OSDN Git Service

lvwLog is now owner-drawn
[winbottle/winbottle.git] / bottleclient / BottleDef.pas
1 unit BottleDef;
2
3 (*
4   \83A\83v\83\8a\83P\81[\83V\83\87\83\93\91S\91Ì\82Å\8eg\82¤\82³\82Ü\82´\82Ü\82È\83f\81[\83^\82ð\92è\8b`
5 *)
6
7 interface
8
9 uses Windows, IniFiles, BRegExp, Graphics, SysUtils, Forms, Dialogs, Classes,
10   ComCtrls, Contnrs;
11
12 type
13   TReturnKeyFunction = (kfYenN, kfReturn, kfYenNReturn, kfConstText);
14   TSoundArrived = (saFalse, saTrue, saParent);
15   TLogWindowPreviewStyle = (psConversation, psScript, psScriptWithLineBreak);
16   TLogListPreviewStyle = (psNormal, psTagStripped);
17   TSurfacePreviewOnScriptPointPosition = (spspMainWindowLeft, spspMainWindowRight);
18
19   //SSTP Bottle\82Ì\90Ý\92è
20   TBottlePrefs = class(TObject)
21   private
22     FIni: TIniFile;
23     //
24     FIgnoreTimeCritical: boolean;
25     FStayOnTop: boolean;
26     FShowConstBar: boolean;
27     FNoConfirm: boolean;
28     FDblClkInsert: boolean;
29     FShowToolBar: boolean;
30     FDefaultScript: TStringList;
31     FTalkColorH: TColor;
32     FMetaWordColor: TColor;
33     FTalkColorU: TColor;
34     FMarkErrorColor: TColor;
35     FMarkUpColor: TColor;
36     FAutoStart: boolean;
37     FCgiName: string;
38     FHomePage: string;
39     FWhenCtrlReturn: TReturnKeyFunction;
40     FWhenShiftReturn: TReturnKeyFunction;
41     FWhenReturn: TReturnKeyFunction;
42     FNoTranslate: boolean;
43     FNoDescript: boolean;
44     FBgColor: TColor;
45     FServerPort: integer;
46     FSilentWhenHidden: boolean;
47     FLUID: String;
48     FSenderWindowPosition: TRect;
49     FTabPosition: TTabPosition;
50     FLogWindowPosition: TRect;
51     FNoTransUrl: boolean;
52     FIgnoreFrequentYenS: boolean;
53     FWaitScriptEnd: integer;
54     FNoSendGhostList: boolean;
55     FCgiNameGhost: String;
56     FGLogPage: String;
57     FVotePage: String;
58     FLogWindowDividerPos: integer;
59     FHelpPage: String;
60     FUseHttpProxy: boolean;
61     FProxyPort: integer;
62     FProxyAddress: String;
63     FConfirmOnExit: boolean;
64     FFixMessySurface: boolean;
65     FResetIfGhostAfterSend: boolean;
66     FGhostDropDownCount: integer;
67     FLogWindowPreviewStyle: TLogWindowPreviewStyle;
68     FCgiFetchLog: String;
69     FTalkColorS: TColor;
70     FLogWindowColumnWidth: String;
71     FClearAfterSend: boolean;
72     FAutoJoinChannels: TStrings;
73     FFMOName: TStrings;
74     FHUTagTo01Tag: boolean;
75     FWarnYenTNotExist: boolean;
76     FWarnScopeChangeInSynchronize: boolean;
77     FNeedConfirmBeforeSend: boolean;
78     FShowRuler: boolean;
79     FHideGhosts: boolean;
80     FVisibleGhostsList: TStringList;
81     FSurfacePreviewOnHint: boolean;
82     FSurfacePreviewOnScriptPoint: boolean;
83     FSurfacePreviewOnScriptPointPosition: TSurfacePreviewOnScriptPointPosition;
84     FNoExtraSSTPHeaders: boolean;
85     FLogListPreviewStyle: TLogListPreviewStyle;
86     procedure SetDblClkInsert(const Value: boolean);
87     procedure SetDefaultScript(const Value: String);
88     procedure SetIgnoreTimeCritical(const Value: boolean);
89     procedure SetMarkErrorColor(const Value: TColor);
90     procedure SetMarkUpColor(const Value: TColor);
91     procedure SetMetaWordColor(const Value: TColor);
92     procedure SetNoConfirm(const Value: boolean);
93     procedure SetShowConstBar(const Value: boolean);
94     procedure SetShowToolBar(const Value: boolean);
95     procedure SetStayOnTop(const Value: boolean);
96     procedure SetTalkColorH(const Value: TColor);
97     procedure SetTalkColorU(const Value: TColor);
98     procedure SetAutoStart(const Value: boolean);
99     procedure SetWhenCtrlReturn(const Value: TReturnKeyFunction);
100     procedure SetWhenReturn(const Value: TReturnKeyFunction);
101     procedure SetWhenShiftReturn(const Value: TReturnKeyFunction);
102     procedure SetNoTranslate(const Value: boolean);
103     procedure SetNoDescript(const Value: boolean);
104     procedure SetBgColor(const Value: TColor);
105     procedure SetServerPort(const Value: integer);
106     procedure SetSilentWhenHidden(const Value: boolean);
107     procedure SetLUID(const Value: String);
108     procedure SetSenderWindowPosition(const Value: TRect);
109     procedure SetTabPosition(const Value: TTabPosition);
110     procedure SetLogWindowPosition(const Value: TRect);
111     procedure SetIgnoreFrequentYenS(const Value: boolean);
112     procedure SetNoTransUrl(const Value: boolean);
113     procedure SetWaitScriptEnd(const Value: integer);
114     procedure SetNoSendGhostList(const Value: boolean);
115     procedure SetLogWindowDividerPos(const Value: integer);
116     procedure SetProxyAddress(const Value: String);
117     procedure SetProxyPort(const Value: integer);
118     procedure SetUseHttpProxy(const Value: boolean);
119     procedure SetConfirmOnExit(const Value: boolean);
120     procedure SetFixMessySurface(const Value: boolean);
121     procedure SetResetIfGhostAfterSend(const Value: boolean);
122     procedure SetGhostDropDownCount(const Value: integer);
123     procedure SetLogWindowPreviewStyle(const Value: TLogWindowPreviewStyle);
124     procedure SetTalkColorS(const Value: TColor);
125     procedure SetLogWindowColumnWidth(const Value: String);
126     procedure SetClearAfterSend(const Value: boolean);
127     procedure SetAutoJoinChannels(const Value: TStrings);
128     procedure SetFMOName(const Value: TStrings);
129     function GetDefaultScript: String;
130     procedure SetHUTagTo01Tag(const Value: boolean);
131     procedure SetWarnScopeChangeInSynchronize(const Value: boolean);
132     procedure SetWarnYenTNotExist(const Value: boolean);
133     procedure SetNeedConfirmBeforeSend(const Value: boolean);
134     procedure SetShowRuler(const Value: boolean);
135     procedure SetHideGhosts(const Value: boolean);
136     procedure SetVisibleGhostsList(const Value: TStringList);
137     procedure SetSurfacePreviewOnHint(const Value: boolean);
138     procedure SetSurfacePreviewOnScriptPoint(const Value: boolean);
139     procedure SetSurfacePreviewOnScriptPointPosition(
140       const Value: TSurfacePreviewOnScriptPointPosition);
141     procedure SetNoExtraSSTPHeaders(const Value: boolean);
142     procedure SetLogListPreviewStyle(const Value: TLogListPreviewStyle);
143   public
144     property NoSendGhostList: boolean read FNoSendGhostList write SetNoSendGhostList;
145     property ConfirmOnExit: boolean read FConfirmOnExit write SetConfirmOnExit;
146     property AutoStart: boolean read FAutoStart write SetAutoStart;
147     property TabPosition: TTabPosition read FTabPosition write SetTabPosition;
148     property GhostDropDownCount: integer read FGhostDropDownCount write SetGhostDropDownCount;
149     property NoTranslate: boolean read FNoTranslate write SetNoTranslate;
150     property NoDescript: boolean read FNoDescript write SetNoDescript;
151     property NoTransUrl: boolean read FNoTransUrl write SetNoTransUrl;
152     property SilentWhenHidden: boolean read FSilentWhenHidden write SetSilentWhenHidden;
153     property FixMessySurface: boolean read FFixMessySurface write SetFixMessySurface;
154     property HUTagTo01Tag: boolean read FHUTagTo01Tag write SetHUTagTo01Tag;
155     property ResetIfGhostAfterSend: boolean read FResetIfGhostAfterSend write SetResetIfGhostAfterSend;
156     property ClearAfterSend: boolean read FClearAfterSend write SetClearAfterSend;
157     property NeedConfirmBeforeSend: boolean read FNeedConfirmBeforeSend write SetNeedConfirmBeforeSend;
158     property IgnoreFrequentYenS: boolean read FIgnoreFrequentYenS write SetIgnoreFrequentYenS;
159     property WarnYenTNotExist: boolean read FWarnYenTNotExist write SetWarnYenTNotExist;
160     property WarnScopeChangeInSynchronize: boolean read FWarnScopeChangeInSynchronize write SetWarnScopeChangeInSynchronize;
161     property WaitScriptEnd: integer read FWaitScriptEnd write SetWaitScriptEnd;
162     property StayOnTop: boolean read FStayOnTop write SetStayOnTop;
163     property IgnoreTimeCritical: boolean read FIgnoreTimeCritical write SetIgnoreTimeCritical;
164     property TalkColorH: TColor read FTalkColorH write SetTalkColorH;
165     property TalkColorU: TColor read FTalkColorU write SetTalkColorU;
166     property TalkColorS: TColor read FTalkColorS write SetTalkColorS;
167     property MarkUpColor: TColor read FMarkUpColor write SetMarkUpColor;
168     property MetaWordColor: TColor read FMetaWordColor write SetMetaWordColor;
169     property MarkErrorColor: TColor read FMarkErrorColor write SetMarkErrorColor;
170     property BgColor: TColor read FBgColor write SetBgColor;
171     property DefaultScript: String read GetDefaultScript write SetDefaultScript;
172     property ShowRuler: boolean read FShowRuler write SetShowRuler;
173     property DblClkInsert: boolean read FDblClkInsert write SetDblClkInsert;
174     property ShowToolBar: boolean read FShowToolBar write SetShowToolBar;
175     property ShowConstBar: boolean read FShowConstBar write SetShowConstBar;
176     property NoConfirm: boolean read FNoConfirm write SetNoConfirm;
177     property HomePage: string read FHomePage;
178     property WhenReturn: TReturnKeyFunction read FWhenReturn write SetWhenReturn;
179     property WhenShiftReturn: TReturnKeyFunction read FWhenShiftReturn write SetWhenShiftReturn;
180     property WhenCtrlReturn: TReturnKeyFunction read FWhenCtrlReturn write SetWhenCtrlReturn;
181     property ServerPort: integer read FServerPort write SetServerPort;
182     //URL\8aÖ\8cW
183     property CgiName: string read FCgiName;
184     property CgiNameGhost: String read FCgiNameGhost;
185     property CgiFetchLog: String read FCgiFetchLog;
186     property GLogPage: String read FGLogPage;
187     property VotePage: String read FVotePage;
188     property HelpPage: String read FHelpPage;
189
190     //\83`\83\83\83\93\83l\83\8b\8aÖ\8cW
191     property AutoJoinChannels: TStrings read FAutoJoinChannels write SetAutoJoinChannels;
192
193     property LUID: String read FLUID write SetLUID;
194
195     //\83E\83B\83\93\83h\83E\88Ê\92u
196     property SenderWindowPosition: TRect
197       read FSenderWindowPosition write SetSenderWindowPosition;
198     property LogWindowPosition: TRect read FLogWindowPosition write SetLogWindowPosition;
199     property LogWindowDividerPos: integer
200       read FLogWindowDividerPos write SetLogWindowDividerPos;
201     property LogWindowColumnWidth: String
202       read FLogWindowColumnWidth write SetLogWindowColumnWidth;
203     //\83v\83\8d\83L\83V\8aÖ\8cW
204     property UseHttpProxy: boolean read FUseHttpProxy write SetUseHttpProxy;
205     property ProxyAddress: String read FProxyAddress write SetProxyAddress;
206     property ProxyPort: integer read FProxyPort write SetProxyPort;
207     //\83\8d\83O\83E\83B\83\93\83h\83E\8aÖ\8cW
208     property LogWindowPreviewStyle: TLogWindowPreviewStyle
209       read FLogWindowPreviewStyle write SetLogWindowPreviewStyle;
210     property LogListPreviewStyle: TLogListPreviewStyle
211       read FLogListPreviewStyle write SetLogListPreviewStyle;
212     //\8fÚ\8d×\90Ý\92è
213     property FMOName: TStrings read FFMOName write SetFMOName;
214     property HideGhosts: boolean read FHideGhosts write SetHideGhosts;
215     property VisibleGhostsList: TStringList read FVisibleGhostsList write SetVisibleGhostsList;
216     property NoExtraSSTPHeaders: boolean read FNoExtraSSTPHeaders write SetNoExtraSSTPHeaders;
217     //\83T\81[\83t\83B\83X\83v\83\8c\83r\83\85\81[
218     property SurfacePreviewOnHint: boolean
219       read FSurfacePreviewOnHint write SetSurfacePreviewOnHint;
220     property SurfacePreviewOnScriptPoint: boolean
221       read FSurfacePreviewOnScriptPoint write SetSurfacePreviewOnScriptPoint;
222     property SurfacePreviewOnScriptPointPosition: TSurfacePreviewOnScriptPointPosition
223       read FSurfacePreviewOnScriptPointPosition write SetSurfacePreviewOnScriptPointPosition;
224     //\83R\83\93\83X\83g\83\89\83N\83^\81E\83f\83X\83g\83\89\83N\83^\81E\95Û\91
225     constructor Create;
226     destructor Destroy; override;
227     procedure SaveSettings;
228   end;
229
230   TChannelListItem = class(TObject)
231   private
232     FMembers: integer;
233     FGhost: String;
234     FInfo: String;
235     FName: String;
236     FNoPost: boolean;
237     FWarnPost: boolean;
238     procedure SetGhost(const Value: String);
239     procedure SetInfo(const Value: String);
240     procedure SetMembers(const Value: integer);
241     procedure SetName(const Value: String);
242     procedure SetNoPost(const Value: boolean);
243     procedure SetWarnPost(const Value: boolean);
244   public
245     property Name: String read FName write SetName;
246     property Info: String read FInfo write SetInfo;
247     property Ghost: String read FGhost write SetGhost;
248     property Members: integer read FMembers write SetMembers;
249     property NoPost: boolean read FNoPost write SetNoPost;
250     property WarnPost: boolean read FWarnPost write SetWarnPost;
251   end;
252
253   TChannelList = class(TList)
254   private
255     function GetChannel(Name: String): TChannelListItem;
256     function GetChannelItem(Index: integer): TChannelListItem;
257   public
258     procedure Clear; override;
259     property Channel[Name: String]: TChannelListItem read GetChannel;
260     property ChannelItem[Index: integer]: TChannelListItem read GetChannelItem;
261   end;
262
263   TScriptTransOption = (
264     toIgnoreTimeCritical,
265     toConvertURL,
266     toNoChoice,
267     toIgnoreFrequentYenS,
268     toWaitScriptEnd,
269     toFixMessySurface,
270     toWarnMessySurface,
271     toHUTagTo01Tag,
272     toWarnCheck
273   );
274
275   TScriptTransOptions = set of TScriptTransOption;
276
277 var
278   RegExp: TBRegExp;
279   Pref: TBottlePrefs;
280   ChannelList: TChannelList; //\83`\83\83\83\93\83l\83\8b\83\8a\83X\83g\82ð\95Û\8e\9d\82·\82é
281   JoinChannels: TStringList; // \8c»\8dÝ\8eQ\89Á\82µ\82Ä\82¢\82é\83`\83\83\83\93\83l\83\8b
282
283 const
284   BottleServerTimeOut = 400000; // \83^\83C\83\80\83A\83E\83g\82·\82é\82Ü\82Å\82Ì\8e\9e\8aÔ
285
286   BottleServer    = 'bottle.mikage.to';
287   DefaultCGI      = '/bottle2.cgi';
288   DefaultCGIGhost = '/glog/bottleglog.cgi';
289   DefaultCGIFetchLog = '/fetchlog.cgi';
290
291
292   DefaultHomePage = 'http://bottle.mikage.to/';
293   DefaultGLogPage = 'http://bottle.mikage.to/glog/glogview.cgi';
294   DefaultVotePage = 'http://bottle.mikage.to/viewvotes.cgi';
295   DefaultHelpPage = 'http://bottle.mikage.to/clihelp/';
296
297   Version = '2.51.1';
298
299   {$IFDEF NOMUTEX}
300   VersionString = 'SSTP Bottle Client ver ' + Version + 'a NO MUTEX VERSION';
301   {$ELSE}
302   VersionString = 'SSTP Bottle Client ver ' + Version;
303   {$ENDIF}
304
305   SentLogFile     = 'sent.log';
306
307   BottleDisclaimer = '(C)2001 - 2003 naru/Mikage Sawatari'#13#10 +
308     DefaultHomePage;
309
310 implementation
311
312 { TBottlePrefs }
313
314 constructor TBottlePrefs.Create;
315 var ARect, Dum: TRect;
316 begin
317   FAutoJoinChannels := TStringList.Create;
318   FDefaultScript := TStringList.Create;
319   FFMOName := TStringList.Create;
320   FVisibleGhostsList := TStringList.Create;
321   try
322     FIni := TIniFile.Create(ChangeFileExt(Application.ExeName, '.ini'));
323     //
324     NoSendGhostList := FIni.ReadBool('System', 'NoSendGhostList', false);
325     ConfirmOnExit := FIni.ReadBool('System', 'ConfirmOnExit', false);
326     AutoStart := FIni.ReadBool('System', 'AutoStart', false);
327     TabPosition := TTabPosition(FIni.ReadInteger('System', 'TabPosition', 0));
328     GhostDropDownCount := FIni.ReadInteger('System', 'GhostDropDownCount', 30);
329
330     NoTranslate := FIni.ReadBool('System', 'NoTranslate', true);
331     NoDescript := FIni.ReadBool('System', 'NoDescript', false);
332     NoTransUrl := FIni.ReadBool('System', 'NoTransUrl', false);
333     SilentWhenHidden:= FIni.ReadBool('System', 'SilentWhenHidden', true);
334     FixMessySurface := FIni.ReadBool('System', 'FixMessySurface', false);
335     HUTagTo01Tag := FIni.ReadBool('System', 'HUTagTo01Tag', false);
336     ResetIfGhostAfterSend := FIni.ReadBool('System', 'ResetIfGhostAfterSend', false);
337     ClearAfterSend := FIni.ReadBool('System', 'ClearAfterSend', false);
338     NeedConfirmBeforeSend := FIni.ReadBool('System', 'NeedConfirmBeforeSend', false);
339     WarnYenTNotExist := FIni.ReadBool('System', 'WarnYenTNotExist', false);
340     WarnScopeChangeInSynchronize := FIni.ReadBool('System', 'WarnScopeChangeInSynchronize', false);
341
342     IgnoreFrequentYenS := FIni.ReadBool('System', 'IgnoreFrequentYenS', false);
343     WaitScriptEnd := FIni.ReadInteger('System', 'WaitScriptEnd', 0);
344     StayOnTop := FIni.ReadBool('System', 'StayOnTop', false);
345     ShowConstBar := FIni.ReadBool('System', 'ShowConstBar', true);
346     ShowToolBar := FIni.ReadBool('System', 'ShowToolBar', true);
347     NoConfirm := FIni.ReadBool('System', 'NoConfirm', false);
348     IgnoreTimeCritical := FIni.ReadBool('System', 'IgnoreTimeCritical', false);
349     FDefaultScript.CommaText := FIni.ReadString('System', 'DefaultScript', '\t\h\s[0]|\e');
350     ShowRuler := FIni.ReadBool('System', 'ShowRuler', false);
351     //
352     try
353       TalkColorH := StringToColor(FIni.ReadString('System', 'TalkColorH', 'clBlack'));
354       TalkColorU := StringToColor(FIni.ReadString('System', 'TalkColorU', 'clMaroon'));
355       TalkColorS := StringToColor(FIni.ReadString('System', 'TalkColorS', 'clPurple'));
356       MarkUpColor := StringToColor(FIni.ReadString('System', 'MarkUpColor', 'clGreen'));
357       MetaWordColor := StringToColor(FIni.ReadString('System', 'MetaWordColor', 'clBlue'));
358       MarkErrorColor := StringToColor(FIni.ReadString('System', 'MarkErrorColor', 'clRed'));
359       BgColor := StringToColor(FIni.ReadString('System', 'BgColor', 'clWhite'));
360     except
361       on EConvertError do begin
362         ShowMessage('\83J\83\89\81[\82Ì\90Ý\92è\93Ç\82Ý\8d\9e\82Ý\83G\83\89\81[\82Å\82·\81B');
363         TalkColorH := clBlack;
364         TalkColorU := clMaroon;
365         MarkUpColor := clGreen;
366         MetaWordColor := clBlue;
367         FMarkErrorColor := clRed;
368       end;
369     end;
370
371     WhenReturn      := TReturnKeyFunction(FIni.ReadInteger('System', 'WhenReturn', 0));
372     WhenShiftReturn := TReturnKeyFunction(FIni.ReadInteger('System', 'WhenShiftReturn', 0));
373     WhenCtrlReturn  := TReturnKeyFunction(FIni.ReadInteger('System', 'WhenCtrlReturn', 0));
374     //\83\\83P\83b\83g\82ð\83{\83g\83\8b\94z\91\97\82ÌSSTP\92Ê\90M\82É\8eg\97p\82·\82é\8fê\8d\87\82Ì\90Ý\92è
375     ServerPort      := FIni.ReadInteger('System', 'ServerPort', 11000);
376
377     FCgiName  := FIni.ReadString('System', 'CgiName', DefaultCGI);
378     FCgiFetchLog := FIni.ReadString('System', 'CgiFetchLog', DefaultCGIFetchLog);
379     FHomePage := FIni.ReadString('System', 'HomePage', DefaultHomePage);
380     FGLogPage := FIni.ReadString('System', 'GLogPage', DefaultGLogPage);
381     FVotePage := FIni.ReadString('System', 'VotePage', DefaultVotePage);
382     FHelpPage := FIni.ReadString('System', 'HelpPage', DefaultHelpPage);
383     FCgiNameGhost := FIni.ReadString('System', 'GHOST', DefaultCGIGhost);
384     FLUID     := FIni.ReadString('System', 'LUID', '');
385     FAutoJoinChannels.CommaText := FIni.ReadString('System', 'AutoJoinChannels', '');
386     //
387     ARect.Top    := FIni.ReadInteger('System', 'SenderWindowPositionTop', 100);
388     ARect.Left   := FIni.ReadInteger('System', 'SenderWindowPositionLeft', 100);
389     ARect.Bottom := FIni.ReadInteger('System', 'SenderWindowPositionBottom', 500);
390     ARect.Right  := FIni.ReadInteger('System', 'SenderWindowPositionRight', 500);
391     if not IntersectRect(Dum, Rect(0, 0, Screen.Width, Screen.Height), ARect) then
392       ARect := Rect(100, 100, 500, 500);
393     SenderWindowPosition := ARect;
394     ARect.Top    := FIni.ReadInteger('System', 'LogWindowPositionTop', 200);
395     ARect.Left   := FIni.ReadInteger('System', 'LogWindowPositionLeft', 200);
396     ARect.Bottom := FIni.ReadInteger('System', 'LogWindowPositionBottom', 600);
397     ARect.Right  := FIni.ReadInteger('System', 'LogWindowPositionRight', 400);
398     LogWindowDividerPos := FIni.ReadInteger('System', 'LogWindowDividerPos', 150);
399     LogWindowColumnWidth := FIni.ReadString('System', 'LogWindowColumnWidth', '');
400     if not IntersectRect(Dum, Rect(0, 0, Screen.Width, Screen.Height), ARect) then begin
401       ARect := Rect(200, 200, 600, 400);
402       LogWindowDividerPos := 150;
403     end;
404     LogWindowPosition := ARect;
405     //
406     UseHttpProxy := FIni.ReadBool('System', 'UseHttpProxy', false);
407     ProxyAddress := FIni.ReadString('System', 'ProxyAddress', '');
408     ProxyPort    := FIni.ReadInteger('System', 'ProxyPort', 0);
409     //\83\8d\83O\83E\83B\83\93\83h\83E\8aÖ\8cW
410     LogWindowPreviewStyle := TLogWindowPreviewStyle(
411       FIni.ReadInteger('System', 'LogWindowPreviewStyle', 0));
412     LogListPreviewStyle := TLogListPreviewStyle(
413       FIni.ReadInteger('System', 'LogListPreviewStyle', 0));
414     //\8fÚ\8d×
415     FMOName.CommaText := FIni.ReadString('System', 'FMOName', 'Sakura');
416     HideGhosts := FIni.ReadBool('System', 'HideGhosts', false);
417     VisibleGhostsList.CommaText := FIni.ReadString('System', 'VisibleGhostsList', '');
418     NoExtraSSTPHeaders := FIni.ReadBool('System', 'NoExtraSSTPHeaders', false);
419     //\83T\81[\83t\83B\83X\83v\83\8c\83r\83\85\81[
420     SurfacePreviewOnHint := FIni.ReadBool('System', 'SurfacePreviewOnHint', false);
421     SurfacePreviewOnScriptPoint := FIni.ReadBool('System', 'SurfacePreviewOnScriptPoint', false);
422     SurfacePreviewOnScriptPointPosition :=
423       TSurfacePreviewOnScriptPointPosition(FIni.ReadInteger('System', 'SurfacePreviewOnScriptPointPosition', 0));
424   except
425     ShowMessage('INI\83t\83@\83C\83\8b\93Ç\82Ý\8d\9e\82Ý\83G\83\89\81[');
426     Application.Terminate;
427   end;
428 end;
429
430 destructor TBottlePrefs.Destroy;
431 begin
432   inherited;
433   SaveSettings;
434   if FIni <> nil then
435     FIni.Free;
436   if FAutoJoinChannels <> nil then
437     FAutoJoinChannels.Free;
438   if FDefaultScript <> nil then
439     FDefaultScript.Free;
440   if FFMOName <> nil then
441     FFMOName.Free;
442   if FVisibleGhostsList <> nil then
443     FVisibleGhostsList.Free;
444 end;
445
446 procedure TBottlePrefs.SetAutoStart(const Value: boolean);
447 begin
448   FAutoStart := Value;
449 end;
450
451 procedure TBottlePrefs.SetBgColor(const Value: TColor);
452 begin
453   FBgColor := Value;
454 end;
455
456 procedure TBottlePrefs.SetConfirmOnExit(const Value: boolean);
457 begin
458   FConfirmOnExit := Value;
459 end;
460
461 procedure TBottlePrefs.SetDblClkInsert(const Value: boolean);
462 begin
463   FDblClkInsert := Value;
464 end;
465
466 procedure TBottlePrefs.SetDefaultScript(const Value: String);
467 begin
468   FDefaultScript.Text := Value;
469 end;
470
471 procedure TBottlePrefs.SetFixMessySurface(const Value: boolean);
472 begin
473   FFixMessySurface := Value;
474 end;
475
476 procedure TBottlePrefs.SetGhostDropDownCount(const Value: integer);
477 begin
478   FGhostDropDownCount := Value;
479 end;
480
481 procedure TBottlePrefs.SetIgnoreFrequentYenS(const Value: boolean);
482 begin
483   FIgnoreFrequentYenS := Value;
484 end;
485
486 procedure TBottlePrefs.SetIgnoreTimeCritical(const Value: boolean);
487 begin
488   FIgnoreTimeCritical := Value;
489 end;
490
491 procedure TBottlePrefs.SetLogWindowDividerPos(const Value: integer);
492 begin
493   FLogWindowDividerPos := Value;
494 end;
495
496 procedure TBottlePrefs.SetLogWindowPosition(const Value: TRect);
497 begin
498   FLogWindowPosition := Value;
499 end;
500
501 procedure TBottlePrefs.SetLUID(const Value: String);
502 begin
503   FLUID := Value;
504 end;
505
506 procedure TBottlePrefs.SetMarkErrorColor(const Value: TColor);
507 begin
508   FMarkErrorColor := Value;
509 end;
510
511 procedure TBottlePrefs.SetMarkUpColor(const Value: TColor);
512 begin
513   FMarkUpColor := Value;
514 end;
515
516 procedure TBottlePrefs.SetMetaWordColor(const Value: TColor);
517 begin
518   FMetaWordColor := Value;
519 end;
520
521 procedure TBottlePrefs.SetNoConfirm(const Value: boolean);
522 begin
523   FNoConfirm := Value;
524 end;
525
526 procedure TBottlePrefs.SetNoDescript(const Value: boolean);
527 begin
528   FNoDescript := Value;
529 end;
530
531 procedure TBottlePrefs.SetNoSendGhostList(const Value: boolean);
532 begin
533   FNoSendGhostList := Value;
534 end;
535
536 procedure TBottlePrefs.SetNoTranslate(const Value: boolean);
537 begin
538   FNoTranslate := Value;
539 end;
540
541 procedure TBottlePrefs.SetNoTransUrl(const Value: boolean);
542 begin
543   FNoTransUrl := Value;
544 end;
545
546 procedure TBottlePrefs.SetLogWindowPreviewStyle(
547   const Value: TLogWindowPreviewStyle);
548 begin
549   FLogWindowPreviewStyle := Value;
550 end;
551
552 procedure TBottlePrefs.SetProxyAddress(const Value: String);
553 begin
554   FProxyAddress := Value;
555 end;
556
557 procedure TBottlePrefs.SetProxyPort(const Value: integer);
558 begin
559   FProxyPort := Value;
560 end;
561
562 procedure TBottlePrefs.SetResetIfGhostAfterSend(const Value: boolean);
563 begin
564   FResetIfGhostAfterSend := Value;
565 end;
566
567 procedure TBottlePrefs.SetSenderWindowPosition(const Value: TRect);
568 begin
569   FSenderWindowPosition := Value;
570 end;
571
572 procedure TBottlePrefs.SetServerPort(const Value: integer);
573 begin
574   if Value > 0 then FServerPort := Value;
575 end;
576
577 procedure TBottlePrefs.SetShowConstBar(const Value: boolean);
578 begin
579   FShowConstBar := Value;
580 end;
581
582 procedure TBottlePrefs.SetShowToolBar(const Value: boolean);
583 begin
584   FShowToolBar := Value;
585 end;
586
587 procedure TBottlePrefs.SetSilentWhenHidden(const Value: boolean);
588 begin
589   FSilentWhenHidden := Value;
590 end;
591
592 procedure TBottlePrefs.SetStayOnTop(const Value: boolean);
593 begin
594   FStayOnTop := Value;
595 end;
596
597 procedure TBottlePrefs.SetTabPosition(const Value: TTabPosition);
598 begin
599   FTabPosition := Value;
600 end;
601
602 procedure TBottlePrefs.SetTalkColorH(const Value: TColor);
603 begin
604   FTalkColorH := Value;
605 end;
606
607 procedure TBottlePrefs.SetTalkColorU(const Value: TColor);
608 begin
609   FTalkColorU := Value;
610 end;
611
612 procedure TBottlePrefs.SetUseHttpProxy(const Value: boolean);
613 begin
614   FUseHttpProxy := Value;
615 end;
616
617 procedure TBottlePrefs.SetWaitScriptEnd(const Value: integer);
618 begin
619   if Value > 0 then FWaitScriptEnd := Value;
620 end;
621
622 procedure TBottlePrefs.SetWhenCtrlReturn(const Value: TReturnKeyFunction);
623 begin
624   FWhenCtrlReturn := Value;
625 end;
626
627 procedure TBottlePrefs.SetWhenReturn(const Value: TReturnKeyFunction);
628 begin
629   FWhenReturn := Value;
630 end;
631
632 procedure TBottlePrefs.SetWhenShiftReturn(const Value: TReturnKeyFunction);
633 begin
634   FWhenShiftReturn := Value;
635 end;
636
637 procedure TBottlePrefs.SetTalkColorS(const Value: TColor);
638 begin
639   FTalkColorS := Value;
640 end;
641
642 procedure TBottlePrefs.SetLogWindowColumnWidth(const Value: String);
643 begin
644   FLogWindowColumnWidth := Value;
645 end;
646
647 procedure TBottlePrefs.SetClearAfterSend(const Value: boolean);
648 begin
649   FClearAfterSend := Value;
650 end;
651
652 procedure TBottlePrefs.SetAutoJoinChannels(const Value: TStrings);
653 begin
654   FAutoJoinChannels.Assign(Value);
655 end;
656
657 procedure TBottlePrefs.SetFMOName(const Value: TStrings);
658 begin
659   FFMOName.Assign(Value);
660 end;
661
662 procedure TBottlePrefs.SaveSettings;
663 begin
664   FIni.WriteBool('System', 'NoSendGhostList', NoSendGhostList);
665   FIni.WriteBool('System', 'ConfirmOnExit', ConfirmOnExit);
666   FIni.WriteBool('System', 'AutoStart', AutoStart);
667   FIni.WriteInteger('System', 'TabPosition', Ord(TabPosition));
668   FIni.WriteInteger('System', 'GhostDropDownCount', GhostDropDownCount);
669
670   FIni.WriteBool('System', 'NoTranslate', NoTranslate);
671   FIni.WriteBool('System', 'NoDescript', NoDescript);
672   FIni.WriteBool('System', 'NoTransUrl', NoTransUrl);
673   FIni.WriteBool('System', 'SilentWhenHidden', SilentWhenHidden);
674   FIni.WriteBool('System', 'FixMessySurface', FixMessySurface);
675   FIni.WriteBool('System', 'HUTagTo01Tag', HUTagTo01Tag);
676   FIni.WriteBool('System', 'ResetIfGhostAfterSend', ResetIfGhostAfterSend);
677   FIni.WriteBool('System', 'ClearAfterSend', ClearAfterSend);
678   FIni.WriteBool('System', 'NeedConfirmBeforeSend', NeedConfirmBeforeSend);
679   FIni.WriteBool('System', 'WarnYenTNotExist', WarnYenTNotExist);
680   FIni.WriteBool('System', 'WarnScopeChangeInSynchronize', WarnScopeChangeInSynchronize);
681
682   FIni.WriteBool('System', 'IgnoreFrequentYenS', IgnoreFrequentYenS);
683   FIni.WriteInteger('System', 'WaitScriptEnd', WaitScriptEnd);
684   FIni.WriteBool('System', 'StayOnTop', StayOnTop);
685   FIni.WriteBool('System', 'NoConfirm', NoConfirm);
686   FIni.WriteBool('System', 'IgnoreTimeCritical', IgnoreTimeCritical);
687   FIni.WriteString('System', 'TalkColorH',     ColorToString(TalkColorH));
688   FIni.WriteString('System', 'TalkColorU',     ColorToString(TalkColorU));
689   FIni.WriteString('System', 'TalkColorS',     ColorToString(TalkColorS));
690   FIni.WriteString('System', 'MarkUpColor',    ColorToString(MarkUpColor));
691   FIni.WriteString('System', 'MetaWordColor',  ColorToString(MetaWordColor));
692   FIni.WriteString('System', 'MarkErrorColor', ColorToString(MarkErrorColor));
693   FIni.WriteString('System', 'BgColor', ColorToString(BgColor));
694   FIni.WriteBool('System', 'ShowToolBar', ShowToolBar);
695   FIni.WriteBool('System', 'ShowConstBar', ShowConstBar);
696   FIni.WriteString('System', 'DefaultScript', FDefaultScript.CommaText);
697   FIni.WriteBool('System', 'ShowRuler', ShowRuler);
698   FIni.WriteInteger('System', 'WhenReturn', Ord(WhenReturn));
699   FIni.WriteInteger('System', 'WhenShiftReturn', Ord(WhenShiftReturn));
700   FIni.WriteInteger('System', 'WhenCtrlReturn', Ord(WhenCtrlReturn));
701   FIni.WriteInteger('System', 'ServerPort', ServerPort);
702   FIni.WriteString('System', 'LUID', LUID);
703   FIni.WriteString('System', 'AutoJoinChannels', FAutoJoinChannels.CommaText);
704   //
705   FIni.WriteInteger('System', 'SenderWindowPositionLeft', SenderWindowPosition.Left);
706   FIni.WriteInteger('System', 'SenderWindowPositionTop', SenderWindowPosition.Top);
707   FIni.WriteInteger('System', 'SenderWindowPositionRight', SenderWindowPosition.Right);
708   FIni.WriteInteger('System', 'SenderWindowPositionBottom', SenderWindowPosition.Bottom);
709   FIni.WriteInteger('System', 'LogWindowPositionLeft', LogWindowPosition.Left);
710   FIni.WriteInteger('System', 'LogWindowPositionTop', LogWindowPosition.Top);
711   FIni.WriteInteger('System', 'LogWindowPositionRight', LogWindowPosition.Right);
712   FIni.WriteInteger('System', 'LogWindowPositionBottom', LogWindowPosition.Bottom);
713   FIni.WriteInteger('System', 'LogWindowDividerPos', LogWindowDividerPos);
714   FIni.WriteString('System', 'LogWindowColumnWidth', LogWindowColumnWidth);
715   //
716   FIni.WriteBool('System', 'UseHttpProxy', UseHttpProxy);
717   FIni.WriteString('System', 'ProxyAddress', ProxyAddress);
718   FIni.WriteInteger('System', 'ProxyPort', ProxyPort);
719   //
720   FIni.WriteInteger('System', 'LogWindowPreviewStyle', Ord(LogWindowPreviewStyle));
721   FIni.WriteInteger('System', 'LogListPreviewStyle', Ord(LogListPreviewStyle));
722   FIni.WriteString('System', 'FMOName', FFMOName.CommaText);
723   FIni.WriteBool('System', 'HideGhosts', HideGhosts);
724   FIni.WriteString('System', 'VisibleGhostsList', VisibleGhostsList.CommaText);
725   FIni.WriteBool('System', 'NoExtraSSTPHeaders', NoExtraSSTPHeaders);
726   //
727   FIni.WriteBool('System', 'SurfacePreviewOnHint', SurfacePreviewOnHint);
728   FIni.WriteBool('System', 'SurfacePreviewOnScriptPoint', SurfacePreviewOnScriptPoint);
729   FIni.WriteInteger('System', 'SurfacePreviewOnScriptPointPosition', Ord(SurfacePreviewOnScriptPointPosition));
730 end;
731
732 function TBottlePrefs.GetDefaultScript: String;
733 begin
734   Result := FDefaultScript.Text;
735 end;
736
737 procedure TBottlePrefs.SetHUTagTo01Tag(const Value: boolean);
738 begin
739   FHUTagTo01Tag := Value;
740 end;
741
742 procedure TBottlePrefs.SetWarnScopeChangeInSynchronize(
743   const Value: boolean);
744 begin
745   FWarnScopeChangeInSynchronize := Value;
746 end;
747
748 procedure TBottlePrefs.SetWarnYenTNotExist(const Value: boolean);
749 begin
750   FWarnYenTNotExist := Value;
751 end;
752
753 procedure TBottlePrefs.SetNeedConfirmBeforeSend(const Value: boolean);
754 begin
755   FNeedConfirmBeforeSend := Value;
756 end;
757
758 procedure TBottlePrefs.SetShowRuler(const Value: boolean);
759 begin
760   FShowRuler := Value;
761 end;
762
763 procedure TBottlePrefs.SetHideGhosts(const Value: boolean);
764 begin
765   FHideGhosts := Value;
766 end;
767
768 procedure TBottlePrefs.SetVisibleGhostsList(const Value: TStringList);
769 begin
770   FVisibleGhostsList.Assign(Value);
771 end;
772
773 procedure TBottlePrefs.SetSurfacePreviewOnHint(const Value: boolean);
774 begin
775   FSurfacePreviewOnHint := Value;
776 end;
777
778 procedure TBottlePrefs.SetSurfacePreviewOnScriptPoint(
779   const Value: boolean);
780 begin
781   FSurfacePreviewOnScriptPoint := Value;
782 end;
783
784 procedure TBottlePrefs.SetSurfacePreviewOnScriptPointPosition(
785   const Value: TSurfacePreviewOnScriptPointPosition);
786 begin
787   FSurfacePreviewOnScriptPointPosition := Value;
788 end;
789
790 procedure TBottlePrefs.SetNoExtraSSTPHeaders(const Value: boolean);
791 begin
792   FNoExtraSSTPHeaders := Value;
793 end;
794
795 procedure TBottlePrefs.SetLogListPreviewStyle(
796   const Value: TLogListPreviewStyle);
797 begin
798   FLogListPreviewStyle := Value;
799 end;
800
801 { TChannelListItem }
802
803 procedure TChannelListItem.SetGhost(const Value: String);
804 begin
805   FGhost := Value;
806 end;
807
808 procedure TChannelListItem.SetInfo(const Value: String);
809 begin
810   FInfo := Value;
811 end;
812
813 procedure TChannelListItem.SetMembers(const Value: integer);
814 begin
815   FMembers := Value;
816 end;
817
818 procedure TChannelListItem.SetName(const Value: String);
819 begin
820   FName := Value;
821 end;
822
823 procedure TChannelListItem.SetNoPost(const Value: boolean);
824 begin
825   FNoPost := Value;
826 end;
827
828 procedure TChannelListItem.SetWarnPost(const Value: boolean);
829 begin
830   FWarnPost := Value;
831 end;
832
833 { TChannelList }
834
835 procedure TChannelList.Clear;
836 var i: integer;
837 begin
838   for i := Self.Count-1 downto 0 do begin
839     TChannelListItem(Self[i]).Free;
840   end;
841   inherited;
842 end;
843
844 function TChannelList.GetChannel(Name: String): TChannelListItem;
845 var i: integer;
846 begin
847   Result := nil;
848   for i := 0 to Count-1 do
849     if TChannelListItem(Self[i]).Name = Name then begin
850       Result := TChannelListItem(Self[i]);
851       Exit;
852     end;
853 end;
854
855 function TChannelList.GetChannelItem(Index: integer): TChannelListItem;
856 begin
857   Result := TChannelListItem(Self[Index]);
858 end;
859
860 initialization
861
862 try
863   RegExp := TBRegExp.Create;
864 except
865   ShowMessage('RegExp\8aJ\8en\83G\83\89\81[');
866   Application.Terminate;
867 end;
868 Pref := TBottlePrefs.Create;
869 ChannelList := TChannelList.Create;
870 JoinChannels := TStringList.Create;
871
872 finalization
873
874 Pref.Free;
875 RegExp.Free;
876 ChannelList.Clear;
877 JoinChannels.Free;
878 ChannelList.Free;
879
880 end.