OSDN Git Service

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