OSDN Git Service

Add dialog to confirm certificate for SSL (experimental).
[ffftp/ffftp.git] / main.c
1 /*=============================================================================\r
2 *\r
3 *                                                                       FFFTP\r
4 *\r
5 ===============================================================================\r
6 / Copyright (C) 1997-2007 Sota. All rights reserved.\r
7 /\r
8 / Redistribution and use in source and binary forms, with or without \r
9 / modification, are permitted provided that the following conditions \r
10 / are met:\r
11 /\r
12 /  1. Redistributions of source code must retain the above copyright \r
13 /     notice, this list of conditions and the following disclaimer.\r
14 /  2. Redistributions in binary form must reproduce the above copyright \r
15 /     notice, this list of conditions and the following disclaimer in the \r
16 /     documentation and/or other materials provided with the distribution.\r
17 /\r
18 / THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR \r
19 / IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES \r
20 / OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \r
21 / IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, \r
22 / INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, \r
23 / BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF \r
24 / USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON \r
25 / ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
26 / (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF \r
27 / THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
28 /============================================================================*/\r
29 \r
30 #define  STRICT\r
31 #include <windows.h>\r
32 #include <stdio.h>\r
33 #include <stdlib.h>\r
34 #include <string.h>\r
35 #include <mbstring.h>\r
36 #include <malloc.h>\r
37 #include <windowsx.h>\r
38 #include <commctrl.h>\r
39 #include <stdarg.h>\r
40 #include <winsock.h>\r
41 \r
42 #include "common.h"\r
43 #include "resource.h"\r
44 #include "aes.h"\r
45 \r
46 #include <htmlhelp.h>\r
47 #include "helpid.h"\r
48 \r
49 // UTF-8対応\r
50 #undef __MBSWRAPPER_H__\r
51 #include "mbswrapper.h"\r
52 \r
53 \r
54 #define RESIZE_OFF              0               /* ウインドウの区切り位置変更していない */\r
55 #define RESIZE_ON               1               /* ウインドウの区切り位置変更中 */\r
56 #define RESIZE_PREPARE  2               /* ウインドウの区切り位置変更の準備 */\r
57 \r
58 #define RESIZE_HPOS             0               /* ローカル-ホスト間の区切り位置変更 */\r
59 #define RESIZE_VPOS             1               /* リスト-タスク間の区切り位置の変更 */\r
60 \r
61 \r
62 /*===== プロトタイプ =====*/\r
63 \r
64 static int InitApp(LPSTR lpszCmdLine, int cmdShow);\r
65 static int MakeAllWindows(int cmdShow);\r
66 static void DeleteAllObject(void);\r
67 static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);\r
68 static void StartupProc(char *Cmd);\r
69 static int AnalyzeComLine(char *Str, int *AutoConnect, int *CmdOption, char *unc, int Max);\r
70 static int CheckIniFileName(char *Str, char *Ini);\r
71 static int CheckMasterPassword(char *Str, char *Ini);\r
72 static int GetTokenAfterOption(char *Str, char *Result, const char* Opt1, const char* Opt2 );\r
73 static char *GetToken(char *Str, char *Buf);\r
74 static void ExitProc(HWND hWnd);\r
75 static void ChangeDir(int Win, char *Path);\r
76 static void ResizeWindowProc(void);\r
77 static void CalcWinSize(void);\r
78 // static void AskWindowPos(HWND hWnd);\r
79 static void CheckResizeFrame(WPARAM Keys, int x, int y);\r
80 static void DispDirInfo(void);\r
81 static void DeleteAlltempFile(void);\r
82 static BOOL CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);\r
83 static int EnterMasterPasswordAndSet( int Res, HWND hWnd );\r
84 \r
85 /*===== ローカルなワーク =====*/\r
86 \r
87 static const char FtpClassStr[] = "FFFTPWin";\r
88 \r
89 static HINSTANCE hInstFtp;\r
90 static HWND hWndFtp = NULL;\r
91 static HWND hWndCurFocus = NULL;\r
92 \r
93 static HACCEL Accel;\r
94 static HBRUSH RootColorBrush = NULL;\r
95 \r
96 static int Resizing = RESIZE_OFF;\r
97 static int ResizePos;\r
98 static HCURSOR hCursor;\r
99 \r
100 int ClientWidth;\r
101 static int ClientHeight;\r
102 int SepaWidth;\r
103 int RemoteWidth;\r
104 int ListHeight;\r
105 \r
106 static TEMPFILELIST *TempFiles = NULL;\r
107 \r
108 static int SaveExit = YES;\r
109 static int AutoExit = NO;\r
110 \r
111 static char HelpPath[FMAX_PATH+1];\r
112 static char IniPath[FMAX_PATH+1];\r
113 static int ForceIni = NO;\r
114 \r
115 TRANSPACKET MainTransPkt;               /* ファイル転送用パケット */\r
116                                                                 /* これを使って転送を行うと、ツールバーの転送 */\r
117                                                                 /* 中止ボタンで中止できる */\r
118 \r
119 char TitleHostName[HOST_ADRS_LEN+1];\r
120 char FilterStr[FILTER_EXT_LEN+1] = { "*" };\r
121 \r
122 int CancelFlg;\r
123 \r
124 static int SuppressRefresh = 0;\r
125 \r
126 static DWORD dwCookie;\r
127 \r
128 \r
129 /*===== グローバルなワーク =====*/\r
130 \r
131 HWND hHelpWin = NULL;\r
132 \r
133 /* 設定値 */\r
134 int WinPosX = CW_USEDEFAULT;\r
135 int WinPosY = 0;\r
136 int WinWidth = 630;\r
137 int WinHeight = 393;\r
138 int LocalWidth = 309;\r
139 int TaskHeight = 50;\r
140 int LocalTabWidth[4] = { 120, 90, 60, 37 };\r
141 int RemoteTabWidth[6] = { 120, 90, 60, 37, 60, 60 };\r
142 char UserMailAdrs[USER_MAIL_LEN+1] = { "who@example.com" };\r
143 char ViewerName[VIEWERS][FMAX_PATH+1] = { { "notepad" }, { "" }, { "" } };\r
144 HFONT ListFont = NULL;\r
145 LOGFONT ListLogFont;\r
146 int LocalFileSort = SORT_NAME;\r
147 int LocalDirSort = SORT_NAME;\r
148 int RemoteFileSort = SORT_NAME;\r
149 int RemoteDirSort = SORT_NAME;\r
150 int TransMode = TYPE_X;\r
151 int ConnectOnStart = YES;\r
152 int DebugConsole = NO;\r
153 int SaveWinPos = NO;\r
154 char AsciiExt[ASCII_EXT_LEN+1] = { "*.txt\0*.html\0*.htm\0*.cgi\0*.pl\0" };\r
155 int RecvMode = TRANS_DLG;\r
156 int SendMode = TRANS_DLG;\r
157 int MoveMode = MOVE_DLG;\r
158 int ListType = LVS_REPORT;\r
159 // LISTのキャッシュを無効にする(リモートのディレクトリの表示が更新されないバグ対策)\r
160 //int CacheEntry = 10;\r
161 int CacheEntry = -10;\r
162 int CacheSave = NO;\r
163 char DefaultLocalPath[FMAX_PATH+1] = { "" };\r
164 int SaveTimeStamp = YES;\r
165 int FindMode = 0;\r
166 int DotFile = YES;\r
167 int DclickOpen = YES;\r
168 int ConnectAndSet = YES;\r
169 SOUNDFILE Sound[SOUND_TYPES] = { { NO, "" }, { NO, "" }, { NO, "" } };\r
170 int FnameCnv = FNAME_NOCNV;\r
171 int TimeOut = 90;\r
172 int RmEOF = NO;\r
173 int RegType = REGTYPE_REG;\r
174 char FwallHost[HOST_ADRS_LEN+1] = { "" };\r
175 char FwallUser[USER_NAME_LEN+1] = { "" };\r
176 char FwallPass[PASSWORD_LEN+1] = { "" };\r
177 int FwallPort = PORT_NOR;\r
178 int FwallType = 1;\r
179 int FwallDefault = NO;\r
180 int FwallSecurity = SECURITY_AUTO;\r
181 int FwallResolv = NO;\r
182 int FwallLower = NO;\r
183 int FwallDelimiter = '@';\r
184 int PasvDefault = NO;\r
185 char MirrorNoTrn[MIRROR_LEN+1] = { "*.bak\0" };\r
186 char MirrorNoDel[MIRROR_LEN+1] = { "" };\r
187 int MirrorFnameCnv = NO;\r
188 int SplitVertical = YES;\r
189 int RasClose = NO;\r
190 int RasCloseNotify = YES;\r
191 int FileHist = 5;\r
192 char DefAttrList[DEFATTRLIST_LEN+1] = { "" };\r
193 SIZE HostDlgSize = { -1, -1 };\r
194 SIZE BmarkDlgSize = { -1, -1 };\r
195 SIZE MirrorDlgSize = { -1, -1 };\r
196 int Sizing = SW_RESTORE;\r
197 int SortSave = NO;\r
198 char TmpPath[FMAX_PATH+1];\r
199 int QuickAnonymous = YES;\r
200 int PassToHist = YES;\r
201 int VaxSemicolon = NO;\r
202 int SendQuit = NO;\r
203 int NoRasControl = NO;\r
204 int SuppressSave = NO;\r
205 int DispIgnoreHide = NO;\r
206 int DispDrives = NO;\r
207 int MirUpDelNotify = YES; \r
208 int MirDownDelNotify = YES; \r
209 int FolderAttr = NO;\r
210 int FolderAttrNum = 777;\r
211 // 同時接続対応\r
212 int MaxThreadCount = 1;\r
213 \r
214 \r
215 \r
216 \r
217 /*----- メインルーチン --------------------------------------------------------\r
218 *\r
219 *       Parameter\r
220 *               HINSTANCE hInstance : このアプリケーションのこのインスタンスのハンドル\r
221 *               HINSTANCE hPrevInstance : このアプリケーションの直前のインスタンスのハンドル\r
222 *               LPSTR lpszCmdLine : アプリケーションが起動したときのコマンドラインをさすロングポインタ\r
223 *               int cmdShow : 最初に表示するウインドウの形式。\r
224 *\r
225 *       Return Value\r
226 *               int 最後のメッセージのwParam\r
227 *----------------------------------------------------------------------------*/\r
228 \r
229 int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int cmdShow)\r
230 {\r
231     MSG Msg;\r
232         int Ret;\r
233         BOOL Sts;\r
234 \r
235         // プロセス保護\r
236 #ifdef ENABLE_PROCESS_PROTECTION\r
237         DWORD ProtectLevel;\r
238         char* pCommand;\r
239         char Option[FMAX_PATH+1];\r
240         ProtectLevel = PROCESS_PROTECTION_NONE;\r
241         pCommand = lpszCmdLine;\r
242         while(pCommand = GetToken(pCommand, Option))\r
243         {\r
244                 if(strcmp(Option, "--protect") == 0)\r
245                 {\r
246                         ProtectLevel = PROCESS_PROTECTION_DEFAULT;\r
247                         break;\r
248                 }\r
249                 else if(strcmp(Option, "--protect-high") == 0)\r
250                 {\r
251                         ProtectLevel = PROCESS_PROTECTION_HIGH;\r
252                         break;\r
253                 }\r
254                 else if(strcmp(Option, "--protect-medium") == 0)\r
255                 {\r
256                         ProtectLevel = PROCESS_PROTECTION_MEDIUM;\r
257                         break;\r
258                 }\r
259                 else if(strcmp(Option, "--protect-low") == 0)\r
260                 {\r
261                         ProtectLevel = PROCESS_PROTECTION_LOW;\r
262                         break;\r
263                 }\r
264         }\r
265         if(ProtectLevel != PROCESS_PROTECTION_NONE)\r
266         {\r
267                 SetProcessProtectionLevel(ProtectLevel);\r
268                 if(!InitializeLoadLibraryHook())\r
269                 {\r
270                         MessageBox(NULL, MSGJPN321, "FFFTP", MB_OK | MB_ICONERROR);\r
271                         return 0;\r
272                 }\r
273 #ifndef _DEBUG\r
274                 if(IsDebuggerPresent())\r
275                 {\r
276                         MessageBox(NULL, MSGJPN322, "FFFTP", MB_OK | MB_ICONERROR);\r
277                         return 0;\r
278                 }\r
279 #endif\r
280                 if(!UnloadUntrustedModule())\r
281                 {\r
282                         MessageBox(NULL, MSGJPN323, "FFFTP", MB_OK | MB_ICONERROR);\r
283                         return 0;\r
284                 }\r
285 #ifndef _DEBUG\r
286                 if(RestartProtectedProcess(" --restart"))\r
287                         return 0;\r
288 #endif\r
289                 if(!EnableLoadLibraryHook(TRUE))\r
290                 {\r
291                         MessageBox(NULL, MSGJPN324, "FFFTP", MB_OK | MB_ICONERROR);\r
292                         return 0;\r
293                 }\r
294         }\r
295         else\r
296                 InitializeLoadLibraryHook();\r
297 #endif\r
298 \r
299 #ifdef DISABLE_MULTI_CPUS\r
300         SetProcessAffinityMask(GetCurrentProcess(), 1);\r
301 #endif\r
302 \r
303         // yutaka\r
304         if(OleInitialize(NULL) != S_OK){\r
305                 MessageBox(NULL, MSGJPN298, "FFFTP", MB_OK | MB_ICONERROR);\r
306                 return 0;\r
307         }\r
308 \r
309         InitCommonControls();\r
310 \r
311         // FTPS対応\r
312 #ifdef USE_OPENSSL\r
313         LoadOpenSSL();\r
314 #endif\r
315 \r
316         Ret = FALSE;\r
317         hWndFtp = NULL;\r
318         hInstFtp = hInstance;\r
319         if(InitApp(lpszCmdLine, cmdShow) == FFFTP_SUCCESS)\r
320         {\r
321                 for(;;)\r
322                 {\r
323                         Sts = GetMessage(&Msg, NULL, 0, 0);\r
324                         if((Sts == 0) || (Sts == -1))\r
325                                 break;\r
326 \r
327                         if(!HtmlHelp(NULL, NULL, HH_PRETRANSLATEMESSAGE, (DWORD)&Msg))\r
328                         { \r
329                                 /* ディレクトリ名の表示コンボボックスでBSやRETが効くように */\r
330                                 /* コンボボックス内ではアクセラレータを無効にする */\r
331                                 if((Msg.hwnd == GetLocalHistEditHwnd()) ||\r
332                                    (Msg.hwnd == GetRemoteHistEditHwnd()) ||\r
333                                    ((hHelpWin != NULL) && (GetAncestor(Msg.hwnd, GA_ROOT) == hHelpWin)) ||\r
334                                    GetHideUI() == YES ||\r
335                                    (TranslateAccelerator(hWndFtp, Accel, &Msg) == 0))\r
336                                 {\r
337                                         TranslateMessage(&Msg);\r
338                                         DispatchMessage(&Msg);\r
339                                 }\r
340                         }\r
341                 }\r
342                 Ret = Msg.wParam;\r
343         }\r
344     UnregisterClass(FtpClassStr, hInstFtp);\r
345         // FTPS対応\r
346 #ifdef USE_OPENSSL\r
347         FreeOpenSSL();\r
348 #endif\r
349         OleUninitialize();\r
350         return(Ret);\r
351 }\r
352 \r
353 \r
354 /*----- アプリケーションの初期設定 --------------------------------------------\r
355 *\r
356 *       Parameter\r
357 *               HINSTANCE hInstance : このアプリケーションのこのインスタンスのハンドル\r
358 *               HINSTANCE hPrevInstance : このアプリケーションの直前のインスタンスのハンドル\r
359 *               LPSTR lpszCmdLine : アプリケーションが起動したときのコマンドラインをさすロングポインタ\r
360 *               int cmdShow : 最初に表示するウインドウの形式。\r
361 *\r
362 *       Return Value\r
363 *               int ステータス\r
364 *                       FFFTP_SUCCESS/FFFTP_FAIL\r
365 *----------------------------------------------------------------------------*/\r
366 \r
367 static int InitApp(LPSTR lpszCmdLine, int cmdShow)\r
368 {\r
369         int sts;\r
370         int Err;\r
371         WSADATA WSAData;\r
372         char PwdBuf[FMAX_PATH+1];\r
373         int useDefautPassword = 0; /* 警告文表示用 */\r
374         int masterpass;\r
375 \r
376         sts = FFFTP_FAIL;\r
377 \r
378         aes_init();\r
379         srand(GetTickCount());\r
380         \r
381         HtmlHelp(NULL, NULL, HH_INITIALIZE, (DWORD)&dwCookie);\r
382 \r
383         SaveUpdateBellInfo();\r
384 \r
385         if((Err = WSAStartup((WORD)0x0202, &WSAData)) != 0)\r
386                 MessageBox(NULL, ReturnWSError(Err), "FFFTP - Startup", MB_OK);\r
387         else\r
388         {\r
389                 Accel = LoadAccelerators(hInstFtp, MAKEINTRESOURCE(ffftp_accel));\r
390 \r
391                 GetTempPath(FMAX_PATH, TmpPath);\r
392 \r
393                 GetModuleFileName(NULL, HelpPath, FMAX_PATH);\r
394                 strcpy(GetFileName(HelpPath), "ffftp.chm");\r
395 \r
396                 if(CheckIniFileName(lpszCmdLine, IniPath) == 0)\r
397                 {\r
398                         GetModuleFileName(NULL, IniPath, FMAX_PATH);\r
399                         strcpy(GetFileName(IniPath), "ffftp.ini");\r
400                 }\r
401                 else\r
402                 {\r
403                         ForceIni = YES;\r
404                         RegType = REGTYPE_INI;\r
405                 }\r
406 \r
407 //              AllocConsole();\r
408 \r
409                 /* 2010.02.01 genta マスターパスワードを入力させる\r
410                   -z オプションがあるときは最初だけスキップ\r
411                   -z オプションがないときは,デフォルトパスワードをまず試す\r
412                   LoadRegistory()する\r
413                   パスワードが不一致なら再入力するか尋ねる.\r
414                   (破損していた場合はさせない)\r
415                 */\r
416                 if( CheckMasterPassword(lpszCmdLine, PwdBuf))\r
417                 {\r
418                         SetMasterPassword( PwdBuf );\r
419                         useDefautPassword = 0;\r
420                 }\r
421                 else {\r
422                         /* パスワード指定無し */\r
423                         SetMasterPassword( NULL );\r
424                         /* この場では表示できないのでフラグだけ立てておく*/\r
425                         useDefautPassword = 2;\r
426                 }\r
427 \r
428                 /* パスワードチェックのみ実施 */\r
429                 masterpass = 1;\r
430                 while( ValidateMasterPassword() == YES &&\r
431                                 GetMasterPasswordStatus() == PASSWORD_UNMATCH ){\r
432                         \r
433                         if( useDefautPassword != 2 ){\r
434                                 /* 再トライするか確認 */\r
435                                 if( MessageBox(NULL, MSGJPN304, "FFFTP", MB_YESNO | MB_ICONEXCLAMATION) == IDNO ){\r
436                                         useDefautPassword = 0; /* 不一致なので,もはやデフォルトかどうかは分からない */\r
437                                         break;\r
438                                 }\r
439                         }\r
440                         \r
441                         /* 再入力させる*/\r
442                         masterpass = EnterMasterPasswordAndSet(masterpasswd_dlg, NULL);\r
443                         if( masterpass == 2 ){\r
444                                 useDefautPassword = 1;\r
445                         }\r
446                         else if( masterpass == 0 ){\r
447                                 SaveExit = NO;\r
448                                 break;\r
449                         }\r
450                         else {\r
451                                 useDefautPassword = 0;\r
452                         }\r
453                 }\r
454                 \r
455                 if(masterpass != 0)\r
456                 {\r
457                         LoadRegistory();\r
458 \r
459                         // 暗号化通信対応\r
460                         SetSSLTimeoutCallback(TimeOut * 1000, SSLTimeoutCallback);\r
461                         SetSSLConfirmCallback(SSLConfirmCallback);\r
462 \r
463                         LoadJre();\r
464                         if(NoRasControl == NO)\r
465                                 LoadRasLib();\r
466                         LoadKernelLib();\r
467 \r
468                         //タイマの精度を改善\r
469                         timeBeginPeriod(1);\r
470 \r
471                         CountPrevFfftpWindows();\r
472 \r
473                         if(MakeAllWindows(cmdShow) == FFFTP_SUCCESS)\r
474                         {\r
475                                 hWndCurFocus = GetLocalHwnd();\r
476 \r
477                                 if(strlen(DefaultLocalPath) > 0)\r
478                                         SetCurrentDirectory(DefaultLocalPath);\r
479 \r
480                                 SetSortTypeImm(LocalFileSort, LocalDirSort, RemoteFileSort, RemoteDirSort);\r
481                                 SetTransferTypeImm(TransMode);\r
482                                 DispTransferType();\r
483                                 SetHostKanaCnvImm(YES);\r
484                                 SetHostKanjiCodeImm(KANJI_NOCNV);\r
485                                 // 本当はローカルのデフォルトをUTF-8にしたいが旧バージョンとの互換性のためShift_JISに設定\r
486 //                              SetLocalKanjiCodeImm(KANJI_UTF8N);\r
487                                 SetLocalKanjiCodeImm(KANJI_SJIS);\r
488                                 DispListType();\r
489                                 DispDotFileMode();\r
490                                 DispSyncMoveMode();\r
491 \r
492                                 MakeCacheBuf(CacheEntry);\r
493                                 if(CacheSave == YES)\r
494                                         LoadCache();\r
495 \r
496                                 if(MakeTransferThread() == FFFTP_SUCCESS)\r
497                                 {\r
498                                         DoPrintf("DEBUG MESSAGE ON ! ##");\r
499 \r
500                                         DispWindowTitle();\r
501                                         // SourceForge.JPによるフォーク\r
502 //                                      SetTaskMsg("FFFTP Ver." VER_STR " Copyright(C) 1997-2010 Sota & cooperators.");\r
503                                         SetTaskMsg("FFFTP Ver." VER_STR " Copyright(C) 1997-2010 Sota & cooperators.\r\nCopyright (C) 2011 FFFTP Project (Hiromichi Matsushima, Suguru Kawamoto, IWAMOTO Kouichi, vitamin0x, unarist, raido).");\r
504 \r
505                                         if(ForceIni)\r
506                                                 SetTaskMsg("%s%s", MSGJPN283, IniPath);\r
507 \r
508                                         if(IsFolderExist(TmpPath) == NO)\r
509                                         {\r
510                                                 SetTaskMsg(MSGJPN152, TmpPath);\r
511                                                 GetTempPath(FMAX_PATH, TmpPath);\r
512                                                 SetTaskMsg(MSGJPN153, TmpPath);\r
513                                         }\r
514 \r
515                                         DoPrintf("Tmp =%s", TmpPath);\r
516                                         DoPrintf("Help=%s", HelpPath);\r
517 \r
518                                         DragAcceptFiles(GetRemoteHwnd(), TRUE);\r
519                                         DragAcceptFiles(GetLocalHwnd(), TRUE);\r
520 \r
521                                         SetAllHistoryToMenu();\r
522                                         GetLocalDirForWnd();\r
523                                         MakeButtonsFocus();\r
524                                         DispTransferFiles();\r
525 \r
526                                         StartupProc(lpszCmdLine);\r
527                                         sts = FFFTP_SUCCESS;\r
528 \r
529                                         /* セキュリティ警告文の表示 */\r
530                                         if( useDefautPassword ){\r
531                                                 SetTaskMsg(MSGJPN300);\r
532                                         }\r
533                                         \r
534                                         /* パスワード不一致警告文の表示 */\r
535                                         switch( GetMasterPasswordStatus() ){\r
536                                         case PASSWORD_UNMATCH:\r
537                                                 SetTaskMsg(MSGJPN301);\r
538                                                 break;\r
539                                         case BAD_PASSWORD_HASH:\r
540                                                 SetTaskMsg(MSGJPN302);\r
541                                                 break;\r
542                                         default:\r
543                                                 break;\r
544                                         }\r
545                                 }\r
546                         }\r
547                 }\r
548         }\r
549 \r
550         // 暗号化通信対応\r
551 #ifdef USE_OPENSSL\r
552         if(IsOpenSSLLoaded())\r
553                 SetTaskMsg(MSGJPN318);\r
554         else\r
555                 SetTaskMsg(MSGJPN319);\r
556 #endif\r
557 \r
558         if(sts == FFFTP_FAIL)\r
559                 DeleteAllObject();\r
560 \r
561         return(sts);\r
562 }\r
563 \r
564 \r
565 /*----- ウインドウを作成する --------------------------------------------------\r
566 *\r
567 *       Parameter\r
568 *               int cmdShow : 最初に表示するウインドウの形式。\r
569 *\r
570 *       Return Value\r
571 *               int ステータス\r
572 *                       FFFTP_SUCCESS/FFFTP_FAIL\r
573 *----------------------------------------------------------------------------*/\r
574 \r
575 static int MakeAllWindows(int cmdShow)\r
576 {\r
577         RECT Rect1;\r
578         RECT Rect2;\r
579         WNDCLASSEX wClass;\r
580         int Sts;\r
581         int StsTask;\r
582         int StsSbar;\r
583         int StsTbar;\r
584         int StsList;\r
585         int StsLvtips;\r
586         int StsSocket;\r
587 \r
588         /*===== メインウインドウ =====*/\r
589 \r
590         RootColorBrush = CreateSolidBrush(GetSysColor(COLOR_3DFACE));\r
591 \r
592         wClass.cbSize = sizeof(WNDCLASSEX);\r
593         wClass.style         = 0;\r
594         wClass.lpfnWndProc   = FtpWndProc;\r
595         wClass.cbClsExtra    = 0;\r
596         wClass.cbWndExtra    = 0;\r
597         wClass.hInstance     = hInstFtp;\r
598         wClass.hIcon         = LoadIcon(hInstFtp, MAKEINTRESOURCE(ffftp));\r
599         wClass.hCursor       = NULL;\r
600         wClass.hbrBackground = RootColorBrush;\r
601         wClass.lpszMenuName  = (LPSTR)MAKEINTRESOURCE(main_menu);\r
602         wClass.lpszClassName = FtpClassStr;\r
603         wClass.hIconSm       = NULL;\r
604         RegisterClassEx(&wClass);\r
605 \r
606         if(SaveWinPos == NO)\r
607         {\r
608                 WinPosX = CW_USEDEFAULT;\r
609                 WinPosY = 0;\r
610         }\r
611         // UTF-8対応\r
612         // ユーザー定義のクラスはデフォルトのWNDPROCがShift_JIS専用のため\r
613 //      hWndFtp = CreateWindow(FtpClassStr, "FFFTP",\r
614 //                              WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,\r
615 //                              WinPosX, WinPosY, WinWidth, WinHeight,\r
616 //                              HWND_DESKTOP, 0, hInstFtp, NULL);\r
617         hWndFtp = CreateWindowA(FtpClassStr, "FFFTP",\r
618                                 WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,\r
619                                 WinPosX, WinPosY, WinWidth, WinHeight,\r
620                                 HWND_DESKTOP, 0, hInstFtp, NULL);\r
621 \r
622         if(hWndFtp != NULL)\r
623         {\r
624                 SystemParametersInfo(SPI_GETWORKAREA, 0, &Rect1, 0);\r
625                 GetWindowRect(hWndFtp, &Rect2);\r
626                 if(Rect2.bottom > Rect1.bottom)\r
627                 {\r
628                         Rect2.top = max1(0, Rect2.top - (Rect2.bottom - Rect1.bottom));\r
629                         MoveWindow(hWndFtp, Rect2.left, Rect2.top, WinWidth, WinHeight, FALSE);\r
630                 }\r
631 \r
632                 /*===== ステイタスバー =====*/\r
633 \r
634                 StsSbar = MakeStatusBarWindow(hWndFtp, hInstFtp);\r
635 \r
636                 CalcWinSize();\r
637 \r
638                 /*===== ツールバー =====*/\r
639 \r
640                 StsTbar = MakeToolBarWindow(hWndFtp, hInstFtp);\r
641 \r
642                 /*===== ファイルリストウインドウ =====*/\r
643 \r
644                 StsList = MakeListWin(hWndFtp, hInstFtp);\r
645 \r
646                 /*==== タスクウインドウ ====*/\r
647 \r
648                 StsTask = MakeTaskWindow(hWndFtp, hInstFtp);\r
649 \r
650                 if((cmdShow != SW_MINIMIZE) && (cmdShow != SW_SHOWMINIMIZED) && (cmdShow != SW_SHOWMINNOACTIVE) &&\r
651                    (Sizing == SW_MAXIMIZE))\r
652                         cmdShow = SW_MAXIMIZE;\r
653 \r
654                 ShowWindow(hWndFtp, cmdShow);\r
655 \r
656                 /*==== ソケットウインドウ ====*/\r
657 \r
658                 StsSocket = MakeSocketWin(hWndFtp, hInstFtp);\r
659 \r
660                 StsLvtips = InitListViewTips(hWndFtp, hInstFtp);\r
661         }\r
662 \r
663         Sts = FFFTP_SUCCESS;\r
664         if((hWndFtp == NULL) ||\r
665            (StsTbar == FFFTP_FAIL) ||\r
666            (StsList == FFFTP_FAIL) ||\r
667            (StsSbar == FFFTP_FAIL) ||\r
668            (StsTask == FFFTP_FAIL) ||\r
669            (StsLvtips == FFFTP_FAIL) ||\r
670            (StsSocket == FFFTP_FAIL))\r
671         {\r
672                 Sts = FFFTP_FAIL;\r
673         }\r
674 \r
675         if(Sts == FFFTP_SUCCESS)\r
676                 SetListViewType();\r
677 \r
678         return(Sts);\r
679 }\r
680 \r
681 \r
682 /*----- ウインドウのタイトルを表示する ----------------------------------------\r
683 *\r
684 *       Parameter\r
685 *               なし\r
686 *\r
687 *       Return Value\r
688 *               なし\r
689 *----------------------------------------------------------------------------*/\r
690 \r
691 void DispWindowTitle(void)\r
692 {\r
693         char Tmp[HOST_ADRS_LEN+FILTER_EXT_LEN+20];\r
694 \r
695         if(AskConnecting() == YES)\r
696                 sprintf(Tmp, "%s (%s) - FFFTP", TitleHostName, FilterStr);\r
697         else\r
698                 sprintf(Tmp, "FFFTP (%s)", FilterStr);\r
699 \r
700         SetWindowText(GetMainHwnd(), Tmp);\r
701         return;\r
702 }\r
703 \r
704 \r
705 /*----- 全てのオブジェクトを削除 ----------------------------------------------\r
706 *\r
707 *       Parameter\r
708 *               なし\r
709 *\r
710 *       Return Value\r
711 *               なし\r
712 *----------------------------------------------------------------------------*/\r
713 \r
714 static void DeleteAllObject(void)\r
715 {\r
716         DeleteCacheBuf();\r
717 \r
718 //move to WM_DESTROY\r
719         WSACleanup();\r
720 \r
721 //test システム任せ\r
722 //      if(ListFont != NULL)\r
723 //              DeleteObject(ListFont);\r
724 //      if(RootColorBrush != NULL)\r
725 //              DeleteObject(RootColorBrush);\r
726 \r
727 //test システム任せ\r
728 //      DeleteListViewTips();\r
729 //      DeleteListWin();\r
730 //      DeleteStatusBarWindow();\r
731 //      DeleteTaskWindow();\r
732 //      DeleteToolBarWindow();\r
733 //      DeleteSocketWin();\r
734 \r
735 //move to WM_DESTROY\r
736         if(hWndFtp != NULL)\r
737                 DestroyWindow(hWndFtp);\r
738 \r
739         ReleaseJre();\r
740         ReleaseRasLib();\r
741         ReleaseKernelLib();\r
742 \r
743         return;\r
744 }\r
745 \r
746 \r
747 /*----- メインウインドウのウインドウハンドルを返す ----------------------------\r
748 *\r
749 *       Parameter\r
750 *               なし\r
751 *\r
752 *       Return Value\r
753 *               HWND ウインドウハンドル\r
754 *----------------------------------------------------------------------------*/\r
755 \r
756 HWND GetMainHwnd(void)\r
757 {\r
758         return(hWndFtp);\r
759 }\r
760 \r
761 \r
762 /*----- 現在フォーカスがあるウインドウのウインドウハンドルを返す --------------\r
763 *\r
764 *       Parameter\r
765 *               なし\r
766 *\r
767 *       Return Value\r
768 *               HWND ウインドウハンドル\r
769 *----------------------------------------------------------------------------*/\r
770 \r
771 HWND GetFocusHwnd(void)\r
772 {\r
773         return(hWndCurFocus);\r
774 }\r
775 \r
776 \r
777 /*----- 現在フォーカスがあるウインドウのをセットする --------------------------\r
778 *\r
779 *       Parameter\r
780 *               HWND hWnd : ウインドウハンドル\r
781 *\r
782 *       Return Value\r
783 *               なし\r
784 *----------------------------------------------------------------------------*/\r
785 \r
786 void SetFocusHwnd(HWND hWnd)\r
787 {\r
788         hWndCurFocus = hWnd;\r
789         return;\r
790 }\r
791 \r
792 \r
793 /*----- プログラムのインスタンスを返す ----------------------------------------\r
794 *\r
795 *       Parameter\r
796 *               なし\r
797 *\r
798 *       Return Value\r
799 *               HINSTANCE インスタンス\r
800 *----------------------------------------------------------------------------*/\r
801 \r
802 HINSTANCE GetFtpInst(void)\r
803 {\r
804         return(hInstFtp);\r
805 }\r
806 \r
807 \r
808 /*----- メインウインドウのメッセージ処理 --------------------------------------\r
809 *\r
810 *       Parameter\r
811 *               HWND hWnd : ウインドウハンドル\r
812 *               UINT message  : メッセージ番号\r
813 *               WPARAM wParam : メッセージの WPARAM 引数\r
814 *               LPARAM lParam : メッセージの LPARAM 引数\r
815 *\r
816 *       Return Value\r
817 *               メッセージに対応する戻り値\r
818 *----------------------------------------------------------------------------*/\r
819 \r
820 static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)\r
821 {\r
822         PAINTSTRUCT ps;\r
823         LPTOOLTIPTEXT lpttt;\r
824         RECT Rect;\r
825 \r
826         int TmpTransType;\r
827 \r
828         switch (message)\r
829         {\r
830                 case WM_COMMAND :\r
831                         switch(LOWORD(wParam))\r
832                         {\r
833                                 case MENU_CONNECT :\r
834                                         ConnectProc(DLG_TYPE_CON, -1);\r
835                                         break;\r
836 \r
837                                 case MENU_CONNECT_NUM :\r
838                                         ConnectProc(DLG_TYPE_CON, (int)lParam);\r
839                                         if(AskConnecting() == YES)\r
840                                         {\r
841                                                 if(HIWORD(wParam) & OPT_MIRROR)\r
842                                                 {\r
843                                                         if(HIWORD(wParam) & OPT_FORCE)\r
844                                                                 MirrorUploadProc(NO);\r
845                                                         else\r
846                                                                 MirrorUploadProc(YES);\r
847                                                 }\r
848                                                 else if(HIWORD(wParam) & OPT_MIRRORDOWN)\r
849                                                 {\r
850                                                         if(HIWORD(wParam) & OPT_FORCE)\r
851                                                                 MirrorDownloadProc(NO);\r
852                                                         else\r
853                                                                 MirrorDownloadProc(YES);\r
854                                                 }\r
855                                         }\r
856                                         break;\r
857 \r
858                                 case MENU_SET_CONNECT :\r
859                                         ConnectProc(DLG_TYPE_SET, -1);\r
860                                         break;\r
861 \r
862                                 case MENU_QUICK :\r
863                                         QuickConnectProc();\r
864                                         break;\r
865 \r
866                                 case MENU_DISCONNECT :\r
867                                         if(AskTryingConnect() == YES)\r
868                                                 CancelFlg = YES;\r
869                                         else if(AskConnecting() == YES)\r
870                                         {\r
871                                                 SaveBookMark();\r
872                                                 SaveCurrentSetToHost();\r
873                                                 DisconnectProc();\r
874                                         }\r
875                                         break;\r
876 \r
877                                 case MENU_HIST_1 :\r
878                                 case MENU_HIST_2 :\r
879                                 case MENU_HIST_3 :\r
880                                 case MENU_HIST_4 :\r
881                                 case MENU_HIST_5 :\r
882                                 case MENU_HIST_6 :\r
883                                 case MENU_HIST_7 :\r
884                                 case MENU_HIST_8 :\r
885                                 case MENU_HIST_9 :\r
886                                 case MENU_HIST_10 :\r
887                                 case MENU_HIST_11 :\r
888                                 case MENU_HIST_12 :\r
889                                 case MENU_HIST_13 :\r
890                                 case MENU_HIST_14 :\r
891                                 case MENU_HIST_15 :\r
892                                 case MENU_HIST_16 :\r
893                                 case MENU_HIST_17 :\r
894                                 case MENU_HIST_18 :\r
895                                 case MENU_HIST_19 :\r
896                                 case MENU_HIST_20 :\r
897                                         HistoryConnectProc(LOWORD(wParam));\r
898                                         break;\r
899 \r
900                                 case MENU_UPDIR :\r
901                                         if(hWndCurFocus == GetLocalHwnd())\r
902                                                 PostMessage(hWnd, WM_COMMAND, MAKEWPARAM(MENU_LOCAL_UPDIR, 0), 0);\r
903                                         else\r
904                                                 PostMessage(hWnd, WM_COMMAND, MAKEWPARAM(MENU_REMOTE_UPDIR, 0), 0);\r
905                                         break;\r
906 \r
907                                 case MENU_DCLICK :\r
908                                         if(hWndCurFocus == GetLocalHwnd())\r
909                                                 DoubleClickProc(WIN_LOCAL, YES, -1);\r
910                                         else\r
911                                         {\r
912                                                 SuppressRefresh = 1;\r
913                                                 DoubleClickProc(WIN_REMOTE, YES, -1);\r
914                                                 SuppressRefresh = 0;\r
915                                         }\r
916                                         break;\r
917 \r
918                                 case MENU_OPEN1 :\r
919                                         if(hWndCurFocus == GetLocalHwnd())\r
920                                                 DoubleClickProc(WIN_LOCAL, YES, 0);\r
921                                         else\r
922                                         {\r
923                                                 SuppressRefresh = 1;\r
924                                                 DoubleClickProc(WIN_REMOTE, YES, 0);\r
925                                                 SuppressRefresh = 0;\r
926                                         }\r
927                                         break;\r
928 \r
929                                 case MENU_OPEN2 :\r
930                                         if(hWndCurFocus == GetLocalHwnd())\r
931                                                 DoubleClickProc(WIN_LOCAL, YES, 1);\r
932                                         else\r
933                                         {\r
934                                                 SuppressRefresh = 1;\r
935                                                 DoubleClickProc(WIN_REMOTE, YES, 1);\r
936                                                 SuppressRefresh = 0;\r
937                                         }\r
938                                         break;\r
939 \r
940                                 case MENU_OPEN3 :\r
941                                         if(hWndCurFocus == GetLocalHwnd())\r
942                                                 DoubleClickProc(WIN_LOCAL, YES, 2);\r
943                                         else\r
944                                         {\r
945                                                 SuppressRefresh = 1;\r
946                                                 DoubleClickProc(WIN_REMOTE, YES, 2);\r
947                                                 SuppressRefresh = 0;\r
948                                         }\r
949                                         break;\r
950 \r
951                                 case MENU_REMOTE_UPDIR :\r
952                                         SuppressRefresh = 1;\r
953                                         SetCurrentDirAsDirHist();\r
954                                         ChangeDir(WIN_REMOTE, "..");\r
955                                         SuppressRefresh = 0;\r
956                                         break;\r
957 \r
958                                 case MENU_LOCAL_UPDIR :\r
959                                         SetCurrentDirAsDirHist();\r
960                                         ChangeDir(WIN_LOCAL, "..");\r
961                                         break;\r
962 \r
963                                 case MENU_REMOTE_CHDIR :\r
964                                         SuppressRefresh = 1;\r
965                                         SetCurrentDirAsDirHist();\r
966                                         ChangeDirDirectProc(WIN_REMOTE);\r
967                                         SuppressRefresh = 0;\r
968                                         break;\r
969 \r
970                                 case MENU_LOCAL_CHDIR :\r
971                                         SetCurrentDirAsDirHist();\r
972                                         ChangeDirDirectProc(WIN_LOCAL);\r
973                                         break;\r
974 \r
975                                 case MENU_DOWNLOAD :\r
976                                         SetCurrentDirAsDirHist();\r
977                                         DownLoadProc(NO, NO, NO);\r
978                                         break;\r
979 \r
980                                 case MENU_DOWNLOAD_AS :\r
981                                         SetCurrentDirAsDirHist();\r
982                                         DownLoadProc(YES, NO, NO);\r
983                                         break;\r
984 \r
985                                 case MENU_DOWNLOAD_AS_FILE :\r
986                                         SetCurrentDirAsDirHist();\r
987                                         DownLoadProc(NO, YES, NO);\r
988                                         break;\r
989 \r
990                                 case MENU_DOWNLOAD_ALL :\r
991                                         SetCurrentDirAsDirHist();\r
992                                         DownLoadProc(NO, NO, YES);\r
993                                         break;\r
994 \r
995                                 case MENU_DOWNLOAD_NAME :\r
996                                         SetCurrentDirAsDirHist();\r
997                                         InputDownLoadProc();\r
998                                         break;\r
999 \r
1000                                 case MENU_UPLOAD :\r
1001                                         SetCurrentDirAsDirHist();\r
1002                                         UpLoadListProc(NO, NO);\r
1003                                         break;\r
1004 \r
1005                                 case MENU_UPLOAD_AS :\r
1006                                         SetCurrentDirAsDirHist();\r
1007                                         UpLoadListProc(YES, NO);\r
1008                                         break;\r
1009 \r
1010                                 case MENU_UPLOAD_ALL :\r
1011                                         SetCurrentDirAsDirHist();\r
1012                                         UpLoadListProc(NO, YES);\r
1013                                         break;\r
1014 \r
1015                                 case MENU_MIRROR_UPLOAD :\r
1016                                         SetCurrentDirAsDirHist();\r
1017                                         MirrorUploadProc(YES);\r
1018                                         break;\r
1019 \r
1020                                 case MENU_MIRROR_DOWNLOAD :\r
1021                                         SetCurrentDirAsDirHist();\r
1022                                         MirrorDownloadProc(YES);\r
1023                                         break;\r
1024 \r
1025                                 case MENU_FILESIZE :\r
1026                                         SetCurrentDirAsDirHist();\r
1027                                         CalcFileSizeProc();\r
1028                                         break;\r
1029 \r
1030                                 case MENU_DELETE :\r
1031                                         SuppressRefresh = 1;\r
1032                                         SetCurrentDirAsDirHist();\r
1033                                         DeleteProc();\r
1034                                         SuppressRefresh = 0;\r
1035                                         break;\r
1036 \r
1037                                 case MENU_RENAME :\r
1038                                         SuppressRefresh = 1;\r
1039                                         SetCurrentDirAsDirHist();\r
1040                                         RenameProc();\r
1041                                         SuppressRefresh = 0;\r
1042                                         break;\r
1043 \r
1044                                 case MENU_MKDIR :\r
1045                                         SuppressRefresh = 1;\r
1046                                         SetCurrentDirAsDirHist();\r
1047                                         MkdirProc();\r
1048                                         SuppressRefresh = 0;\r
1049                                         break;\r
1050 \r
1051                                 case MENU_CHMOD :\r
1052                                         SuppressRefresh = 1;\r
1053                                         ChmodProc();\r
1054                                         SuppressRefresh = 0;\r
1055                                         break;\r
1056 \r
1057                                 case MENU_SOMECMD :\r
1058                                         SuppressRefresh = 1;\r
1059                                         SomeCmdProc();\r
1060                                         SuppressRefresh = 0;\r
1061                                         break;\r
1062 \r
1063                                 case MENU_OPTION :\r
1064                                         SetOption(0);\r
1065                                         if(ListFont != NULL)\r
1066                                         {\r
1067                                                 SendMessage(GetLocalHwnd(), WM_SETFONT, (WPARAM)ListFont, MAKELPARAM(TRUE, 0));\r
1068                                                 SendMessage(GetRemoteHwnd(), WM_SETFONT, (WPARAM)ListFont, MAKELPARAM(TRUE, 0));\r
1069                                                 SendMessage(GetTaskWnd(), WM_SETFONT, (WPARAM)ListFont, MAKELPARAM(TRUE, 0));\r
1070                                         }\r
1071                                         GetLocalDirForWnd();\r
1072                                         DispTransferType();\r
1073                                         CheckHistoryNum(0);\r
1074                                         SetAllHistoryToMenu();\r
1075                                         // 暗号化通信対応\r
1076                                         SetSSLTimeoutCallback(TimeOut * 1000, SSLTimeoutCallback);\r
1077                                         break;\r
1078 \r
1079                                 case MENU_FILTER :\r
1080                                         SetFilter(&CancelFlg);\r
1081                                         break;\r
1082 \r
1083                                 case MENU_SORT :\r
1084                                         if(SortSetting() == YES)\r
1085                                         {\r
1086                                                 LocalFileSort = AskSortType(ITEM_LFILE);\r
1087                                                 LocalDirSort = AskSortType(ITEM_LDIR);\r
1088                                                 RemoteFileSort = AskSortType(ITEM_RFILE);\r
1089                                                 RemoteDirSort = AskSortType(ITEM_RDIR);\r
1090                                                 ReSortDispList(WIN_LOCAL, &CancelFlg);\r
1091                                                 ReSortDispList(WIN_REMOTE, &CancelFlg);\r
1092                                         }\r
1093                                         break;\r
1094 \r
1095                                 case MENU_EXIT :\r
1096                                         PostMessage(hWnd, WM_CLOSE, 0, 0L);\r
1097                                         break;\r
1098 \r
1099                                 case MENU_AUTO_EXIT :\r
1100                                         if(AutoExit == YES)\r
1101                                                 PostMessage(hWnd, WM_CLOSE, 0, 0L);\r
1102                                         break;\r
1103 \r
1104                                 case MENU_ABOUT :\r
1105                                         DialogBox(hInstFtp, MAKEINTRESOURCE(about_dlg), hWnd, AboutDialogProc);\r
1106                                         break;\r
1107 \r
1108                                 case MENU_TEXT :\r
1109                                 case MENU_BINARY :\r
1110                                 case MENU_AUTO :\r
1111                                         SetTransferType(LOWORD(wParam));\r
1112                                         DispTransferType();\r
1113                                         break;\r
1114 \r
1115                                 case MENU_XFRMODE :\r
1116                                         switch(AskTransferType())\r
1117                                         {\r
1118                                                 case TYPE_A :\r
1119                                                         TmpTransType = MENU_BINARY;\r
1120                                                         break;\r
1121 \r
1122                                                 case TYPE_I :\r
1123                                                         TmpTransType = MENU_AUTO;\r
1124                                                         break;\r
1125 \r
1126                                                 default :\r
1127                                                         TmpTransType = MENU_TEXT;\r
1128                                                         break;\r
1129                                         }\r
1130                                         SetTransferType(TmpTransType);\r
1131                                         DispTransferType();\r
1132                                         break;\r
1133 \r
1134                                 // UTF-8対応\r
1135                                 case MENU_KNJ_SJIS :\r
1136                                 case MENU_KNJ_EUC :\r
1137                                 case MENU_KNJ_JIS :\r
1138                                 case MENU_KNJ_UTF8N :\r
1139                                 case MENU_KNJ_NONE :\r
1140                                         SetHostKanjiCode(LOWORD(wParam));\r
1141                                         break;\r
1142 \r
1143                                 case MENU_L_KNJ_SJIS :\r
1144                                 case MENU_L_KNJ_EUC :\r
1145                                 case MENU_L_KNJ_JIS :\r
1146                                 case MENU_L_KNJ_UTF8N :\r
1147                                         SetLocalKanjiCode(LOWORD(wParam));\r
1148                                         break;\r
1149 \r
1150                                 case MENU_KANACNV :\r
1151                                         SetHostKanaCnv();\r
1152                                         break;\r
1153 \r
1154                                 case MENU_REFRESH :\r
1155                                         SuppressRefresh = 1;\r
1156                                         GetLocalDirForWnd();\r
1157                                         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
1158                                                 GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
1159                                         SuppressRefresh = 0;\r
1160                                         break;\r
1161 \r
1162                                 case MENU_LIST :\r
1163                                         ListType = LVS_LIST;\r
1164                                         DispListType();\r
1165                                         SetListViewType();\r
1166                                         break;\r
1167 \r
1168                                 case MENU_REPORT :\r
1169                                         ListType = LVS_REPORT;\r
1170                                         DispListType();\r
1171                                         SetListViewType();\r
1172                                         break;\r
1173 \r
1174                                 case REFRESH_LOCAL :\r
1175                                         GetLocalDirForWnd();\r
1176                                         break;\r
1177 \r
1178                                 case REFRESH_REMOTE :\r
1179                                         SuppressRefresh = 1;\r
1180                                         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
1181                                                 GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
1182                                         SuppressRefresh = 0;\r
1183                                         break;\r
1184 \r
1185                                 case COMBO_LOCAL :\r
1186                                 case COMBO_REMOTE :\r
1187                                         SuppressRefresh = 1;\r
1188                                         if(HIWORD(wParam) == CBN_SELCHANGE)\r
1189                                         {\r
1190                                                 SetCurrentDirAsDirHist();\r
1191                                                 ChangeDirComboProc((HWND)lParam);\r
1192                                         }\r
1193                                         else if(HIWORD(wParam) != CBN_CLOSEUP)\r
1194                                         {\r
1195                                                 MakeButtonsFocus();\r
1196                                                 SuppressRefresh = 0;\r
1197                                                 return(0);\r
1198                                         }\r
1199                                         SuppressRefresh = 0;\r
1200                                         break;\r
1201 \r
1202                                 case MENU_HELP :\r
1203                                         hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000001);\r
1204                                         break;\r
1205 \r
1206                                 case MENU_HELP_TROUBLE :\r
1207                                         ShellExecute(NULL, "open", MYWEB_URL, NULL, ".", SW_SHOW);\r
1208                                         break;\r
1209 \r
1210                                 case MENU_BMARK_ADD :\r
1211                                         AddCurDirToBookMark(WIN_REMOTE);\r
1212                                         break;\r
1213 \r
1214                                 case MENU_BMARK_ADD_LOCAL :\r
1215                                         AddCurDirToBookMark(WIN_LOCAL);\r
1216                                         break;\r
1217 \r
1218                                 case MENU_BMARK_ADD_BOTH :\r
1219                                         AddCurDirToBookMark(WIN_BOTH);\r
1220                                         break;\r
1221 \r
1222                                 case MENU_BMARK_EDIT :\r
1223                                         EditBookMark();\r
1224                                         break;\r
1225 \r
1226                                 case MENU_SELECT_ALL :\r
1227                                         SelectFileInList(hWndCurFocus, SELECT_ALL);\r
1228                                         break;\r
1229 \r
1230                                 case MENU_SELECT :\r
1231                                         SelectFileInList(hWndCurFocus, SELECT_REGEXP);\r
1232                                         break;\r
1233 \r
1234                                 case MENU_FIND :\r
1235                                         FindFileInList(hWndCurFocus, FIND_FIRST);\r
1236                                         break;\r
1237 \r
1238                                 case MENU_FINDNEXT :\r
1239                                         FindFileInList(hWndCurFocus, FIND_NEXT);\r
1240                                         break;\r
1241 \r
1242                                 case MENU_DOTFILE :\r
1243                                         DotFile ^= 1;\r
1244                                         DispDotFileMode();\r
1245                                         GetLocalDirForWnd();\r
1246                                         GetRemoteDirForWnd(CACHE_LASTREAD, &CancelFlg);\r
1247                                         break;\r
1248 \r
1249                                 case MENU_SYNC :\r
1250                                         ToggleSyncMoveMode();\r
1251                                         break;\r
1252 \r
1253                                 case MENU_IMPORT_WS :\r
1254                                         ImportFromWSFTP();\r
1255                                         break;\r
1256 \r
1257                                 case MENU_REGSAVE :\r
1258                                         GetListTabWidth();\r
1259                                         SaveRegistory();\r
1260                                         SaveSettingsToFile();\r
1261                                         break;\r
1262 \r
1263                                 case MENU_REGLOAD :\r
1264                                         if(LoadSettingsFromFile() == YES)\r
1265                                         {\r
1266                                                 MessageBox(hWnd, MSGJPN292, "FFFTP", MB_OK);\r
1267                                                 SaveExit = NO;\r
1268                                                 PostMessage(hWnd, WM_CLOSE, 0, 0L);\r
1269                                         }\r
1270                                         break;\r
1271 \r
1272                                 case MENU_REGINIT :\r
1273                                         if(DialogBox(hInstFtp, MAKEINTRESOURCE(reginit_dlg), hWnd, ExeEscDialogProc) == YES)\r
1274                                         {\r
1275                                                 ClearRegistory();\r
1276                                                 SaveExit = NO;\r
1277                                                 PostMessage(hWnd, WM_CLOSE, 0, 0L);\r
1278                                         }\r
1279                                         break;\r
1280                                 case MENU_CHANGEPASSWD: /* 2010.01.31 genta */\r
1281                                         if( GetMasterPasswordStatus() != PASSWORD_OK )\r
1282                                         {\r
1283                                                 /* 強制的に設定するか確認 */\r
1284                                                 if( DialogBox(hInstFtp, MAKEINTRESOURCE(forcepasschange_dlg), hWnd, ExeEscDialogProc) != YES){\r
1285                                                         break;\r
1286                                                 }\r
1287                                         }\r
1288                                         if( EnterMasterPasswordAndSet( newmasterpasswd_dlg, hWnd ) != 0 ){\r
1289                                                 SetTaskMsg( MSGJPN303 );\r
1290                                         }\r
1291                                         break;\r
1292 \r
1293                                 case MENU_DIRINFO :\r
1294                                         DispDirInfo();\r
1295                                         break;\r
1296 \r
1297                                 case MENU_TASKINFO :\r
1298                                         DispTaskMsg();\r
1299                                         break;\r
1300 \r
1301                                 case MENU_ABORT :\r
1302                                         CancelFlg = YES;\r
1303                                         if(AskTryingConnect() == NO)\r
1304                                                 MainTransPkt.Abort = ABORT_USER;\r
1305                                         break;\r
1306 \r
1307                                 case MENU_OTPCALC :\r
1308                                         OtpCalcTool();\r
1309                                         break;\r
1310 \r
1311                                 case MENU_URL_COPY :\r
1312                                         CopyURLtoClipBoard();\r
1313                                         break;\r
1314 \r
1315                                 case MENU_APPKEY :\r
1316                                         EraseListViewTips();\r
1317                                         if(hWndCurFocus == GetRemoteHwnd())\r
1318                                                 RemoteRbuttonMenu(1);\r
1319                                         else if(hWndCurFocus == GetLocalHwnd())\r
1320                                                 LocalRbuttonMenu(1);\r
1321                                         break;\r
1322 \r
1323                                 default :\r
1324                                         if((LOWORD(wParam) >= MENU_BMARK_TOP) &&\r
1325                                            (LOWORD(wParam) < MENU_BMARK_TOP+100))\r
1326                                         {\r
1327                                                 ChangeDirBmarkProc(LOWORD(wParam));\r
1328                                         }\r
1329                                         break;\r
1330                         }\r
1331 // 常にホストかローカルへフォーカスを移動\r
1332 //                      SetFocus(hWndCurFocus);\r
1333                         MakeButtonsFocus();\r
1334                         break;\r
1335 \r
1336                 case WM_NOTIFY :\r
1337                         switch(((LPNMHDR)lParam)->code)\r
1338                         {\r
1339                                 /* ツールチップコントロールメッセージの処理 */\r
1340                                 case TTN_NEEDTEXT:\r
1341                                         lpttt = (LPTOOLTIPTEXT)lParam;\r
1342                                         lpttt->hinst = hInstFtp;\r
1343                                         switch(lpttt->hdr.idFrom)\r
1344                                         {\r
1345                                                 case MENU_CONNECT :\r
1346                                                         lpttt->lpszText = MSGJPN154;\r
1347                                                         break;\r
1348 \r
1349                                                 case MENU_QUICK :\r
1350                                                         lpttt->lpszText = MSGJPN155;\r
1351                                                         break;\r
1352 \r
1353                                                 case MENU_DISCONNECT :\r
1354                                                         lpttt->lpszText = MSGJPN156;\r
1355                                                         break;\r
1356 \r
1357                                                 case MENU_DOWNLOAD :\r
1358                                                         lpttt->lpszText = MSGJPN157;\r
1359                                                         break;\r
1360 \r
1361                                                 case MENU_UPLOAD :\r
1362                                                         lpttt->lpszText = MSGJPN158;\r
1363                                                         break;\r
1364 \r
1365                                                 case MENU_MIRROR_UPLOAD :\r
1366                                                         lpttt->lpszText = MSGJPN159;\r
1367                                                         break;\r
1368 \r
1369                                                 case MENU_DELETE :\r
1370                                                         lpttt->lpszText = MSGJPN160;\r
1371                                                         break;\r
1372 \r
1373                                                 case MENU_RENAME :\r
1374                                                         lpttt->lpszText = MSGJPN161;\r
1375                                                         break;\r
1376 \r
1377                                                 case MENU_MKDIR :\r
1378                                                         lpttt->lpszText = MSGJPN162;\r
1379                                                         break;\r
1380 \r
1381                                                 case MENU_LOCAL_UPDIR :\r
1382                                                 case MENU_REMOTE_UPDIR :\r
1383                                                         lpttt->lpszText = MSGJPN163;\r
1384                                                         break;\r
1385 \r
1386                                                 case MENU_LOCAL_CHDIR :\r
1387                                                 case MENU_REMOTE_CHDIR :\r
1388                                                         lpttt->lpszText = MSGJPN164;\r
1389                                                         break;\r
1390 \r
1391                                                 case MENU_TEXT :\r
1392                                                         lpttt->lpszText = MSGJPN165;\r
1393                                                         break;\r
1394 \r
1395                                                 case MENU_BINARY :\r
1396                                                         lpttt->lpszText = MSGJPN166;\r
1397                                                         break;\r
1398 \r
1399                                                 case MENU_AUTO :\r
1400                                                         lpttt->lpszText = MSGJPN167;\r
1401                                                         break;\r
1402 \r
1403                                                 case MENU_REFRESH :\r
1404                                                         lpttt->lpszText = MSGJPN168;\r
1405                                                         break;\r
1406 \r
1407                                                 case MENU_LIST :\r
1408                                                         lpttt->lpszText = MSGJPN169;\r
1409                                                         break;\r
1410 \r
1411                                                 case MENU_REPORT :\r
1412                                                         lpttt->lpszText = MSGJPN170;\r
1413                                                         break;\r
1414 \r
1415                                                 case MENU_KNJ_SJIS :\r
1416                                                         lpttt->lpszText = MSGJPN307;\r
1417                                                         break;\r
1418 \r
1419                                                 case MENU_KNJ_EUC :\r
1420                                                         lpttt->lpszText = MSGJPN171;\r
1421                                                         break;\r
1422 \r
1423                                                 case MENU_KNJ_JIS :\r
1424                                                         lpttt->lpszText = MSGJPN172;\r
1425                                                         break;\r
1426 \r
1427                                                 case MENU_KNJ_UTF8N :\r
1428                                                         lpttt->lpszText = MSGJPN308;\r
1429                                                         break;\r
1430 \r
1431                                                 case MENU_KNJ_NONE :\r
1432                                                         lpttt->lpszText = MSGJPN173;\r
1433                                                         break;\r
1434 \r
1435                                                 case MENU_L_KNJ_SJIS :\r
1436                                                         lpttt->lpszText = MSGJPN309;\r
1437                                                         break;\r
1438 \r
1439                                                 case MENU_L_KNJ_EUC :\r
1440                                                         lpttt->lpszText = MSGJPN310;\r
1441                                                         break;\r
1442 \r
1443                                                 case MENU_L_KNJ_JIS :\r
1444                                                         lpttt->lpszText = MSGJPN311;\r
1445                                                         break;\r
1446 \r
1447                                                 case MENU_L_KNJ_UTF8N :\r
1448                                                         lpttt->lpszText = MSGJPN312;\r
1449                                                         break;\r
1450 \r
1451                                                 case MENU_KANACNV :\r
1452                                                         lpttt->lpszText = MSGJPN174;\r
1453                                                         break;\r
1454 \r
1455                                                 case MENU_SYNC :\r
1456                                                         lpttt->lpszText = MSGJPN175;\r
1457                                                         break;\r
1458 \r
1459                                                 case MENU_ABORT :\r
1460                                                         lpttt->lpszText = MSGJPN176;\r
1461                                                         break;\r
1462                                         }\r
1463                                         // UTF-8からShift_JISへ変換\r
1464                                         {\r
1465                                                 static wchar_t StringBufferUTF16[1024];\r
1466                                                 static char StringBufferSJIS[1024];\r
1467                                                 if(lpttt->lpszText)\r
1468                                                 {\r
1469                                                         MtoW(StringBufferUTF16, sizeof(StringBufferUTF16)/ sizeof(wchar_t), lpttt->lpszText, -1);\r
1470                                                         WtoA(StringBufferSJIS, sizeof(StringBufferSJIS)/ sizeof(char), StringBufferUTF16, -1);\r
1471                                                         lpttt->lpszText = StringBufferSJIS;\r
1472                                                 }\r
1473                                         }\r
1474                                         break;\r
1475 \r
1476                                 case LVN_COLUMNCLICK :\r
1477                                         if(((NMHDR *)lParam)->hwndFrom == GetLocalHwnd())\r
1478                                         {\r
1479                                                 SetSortTypeByColumn(WIN_LOCAL, ((NM_LISTVIEW *)lParam)->iSubItem);\r
1480                                                 ReSortDispList(WIN_LOCAL, &CancelFlg);\r
1481                                         }\r
1482                                         else if(((NMHDR *)lParam)->hwndFrom == GetRemoteHwnd())\r
1483                                         {\r
1484                                                 if(((NM_LISTVIEW *)lParam)->iSubItem != 4)\r
1485                                                 {\r
1486                                                         SetSortTypeByColumn(WIN_REMOTE, ((NM_LISTVIEW *)lParam)->iSubItem);\r
1487                                                         ReSortDispList(WIN_REMOTE, &CancelFlg);\r
1488                                                 }\r
1489                                         }\r
1490                                         SetFocus(hWndCurFocus);\r
1491                                         break;\r
1492 \r
1493                                 case LVN_ITEMCHANGED :\r
1494                                         DispSelectedSpace();\r
1495                                         MakeButtonsFocus();\r
1496                                         break;\r
1497                         }\r
1498                         break;\r
1499 \r
1500                 case WM_SIZE :\r
1501                         Sizing = SW_RESTORE;\r
1502                         if(wParam == SIZE_RESTORED)\r
1503                         {\r
1504                                 ResizeWindowProc();\r
1505                                 GetWindowRect(hWnd, &Rect);\r
1506                                 WinPosX = Rect.left;\r
1507                                 WinPosY = Rect.top;\r
1508                         }\r
1509                         else if(wParam == SIZE_MAXIMIZED)\r
1510                         {\r
1511                                 Sizing = SW_MAXIMIZE;\r
1512                                 ResizeWindowProc();\r
1513                         }\r
1514                         else\r
1515                                 return(DefWindowProc(hWnd, message, wParam, lParam));\r
1516                         break;\r
1517 \r
1518                 case WM_MOVING :\r
1519                         WinPosX = ((RECT *)lParam)->left;\r
1520                         WinPosY = ((RECT *)lParam)->top;\r
1521                         return(DefWindowProc(hWnd, message, wParam, lParam));\r
1522 \r
1523                 case WM_SETFOCUS :\r
1524                         SetFocus(hWndCurFocus);\r
1525                         break;\r
1526 \r
1527                 case WM_LBUTTONDOWN :\r
1528                 case WM_LBUTTONUP :\r
1529                 case WM_MOUSEMOVE :\r
1530                         CheckResizeFrame(wParam, LOWORD(lParam), HIWORD(lParam));\r
1531                         break;\r
1532 \r
1533                 case WM_CHANGE_COND :\r
1534                         DispTransferFiles();\r
1535                         break;\r
1536 \r
1537                 case WM_REFRESH_LOCAL_FLG :\r
1538                         PostMessage(hWnd,  WM_COMMAND, MAKEWPARAM(REFRESH_LOCAL, 0), 0);\r
1539                         break;\r
1540 \r
1541                 case WM_REFRESH_REMOTE_FLG :\r
1542                         if(SuppressRefresh == 0)\r
1543                                 PostMessage(hWnd,  WM_COMMAND, MAKEWPARAM(REFRESH_REMOTE, 0), 0);\r
1544                         break;\r
1545 \r
1546                 case WM_PAINT :\r
1547                     BeginPaint(hWnd, (LPPAINTSTRUCT) &ps);\r
1548                     EndPaint(hWnd, (LPPAINTSTRUCT) &ps);\r
1549                         break;\r
1550 \r
1551                 case WM_DESTROY :\r
1552 //                      WSACleanup();\r
1553 //                      DestroyWindow(hWndFtp);\r
1554                         PostQuitMessage(0);\r
1555                         break;\r
1556 \r
1557                 case WM_QUERYENDSESSION :\r
1558                         ExitProc(hWnd);\r
1559                         return(TRUE);\r
1560 \r
1561                 case WM_CLOSE :\r
1562                         if((AskTransferNow() == NO) ||\r
1563                            (DialogBox(hInstFtp, MAKEINTRESOURCE(exit_dlg), hWnd, ExeEscDialogProc) == YES))\r
1564                         {\r
1565                                 ExitProc(hWnd);\r
1566                                 return(DefWindowProc(hWnd, message, wParam, lParam));\r
1567                         }\r
1568                         break;\r
1569 \r
1570                 default :\r
1571                         return(DefWindowProc(hWnd, message, wParam, lParam));\r
1572         }\r
1573     return(0L);\r
1574 }\r
1575 \r
1576 \r
1577 /*----- プログラム開始時の処理 ------------------------------------------------\r
1578 *\r
1579 *       Parameter\r
1580 *               char *Cmd : コマンドライン文字列\r
1581 *\r
1582 *       Return Value\r
1583 *               なし\r
1584 *----------------------------------------------------------------------------*/\r
1585 \r
1586 static void StartupProc(char *Cmd)\r
1587 {\r
1588         int Sts;\r
1589         int AutoConnect;\r
1590         int CmdOption;\r
1591         int Kanji;\r
1592         int Kana;\r
1593         int FnameKanji;\r
1594         int TrMode;\r
1595         char unc[FMAX_PATH+1];\r
1596 \r
1597         Sts = AnalyzeComLine(Cmd, &AutoConnect, &CmdOption, unc, FMAX_PATH);\r
1598 \r
1599         TrMode = TYPE_DEFAULT;\r
1600         Kanji = KANJI_NOCNV;\r
1601         FnameKanji = KANJI_NOCNV;\r
1602         Kana = YES;\r
1603         if(CmdOption & OPT_ASCII)\r
1604                 TrMode = TYPE_A;\r
1605         if(CmdOption & OPT_BINARY)\r
1606                 TrMode = TYPE_I;\r
1607         if(CmdOption & OPT_EUC)\r
1608                 Kanji = KANJI_EUC;\r
1609         if(CmdOption & OPT_JIS)\r
1610                 Kanji = KANJI_JIS;\r
1611         if(CmdOption & OPT_EUC_NAME)\r
1612                 FnameKanji = KANJI_EUC;\r
1613         if(CmdOption & OPT_JIS_NAME)\r
1614                 FnameKanji = KANJI_JIS;\r
1615         if(CmdOption & OPT_KANA)\r
1616                 Kana = NO;\r
1617 \r
1618         if(CmdOption & OPT_QUIT)\r
1619                 AutoExit = YES;\r
1620 \r
1621         if(CmdOption & OPT_SAVEOFF)\r
1622                 SuppressSave = YES;\r
1623         if(CmdOption & OPT_SAVEON)\r
1624                 SuppressSave = NO;\r
1625 \r
1626         if(Sts == 0)\r
1627         {\r
1628                 if(ConnectOnStart == YES)\r
1629                         PostMessage(hWndFtp, WM_COMMAND, MAKEWPARAM(MENU_CONNECT, 0), 0);\r
1630         }\r
1631         else if(Sts == 1)\r
1632         {\r
1633                 DirectConnectProc(unc, Kanji, Kana, FnameKanji, TrMode);\r
1634         }\r
1635         else if(Sts == 2)\r
1636         {\r
1637                 PostMessage(hWndFtp, WM_COMMAND, MAKEWPARAM(MENU_CONNECT_NUM, CmdOption), (LPARAM)AutoConnect);\r
1638         }\r
1639         return;\r
1640 }\r
1641 \r
1642 \r
1643 /*----- コマンドラインを解析 --------------------------------------------------\r
1644 *\r
1645 *       Parameter\r
1646 *               char *Str : コマンドライン文字列\r
1647 *               int *AutoConnect : 接続ホスト番号を返すワーク\r
1648 *               int *CmdOption : オプションを返すワーク\r
1649 *               char *unc : uncを返すワーク\r
1650 *               int Max : uncの最大長\r
1651 *\r
1652 *       Return Value\r
1653 *               int ステータス\r
1654 *                       0=指定なし、1=URL指定、2=設定名指定、-1=エラー\r
1655 *\r
1656 *       Note\r
1657 *               -m      --mirror\r
1658 *               -d      --mirrordown\r
1659 *               -f      --force\r
1660 *               -q      --quit\r
1661 *               -s      --set\r
1662 *               -h      --help\r
1663 *               -e      --euc\r
1664 *               -j      --jis\r
1665 *               -a      --ascii\r
1666 *               -b      --binary\r
1667 *               -x      --auto\r
1668 *               -k      --kana\r
1669 *               -u      --eucname\r
1670 *               -i      --jisname\r
1671 *               -n  --ini               (CheckIniFileNameで検索)\r
1672 *                       --saveoff\r
1673 *                       --saveon\r
1674 *               -z      --mpasswd       (CheckMasterPasswordで検索)  2010.01.30 genta 追加\r
1675 *----------------------------------------------------------------------------*/\r
1676 \r
1677 static int AnalyzeComLine(char *Str, int *AutoConnect, int *CmdOption, char *unc, int Max)\r
1678 {\r
1679         int Ret;\r
1680         char Tmp[FMAX_PATH+1];\r
1681 \r
1682         *AutoConnect = -1;\r
1683         *CmdOption = 0;\r
1684 \r
1685         Ret = 0;\r
1686         memset(unc, NUL, Max+1);\r
1687 \r
1688         while((Ret != -1) && ((Str = GetToken(Str, Tmp)) != NULL))\r
1689         {\r
1690                 if(Tmp[0] == '-')\r
1691                 {\r
1692                         _strlwr(Tmp);\r
1693                         if((strcmp(&Tmp[1], "m") == 0) || (strcmp(&Tmp[1], "-mirror") == 0))\r
1694                                 *CmdOption |= OPT_MIRROR;\r
1695                         else if((strcmp(&Tmp[1], "d") == 0) || (strcmp(&Tmp[1], "-mirrordown") == 0))\r
1696                                 *CmdOption |= OPT_MIRRORDOWN;\r
1697                         else if((strcmp(&Tmp[1], "e") == 0) || (strcmp(&Tmp[1], "-euc") == 0))\r
1698                                 *CmdOption |= OPT_EUC;\r
1699                         else if((strcmp(&Tmp[1], "j") == 0) || (strcmp(&Tmp[1], "-jis") == 0))\r
1700                                 *CmdOption |= OPT_JIS;\r
1701                         else if((strcmp(&Tmp[1], "a") == 0) || (strcmp(&Tmp[1], "-ascii") == 0))\r
1702                                 *CmdOption |= OPT_ASCII;\r
1703                         else if((strcmp(&Tmp[1], "b") == 0) || (strcmp(&Tmp[1], "-binary") == 0))\r
1704                                 *CmdOption |= OPT_BINARY;\r
1705                         else if((strcmp(&Tmp[1], "x") == 0) || (strcmp(&Tmp[1], "-auto") == 0))\r
1706                                 *CmdOption |= OPT_AUTO;\r
1707                         else if((strcmp(&Tmp[1], "f") == 0) || (strcmp(&Tmp[1], "-force") == 0))\r
1708                                 *CmdOption |= OPT_FORCE;\r
1709                         else if((strcmp(&Tmp[1], "q") == 0) || (strcmp(&Tmp[1], "-quit") == 0))\r
1710                                 *CmdOption |= OPT_QUIT;\r
1711                         else if((strcmp(&Tmp[1], "k") == 0) || (strcmp(&Tmp[1], "-kana") == 0))\r
1712                                 *CmdOption |= OPT_KANA;\r
1713                         else if((strcmp(&Tmp[1], "u") == 0) || (strcmp(&Tmp[1], "-eucname") == 0))\r
1714                                 *CmdOption |= OPT_EUC_NAME;\r
1715                         else if((strcmp(&Tmp[1], "i") == 0) || (strcmp(&Tmp[1], "-jisname") == 0))\r
1716                                 *CmdOption |= OPT_JIS_NAME;\r
1717                         else if((strcmp(&Tmp[1], "n") == 0) || (strcmp(&Tmp[1], "-ini") == 0))\r
1718                         {\r
1719                                 if((Str = GetToken(Str, Tmp)) == NULL)\r
1720                                 {\r
1721                                         SetTaskMsg(MSGJPN282);\r
1722                                         Ret = -1;\r
1723                                 }\r
1724                         }\r
1725                         else if(strcmp(&Tmp[1], "-saveoff") == 0)\r
1726                                 *CmdOption |= OPT_SAVEOFF;\r
1727                         else if(strcmp(&Tmp[1], "-saveon") == 0)\r
1728                                 *CmdOption |= OPT_SAVEON;\r
1729                         else if((strcmp(&Tmp[1], "z") == 0) || (strcmp(&Tmp[1], "-mpasswd") == 0))\r
1730                         {       /* 2010.01.30 genta : Add master password option */\r
1731                                 if((Str = GetToken(Str, Tmp)) == NULL)\r
1732                                 {\r
1733                                         SetTaskMsg(MSGJPN299);\r
1734                                         Ret = -1;\r
1735                                 }\r
1736                         }\r
1737                         else if((strcmp(&Tmp[1], "s") == 0) || (strcmp(&Tmp[1], "-set") == 0))\r
1738                         {\r
1739                                 if(Ret == 0)\r
1740                                 {\r
1741                                         if((Str = GetToken(Str, Tmp)) != NULL)\r
1742                                         {\r
1743                                                 if((*AutoConnect = SearchHostName(Tmp)) != -1)\r
1744                                                         Ret = 2;\r
1745                                                 else\r
1746                                                 {\r
1747                                                         SetTaskMsg(MSGJPN177, Tmp);\r
1748                                                         Ret = -1;\r
1749                                                 }\r
1750                                         }\r
1751                                         else\r
1752                                         {\r
1753                                                 SetTaskMsg(MSGJPN178);\r
1754                                                 Ret = -1;\r
1755                                         }\r
1756                                 }\r
1757                                 else\r
1758                                 {\r
1759                                         SetTaskMsg(MSGJPN179);\r
1760                                         Ret = -1;\r
1761                                 }\r
1762                         }\r
1763                         else if((strcmp(&Tmp[1], "h") == 0) || (strcmp(&Tmp[1], "-help") == 0))\r
1764                         {\r
1765                                 hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000024);\r
1766                         }\r
1767                         // プロセス保護\r
1768 #ifdef ENABLE_PROCESS_PROTECTION\r
1769                         else if(strcmp(Tmp, "--restart") == 0)\r
1770                         {\r
1771                         }\r
1772                         else if(strcmp(Tmp, "--protect") == 0)\r
1773                         {\r
1774                         }\r
1775                         else if(strcmp(Tmp, "--protect-high") == 0)\r
1776                         {\r
1777                         }\r
1778                         else if(strcmp(Tmp, "--protect-medium") == 0)\r
1779                         {\r
1780                         }\r
1781                         else if(strcmp(Tmp, "--protect-low") == 0)\r
1782                         {\r
1783                         }\r
1784 #endif\r
1785                         else\r
1786                         {\r
1787                                 SetTaskMsg(MSGJPN180, Tmp);\r
1788                                 Ret = -1;\r
1789                         }\r
1790                 }\r
1791                 else\r
1792                 {\r
1793                         if(Ret == 0)\r
1794                         {\r
1795                                 strncpy(unc, Tmp, Max);\r
1796                                 Ret = 1;\r
1797                         }\r
1798                         else\r
1799                         {\r
1800                                 SetTaskMsg(MSGJPN181);\r
1801                                 Ret = -1;\r
1802                         }\r
1803                 }\r
1804         }\r
1805         return(Ret);\r
1806 }\r
1807 \r
1808 \r
1809 /*----- INIファイルのパス名の指定をチェック ------------------------------------\r
1810 *\r
1811 *       Parameter\r
1812 *               char *Str : コマンドライン文字列\r
1813 *               char *Ini : iniファイル名を返すワーク\r
1814 *\r
1815 *       Return Value\r
1816 *               int ステータス\r
1817 *                       0=指定なし、1=あり\r
1818 *\r
1819 *       Note\r
1820 *               -n  --ini\r
1821 *----------------------------------------------------------------------------*/\r
1822 \r
1823 static int CheckIniFileName(char *Str, char *Ini)\r
1824 {\r
1825         return GetTokenAfterOption( Str, Ini, "n", "-ini" );\r
1826 }\r
1827 \r
1828 /* マスターパスワードの指定をチェック */\r
1829 static int CheckMasterPassword(char *Str, char *Ini)\r
1830 {\r
1831         return GetTokenAfterOption( Str, Ini, "z", "-mpasswd" );\r
1832 }\r
1833 \r
1834 /*----- オプションの後ろのトークンを取り出す ------------------------------------\r
1835 *\r
1836 *       Parameter\r
1837 *               char *Str : コマンドライン文字列\r
1838 *               char *Result : 取り出した文字列を格納するワーク\r
1839 *               const char* Opt1, *Opt2: オプション文字列(2つ)\r
1840 *\r
1841 *       Return Value\r
1842 *               int ステータス\r
1843 *                       0=指定なし、1=あり\r
1844 *\r
1845 *       Note\r
1846 *               2010.01.30 genta マスターパスワード取り出しのため共通化\r
1847 *----------------------------------------------------------------------------*/\r
1848 static int GetTokenAfterOption(char *Str, char *Result, const char* Opt1, const char* Opt2 )\r
1849 {\r
1850         int Ret = 0;\r
1851         char Tmp[FMAX_PATH+1];\r
1852 \r
1853         Result[0] = NUL;\r
1854         while((Str = GetToken(Str, Tmp)) != NULL)\r
1855         {\r
1856                 if(Tmp[0] == '-')\r
1857                 {\r
1858                         _strlwr(Tmp);\r
1859                         if((strcmp(&Tmp[1], Opt1) == 0) || (strcmp(&Tmp[1], Opt2) == 0))\r
1860                         {\r
1861                                 if((Str = GetToken(Str, Result)) != NULL)\r
1862                                         Ret = 1;\r
1863                                 break;\r
1864                         }\r
1865                 }\r
1866         }\r
1867         return(Ret);\r
1868 }\r
1869 \r
1870 /*----- トークンを返す --------------------------------------------------------\r
1871 *\r
1872 *       Parameter\r
1873 *               char *Str : 文字列\r
1874 *               char *Buf : 文字列を返すバッファ\r
1875 *\r
1876 *       Return Value\r
1877 *               char *返したトークンの末尾\r
1878 *                       NULL=終わり\r
1879 *----------------------------------------------------------------------------*/\r
1880 \r
1881 static char *GetToken(char *Str, char *Buf)\r
1882 {\r
1883         int InQuote;\r
1884 \r
1885         while(*Str != NUL)\r
1886         {\r
1887                 if((*Str != ' ') && (*Str != '\t'))\r
1888                         break;\r
1889                 Str++;\r
1890         }\r
1891 \r
1892         if(*Str != NUL)\r
1893         {\r
1894                 InQuote = 0;\r
1895                 while(*Str != NUL)\r
1896                 {\r
1897                         if(*Str == 0x22)\r
1898                                 InQuote = !InQuote;\r
1899                         else\r
1900                         {\r
1901                                 if(((*Str == ' ') || (*Str == '\t')) &&\r
1902                                    (InQuote == 0))\r
1903                                 {\r
1904                                         break;\r
1905                                 }\r
1906                                 *Buf++ = *Str;\r
1907                         }\r
1908                         Str++;\r
1909                 }\r
1910         }\r
1911         else\r
1912                 Str = NULL;\r
1913 \r
1914         *Buf = NUL;\r
1915 \r
1916         return(Str);\r
1917 }\r
1918 \r
1919 \r
1920 /*----- プログラム終了時の処理 ------------------------------------------------\r
1921 *\r
1922 *       Parameter\r
1923 *               HWND hWnd : ウインドウハンドル\r
1924 *\r
1925 *       Return Value\r
1926 *               なし\r
1927 *----------------------------------------------------------------------------*/\r
1928 \r
1929 static void ExitProc(HWND hWnd)\r
1930 {\r
1931         CancelFlg = YES;\r
1932 \r
1933         CloseTransferThread();\r
1934 \r
1935         if(SaveExit == YES)\r
1936         {\r
1937                 SaveBookMark();\r
1938                 SaveCurrentSetToHost();\r
1939         }\r
1940         DeleteAlltempFile();\r
1941 \r
1942 //      WSACancelBlockingCall();\r
1943         DisconnectProc();\r
1944 //      CloseTransferThread();\r
1945 \r
1946         if(SaveExit == YES)\r
1947         {\r
1948                 GetListTabWidth();\r
1949                 SaveRegistory();\r
1950 \r
1951                 if((CacheEntry > 0) && (CacheSave == YES))\r
1952                         SaveCache();\r
1953                 else\r
1954                         DeleteCache();\r
1955         }\r
1956         else\r
1957                 DeleteCache();\r
1958 \r
1959         if(RasClose == YES)\r
1960         {\r
1961                 DisconnectRas(RasCloseNotify);\r
1962         }\r
1963         DeleteAllObject();\r
1964         HtmlHelp(NULL, NULL, HH_UNINITIALIZE, dwCookie); \r
1965         return;\r
1966 }\r
1967 \r
1968 \r
1969 /*----- ファイル名をダブルクリックしたときの処理 ------------------------------\r
1970 *\r
1971 *       Parameter\r
1972 *               int Win : ウインドウ番号 (WIN_xxx)\r
1973 *               int Mode : 常に「開く」動作をするかどうか (YES/NO)\r
1974 *               int App : アプリケーション番号(-1=関連づけ優先)\r
1975 *\r
1976 *       Return Value\r
1977 *               なし\r
1978 *----------------------------------------------------------------------------*/\r
1979 \r
1980 void DoubleClickProc(int Win, int Mode, int App)\r
1981 {\r
1982         int Pos;\r
1983         int Type;\r
1984         char Local[FMAX_PATH+1];\r
1985         char Remote[FMAX_PATH+1];\r
1986         char Tmp[FMAX_PATH+1];\r
1987         int Sts;\r
1988         int UseDiffViewer;\r
1989 \r
1990         if(AskUserOpeDisabled() == NO)\r
1991         {\r
1992                 SetCurrentDirAsDirHist();\r
1993                 if(GetSelectedCount(Win) == 1)\r
1994                 {\r
1995                         if((Pos = GetFirstSelected(Win, NO)) != -1)\r
1996                         {\r
1997                                 GetNodeName(Win, Pos, Tmp, FMAX_PATH);\r
1998                                 Type = GetNodeType(Win, Pos);\r
1999 \r
2000                                 if(Win == WIN_LOCAL)\r
2001                                 {\r
2002                                         if((App != -1) || (Type == NODE_FILE))\r
2003                                         {\r
2004                                                 if((DclickOpen == YES) || (Mode == YES))\r
2005                                                 {\r
2006                                                         AskLocalCurDir(Local, FMAX_PATH);\r
2007                                                         ReplaceAll(Local, '/', '\\');\r
2008                                                         SetYenTail(Local);\r
2009                                                         strcat(Local, Tmp);\r
2010                                                         ExecViewer(Local, App);\r
2011                                                 }\r
2012                                                 else\r
2013                                                         PostMessage(hWndFtp, WM_COMMAND, MAKEWPARAM(MENU_UPLOAD, 0), 0);\r
2014                                         }\r
2015                                         else\r
2016                                                 ChangeDir(WIN_LOCAL, Tmp);\r
2017                                 }\r
2018                                 else if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
2019                                 {\r
2020                                         if((App != -1) || (Type == NODE_FILE))\r
2021                                         {\r
2022                                                 if((DclickOpen == YES) || (Mode == YES))\r
2023                                                 {\r
2024                                                         // ビューワ2、3のパスが "d " で始まっていたら差分ビューア使用\r
2025                                                         if ((App == 1 || App == 2) && strncmp(ViewerName[App], "d ", 2) == 0)\r
2026                                                                 UseDiffViewer = YES;\r
2027                                                         else\r
2028                                                                 UseDiffViewer = NO;\r
2029 \r
2030                                                         strcpy(Remote, TmpPath);\r
2031                                                         SetYenTail(Remote);\r
2032                                                         if (UseDiffViewer == YES) {\r
2033                                                                 strcat(Remote, "remote.");\r
2034                                                         }\r
2035                                                         strcat(Remote, Tmp);\r
2036 \r
2037                                                         if(AskTransferNow() == YES)\r
2038                                                                 SktShareProh();\r
2039 \r
2040         //                                              MainTransPkt.ctrl_skt = AskCmdCtrlSkt();\r
2041                                                         strcpy(MainTransPkt.Cmd, "RETR ");\r
2042                                                         if(AskHostType() == HTYPE_ACOS)\r
2043                                                         {\r
2044                                                                 strcpy(MainTransPkt.RemoteFile, "'");\r
2045                                                                 strcat(MainTransPkt.RemoteFile, AskHostLsName());\r
2046                                                                 strcat(MainTransPkt.RemoteFile, "(");\r
2047                                                                 strcat(MainTransPkt.RemoteFile, Tmp);\r
2048                                                                 strcat(MainTransPkt.RemoteFile, ")");\r
2049                                                                 strcat(MainTransPkt.RemoteFile, "'");\r
2050                                                         }\r
2051                                                         else if(AskHostType() == HTYPE_ACOS_4)\r
2052                                                         {\r
2053                                                                 strcpy(MainTransPkt.RemoteFile, Tmp);\r
2054                                                         }\r
2055                                                         else\r
2056                                                         {\r
2057                                                                 strcpy(MainTransPkt.RemoteFile, Tmp);\r
2058                                                         }\r
2059                                                         strcpy(MainTransPkt.LocalFile, Remote);\r
2060                                                         MainTransPkt.Type = AskTransferTypeAssoc(MainTransPkt.RemoteFile, AskTransferType());\r
2061                                                         MainTransPkt.Size = 1;\r
2062                                                         MainTransPkt.KanjiCode = AskHostKanjiCode();\r
2063                                                         MainTransPkt.KanjiCodeDesired = AskLocalKanjiCode();\r
2064                                                         MainTransPkt.KanaCnv = AskHostKanaCnv();\r
2065                                                         MainTransPkt.Mode = EXIST_OVW;\r
2066                                                         MainTransPkt.ExistSize = 0;\r
2067                                                         MainTransPkt.hWndTrans = NULL;\r
2068                                                         MainTransPkt.Next = NULL;\r
2069 \r
2070                                                         DisableUserOpe();\r
2071 \r
2072                                                         /* 不正なパスを検出 */\r
2073                                                         if(CheckPathViolation(&MainTransPkt) == NO)\r
2074                                                         {\r
2075 //                                                              if((Sts = DoDownLoad(AskCmdCtrlSkt(), &MainTransPkt, NO)) == 429)\r
2076 //                                                              {\r
2077 //                                                                      ReConnectCmdSkt();\r
2078                                                                         Sts = DoDownLoad(AskCmdCtrlSkt(), &MainTransPkt, NO, &CancelFlg);\r
2079 //                                                              }\r
2080                                                         }\r
2081 \r
2082                                                         EnableUserOpe();\r
2083 \r
2084                                                         AddTempFileList(Remote);\r
2085                                                         if(Sts/100 == FTP_COMPLETE) {\r
2086                                                                 if (UseDiffViewer == YES) {\r
2087                                                                         AskLocalCurDir(Local, FMAX_PATH);\r
2088                                                                         ReplaceAll(Local, '/', '\\');\r
2089                                                                         SetYenTail(Local);\r
2090                                                                         strcat(Local, Tmp);\r
2091                                                                         ExecViewer2(Local, Remote, App);\r
2092                                                                 } else {\r
2093                                                                         ExecViewer(Remote, App);\r
2094                                                                 }\r
2095                                                         }\r
2096                                                 }\r
2097                                                 else\r
2098                                                         PostMessage(hWndFtp, WM_COMMAND, MAKEWPARAM(MENU_DOWNLOAD, 0), 0);\r
2099                                         }\r
2100                                         else\r
2101                                                 ChangeDir(WIN_REMOTE, Tmp);\r
2102                                 }\r
2103                         }\r
2104                 }\r
2105                 MakeButtonsFocus();\r
2106         }\r
2107         return;\r
2108 }\r
2109 \r
2110 \r
2111 /*----- フォルダの移動 --------------------------------------------------------\r
2112 *\r
2113 *       Parameter\r
2114 *               int Win : ウインドウ番号 (WIN_xxx)\r
2115 *               char *Path : 移動先のパス名\r
2116 *\r
2117 *       Return Value\r
2118 *               なし\r
2119 *\r
2120 *       Note\r
2121 *               フォルダ同時移動の処理も行う\r
2122 *----------------------------------------------------------------------------*/\r
2123 \r
2124 static void ChangeDir(int Win, char *Path)\r
2125 {\r
2126         int Sync;\r
2127         char Local[FMAX_PATH+1];\r
2128         char Remote[FMAX_PATH+1];\r
2129 \r
2130         Sync = AskSyncMoveMode();\r
2131         if(Sync == YES)\r
2132         {\r
2133                 if(strcmp(Path, "..") == 0)\r
2134                 {\r
2135                         AskLocalCurDir(Local, FMAX_PATH);\r
2136                         AskRemoteCurDir(Remote, FMAX_PATH);\r
2137                         if(strcmp(GetFileName(Local), GetFileName(Remote)) != 0)\r
2138                                 Sync = NO;\r
2139                 }\r
2140         }\r
2141 \r
2142         if((Win == WIN_LOCAL) || (Sync == YES))\r
2143         {\r
2144                 if(DoLocalCWD(Path) == FFFTP_SUCCESS)\r
2145                         GetLocalDirForWnd();\r
2146         }\r
2147 \r
2148         if((Win == WIN_REMOTE) || (Sync == YES))\r
2149         {\r
2150                 if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
2151                 {\r
2152 #if defined(HAVE_OPENVMS)\r
2153                         /* OpenVMSの場合、".DIR;?"を取る */\r
2154                         if (AskHostType() == HTYPE_VMS)\r
2155                                 ReformVMSDirName(Path, TRUE);\r
2156 #endif\r
2157                         if(DoCWD(Path, YES, NO, YES) < FTP_RETRY)\r
2158                                 GetRemoteDirForWnd(CACHE_NORMAL, &CancelFlg);\r
2159                 }\r
2160         }\r
2161         return;\r
2162 }\r
2163 \r
2164 \r
2165 /*----- ウインドウのサイズ変更の処理 ------------------------------------------\r
2166 *\r
2167 *       Parameter\r
2168 *               なし\r
2169 *\r
2170 *       Return Value\r
2171 *               なし\r
2172 *----------------------------------------------------------------------------*/\r
2173 \r
2174 static void ResizeWindowProc(void)\r
2175 {\r
2176 #if 0\r
2177         RECT Rect;\r
2178         int RemotePosX;\r
2179 \r
2180         GetClientRect(hWndFtp, &Rect);\r
2181         SendMessage(GetSbarWnd(), WM_SIZE, SIZE_RESTORED, MAKELPARAM(Rect.right, Rect.bottom));\r
2182 \r
2183         CalcWinSize();\r
2184         SetWindowPos(GetMainTbarWnd(), 0, 0, 0, WinWidth, TOOLWIN_HEIGHT, SWP_NOACTIVATE | SWP_NOZORDER);\r
2185 \r
2186         SetWindowPos(GetLocalTbarWnd(), 0, 0, TOOLWIN_HEIGHT, LocalWidth, TOOLWIN_HEIGHT, SWP_NOACTIVATE | SWP_NOZORDER);\r
2187         SendMessage(GetLocalTbarWnd(), TB_GETITEMRECT, 3, (LPARAM)&Rect);\r
2188         SetWindowPos(GetLocalHistHwnd(), 0, Rect.right, Rect.top, LocalWidth - Rect.right, 200, SWP_NOACTIVATE | SWP_NOZORDER);\r
2189         SetWindowPos(GetLocalHwnd(), 0, 0, TOOLWIN_HEIGHT*2, LocalWidth, ListHeight, SWP_NOACTIVATE | SWP_NOZORDER);\r
2190 \r
2191         RemotePosX = LocalWidth + SepaWidth;\r
2192         if(SplitVertical == YES)\r
2193                 RemotePosX = 0;\r
2194 \r
2195         SetWindowPos(GetRemoteTbarWnd(), 0, RemotePosX, TOOLWIN_HEIGHT, RemoteWidth, TOOLWIN_HEIGHT, SWP_NOACTIVATE | SWP_NOZORDER);\r
2196         SendMessage(GetRemoteTbarWnd(), TB_GETITEMRECT, 3, (LPARAM)&Rect);\r
2197         SetWindowPos(GetRemoteHistHwnd(), 0, Rect.right, Rect.top, RemoteWidth - Rect.right, 200, SWP_NOACTIVATE | SWP_NOZORDER);\r
2198         SetWindowPos(GetRemoteHwnd(), 0, RemotePosX, TOOLWIN_HEIGHT*2, RemoteWidth, ListHeight, SWP_NOACTIVATE | SWP_NOZORDER);\r
2199 \r
2200         SetWindowPos(GetTaskWnd(), 0, 0, TOOLWIN_HEIGHT*2+ListHeight+SepaWidth, ClientWidth, TaskHeight, SWP_NOACTIVATE | SWP_NOZORDER);\r
2201 #else\r
2202         RECT Rect;\r
2203 \r
2204         GetClientRect(hWndFtp, &Rect);\r
2205         SendMessage(GetSbarWnd(), WM_SIZE, SIZE_RESTORED, MAKELPARAM(Rect.right, Rect.bottom));\r
2206 \r
2207         CalcWinSize();\r
2208         SetWindowPos(GetMainTbarWnd(), 0, 0, 0, Rect.right, TOOLWIN_HEIGHT, SWP_NOACTIVATE | SWP_NOZORDER);\r
2209         SetWindowPos(GetLocalTbarWnd(), 0, 0, TOOLWIN_HEIGHT, LocalWidth, TOOLWIN_HEIGHT, SWP_NOACTIVATE | SWP_NOZORDER);\r
2210         SetWindowPos(GetRemoteTbarWnd(), 0, LocalWidth + SepaWidth, TOOLWIN_HEIGHT, RemoteWidth, TOOLWIN_HEIGHT, SWP_NOACTIVATE | SWP_NOZORDER);\r
2211         SendMessage(GetLocalTbarWnd(), TB_GETITEMRECT, 3, (LPARAM)&Rect);\r
2212         SetWindowPos(GetLocalHistHwnd(), 0, Rect.right, Rect.top, LocalWidth - Rect.right, 200, SWP_NOACTIVATE | SWP_NOZORDER);\r
2213         SendMessage(GetRemoteTbarWnd(), TB_GETITEMRECT, 3, (LPARAM)&Rect);\r
2214         SetWindowPos(GetRemoteHistHwnd(), 0, Rect.right, Rect.top, RemoteWidth - Rect.right, 200, SWP_NOACTIVATE | SWP_NOZORDER);\r
2215         SetWindowPos(GetLocalHwnd(), 0, 0, TOOLWIN_HEIGHT*2, LocalWidth, ListHeight, SWP_NOACTIVATE | SWP_NOZORDER);\r
2216         SetWindowPos(GetRemoteHwnd(), 0, LocalWidth + SepaWidth, TOOLWIN_HEIGHT*2, RemoteWidth, ListHeight, SWP_NOACTIVATE | SWP_NOZORDER);\r
2217         SetWindowPos(GetTaskWnd(), 0, 0, TOOLWIN_HEIGHT*2+ListHeight+SepaWidth, ClientWidth, TaskHeight, SWP_NOACTIVATE | SWP_NOZORDER);\r
2218 #endif\r
2219 \r
2220         return;\r
2221 }\r
2222 \r
2223 \r
2224 /*----- ウインドウの各部分のサイズを計算する ----------------------------------\r
2225 *\r
2226 *       Parameter\r
2227 *               なし\r
2228 *\r
2229 *       Return Value\r
2230 *               なし\r
2231 *----------------------------------------------------------------------------*/\r
2232 \r
2233 static void CalcWinSize(void)\r
2234 {\r
2235         RECT Rect;\r
2236 \r
2237         GetWindowRect(hWndFtp, &Rect);\r
2238 \r
2239         if(Sizing != SW_MAXIMIZE)\r
2240         {\r
2241                 WinWidth = Rect.right - Rect.left;\r
2242                 WinHeight = Rect.bottom - Rect.top;\r
2243         }\r
2244 \r
2245         GetClientRect(hWndFtp, &Rect);\r
2246 \r
2247         ClientWidth = Rect.right;\r
2248         ClientHeight = Rect.bottom;\r
2249 \r
2250         SepaWidth = 4;\r
2251         LocalWidth = max1(0, min1(LocalWidth, ClientWidth - SepaWidth));\r
2252         RemoteWidth = max1(0, ClientWidth - LocalWidth - SepaWidth);\r
2253 //      TaskHeight = min1(TaskHeight, max1(0, ClientHeight - TOOLWIN_HEIGHT * 2 - SepaWidth));\r
2254 \r
2255         GetClientRect(GetSbarWnd(), &Rect);\r
2256 \r
2257         ListHeight = max1(0, ClientHeight - TOOLWIN_HEIGHT * 2 - TaskHeight - SepaWidth - Rect.bottom);\r
2258 \r
2259         return;\r
2260 }\r
2261 \r
2262 \r
2263 #if 0\r
2264 /*----- ウインドウの表示位置を取得する ----------------------------------------\r
2265 *\r
2266 *       Parameter\r
2267 *               HWND hWnd : ウインドウハンドル\r
2268 *\r
2269 *       Return Value\r
2270 *               なし\r
2271 *----------------------------------------------------------------------------*/\r
2272 \r
2273 static void AskWindowPos(HWND hWnd)\r
2274 {\r
2275         WINDOWPLACEMENT WinPlace;\r
2276 \r
2277         WinPlace.length = sizeof(WINDOWPLACEMENT);\r
2278         GetWindowPlacement(hWnd, &WinPlace);\r
2279         WinPosX = WinPlace.rcNormalPosition.left;\r
2280         WinPosY = WinPlace.rcNormalPosition.top;\r
2281 \r
2282         return;\r
2283 }\r
2284 #endif\r
2285 \r
2286 \r
2287 /*----- ディレクトリリストとファイルリストの境界変更処理 ----------------------\r
2288 *\r
2289 *       Parameter\r
2290 *               WPARAM Keys : WM_MOUSEMOVEなどのWPARAMの値\r
2291 *               int x : マウスカーソルのX座標\r
2292 *               int y : マウスカーソルのY座標\r
2293 *\r
2294 *       Return Value\r
2295 *               なし\r
2296 *----------------------------------------------------------------------------*/\r
2297 \r
2298 static void CheckResizeFrame(WPARAM Keys, int x, int y)\r
2299 {\r
2300         RECT Rect;\r
2301         RECT Rect1;\r
2302 \r
2303         if((Resizing == RESIZE_OFF) && (Keys == 0))\r
2304         {\r
2305                 if((x >= LocalWidth) && (x <= LocalWidth + SepaWidth) &&\r
2306                    (y > TOOLWIN_HEIGHT) && (y < (TOOLWIN_HEIGHT * 2 + ListHeight)))\r
2307                 {\r
2308                         /* 境界位置変更用カーソルに変更 */\r
2309                         SetCapture(hWndFtp);\r
2310                         hCursor = LoadCursor(hInstFtp, MAKEINTRESOURCE(resize_lr_csr));\r
2311                         SetCursor(hCursor);\r
2312                         Resizing = RESIZE_PREPARE;\r
2313                         ResizePos = RESIZE_HPOS;\r
2314                 }\r
2315                 else if((y >= TOOLWIN_HEIGHT*2+ListHeight) && (y <= TOOLWIN_HEIGHT*2+ListHeight+SepaWidth))\r
2316                 {\r
2317                         /* 境界位置変更用カーソルに変更 */\r
2318                         SetCapture(hWndFtp);\r
2319                         hCursor = LoadCursor(hInstFtp, MAKEINTRESOURCE(resize_ud_csr));\r
2320                         SetCursor(hCursor);\r
2321                         Resizing = RESIZE_PREPARE;\r
2322                         ResizePos = RESIZE_VPOS;\r
2323                 }\r
2324         }\r
2325         else if(Resizing == RESIZE_PREPARE)\r
2326         {\r
2327                 if(Keys & MK_LBUTTON)\r
2328                 {\r
2329                         /* 境界位置変更開始 */\r
2330                         Resizing = RESIZE_ON;\r
2331                         GetWindowRect(hWndFtp, &Rect);\r
2332                         GetClientRect(GetSbarWnd(), &Rect1);\r
2333                         Rect.left += GetSystemMetrics(SM_CXFRAME);\r
2334                         Rect.right -= GetSystemMetrics(SM_CXFRAME);\r
2335                         Rect.top += TOOLWIN_HEIGHT*2 + GetSystemMetrics(SM_CYMENU) + GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYFRAME);\r
2336                         Rect.bottom -= GetSystemMetrics(SM_CYFRAME) + Rect1.bottom;\r
2337                         ClipCursor(&Rect);\r
2338                 }\r
2339                 else\r
2340                 {\r
2341                         if(((ResizePos == RESIZE_HPOS) &&\r
2342                                 ((x < LocalWidth) || (x > LocalWidth + SepaWidth) ||\r
2343                                  (y <= TOOLWIN_HEIGHT) || (y >= (TOOLWIN_HEIGHT * 2 + ListHeight)))) ||\r
2344                            ((ResizePos == RESIZE_VPOS) &&\r
2345                                 ((y < TOOLWIN_HEIGHT*2+ListHeight) || (y > TOOLWIN_HEIGHT*2+ListHeight+SepaWidth))))\r
2346                         {\r
2347                                 /* 元のカーソルに戻す */\r
2348                                 ReleaseCapture();\r
2349                                 hCursor = LoadCursor(NULL, IDC_ARROW);\r
2350                                 SetCursor(hCursor);\r
2351                                 Resizing = RESIZE_OFF;\r
2352                         }\r
2353                 }\r
2354         }\r
2355         else if(Resizing == RESIZE_ON)\r
2356         {\r
2357                 if(ResizePos == RESIZE_HPOS)\r
2358                         LocalWidth = x;\r
2359                 else\r
2360                 {\r
2361                         GetClientRect(hWndFtp, &Rect);\r
2362                         GetClientRect(GetSbarWnd(), &Rect1);\r
2363                         TaskHeight = max1(0, Rect.bottom - y - Rect1.bottom);\r
2364                 }\r
2365                 ResizeWindowProc();\r
2366 \r
2367                 if((Keys & MK_LBUTTON) == 0)\r
2368                 {\r
2369                         /* 境界位置変更終了 */\r
2370                         ReleaseCapture();\r
2371                         ClipCursor(NULL);\r
2372                         hCursor = LoadCursor(NULL, IDC_ARROW);\r
2373                         SetCursor(hCursor);\r
2374                         Resizing = RESIZE_OFF;\r
2375                 }\r
2376         }\r
2377         return;\r
2378 }\r
2379 \r
2380 \r
2381 /*----- ファイル一覧情報をビューワで表示 --------------------------------------\r
2382 *\r
2383 *       Parameter\r
2384 *               なし\r
2385 *\r
2386 *       Return Value\r
2387 *               なし\r
2388 *----------------------------------------------------------------------------*/\r
2389 \r
2390 static void DispDirInfo(void)\r
2391 {\r
2392         char Buf[FMAX_PATH+1];\r
2393 \r
2394         MakeCacheFileName(AskCurrentFileListNum(), Buf);\r
2395         ExecViewer(Buf, 0);\r
2396         return;\r
2397 }\r
2398 \r
2399 \r
2400 \r
2401 /*----- ビューワを起動 --------------------------------------------------------\r
2402 *\r
2403 *       Parameter\r
2404 *               char Fname : ファイル名\r
2405 *               int App : アプリケーション番号(-1=関連づけ優先)\r
2406 *\r
2407 *       Return Value\r
2408 *               なし\r
2409 *----------------------------------------------------------------------------*/\r
2410 \r
2411 void ExecViewer(char *Fname, int App)\r
2412 {\r
2413         PROCESS_INFORMATION Info;\r
2414         STARTUPINFO Startup;\r
2415         char AssocProg[FMAX_PATH+1];\r
2416         char ComLine[FMAX_PATH*2+3+1];\r
2417         char CurDir[FMAX_PATH+1];\r
2418 \r
2419         /* FindExecutable()は関連付けられたプログラムのパス名にスペースが        */\r
2420         /* 含まれている時、間違ったパス名を返す事がある。                                        */\r
2421         /* そこで、関連付けられたプログラムの起動はShellExecute()を使う。       */\r
2422 \r
2423         AskLocalCurDir(CurDir, FMAX_PATH);\r
2424 \r
2425         if((App == -1) && (FindExecutable(Fname, NULL, AssocProg) > (HINSTANCE)32))\r
2426         {\r
2427                 DoPrintf("ShellExecute - %s", Fname);\r
2428                 ShellExecute(NULL, "open", Fname, NULL, CurDir, SW_SHOW);\r
2429         }\r
2430         else\r
2431         {\r
2432                 App = max1(0, App);\r
2433                 strcpy(AssocProg, ViewerName[App]);\r
2434 \r
2435                 if(strchr(Fname, ' ') == NULL)\r
2436                         sprintf(ComLine, "%s %s", AssocProg, Fname);\r
2437                 else\r
2438                         sprintf(ComLine, "%s \"%s\"", AssocProg, Fname);\r
2439 \r
2440                 DoPrintf("FindExecutable - %s", ComLine);\r
2441 \r
2442                 memset(&Startup, NUL, sizeof(STARTUPINFO));\r
2443                 Startup.cb = sizeof(STARTUPINFO);\r
2444                 Startup.wShowWindow = SW_SHOW;\r
2445                 if(CreateProcess(NULL, ComLine, NULL, NULL, FALSE, 0, NULL, NULL, &Startup, &Info) == FALSE)\r
2446                 {\r
2447                         SetTaskMsg(MSGJPN182, GetLastError());\r
2448                         SetTaskMsg(">>%s", ComLine);\r
2449                 }\r
2450         }\r
2451         return;\r
2452 }\r
2453 \r
2454 \r
2455 /*----- 差分表示ビューワを起動 ------------------------------------------------\r
2456 *\r
2457 *       Parameter\r
2458 *               char Fname1 : ファイル名\r
2459 *               char Fname2 : ファイル名2\r
2460 *               int App : アプリケーション番号(2 or 3)\r
2461 *\r
2462 *       Return Value\r
2463 *               なし\r
2464 *----------------------------------------------------------------------------*/\r
2465 \r
2466 void ExecViewer2(char *Fname1, char *Fname2, int App)\r
2467 {\r
2468         PROCESS_INFORMATION Info;\r
2469         STARTUPINFO Startup;\r
2470         char AssocProg[FMAX_PATH+1];\r
2471         char ComLine[FMAX_PATH*2+3+1];\r
2472         char CurDir[FMAX_PATH+1];\r
2473 \r
2474         /* FindExecutable()は関連付けられたプログラムのパス名にスペースが        */\r
2475         /* 含まれている時、間違ったパス名を返す事がある。                                        */\r
2476         /* そこで、関連付けられたプログラムの起動はShellExecute()を使う。       */\r
2477 \r
2478         AskLocalCurDir(CurDir, FMAX_PATH);\r
2479 \r
2480         strcpy(AssocProg, ViewerName[App] + 2); /* 先頭の "d " は読み飛ばす */\r
2481 \r
2482         if(strchr(Fname1, ' ') == NULL && strchr(Fname2, ' ') == NULL)\r
2483                 sprintf(ComLine, "%s %s %s", AssocProg, Fname1, Fname2);\r
2484         else\r
2485                 sprintf(ComLine, "%s \"%s\" \"%s\"", AssocProg, Fname1, Fname2);\r
2486 \r
2487         DoPrintf("FindExecutable - %s", ComLine);\r
2488 \r
2489         memset(&Startup, NUL, sizeof(STARTUPINFO));\r
2490         Startup.cb = sizeof(STARTUPINFO);\r
2491         Startup.wShowWindow = SW_SHOW;\r
2492         if(CreateProcess(NULL, ComLine, NULL, NULL, FALSE, 0, NULL, NULL, &Startup, &Info) == FALSE)\r
2493         {\r
2494                 SetTaskMsg(MSGJPN182, GetLastError());\r
2495                 SetTaskMsg(">>%s", ComLine);\r
2496         }\r
2497 \r
2498         return;\r
2499 }\r
2500 \r
2501 \r
2502 /*----- テンポラリファイル名をテンポラリファイルリストに追加 ------------------\r
2503 *\r
2504 *       Parameter\r
2505 *               char *Fname : テンポラリファイル名\r
2506 *\r
2507 *       Return Value\r
2508 *               なし\r
2509 *----------------------------------------------------------------------------*/\r
2510 \r
2511 void AddTempFileList(char *Fname)\r
2512 {\r
2513         TEMPFILELIST *New;\r
2514 \r
2515         if((New = malloc(sizeof(TEMPFILELIST))) != NULL)\r
2516         {\r
2517                 if((New->Fname = malloc(strlen(Fname)+1)) != NULL)\r
2518                 {\r
2519                         strcpy(New->Fname, Fname);\r
2520                         if(TempFiles == NULL)\r
2521                                 New->Next = NULL;\r
2522                         else\r
2523                                 New->Next = TempFiles;\r
2524                         TempFiles = New;\r
2525                 }\r
2526                 else\r
2527                         free(New);\r
2528         }\r
2529         return;\r
2530 }\r
2531 \r
2532 \r
2533 /*----- テンポラリファイルリストに登録されているファイルを全て削除 ------------\r
2534 *\r
2535 *       Parameter\r
2536 *               なし\r
2537 *\r
2538 *       Return Value\r
2539 *               なし\r
2540 *----------------------------------------------------------------------------*/\r
2541 \r
2542 static void DeleteAlltempFile(void)\r
2543 {\r
2544         TEMPFILELIST *Pos;\r
2545         TEMPFILELIST *Next;\r
2546 \r
2547         Pos = TempFiles;\r
2548         while(Pos != NULL)\r
2549         {\r
2550                 DeleteFile(Pos->Fname);\r
2551 \r
2552                 Next = Pos->Next;\r
2553                 free(Pos->Fname);\r
2554                 free(Pos);\r
2555                 Pos = Next;\r
2556         }\r
2557 \r
2558         // OLE D&Dのテンポラリを削除する (2007.9.11 yutaka)\r
2559         doDeleteRemoteFile();\r
2560 \r
2561         return;\r
2562 }\r
2563 \r
2564 \r
2565 /*----- Aboutダイアログボックスのコールバック関数 ------------------------\r
2566 *\r
2567 *       Parameter\r
2568 *               HWND hDlg : ウインドウハンドル\r
2569 *               UINT message : メッセージ番号\r
2570 *               WPARAM wParam : メッセージの WPARAM 引数\r
2571 *               LPARAM lParam : メッセージの LPARAM 引数\r
2572 *\r
2573 *       Return Value\r
2574 *               BOOL TRUE/FALSE\r
2575 *----------------------------------------------------------------------------*/\r
2576 \r
2577 static BOOL CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
2578 {\r
2579         static char Tmp[80];\r
2580         int Ver;\r
2581 \r
2582         switch (message)\r
2583         {\r
2584                 case WM_INITDIALOG :\r
2585                         Ver = GetJreVersion();\r
2586                         if(Ver == -1)\r
2587                                 sprintf(Tmp, MSGJPN183);\r
2588                         else\r
2589                                 sprintf(Tmp, MSGJPN184, Ver / 0x100, Ver % 0x100);\r
2590                         SendDlgItemMessage(hDlg, ABOUT_JRE, WM_SETTEXT, 0, (LPARAM)Tmp);\r
2591                         SendDlgItemMessage(hDlg, ABOUT_URL, EM_LIMITTEXT, 256, 0);\r
2592                         SendDlgItemMessage(hDlg, ABOUT_URL, WM_SETTEXT, 0, (LPARAM)MSGJPN284);\r
2593                         return(TRUE);\r
2594 \r
2595                 case WM_COMMAND :\r
2596                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
2597                         {\r
2598                                 case IDOK :\r
2599                                 case IDCANCEL :\r
2600                                         EndDialog(hDlg, YES);\r
2601                                         break;\r
2602                         }\r
2603                         return(TRUE);\r
2604         }\r
2605     return(FALSE);\r
2606 }\r
2607 \r
2608 \r
2609 /*----- サウンドを鳴らす ------------------------------------------------------\r
2610 *\r
2611 *       Parameter\r
2612 *               Int num : サウンドの種類 (SND_xxx)\r
2613 *\r
2614 *       Return Value\r
2615 *               なし\r
2616 *----------------------------------------------------------------------------*/\r
2617 \r
2618 void SoundPlay(int Num)\r
2619 {\r
2620         if(Sound[Num].On == YES)\r
2621                 sndPlaySound(Sound[Num].Fname, SND_ASYNC | SND_NODEFAULT);\r
2622 \r
2623         return;\r
2624 }\r
2625 \r
2626 \r
2627 /*----- ヘルプファイルのパス名を返す ------------------------------------------\r
2628 *\r
2629 *       Parameter\r
2630 *               なし\r
2631 *\r
2632 *       Return Value\r
2633 *               char *パス名\r
2634 *----------------------------------------------------------------------------*/\r
2635 \r
2636 char *AskHelpFilePath(void)\r
2637 {\r
2638         return(HelpPath);\r
2639 }\r
2640 \r
2641 \r
2642 /*----- テンポラリファイルのパス名を返す --------------------------------------\r
2643 *\r
2644 *       Parameter\r
2645 *               なし\r
2646 *\r
2647 *       Return Value\r
2648 *               char *パス名\r
2649 *----------------------------------------------------------------------------*/\r
2650 \r
2651 char *AskTmpFilePath(void)\r
2652 {\r
2653         return(TmpPath);\r
2654 }\r
2655 \r
2656 \r
2657 /*----- INIファイルのパス名を返す ---------------------------------------------\r
2658 *\r
2659 *       Parameter\r
2660 *               なし\r
2661 *\r
2662 *       Return Value\r
2663 *               char *パス名\r
2664 *----------------------------------------------------------------------------*/\r
2665 \r
2666 char *AskIniFilePath(void)\r
2667 {\r
2668         return(IniPath);\r
2669 }\r
2670 \r
2671 /*----- INIファイルのみを使うかどうかを返す -----------------------------------\r
2672 *\r
2673 *       Parameter\r
2674 *               なし\r
2675 *\r
2676 *       Return Value\r
2677 *               int ステータス : YES/NO\r
2678 *----------------------------------------------------------------------------*/\r
2679 \r
2680 int AskForceIni(void)\r
2681 {\r
2682         return(ForceIni);\r
2683 }\r
2684 \r
2685 \r
2686 \r
2687 \r
2688 /*----- メッセージ処理 --------------------------------------------------------\r
2689 *\r
2690 *       Parameter\r
2691 *               なし\r
2692 *\r
2693 *       Return Value\r
2694 *               int 終了フラグ (YES=WM_CLOSEが来た/NO)\r
2695 *----------------------------------------------------------------------------*/\r
2696 \r
2697 int BackgrndMessageProc(void)\r
2698 {\r
2699     MSG Msg;\r
2700         int Ret;\r
2701 \r
2702         Ret = NO;\r
2703         while(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE))\r
2704         {\r
2705                 if(!HtmlHelp(NULL, NULL, HH_PRETRANSLATEMESSAGE, (DWORD)&Msg))\r
2706                 {\r
2707                         /* ディレクトリ名の表示コンボボックスでBSやRETが効くように */\r
2708                         /* コンボボックス内ではアクセラレータを無効にする */\r
2709                         if((Msg.hwnd == GetLocalHistEditHwnd()) ||\r
2710                            (Msg.hwnd == GetRemoteHistEditHwnd()) ||\r
2711                            ((hHelpWin != NULL) && (Msg.hwnd == hHelpWin)) ||\r
2712                            GetHideUI() == YES ||\r
2713                            (TranslateAccelerator(GetMainHwnd(), Accel, &Msg) == 0))\r
2714                         {\r
2715                                 if(Msg.message == WM_QUIT)\r
2716                                 {\r
2717                                         Ret = YES;\r
2718                                         PostQuitMessage(0);\r
2719                                         break;\r
2720                                 }\r
2721                                 TranslateMessage(&Msg);\r
2722                                 DispatchMessage(&Msg);\r
2723                         }\r
2724                 }\r
2725         }\r
2726         return(Ret);\r
2727 }\r
2728 \r
2729 \r
2730 /*----- 自動終了フラグをクリアする --------------------------------------------\r
2731 *\r
2732 *       Parameter\r
2733 *               なし\r
2734 *\r
2735 *       Return Value\r
2736 *               なし\r
2737 *----------------------------------------------------------------------------*/\r
2738 \r
2739 void ResetAutoExitFlg(void)\r
2740 {\r
2741         AutoExit = NO;\r
2742         return;\r
2743 }\r
2744 \r
2745 \r
2746 /*----- 自動終了フラグを返す --------------------------------------------------\r
2747 *\r
2748 *       Parameter\r
2749 *               なし\r
2750 *\r
2751 *       Return Value\r
2752 *               int フラグ (YES/NO)\r
2753 *----------------------------------------------------------------------------*/\r
2754 \r
2755 int AskAutoExit(void)\r
2756 {\r
2757         return(AutoExit);\r
2758 }\r
2759 \r
2760 /*----- ユーザにパスワードを入力させ,それを設定する -----------------------\r
2761 *\r
2762 *       Parameter\r
2763 *               なし\r
2764 *\r
2765 *       Return Value\r
2766 *               int : 0/ユーザキャンセル, 1/設定した, 2/デフォルト設定\r
2767 *----------------------------------------------------------------------------*/\r
2768 int EnterMasterPasswordAndSet( int Res, HWND hWnd )\r
2769 {\r
2770         char buf[MAX_PASSWORD_LEN + 1];\r
2771         // パスワードの入力欄を非表示\r
2772         // 非表示にしたため新しいパスワードを2回入力させる\r
2773         char buf1[MAX_PASSWORD_LEN + 1];\r
2774         char *p;\r
2775         int Flag;\r
2776 \r
2777         buf[0] = NUL;\r
2778         if( InputDialogBox(Res, hWnd, NULL, buf, MAX_PASSWORD_LEN + 1,\r
2779                 &Flag, IDH_HELP_TOPIC_0000064) == YES){\r
2780                 // パスワードの入力欄を非表示\r
2781                 if(Res == newmasterpasswd_dlg)\r
2782                 {\r
2783                         buf1[0] = NUL;\r
2784                         if( InputDialogBox(Res, hWnd, NULL, buf1, MAX_PASSWORD_LEN + 1,\r
2785                                 &Flag, IDH_HELP_TOPIC_0000064) != YES){\r
2786                                 return 0;\r
2787                         }\r
2788                         if(strcmp(buf, buf1) != 0)\r
2789                         {\r
2790                                 MessageBox(hWnd, MSGJPN325, "FFFTP", MB_OK | MB_ICONERROR);\r
2791                                 return 0;\r
2792                         }\r
2793                 }\r
2794                 /* 末尾の空白を削除 */\r
2795                 RemoveTailingSpaces(buf);\r
2796                 /* 先頭の空白を削除 */\r
2797                 for( p = buf; *p == ' '; p++ )\r
2798                         ;\r
2799                 \r
2800                 if( p[0] != NUL ){\r
2801                         SetMasterPassword( p );\r
2802                         return 1;\r
2803                 }\r
2804                 else {\r
2805                         /* 空の場合はデフォルト値を設定 */\r
2806                         SetMasterPassword( NULL );\r
2807                         return 2;\r
2808                 }\r
2809         }\r
2810         return 0;\r
2811 }\r
2812 \r
2813 // 暗号化通信対応\r
2814 BOOL __stdcall SSLTimeoutCallback()\r
2815 {\r
2816         Sleep(1);\r
2817         if(BackgrndMessageProc() == YES)\r
2818                 return TRUE;\r
2819         // 念のためツールバーのMENU_ABORTも確認\r
2820 //      if(MainTransPkt.Abort != ABORT_NONE)\r
2821 //      {\r
2822 //              MainTransPkt.Abort = ABORT_NONE;\r
2823 //              return TRUE;\r
2824 //      }\r
2825         return FALSE;\r
2826 }\r
2827 \r
2828 BOOL __stdcall SSLConfirmCallback(BOOL bVerified, LPCSTR Certificate, LPCSTR CommonName)\r
2829 {\r
2830         BOOL bResult;\r
2831         char* pm0;\r
2832         bResult = FALSE;\r
2833         pm0 = NULL;\r
2834         if(pm0 = AllocateStringM(strlen(Certificate) + 1024))\r
2835         {\r
2836                 sprintf(pm0, MSGJPN326, IsHostNameMatched(AskHostAdrs(), CommonName) ? MSGJPN327 : MSGJPN328, bVerified ? MSGJPN327 : MSGJPN328, Certificate);\r
2837                 if(MessageBox(GetMainHwnd(), pm0, "FFFTP", MB_YESNO) == IDYES)\r
2838                         bResult = TRUE;\r
2839         }\r
2840         FreeDuplicatedString(pm0);\r
2841         return bResult;\r
2842 }\r
2843 \r