OSDN Git Service

レスエディタ/スレ立てエディタにUnicode対応表示を追加
[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         MSHTML,
11 {$ELSE}
12         SHDocVw_TLB,
13         MSHTML_TLB,
14 {$IFEND}
15         ActiveX, {HTTPApp,} YofUtils, IniFiles, StrUtils,
16         GikoSystem, GikoUtil, ImgList, Clipbrd, BoardGroup,
17         IdAntiFreezeBase,       IdAntiFreeze, IdBaseComponent, IdComponent,
18         IdTCPConnection, IdTCPClient, IdHTTP, ActnList, StdActns, IdIntercept,
19         IdLogBase, IdLogDebug, IdException, DateUtils,  bmRegExp,
20         Gesture, AppEvnts, SambaTimer, IdCookieManager, WideMemo;
21
22 type
23 //      TSetLayeredWindowAttributes = function(wnd: HWND; crKey: DWORD; bAlpha: BYTE; dwFlag: DWORD): Boolean; stdcall;
24         //\8f\91\82«\8d\9e\82Ý\96ß\82è\92l\83^\83C\83v
25         TGikoResultType = (grtOK, grtCookie, grtCheck, grtError, grtNinpou, grtNinpouErr, grtSuiton);
26
27         TEditorForm = class(TForm)
28                 MainMenu: TMainMenu;
29                 FileMenu: TMenuItem;
30                 PostMessage: TMenuItem;
31                 SaveMessage: TMenuItem;
32                 CloseMenu: TMenuItem;
33                 N01: TMenuItem;
34                 StatusBar: TStatusBar;
35         EditorPage: TPageControl;
36                 EditorTab: TTabSheet;
37                 PreviewTab: TTabSheet;
38                 Browser: TWebBrowser;
39                 EditMenu: TMenuItem;
40                 UndoMenu: TMenuItem;
41                 CutMenu: TMenuItem;
42                 CopyMenu: TMenuItem;
43                 PasteMenu: TMenuItem;
44                 N02: TMenuItem;
45                 ToolBarImageList: TImageList;
46                 HotToobarImageList: TImageList;
47                 NameBasePanel: TPanel;
48                 NameLabel: TLabel;
49                 MailLabel: TLabel;
50                 NameComboBox: TComboBox;
51                 MailComboBox: TComboBox;
52                 ToolBar: TToolBar;
53                 SendToolButton: TToolButton;
54                 OutBoxToolButton: TToolButton;
55                 ToolButton5: TToolButton;
56                 UndoToolButton: TToolButton;
57                 CutToolButton: TToolButton;
58                 CopyToolButton: TToolButton;
59                 PasteToolButton: TToolButton;
60                 ToolButton3: TToolButton;
61                 TransToolButton: TToolButton;
62                 TopToolButton: TToolButton;
63                 Indy: TIdHTTP;
64                 IdAntiFreeze: TIdAntiFreeze;
65                 ToolButton1: TToolButton;
66                 ToolButton2: TToolButton;
67                 ActionList: TActionList;
68                 SendAction: TAction;
69                 SaveAction: TAction;
70                 CloseAction: TAction;
71                 UndoAction: TAction;
72                 CutAction: TAction;
73                 CopyAction: TAction;
74                 PasteAction: TAction;
75                 AbortAction: TAction;
76                 TopAction: TAction;
77                 Show1: TMenuItem;
78                 T1: TMenuItem;
79                 N1: TMenuItem;
80                 S1: TMenuItem;
81                 SageCheckBox: TCheckBox;
82                 IdLogDebug: TIdLogDebug;
83                 TransAction: TAction;
84                 A1: TMenuItem;
85                 KotehanCheckBox: TCheckBox;
86                 TitlePanel: TPanel;
87                 Label1: TLabel;
88                 TitleEdit: TEdit;
89                 SelectAllAction: TAction;
90                 N2: TMenuItem;
91                 SelectAll1: TMenuItem;
92         QuotePasteAction: TAction;
93         QuotePasteMenuItem: TMenuItem;
94         C1: TMenuItem;
95         SpaceToNBSPAction: TAction;
96         AmpToCharRefAction: TAction;
97         SpaceTabnbsp1: TMenuItem;
98         amp1: TMenuItem;
99         BoardInformationTab: TTabSheet;
100                                 BoardtopTab: TTabSheet;
101         TitlePictureBrowser: TWebBrowser;
102         BoardTop: TMenuItem;
103         BoardInformationMemo: TMemo;
104         GetSETTINGTXTAction: TAction;
105         N3: TMenuItem;
106         SETTINGTXT2: TMenuItem;
107         GetTitlePictureAction: TAction;
108         OP1: TMenuItem;
109     GetHeadTXTAction: TAction;
110     HeadTXT1: TMenuItem;
111     RocalRuleTab: TTabSheet;
112     WebBrowser1: TWebBrowser;
113     CalcCapacityAction: TAction;
114     N4: TMenuItem;
115     N5: TMenuItem;
116     LocalRule: TMenuItem;
117     LocalEdit: TMemo;
118     N6: TMenuItem;
119     LocalRuleBrowse: TMenuItem;
120         ToolButton4: TToolButton;
121     ToolButton6: TToolButton;
122     SaveNameMailAction: TAction;
123     ToolButton7: TToolButton;
124     BeLogInOutEAction: TAction;
125     UpdateSambaAction: TAction;
126     Samba241: TMenuItem;
127     N7: TMenuItem;
128     InputAssistAction: TAction;
129     InputAssistPopupMenu: TPopupMenu;
130     ApplicationEvents1: TApplicationEvents;
131     ToolButton8: TToolButton;
132     ToolButton9: TToolButton;
133     ShowInputAssistForm: TAction;
134     ReleaseCookieAction: TAction;
135     Cookie1: TMenuItem;
136     ContinueModeAction: TAction;
137     ToolButton10: TToolButton;
138     ToolButton11: TToolButton;
139     OpenSendTargetAction: TAction;
140     ReloadTargetAction: TAction;
141     N8: TMenuItem;
142     N9: TMenuItem;
143     N10: TMenuItem;
144     UCInfoPanel: TPanel;
145
146                 procedure EditorPageChange(Sender: TObject);
147                 procedure FormCreate(Sender: TObject);
148                 procedure BrowserStatusTextChange(Sender: TObject;
149                         const Text: WideString);
150                 procedure FormClose(Sender: TObject; var Action: TCloseAction);
151                 procedure FormDestroy(Sender: TObject);
152                 procedure SendActionExecute(Sender: TObject);
153                 procedure SaveActionExecute(Sender: TObject);
154                 procedure AbortActionExecute(Sender: TObject);
155                 procedure CloseActionExecute(Sender: TObject);
156                 procedure UndoActionExecute(Sender: TObject);
157                 procedure CutActionExecute(Sender: TObject);
158                 procedure CopyActionExecute(Sender: TObject);
159                 procedure PasteActionExecute(Sender: TObject);
160                 procedure SendActionUpdate(Sender: TObject);
161                 procedure SaveActionUpdate(Sender: TObject);
162                 procedure CloseActionUpdate(Sender: TObject);
163                 procedure UndoActionUpdate(Sender: TObject);
164                 procedure CutActionUpdate(Sender: TObject);
165                 procedure CopyActionUpdate(Sender: TObject);
166                 procedure PasteActionUpdate(Sender: TObject);
167                 procedure TopActionExecute(Sender: TObject);
168                 procedure TopActionUpdate(Sender: TObject);
169                 procedure SageCheckBoxClick(Sender: TObject);
170                 procedure MailComboBoxChange(Sender: TObject);
171                 procedure TransActionExecute(Sender: TObject);
172                 procedure TransActionUpdate(Sender: TObject);
173                 procedure IdLogDebugReceive(ASender: TIdConnectionIntercept;
174                         AStream: TStream);
175                 procedure IdLogDebugSend(ASender: TIdConnectionIntercept;
176                         AStream: TStream);
177                 procedure SelectAllActionExecute(Sender: TObject);
178         procedure StatusBarResize(Sender: TObject);
179         procedure FormActivate(Sender: TObject);
180         procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
181                 procedure QuotePasteActionExecute(Sender: TObject);
182         procedure SpaceToNBSPActionExecute(Sender: TObject);
183         procedure AmpToCharRefActionExecute(Sender: TObject);
184         procedure BoardTopClick(Sender: TObject);
185         procedure GetSETTINGTXTActionExecute(Sender: TObject);
186         procedure GetTitlePictureActionUpdate(Sender: TObject);
187         procedure GetTitlePictureActionExecute(Sender: TObject);
188     procedure GetHeadTXTActionExecute(Sender: TObject);
189         procedure CalcCapacityActionExecute(Sender: TObject);
190     procedure LocalRuleClick(Sender: TObject);
191     procedure FormDeactivate(Sender: TObject);
192     procedure LocalRuleBrowseClick(Sender: TObject);
193     procedure SaveNameMailActionExecute(Sender: TObject);
194     procedure BeLogInOutEActionExecute(Sender: TObject);
195     procedure BeLogInOutEActionUpdate(Sender: TObject);
196     procedure UpdateSambaActionUpdate(Sender: TObject);
197     procedure UpdateSambaActionExecute(Sender: TObject);
198     procedure InputAssistActionExecute(Sender: TObject);
199     procedure ApplicationEvents1Message(var Msg: tagMSG;
200       var Handled: Boolean);
201     procedure ShowInputAssistFormExecute(Sender: TObject);
202     procedure ReleaseCookieActionExecute(Sender: TObject);
203     procedure GetSETTINGTXTActionUpdate(Sender: TObject);
204     procedure GetHeadTXTActionUpdate(Sender: TObject);
205     procedure ContinueModeActionExecute(Sender: TObject);
206     procedure ContinueModeActionUpdate(Sender: TObject);
207     procedure OpenSendTargetActionExecute(Sender: TObject);
208     procedure ReloadTargetActionExecute(Sender: TObject);
209         private
210                 FThreadItem: TThreadItem;
211                 FBoard: TBoard;
212                 FNameComboEdit: THandle;
213                 FMailComboEdit: THandle;
214                 FAbort: Boolean;
215                 FWork: Boolean;
216                 FStatusCode: Integer;
217                 FDebugStrReceive: string;
218                 FDebugStrSend: string;
219                 FNow: TDateTime;
220                 FInputAssistKey: String;        ///< \93ü\97Í\83A\83V\83X\83g\82Ì\83L\81[
221                 FResistWords: TStringList;      ///< \93ü\97Í\83A\83V\83X\83g\82Ì\8e«\8f\91\82©\82ç\82Ì\8c\9f\8dõ\8c\8b\89Ê
222         FSambaTimer: TSambaTimer;   ///< Samba\91Î\8dô\82Ì\83^\83C\83}\81[
223         FCookieDomain: string;        ///< \94E\96@\92\9f\83h\83\81\83C\83\93
224                 procedure Preview;
225                 function Check: Boolean;
226                 procedure SetNameList(sName, sMail: string);
227                 procedure Send(const ACOOKIE: string; const SPID: string; const PON: string; FirstWriting: Boolean);
228                 function GetActiveControlHandle: THandle;
229                 procedure GetSendData(Source: TStringStream);
230                 procedure SaveSendFile;
231                 procedure SetContent(Content: string; ABrowser: TWebBrowser);
232                 function GetResultType(ResponseText: string): TGikoResultType;
233                 /// \96{\95\82Ì\8eæ\93¾
234                 function GetBody : string;
235                 //IdHttp\82Ì\8f\89\8aú\89»
236                 procedure InitIdHTTP(http: TIdHTTP);
237                 procedure ShowBoardInformation(ABoard: TBoard; AMemo: TMemo);
238                 function GetTitlePictureURL(body: TStringList; ABoard: TBoard): string;
239                 procedure ShowTitlePicture();
240                                 function GetFusianaName(body: TStringList; ABoard: TBoard): String;
241                 //! \83}\83E\83X\83W\83F\83X\83`\83\83\81[\8aJ\8en
242                 procedure OnGestureStart(Sender: TObject);
243                 //! \83}\83E\83X\83W\83F\83X\83`\83\83\81[\92\86
244                 procedure OnGestureMove(Sender: TObject);
245                 //! \83}\83E\83X\83W\83F\83X\83`\83\83\81[\8fI\97¹
246                 procedure OnGestureEnd(Sender: TObject);
247                                 //HEAD.TXT\8e©\93®\95\\8e¦
248                                 procedure ShowBoardHead(ABoard: TBoard; AMemo: TMemo);
249                                 //LocalFusianaTrapAlart
250                                 function LFusianaGet(const s: String): Boolean;
251                 // Cookie\82Ì\8eæ\93¾
252                 procedure GetCookie(CookieMng: TIdCookieManager; ABoard: TBoard);
253         // hidden\83f\81[\83^\8eæ\93¾
254         procedure GetHiddenParameter(Rawtext: String; ABoard: TBoard);
255                 //! \93ü\97Í\83A\83V\83X\83g\82Ì\83|\83b\83v\83A\83b\83v\83\81\83j\83\85\81[\82Ì\83N\83\8a\83b\83N\83C\83x\83\93\83g
256                 procedure InputAssistMenuClick(Sender: TObject);
257                 //! TMemo\82Ì\83J\81[\83\\83\8b\88Ê\92u\82É\95\8e\9a\97ñ\91}\93ü
258 //              procedure InsertText(Memo: TMemo; Text: String);
259                 //! \91\97\90M\92\86\8e~
260                 procedure CancelSend(ABoard: TBoard; ASysMenu: HMENU);
261         //! Samba\83^\83C\83}\81[\83C\83x\83\93\83g
262         procedure SambaTimer(Sender: TObject);
263         //! \83E\83B\83\93\83h\83E\82Ì\88Ê\92u\82Æ\83T\83C\83Y\82Ì\90Ý\92è
264         procedure SetWindowRect;
265         //! \8ag\92£\83^\83u\90Ý\92è
266         procedure SetExtraTab;
267         //! \94Â\8eæ\93¾
268         function GetBoard : TBoard;
269         //! URL\82Ì\83f\81[\83^\82ðstream\82É\8eæ\82è\8d\9e\82Þ
270         procedure GetWebData(const URL: string; const RefURL: string;
271              Modified: TDateTime; stream: TStream);
272         //! GikoForm\82É\90V\92\85\83\81\83b\83Z\81[\83W\82ð\92Ç\89Á\82·\82é
273         procedure AddFormMessageNew(icon: TGikoMessageIcon);
274         //! \83\8d\81[\83J\83\8bfusiana\83g\83\89\83b\83v
275         function isLocalFusianaTrap: Boolean;
276         //! \83\8d\81[\83J\83\8bfusiana\83g\83\89\83b\83v
277         function isRemoteFusianaTrap: Boolean;
278         //! Header\95\8e\9a\97ñ\8eæ\93¾
279         function getHeaderStr(const ACOOKIE: string; const SPID : string;
280             const PON : string; const HAP : string; Board : TBoard) : string;
281         //! fusiana\8cx\8d\90\83_\83C\83A\83\8d\83O
282         function FusianaMsgBox: Integer;
283         //! sent.ini\83t\83@\83C\83\8b\82Ì\90\90¬
284         function CreateSentIniFile: TMemIniFile;
285         //! \8cë\94\9a\83`\83F\83b\83N
286         function isGobaku: Boolean;
287         protected
288                 procedure CreateParams(var Params: TCreateParams); override;
289         public
290         BodyEdit: TWideMemo;
291                 FBBSID: String;
292                 procedure SetFont;
293                 procedure SetThreadItem(Item: TThreadItem);
294                 procedure SetBoard(Item: TBoard);
295         procedure UpdateSambaStatus;
296                 property BBSID: string read FBBSID write FBBSID;
297         end;
298
299 implementation
300
301 uses
302         Giko, ItemDownload, MojuUtils, IdGlobal, GikoMessage,  Imm,
303   InputAssistDataModule, InputAssist, HTMLCreate, IdCookie, GikoDataModule,
304   Belib;
305 const
306         CAPTION_NAME_NEW: string = '\83M\83R\83i\83\83X\83\8c\97§\82Ä\83G\83f\83B\83^';
307         CAPTION_NAME_RES: string = '\83M\83R\83i\83\83\8c\83X\83G\83f\83B\83^';
308
309         // \83G\83f\83B\83b\83g\83E\83B\83\93\83h\83E\82ð\89E\89º\82É\82¸\82ç\82µ\82Ä\8aJ\82­\88Ú\93®\97Ê
310         WINDOWMOVE_H = 30;
311         WINDOWMOVE_V = 30;
312
313         //DAX\82³\82ñ±Ø¶ÞÄ!(\81L\81¤\81M)
314         READCGI_ERR                     = '-ERR';
315         READCGI_INCR            = '-INCR';
316         READCGI_OK                      = '+OK';
317         READCGI_PARTIAL = '+PARTIAL';
318         READCGI_ERR_FOUND_KAKO  = '-ERR \89ß\8b\8e\83\8d\83O\91q\8cÉ\82Å\94­\8c©';
319         READCGI_ERR_NOT_HTML            = '-ERR html\89»\91Ò\82¿';
320         READCGI_ERR_NOT_FOUND           = '-ERR \82»\82ñ\82È\94Âor\83X\83\8c\83b\83h\82È\82¢\82Å\82·\81B';
321         READCGI_ERR_ABONE                               = '-ERR \82Ç\82±\82©\82Å\82 \82Ú\81[\82ñ\82ª\82 \82Á\82½\82Ý\82½\82¢\82Å\82·\81B';
322         READCGI_ERR_TIMEOUT                     = '-ERR \8ew\92è\8e\9e\8aÔ\82ª\89ß\82¬\82Ü\82µ\82½\81B';
323         READCGI_ERR_CANTUSE                     = '-ERR \82à\82¤\81@\82Â\82©\82¦\82Ü\82¹\82ñ';
324         RES2CH_TRUE                             = '<!-- 2ch_X:true -->';
325         RES2CH_FALSE                    = '<!-- 2ch_X:false -->';
326         RES2CH_ERROR                    = '<!-- 2ch_X:error -->';
327         RES2CH_CHECK                    = '<!-- 2ch_X:check -->';
328         RES2CH_COOKIE                   = '<!-- 2ch_X:cookie -->';
329
330 type
331         TSelection = record
332                 StartPos, EndPos: Integer;
333         end;
334
335 {$R *.DFM}
336
337 {constructor TEditorForm.Create(AOwner: TComponent; Item: TBoard);
338 begin
339         inherited Create(AOwner);
340 end;}
341
342 procedure TEditorForm.CreateParams(var Params: TCreateParams);
343 begin
344         inherited;
345         if FormStyle in [fsNormal, fsStayOnTop] then
346                 if BorderStyle in [bsSingle, bsSizeable] then begin
347                         Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
348                         Params.WndParent := 0;
349                 end;
350 end;
351
352 {procedure TEditorForm.CreateParams(var Params: TCreateParams);
353 begin
354         inherited CreateParams(Params);
355         Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
356 end;}
357
358 procedure TEditorForm.FormCreate(Sender: TObject);
359 begin
360     BodyEdit := TWideMemo.Create(EditorTab);
361     BodyEdit.Parent := EditorTab;
362     BodyEdit.Align := alClient;
363     BodyEdit.ScrollBars := ssBoth;
364
365         FWork := False;
366     FSambaTimer := TSambaTimer.Create(Self);
367     FSambaTimer.Interval := 0;
368         Browser.Navigate('about:blank');
369         TitlePictureBrowser.Navigate('about:blank');
370     WebBrowser1.Navigate('about:blank');
371         FBoard := nil;
372         FThreadItem := nil;
373
374     if (Owner <> nil) and (Owner.ClassNameIs('TKeySettingForm') = False) then
375         //\83E\83B\83\93\83h\83E\82Ì\88Ê\92u\90Ý\92è
376         SetWindowRect;
377
378         EditorPage.ActivePage := EditorTab;
379         FNameComboEdit := GetWindow(NameComboBox.Handle, GW_CHILD);
380         FMailComboEdit := GetWindow(MailComboBox.Handle, GW_CHILD);
381         NameComboBox.Items.Assign(GikoSys.Setting.NameList);
382         MailComboBox.Items.Assign(GikoSys.Setting.MailList);
383         SetFont;
384     // \94¼\93§\96¾\97\98\97p\89Â\94\\90Ý\92è
385     TransAction.Enabled := GikoSys.CanUser32DLL;
386
387     // \83E\83B\83\93\83h\83E\82Ì\83X\83e\83C\8fó\91Ô
388         if GikoSys.Setting.EditWindowStay then begin    // \83X\83e\83C\8fó\91Ô
389                 SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
390                 TopAction.Checked := true;
391                 TopToolButton.Down := true;
392         end else begin                                  // \83X\83e\83C\82µ\82È\82¢
393                 SetWindowPos(Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
394                 TopAction.Checked := false;
395                 TopToolButton.Down := false;
396         end;
397
398     // \83E\83B\83\93\83h\83E\82Ì\94¼\93§\96¾\8fó\91Ô
399         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Ô
400         AlphaBlend := true;
401         TransAction.Checked := true;
402         TransToolButton.Down := true;
403     end else begin                                      // \95s\93§\96¾
404         AlphaBlend := false;
405         TransAction.Checked := false;
406         TransToolButton.Down := false;
407     end;
408         // \94¼\93§\96¾\8fó\91Ô\82Ì\95Û\91
409         GikoSys.Setting.EditWindowTranslucent := TransAction.Checked;
410
411         SpaceToNBSPAction.Checked               := GikoSys.Setting.SpaceToNBSP;
412         AmpToCharRefAction.Checked      := GikoSys.Setting.AmpToCharRef;
413     // \83\8d\81[\83J\83\8b\83\8b\81[\83\8b\81{\94Â\83g\83b\83v\89æ\91\9c\82Ì\83^\83u\82Ì\90Ý\92è
414     SetExtraTab;
415
416         // \83L\81[\90Ý\92è\82Ì\93Ç\82Ý\8d\9e\82Ý
417         GikoSys.LoadKeySetting(ActionList, GikoSys.GetEditorKeyFileName);
418         SaveNameMailAction.Checked := True;
419 end;
420 procedure TEditorForm.SetBoard(Item: TBoard);
421 begin
422         FBoard := Item;
423         Caption := CAPTION_NAME_NEW + ' - [' + Item.Title + ']';
424         NameComboBox.Text := FBoard.KotehanName;
425         MailComboBox.Text := FBoard.KotehanMail;
426         SageCheckBox.Checked := AnsiPos('sage', MailComboBox.Text) <> 0;
427         TitlePanel.Visible := True;
428
429     if (FSambaTimer.SetBoard(FBoard) >= 0) then begin
430         UpdateSambaStatus;
431         FNow := Now();
432         FSambaTimer.OnTimer := SambaTimer;
433     end;
434
435         ShowBoardInformation(FBoard, BoardInformationMemo);
436         ShowTitlePicture();
437 end;
438
439 procedure TEditorForm.SetThreadItem(Item: TThreadItem);
440 begin
441         FThreadItem := Item;
442         Caption := CAPTION_NAME_RES + ' - [' + FThreadItem.Title + ']';
443         NameComboBox.Text := FThreadItem.ParentBoard.KotehanName;
444         MailComboBox.Text := FThreadItem.ParentBoard.KotehanMail;
445         SageCheckBox.Checked := AnsiPos('sage', MailComboBox.Text) <> 0;
446         TitlePanel.Visible := False;
447
448     if (FSambaTimer.SetBoard(FThreadItem.ParentBoard) >= 0) then begin
449         UpdateSambaStatus;
450         FNow := Now();
451         FSambaTimer.OnTimer := SambaTimer;
452     end;
453
454         ShowBoardInformation(FThreadItem.ParentBoard, BoardInformationMemo);
455         ShowTitlePicture();
456 end;
457
458 function TEditorForm.GetBody : string;
459 var
460         body, tmp               : string;
461         p, tail                 : PChar;
462         len                                     : Integer;
463 const
464         TAB_LENGTH      = 4;
465 begin
466
467         body := BodyEdit.EncodeText;
468         if AmpToCharRefAction.Checked then
469                 // & \82Ì\92u\8a·\82Í\88ê\94Ô\8dÅ\8f\89\82É\82â\82é\82±\82Æ
470                 body := CustomStringReplace( body, '&', '&amp;' );
471         if SpaceToNBSPAction.Checked then begin
472                 p                       := PChar( body );
473                 tail    := p + Length( body );
474                 len             := 0;
475                 while p < tail do begin
476                         case p^ of
477                         #09:
478                                 begin
479                                         Inc( p );
480                                         repeat
481                                                 Inc( len );
482                                                 tmp := tmp + '&nbsp;';
483                                         until (len mod TAB_LENGTH) = 0;
484                                 end;
485
486                         #10, #13:
487                                 begin
488                                         tmp := tmp + p^;        Inc( p );
489                                         len     := 0;
490                                 end;
491
492                         ' ':
493                                 begin
494                                         tmp     := tmp + '&nbsp;';
495                                         Inc( p );
496                                         Inc( len );
497                                 end;
498                                 
499                         '&':
500                                 // \8eÀ\91Ì\8eQ\8fÆ\82Í 1 \95\8e\9a\95ª
501                                 begin
502                                         tmp := tmp + '&';
503                                         Inc( p );
504                                         Inc( len );
505                                         while p < tail do begin
506                                                 if p^ in ['a'..'z', 'A'..'Z', '0'..'9', '#'] then begin
507                                                         tmp := tmp + p^;
508                                                 end else if p^ = ';' then begin
509                                                         tmp := tmp + p^;
510                                                         Inc( p );
511                                                         Break;
512                                                 end else begin
513                                                         Break;
514                                                 end;
515                                                 Inc( p );
516                                         end;
517                                 end;
518
519                         else
520                                 if p^ in kYofKanji then begin
521                                         tmp := tmp + p^;        Inc( p );
522                                         tmp     := tmp + p^;    Inc( p );
523                                         len     := len + 2;
524                                 end else begin
525                                         tmp := tmp + p^;        Inc( p );
526                                         Inc( len );
527                                 end;
528                         end;
529                 end;
530                 body := tmp;
531         end;
532
533         Result  := body;
534
535 end;
536
537 procedure TEditorForm.SetFont;
538 begin
539         BodyEdit.Font.Name := GikoSys.Setting.EditorFontName;
540         BodyEdit.Font.Size := GikoSys.Setting.EditorFontSize;
541         BodyEdit.Font.Color := GikoSys.Setting.EditorFontColor;
542         BodyEdit.Color := GikoSys.Setting.EditorBackColor;
543 end;
544
545 procedure TEditorForm.Preview;
546 var
547         Title: string;
548         No: string;
549         Mail: string;
550         Namae: string;
551         Body: string;
552         s: string;
553 begin
554         if FThreadItem = nil then begin
555                 No := '1';
556                 Title := THTMLCreate.RepHtml(TitleEdit.Text);
557         end else begin
558                 No := IntToStr(FThreadItem.Count + 1);
559                 Title := THTMLCreate.RepHtml(FThreadItem.Title);
560         end;
561
562         Body := GetBody;
563         Namae := THTMLCreate.RepHtml(NameComboBox.Text);
564         Mail := THTMLCreate.RepHtml(MailComboBox.Text);
565         Body := THTMLCreate.RepHtml(Body);
566         Body := CustomStringReplace(Body, #13#10, '<br>', False);
567
568
569         if Trim(Namae) = '' then
570                 Namae := '\96¼\96³\82µ\82³\82ñ';
571
572     s := THTMLCreate.CreatePreviewHTML(Title, No, Mail, Namae, Body);
573     
574         SetContent(s, Browser);
575 end;
576
577 procedure TEditorForm.EditorPageChange(Sender: TObject);
578 var
579         tmpBoard: TBoard;
580 begin
581
582     tmpBoard := GetBoard;
583
584         if tmpBoard = nil then Exit;
585
586         if EditorPage.ActivePage = PreviewTab then begin
587                 Preview;
588         end else if EditorPage.ActivePage = RocalRuleTab then begin
589                 if not FileExists(tmpBoard.GETHEADTXTFileName) then begin
590                         LocalEdit.Text := '\83\8d\81[\83J\83\8b\83\8b\81[\83\8b\96¢\8eæ\93¾';
591                         Exit;
592                 end;
593                 ShowBoardHead(tmpBoard, LocalEdit);
594         end else begin
595                 Browser.Navigate('about:blank');
596         end;
597 end;
598
599 procedure TEditorForm.BrowserStatusTextChange(Sender: TObject;
600         const Text: WideString);
601 begin
602         if EditorPage.ActivePage = PreviewTab then begin
603                 StatusBar.Panels[0].Text := Text;
604         end else begin
605                 StatusBar.Panels[0].Text := '';
606         end;
607 end;
608
609 function TEditorForm.Check: Boolean;
610 const
611         REQUIRED: string = '\82ª\93ü\97Í\82³\82ê\82Ä\82¢\82Ü\82¹\82ñ\81B';
612         ERROR: string = '\83G\83\89\81[';
613 var
614         Msg: string;
615         rc: Integer;
616         Board: TBoard;
617 begin
618         Result := True;
619
620     Board := GetBoard;
621
622         if (not GikoSys.Setting.UseMachineTime) and
623                  ((Board.LastGetTime = 0) or
624                         (Board.LastGetTime = ZERO_DATE)) then begin
625                 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
626                                  + '\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¢';
627                 MsgBox(Handle, Msg, ERROR, MB_OK or MB_ICONSTOP);
628                 Result := False;
629         end else if BodyEdit.Text = '' then begin
630                 Msg := '\96{\95¶' + REQUIRED;
631                 MsgBox(Handle, Msg, ERROR, MB_OK or MB_ICONSTOP);
632                 Result := False;
633         end else if (FBoard <> nil) and (Trim(TitleEdit.Text) = '') then begin
634                 Msg := '\83^\83C\83g\83\8b' + REQUIRED;
635                 MsgBox(Handle, Msg, ERROR, MB_OK or MB_ICONSTOP);
636                 Result := False;
637         end else begin
638                 if (not GikoSys.Dolib.Connected) and (AnsiPos('\81\9c', NameComboBox.Text) <> 0) then begin
639                         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
640                                          + '\82±\82Ì\82Ü\82Ü\91\97\90M\82µ\82Ä\82à\82æ\82ë\82µ\82¢\82Å\82·\82©\81H';
641                         rc := MsgBox(Handle, Msg, '\8am\94F', MB_YESNO or MB_ICONQUESTION);
642                         Result := (rc = IDYES);
643                 end;
644         end;
645 end;
646
647 procedure TEditorForm.FormClose(Sender: TObject; var Action: TCloseAction);
648 begin
649         Action := caFree;
650 end;
651
652 procedure TEditorForm.FormDestroy(Sender: TObject);
653 var
654         wp: TWindowPlacement;
655 begin
656     FSambaTimer.Free;
657
658     if (Owner <> nil) and (Owner.ClassNameIs('TKeySettingForm') = False) then begin
659         //\8dÅ\91å\89»\81E\83E\83B\83\93\83h\83E\88Ê\92u\95Û\91
660         wp.length := sizeof(wp);
661         GetWindowPlacement(Handle, @wp);
662
663         GikoSys.Setting.EditWindowTop := wp.rcNormalPosition.Top;
664         GikoSys.Setting.EditWindowLeft := wp.rcNormalPosition.Left;
665         GikoSys.Setting.EditWindowHeight := wp.rcNormalPosition.Bottom - wp.rcNormalPosition.Top;
666         GikoSys.Setting.EditWindowWidth := wp.rcNormalPosition.Right - wp.rcNormalPosition.Left;
667         GikoSys.Setting.EditWindowMax := WindowState = wsMaximized;
668         //GikoSys.Setting.EditWindowStay := FormStyle = fsStayOnTop;      // \83X\83e\83C\8fó\91Ô\82Ì\95Û\91
669         GikoSys.Setting.EditWindowTranslucent := TransAction.Checked;   // \94¼\93§\96¾\8fó\91Ô\82Ì\95Û\91
670     end;
671
672     BodyEdit.Free;
673 end;
674
675 procedure TEditorForm.SetNameList(sName, sMail: string);
676 begin
677         if SaveNameMailAction.Checked then begin
678                 if Trim(sName) <> '' then begin
679                         if GikoSys.Setting.NameList.IndexOf(sName) = -1 then
680                                 GikoSys.Setting.NameList.Insert(0, sName);
681                 end;
682                 if Trim(sMail) <> '' then begin
683                         if GikoSys.Setting.MailList.IndexOf(sMail) = -1 then
684                                 GikoSys.Setting.MailList.Insert(0, sMail);
685                 end;
686         end;
687 end;
688
689 function TEditorForm.GetActiveControlHandle: THandle;
690 begin
691         if EditorPage.ActivePage = EditorTab then begin
692                 if ActiveControl = NameComboBox then
693                         Result := FNameComboEdit
694                 else if ActiveControl = MailComboBox then
695                         Result := FMailComboEdit
696                 else if ActiveControl = BodyEdit then
697                         Result := BodyEdit.Handle
698                 else if ActiveControl = TitleEdit then
699                         Result := TitleEdit.Handle
700                 else
701                         Result := 0;
702         end else if Editorpage.ActivePage = BoardInformationTab then begin
703                 if ActiveControl = BoardInformationMemo then
704                         Result := BoardInformationMemo.Handle
705                 else
706                         Result := 0;
707         end else if Editorpage.ActivePage = RocalRuleTab then begin
708                 if ActiveCOntrol = LocalEdit then
709                         Result := LocalEdit.Handle
710                 else
711                         Result := 0;
712         end else
713                 Result := 0;
714 end;
715
716 procedure TEditorForm.SetContent(Content: string; ABrowser: TWebBrowser);
717 var
718         doc: OleVariant;
719 begin
720         if Assigned(ABrowser.ControlInterface.Document) then begin
721                 doc := OleVariant(ABrowser.Document);
722                 doc.Clear;
723                 doc.open;
724                 doc.charset := 'Shift_JIS';
725                 doc.Write(Content);
726                 doc.Close;
727         end;
728 end;
729 procedure TEditorForm.InitIdHTTP(http: TIdHTTP);
730 begin
731         http.Request.Clear;
732         http.ProxyParams.BasicAuthentication := False;
733         if GikoSys.Setting.WriteProxy then begin
734                 http.ProxyParams.ProxyServer := GikoSys.Setting.WriteProxyAddress;
735                 http.ProxyParams.ProxyPort := GikoSys.Setting.WriteProxyPort;
736                 http.ProxyParams.ProxyUsername := GikoSys.Setting.WriteProxyUserID;
737                 http.ProxyParams.ProxyPassword := GikoSys.Setting.WriteProxyPassword;
738                 if GikoSys.Setting.ReadProxyUserID <> '' then
739                         http.ProxyParams.BasicAuthentication := True;
740         end else begin
741                 http.ProxyParams.ProxyServer := '';
742                 http.ProxyParams.ProxyPort := 80;
743                 http.ProxyParams.ProxyUsername := '';
744                 http.ProxyParams.ProxyPassword := '';
745         end;
746         http.Request.UserAgent := GikoSys.GetUserAgent;
747         http.Request.AcceptEncoding := '';
748     http.AllowCookies := True;
749     http.ReadTimeout := GikoSys.Setting.ReadTimeOut;
750     http.ConnectTimeout := GikoSys.Setting.ReadTimeOut;
751 end;
752 //! \91\97\90M\92\86\8e~\82Ì\82½\82ß\82Ì\83\81\83j\83\85\81[\82Ì\8dÄ\90
753 procedure TEditorForm.CancelSend(ABoard: TBoard; ASysMenu: HMENU);
754 begin
755         ABoard.SPID := '';
756         ABoard.PON := '';
757         FWork := false;
758         EnableMenuItem(ASysMenu, SC_CLOSE, MF_BYCOMMAND or MF_ENABLED);
759         DrawMenuBar(Handle);
760 end;
761
762 procedure TEditorForm.Send( const ACOOKIE: string; const SPID: string;
763  const PON: string; FirstWriting: Boolean);
764 var
765         TextStream: TStringStream;
766         Source: TStringStream;
767         ResponseText: string;
768         URL: string;
769         State: TGikoDownloadState;
770         ResultType: TGikoResultType;
771         MsgResult: Integer;
772         Board: TBoard;
773         sysMenu : HMENU;
774     ExpMsg: String;
775     {Protocol,Host, Path, Document, Port, Bookmark : String;}
776 begin
777         FAbort := False;
778         State := gdsError;
779     Board := GetBoard;
780
781         InitIdHTTP(Indy);
782         if FThreadItem = nil then begin
783                 URL := FBoard.GetSendURL;
784                 Indy.Request.Referer := GikoSys.UrlToServer(FBoard.URL) + 'test/bbs.cgi';
785         end else begin
786                 URL := FThreadItem.GetSendURL;
787                 Indy.Request.Referer := FThreadItem.URL;
788         end;
789         sysMenu := GetSystemMenu( Handle, false );
790         EnableMenuItem( sysMenu, SC_CLOSE, MF_GRAYED );
791 {
792   EnableMenuItem(SysMenu, SC_CLOSE, MF_BYCOMMAND or MF_ENABLED);
793   DrawMenuBar(Handle);
794 }
795         Indy.Request.CustomHeaders.Clear;
796 //      Indy.Request.CacheControl := 'no-cache';
797         Indy.Request.CustomHeaders.Add('Pragma: no-cache');
798         Indy.Request.AcceptLanguage := 'ja';
799         Indy.Request.Accept := 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*';
800         Indy.Request.ContentType := 'application/x-www-form-urlencoded';
801         Indy.Request.CustomHeaders.Add(getHeaderStr(ACOOKIE, SPID, PON, GikoSys.GetBouken(URL, FCookieDomain), Board));
802         TextStream := TStringStream.Create('');
803         Source := TStringStream.Create('');
804         try
805                 try
806                         FDebugStrReceive := '';
807                         FDebugStrSend := '';
808
809                         if (FirstWriting) then begin
810                                 //\83t\83V\83A\83i\83g\83\89\83b\83v\8cx\8d\90(LocalMode) by \92è\8aú\95Ö
811                 if (isLocalFusianaTrap) then begin
812                     CancelSend( Board, SysMenu );
813                     Exit;
814                 end;
815                 //\83t\83V\83A\83i\83g\83\89\83b\83v\8cx\8d\90(Remote)
816                 if (isRemoteFusianaTrap) then begin
817                     CancelSend( Board, SysMenu );
818                     Exit;
819                 end;
820                 // \8cë\94\9a\83`\83F\83b\83N
821                 if (isGobaku) then begin
822                     CancelSend( Board, SysMenu );
823                     Exit;
824                 end;
825                         end;
826
827                         GetSendData(Source);
828                         IdAntiFreeze.Active := True;
829                         try
830                                 Indy.Post(URL, Source, TextStream);
831                         finally
832                                 IdAntiFreeze.Active := False;
833                         end;
834                         ResponseText := TextStream.DataString;
835
836                         ResultType := GetResultType(ResponseText);
837
838
839                         if ResultType = grtOK then begin
840                                 if (GikoSys.Setting.UseSamba) and  (FSambaTimer.Enabled) then
841                 begin
842                     FSambaTimer.WriteSambaTime(Now());
843                 end;
844                 GetCookie(Indy.CookieManager, Board);
845                                 State := gdsComplete;
846                         end else if ResultType = grtCookie then begin
847                                 //\83\8b\81[\83v\96h\8e~
848                                 if not FirstWriting then
849                                         raise Exception.Create('');
850
851                                 MsgResult := MsgBox( Handle,
852                                                                 '\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 +
853                                                                 '\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 +
854                                                                 '\91S\90Ó\94C\82ð\95\89\82¤\82±\82Æ\82ð\8f³\91ø\82µ\82Ä\8f\91\82«\8d\9e\82Ý\82Ü\82·\82©\81H',
855                                                                 '\8fî\95ñ',
856                                                                 MB_YESNO or MB_ICONQUESTION);
857
858                                 if MsgResult = IDYES then begin
859                                         GetCookie(Indy.CookieManager, Board);
860                     if (Board.Is2ch) then begin
861                         GetHiddenParameter(ResponseText, Board);
862                     end;
863
864                                         if (Board.SPID = '') and (Board.PON = '') and (Board.Cookie = '') then
865                                                 raise Exception.Create('');
866                                         //\82à\82¤\88ê\89ñ\82±\82Ì\83\81\83\\83b\83h
867                                         Send(Board.Cookie, Board.SPID, Board.PON, False);
868                                         Exit;
869                                 end else begin
870                                         CancelSend( Board, SysMenu );
871                                         Exit;
872                                 end;
873                         end else if ResultType = grtCheck then begin
874                                 //\83\8b\81[\83v\96h\8e~
875                                 if not FirstWriting then
876                                         raise Exception.Create('');
877
878                                 MsgResult := MsgBox( Handle,
879                                                 '\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 +
880                                                 '\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 +
881                                                 '\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 +
882                                                 '\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 +
883                                                 #13#10 +
884                                                 '\91S\90Ó\94C\82ð\95\89\82¤\82±\82Æ\82ð\8f³\91ø\82µ\82Ä\8f\91\82«\8d\9e\82Ý\82Ü\82·\82©\81H',
885                                                 '\8am\94F',
886                                                 MB_YESNO or MB_ICONQUESTION);
887
888                                 if MsgResult = IDYES then begin
889                                         GetCookie(Indy.CookieManager, Board);
890                     if (Board.Is2ch) then begin
891                         GetHiddenParameter(ResponseText, Board);
892                     end;
893
894                                         if (Board.SPID = '') and (Board.PON = '') and (Board.Cookie = '') then
895                                                 raise Exception.Create('');
896
897
898                                         Send(Board.Cookie, Board.SPID, Board.PON, False);
899                                         Exit;
900                                 end else begin
901                                         CancelSend( Board, SysMenu );
902                                         Exit;
903                                 end;
904                         end else if ResultType = grtNinpou then begin
905                                 MsgBox( Handle,
906                                                 '\8bM\95û\82Ì\94E\96@\92\9f\82ð\8dì\90¬\92\86\82Å\82·\81B\88ø\82«\95Ô\82·\82È\82ç\82¢\82Ü\82¾\81B(\82Q\95ª\82Ù\82Ç\82©\82©\82è\82Ü\82·)' + #13#10
907                                                 , '\8am\94F',
908                                                 MB_OK or MB_ICONINFORMATION);
909                                 if (GikoSys.Setting.UseSamba)  and  (FSambaTimer.Enabled) then
910                 begin
911                                         FSambaTimer.WriteSambaTime(Now());
912                 end;
913                 Board.PON  := '';
914                 Board.SPID := '';
915                 Board.Cookie := '';
916                 GetCookie(Indy.CookieManager, Board);
917                                 Exit;
918             end else if ResultType = grtSuiton then begin
919                                 MsgBox( Handle,
920                                                 '\8bM\95û\82Ì\94E\96@\92\9f\82Í\8fÄ\82©\82ê\82Ü\82µ\82½\81B' + #13#10 +
921                         '\94E\96@\92\9f\82ð\8dí\8f\9c\82µ\82Ü\82µ\82½\81A\8dÄ\91\97\90M\82µ\82Ä\82­\82¾\82³\82¢\81B'
922                                                 , '\8am\94F',
923                                                 MB_OK or MB_ICONINFORMATION);
924                 // \94E\96@\92\9f\8aª\95¨\82ð\8fÁ\82·
925                 GikoSys.DelBoukenCookie(FCookieDomain);
926                 GikoSys.Setting.WriteBoukenSettingFile;
927                 Board.PON  := '';
928                 Board.SPID := '';
929                 Board.Cookie := '';
930                 Exit;
931                         end else begin
932                                 if (GikoSys.Setting.UseSamba)  and  (FSambaTimer.Enabled) then
933                 begin
934                                         FSambaTimer.WriteSambaTime(Now());
935                 end;
936                 // \94E\96@\92\9f\8aª\95¨\83G\83\89\81[\82ÍCookie\82ð\8dX\90V\82·\82é
937                 if ResultType = grtNinpouErr then begin
938                     GetCookie(Indy.CookieManager, Board);
939                 end;
940                                 State := gdsError;
941                                 raise Exception.Create('');
942                         end;
943                 except
944             on E: EIdSocketError do begin
945                                 State := gdsError;
946                                 ResponseText := '<html><body>'
947                                                                                         + '<div>\90Ú\91±\82ª\8e¸\94s\82µ\82Ü\82µ\82½<br>'
948                                                                                         + '\89ñ\90ü\82Ì\8fó\91Ô\82ð\92²\82×\82Ä\82­\82¾\82³\82¢<br></div>'
949                                                                                         + '<br><br><div>' + E.Message + '</div>'
950                                                                                         + '</body></html>';
951             end;
952                         on E: EIdConnectException do begin
953                                 State := gdsError;
954                                 ResponseText := '<html><body>'
955                                                                                         + '<div>\90Ú\91±\82ª\8e¸\94s\82µ\82Ü\82µ\82½<br>'
956                                                                                         + '\89ñ\90ü\82â\83v\83\8d\83L\83V\82Ì\8fó\91Ô\82ð\92²\82×\82Ä\82­\82¾\82³\82¢<br></div>'
957                                                                                         + '<br><br><div>' + E.Message + '</div>'
958                                                                                         + '</body></html>';
959                         end;
960                         on E: Exception do begin
961                                 State := gdsError;
962
963                                 FDebugStrReceive := AnsiReplaceText(FDebugStrReceive, '<', '&lt;');
964                                 FDebugStrReceive := AnsiReplaceText(FDebugStrReceive, '>', '&gt;');
965                                 FDebugStrSend := AnsiReplaceText(FDebugStrSend, '<', '&lt;');
966                                 FDebugStrSend := AnsiReplaceText(FDebugStrSend, '>', '&gt;');
967                 ExpMsg := AnsiReplaceText(E.Message, '<', '&lt;');
968                                 ExpMsg := AnsiReplaceText(ExpMsg,    '>', '&gt;');
969
970                                 ResponseText := '<html><body>' + TextStream.DataString;
971                                 ResponseText := AnsiReplaceText(ResponseText, '</body>', '');
972                                 ResponseText := AnsiReplaceText(ResponseText, '</html>', '');
973                                 ResponseText := ResponseText + '<hr><div align="left"><pre>';
974                                 ResponseText := ResponseText + '<b>\82±\82±\82©\82ç\83M\83R\83i\83r\82Ì\8fî\95ñ</b>'#13#10;
975                                 ResponseText := ResponseText + #13#10'\81\9c\97á\8aO'#13#10;
976                                 ResponseText := ResponseText + ExpMsg;
977                                 ResponseText := ResponseText + #13#10'\81\9c\91\97\90M'#13#10;
978                                 ResponseText := ResponseText + FDebugStrSend;
979                                 ResponseText := ResponseText + #13#10'\81\9c\8eó\90M'#13#10;
980                                 ResponseText := ResponseText + FDebugStrReceive;
981                                 ResponseText := ResponseText + '</pre></div></body></html>';
982                         end;
983                 end;
984                 FStatusCode := Indy.ResponseCode;
985                 if FAbort then
986                         State := gdsAbort;
987         finally
988                 Source.Free;
989                 TextStream.Free;
990         if ( Indy.CookieManager <> nil ) then begin
991             Indy.CookieManager.CookieCollection.Clear;
992         end;
993                 //sysMenu := GetSystemMenu( Handle, true );
994                 EnableMenuItem(SysMenu, SC_CLOSE, MF_BYCOMMAND or MF_ENABLED);
995                 DrawMenuBar(Handle);
996         end;
997         FWork := false;
998     //\94ñ\8cö\8e®\83M\83R\83i\83r\94Â\82È\82Ç\82Ì2ch\8cÝ\8a·\83X\83N\83\8a\83v\83g\97p
999     //2ch\88È\8aO\82Å\82©\82ÂResponceCode\82ª302Found\82Å\8f\91\82«\8d\9e\82Ý\8a®\97¹
1000     //if (not Board.Is2ch) and (FStatusCode = 302) then begin
1001     if FStatusCode = 302 then begin
1002         GikoForm.PlaySound('ResEnd');
1003         SaveSendFile;
1004         AddFormMessageNew( gmiOK );
1005         if (not ContinueModeAction.Enabled) or (not ContinueModeAction.Checked) then begin
1006             Close;
1007             Exit;
1008         end;
1009     end;
1010         if State = gdsComplete then begin
1011                 GikoForm.PlaySound('ResEnd');
1012                 SaveSendFile;
1013         AddFormMessageNew( gmiOK );
1014         if (not ContinueModeAction.Enabled) or (not ContinueModeAction.Checked) then begin
1015                 Close;
1016         end;
1017         end else if State = gdsError then begin
1018         AddFormMessageNew( gmiOK );
1019                 EditorPage.ActivePage := PreviewTab;
1020                 SetContent(ResponseText, Browser);
1021         end else if State = gdsAbort then begin
1022                 GikoForm.AddMessageList(FThreadItem.Title + ' ' + GikoSys.GetGikoMessage(gmAbort), nil, gmiSAD);
1023         end;
1024 end;
1025 function TEditorForm.GetResultType(ResponseText: string): TGikoResultType;
1026 begin
1027         if AnsiPos('\8f\91\82«\82±\82Ý\82ª\8fI\82í\82è\82Ü\82µ\82½', ResponseText) <> 0 then
1028                 Result := grtOK
1029     else if ( (AnsiPos('<b>\82æ\82¤\82±\82»\81F\8bM\95û\82Ì\94E\96@\92\9f\82ð\8dì\90¬\82µ\82Ü\82·\81B\82Q\95ª\8cã\82É\8dÄ\93x\8f\91\82«\8d\9e\82Þ\82©\81A\82¨\8bA\82è\82­\82¾\82³\82¢', ResponseText) > 0) or
1030               (AnsiPos('\82d\82q\82q\82n\82q\81F\8bM\95û\82Ì\96`\8c¯\82Ì\8f\91\82ð\8dì\90¬\92\86\82Å\82·', ResponseText) > 0) )
1031                 and (AnsiPos(RES2CH_COOKIE, ResponseText) > 0)  then
1032         Result := grtNinpou
1033     else if ( (AnsiPos('\82d\82q\82q\82n\82q\81F\8fC\8ds\82ª\91«\82è\82Ü\82¹\82ñ', ResponseText) > 0) or   // \83G\83\89\81[\88µ\82¢
1034               (AnsiPos('\82d\82q\82q\82n\82q\81FLv\82ª\91«\82è\82È\82­\82Ä\83X\83\8c\83b\83h\97§\82Ä', ResponseText) > 0) ) // \83G\83\89\81[\88µ\82¢
1035               and (AnsiPos(RES2CH_COOKIE, ResponseText) > 0)    then
1036         Result := grtNinpouErr
1037     else if( AnsiPos('<b>\82â\82ç\82ê\82½\82Å\82²\82´\82é\81FLv=0 <br>\82³\82Ä\8e©\97Í\82Å\95\9c\8a\88\82Å\82«\82é\82©\82È?', ResponseText) > 0) 
1038               and (AnsiPos(RES2CH_COOKIE, ResponseText) > 0)    then
1039         Result := grtSuiton
1040         else if ( AnsiPos('\83N\83b\83L\81[\82ª\82È\82¢\82©\8aú\8cÀ\90Ø\82ê\82Å\82·', ResponseText) > 0) or
1041                                         (AnsiPos('<title>\83N\83b\83L\81[\8am\94F\81I</title>', ResponseText) > 0)    or
1042                                         (AnsiPos('<title>\81¡\83N\83b\83L\81[\8am\94F\81I\81¡</title>', ResponseText) > 0) or
1043                     (AnsiPos(RES2CH_COOKIE, ResponseText) > 0)  then
1044                 Result := grtCookie
1045         else if (AnsiPos('<font size=+2 color=#FF0000>\8f\91\82«\8d\9e\82Ý\83`\83F\83b\83N\81I </font>', ResponseText) > 0)   or
1046                                         (AnsiPos('<title>\81¡ \8f\91\82«\8d\9e\82Ý\8am\94F\82µ\82Ü\82· \81¡</title>', ResponseText) > 0)  or
1047                                         (AnsiPos('<title>\93\8a\8de\8am\94F</title>', ResponseText) > 0)  or
1048                                         (AnsiPos('<b>\8f\91\82«\82±\82Ý\8am\94F</b>', ResponseText) > 0)      or
1049                                         (AnsiPos('="../test/subbbs.cgi">', ResponseText) > 0)   or
1050                                         (AnsiPos(RES2CH_FALSE, ResponseText) > 0)       then
1051                 Result := grtCheck
1052         else if (AnsiPos('\81E\93\8a\8de\8eÒ\82Í\81A\8cf\8e¦\94Â\89^\89c\8eÒ\82É\91Î\82µ\82Ä\81A\92\98\8dì\8eÒ\90l\8ai\8c \82ð\88ê\90Ø\8ds\8eg\82µ\82È\82¢\82±\82Æ\82ð\8f³\91ø\82µ\82Ü\82·\81B<br>', ResponseText) > 0) or
1053                                         (AnsiPos('\81i\92\98\8dì\8c \96@\91æ21\8fð\82È\82¢\82µ\91æ28\8fð\82É\8bK\92è\82³\82ê\82é\8c \97\98\82à\8aÜ\82Þ\81j\82»\82Ì\91¼\82Ì\8c \97\98\82É\82Â\82«\81A', ResponseText) > 0) then
1054                 Result := grtCookie
1055     else
1056         Result := grtError;
1057 end;
1058
1059
1060 procedure TEditorForm.GetSendData(Source: TStringStream);
1061 var
1062         SessionID: string;
1063         s: string;
1064         SendTime: Integer;
1065         Adjust: Integer;
1066         Board: TBoard;
1067         body            : string;
1068 begin
1069     Board := GetBoard;
1070
1071         if GikoSys.Setting.UseMachineTime then begin
1072                 if GikoSys.Setting.TimeAdjust then
1073                         Adjust := Gikosys.Setting.TimeAdjustSec
1074                 else
1075                         Adjust := GikoSys.Setting.TimeAdjustSec * -1;
1076                 SendTime := GikoSys.DateTimeToInt(Now) - (9 * 60 * 60) + Adjust
1077         end else begin
1078                 if (Board.LastGetTime = 0) or (Board.LastGetTime = ZERO_DATE) then
1079                         SendTime := GikoSys.DateTimeToInt(Now)
1080                 else
1081                         SendTime := GikoSys.DateTimeToInt(Board.LastGetTime);
1082         end;
1083
1084         body := GetBody;
1085
1086         SessionID := GikoSys.Dolib.SessionID;
1087         if SessionID <> '' then
1088                 s := 'sid=' + HttpEncode(SessionID) + '&'
1089         else
1090                 s := '';
1091         s := s + 'subject=&'
1092                + 'FROM=' + HttpEncode(NameComboBox.Text) + '&'
1093                + 'mail=' + HttpEncode(MailComboBox.Text) + '&'
1094                + 'MESSAGE=' + HttpEncode(body) + '&'
1095                + 'bbs=' + Board.BBSID + '&'
1096                            + 'time=' + IntToStr(SendTime) + '&';
1097                            
1098         if FThreadItem = nil then begin
1099                 s := s + 'subject=' + HttpEncode(TitleEdit.Text) + '&';
1100                 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;
1101         end else begin
1102                 s := s + 'key=' + ChangeFileExt(FThreadItem.FileName, '') + '&';
1103                 s := s + 'submit=' + HttpEncode('\8f\91\82«\8d\9e\82Þ') + #13#10;
1104         end;
1105         Source.WriteString(s);
1106 end;
1107
1108 procedure TEditorForm.SaveSendFile;
1109 var
1110         sDate: string;
1111         ini: TMemIniFile;
1112 begin
1113         ini := CreateSentIniFile;
1114     if (ini <> nil) then begin
1115         try
1116             sDate := IntToStr(GikoSys.DateTimeToInt(Now));
1117
1118             ini.WriteString(sDate, 'Name', NameComboBox.Text);
1119             ini.WriteString(sDate, 'EMail', MailComboBox.Text);
1120             ini.WriteString(sDate, 'Body', HttpEncode(BodyEdit.EncodeText));
1121             ini.WriteInteger(sDate, 'Status', FStatusCode);
1122             ini.WriteDateTime(sDate, 'Date', Now);
1123             if FThreadItem = nil then begin
1124                 ini.WriteString(sDate, 'Title', MojuUtils.Sanitize(TitleEdit.Text));
1125                 //ini.WriteString(sDate, 'BBS', FBoard.BBSID);
1126                 ini.WriteString(sDate, 'URL', FBoard.URL);
1127                 ini.WriteInteger(sDate, 'NewThread', 1);
1128             end else begin
1129                 ini.WriteString(sDate, 'Title', FThreadItem.Title);
1130                 //ini.WriteString(sDate, 'BBS', FThreadItem.ParentBoard.BBSID);
1131                 ini.WriteString(sDate, 'URL', FThreadItem.URL);
1132                 ini.WriteString(sDate, 'Key', ChangeFileExt(FThreadItem.FileName, ''));
1133             end;
1134
1135             ini.UpdateFile;
1136         finally
1137             ini.Free;
1138         end;
1139     end;
1140 end;
1141 function TEditorForm.CreateSentIniFile: TMemIniFile;
1142 var
1143     maxSize, fileSize, i: Integer;
1144     newName: String;
1145 begin
1146     Result := nil;
1147     // MB -> bytes
1148     maxSize := GikoSys.Setting.SentIniFileSize * 1024 * 1024;
1149     // \83t\83@\83C\83\8b\83T\83C\83Y\82ª0\82Ì\8fê\8d\87\82Í\81Asent.ini\82É\8f\91\82«\8d\9e\82Ü\82È\82¢\82Ì\82Ånil\82ð\95Ô\82·
1150     if (maxSize > 0) then begin
1151         fileSize := GikoSys.GetFileSize(GikoSys.Setting.GetSentFileName);
1152         // \8dÅ\91å\83T\83C\83Y\82ð\92´\82¦\82Ä\82¢\82½\8fê\8d\87\82Í\83\8a\83l\81[\83\80\82·\82é
1153         if (fileSize >= maxSize) then begin
1154             i := 0;
1155             // \8d¡\82Ì\8e\9e\8d\8f\82ð\83t\83@\83C\83\8b\96¼\82Ì\8cã\82ë\82É\82Â\82¯\82é
1156             repeat
1157                 // 10\89ñ\88È\8fã\8e¸\94s\82µ\82½\82ç\82 \82«\82ç\82ß\82é
1158                 if (i > 10) then break;
1159                 DateTimeToString(newName, 'yyhhnnsszzz', Now());
1160                 Inc(i);
1161             until RenameFile(GikoSys.Setting.GetSentFileName,
1162                 GikoSys.Setting.GetSentFileName + '.' + newName);
1163         end;
1164         Result := TMemIniFile.Create(GikoSys.Setting.GetSentFileName);
1165     end;
1166 end;
1167 procedure TEditorForm.SendActionExecute(Sender: TObject);
1168 const
1169         TITLE_SAMBA : string = 'Samba24\8cx\8d\90';
1170 var
1171         Board: TBoard;
1172         rc: Integer;
1173         rc2: Integer;
1174         state : TGikoDownloadState;
1175         body            : string;
1176 begin
1177         if FWork then
1178                 Exit;
1179         try
1180                 FWork := True;
1181                 SendAction.Enabled := False;
1182                 Application.ProcessMessages;
1183                 if not Check then Exit;
1184
1185         Board := GetBoard;
1186
1187                 if FThreadItem = nil then begin
1188                         rc := GikoUtil.MsgBox(Handle,
1189                                                                                                         '\81u' + Board.Title + '\81v\94Â\82É\90V\82µ\82¢\83X\83\8c\83b\83h\97§\82Ä\82Ü\82·'#13#10#13#10
1190                                                                                                         + '\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
1191                                                                                                         + '\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
1192                                                                                                         + '\81u\82Í\82¢\81v\82ð\89\9f\82·\82Æ\91\97\90M\82µ\82Ü\82·',
1193                                                                                                         '\8am\94F',
1194                                                                                                         MB_ICONQUESTION or MB_YESNO);
1195                         if rc <> ID_YES then
1196                                 Exit;
1197                 end;
1198
1199                 SetNameList(NameComboBox.Text, MailComboBox.Text);
1200                 if (KotehanCheckBox.Enabled) and (KotehanCheckBox.Checked) then begin
1201                         Board.KotehanName := NameComboBox.Text;
1202                         Board.KotehanMail := MailComboBox.Text;
1203                 end;
1204
1205                 if Board.IsBoardPlugInAvailable then begin
1206                         body := GetBody;
1207
1208                         if FThreadItem = nil then begin
1209                                 // \83X\83\8c\97§\82Ä
1210                                 state := TGikoDownloadState( Board.BoardPlugIn.CreateThread(
1211                                         DWORD( Board ), TitleEdit.Text, NameComboBox.Text, MailComboBox.Text, body ) );
1212
1213                                 if state = gdsComplete then begin
1214                                         GikoForm.PlaySound('ResEnd');
1215                                         SaveSendFile;
1216                                         GikoForm.AddMessageList(FBoard.Title + ' ' + GikoSys.GetGikoMessage(gmNewSure), nil, gmiOK);
1217                                         FWork := False;
1218                                         Close;
1219                                 end else if State = gdsError then begin
1220                                         GikoForm.AddMessageList(FBoard.Title + ' ' + GikoSys.GetGikoMessage(gmSureError), nil, gmiNG);
1221                                 end else if State = gdsAbort then begin
1222                                         GikoForm.AddMessageList(FBoard.Title + ' ' + GikoSys.GetGikoMessage(gmAbort), nil, gmiNG);
1223                                 end;
1224                         end else begin
1225                                 // \83\8c\83X
1226                                 state := TGikoDownloadState( FThreadItem.ParentBoard.BoardPlugIn.WriteThread(
1227                                         DWORD( FThreadItem ), NameComboBox.Text, MailComboBox.Text, body ) );
1228
1229                                 if state = gdsComplete then begin
1230                                         GikoForm.PlaySound('ResEnd');
1231                                         SaveSendFile;
1232                                         GikoForm.AddMessageList(FThreadItem.Title + ' ' + GikoSys.GetGikoMessage(gmNewRes), nil, gmiOK);
1233                                         FWork := False;
1234                                         Close;
1235                                 end else if State = gdsError then begin
1236                                         GikoForm.AddMessageList(FThreadItem.Title + ' ' + GikoSys.GetGikoMessage(gmResError), nil, gmiOK);
1237                                 end else if State = gdsAbort then begin
1238                     GikoForm.AddMessageList(FThreadItem.Title + ' ' + GikoSys.GetGikoMessage(gmAbort), nil, gmiOK);
1239                                 end;
1240                         end;
1241                 end else begin
1242                         if not FSambaTimer.Enabled then begin
1243                                 if CompareDateTime(Board.Expires ,Now) <= 0 then begin
1244                                         Board.Cookie    := '';
1245                                         Board.SPID      := '';
1246                                         Board.PON               := '';
1247                                 end;
1248                 // \96`\8c¯\82Ì\8f\91\83\8c\83x\83\8b\96ß\82é\96â\91è\91Î\89\9e
1249                 if (Board.Is2ch) and (AnsiPos('HAP=', Board.Cookie)>0) then begin
1250                     Board.Cookie := '';
1251                 end;
1252                                 Send(Board.Cookie, Board.SPID, Board.PON, True);
1253                         end else begin
1254                                 if not FSambaTimer.CheckSambaTime(Now()) then begin
1255                                         rc := GikoUtil.MsgBox(Handle,
1256                                                                 '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
1257                                                                 + '\91\97\90M\82ð\92\86\8e~\82µ\82Ü\82·\82©\81H' + #13#10
1258                                                                 + '(\81u\82¢\82¢\82¦\81v\82¾\82Æ\91\97\90M\82µ\82Ü\82·)', TITLE_SAMBA,
1259                                                                 MB_YESNO or MB_ICONQUESTION);
1260                                         if rc = IDYES then begin
1261                                                 FWork := false;
1262                                                 Exit;
1263                                         end;
1264                                         if rc = IDNO then begin
1265                                                 rc2 := GikoUtil.MsgBox(Handle,
1266                                                                        '\96{\93\96\82É\91\97\90M\82µ\82Ü\82·\82©\81H',
1267                                                                        TITLE_SAMBA,
1268                                                                        MB_YESNO or MB_ICONQUESTION);
1269                                                 if rc2 = IDNO then begin
1270                                                         FWork := False;
1271                                                         Exit;
1272                                                 end;
1273                                         end;
1274                                 end;
1275                                 if CompareDateTime(Board.Expires ,Now) <= 0 then begin
1276                                         Board.Cookie    := '';
1277                                         Board.SPID      := '';
1278                                         Board.PON               := '';
1279                                 end;
1280                 // \96`\8c¯\82Ì\8f\91\83\8c\83x\83\8b\96ß\82é\96â\91è\91Î\89\9e
1281                 if (Board.Is2ch) and (AnsiPos('HAP=', Board.Cookie)>0) then begin
1282                     Board.Cookie := '';
1283                 end;
1284                                 Send(Board.Cookie, Board.SPID, Board.PON, True);
1285                         end;
1286                 end;
1287         finally
1288                 FWork := False;
1289                 if FSambaTimer.Enabled then begin
1290                         FNow := FSambaTimer.Update;
1291         end;
1292         end;
1293 end;
1294
1295 procedure TEditorForm.SaveActionExecute(Sender: TObject);
1296 begin
1297 //
1298 end;
1299
1300 procedure TEditorForm.CloseActionExecute(Sender: TObject);
1301 begin
1302         Close;
1303 end;
1304
1305 procedure TEditorForm.UndoActionExecute(Sender: TObject);
1306 begin
1307         SendMessage(GetActiveControlHandle, WM_UNDO, 0, 0);
1308 end;
1309
1310 procedure TEditorForm.CutActionExecute(Sender: TObject);
1311 begin
1312         SendMessage(GetActiveControlHandle, WM_CUT, 0, 0);
1313 end;
1314
1315 procedure TEditorForm.CopyActionExecute(Sender: TObject);
1316 begin
1317         SendMessage(GetActiveControlHandle, WM_COPY, 0, 0);
1318 end;
1319
1320 procedure TEditorForm.PasteActionExecute(Sender: TObject);
1321 begin
1322         SendMessage(GetActiveControlHandle, WM_PASTE, 0, 0);
1323 end;
1324
1325 procedure TEditorForm.SelectAllActionExecute(Sender: TObject);
1326 begin
1327         SendMessage(GetActiveControlHandle, EM_SETSEL, 0, GetWindowTextLength(GetActiveControlHandle));
1328 end;
1329
1330 procedure TEditorForm.TopActionExecute(Sender: TObject);     // \83E\83B\83\93\83h\83E\8dÅ\91O\96Ê(Stay)\83{\83^\83\93\82Ì\8f\88\97\9d
1331 begin
1332         if not (fsShowing in Self.FormState) then begin
1333                 if TopAction.Checked then begin // \83X\83e\83C\8fó\91Ô\82É\90Ý\92è
1334                         SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
1335                         GikoSys.Setting.EditWindowStay := true;
1336                 end     else begin   // \83X\83e\83C\8fó\91Ô\89ð\8f\9c
1337                         SetWindowPos(Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
1338                         GikoSys.Setting.EditWindowStay := false;
1339                 end;
1340                 // \83X\83e\83C\8fó\91Ô\82Ì\95Û\91
1341                 //GikoSys.Setting.EditWindowStay := FormStyle = fsStayOnTop;
1342         end;
1343 end;
1344
1345 procedure TEditorForm.AbortActionExecute(Sender: TObject);
1346 begin
1347         FAbort := True;
1348 end;
1349
1350 procedure TEditorForm.SendActionUpdate(Sender: TObject);
1351 begin
1352         SendAction.Enabled := not FWork;
1353 end;
1354
1355 procedure TEditorForm.SaveActionUpdate(Sender: TObject);
1356 begin
1357         SaveAction.Enabled := False;
1358 end;
1359
1360 procedure TEditorForm.CloseActionUpdate(Sender: TObject);
1361 begin
1362         CloseAction.Enabled := not FWork;
1363 end;
1364
1365 procedure TEditorForm.UndoActionUpdate(Sender: TObject);
1366 begin
1367         UndoAction.Enabled := (GetActiveControlHandle <> 0)
1368                                                                                                 and (SendMessage(GetActiveControlHandle, EM_CANUNDO, 0, 0) <> 0)
1369                                                                                                 and (not FWork);
1370 end;
1371
1372 procedure TEditorForm.CutActionUpdate(Sender: TObject);
1373 var
1374         Selection: TSelection;
1375         AHandle: THandle;
1376 begin
1377         AHandle := GetActiveControlHandle;
1378         SendMessage(AHandle, EM_GETSEL, Longint(@Selection.StartPos), Longint(@Selection.EndPos));
1379         CutAction.Enabled := (AHandle <> 0)
1380                                                                                 and ((Selection.EndPos - Selection.StartPos) <> 0)
1381                                                                                 and (not FWork);
1382 end;
1383
1384 procedure TEditorForm.CopyActionUpdate(Sender: TObject);
1385 var
1386         Selection: TSelection;
1387         AHandle: THandle;
1388 begin
1389         AHandle := GetActiveControlHandle;
1390         SendMessage(AHandle, EM_GETSEL, Longint(@Selection.StartPos), Longint(@Selection.EndPos));
1391         CopyAction.Enabled := (AHandle <> 0)
1392                                                                                 and ((Selection.EndPos - Selection.StartPos) <> 0)
1393                                                                                 and (not FWork);
1394 end;
1395
1396 procedure TEditorForm.PasteActionUpdate(Sender: TObject);
1397 begin
1398         PasteAction.Enabled := (GetActiveControlHandle <> 0)
1399                                                                                         and (Clipboard.HasFormat(CF_TEXT))
1400                                                                                         and (not FWork);
1401 end;
1402
1403 procedure TEditorForm.TopActionUpdate(Sender: TObject);
1404 begin
1405         TopAction.Enabled := not FWork;
1406 end;
1407
1408 procedure TEditorForm.SageCheckBoxClick(Sender: TObject);
1409 begin
1410         if SageCheckBox.Checked then begin
1411                 if AnsiPos('sage', MailComboBox.Text) = 0 then
1412                         MailComboBox.Text := 'sage' + MailComboBox.Text;
1413         end else begin
1414                 if AnsiPos('sage', MailComboBox.Text) <> 0 then
1415                         MailComboBox.Text := StringReplace(MailComboBox.Text, 'sage', '', [rfReplaceAll]);
1416         end;
1417 end;
1418
1419 procedure TEditorForm.MailComboBoxChange(Sender: TObject);
1420 begin
1421         if AnsiPos('sage', MailComboBox.Text) = 0 then
1422                 SageCheckBox.Checked := False
1423         else
1424                 SageCheckBox.Checked := True;
1425 end;
1426
1427 procedure TEditorForm.IdLogDebugReceive(ASender: TIdConnectionIntercept;
1428         AStream: TStream);
1429 var
1430         StringStream: TStringStream;
1431 begin
1432         StringStream := TStringStream.Create('');
1433         try
1434                 StringStream.CopyFrom(AStream, AStream.Size);
1435                 FDebugStrReceive := FDebugStrReceive + StringStream.DataString;
1436         finally
1437                 StringStream.Free;
1438         end;
1439 end;
1440
1441 procedure TEditorForm.IdLogDebugSend(ASender: TIdConnectionIntercept;
1442         AStream: TStream);
1443 var
1444         StringStream: TStringStream;
1445 begin
1446         StringStream := TStringStream.Create('');
1447         try
1448                 StringStream.CopyFrom(AStream, AStream.Size);
1449                 FDebugStrSend := FDebugStrSend + StringStream.DataString;
1450         finally
1451                 StringStream.Free;
1452         end;
1453 end;
1454
1455 procedure TEditorForm.TransActionExecute(Sender: TObject);
1456 begin
1457         AlphaBlend := TransAction.Checked;
1458         // \94¼\93§\96¾\8fó\91Ô\82Ì\95Û\91
1459         GikoSys.Setting.EditWindowTranslucent := TransAction.Checked;
1460 end;
1461
1462 procedure TEditorForm.TransActionUpdate(Sender: TObject);
1463 begin
1464         TransAction.Enabled := not FWork;
1465 end;
1466 //StatusBar\82ÌPanels[0]\82Ì\95\9d\82ð\89Â\95Ï\81B\8ec\82è\82ð\8cÅ\92è\82É\82·\82é
1467 procedure TEditorForm.StatusBarResize(Sender: TObject);
1468 begin
1469         StatusBar.Panels[0].Width := StatusBar.Width
1470                                                                         - StatusBar.Panels[1].Width - StatusBar.Panels[2].Width;
1471
1472 end;
1473
1474 //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Þ
1475 procedure TEditorForm.FormActivate(Sender: TObject);
1476 begin
1477         if ( FSambaTimer.Enabled ) and ( FThreadItem <> nil ) then
1478     begin
1479                 FNow := FSambaTimer.Update;
1480     end;
1481         if GikoSys.Setting.GestureEnabled then begin
1482                 GikoSys.Setting.Gestures.ClearGesture;
1483                 GikoSys.Setting.Gestures.LoadGesture(
1484                         GikoSys.Setting.GetGestureFileName, ActionList );
1485                 MouseGesture.UnHook;
1486                 MouseGesture.OnGestureStart := OnGestureStart;
1487                 MouseGesture.OnGestureMove := OnGestureMove;
1488                 MouseGesture.OnGestureEnd := OnGestureEnd;
1489                 MouseGesture.SetHook( Handle );
1490         end;
1491 end;
1492 procedure TEditorForm.FormCloseQuery(Sender: TObject;
1493   var CanClose: Boolean);
1494 begin
1495         CanClose := not FWork;
1496 end;
1497
1498 procedure TEditorForm.QuotePasteActionExecute(Sender: TObject);
1499 var
1500         s                       : TStringList;
1501         i                       : Integer;
1502         quote   : string;
1503 begin
1504
1505         quote   := GikoSys.GetOEIndentChar;
1506         s                       := TStringList.Create;
1507         try
1508                 s.Text  := Clipboard.AsText;
1509
1510                 for i := s.Count - 1 downto 0 do
1511                         s[ i ]  := quote + s[ i ];
1512
1513                 BodyEdit.SelText        := s.Text;
1514         finally
1515                 s.Free;
1516         end;
1517
1518 end;
1519
1520 procedure TEditorForm.SpaceToNBSPActionExecute(Sender: TObject);
1521 begin
1522         GikoSys.Setting.SpaceToNBSP := SpaceToNBSPAction.Checked;
1523         if EditorPage.ActivePage = PreviewTab then
1524                 Preview;
1525 end;
1526
1527 procedure TEditorForm.AmpToCharRefActionExecute(Sender: TObject);
1528 begin
1529         GikoSys.Setting.AmpToCharRef := AmpToCharRefAction.Checked;
1530         if EditorPage.ActivePage = PreviewTab then
1531                 Preview;
1532 end;
1533
1534 procedure TEditorForm.BoardTopClick(Sender: TObject);
1535 var
1536         ini: TMemIniFile;
1537 begin
1538         ini := TMemIniFile.Create(GikoSys.Setting.GetFileName);
1539         try
1540                 BoardtopTab.TabVisible := BoardTop.Checked;
1541                 ini.WriteBool('EditorForm', 'BoardTopTab', BoardtopTab.TabVisible);
1542         ini.UpdateFile;
1543         finally
1544                 ini.Free;
1545         end;
1546 end;
1547
1548
1549 procedure TEditorForm.GetSETTINGTXTActionExecute(Sender: TObject);
1550 var
1551         memStream: TMemoryStream;
1552         URL, RefURL: string;
1553         settingBody: TStringList;
1554         tmpBoard: TBoard;
1555 begin
1556         if not FWork then begin
1557         FWork := True;
1558
1559         tmpBoard := GetBoard;
1560         if tmpBoard <> nil then begin
1561
1562             RefURL      := tmpBoard.URL;
1563             if RefURL[Length(RefURL)] <> '/' then
1564                 URL     := RefURL + '/' + 'SETTING.TXT'
1565             else
1566                 URL     := RefURL + 'SETTING.TXT';
1567             Screen.Cursor := crHourGlass;
1568             memStream := TMemoryStream.Create;
1569             try
1570                 try
1571                     StatusBar.Panels[0].Text := 'SETTING.TXT\83_\83E\83\93\83\8d\81[\83h\92\86';
1572                     GetWebData(URL, RefURL, tmpBoard.SETTINGTXTTime, memStream);
1573                     if( Indy.ResponseCode = 200 ) then begin
1574                         settingBody := TStringList.Create;
1575                         try
1576                             memStream.Seek(0, soFromBeginning);
1577                             settingBody.LoadFromStream(memStream);
1578                             settingBody.SaveToFile(tmpBoard.GetSETTINGTXTFileName);
1579                             tmpBoard.SETTINGTXTTime := Indy.Response.LastModified;
1580                             tmpBoard.IsSETTINGTXT := true;
1581                             tmpBoard.TitlePictureURL := GetTitlePictureURL(settingBody, tmpBoard);
1582                             tmpBoard.Modified := true;
1583                         finally
1584                             settingBody.Free;
1585                         end;
1586                         StatusBar.Panels[0].Text := 'SETTING.TXT\8eæ\93¾\8a®\97¹(' + IntToStr(Indy.ResponseCode) + ')';
1587                     end;
1588                 except
1589                     on E: EIdException do begin
1590                         if( AnsiPos('304', E.Message) > 0 ) then
1591                             StatusBar.Panels[0].Text := 'SETTING.TXT\8dX\90V\96³\82µ(' + IntToStr(Indy.ResponseCode) + ')'
1592                         else
1593                             StatusBar.Panels[0].Text := 'SETTING.TXT\8eæ\93¾\83G\83\89\81[(' + IntToStr(Indy.ResponseCode) + ')';
1594                     end;
1595                 end;
1596             finally
1597                 memStream.Free;
1598                 Screen.Cursor := crDefault;
1599             end;
1600             ShowBoardInformation(tmpBoard, BoardInformationMemo);
1601         end;
1602         FWork := False;
1603     end;
1604 end;
1605
1606 procedure TEditorForm.ShowBoardInformation(ABoard: TBoard; AMemo: TMemo);
1607 var
1608         body: TStringList;
1609     UCType: Integer;    // 0:\95s\96¾\81A1:\91Î\89\9e\81A-1:\94ñ\91Î\89\9e
1610 begin
1611     UCType := 0;
1612         AMemo.Clear;
1613         AMemo.Lines.Add('[SETTING.TXT]');
1614         if ABoard.IsSETTINGTXT then begin
1615                 if FileExists(ABoard.GetSETTINGTXTFileName)  then begin
1616                         AMemo.Lines.Add(DateTimeToStr(ABoard.SETTINGTXTTime) + ' \8dX\90V');
1617                         body := TStringList.Create;
1618                         try
1619                                 body.LoadFromFile(ABoard.GetSETTINGTXTFileName);
1620                                 AMemo.Lines.AddStrings(body);
1621                         finally
1622                                 body.Free;
1623                         end;
1624             if (Pos('BBS_UNICODE=pass', AMemo.Text) > 0) then
1625                 UCType := 1
1626             else if (Pos('BBS_UNICODE=', AMemo.Text) > 0) then
1627                 UCType := -1;
1628                 end else begin
1629                         ABoard.IsSETTINGTXT := false;
1630                         ABoard.SETTINGTXTTime := ZERO_DATE;
1631                         AMemo.Lines.Add('Local\82É\95Û\91\82³\82ê\82½SETTING.TXT\82ª\8c©\82Â\82©\82è\82Ü\82¹\82ñ');
1632                         AMemo.Lines.Add('\83\81\83j\83\85\81[\82æ\82è\8dÄ\8eæ\93¾\82µ\82Ä\82­\82¾\82³\82¢\81B');
1633                 end;
1634         end else begin
1635                 AMemo.Lines.Add('SETTING.TXT\82ð\8eæ\93¾\82µ\82Ä\82¢\82Ü\82¹\82ñ\81B');
1636                 AMemo.Lines.Add('\83\81\83j\83\85\81[\82æ\82è\8eæ\93¾\82µ\82Ä\82­\82¾\82³\82¢\81B');
1637         end;
1638
1639     case UCType of
1640         -1: begin
1641             UCInfoPanel.Caption := 'Unicode\94ñ\91Î\89\9e';
1642             UCInfoPanel.Color := clRed;
1643             UCInfoPanel.Hint := '\82±\82Ì\94Â\82ÍUnicode\82Å\82Ì\83\8c\83X\82É\91Î\89\9e\82µ\82Ä\82¢\82Ü\82¹\82ñ\81B';
1644         end;
1645         0: begin
1646             UCInfoPanel.Caption := 'Unicode\91Î\89\9e\95s\96¾';
1647             UCInfoPanel.Color := clBtnFace;
1648             UCInfoPanel.Hint := '\94Â\8fî\95ñ\82ð\8eæ\93¾\82µ\82Ä\82­\82¾\82³\82¢\81B';
1649         end;
1650         1: begin
1651             UCInfoPanel.Caption := 'Unicode\91Î\89\9e';
1652             UCInfoPanel.Color := clLime;
1653             UCInfoPanel.Hint := '\82±\82Ì\94Â\82ÍUnicode\82Å\82Ì\83\8c\83X\82É\91Î\89\9e\82µ\82Ä\82¢\82Ü\82·\81B';
1654         end;
1655     end;
1656 end;
1657 function TEditorForm.GetTitlePictureURL(body: TStringList; ABoard: TBoard): string;
1658 //BBS_TITLE_PICTURE=
1659 //BBS_FIGUREHEAD=
1660 var
1661         i: Integer;
1662         tmp: string;
1663 begin
1664         Result := '';
1665         for i := 0 to body.Count - 1 do begin
1666                 if (AnsiPos('BBS_TITLE_PICTURE=', body[i]) > 0) or
1667                    (AnsiPos('BBS_FIGUREHEAD=', body[i]) > 0) then begin
1668                         tmp := body[i];
1669                         Delete(tmp, 1, AnsiPos('=', tmp));
1670                         if AnsiPos('../', tmp) > 0 then begin
1671                                 tmp := CustomStringReplace(tmp, '../', GikoSys.UrlToServer(ABoard.URL));
1672                         end;
1673                         Result := tmp;
1674                         Exit;
1675                 end;
1676         end;
1677 end;
1678
1679 procedure TEditorForm.GetTitlePictureActionUpdate(Sender: TObject);
1680 begin
1681         if FThreadItem = nil then
1682                 GetTitlePictureAction.Enabled :=  FBoard.IsSETTINGTXT
1683         else
1684                 GetTitlePictureAction.Enabled :=  FThreadItem.ParentBoard.IsSETTINGTXT;
1685
1686         if GetTitlePictureAction.Enabled Then begin
1687                 // \8eÀ\8ds\92\86\82Í\8eÀ\8ds\95s\89Â
1688                 GetTitlePictureAction.Enabled := not FWork;
1689         end;
1690 end;
1691
1692 procedure TEditorForm.GetTitlePictureActionExecute(Sender: TObject);
1693 var
1694         memStream: TMemoryStream;
1695         tmpBoard: TBoard;
1696 begin
1697         if FWork then
1698                 Exit;
1699
1700         FWork := True;
1701         memStream := TMemoryStream.Create;
1702         try
1703         tmpBoard := GetBoard;
1704
1705                 if (tmpBoard <> nil) and (tmpBoard.TitlePictureURL <> '') then begin
1706                         StatusBar.Panels[0].Text := '\94Â\83g\83b\83v\89æ\91\9c\83_\83E\83\93\83\8d\81[\83h\92\86';
1707                         Screen.Cursor := crHourGlass;
1708                         try
1709                 // URL\82ð\8ew\92è\82µ\82Ä\83\81\83\82\83\8a\82É\93Ç\82Ý\8d\9e\82Þ
1710                 GetWebData(tmpBoard.TitlePictureURL, tmpBoard.URL,
1711                     ZERO_DATE, memStream);
1712                                 if Indy.ResponseCode = 200 then begin
1713                                         memStream.SaveToFile(tmpBoard.GetTitlePictureFileName);
1714                                         ShowTitlePicture();
1715                                         tmpBoard.Modified := true;
1716                                 end;
1717                 StatusBar.Panels[0].Text := '\94Â\83g\83b\83v\89æ\91\9c (' + IntToStr(Indy.ResponseCode) + ')';
1718                         except
1719                         end;
1720                 end;
1721         finally
1722                 memStream.Free;
1723         FWork := False;
1724                 Screen.Cursor := crDefault;
1725         end;
1726 end;
1727 {
1728 \brief  URL\82Ì\83f\81[\83^\82ðstream\82É\93Ç\82Ý\8d\9e\82Þ
1729 \param  URL \93Ç\82Ý\8d\9e\82Þ\90æ
1730 \param  RefURL   referer\82É\90Ý\92è\82·\82é
1731 \param  Modified    Modified\82É\90Ý\92è\82·\82é
1732 \param  stream  \93Ç\82Ý\8d\9e\82ñ\82¾\83f\81[\83^\82Ì\95Û\91\90æ
1733 }
1734 procedure TEditorForm.GetWebData(const URL: string; const RefURL: string;
1735              Modified: TDateTime; stream: TStream);
1736 begin
1737     InitIdHTTP(Indy);
1738     Indy.Request.Referer := RefURL;
1739     Indy.Request.LastModified := Modified;
1740     
1741     IdAntiFreeze.Active := True;
1742     try
1743         Indy.Get(URL, stream);
1744     finally
1745         IdAntiFreeze.Active := False;
1746     end;
1747
1748 end;
1749 procedure TEditorForm.ShowTitlePicture();
1750 var
1751         tmpBoard: TBoard;
1752         s: String;
1753 begin
1754     tmpBoard := GetBoard;
1755
1756         if FileExists(tmpBoard.GetTitlePictureFileName) then begin
1757                 TitlePictureBrowser.Navigate(tmpBoard.GetTitlePictureFileName);
1758         end else begin
1759                 s := '\94Â\83g\83b\83v\89æ\91\9c\96¢\8eæ\93¾\82Å\82·\81B<br>\83\81\83j\83\85\81[\82æ\82è\8eæ\93¾\82µ\82Ä\82­\82¾\82³\82¢\81B';
1760                 SetContent(s, TitlePictureBrowser);
1761         end;
1762 end;
1763
1764 function TEditorForm.GetFusianaName(body: TStringList; ABoard: TBoard): String;
1765 var
1766         i: Integer;
1767         tmp: string;
1768 begin
1769         for i := 0 to body.Count - 1 do begin
1770                 if (AnsiPos('BBS_NONAME_NAME=', body[i]) > 0) then begin
1771                         tmp := body[i];
1772                         Delete(tmp, 1, AnsiPos('=', tmp));
1773                         Result := tmp;
1774                         Exit;
1775                 end;
1776         end;
1777 end;
1778
1779 procedure TEditorForm.GetHeadTXTActionExecute(Sender: TObject);
1780 var
1781         URL, RefURL: string;
1782         settingBody: TStringList;
1783         tmpBoard: TBoard;
1784         memStream: TMemoryStream;
1785 begin
1786     if not FWork then begin
1787         FWork := True;
1788
1789         tmpBoard := GetBoard;
1790         if (tmpBoard <> nil) then begin
1791
1792             RefURL      := tmpBoard.URL;
1793             if RefURL[Length(RefURL)] <> '/' then
1794                 URL     := RefURL + '/' + 'head.txt'
1795             else
1796                 URL     := RefURL + 'head.txt';
1797
1798             Screen.Cursor := crHourGlass;
1799             memStream := TMemoryStream.Create;
1800             try
1801                 StatusBar.Panels[0].Text := '\83\8d\81[\83J\83\8b\83\8b\81[\83\8b(head.txt)\83_\83E\83\93\83\8d\81[\83h\92\86';
1802                 try
1803                     GetWebData(URL, RefURL, tmpBoard.HEADTXTTime, memStream);
1804                     if( Indy.ResponseCode = 200 ) then begin
1805                         settingBody := TStringList.Create;
1806                         try
1807                             memStream.Seek(0, soFromBeginning);
1808                             settingBody.LoadFromStream(memStream);
1809                             settingBody.Insert(0, '<HTML lang="ja"><HEAD>');
1810                             settingBody.Insert(1, '<META http-equiv="Content-Type" content="text/html; charset=Shift_JIS">');
1811                             settingBody.Insert(2, '<TITLE>' + tmpBoard.Title + '</TITLE>');
1812                             settingBody.Insert(3, '<base href="' + RefURL + '"></HEAD><BODY>');
1813                             settingBody.Add('</BODY></HTML>');
1814                             settingBody.SaveToFile(tmpBoard.GETHEADTXTFileName);
1815                             tmpBoard.HEADTXTTime := Indy.Response.LastModified;
1816                             tmpBoard.IsHEADTXT := true;
1817                             tmpBoard.Modified := true;
1818                         finally
1819                             settingBody.Free;
1820                         end;
1821                         StatusBar.Panels[0].Text := '\83\8d\81[\83J\83\8b\83\8b\81[\83\8b\8eæ\93¾\8a®\97¹(' + IntToStr(Indy.ResponseCode) + ')';
1822                     end;
1823                 except
1824                     on E: EIdException do begin
1825                         if( AnsiPos('304', E.Message) > 0 ) then
1826                             StatusBar.Panels[0].Text := '\83\8d\81[\83J\83\8b\83\8b\81[\83\8b\8dX\90V\96³\82µ(' + IntToStr(Indy.ResponseCode) + ')'
1827                         else
1828                             StatusBar.Panels[0].Text := '\83\8d\81[\83J\83\8b\83\8b\81[\83\8b\8eæ\93¾\83G\83\89\81[(' + IntToStr(Indy.ResponseCode) + ')';
1829                     end;
1830                 end;
1831             finally
1832                 memStream.Free;
1833                 Screen.Cursor := crDefault;
1834             end;
1835             if tmpBoard.IsHEADTXT then begin
1836                 ShowBoardHead(tmpboard, LocalEdit);
1837             end;
1838         end;
1839         FWork := False;
1840     end;
1841
1842 end;
1843
1844 procedure TEditorForm.CalcCapacityActionExecute(Sender: TObject);
1845 var
1846         Board: TBoard;
1847         body: String;
1848 begin
1849         body := GetBody;
1850     //\82Ç\82¤\82à\81A\89ü\8ds\95ª\82¸\82ê\82Ä\82½\82Á\82Û\82¢\82¯\82Ç\81A\96{\93\96\82©\82æ\82­\95ª\82©\82ç\82È\82¢\81B
1851     Board := GetBoard;
1852
1853         if Board.BoardPlugIn <> nil then
1854                 body := CustomStringReplace(body, #13#10, '<br>')
1855         else
1856                 body := CustomStringReplace(body, #13#10, ' <br> ');
1857         StatusBar.Panels[0].Text := '\97e\97Ê:' + IntToStr(Length(body)) + ' byte';
1858 end;
1859
1860 procedure TEditorForm.LocalRuleClick(Sender: TObject);
1861 var
1862   ini: TMemIniFile;
1863 begin
1864         ini := TMemIniFile.Create(GikoSys.Setting.GetFileName);
1865         try
1866                 RocalRuleTab.TabVisible := LocalRule.Checked;
1867                 ini.WriteBool('EditorForm', 'LocalRuleTab', RocalRuleTab.TabVisible);
1868         ini.UpdateFile;
1869         finally
1870                 ini.Free;
1871         end;
1872 end;
1873
1874 procedure TEditorForm.FormDeactivate(Sender: TObject);
1875 begin
1876     if GikoSys.Setting.GestureEnabled then begin
1877         GikoSys.Setting.Gestures.ClearGesture;
1878         MouseGesture.UnHook;
1879                 MouseGesture.OnGestureStart := nil;
1880                 MouseGesture.OnGestureMove := nil;
1881                 MouseGesture.OnGestureEnd := nil;
1882     end;
1883 end;
1884
1885 procedure TEditorForm.OnGestureStart(Sender: TObject);
1886 begin
1887 //
1888 end;
1889
1890 procedure TEditorForm.OnGestureMove(Sender: TObject);
1891 var
1892         s: string;
1893         Action: TAction;
1894         ActStr: string;
1895 begin
1896         s := MouseGesture.GetGestureStr;
1897         ActStr := '';
1898         Action := GikoSys.Setting.Gestures.GetGestureAction(s);
1899         if Action <> nil then
1900                 ActStr := '\81i' + Action.Caption + '\81j';
1901         s := '\83W\83F\83X\83`\83\83\81[: ' + s + ActStr;
1902         StatusBar.Panels[0].Text := s;
1903 end;
1904
1905 procedure TEditorForm.OnGestureEnd(Sender: TObject);
1906 var
1907         s: string;
1908         Action: TAction;
1909 begin
1910         s := MouseGesture.GetGestureStr;
1911     MouseGesture.Clear;
1912         Action := GikoSys.Setting.Gestures.GetGestureAction(s);
1913         if Action <> nil then
1914                 Action.Execute;
1915         StatusBar.Panels[0].Text := '';
1916 end;
1917
1918 procedure TEditorForm.ShowBoardHead(ABoard: TBoard; AMemo: TMemo);
1919 var
1920     range: OleVariant;
1921 begin
1922         //\8eQ\8dl\8c³
1923         //http://www.campus.ne.jp/~ishigami/CREATION/TECHNIC/WEBAP-2.htm
1924         WebBrowser1.Navigate(ABoard.GETHEADTXTFileName);
1925         //\83\8c\83^\83\8a\83\93\83O\82ª\92x\82·\82¬\82ÄTXT\82É\88Ú\82¹\82È\82¢\81B\82Ê\82é\82Ûorz
1926         //\89º\82Ì\82æ\82¤\82É\82¿\82á\82ñ\82Æ\93Ç\82Ý\8d\9e\82Ý\82ª\8fI\82í\82Á\82Ä\82¢\82é\82©\81A\83`\83F\83b\83N\82·\82ê\82Î\82¢\82¢\82ñ\82¾\82æ\81B
1927         //\82±\82ê\82Å\82¢\82¯\82Ü\82µ\82½\81B\82 \82è\82ª\82Æ\82¤\82²\82´\82¢\82Ü\82µ\82½\81B
1928         while (WebBrowser1.ReadyState <> READYSTATE_COMPLETE) and
1929                         (WebBrowser1.ReadyState <> READYSTATE_INTERACTIVE) do begin
1930                 Application.ProcessMessages;
1931         end;
1932
1933     try
1934     ;
1935         range := OleVariant(WebBrowser1.Document).body.createTextRange;
1936             LocalEdit.Text := range.text;
1937     except
1938     end;
1939 end;
1940
1941 procedure TEditorForm.LocalRuleBrowseClick(Sender: TObject);
1942 var
1943     URL: String;
1944     ABoard: TBoard;
1945 begin
1946     ABoard := GetBoard;
1947
1948         if ABoard = nil
1949         then Exit;
1950
1951     URL := ABoard.GETHEADTXTFileName;
1952     GikoSys.OpenBrowser(URL, gbtAuto);
1953 end;
1954
1955 procedure TEditorForm.SaveNameMailActionExecute(Sender: TObject);
1956 begin
1957         SaveNameMailAction.Checked := not SaveNameMailAction.Checked;
1958         KotehanCheckBox.Enabled := SaveNameMailAction.Checked;
1959 end;
1960
1961 function TEditorForm.LFusianaGet(const s: String): Boolean;
1962 const
1963     FUSIANA = 'fusianasan';
1964 var
1965         i: Integer;
1966 begin
1967     i := AnsiPos(FUSIANA, s);
1968     Result := (i > 0);
1969 end;
1970
1971 procedure TEditorForm.BeLogInOutEActionExecute(Sender: TObject);
1972 begin
1973     GikoDM.BeLogInOutAction.Execute;
1974 end;
1975
1976 procedure TEditorForm.BeLogInOutEActionUpdate(Sender: TObject);
1977 begin
1978     BeLogInOutEAction.Checked := GikoDM.BeLogInOutAction.Checked;
1979     BeLogInOutEAction.Enabled := GikoDM.BeLogInOutAction.Enabled;
1980 end;
1981 // Cookie\82Ì\8eæ\93¾
1982 procedure TEditorForm.GetCookie(CookieMng: TIdCookieManager; ABoard: TBoard);
1983 const
1984         VAL_SPID        = 'SPID';
1985         VAL_PON         = 'PON';
1986     VAL_HAP     = 'HAP';
1987 var
1988         i : Integer;
1989     Cookie : TIdCookieRFC2109;
1990     curCookies : TStringList;
1991 begin
1992     // 2008.12.14 \96³\8fð\8c\8f\83N\83\8a\83A\82µ\82Ä\82Í\82¢\82¯\82È\82¢ by \82à\82\82ã
1993     curCookies := TStringList.Create;
1994     curCookies.Delimiter := ';';
1995     curCookies.DelimitedText := ABoard.Cookie;
1996     curCookies.Sort;
1997     curCookies.Duplicates := dupIgnore;
1998         ABoard.Cookie := '';
1999     try
2000         for i := 0 to CookieMng.CookieCollection.Count - 1 do begin
2001             Cookie := CookieMng.CookieCollection.Items[i];
2002             if ( Cookie.CookieName = VAL_PON ) then begin
2003                 ABoard.PON := Cookie.Value;
2004                 ABoard.Expires := GMTToLocalDateTime(Cookie.Expires);
2005             end else if ( Cookie.CookieName = VAL_SPID ) then begin
2006                 ABoard.SPID := Cookie.Value;
2007                 ABoard.Expires := GMTToLocalDateTime(Cookie.Expires);
2008             end else if ( Cookie.CookieName = VAL_HAP ) then begin
2009                 // HAP\8dí\8f\9c\97p\82ÌCookie\82ª\94z\95z\82³\82ê\82é\82Ì\82Å\81A\97L\8cø\8aú\8cÀ\82ð\83`\83F\83b\83N\82·\82é
2010                 if CompareDateTime(GMTToLocalDateTime(Cookie.Expires) ,Now) > 0 then begin
2011                     GikoSys.SetBoukenCookie(Cookie.Value, Cookie.Domain);
2012                     // \96`\8c¯\82Ì\8f\91\82Ì\95Û\91
2013                     GikoSys.Setting.WriteBoukenSettingFile;
2014                 end;
2015             end else begin
2016                 if Length( curCookies.Values[ Cookie.CookieName ] ) > 0 then begin
2017                     // \8aù\91\92l\82Ì\95t\82¯\91Ö\82¦
2018                     curCookies[curCookies.IndexOfName(Cookie.CookieName)] :=
2019                         Cookie.ClientCookie;
2020                 end else begin
2021                     // \92Ç\89Á
2022                     curCookies.Add(Cookie.ClientCookie);
2023                 end;
2024             end;
2025         end;
2026         for i := 0 to curCookies.Count - 1 do begin
2027             if (curCookies[i] <> '') then begin
2028                 ABoard.Cookie := ABoard.Cookie + curCookies[i] + '; ';
2029             end;
2030         end;
2031     finally
2032         CookieMng.CookieCollection.Clear;
2033         curCookies.Free;
2034     end;
2035 end;
2036 //! hidden\83f\81[\83^\8eæ\93¾
2037 procedure TEditorForm.GetHiddenParameter(Rawtext: String; ABoard: TBoard);
2038 const
2039     INPUT_MARK = '<input type=hidden' ; // \91å\95\8e\9a\8f¬\95\8e\9a\82Î\82ç\82Î\82ç\82È\82±\82Æ\82É\92\8d\88Ó
2040     VALUE_MARK = 'value=' ;              // \91å\95\8e\9a\8f¬\95\8e\9a\82Î\82ç\82Î\82ç\82È\82±\82Æ\82É\92\8d\88Ó
2041     NAME_MARK  = 'name=' ;               // \91å\95\8e\9a\8f¬\95\8e\9a\82Î\82ç\82Î\82ç\82È\82±\82Æ\82É\92\8d\88Ó
2042     IGNORE_NAMES : array[0..6] of String =
2043         ('subject', 'from', 'mail', 'message', 'bbs', 'time', 'key');
2044 var
2045     tmp, line, name, value, lname : String;
2046     pos, pose, i : Integer;
2047 begin
2048     tmp := AnsiLowerCase(Rawtext);
2049     pos := AnsiPos(INPUT_MARK, tmp);
2050     while  (pos > 0 ) do begin
2051                 tmp := Copy(Rawtext, pos + Length(INPUT_MARK), Length(tmp));
2052         Delete(Rawtext, 1, pos+ Length(INPUT_MARK) - 1);
2053         pose := AnsiPos('>', tmp);
2054         // name=xxx value=yyy \82ª\90Ø\82è\8fo\82³\82ê\82é
2055         line := Copy(tmp, 1, pose - 1);
2056         name := '';
2057         value := '';
2058         pos := AnsiPos(NAME_MARK, tmp);
2059         if (pos > 0) then begin
2060             name := Copy(Rawtext, pos + Length(NAME_MARK), Length(line));
2061             //\94¼\8ap"\82Å\8en\82Ü\82Á\82Ä\82¢\82é\82©
2062             if AnsiPos('"', name) = 1 then begin
2063                 // \94¼\8ap"\82Ü\82Å\82ð\83R\83s\81[
2064                 Delete(name, 1, 1);
2065                 pose := AnsiPos('"', name);
2066                 if (pose > 0) then begin
2067                     Delete(name, pose, Length(name));
2068                 end else begin
2069                     pose := AnsiPos(' ', name);
2070                     if (pose > 0) then begin
2071                         Delete(name, pose, Length(name));
2072                     end;
2073                 end;
2074             end else begin
2075                 pose := AnsiPos(' ', name);
2076                 if (pose > 0) then begin
2077                     Delete(name, pose, Length(name));
2078                 end;
2079             end;
2080         end;
2081         lname := AnsiLowerCase(name);
2082         for i := 0 to Length(IGNORE_NAMES) do begin
2083             if lname = IGNORE_NAMES[i] then begin
2084                 name := '';
2085                 break;
2086             end;
2087         end;
2088         pos := AnsiPos(VALUE_MARK, tmp);
2089         if (name <> '') and (pos > 0) then begin
2090             value := Copy(Rawtext, pos + Length(VALUE_MARK), Length(line));
2091             //\94¼\8ap"\82Å\8en\82Ü\82Á\82Ä\82¢\82é\82©
2092             if AnsiPos('"', value) = 1 then begin
2093                 // \94¼\8ap"\82Ü\82Å\82ð\83R\83s\81[
2094                 Delete(value, 1, 1);
2095                 pose := AnsiPos('"', value);
2096                 if (pose > 0) then begin
2097                     Delete(value, pose, Length(value));
2098                 end else begin
2099                     pose := AnsiPos(' ', value);
2100                     if (pose > 0) then begin
2101                         Delete(value, pose, Length(value));
2102                     end;
2103                 end;
2104             end else begin
2105                 pose := AnsiPos(' ', value);
2106                 if (pose > 0) then begin
2107                     Delete(value, pose, Length(name));
2108                 end;
2109             end;
2110         end;
2111         if (name <> '') then begin
2112             ABoard.Cookie := ABoard.Cookie + name + '=' + value + '; '; 
2113
2114         end;
2115                 Delete(tmp, 1, Length(line));
2116         Delete(Rawtext, 1, Length(line));
2117         pos := AnsiPos(INPUT_MARK, tmp);
2118     end;
2119 end;
2120
2121 //! \83T\83\93\83o\8dX\90V\82Ì\83A\83N\83V\83\87\83\93\82ÌUpdate\83C\83x\83\93\83g\81@\8aÈ\92P\82Ì\82½\82ß\83^\83C\83}\81[\82Æ\93¯\82\82É\82µ\82Ä\82¨\82­
2122 procedure TEditorForm.UpdateSambaActionUpdate(Sender: TObject);
2123 begin
2124         UpdateSambaAction.Enabled := FSambaTimer.Enabled;
2125 end;
2126
2127 //! \83T\83\93\83o\8dX\90V\83A\83N\83V\83\87\83\93
2128 procedure TEditorForm.UpdateSambaActionExecute(Sender: TObject);
2129 var
2130         input : String;
2131         i : Integer;
2132 begin
2133         if InputQuery('Samba24\90Ý\92è\92l\8dX\90V', '\90V\82µ\82¢\90Ý\92è\92l\82ð\93ü\97Í\82µ\82Ä\82­\82¾\82³\82¢', input) then begin
2134         input := ZenToHan(input);
2135                 if GikoSys.IsNumeric(input) then begin
2136             FSambaTimer.UpdateSambaSetting(StrToInt(input));
2137             UpdateSambaStatus;
2138                         //\91S\82Ä\82Ì\83t\83H\81[\83\80\82©\82ç\81ASamba\83^\83C\83}\81[\82ð\8dX\90V\82·\82é
2139                         for i := 0 to Screen.FormCount - 1 do begin
2140                                 if Screen.Forms[i] is TEditorForm then begin
2141                     TEditorForm(Screen.Forms[i]).FSambaTimer.Update;
2142                     TEditorForm(Screen.Forms[i]).UpdateSambaStatus;
2143                 end;
2144                         end;
2145                 end else begin
2146                         ShowMessage('\90\94\92l\82ð\93ü\97Í\82µ\82Ä\82­\82¾\82³\82¢');
2147                         UpdateSambaActionExecute(Sender);
2148                 end;
2149         end;
2150 end;
2151
2152 procedure TEditorForm.UpdateSambaStatus;
2153 begin
2154     if (FSambaTimer.Enabled) then begin
2155         StatusBar.Panels[2].Text
2156             := 'Samba24\8bK\92è\92l' + IntToStr(FSambaTimer.SambaInterval);
2157     end;
2158 end;
2159
2160 procedure TEditorForm.InputAssistActionExecute(Sender: TObject);
2161 var
2162         count, i : Integer;
2163         item : TMenuItem;
2164         point: TPoint;
2165         Bitmap : TBitmap;
2166         TextWidth, ItemWidth, tmpWidth: Integer;
2167 begin
2168         if FInputAssistKey = '' then Exit;
2169
2170         InputAssistPopupMenu.Items.Clear;
2171
2172         if (FResistWords = nil) then begin
2173                 FResistWords := TStringList.Create;
2174         end else begin
2175                 FResistWords.Clear;
2176         end;
2177
2178         if (GetKeyState( VK_SHIFT ) < 0) then begin
2179                 // \83V\83t\83g\82ª\89\9f\82³\82ê\82Ä\82¢\82ê\82Î\81A\83L\81[\82Å\8en\82Ü\82é\83J\83e\83S\83\8a
2180                 count :=
2181                         InputAssistDM.GetStartWithCategoryResistWords(
2182                                                                         FInputAssistKey, FResistWords);
2183         end else begin
2184                 // \83V\83t\83g\82ª\96³\82¢\82Ì\82Å\81A\83L\81[\82Å\8en\82Ü\82é\83L\81[
2185                 count :=
2186                         InputAssistDM.GetStartWithKeyResistWords(
2187                                                                         FInputAssistKey, FResistWords);
2188         end;
2189         Bitmap := TBitmap.Create;
2190         try
2191                 Bitmap.Canvas.Font.Assign(BodyEdit.Font);
2192                 // \83}\81[\83W\83\935px
2193                 TextWidth := Bitmap.Canvas.TextWidth(FInputAssistKey) + 5;
2194                 ItemWidth := 0;
2195                 for i := 0 to count - 1 do begin
2196                         item := TMenuItem.Create(nil);
2197                         item.Break := mbNone;
2198                         item.Caption := FResistWords[i];
2199                         item.Tag := i;
2200                         item.OnClick := InputAssistMenuClick;
2201                         InputAssistPopupMenu.Items.Add(item);
2202
2203                         tmpWidth := Bitmap.Canvas.TextWidth(Item.Caption);
2204                         if (tmpWidth > ItemWidth) then begin
2205                                 ItemWidth := tmpWidth;
2206                         end;
2207                 end;
2208         finally
2209                 Bitmap.Free;
2210         end;
2211
2212         if (count > 0) then begin
2213                 GetCaretpos(point);
2214                 point.X := point.X + Self.Left + (Self.Width - BodyEdit.Width) div 2;
2215                 point.Y := point.Y + Self.Top + (Self.Height - Self.ClientHeight);
2216
2217                 if Screen.DesktopWidth >
2218                         (point.X + TextWidth + ItemWidth) then begin
2219                         InputAssistPopupMenu.Popup(
2220                                 point.X + TextWidth,
2221                                 point.Y + EditorPage.Top + EditorPage.TabHeight + BodyEdit.Top);
2222                 end else begin
2223                         InputAssistPopupMenu.Popup(
2224                                 point.X - TextWidth - ItemWidth,
2225                                 point.Y + EditorPage.Top + EditorPage.TabHeight + BodyEdit.Top);
2226                 end;
2227         end;
2228 end;
2229
2230 procedure TEditorForm.InputAssistMenuClick(Sender: TObject);
2231 var
2232         text : String;
2233         IMC: HIMC;
2234 begin
2235         if not (Sender is TMenuItem) then Exit;
2236
2237         if (FResistWords <> nil) then begin
2238                 try
2239                         text :=
2240                                 TResistWord(FResistWords.Objects[TMenuItem(Sender).Tag]).GetText;
2241                 except
2242                         text := '';
2243                 end;
2244                 IMC := ImmGetContext(BodyEdit.Handle); //\83R\83\93\83e\83L\83X\83g\8eæ\93¾
2245                 try
2246                         ImmNotifyIME(IMC, NI_COMPOSITIONSTR, CPS_CANCEL, 0);
2247                 finally
2248                         ImmReleaseContext(BodyEdit.Handle, IMC);  //\83R\83\93\83e\83L\83X\83g\89ð\95ú
2249                 end;
2250
2251                 FResistWords.Clear;
2252                 FInputAssistKey := '';
2253         end;
2254     BodyEdit.InsertText(text);
2255 end;
2256
2257 (*
2258 //! TMemo\82Ì\83J\81[\83\\83\8b\88Ê\92u\82É\95\8e\9a\97ñ\91}\93ü
2259 procedure TEditorForm.InsertText(Memo: TMemo; Text: String);
2260 var
2261         line, sel, pos: Integer;
2262         left, right : String;
2263 begin
2264         Memo.Lines.BeginUpdate;
2265         line := SendMessage(Memo.Handle,EM_LINEFROMCHAR,-1,0);  //\8ds
2266         sel := Memo.SelStart;
2267         pos     := sel - SendMessage(Memo.Handle, EM_LINEINDEX, -1, 0); //\8c\85
2268         if (pos > 0) then begin
2269                 left := Copy(Memo.Lines[line], 0, pos);
2270         end else begin
2271                 left := '';
2272         end;
2273         right := Copy(Memo.Lines[line], pos + 1, Length(Memo.Lines[line]));
2274         Memo.Lines.Strings[line] := left + Text + right;
2275         Memo.Lines.EndUpdate;
2276         //\81@\83L\83\83\83\8c\83b\83g\82Ì\88Ê\92u\82ð\8dX\90V\82·\82é
2277         Memo.SelStart := sel + Length(text);
2278         // \83L\83\83\83\8c\83b\83g\82Ì\88Ê\92u\82Ü\82Å\83X\83N\83\8d\81[\83\8b
2279         Memo.Perform(EM_SCROLLCARET, 0, 0);
2280
2281 end;
2282 *)
2283
2284 procedure TEditorForm.ApplicationEvents1Message(var Msg: tagMSG;
2285   var Handled: Boolean);
2286 var
2287         wmMsg: TWMKey;
2288         IMC: HIMC;
2289         Len: integer;
2290         Str: string;
2291 begin
2292         if (Self.Active) then begin
2293                 case Msg.message of
2294                         //\83L\81[\89\9f\89º\82Ì\82Ý\8eó\82¯\8eæ\82é
2295                         WM_KEYDOWN:
2296                         begin
2297                                 // \83^\83u\82ª\81h\95Ò\8fW\81h\82ÅCtrl\83L\81[\82ª\89\9f\82³\82ê\82Ä\82¢\82é\82Ì\82ð\8am\94F\82·\82é
2298                                 if (EditorPage.ActivePageIndex = 0)
2299                                                 and (GetKeyState( VK_CONTROL ) < 0) then begin
2300                                         wmMsg.Msg := Msg.message;
2301                                         wmMsg.CharCode := Word(Msg.wParam);
2302                                         wmMsg.KeyData := Msg.lParam;
2303                                         if (wmMsg.CharCode = 229) and (wmMsg.KeyData = 3735553) then begin
2304                                                 IMC := ImmGetContext(BodyEdit.Handle); //\83R\83\93\83e\83L\83X\83g\8eæ\93¾
2305                                                 Len := ImmGetCompositionString(IMC, GCS_COMPSTR, nil, 0); //\82Ü\82¸\92·\82³\82ð\8eæ\93¾
2306                                                 if (Len > 0) then begin
2307                                                         SetLength(Str, Len + 1); //Buffer\82Ì\83\81\83\82\83\8a\82ð\90Ý\92è
2308                                                         ImmGetCompositionString(IMC, GCS_COMPSTR, PChar(Str), Len + 1); //\82Ü\82¸\92·\82³\82ð\8eæ\93¾
2309                                                         SetLength(Str, Len);
2310                                                         FInputAssistKey := Str;
2311                                                         InputAssistActionExecute(nil);
2312                                                         Handled := True;
2313                                                 end;
2314                                                 ImmReleaseContext(BodyEdit.Handle, IMC);  //\83R\83\93\83e\83L\83X\83g\89ð\95ú
2315                                         end;
2316                                 end;
2317                         end;
2318                 end;
2319
2320         end;
2321 end;
2322
2323 procedure TEditorForm.ShowInputAssistFormExecute(Sender: TObject);
2324 var
2325         form : TInputAssistForm;
2326 begin
2327         form := TInputAssistForm.Create(nil);
2328         try
2329                 if TopAction.Checked then begin // \83X\83e\83C\8fó\91Ô\82É\90Ý\92è
2330                         SetWindowPos(form.Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
2331         end;
2332                 form.SetUpFromEditor;
2333                 if (form.ShowModal = mrOk) then begin
2334                         BodyEdit.InsertText(form.GetInsertText);
2335                 end;
2336         finally
2337                 form.Release;
2338         end;
2339 end;
2340 //! Cookie\8fî\95ñ\8dí\8f\9c
2341 procedure TEditorForm.ReleaseCookieActionExecute(Sender: TObject);
2342 var
2343         Board : TBoard;
2344 begin
2345         // \83X\83\8c\83b\83h\82ª\96³\82¢\81@\83X\83\8c\97§\82Ä\82Ì\82Æ\82«\82ÍFBoard\82ð\92¼\90Ú\8eg\82¤
2346     Board := GetBoard;
2347
2348         // \83N\83b\83L\81[\82Ì\8fî\95ñ\82ð\8eÌ\82Ä\82é
2349         Board.Cookie := '';
2350         Board.SPID := '';
2351         Board.PON  := '';
2352         // 0\82É\8aª\82«\96ß\82·
2353         Board.Expires := 0;
2354 end;
2355 //! \94Â\8fî\95ñ\8eæ\93¾Update\83C\83x\83\93\83g
2356 procedure TEditorForm.GetSETTINGTXTActionUpdate(Sender: TObject);
2357 begin
2358         // \8eÀ\8ds\92\86\82Í\8eÀ\8ds\95s\89Â
2359         GetSETTINGTXTAction.Enabled := not FWork;
2360 end;
2361 //! \83\8d\81[\83J\83\8b\83\8b\81[\83\8b\8eæ\93¾Update\83C\83x\83\93\83g
2362 procedure TEditorForm.GetHeadTXTActionUpdate(Sender: TObject);
2363 begin
2364         // \8eÀ\8ds\92\86\82Í\8eÀ\8ds\95s\89Â
2365         GetSETTINGTXTAction.Enabled := not FWork;
2366 end;
2367
2368 //! Samba\83^\83C\83}\81[\83C\83x\83\93\83g
2369 procedure TEditorForm.SambaTimer(Sender: TObject);
2370 begin
2371
2372         if FSambaTimer.WriteDeta = ZERO_DATE then
2373                 StatusBar.Panels[1].Text := '\8f\89\8f\91'
2374         else begin
2375                 FNow := IncMilliSecond(FNow, 500);
2376                 StatusBar.Panels[1].Text :=
2377             Format('%8.0f\95b\8co\89ß', [SecondSpan(FNow, FSambaTimer.WriteDeta)]);
2378         end;
2379 end;
2380 {
2381 \brief \83E\83B\83\93\83h\83E\82Ì\88Ê\92u\82Æ\83T\83C\83Y\82Ì\90Ý\92è
2382 }
2383 procedure TEditorForm.SetWindowRect;
2384 var
2385     wp: TWindowPlacement;
2386     MonCnt: Integer;
2387     MonOk: Boolean;
2388     MonR: Integer;
2389     MonB: Integer;
2390     Right: Integer;
2391     Bottom: Integer;
2392 begin
2393         //\83E\83B\83\93\83h\83E\82Ì\88Ê\92u\90Ý\92è
2394         wp.length := sizeof(wp);
2395         wp.rcNormalPosition.Top := GikoSys.Setting.EditWindowTop;
2396         wp.rcNormalPosition.Left := GikoSys.Setting.EditWindowLeft;
2397
2398         wp.rcNormalPosition.Bottom := GikoSys.Setting.EditWindowTop + GikoSys.Setting.EditWindowHeight;
2399         wp.rcNormalPosition.Right := GikoSys.Setting.EditWindowLeft + GikoSys.Setting.EditWindowWidth;
2400         wp.showCmd := SW_HIDE;
2401         SetWindowPlacement(Handle, @wp);
2402
2403         if GikoSys.Setting.EditWindowMax then begin
2404                 WindowState := wsMaximized;
2405     end;
2406
2407         //\83E\83B\83\93\83h\83E\82ª\89æ\96Ê\8aO\82È\82ç\89æ\96Ê\93à\82É\88Ú\93®\82·\82é
2408     Right := Left + Width;
2409     Bottom := Top + Height;
2410     MonOk := False;
2411     MonCnt := 0;
2412     while (MonCnt < Screen.MonitorCount) do begin
2413         MonR := Screen.Monitors[MonCnt].Left + Screen.Monitors[MonCnt].Width;
2414         MonB := Screen.Monitors[MonCnt].Top  + Screen.Monitors[MonCnt].Height;
2415
2416         if ((Left  >= Screen.Monitors[MonCnt].Left) and (Left   <  MonR) and
2417             (Top   >= Screen.Monitors[MonCnt].Top)  and (Top    <  MonB) and
2418             (Right  > Screen.Monitors[MonCnt].Left) and (Right  <= MonR) and
2419             (Bottom > Screen.Monitors[MonCnt].Top)  and (Bottom <= MonB)) then begin
2420             MonOk := True;
2421             Break;
2422         end;
2423
2424         MonCnt := MonCnt + 1;
2425     end;
2426
2427     if (MonOk = False) then begin
2428         Left := 0;
2429         Top := 0;
2430     end;
2431
2432     //\8c»\8dÝ\82Ì\83E\83B\83\93\83h\83E\82Ì\88Ê\92u\82ð\95Û\91
2433     GikoSys.Setting.EditWindowTop := Top  + WINDOWMOVE_V;   // \8e\9f\82É\8aJ\82­\83E\83B\83\93\83h\83E\82Í
2434     GikoSys.Setting.EditWindowLeft := Left + WINDOWMOVE_H;  // \81@\81@\81@\89E\8eÎ\82ß\89º\82É\82¸\82ç\82·
2435     //\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·
2436         if GikoSys.Setting.EditWindowHeight < 144 then begin
2437                 Height := 400;
2438     end;
2439         if GikoSys.Setting.EditWindowWidth < 144 then begin
2440                 Width := 640;
2441     end;
2442 end;
2443 {
2444 \brief \8ag\92£\83^\83u\90Ý\92è
2445 }
2446 procedure TEditorForm.SetExtraTab;
2447 const
2448     SECTION = 'EditorForm';
2449 var
2450     ini: TMemIniFile;
2451 begin
2452     ini := TMemIniFile.Create(GikoSys.Setting.GetFileName);
2453     try
2454         BoardtopTab.TabVisible := ini.Readbool(SECTION, 'BoardTopTab', False);
2455         BoardTop.Checked := BoardtopTab.TabVisible;
2456         RocalRuleTab.TabVisible := ini.ReadBool(SECTION, 'LocalRuleTab', False);
2457         LocalRule.Checked := RocalRuleTab.TabVisible;
2458     finally
2459         ini.Free;
2460     end;
2461 end;
2462 {
2463 \brief \94Â\8eæ\93¾
2464 \return \83\8c\83X\83G\83f\83B\83^\82ª\93\8a\8de\82µ\82æ\82¤\82Æ\82µ\82Ä\82¢\82é\94Â
2465 }
2466 function TEditorForm.GetBoard : TBoard;
2467 begin
2468     // \83X\83\8c\83b\83h\83A\83C\83e\83\80\82ªnull\82Ì\8e\9e\82ÍFBoard
2469     if FThreadItem = nil then begin
2470         Result := FBoard;
2471     end else  begin
2472         Result := FThreadItem.ParentBoard;
2473     end;
2474 end;
2475 {
2476 \brief  GikoForm\82É\83\81\83b\83Z\81[\83W\82ð\92Ç\89Á\82·\82é
2477 \param  icon    \83\81\83b\83Z\81[\83W\82É\82Â\82­\83A\83C\83R\83\93
2478 }
2479 procedure TEditorForm.AddFormMessageNew(icon: TGikoMessageIcon);
2480 begin
2481     if FThreadItem = nil then begin
2482         GikoForm.AddMessageList(FBoard.Title + ' ' + GikoSys.GetGikoMessage(gmNewSure), nil, icon)
2483     end else begin
2484         GikoForm.AddMessageList(FThreadItem.Title + ' ' + GikoSys.GetGikoMessage(gmNewRes), nil, icon);
2485     end;
2486
2487 end;
2488 {
2489 \brief  \83\8d\81[\83J\83\8bfusiana\83g\83\89\83b\83v
2490 \return true:\91\97\90M\92\86\8e~ false:\91\97\90M
2491 }
2492 function TEditorForm.isLocalFusianaTrap: Boolean;
2493 var
2494     Namae : string;
2495 begin
2496     Result := False;
2497     if GikoSys.Setting.LocalTrapAtt then begin
2498         Namae := THTMLCreate.RepHtml(NameComboBox.Text);
2499         if (LFusianaGet(Namae)) or (Namae = '\8eR\8dè\8fÂ') then begin
2500             if FusianaMsgBox = IDNO  then begin
2501                 Result := True;
2502             end;
2503         end;
2504     end;
2505 end;
2506 {
2507 \brief  \83\8a\83\82\81[\83gfusiana\83g\83\89\83b\83v
2508 \return true:\91\97\90M\92\86\8e~ false:\91\97\90M
2509 }
2510 function TEditorForm.isRemoteFusianaTrap: Boolean;
2511 var
2512     Namae : string;
2513     Board : TBoard;
2514     Remote: string;
2515     body : TStringList;
2516 begin
2517     Result := False;
2518     Namae := THTMLCreate.RepHtml(NameComboBox.Text);
2519     if (GikoSys.Setting.RemoteTrapAtt) and (Length(Namae) = 0) then begin
2520         Board := GetBoard;
2521
2522         if Board = nil then Exit;
2523
2524         if not FileExists(Board.GetSETTINGTXTFileName)  then begin
2525             //Setting.txt\82ª\82È\82©\82Á\82½\82ç\8eæ\93¾
2526             //\8eI\82É\95\89\89×\82ª\82©\82©\82è\82»\82¤...
2527             try
2528                 GetSETTINGTXTAction.Execute;
2529             except
2530             end;
2531         end;
2532
2533         Remote := '';
2534         if FileExists(Board.GetSETTINGTXTFileName)  then begin
2535             body := TStringList.Create;
2536             try
2537                 body.LoadFromFile(Board.GetSETTINGTXTFileName);
2538                 Remote := GetFusianaName(body, Board);
2539             finally
2540                 body.Free;
2541             end;
2542         end;
2543
2544         if LFusianaGet(Remote) then begin
2545             if FusianaMsgBox = IDNO  then begin
2546                 Result := True;
2547             end;
2548         end;
2549     end;
2550 end;
2551 {
2552 \brief  Header\95\8e\9a\97ñ\8eæ\93¾
2553 \param  ACOOKIE Cookie
2554 \param  SPID    SPID
2555 \param  PON    PON
2556 \param  HAP     HAP
2557 \param  Board   \94Â
2558 \return Header\95\8e\9a\97ñ
2559 }
2560 function TEditorForm.getHeaderStr(const ACOOKIE: string; const SPID : string;
2561     const PON : string; const HAP : string; Board : TBoard) : string;
2562 begin
2563     Result := ACOOKIE;
2564
2565         if SPID <> '' then
2566                 Result := Result + 'SPID=' + SPID + '; ';
2567         if PON <> '' then
2568                 Result := Result + 'PON=' + PON + '; ';
2569
2570         //\83z\83X\83g\82ª2ch\82Å\81ABe\82ÉLogin\82µ\82Ä\82¢\82ê\82ÎBE\82Ì\83f\81[\83^\82ð\91\97\82é
2571         //GikoSys.ParseURI( URL, Protocol,Host, Path, Document, Port, Bookmark );
2572         //if GikoSys.Is2chHost(Host) and GikoSys.Setting.BeLogin then
2573         if (Board.Is2ch) then begin
2574                 // \8cÅ\92è\82Ì\83N\83b\83L\81[\82ª\82 \82ê\82Î\90H\82í\82¹\82é
2575                 if Length(GikoSys.Setting.FixedCookie) > 0 then begin
2576                         // \83z\83X\83g\82ª2ch\82Ì\8fê\8d\87\81C\8cÅ\92è\82Ì\83N\83b\83L\81[\82ð\90H\82í\82¹\82é
2577                         Result := Result + GikoSys.Setting.FixedCookie + '; ';
2578                 end;
2579         if (GikoSys.Belib.Connected) then begin
2580                         Result := Result + 'MDMD=' + GikoSys.Belib.MDMD + '; '
2581                              + 'DMDM=' + GikoSys.Belib.DMDM + '; ';
2582                 end;
2583     end;
2584
2585         Result := 'Cookie: ' + Result + 'NAME=' + NameComboBox.Text + '; MAIL=' + MailComboBox.Text;
2586
2587     if HAP <> '' then
2588         Result := Result + '; HAP=' + HAP + '; ';
2589
2590 end;
2591
2592 {
2593 \brief fusiana\8cx\8d\90\83_\83C\83A\83\8d\83O
2594 \return IDYES \8f\91\82«\8d\9e\82Þ IDNO \92\86\8e~
2595 }
2596 function TEditorForm.FusianaMsgBox: Integer;
2597 const
2598         MSG_FUSIANA : string =  '\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 +
2599                 '\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' +
2600                 #13#10#13#10'\90Ó\94C\82ð\95\89\82¤\82±\82Æ\82ð\8f³\91ø\82µ\82Ä\8f\91\82«\8d\9e\82Ý\82Ü\82·\82©\81H';
2601 begin
2602     Result := MsgBox(Handle, MSG_FUSIANA, '\8fî\95ñ',
2603                 MB_YESNO or MB_ICONQUESTION);
2604 end;
2605 {
2606 \brief \98A\93\8a\83\82\81[\83hON/OFF\90Ø\82è\91Ö\82¦
2607 }
2608 procedure TEditorForm.ContinueModeActionExecute(Sender: TObject);
2609 begin
2610         ContinueModeAction.Checked := not ContinueModeAction.Checked;
2611 end;
2612 {
2613 \brief \98A\93\8a\83\82\81[\83h\8dX\90V\8f\88\97\9d
2614 }
2615 procedure TEditorForm.ContinueModeActionUpdate(Sender: TObject);
2616 begin
2617     // \83X\83\8c\82½\82Ä\82Ì\82Æ\82«\82Í\96³\8cø
2618     ContinueModeAction.Enabled := FThreadItem <> nil;
2619 end;
2620 {
2621 \brief \8f\91\82«\8d\9e\82Þ\94Â/\83X\83\8c\83b\83h\82ð\95\\8e¦\82·\82é
2622 }
2623 procedure TEditorForm.OpenSendTargetActionExecute(Sender: TObject);
2624 begin
2625     if (FThreadItem <> nil) then begin
2626         // \83\81\83C\83\93\82ð\8dX\90V\82µ\82Ä\82µ\82Ü\82¤\82Ì\82Å\89æ\96Ê\82ª\83p\83^\83p\83^\90Ø\82è\91Ö\82í\82é\82Ì\82ð\96h\82®\82½\82ß\82É
2627         // \91O\96Ê\82Å\8cÅ\92è\82·\82é
2628         if not (fsShowing in Self.FormState) then begin
2629             // \83X\83e\83C\8fó\91Ô\82É\90Ý\92è
2630             SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
2631         end;
2632         try
2633             // \83X\83\8c\83b\83h
2634             GikoForm.InsertBrowserTab(FThreadItem, True);
2635         finally
2636             if not TopAction.Checked then begin // \83X\83e\83C\8fó\91Ô\89ð\8f\9c
2637                 SetWindowPos(Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
2638             end;
2639         end;
2640         Self.SetFocus;
2641     end else begin
2642         // \94Â
2643         GikoForm.SelectTreeNode(
2644             GetBoard, True );
2645     end;
2646 end;
2647 procedure TEditorForm.ReloadTargetActionExecute(Sender: TObject);
2648 begin
2649     if (FThreadItem <> nil) then begin
2650         // \83X\83\8c\83b\83h
2651         // \83\81\83C\83\93\82ð\8dX\90V\82µ\82Ä\82µ\82Ü\82¤\82Ì\82Å\89æ\96Ê\82ª\83p\83^\83p\83^\90Ø\82è\91Ö\82í\82é\82Ì\82ð\96h\82®\82½\82ß\82É
2652         // \91O\96Ê\82Å\8cÅ\92è\82·\82é(\83_\83E\83\93\83\8d\81[\83h\82ª\94­\90\82·\82é\82Æ\90Ø\82è\91Ö\82í\82Á\82Ä\82µ\82Ü\82¤\82ª\82 \82«\82ç\82ß\82é)
2653         if not (fsShowing in Self.FormState) then begin
2654             // \83X\83e\83C\8fó\91Ô\82É\90Ý\92è
2655             SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
2656         end;
2657         try
2658             GikoForm.DownloadContent(FThreadItem);
2659         finally
2660             if not TopAction.Checked then begin // \83X\83e\83C\8fó\91Ô\89ð\8f\9c
2661                 SetWindowPos(Handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE);
2662             end;
2663         end;
2664         Self.SetFocus;
2665     end else begin
2666         // \94Â
2667         GikoForm.DownloadList(GetBoard);
2668     end;
2669 end;
2670 //! \8cë\94\9a\83`\83F\83b\83N
2671 function TEditorForm.isGobaku: Boolean;
2672 const
2673         MSG_GOBAKU : string =
2674         '\95\\8e¦\82µ\82Ä\82¢\82é%s\82Æ\93\8a\8de\90æ\82Ì%s\82ª\88Ù\82È\82è\82Ü\82·\81B'#13#10 +
2675                 '\82±\82Ì\82Ü\82Ü\8f\91\82«\8d\9e\82Ý\82Ü\82·\82©\81H';
2676 var
2677     ThreadItem : TThreadItem;
2678     msg : String;
2679
2680 begin
2681     Result := False;
2682     // \83I\83v\83V\83\87\83\93\97L\8cø\82©\82Â\83\8c\83X\91\97\90M\82Å\82Ì\82Ý\97L\8cø
2683     if (GikoSys.Setting.UseGobakuCheck) then begin
2684         // \83\8c\83X\91\97\90M
2685         if (FThreadItem <> nil) then begin
2686             ThreadItem := GikoForm.GetActiveContent(False);
2687             if (ThreadItem <> nil) then begin
2688                 if (FThreadItem <> ThreadItem) then begin
2689                     msg := Format(MSG_GOBAKU, ['\83X\83\8c\83b\83h', '\83X\83\8c\83b\83h']);
2690                     Result := MsgBox(Handle, msg, '\8fî\95ñ', MB_YESNO or MB_ICONQUESTION) = IDNO;
2691                 end;
2692             end else begin
2693                 if GikoForm.ActiveList is TBBS then begin
2694                     if TBBS(GikoForm.ActiveList) <> FThreadItem.ParentBoard.ParentCategory.ParenTBBS then begin
2695                         msg := Format(MSG_GOBAKU, ['BBS', '\83X\83\8c\83b\83h\82Ì\8f\8a\91®\82·\82éBBS']);
2696                         Result := MsgBox(Handle, msg, '\8fî\95ñ', MB_YESNO or MB_ICONQUESTION) = IDNO;
2697                     end;
2698                 end else if GikoForm.ActiveList is TCategory then begin
2699                     if TCategory(GikoForm.ActiveList).FindThreadFromURL(FThreadItem.URL) = nil then begin
2700                         msg := Format(MSG_GOBAKU, ['\83J\83e\83S\83\8a', '\83X\83\8c\83b\83h\82Ì\8f\8a\91®\82·\82é\83J\83e\83S\83\8a']);
2701                         Result := MsgBox(Handle, msg, '\8fî\95ñ', MB_YESNO or MB_ICONQUESTION) = IDNO;
2702                     end;
2703                 end else if GikoForm.ActiveList is TBoard then begin
2704                     if TBoard(GikoForm.ActiveList) <> FThreadItem.ParentBoard then begin
2705                         msg := Format(MSG_GOBAKU, ['\94Â', '\83X\83\8c\83b\83h\82Ì\8f\8a\91®\82·\82é\94Â']);
2706                         Result := MsgBox(Handle, msg, '\8fî\95ñ', MB_YESNO or MB_ICONQUESTION) = IDNO;
2707                     end;
2708                 end;
2709             end;
2710         end else begin
2711             // \83X\83\8c\82½\82Ä
2712             if GikoForm.ActiveList is TBBS then begin
2713                 if TBBS(GikoForm.ActiveList) <> FBoard.ParentCategory.ParenTBBS then begin
2714                     msg := Format(MSG_GOBAKU, ['BBS', '\94Â\82Ì\8f\8a\91®\82·\82éBBS']);
2715                     Result := MsgBox(Handle, msg, '\8fî\95ñ', MB_YESNO or MB_ICONQUESTION) = IDNO;
2716                 end;
2717             end else if GikoForm.ActiveList is TCategory then begin
2718                 if TCategory(GikoForm.ActiveList).FindBoardFromURL(FBoard.URL) = nil then begin
2719                     msg := Format(MSG_GOBAKU, ['\83J\83e\83S\83\8a', '\94Â\82Ì\8f\8a\91®\82·\82é\83J\83e\83S\83\8a']);
2720                     Result := MsgBox(Handle, msg, '\8fî\95ñ', MB_YESNO or MB_ICONQUESTION) = IDNO;
2721                 end;
2722             end else if GikoForm.ActiveList is TBoard then begin
2723                 if TBoard(GikoForm.ActiveList) <> FBoard then begin
2724                     msg := Format(MSG_GOBAKU, ['\94Â', '\94Â']);
2725                     Result := MsgBox(Handle, msg, '\8fî\95ñ', MB_YESNO or MB_ICONQUESTION) = IDNO;
2726                 end;
2727             end;
2728         end;
2729     end;
2730 end;
2731
2732 end.