OSDN Git Service

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