OSDN Git Service

板トップなどの表示設定を保存できるようにしました
[gikonavigoeson/gikonavi.git] / Editor.pas
1 unit Editor;
2
3 interface
4
5 uses
6         Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
7         Dialogs, StdCtrls, ComCtrls, ExtCtrls, ToolWin, Menus, OleCtrls, Registry,
8 {$IF Defined(DELPRO) }
9         SHDocVw,
10 {$ELSE}
11         SHDocVw_TLB,
12 {$IFEND}
13         ActiveX, {HTTPApp,} YofUtils, Trip, IniFiles, StrUtils,
14         GikoSystem, GikoUtil, ImgList, Clipbrd, BoardGroup,
15         IdAntiFreezeBase,       IdAntiFreeze, IdBaseComponent, IdComponent,
16         IdTCPConnection, IdTCPClient, IdHTTP, ActnList, StdActns, IdIntercept,
17         IdLogBase, IdLogDebug, IdException, DateUtils, MojuUtils, bmRegExp;
18
19 type
20 //      TSetLayeredWindowAttributes = function(wnd: HWND; crKey: DWORD; bAlpha: BYTE; dwFlag: DWORD): Boolean; stdcall;
21         //\8f\91\82«\8d\9e\82Ý\96ß\82è\92l\83^\83C\83v
22         TGikoResultType = (grtOK, grtCookie, grtCheck, grtError);
23
24         TEditorForm = class(TForm)
25                 MainMenu: TMainMenu;
26                 FileMenu: TMenuItem;
27                 PostMessage: TMenuItem;
28                 SaveMessage: TMenuItem;
29                 CloseMenu: TMenuItem;
30                 N01: TMenuItem;
31                 StatusBar: TStatusBar;
32                 EditorPage: TPageControl;
33                 EditorTab: TTabSheet;
34                 PreviewTab: TTabSheet;
35                 Browser: TWebBrowser;
36                 EditMenu: TMenuItem;
37                 UndoMenu: TMenuItem;
38                 CutMenu: TMenuItem;
39                 CopyMenu: TMenuItem;
40                 PasteMenu: TMenuItem;
41                 N02: TMenuItem;
42                 ToolBarImageList: TImageList;
43                 HotToobarImageList: TImageList;
44                 BodyEdit: TMemo;
45                 NameBasePanel: TPanel;
46                 NameLabel: TLabel;
47                 MailLabel: TLabel;
48                 NameComboBox: TComboBox;
49                 MailComboBox: TComboBox;
50                 ToolBar: TToolBar;
51                 SendToolButton: TToolButton;
52                 OutBoxToolButton: TToolButton;
53                 ToolButton5: TToolButton;
54                 UndoToolButton: TToolButton;
55                 CutToolButton: TToolButton;
56                 CopyToolButton: TToolButton;
57                 PasteToolButton: TToolButton;
58                 ToolButton3: TToolButton;
59                 TransToolButton: TToolButton;
60                 TopToolButton: TToolButton;
61                 Indy: TIdHTTP;
62                 IdAntiFreeze: TIdAntiFreeze;
63                 ToolButton1: TToolButton;
64                 ToolButton2: TToolButton;
65                 ActionList: TActionList;
66                 SendAction: TAction;
67                 SaveAction: TAction;
68                 CloseAction: TAction;
69                 UndoAction: TAction;
70                 CutAction: TAction;
71                 CopyAction: TAction;
72                 PasteAction: TAction;
73                 AbortAction: TAction;
74                 TopAction: TAction;
75                 Show1: TMenuItem;
76                 T1: TMenuItem;
77                 N1: TMenuItem;
78                 S1: TMenuItem;
79                 SageCheckBox: TCheckBox;
80                 IdLogDebug: TIdLogDebug;
81                 TransAction: TAction;
82                 A1: TMenuItem;
83                 KotehanCheckBox: TCheckBox;
84                 TitlePanel: TPanel;
85                 Label1: TLabel;
86                 TitleEdit: TEdit;
87                 SelectAllAction: TAction;
88                 N2: TMenuItem;
89                 SelectAll1: TMenuItem;
90     Timer1: TTimer;
91     QuotePasteAction: TAction;
92     QuotePasteMenuItem: TMenuItem;
93     C1: TMenuItem;
94     SpaceToNBSPAction: TAction;
95     AmpToCharRefAction: TAction;
96     SpaceTabnbsp1: TMenuItem;
97     amp1: TMenuItem;
98     SETTINGTab: TTabSheet; 
99                 Browser1: TWebBrowser;
100                 BoardtopTab: TTabSheet;
101                 Browser2: TWebBrowser;
102     HEADTab: TTabSheet;
103     Browser3: TWebBrowser;
104     SETTINGTXT1: TMenuItem;
105     HEADTXT1: TMenuItem;
106     BoardTop: TMenuItem;
107
108                 procedure EditorPageChange(Sender: TObject);
109                 procedure FormCreate(Sender: TObject);
110                 procedure BrowserStatusTextChange(Sender: TObject;
111                         const Text: WideString);
112                 procedure FormClose(Sender: TObject; var Action: TCloseAction);
113                 procedure FormDestroy(Sender: TObject);
114                 procedure SendActionExecute(Sender: TObject);
115                 procedure SaveActionExecute(Sender: TObject);
116                 procedure AbortActionExecute(Sender: TObject);
117                 procedure CloseActionExecute(Sender: TObject);
118                 procedure UndoActionExecute(Sender: TObject);
119                 procedure CutActionExecute(Sender: TObject);
120                 procedure CopyActionExecute(Sender: TObject);
121                 procedure PasteActionExecute(Sender: TObject);
122                 procedure SendActionUpdate(Sender: TObject);
123                 procedure SaveActionUpdate(Sender: TObject);
124                 procedure CloseActionUpdate(Sender: TObject);
125                 procedure UndoActionUpdate(Sender: TObject);
126                 procedure CutActionUpdate(Sender: TObject);
127                 procedure CopyActionUpdate(Sender: TObject);
128                 procedure PasteActionUpdate(Sender: TObject);
129                 procedure TopActionExecute(Sender: TObject);
130                 procedure TopActionUpdate(Sender: TObject);
131                 procedure SageCheckBoxClick(Sender: TObject);
132                 procedure MailComboBoxChange(Sender: TObject);
133                 procedure TransActionExecute(Sender: TObject);
134                 procedure TransActionUpdate(Sender: TObject);
135                 procedure IdLogDebugReceive(ASender: TIdConnectionIntercept;
136                         AStream: TStream);
137                 procedure IdLogDebugSend(ASender: TIdConnectionIntercept;
138                         AStream: TStream);
139                 procedure SelectAllActionExecute(Sender: TObject);
140     procedure StatusBarResize(Sender: TObject);
141     procedure Timer1Timer(Sender: TObject);
142     procedure FormActivate(Sender: TObject);
143     procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
144                 procedure QuotePasteActionExecute(Sender: TObject);
145     procedure SpaceToNBSPActionExecute(Sender: TObject);
146     procedure AmpToCharRefActionExecute(Sender: TObject);
147     procedure SETTINGTXT1Click(Sender: TObject);
148     procedure HEADTXT1Click(Sender: TObject);
149     procedure BoardTopClick(Sender: TObject);
150         private
151                 FThreadItem: TThreadItem;
152                 FBoard: TBoard;
153                 FNameComboEdit: THandle;
154                 FMailComboEdit: THandle;
155                 FAbort: Boolean;
156                 FWork: Boolean;
157                 FStatusCode: Integer;
158                 FDebugStrReceive: string;
159                 FDebugStrSend: string;
160         FSambaTime: TDateTime;
161         FHost: string;
162                 FNow: TDateTime;
163                 procedure Preview;
164                 function RepHtml(s: string): string;
165                 function Check: Boolean;
166                 procedure SetNameList(sName, sMail: string);
167 //              procedure Send(SendType: TGikoSendType; SPID: string; PON: string; FirstWriting: Boolean);
168                 procedure Send(SPID: string; PON: string; FirstWriting: Boolean);
169
170                 function GetActiveControlHandle: THandle;
171 //              function GetSendData: string;
172 //              procedure GetSendData(Source: TStringStream);
173                 procedure GetSendData(Source: TStringStream);
174                 procedure SaveSendFile;
175                 procedure SetContent(Content: string);
176                 function GetSPID(CookieLine: string): string;
177                 function GetPON(CookieLine: string): string;
178                 function GetResultType(ResponseText: string): TGikoResultType;
179         procedure ReadSambaTime(const AHost: string);
180         procedure WriteSambaTime(const AHost: string; ATime: TDateTime);
181         function ReadSettingTime(const AHost: string): Integer;
182         function CheckSambaTime(const AHost: string; ATime: TDateTime): Boolean;
183                                 procedure SetSamba24(AURL: string);
184                 /// \88ø\97p\95\84\82Ì\8eæ\93¾
185                 function GetOEIndentChar : string;
186                 /// \96{\95\82Ì\8eæ\93¾
187                 function GetBody : string;
188         protected
189                 procedure CreateParams(var Params: TCreateParams); override;
190         public
191                 FBBSID: String;
192                 procedure SetFont;
193                 procedure SetThreadItem(Item: TThreadItem);
194                 procedure SetBoard(Item: TBoard);
195                 property BBSID: string read FBBSID write FBBSID;
196
197                 function GetFileName(): string;
198         end;
199
200 implementation
201
202 uses
203         Giko, ItemDownload;
204 const
205         CAPTION_NAME_NEW: string = '\83M\83R\83i\83\83X\83\8c\97§\82Ä\83G\83f\83B\83^';
206         CAPTION_NAME_RES: string = '\83M\83R\83i\83\83\8c\83X\83G\83f\83B\83^';
207
208     // \83G\83f\83B\83b\83g\83E\83B\83\93\83h\83E\82ð\89E\89º\82É\82¸\82ç\82µ\82Ä\8aJ\82­\88Ú\93®\97Ê
209     WINDOWMOVE_H = 30;
210     WINDOWMOVE_V = 30;
211
212         //DAX\82³\82ñ±Ø¶ÞÄ!(\81L\81¤\81M)
213         READCGI_ERR                     = '-ERR';
214         READCGI_INCR            = '-INCR';
215         READCGI_OK                      = '+OK';
216         READCGI_PARTIAL = '+PARTIAL';
217         READCGI_ERR_FOUND_KAKO  = '-ERR \89ß\8b\8e\83\8d\83O\91q\8cÉ\82Å\94­\8c©';
218         READCGI_ERR_NOT_HTML            = '-ERR html\89»\91Ò\82¿';
219         READCGI_ERR_NOT_FOUND           = '-ERR \82»\82ñ\82È\94Âor\83X\83\8c\83b\83h\82È\82¢\82Å\82·\81B';
220         READCGI_ERR_ABONE                               = '-ERR \82Ç\82±\82©\82Å\82 \82Ú\81[\82ñ\82ª\82 \82Á\82½\82Ý\82½\82¢\82Å\82·\81B';
221         READCGI_ERR_TIMEOUT                     = '-ERR \8ew\92è\8e\9e\8aÔ\82ª\89ß\82¬\82Ü\82µ\82½\81B';
222         READCGI_ERR_CANTUSE                     = '-ERR \82à\82¤\81@\82Â\82©\82¦\82Ü\82¹\82ñ';
223         RES2CH_TRUE                             = '<!-- 2ch_X:true -->';
224         RES2CH_FALSE                    = '<!-- 2ch_X:false -->';
225         RES2CH_ERROR                    = '<!-- 2ch_X:error -->';
226         RES2CH_CHECK                    = '<!-- 2ch_X:check -->';
227         RES2CH_COOKIE                   = '<!-- 2ch_X:cookie -->';
228
229
230         BBS2CH_NAME:                                     string = '\82Q\82¿\82á\82ñ\82Ë\82é';
231         BBS2CH_LOG_FOLDER:               string = '2ch';
232         EXTERNAL_LOG_FOLDER:            string  = 'exboard';
233
234         FOLDER_INI_FILENAME:     string = 'Folder.ini';
235         FOLDER_INDEX_FILENAME: string   = 'Folder.idx';
236         SUBJECT_FILENAME:                       string  = 'subject.txt';
237         PATH_DELIM:                                             string  = '\';
238
239         INI_FILE_NAME: string                            = 'gikoNavi.ini';
240
241
242 type
243         TSelection = record
244                 StartPos, EndPos: Integer;
245         end;
246
247 {$R *.DFM}
248
249 {constructor TEditorForm.Create(AOwner: TComponent; Item: TBoard);
250 begin
251         inherited Create(AOwner);
252 end;}
253
254 procedure TEditorForm.CreateParams(var Params: TCreateParams);
255 begin
256         inherited;
257         if FormStyle in [fsNormal, fsStayOnTop] then
258                 if BorderStyle in [bsSingle, bsSizeable] then begin
259                         Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
260                         Params.WndParent := 0;
261                 end;
262 end;
263
264 {procedure TEditorForm.CreateParams(var Params: TCreateParams);
265 begin
266         inherited CreateParams(Params);
267         Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
268 end;}
269
270 procedure TEditorForm.FormCreate(Sender: TObject);
271 var
272         wp: TWindowPlacement;
273                 hUser32 : HINST;
274         ini: TMemIniFile;
275         BSettingTab, BHeadTab, BBoardTopTab: Boolean;
276 begin
277         FWork := False;
278         Browser.Navigate('about:blank');
279
280         FBoard := nil;
281         FThreadItem := nil;
282
283         //\83E\83B\83\93\83h\83E\82Ì\88Ê\92u\90Ý\92è
284         wp.length := sizeof(wp);
285         wp.rcNormalPosition.Top := GikoSys.Setting.EditWindowTop;
286         wp.rcNormalPosition.Left := GikoSys.Setting.EditWindowLeft;
287
288         wp.rcNormalPosition.Bottom := GikoSys.Setting.EditWindowTop + GikoSys.Setting.EditWindowHeight;
289         wp.rcNormalPosition.Right := GikoSys.Setting.EditWindowLeft + GikoSys.Setting.EditWindowWidth;
290         wp.showCmd := SW_HIDE;
291         SetWindowPlacement(Handle, @wp);
292
293         if GikoSys.Setting.EditWindowMax then
294                 WindowState := wsMaximized;
295
296         //\83E\83B\83\93\83h\83E\82ª\89æ\96Ê\8aO\82È\82ç\89æ\96Ê\93à\82É\88Ú\93®\82·\82é
297         if (Left + Width) > Screen.Width then
298 //              Left := Screen.Width - Width;
299                 Left := 0;
300         if (Top + Height) > Screen.Height then
301 //              Top := Screen.Height - Height;
302                 Top := 0;
303         if Left < 0 then
304                 Left := 0;
305         if Top < 0 then
306                 Top := 0;
307
308     //\8c»\8dÝ\82Ì\83E\83B\83\93\83h\83E\82Ì\88Ê\92u\82ð\95Û\91
309     GikoSys.Setting.EditWindowTop := Top  + WINDOWMOVE_V;   // \8e\9f\82É\8aJ\82­\83E\83B\83\93\83h\83E\82Í
310     GikoSys.Setting.EditWindowLeft := Left + WINDOWMOVE_H;  // \81@\81@\81@\89E\8eÎ\82ß\89º\82É\82¸\82ç\82·
311     //\83E\83B\83\93\83h\83E\82Ì\95\9d\82Æ\8d\82\82³\82ª\8f¬\82³\82·\82¬\82¢\82ê\82Î\8c³\82É\96ß\82·
312         if GikoSys.Setting.EditWindowHeight < 144 then
313                 Height := 400;
314         if GikoSys.Setting.EditWindowWidth < 144 then
315                 Width := 640;
316
317         EditorPage.ActivePage := EditorTab;
318         FNameComboEdit := GetWindow(NameComboBox.Handle, GW_CHILD);
319         FMailComboEdit := GetWindow(MailComboBox.Handle, GW_CHILD);
320         NameComboBox.Items.Assign(GikoSys.Setting.NameList);
321         MailComboBox.Items.Assign(GikoSys.Setting.MailList);
322         SetFont;
323         hUser32 := 0;
324         try
325                 try
326                         hUser32 := LoadLibrary('User32.dll');
327                         if hUser32 <> 0 then
328                                 TransAction.Enabled := true
329                         else
330                                 TransAction.Enabled := false;
331                 except
332                 TransAction.Enabled := false;
333                 end;
334         finally
335                 FreeLibrary(hUser32);
336         end;
337
338     // \83E\83B\83\93\83h\83E\82Ì\83X\83e\83C\8fó\91Ô
339         if GikoSys.Setting.EditWindowStay then begin    // \83X\83e\83C\8fó\91Ô
340                 SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
341                 TopAction.Checked := true;
342                 TopToolButton.Down := true;
343         end else begin                                  // \83X\83e\83C\82µ\82È\82¢
344                 SetWindowPos(Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
345                 TopAction.Checked := false;
346                 TopToolButton.Down := false;
347         end;
348
349     // \83E\83B\83\93\83h\83E\82Ì\94¼\93§\96¾\8fó\91Ô
350         if(GikoSys.Setting.EditWindowTranslucent) and (TransAction.Enabled) then begin // \94¼\93§\96¾\81i\83g\83\89\83\93\83X\83\8b\81[\83Z\83\93\83g\81j\8fó\91Ô
351         AlphaBlend := true;
352         TransAction.Checked := true;
353         TransToolButton.Down := true;
354     end else begin                                      // \95s\93§\96¾
355         AlphaBlend := false;
356         TransAction.Checked := false;
357         TransToolButton.Down := false;
358     end;
359         // \94¼\93§\96¾\8fó\91Ô\82Ì\95Û\91
360         GikoSys.Setting.EditWindowTranslucent := TransAction.Checked;
361
362         SpaceToNBSPAction.Checked               := GikoSys.Setting.SpaceToNBSP;
363         AmpToCharRefAction.Checked      := GikoSys.Setting.AmpToCharRef;
364
365         ini := TMemIniFile.Create(GetFileName);
366
367         try
368               BSettingTab := ini.ReadBool('EditorForm', 'SettingTab', False);
369               BHeadTab :=  ini.ReadBool('EditorForm', 'HeadTab', False);
370               BBoardTopTab := ini.Readbool('EditorForm', 'BoardTopTab', False);
371         finally
372                 ini.Free;
373         end;
374         //SETTING.TXT,\94Â\83g\83b\83v\81CHEAD.TXT\94ñ\95\\8e¦
375         if BSettingTab then begin
376                 SettingTab.TabVisible := True;
377                 SettingTxt1.Checked := True;
378         end else begin
379                 SettingTab.TabVisible := False;
380                 SettingTxt1.Checked := False;
381         end;
382
383         if BHeadTab then begin
384                 HeadTab.TabVisible := True;
385                 HeadTxt1.Checked := True;
386         end else begin
387                 HeadTab.TabVisible := False;
388                 HeadTxt1.Checked := False;
389         end;
390
391         if BBoardTopTab then begin
392                 BoardTopTab.TabVisible := True;
393                 BoardTop.Checked := True;
394         end else begin
395                 BoardTopTab.TabVisible := False;
396                 BoardTop.Checked := False;
397         end;
398 end;
399
400 procedure TEditorForm.SetBoard(Item: TBoard);
401 begin
402         FBoard := Item;
403         Caption := CAPTION_NAME_NEW + ' - [' + Item.Title + ']';
404         NameComboBox.Text := FBoard.KotehanName;
405         MailComboBox.Text := FBoard.KotehanMail;
406         SageCheckBox.Checked := AnsiPos('sage', MailComboBox.Text) <> 0;
407         TitlePanel.Visible := True;
408     SetSamba24('');
409 end;
410
411 procedure TEditorForm.SetThreadItem(Item: TThreadItem);
412 begin
413         FThreadItem := Item;
414         Caption := CAPTION_NAME_RES + ' - [' + FThreadItem.Title + ']';
415         NameComboBox.Text := FThreadItem.ParentBoard.KotehanName;
416         MailComboBox.Text := FThreadItem.ParentBoard.KotehanMail;
417         SageCheckBox.Checked := AnsiPos('sage', MailComboBox.Text) <> 0;
418         TitlePanel.Visible := False;
419     SetSamba24(FThreadItem.ParentBoard.URL);
420 end;
421
422 function TEditorForm.GetBody : string;
423 var
424         body            : string;
425         regexp  : TAWKStr;
426 begin
427
428         body := BodyEdit.Text;
429         if AmpToCharRefAction.Checked then
430                 // & \82Ì\92u\8a·\82Í\88ê\94Ô\8dÅ\8f\89\82É\82â\82é\82±\82Æ
431                 body := CustomStringReplace( body, '&', '&amp;' );
432         if SpaceToNBSPAction.Checked then begin
433                 body := CustomStringReplace( body, #09, '&nbsp;&nbsp;&nbsp;&nbsp;' );
434                 body := CustomStringReplace( body, '  ', '&nbsp;&nbsp;' );
435                 body := CustomStringReplace( body, '&nbsp; ', '&nbsp;&nbsp;' );
436                 regexp := TAWKStr.Create( nil );
437                 try
438                         regexp.RegExp := '^ ';
439                         regexp.GSub( '\&nbsp;', body );
440                 finally
441                         regexp.Free;
442                 end;
443         end;
444
445         Result  := body;
446
447 end;
448
449 procedure TEditorForm.SetFont;
450 begin
451         BodyEdit.Font.Name := GikoSys.Setting.EditorFontName;
452         BodyEdit.Font.Size := GikoSys.Setting.EditorFontSize;
453         BodyEdit.Font.Color := GikoSys.Setting.EditorFontColor;
454         BodyEdit.Color := GikoSys.Setting.EditorBackColor;
455 end;
456
457 procedure TEditorForm.Preview;
458 var
459         Title: string;
460         No: string;
461         Mail: string;
462         Namae: string;
463         DateTime: string;
464         Body: string;
465         s: string;
466
467                                 posTrip : Integer;
468                                 tripOrigin : string;
469 begin
470         if FThreadItem = nil then begin
471                 No := '1';
472                 Title := RepHtml(TitleEdit.Text);
473         end else begin
474                 No := IntToStr(FThreadItem.Count + 1);
475                 Title := RepHtml(FThreadItem.Title);
476         end;
477
478         body := GetBody;
479
480         Namae := RepHtml(NameComboBox.Text);
481         Mail := RepHtml(MailComboBox.Text);
482         Body := RepHtml(body);
483         Body := StringReplace(Body, #13#10, '<br>', [rfReplaceAll]);
484         DateTime := FormatDateTime('yyyy/mm/dd(aaa) hh:nn', now);
485
486         if Trim(Namae) = '' then
487                 Namae := '\96¼\96³\82µ\82³\82ñ';
488
489         s := '<HTML><HEAD>' + #13#10
490                         + '<META http-equiv="Content-Type" content="text/html; charset=Shift_JIS">' + #13#10
491                         + '<TITLE>' + title + '</TITLE>' + #13#10
492 //                      + '<STYLE><!--BODY{font-size : 9pt;font-family : "\82l\82\82o\83S\83V\83b\83N";}--></STYLE>' + #13#10
493                         + '</HEAD>' + #13#10
494                         + '<BODY text="#000000" bgcolor="#EFEFEF" link="#0000FF" alink="#FF0000" vlink="#660099">' + #13#10
495                         + '<FONT COLOR="#FF0000">' + title + '</FONT>' + #13#10
496                         + '<DL>' + #13#10;
497                                 posTrip := AnsiPos( '#', Namae );
498                                 if posTrip > 0 then
499                                 begin
500                                                                 tripOrigin := Copy( Namae, posTrip + 1, Length( Namae ) );
501                                                                 Namae :=
502                                                                                                 Copy( Namae, 1, posTrip - 1 ) + '</B> \81\9f' +
503                                                                                                 get_2ch_trip( PChar( tripOrigin ) ) + '<B>';
504                                 end;
505         if Mail = '' then
506                 s := s + '<DT>' + No + ' \81F <FONT color="forestgreen"><B>' + Namae + '</B></FONT> \81F ' + DateTime+ '<BR><DD>' + Body + '<BR><BR><BR>' + #13#10
507         else
508                 s := s + '<DT>' + No + ' \81F <A href="mailto:' + Mail + '"><B>' + Namae + '</B></A> [' + Mail + ']\81F ' + DateTime+ '<BR><DD>' + Body + '<BR><BR><BR>' + #13#10;
509         s := s + '</BODY></HTML>';
510         SetContent(s);
511 end;
512
513 function TEditorForm.RepHtml(s: string): string;
514 begin
515 //      s := StringReplace(s, '&', '&amp;', [rfReplaceAll]);
516         s := StringReplace(s, '<', '&lt;', [rfReplaceAll]);
517         s := StringReplace(s, '>', '&gt;', [rfReplaceAll]);
518 //      s := StringReplace(s, ' ', '&nbsp;', [rfReplaceAll]);   //\8ed\97l\95Ï\8dX\82É\82æ\82è&nbsp;\8eg\97p\95s\89Â
519         s := StringReplace(s, '"', '&quot;', [rfReplaceAll]);
520         Result := s;
521 end;
522
523 procedure TEditorForm.EditorPageChange(Sender: TObject);
524 var
525         URL, RefURL, RefeURL, HeadURL: String;
526 begin
527         if EditorPage.ActivePage = PreviewTab then begin
528                 Preview;
529         end else begin
530                 Browser.Navigate('about:blank');
531         end;
532
533         if FThreadItem = nil then begin
534                 URL := FBoard.GetSendURL;
535                 RefURL := GikoSys.UrlToServer(FBoard.URL)
536                         + GikoSys.UrlToID(FBoard.URL)
537                         + '/';
538                 RefeURL := RefURL + 'SETTING.TXT';
539                 HeadURL := RefURL + 'head.txt';
540         end else begin
541                 URL := FThreadItem.GetSendURL;
542                 RefURL := GikoSys.UrlToServer(FThreadItem.ParentBoard.URL)
543                         + FThreadItem.ParentBoard.BBSID
544                         + '/';
545                 RefeURL := RefURL + 'SETTING.TXT';
546                 HeadURL := RefURL + 'head.txt';
547         end;
548
549         if EditorPage.ActivePage = SETTINGTab then begin
550                 Browser1.Navigate(RefeURL);
551         end else begin
552                 Browser1.Navigate('about:blank');
553         end;
554
555         if EditorPage.ActivePage = BoardtopTab then begin
556                 Browser2.Navigate(RefURL);
557         end else begin
558                 Browser2.Navigate('about:blank');
559         end;
560
561         if EditorPage.ActivePage = HEADTab then begin
562                 Browser3.Navigate(HeadURL);
563         end else begin
564                 Browser3.Navigate('about:blank');
565         end;
566 end;
567
568 procedure TEditorForm.BrowserStatusTextChange(Sender: TObject;
569         const Text: WideString);
570 begin
571         if EditorPage.ActivePage = PreviewTab then begin
572                 StatusBar.Panels[0].Text := Text;
573         end else begin
574                 StatusBar.Panels[0].Text := '';
575         end;
576 end;
577
578 function TEditorForm.Check: Boolean;
579 var
580         Msg: string;
581         rc: Integer;
582         Board: TBoard;
583 begin
584         Result := True;
585         if FThreadItem = nil then
586                 Board := FBoard
587         else
588                 Board := FThreadItem.ParentBoard;
589
590         if (not GikoSys.Setting.UseMachineTime) and
591                  ((Board.LastGetTime = 0) or
592                         (Board.LastGetTime = ZERO_DATE)) then begin
593                 Msg := '\83T\81[\83o\82Ì\8e\9e\8d\8f\82ª\95ª\82©\82ç\82È\82¢\82½\82ß\81A\91\97\90M\8fo\97\88\82Ü\82¹\82ñ'#13#10
594                                  + '\83X\83\8c\83b\83h\82ð\8dX\90V\81i\8eæ\93¾\81j\8cã\81A15\95b\91Ò\82Á\82Ä\82©\82ç\91\97\90M\82µ\82Ä\82­\82¾\82³\82¢';
595                 MsgBox(Handle, Msg, '\83G\83\89\81[', MB_OK or MB_ICONSTOP);
596                 Result := False;
597         end else if BodyEdit.Text = '' then begin
598                 Msg := '\96{\95\82ª\93ü\97Í\82³\82ê\82Ä\82¢\82Ü\82¹\82ñ\81B';
599                 MsgBox(Handle, Msg, '\83G\83\89\81[', MB_OK or MB_ICONSTOP);
600                 Result := False;
601         end else if (FBoard <> nil) and (Trim(TitleEdit.Text) = '') then begin
602                 Msg := '\83^\83C\83g\83\8b\82ª\93ü\97Í\82³\82ê\82Ä\82¢\82Ü\82¹\82ñ\81B';
603                 MsgBox(Handle, Msg, '\83G\83\89\81[', MB_OK or MB_ICONSTOP);
604                 Result := False;
605         end else begin
606                 if (not GikoSys.Dolib.Connected) and (AnsiPos('\81\9c', NameComboBox.Text) <> 0) then begin
607                         Msg := '\83\8d\83O\83C\83\93\82µ\82Ä\82¢\82È\82¢\82Ì\82Å\81\9c\82Ì\8b@\94\\82Í\97\98\97p\8fo\97\88\82Ü\82¹\82ñ\81B'#13#10
608                                          + '\82±\82Ì\82Ü\82Ü\91\97\90M\82µ\82Ä\82à\82æ\82ë\82µ\82¢\82Å\82·\82©\81H';
609                         rc := MsgBox(Handle, Msg, '\8am\94F', MB_YESNO or MB_ICONQUESTION);
610                         Result := (rc = IDYES);
611                 end;
612         end;
613 end;
614
615 procedure TEditorForm.FormClose(Sender: TObject; var Action: TCloseAction);
616 begin
617         Action := caFree;
618 end;
619
620 procedure TEditorForm.FormDestroy(Sender: TObject);
621 var
622         wp: TWindowPlacement;
623 begin
624         //\8dÅ\91å\89»\81E\83E\83B\83\93\83h\83E\88Ê\92u\95Û\91
625         wp.length := sizeof(wp);
626         GetWindowPlacement(Handle, @wp);
627
628         GikoSys.Setting.EditWindowTop := wp.rcNormalPosition.Top;
629         GikoSys.Setting.EditWindowLeft := wp.rcNormalPosition.Left;
630         GikoSys.Setting.EditWindowHeight := wp.rcNormalPosition.Bottom - wp.rcNormalPosition.Top;
631         GikoSys.Setting.EditWindowWidth := wp.rcNormalPosition.Right - wp.rcNormalPosition.Left;
632         GikoSys.Setting.EditWindowMax := WindowState = wsMaximized;
633         //GikoSys.Setting.EditWindowStay := FormStyle = fsStayOnTop;      // \83X\83e\83C\8fó\91Ô\82Ì\95Û\91
634         GikoSys.Setting.EditWindowTranslucent := TransAction.Checked;   // \94¼\93§\96¾\8fó\91Ô\82Ì\95Û\91
635
636 end;
637
638 procedure TEditorForm.SetNameList(sName, sMail: string);
639 begin
640         if Trim(sName) <> '' then begin
641                 if GikoSys.Setting.NameList.IndexOf(sName) = -1 then
642                         GikoSys.Setting.NameList.Insert(0, sName);
643         end;
644         if Trim(sMail) <> '' then begin
645                 if GikoSys.Setting.MailList.IndexOf(sMail) = -1 then
646                         GikoSys.Setting.MailList.Insert(0, sMail);
647         end;
648 end;
649
650 function TEditorForm.GetActiveControlHandle: THandle;
651 begin
652         if EditorPage.ActivePage = EditorTab then begin
653                 if ActiveControl = NameComboBox then
654                         Result := FNameComboEdit
655                 else if ActiveControl = MailComboBox then
656                         Result := FMailComboEdit
657                 else if ActiveControl = BodyEdit then
658                         Result := BodyEdit.Handle
659                 else if ActiveControl = TitleEdit then
660                         Result := TitleEdit.Handle
661                 else
662                         Result := 0;
663         end else
664                 Result := 0;
665 end;
666
667 procedure TEditorForm.SetContent(Content: string);
668 var
669         doc : Variant;
670 begin
671         if Browser.Document <> nil then begin
672                 doc := Browser.Document;
673                 doc.Clear;
674                 doc.open;
675                 doc.charset := 'Shift_JIS';
676                 doc.Write(Content);
677                 doc.Close;
678         end;
679 end;
680
681 procedure TEditorForm.Send(SPID: string; PON: string; FirstWriting: Boolean);
682 var
683         TextStream: TStringStream;
684         Source: TStringStream;
685         ResponseText: string;
686         URL: string;
687         RefURL: string;
688         State: TGikoDownloadState;
689         ResultType: TGikoResultType;
690         MsgResult: Integer;
691         Cookie: string;
692         Board: TBoard;
693         sysMenu : HMENU;
694         //fusianasan\83g\83\89\83b\83v by\92è\8aú\95Ö
695         Namae: String;
696         SettingTxt: String;
697         RefeURL: string;
698 //        RuleURL: String;
699 //        RuleTxt: String;
700 begin
701         FAbort := False;
702         State := gdsError;
703         Namae := RepHtml(NameComboBox.Text);
704         if FThreadItem = nil then
705                 Board := FBoard
706         else
707                 Board := FThreadItem.ParentBoard;
708
709         Indy.Request.Clear;
710         Indy.ProxyParams.BasicAuthentication := False;
711         if GikoSys.Setting.WriteProxy then begin
712                 Indy.ProxyParams.ProxyServer := GikoSys.Setting.WriteProxyAddress;
713                 Indy.ProxyParams.ProxyPort := GikoSys.Setting.WriteProxyPort;
714                 Indy.ProxyParams.ProxyUsername := GikoSys.Setting.WriteProxyUserID;
715                 Indy.ProxyParams.ProxyPassword := GikoSys.Setting.WriteProxyPassword;
716                 if GikoSys.Setting.ReadProxyUserID <> '' then
717                         Indy.ProxyParams.BasicAuthentication := True;
718         end else begin
719                 Indy.ProxyParams.ProxyServer := '';
720                 Indy.ProxyParams.ProxyPort := 80;
721                 Indy.ProxyParams.ProxyUsername := '';
722                 Indy.ProxyParams.ProxyPassword := '';
723         end;
724         if FThreadItem = nil then begin
725                 URL := FBoard.GetSendURL;
726                 RefURL := GikoSys.UrlToServer(FBoard.URL) + 'test/bbs.cgi';
727         end else begin
728                 URL := FThreadItem.GetSendURL;
729                 RefURL := FThreadItem.URL;
730         end;
731         Indy.Request.UserAgent := GikoSys.GetUserAgent;
732         Indy.Request.Referer := RefURL;
733         Indy.Request.AcceptEncoding := '';
734
735         Cookie := '';
736         if SPID <> '' then
737                 Cookie := Cookie + 'SPID=' + SPID + '; ';
738         if PON <> '' then
739                 Cookie := Cookie + 'PON=' + PON + '; ';
740         Cookie := 'Cookie: ' + Cookie + 'NAME=' + NameComboBox.Text + '; MAIL=' + MailComboBox.Text;
741
742         sysMenu := GetSystemMenu( Handle, false );
743         EnableMenuItem( sysMenu, SC_CLOSE, MF_GRAYED );
744 {
745   EnableMenuItem(SysMenu, SC_CLOSE, MF_BYCOMMAND or MF_ENABLED);
746   DrawMenuBar(Handle);
747 }
748         Indy.Request.CustomHeaders.Clear;
749 //      Indy.Request.CacheControl := 'no-cache';
750         Indy.Request.CustomHeaders.Add('Pragma: no-cache');
751         Indy.Request.AcceptLanguage := 'ja';
752         Indy.Request.Accept := 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*';
753         Indy.Request.ContentType := 'application/x-www-form-urlencoded';
754         Indy.Request.CustomHeaders.Add(Cookie);
755         TextStream := TStringStream.Create('');
756         Source := TStringStream.Create('');
757         try
758                 try
759                         FDebugStrReceive := '';
760                         FDebugStrSend := '';
761                         GetSendData(Source);
762                         Indy.Post(URL, Source, TextStream);
763                         ResponseText := TextStream.DataString;
764
765                         ResultType := GetResultType(ResponseText);
766
767                         //MsgResult\8f\89\8aú\89»
768                         MsgResult := IDNO;
769                         //\83t\83V\83A\83i\83g\83\89\83b\83v\8cx\8d\90(LocalMode) by \92è\8aú\95Ö
770                         if ((Namae = '\8eR\8dè\8fÂ') or (Namae = 'fusianasan')) and (FirstWriting) then begin
771                                 MsgResult := MsgBox(
772                                                 Handle,
773                                         '\83\8a\83\82\81[\83g\83z\83X\83g\82ð\95\\8e¦\82·\82é\8b@\94\\82ª\8eg\82í\82ê\82Ä\82¢\82Ü\82·' + #13#10 +
774                                         '\82à\82µ\82à\8aÔ\88á\82Á\82Ä\82±\82Ì\95û\96@\82Å\83z\83X\83g\82ª\95\\8e¦\82³\82ê\82½\82Æ\82µ\82Ä\82à\81A\8e©\8cÈ\90Ó\94C\82È\82Ì\82Å\8dí\8f\9c\88Ë\97\8a\82É\82Í\89\9e\82\82Ü\82¹\82ñ\81B' + #13#10#13#10 +
775                                         '\90Ó\94C\82ð\95\89\82¤\82±\82Æ\82ð\8f³\91ø\82µ\82Ä\8f\91\82«\8d\9e\82Ý\82Ü\82·\82©\81H',
776                                         '\8fî\95ñ',
777                                         MB_YESNO or MB_ICONQUESTION);
778                                 if MsgResult = IDNO  then begin
779                                         Board.SPID := '';
780                                         Board.PON := '';
781                                         FWork := false;
782                                         EnableMenuItem(SysMenu, SC_CLOSE, MF_BYCOMMAND or MF_ENABLED);
783                                         DrawMenuBar(Handle);
784                                         Exit;
785                                 end;
786                         end;
787                         if ResultType = grtOK then begin
788                                 WriteSambaTime(FHost, Now());
789                                 State := gdsComplete;
790                         end else if ResultType = grtCookie then begin
791                                 //\83\8b\81[\83v\96h\8e~
792                                 if not FirstWriting then
793                                         raise Exception.Create('');
794                                 MsgResult := MsgBox(
795                                         Handle,
796                                         '\81E\93\8a\8de\82³\82ê\82½\93à\97e\82Í\83R\83s\81[\81A\95Û\91\81A\88ø\97p\81A\93]\8dÚ\93\99\82³\82ê\82é\8fê\8d\87\82ª\82 \82è\82Ü\82·\81B' + #13#10 +
797                                         '\81E\93\8a\8de\82É\8aÖ\82µ\82Ä\94­\90\82·\82é\90Ó\94C\82Í\91S\82Ä\93\8a\8de\8eÒ\82É\8bA\82µ\82Ü\82·\81B' + #13#10#13#10 +
798                                         '\91S\90Ó\94C\82ð\95\89\82¤\82±\82Æ\82ð\8f³\91ø\82µ\82Ä\8f\91\82«\8d\9e\82Ý\82Ü\82·\82©\81H',
799                                         '\8fî\95ñ',
800                                         MB_YESNO or MB_ICONQUESTION);
801                                 if MsgResult = IDYES then begin
802                                         Board.SPID := GetSPID(Indy.Response.RawHeaders.Values['Set-Cookie']);
803                                         Board.PON := GetPON(Indy.Response.RawHeaders.Values['Set-Cookie']);
804                                         if (Board.SPID = '') and (Board.PON = '') then
805                                                 raise Exception.Create('');
806                                         //\82à\82¤\88ê\89ñ\82±\82Ì\83\81\83\\83b\83h
807                                         Send(Board.SPID, Board.PON, False);
808                                         Exit;
809                                 end else begin
810                                         Board.SPID := '';
811                                         Board.PON := '';
812                                         FWork := false;
813                                         EnableMenuItem(SysMenu, SC_CLOSE, MF_BYCOMMAND or MF_ENABLED);
814                                         DrawMenuBar(Handle);
815                                         Exit;
816                                 end;
817                         end else if ResultType = grtCheck then begin
818                                 //
819                                 //\83\8b\81[\83v\96h\8e~
820                                 if not FirstWriting then
821                                         raise Exception.Create('');
822
823                                 MsgResult := MsgBox(
824                                         Handle,
825                                         '\8f\91\82«\8d\9e\82Ý\82É\8aÖ\82µ\82Ä\82Í\97l\81X\82È\83\8d\83O\8fî\95ñ\82ª\8bL\98^\82³\82ê\82Ä\82¢\82Ü\82·\81B' + #13#10 +
826                                         '\93\8a\8de\82É\8aÖ\82µ\82Ä\94­\90\82·\82é\90Ó\94C\82Í\91S\82Ä\93\8a\8de\8eÒ\82É\8bA\82µ\82Ü\82·\81B' + #13#10 +
827                                         '\8cö\8f\98\97Ç\91­\82É\94½\82µ\82½\82è\81A\91¼\90l\82É\96À\98f\82ð\82©\82¯\82é\8f\91\82«\8d\9e\82Ý\82Í\8dT\82¦\82Ä\89º\82³\82¢\81B' + #13#10 +
828                                         '\93\8a\8de\82³\82ê\82½\93à\97e\82Í\83R\83s\81[\81E\95Û\91\81E\88ø\97p\81E\93]\8dÚ\93\99\82³\82ê\82é\8fê\8d\87\82ª\82 \82è\82Ü\82·\81B' + #13#10 +
829                                         #13#10 +
830                                         '\91S\90Ó\94C\82ð\95\89\82¤\82±\82Æ\82ð\8f³\91ø\82µ\82Ä\8f\91\82«\8d\9e\82Ý\82Ü\82·\82©\81H',
831                                         '\8am\94F',
832                                         MB_YESNO or MB_ICONQUESTION);
833
834                                 if MsgResult = IDYES then begin
835                                         Board.SPID := GetSPID(Indy.Response.RawHeaders.Values['Set-Cookie']);
836                                         Board.PON := GetPON(Indy.Response.RawHeaders.Values['Set-Cookie']);
837                                         if (Board.SPID = '') and (Board.PON = '') then
838                                                 raise Exception.Create('');
839                                         Send(Board.SPID, Board.PON, False);
840                                         Exit;
841                                 end else begin
842                                         EnableMenuItem(SysMenu, SC_CLOSE, MF_BYCOMMAND or MF_ENABLED);
843                                         DrawMenuBar(Handle);
844                                         Board.SPID := '';
845                                         Board.PON := '';
846                                         FWork := false;
847                                         Exit;
848                                         end;
849                         end else begin
850                 WriteSambaTime(FHost, Now());
851                                 State := gdsError;
852                                 raise Exception.Create('');
853                         end;
854
855                 except
856                         on E: EIdConnectException do begin
857                                 State := gdsError;
858                                 ResponseText := '<html><body>'
859                                                                                         + '<div>\90Ú\91±\82ª\8e¸\94s\82µ\82Ü\82µ\82½<br>'
860                                                                                         + '\89ñ\90ü\82â\83v\83\8d\83L\83V\82Ì\8fó\91Ô\82ð\92²\82×\82Ä\82­\82¾\82³\82¢<br></div>'
861                                                                                         + '<br><br><div>' + E.Message + '</div>'
862                                                                                         + '</body></html>';
863                         end;
864                         on E: Exception do begin
865                                 State := gdsError;
866
867                                 FDebugStrReceive := AnsiReplaceText(FDebugStrReceive, '<', '&lt;');
868                                 FDebugStrReceive := AnsiReplaceText(FDebugStrReceive, '>', '&gt;');
869                                 FDebugStrSend := AnsiReplaceText(FDebugStrSend, '<', '&lt;');
870                                 FDebugStrSend := AnsiReplaceText(FDebugStrSend, '>', '&gt;');
871
872                                 ResponseText := '<html><body>' + TextStream.DataString;
873                                 ResponseText := AnsiReplaceText(ResponseText, '</body>', '');
874                                 ResponseText := AnsiReplaceText(ResponseText, '</html>', '');
875                                 ResponseText := ResponseText + '<hr><div align="left"><pre>';
876                                 ResponseText := ResponseText + '<b>\82±\82±\82©\82ç\83M\83R\83i\83r\82Ì\8fî\95ñ</b>'#13#10;
877                                 ResponseText := ResponseText + #13#10'\81\9c\91\97\90M'#13#10;
878                                 ResponseText := ResponseText + FDebugStrSend;
879                                 ResponseText := ResponseText + #13#10'\81\9c\8eó\90M'#13#10;
880                                 ResponseText := ResponseText + FDebugStrReceive;
881                                 ResponseText := ResponseText + '</pre></div></body></html>';
882                         end;
883                 end;
884                 FStatusCode := Indy.ResponseCode;
885                 if FAbort then
886                         State := gdsAbort;
887         finally
888                 Source.Free;
889                 TextStream.Free;
890                 //sysMenu := GetSystemMenu( Handle, true );
891                 EnableMenuItem(SysMenu, SC_CLOSE, MF_BYCOMMAND or MF_ENABLED);
892                 DrawMenuBar(Handle);
893         end;
894         FWork := false;
895         //\94ñ\8cö\8e®\83M\83R\83i\83r\94Â\82È\82Ç\82Ì\83X\83N\83\8a\83v\83g\97p
896         //ResponceCode\82ª302Found\82Å\8f\91\82«\8d\9e\82Ý\8a®\97¹
897         if FStatusCode = 302 then begin
898                 GikoForm.PlaySound('ResEnd');
899                 SaveSendFile;
900                 if FThreadItem = nil then
901                         GikoForm.AddMessageList(FBoard.Title + ' [\90V\83X\83\8c\91\97\90M\8fI\97¹]', nil, gmiOK)
902                 else
903                         GikoForm.AddMessageList(FThreadItem.Title + ' [\83\8c\83X\91\97\90M\8fI\97¹]', nil, gmiOK);
904                 Close;
905                 Exit;
906         end;
907         if State = gdsComplete then begin
908                 GikoForm.PlaySound('ResEnd');
909                 SaveSendFile;
910                 if FThreadItem = nil then
911                         GikoForm.AddMessageList(FBoard.Title + ' [\90V\83X\83\8c\91\97\90M\8fI\97¹]', nil, gmiOK)
912                 else
913                         GikoForm.AddMessageList(FThreadItem.Title + ' [\83\8c\83X\91\97\90M\8fI\97¹]', nil, gmiOK);
914                 Close;
915         end else if State = gdsError then begin
916                 if FThreadItem = nil then
917                         GikoForm.AddMessageList(FBoard.Title + ' [\90V\83X\83\8c\91\97\90M\8e¸\94s]', nil, gmiNG)
918                 else
919                         GikoForm.AddMessageList(FThreadItem.Title + ' [\83\8c\83X\91\97\90M\8e¸\94s]', nil, gmiNG);
920                 EditorPage.ActivePage := PreviewTab;
921                 SetContent(ResponseText);
922         end else if State = gdsAbort then begin
923                 GikoForm.AddMessageList(FThreadItem.Title + ' [\92\86\92f]', nil, gmiSAD);
924         end;
925 end;
926
927 function TEditorForm.GetResultType(ResponseText: string): TGikoResultType;
928 begin
929         if AnsiPos('\8f\91\82«\82±\82Ý\82ª\8fI\82í\82è\82Ü\82µ\82½', ResponseText) <> 0 then
930                 Result := grtOK
931         else if (AnsiPos('\83N\83b\83L\81[\82ª\82È\82¢\82©\8aú\8cÀ\90Ø\82ê\82Å\82·', ResponseText) > 0) or
932                                         (AnsiPos('<title>\83N\83b\83L\81[\8am\94F\81I</title>', ResponseText) > 0)    or
933                                         (AnsiPos('<title>\81¡\83N\83b\83L\81[\8am\94F\81I\81¡</title>', ResponseText) > 0)        or
934                                         //(AnsiPos('\83N\83b\83L\81[\8am\94F', ResponseText) > 0) or
935                                         (AnsiPos(RES2CH_COOKIE, ResponseText) > 0)      then
936                 Result := grtCookie
937         else if (AnsiPos('<font size=+2 color=#FF0000>\8f\91\82«\8d\9e\82Ý\83`\83F\83b\83N\81I </font>', ResponseText) > 0)   or
938                                         (AnsiPos('<title>\81¡ \8f\91\82«\8d\9e\82Ý\8am\94F\82µ\82Ü\82· \81¡</title>', ResponseText) > 0)  or
939                                         (AnsiPos('<title>\93\8a\8de\8am\94F</title>', ResponseText) > 0)  or
940                                         (AnsiPos('<b>\8f\91\82«\82±\82Ý\8am\94F</b>', ResponseText) > 0)      or
941                                         (AnsiPos('="../test/subbbs.cgi">', ResponseText) > 0)   or
942                                         (AnsiPos(RES2CH_FALSE, ResponseText) > 0)       then
943                 Result := grtCheck
944         else
945                 Result := grtError;
946 end;
947
948
949 procedure TEditorForm.GetSendData(Source: TStringStream);
950 var
951         SessionID: string;
952         s: string;
953         SendTime: Integer;
954         Adjust: Integer;
955         Board: TBoard;
956         body            : string;
957 begin
958         if FThreadItem = nil then
959                 Board := FBoard
960         else
961                 Board := FThreadItem.ParentBoard;
962
963         if GikoSys.Setting.UseMachineTime then begin
964                 if GikoSys.Setting.TimeAdjust then
965                         Adjust := Gikosys.Setting.TimeAdjustSec
966                 else
967                         Adjust := GikoSys.Setting.TimeAdjustSec * -1;
968                 SendTime := GikoSys.DateTimeToInt(Now) - (9 * 60 * 60) + Adjust
969         end else begin
970                 if (Board.LastGetTime = 0) or (Board.LastGetTime = ZERO_DATE) then
971                         SendTime := GikoSys.DateTimeToInt(Now)
972                 else
973                         SendTime := GikoSys.DateTimeToInt(Board.LastGetTime);
974         end;
975
976         body := GetBody;
977
978         SessionID := GikoSys.Dolib.SessionID;
979         if SessionID <> '' then
980                 s := 'sid=' + HttpEncode(SessionID) + '&'
981         else
982                 s := '';
983         s := s + 'subject=&'
984                                  + 'FROM=' + HttpEncode(NameComboBox.Text) + '&'
985                                  + 'mail=' + HttpEncode(MailComboBox.Text) + '&'
986                                  + 'MESSAGE=' + HttpEncode(body) + '&'
987                                  + 'bbs=' + Board.BBSID + '&'
988                                  + 'time=' + IntToStr(SendTime) + '&';
989         if FThreadItem = nil then begin
990                 s := s + 'subject=' + HttpEncode(TitleEdit.Text) + '&';
991                 s := s + 'submit=' + HttpEncode('\91S\90Ó\94C\82ð\95\89\82¤\82±\82Æ\82ð\8f³\91ø\82µ\82Ä\8f\91\82«\8d\9e\82Þ') + #13#10;
992         end else begin
993                 s := s + 'key=' + ChangeFileExt(FThreadItem.FileName, '') + '&';
994                 s := s + 'submit=' + HttpEncode('\8f\91\82«\8d\9e\82Þ') + #13#10;
995         end;
996         Source.WriteString(s);
997 end;
998
999 procedure TEditorForm.SaveSendFile;
1000 var
1001         sDate: string;
1002         ini: TMemIniFile;
1003 begin
1004         ini := TMemIniFile.Create(GikoSys.GetSentFileName);
1005         try
1006                 sDate := IntToStr(GikoSys.DateTimeToInt(Now));
1007
1008                 ini.WriteString(sDate, 'Name', NameComboBox.Text);
1009                 ini.WriteString(sDate, 'EMail', MailComboBox.Text);
1010                 ini.WriteString(sDate, 'Body', HttpEncode(BodyEdit.Text));
1011                 ini.WriteInteger(sDate, 'Status', FStatusCode);
1012                 ini.WriteDateTime(sDate, 'Date', Now);
1013                 if FThreadItem = nil then begin
1014                         ini.WriteString(sDate, 'Title', TitleEdit.Text);
1015                         ini.WriteString(sDate, 'BBS', FBoard.BBSID);
1016                         ini.WriteInteger(sDate, 'NewThread', 1);
1017                 end else begin
1018                         ini.WriteString(sDate, 'Title', FThreadItem.Title);
1019                         ini.WriteString(sDate, 'BBS', FThreadItem.ParentBoard.BBSID);
1020                         ini.WriteString(sDate, 'Key', ChangeFileExt(FThreadItem.FileName, ''));
1021                 end;
1022
1023                 ini.UpdateFile;
1024         finally
1025                 ini.Free;
1026         end;
1027 end;
1028
1029 procedure TEditorForm.SendActionExecute(Sender: TObject);
1030 var
1031         Board: TBoard;
1032         rc: Integer;
1033         state : TGikoDownloadState;
1034         body            : string;
1035 begin
1036         if FWork then
1037                 Exit;
1038         try
1039                 FWork := True;
1040                 SendAction.Enabled := False;
1041                 Application.ProcessMessages;
1042                 if not Check then Exit;
1043
1044                 if FThreadItem = nil then
1045                         Board := FBoard
1046                 else
1047                         Board := FThreadItem.ParentBoard;
1048
1049                 if FThreadItem = nil then begin
1050                         rc := GikoUtil.MsgBox(Handle,
1051                                                                                                         '\81u' + Board.Title + '\81v\94Â\82É\90V\82µ\82¢\83X\83\8c\83b\83h\97§\82Ä\82Ü\82·'#13#10#13#10
1052                                                                                                         + '\81E\94Â\82Ì\83\8b\81[\83\8b\82ð\8eç\82Á\82½\8f\91\82«\8d\9e\82Ý\82Å\82 \82é\82±\82Æ\82ð\8am\94F\82µ\82Ü\82µ\82½\82©\81H'#13#10
1053                                                                                                         + '\81E\91¼\82É\93¯\82\82æ\82¤\82È\83X\83\8c\83b\83h\82ª\96³\82©\82Á\82½\82±\82Æ\82ð\8am\94F\82µ\82Ü\82µ\82½\82©\81H'#13#10#13#10
1054                                                                                                         + '\81u\82Í\82¢\81v\82ð\89\9f\82·\82Æ\91\97\90M\82µ\82Ü\82·',
1055                                                                                                         '\8am\94F',
1056                                                                                                         MB_ICONQUESTION or MB_YESNO);
1057                         if rc <> ID_YES then
1058                                 Exit;
1059                 end;
1060
1061                 SetNameList(NameComboBox.Text, MailComboBox.Text);
1062                 if KotehanCheckBox.Checked then begin
1063                         Board.KotehanName := NameComboBox.Text;
1064                         Board.KotehanMail := MailComboBox.Text;
1065                 end;
1066
1067                 if Board.IsBoardPlugInAvailable then begin
1068                         body := GetBody;
1069
1070                         if FThreadItem = nil then begin
1071                                 // \83X\83\8c\97§\82Ä
1072                                 state := TGikoDownloadState( Board.BoardPlugIn.CreateThread(
1073                                         DWORD( Board ), TitleEdit.Text, NameComboBox.Text, MailComboBox.Text, body ) );
1074
1075                                 if state = gdsComplete then begin
1076                                         GikoForm.PlaySound('ResEnd');
1077                                         SaveSendFile;
1078                                         GikoForm.AddMessageList(FBoard.Title + ' [\90V\83X\83\8c\91\97\90M\8fI\97¹]', nil, gmiOK);
1079                                         FWork := False;
1080                                         Close;
1081                                 end else if State = gdsError then begin
1082                                         GikoForm.AddMessageList(FBoard.Title + ' [\90V\83X\83\8c\91\97\90M\8e¸\94s]', nil, gmiNG);
1083                                 end else if State = gdsAbort then begin
1084                                         GikoForm.AddMessageList(FThreadItem.Title + ' [\92\86\92f]', nil, gmiSAD);
1085                                 end;
1086                         end else begin
1087                                 // \83\8c\83X
1088                                 state := TGikoDownloadState( FThreadItem.BoardPlugIn.WriteThread(
1089                                         DWORD( FThreadItem ), NameComboBox.Text, MailComboBox.Text, body ) );
1090
1091                                 if state = gdsComplete then begin
1092                                         GikoForm.PlaySound('ResEnd');
1093                                         SaveSendFile;
1094                                         GikoForm.AddMessageList(FThreadItem.Title + ' [\83\8c\83X\91\97\90M\8fI\97¹]', nil, gmiOK);
1095                     FWork := False;
1096                                         Close;
1097                                 end else if State = gdsError then begin
1098                                         GikoForm.AddMessageList(FThreadItem.Title + ' [\83\8c\83X\91\97\90M\8e¸\94s]', nil, gmiNG);
1099                                 end else if State = gdsAbort then begin
1100                                         GikoForm.AddMessageList(FThreadItem.Title + ' [\92\86\92f]', nil, gmiSAD);
1101                                 end;
1102                         end;
1103                 end else begin
1104                         if not Timer1.Enabled then
1105                                 Send(Board.SPID, Board.PON, True)
1106                         else begin
1107                                 if not CheckSambaTime(FHost, Now()) then begin
1108                                         rc := GikoUtil.MsgBox(Handle,
1109                                                                 'Samba24\82Ì\8bK\92è\92l\96¢\96\9e\82Ì\95b\90\94\82µ\82©\8co\89ß\82µ\82Ä\82¢\82Ü\82¹\82ñ\81B'#13#10
1110                                                                 + '\91\97\90M\82ð\92\86\8e~\82µ\82Ü\82·\82©\81H' + #13#10
1111                                                                 + '(\81u\82¢\82¢\82¦\81v\82¾\82Æ\91\97\90M\82µ\82Ü\82·)', 'Samba24\8cx\8d\90',
1112                                                                 MB_YESNO or MB_ICONQUESTION);
1113                                         if rc = IDYES then begin
1114                                                 FWork := false;
1115                                                 Exit;
1116                                         end;
1117                                 end;
1118                                 Send(Board.SPID, Board.PON, True);
1119                         end;
1120                 end;
1121         finally
1122                 FWork := False;
1123                 if Timer1.Enabled then
1124                         ReadSambaTime(FHost);
1125         end;
1126 end;
1127
1128 procedure TEditorForm.SaveActionExecute(Sender: TObject);
1129 begin
1130 //
1131 end;
1132
1133 procedure TEditorForm.CloseActionExecute(Sender: TObject);
1134 begin
1135         Close;
1136 end;
1137
1138 procedure TEditorForm.UndoActionExecute(Sender: TObject);
1139 begin
1140         SendMessage(GetActiveControlHandle, WM_UNDO, 0, 0);
1141 end;
1142
1143 procedure TEditorForm.CutActionExecute(Sender: TObject);
1144 begin
1145         SendMessage(GetActiveControlHandle, WM_CUT, 0, 0);
1146 end;
1147
1148 procedure TEditorForm.CopyActionExecute(Sender: TObject);
1149 begin
1150         SendMessage(GetActiveControlHandle, WM_COPY, 0, 0);
1151 end;
1152
1153 procedure TEditorForm.PasteActionExecute(Sender: TObject);
1154 begin
1155         SendMessage(GetActiveControlHandle, WM_PASTE, 0, 0);
1156 end;
1157
1158 procedure TEditorForm.SelectAllActionExecute(Sender: TObject);
1159 begin
1160         SendMessage(GetActiveControlHandle, EM_SETSEL, 0, GetWindowTextLength(GetActiveControlHandle));
1161 end;
1162
1163 procedure TEditorForm.TopActionExecute(Sender: TObject);     // \83E\83B\83\93\83h\83E\8dÅ\91O\96Ê(Stay)\83{\83^\83\93\82Ì\8f\88\97\9d
1164 begin
1165         if not (fsShowing in Self.FormState) then begin
1166                 if TopAction.Checked then begin // \83X\83e\83C\8fó\91Ô\82É\90Ý\92è
1167                         SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
1168                         GikoSys.Setting.EditWindowStay := true;
1169                 end     else begin   // \83X\83e\83C\8fó\91Ô\89ð\8f\9c
1170                         SetWindowPos(Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
1171                         GikoSys.Setting.EditWindowStay := false;
1172                 end;
1173                 // \83X\83e\83C\8fó\91Ô\82Ì\95Û\91
1174                 //GikoSys.Setting.EditWindowStay := FormStyle = fsStayOnTop;
1175         end;
1176 end;
1177
1178 procedure TEditorForm.AbortActionExecute(Sender: TObject);
1179 begin
1180         FAbort := True;
1181 end;
1182
1183 procedure TEditorForm.SendActionUpdate(Sender: TObject);
1184 begin
1185         SendAction.Enabled := not FWork;
1186 end;
1187
1188 procedure TEditorForm.SaveActionUpdate(Sender: TObject);
1189 begin
1190         SaveAction.Enabled := False;
1191 end;
1192
1193 procedure TEditorForm.CloseActionUpdate(Sender: TObject);
1194 begin
1195         CloseAction.Enabled := not FWork;
1196 end;
1197
1198 procedure TEditorForm.UndoActionUpdate(Sender: TObject);
1199 begin
1200         UndoAction.Enabled := (GetActiveControlHandle <> 0)
1201                                                                                                 and (SendMessage(GetActiveControlHandle, EM_CANUNDO, 0, 0) <> 0)
1202                                                                                                 and (not FWork);
1203 end;
1204
1205 procedure TEditorForm.CutActionUpdate(Sender: TObject);
1206 var
1207         Selection: TSelection;
1208         AHandle: THandle;
1209 begin
1210         AHandle := GetActiveControlHandle;
1211         SendMessage(AHandle, EM_GETSEL, Longint(@Selection.StartPos), Longint(@Selection.EndPos));
1212         CutAction.Enabled := (AHandle <> 0)
1213                                                                                 and ((Selection.EndPos - Selection.StartPos) <> 0)
1214                                                                                 and (not FWork);
1215 end;
1216
1217 procedure TEditorForm.CopyActionUpdate(Sender: TObject);
1218 var
1219         Selection: TSelection;
1220         AHandle: THandle;
1221 begin
1222         AHandle := GetActiveControlHandle;
1223         SendMessage(AHandle, EM_GETSEL, Longint(@Selection.StartPos), Longint(@Selection.EndPos));
1224         CopyAction.Enabled := (AHandle <> 0)
1225                                                                                 and ((Selection.EndPos - Selection.StartPos) <> 0)
1226                                                                                 and (not FWork);
1227 end;
1228
1229 procedure TEditorForm.PasteActionUpdate(Sender: TObject);
1230 begin
1231         PasteAction.Enabled := (GetActiveControlHandle <> 0)
1232                                                                                         and (Clipboard.HasFormat(CF_TEXT))
1233                                                                                         and (not FWork);
1234 end;
1235
1236 procedure TEditorForm.TopActionUpdate(Sender: TObject);
1237 begin
1238         TopAction.Enabled := not FWork;
1239 end;
1240
1241 procedure TEditorForm.SageCheckBoxClick(Sender: TObject);
1242 begin
1243         if SageCheckBox.Checked then begin
1244                 if AnsiPos('sage', MailComboBox.Text) = 0 then
1245                         MailComboBox.Text := 'sage' + MailComboBox.Text;
1246         end else begin
1247                 if AnsiPos('sage', MailComboBox.Text) <> 0 then
1248                         MailComboBox.Text := StringReplace(MailComboBox.Text, 'sage', '', [rfReplaceAll]);
1249         end;
1250 end;
1251
1252 procedure TEditorForm.MailComboBoxChange(Sender: TObject);
1253 begin
1254         if AnsiPos('sage', MailComboBox.Text) = 0 then
1255                 SageCheckBox.Checked := False
1256         else
1257                 SageCheckBox.Checked := True;
1258 end;
1259
1260
1261 function TEditorForm.GetSPID(CookieLine: string): string;
1262 var
1263         s: string;
1264         i: Integer;
1265 begin
1266         Result := '';
1267         i := 0;
1268         while True do begin
1269                 s := Trim(GikoSys.GetTokenIndex(CookieLine, ';', i));
1270                 if s = '' then
1271                         Break
1272                 else begin
1273                         if Pos('SPID=', s) = 1 then begin
1274                                 Result := Trim(Copy(s, 6, Length(s)));
1275                                 Break;
1276                         end;
1277                 end;
1278                 inc(i);
1279         end;
1280 end;
1281
1282 function TEditorForm.GetPON(CookieLine: string): string;
1283 var
1284         s: string;
1285         i: Integer;
1286 begin
1287         Result := '';
1288         i := 0;
1289         while True do begin
1290                 s := Trim(GikoSys.GetTokenIndex(CookieLine, ';', i));
1291                 if s = '' then
1292                         Break
1293                 else begin
1294                         if Pos('PON=', s) = 1 then begin
1295                                 Result := Trim(Copy(s, 5, Length(s)));
1296                                 Break;
1297                         end;
1298                 end;
1299                 inc(i);
1300         end;
1301 end;
1302
1303 procedure TEditorForm.IdLogDebugReceive(ASender: TIdConnectionIntercept;
1304         AStream: TStream);
1305 var
1306         StringStream: TStringStream;
1307 begin
1308         StringStream := TStringStream.Create('');
1309         try
1310                 StringStream.CopyFrom(AStream, AStream.Size);
1311                 FDebugStrReceive := FDebugStrReceive + StringStream.DataString;
1312         finally
1313                 StringStream.Free;
1314         end;
1315 end;
1316
1317 procedure TEditorForm.IdLogDebugSend(ASender: TIdConnectionIntercept;
1318         AStream: TStream);
1319 var
1320         StringStream: TStringStream;
1321 begin
1322         StringStream := TStringStream.Create('');
1323         try
1324                 StringStream.CopyFrom(AStream, AStream.Size);
1325                 FDebugStrSend := FDebugStrSend + StringStream.DataString;
1326         finally
1327                 StringStream.Free;
1328         end;
1329 end;
1330
1331 procedure TEditorForm.TransActionExecute(Sender: TObject);
1332 begin
1333         AlphaBlend := TransAction.Checked;
1334         // \94¼\93§\96¾\8fó\91Ô\82Ì\95Û\91
1335         GikoSys.Setting.EditWindowTranslucent := TransAction.Checked;
1336 end;
1337
1338 procedure TEditorForm.TransActionUpdate(Sender: TObject);
1339 begin
1340         TransAction.Enabled := not FWork;
1341 end;
1342 //StatusBar\82ÌPanels[0]\82Ì\95\9d\82ð\89Â\95Ï\81B\8ec\82è\82ð\8cÅ\92è\82É\82·\82é
1343 procedure TEditorForm.StatusBarResize(Sender: TObject);
1344 begin
1345         StatusBar.Panels[0].Width := StatusBar.Width
1346                                                                         - StatusBar.Panels[1].Width - StatusBar.Panels[2].Width;
1347
1348 end;
1349
1350 procedure TEditorForm.Timer1Timer(Sender: TObject);
1351 begin
1352         if FSambaTime = ZERO_DATE then
1353                 StatusBar.Panels[1].Text := '\8f\89\8f\91'
1354         else begin
1355                 FNow := IncMilliSecond(FNow, 500);
1356                 StatusBar.Panels[1].Text := Format('%8.0f\95b\8co\89ß', [SecondSpan(FNow, FSambaTime)]);
1357         end;
1358
1359 end;
1360 //Samba.ini\82Ì\8f\91\82«\8d\9e\82Ý\8e\9e\8aÔ\82ð\93Ç\82Ý\8d\9e\82Þ
1361 procedure TEditorForm.ReadSambaTime(const AHost: string);
1362 var
1363         ini :TMemIniFile;
1364         tmp: string;
1365 begin
1366         Timer1.Enabled := false; //\8co\89ß\95b\90\94\95\\8e¦Timer\82ðOff\82É\82·\82é\81i\82±\82ê\82ªON\82Ì\82Æ\82«Samba24\91Î\8dôOn\81j
1367         FNow := Now();   //\8c»\8dÝ\8e\9e\8aÔ\82ð\8eæ\93¾\81iTimer\95\\8e¦\97p\82Å\81ACheck\82·\82é\82Æ\82«\82Í\8dÄ\82ÑNow()\82ð\8cÄ\82Ô\81j
1368         Timer1.Enabled := true; //\8co\89ß\95b\90\94\95\\8e¦Timer\82ðOn\82É\82·\82é\81i\82±\82ê\82ªON\82Ì\82Æ\82«Samba24\91Î\8dôOn\81j
1369         ini := TMemIniFile.Create(GikoSys.GetSambaFileName);
1370         try
1371                  //\95\8e\9a\97ñ\82Å\93Ç\82Ý\8eæ\82Á\82Ä\81A\95Ï\8a·\8aÖ\90\94\82ÅTDateTime\82Ö
1372                  tmp := ini.ReadString('Send', AHost, DateTimeToStr(ZERO_DATE));
1373                  FSambaTime := ConvertDateTimeString(tmp);
1374         finally
1375                 ini.Free;
1376         end;
1377 end;
1378 //Samba.ini\82É\8dÅ\8fI\8f\91\82«\8d\9e\82Ý\8e\9e\8aÔ\82ð\8f\91\82«\8d\9e\82Þ
1379 procedure TEditorForm.WriteSambaTime(const AHost: string; ATime: TDateTime);
1380 var
1381         ini :TMemIniFile;
1382 begin
1383         ini := TMemIniFile.Create(GikoSys.GetSambaFileName);
1384         try
1385                 ini.WriteDateTime('Send', AHost, ATime);
1386                 ini.UpdateFile;
1387         finally
1388                 ini.Free;
1389         end;
1390 end;
1391 //\8dÅ\8fI\8f\91\82«\8d\9e\82Ý\8e\9e\8aÔ\82Æ\8c»\8dÝ\8e\9e\82ð\94ä\8ar\82·\82é\81i\90^\81F\8bK\92è\92l\88È\8fã\81@\8bU\81F\8bK\92è\92l\96¢\96\9e\81j
1392 function TEditorForm.CheckSambaTime(const AHost: string; ATime: TDateTime): Boolean;
1393 var
1394         pastsec: double;
1395         SettingTime: Integer;
1396 begin
1397         SettingTime := ReadSettingTime(AHost);
1398         ReadSambaTime(AHost);
1399         pastsec := SecondSpan(ATime, FSambaTime);
1400         if pastsec > SettingTime then
1401                 Result := true
1402         else
1403                 Result := false;
1404 end;
1405 //AHost\81i\8eI\96¼\81j\82ÌSamba\82Ì\8bK\92è\92l\82ð\93Ç\82Ý\8d\9e\82Þ
1406 function TEditorForm.ReadSettingTime(const AHost: string): Integer;
1407 var
1408         ini :TMemIniFile;
1409 begin
1410         ini := TMemIniFile.Create(GikoSys.GetSambaFileName);
1411         try
1412                 Result := ini.ReadInteger('Setting', AHost, 0);
1413                 //\8bK\92è\92l\82ª\82O\82Ì\82Æ\82«\81A\82à\82µ\82­\82Í\90Ý\92è\82³\82ê\82Ä\82¢\82È\82¢\82Æ\82«\82Í\81A\83t\83@\83C\83\8b\82É\8f\91\82«\82½\82·\81B
1414                 if Result = 0 then begin
1415                         ini.WriteInteger('Setting', AHost, 0);
1416                         ini.UpdateFile;
1417                 end;
1418         finally
1419                 ini.Free;
1420         end;
1421 end;
1422 //Form\82ªActive\82É\82È\82Á\82½\82ç\8dÅ\8fI\8f\91\82«\8d\9e\82Ý\8e\9e\8aÔ\82ð\93Ç\82Ý\8d\9e\82Þ
1423 procedure TEditorForm.FormActivate(Sender: TObject);
1424 begin
1425         if ( Timer1.Enabled ) and ( FThreadItem <> nil )then
1426                 ReadSambaTime(FHost);
1427 end;
1428 //Samba24\91Î\8dô\82ð\8eg\82¤\82©\82Ç\82¤\82©\8c\88\82ß\82é\8aÖ\90\94
1429 //ReadSambaTime \82ð\8cÄ\82Ñ\8fo\82·\82ÆTimer\82ªOn\82É\82È\82é
1430 procedure TEditorForm.SetSamba24(AURL: string);
1431 var
1432         Protocol, Host, Path, Document, Port, Bookmark : string;
1433 begin
1434         //Samba24\91Î\8dô\82ð\82µ\82È\82¢\82È\82ç\8fI\97¹
1435         if not GikoSys.Setting.UseSamba then
1436                 Exit;
1437         //Host\82ÌURL\82É'.2ch.'\82©'.bbspink.'\82ª\8aÜ\82Ü\82ê\82Ä\82¢\82½\82çSamba24\91Î\8dô\82ð\82·\82é
1438         GikoSys.ParseURI( AURL, Protocol,Host, Path, Document, Port, Bookmark );
1439         if GikoSys.Is2chHost(Host) then begin
1440                 Host := Copy(Host, 1, AnsiPos('.', Host) - 1);
1441                 FHost := Host;   //FHost=\8eI\96¼
1442                 ReadSambaTime(FHost); //\88È\91O\82Ì\8f\91\82«\8d\9e\82Ý\8e\9e\8aÔ\82ð\93Ç\82Ý\8d\9e\82Þ
1443                 //StatusBar\82É\82±\82Ì\8eI\82Ì\8bK\92è\92l\82ð\95\\8e¦\82·\82é
1444                 StatusBar.Panels[2].Text := 'Samba24\8bK\92è\92l' + IntToStr(ReadSettingTime(FHost));
1445         end;
1446 end;
1447 procedure TEditorForm.FormCloseQuery(Sender: TObject;
1448   var CanClose: Boolean);
1449 begin
1450         CanClose := not FWork;
1451 end;
1452
1453 function TEditorForm.GetOEIndentChar : string;
1454 var
1455         regKey                  : TRegistry;
1456         Identities      : string;
1457         IndentChar      : DWORD;
1458 const
1459         DEFAULT_CHAR    = '> ';
1460         OE_MAIL_PATH    = '\Software\Microsoft\Outlook Express\5.0\Mail';
1461         INDENT_CHAR             = 'Indent Char';
1462 begin
1463
1464         Result  := DEFAULT_CHAR;
1465         regKey  := TRegistry.Create;
1466         try
1467                 try
1468                         regKey.RootKey  := HKEY_CURRENT_USER;
1469                         if not regKey.OpenKey( 'Identities', False ) then
1470                                 Exit;
1471                         Identities                      := regKey.ReadString( 'Default User ID' );
1472                         if Identities = '' then
1473                                 Exit;
1474                         if not regKey.OpenKey( Identities + OE_MAIL_PATH, False ) then
1475                                 Exit;
1476                         IndentChar := regKey.ReadInteger( INDENT_CHAR );
1477                         Result := Char( IndentChar ) + ' ';
1478                 except
1479                 end;
1480         finally
1481                 regKey.Free;
1482         end;
1483
1484 end;
1485
1486 procedure TEditorForm.QuotePasteActionExecute(Sender: TObject);
1487 var
1488         s                       : TStringList;
1489         i                       : Integer;
1490         quote   : string;
1491 begin
1492
1493         quote   := GetOEIndentChar;
1494         s                       := TStringList.Create;
1495         try
1496                 s.Text  := Clipboard.AsText;
1497
1498                 for i := s.Count - 1 downto 0 do
1499                         s[ i ]  := quote + s[ i ];
1500
1501                 BodyEdit.SelText        := s.Text;
1502         finally
1503                 s.Free;
1504         end;
1505
1506 end;
1507
1508 procedure TEditorForm.SpaceToNBSPActionExecute(Sender: TObject);
1509 begin
1510         GikoSys.Setting.SpaceToNBSP := SpaceToNBSPAction.Checked;
1511         if EditorPage.ActivePage = PreviewTab then
1512                 Preview;
1513 end;
1514
1515 procedure TEditorForm.AmpToCharRefActionExecute(Sender: TObject);
1516 begin
1517         GikoSys.Setting.AmpToCharRef := AmpToCharRefAction.Checked;
1518         if EditorPage.ActivePage = PreviewTab then
1519                 Preview;
1520 end;
1521
1522 procedure TEditorForm.SETTINGTXT1Click(Sender: TObject);
1523 var
1524         Visible: Boolean;
1525         ini: TMemIniFile;
1526 begin
1527         ini := TMemIniFile.Create(GetFileName);
1528         Visible := False;
1529         if not Visible then begin
1530                 SettingTab.TabVisible := True;
1531                 Settingtxt1.Checked := True;
1532                 Visible := True;
1533
1534                 try
1535                         ini.WriteBool('EditorForm', 'SettingTab', True);
1536                 finally
1537                         ini.Free;
1538                 end;
1539         end else begin
1540                 SettingTab.TabVisible := False;
1541                 Settingtxt1.Checked := False;
1542                 Visible := False;
1543
1544                 try
1545                         ini.WriteBool('EditorForm', 'SettingTab', False);
1546                 finally
1547                         ini.Free;
1548                 end;
1549         end;
1550
1551 end;
1552
1553 procedure TEditorForm.HEADTXT1Click(Sender: TObject);
1554 var
1555         Visible: Boolean;
1556         ini: TMemIniFile;
1557 begin
1558         Visible := False;
1559         ini := TMemIniFile.Create(GetFileName);
1560         if not Visible then begin
1561                 HeadTab.TabVisible := True;
1562                 HeadTXT1.Checked := True;
1563                 Visible := True;
1564
1565                 try
1566                         ini.WriteBool('EditorForm', 'HeadTab', True);
1567                 finally
1568                         ini.Free;
1569                 end;
1570         end else begin
1571                 HeadTab.TabVisible := False;
1572                 HeadTxt1.Checked := False;
1573                 Visible := False;
1574                 
1575                 try
1576                         ini.WriteBool('EditorForm', 'HeadTab', False);
1577                 finally
1578                         ini.Free;
1579                 end;
1580         end;
1581 end;
1582
1583 procedure TEditorForm.BoardTopClick(Sender: TObject);
1584 var
1585         Visible: Boolean;
1586         ini: TMemIniFile;
1587 begin
1588         Visible := False;
1589         ini := TMemIniFile.Create(GetFileName);
1590         if not Visible then begin
1591                 BoardTopTab.TabVisible := True;
1592                 BoardTop.Checked := True;
1593                 Visible := True;
1594
1595                 try
1596                         ini.WriteBool('EditorForm', 'BoardTopTab', True);
1597                 finally
1598                         ini.Free;
1599                 end;
1600         end else begin
1601                 BoardTopTab.TabVisible := False;
1602                 Boardtop.Checked := False;
1603                 Visible := False;
1604
1605                 try
1606                         ini.WriteBool('EditorForm', 'BoardTopTab', False);
1607                 finally
1608                         ini.Free;
1609                 end;
1610         end;
1611 end;
1612
1613 function TEditorForm.GetFileName(): string;
1614 begin
1615         Result := ExtractFilePath(Application.ExeName) + INI_FILE_NAME;
1616 end;
1617
1618 end.
1619