OSDN Git Service

Fix bugs of corruption on resuming downloading files larger than 4GB.
[ffftp/ffftp.git] / hostman.c
1 /*=============================================================================\r
2 *\r
3 *                                                               ホスト一覧\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 <commctrl.h>\r
36 #include <windowsx.h>\r
37 \r
38 #include "common.h"\r
39 #include "resource.h"\r
40 \r
41 #include <htmlhelp.h>\r
42 #include "helpid.h"\r
43 \r
44 // UTF-8対応\r
45 #undef __MBSWRAPPER_H__\r
46 #include "mbswrapper.h"\r
47 \r
48 \r
49 /*===== プロトタイプ =====*/\r
50 \r
51 static BOOL CALLBACK SelectHostProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);\r
52 static LRESULT CALLBACK HostListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);\r
53 static HOSTLISTDATA *GetNextNode(HOSTLISTDATA *Pos);\r
54 static int GetNodeLevel(int Num);\r
55 static int GetNodeLevelByData(HOSTLISTDATA *Data);\r
56 static int GetNodeNumByData(HOSTLISTDATA *Data);\r
57 static HOSTLISTDATA *GetNodeByNum(int Num);\r
58 static int SetNodeLevelAll(void);\r
59 static int UpdateHostToList(int Num, HOSTDATA *Set);\r
60 static int DelHostFromList(int Num);\r
61 static int DeleteChildAndNext(HOSTLISTDATA *Pos);\r
62 static void SendAllHostNames(HWND hWnd, int Cur);\r
63 static int IsNodeGroup(int Num);\r
64 static int DispHostSetDlg(HWND hDlg);\r
65 static BOOL CALLBACK MainSettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
66 static BOOL CALLBACK AdvSettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
67 static BOOL CALLBACK CodeSettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
68 static BOOL CALLBACK DialupSettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
69 static BOOL CALLBACK Adv2SettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
70 // 暗号化通信対応\r
71 static BOOL CALLBACK CryptSettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
72 // 同時接続対応\r
73 static BOOL CALLBACK Adv3SettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);\r
74 \r
75 /*===== 外部参照 =====*/\r
76 \r
77 extern HWND hHelpWin;\r
78 \r
79 /* 設定値 */\r
80 extern char UserMailAdrs[USER_MAIL_LEN+1];\r
81 extern HFONT ListFont;\r
82 extern char DefaultLocalPath[FMAX_PATH+1];\r
83 extern int ConnectAndSet;\r
84 extern SIZE HostDlgSize;\r
85 \r
86 /*===== ローカルなワーク =====*/\r
87 \r
88 static int Hosts = 0;                                           /* ホスト数 */\r
89 static int ConnectingHost;                                      /* 接続中のホスト */\r
90 static int CurrentHost;                                         /* カーソル位置のホスト */\r
91 static HOSTLISTDATA *HostListTop = NULL;        /* ホスト一覧データ */\r
92 static HOSTDATA TmpHost;                                        /* ホスト情報コピー用 */\r
93 static int Apply;                                                       /* プロパティシートでOKを押したフラグ */\r
94 static WNDPROC HostListProcPtr;\r
95 \r
96 \r
97 \r
98 /*----- ホスト一覧ウインドウ --------------------------------------------------\r
99 *\r
100 *       Parameter\r
101 *               int Type : ダイアログのタイプ (DLG_TYPE_xxx)\r
102 *\r
103 *       Return Value\r
104 *               ステータス (YES=実行/NO=取消)\r
105 *----------------------------------------------------------------------------*/\r
106 \r
107 int SelectHost(int Type)\r
108 {\r
109         int Sts;\r
110         int Dlg;\r
111 \r
112         Dlg = hostconnect_dlg;\r
113         if((ConnectAndSet == YES) || (Type == DLG_TYPE_SET))\r
114                 Dlg = hostlist_dlg;\r
115 \r
116         Sts = DialogBox(GetFtpInst(), MAKEINTRESOURCE(Dlg), GetMainHwnd(), SelectHostProc);\r
117 \r
118         /* ホスト設定を保存 */\r
119         SetNodeLevelAll();\r
120         SaveRegistory();\r
121 \r
122         return(Sts);\r
123 }\r
124 \r
125 \r
126 /*----- ホスト一覧ウインドウのコールバック ------------------------------------\r
127 *\r
128 *       Parameter\r
129 *               HWND hDlg : ウインドウハンドル\r
130 *               UINT message : メッセージ番号\r
131 *               WPARAM wParam : メッセージの WPARAM 引数\r
132 *               LPARAM lParam : メッセージの LPARAM 引数\r
133 *\r
134 *       Return Value\r
135 *               BOOL TRUE/FALSE\r
136 *----------------------------------------------------------------------------*/\r
137 \r
138 static BOOL CALLBACK SelectHostProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)\r
139 {\r
140         static DIALOGSIZE DlgSize = {\r
141                 { HOST_NEW, HOST_FOLDER, HOST_SET, HOST_COPY, HOST_DEL, HOST_DOWN, HOST_UP, IDHELP, HOST_SIZEGRIP, -1 },\r
142                 { IDOK, IDCANCEL, HOST_SIZEGRIP, -1 },\r
143                 { HOST_LIST, -1 },\r
144                 { 0, 0 },\r
145                 { 0, 0 }\r
146         };\r
147         static HIMAGELIST hImage;\r
148         HTREEITEM hItem;\r
149         TV_ITEM Item;\r
150         int Level1;\r
151         int Level2;\r
152         HOSTLISTDATA *Data1;\r
153         HOSTLISTDATA *Data2;\r
154         // UTF-8対応\r
155 //      NM_TREEVIEW *tView;\r
156         NM_TREEVIEWW *tView;\r
157         HTREEITEM tViewPos;\r
158         TV_HITTESTINFO HitInfo;\r
159 \r
160         switch (message)\r
161         {\r
162                 case WM_INITDIALOG :\r
163                         /* TreeViewでのダブルクリックをつかまえるため */\r
164                         HostListProcPtr = (WNDPROC)SetWindowLong(GetDlgItem(hDlg, HOST_LIST), GWL_WNDPROC, (LONG)HostListWndProc);\r
165 \r
166 \r
167 //              SetClassLong(hDlg, GCL_HICON, (LONG)LoadIcon(GetFtpInst(), MAKEINTRESOURCE(ffftp)));\r
168 \r
169                         if(AskConnecting() == YES)\r
170                         {\r
171                                 /* 接続中は「変更」のみ許可 */\r
172                                 EnableWindow(GetDlgItem(hDlg, HOST_NEW), FALSE);\r
173                                 EnableWindow(GetDlgItem(hDlg, HOST_FOLDER), FALSE);\r
174                                 EnableWindow(GetDlgItem(hDlg, HOST_COPY), FALSE);\r
175                                 EnableWindow(GetDlgItem(hDlg, HOST_DEL), FALSE);\r
176                                 EnableWindow(GetDlgItem(hDlg, HOST_DOWN), FALSE);\r
177                                 EnableWindow(GetDlgItem(hDlg, HOST_UP), FALSE);\r
178                         }\r
179                         if(ListFont != NULL)\r
180                                 SendDlgItemMessage(hDlg, HOST_LIST, WM_SETFONT, (WPARAM)ListFont, MAKELPARAM(TRUE, 0));\r
181                         hImage = ImageList_LoadBitmap(GetFtpInst(), MAKEINTRESOURCE(hlist_bmp), 16, 8, RGB(255,0,0));\r
182                         SendDlgItemMessage(hDlg, HOST_LIST, TVM_SETIMAGELIST, TVSIL_NORMAL, (LPARAM)hImage);\r
183                         CurrentHost = 0;\r
184                         if(ConnectingHost >= 0)\r
185                                 CurrentHost = ConnectingHost;\r
186                         SendAllHostNames(GetDlgItem(hDlg, HOST_LIST), CurrentHost);\r
187                         DlgSizeInit(hDlg, &DlgSize, &HostDlgSize);\r
188                     return(TRUE);\r
189 \r
190                 case WM_COMMAND :\r
191                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
192                         {\r
193                                 case IDOK :\r
194                                         if((hItem = (HTREEITEM)SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETNEXTITEM, TVGN_CARET, 0)) != NULL)\r
195                                         {\r
196                                                 Item.hItem = hItem;\r
197                                                 Item.mask = TVIF_PARAM;\r
198                                                 SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETITEM, TVGN_CARET, (LPARAM)&Item);\r
199                                                 CurrentHost = Item.lParam;\r
200                                                 ConnectingHost = CurrentHost;\r
201                                                 AskDlgSize(hDlg, &DlgSize, &HostDlgSize);\r
202                                                 ImageList_Destroy(hImage);\r
203                                                 EndDialog(hDlg, YES);\r
204                                                 break;\r
205                                         }\r
206                                         /* ここにbreakはない */\r
207 \r
208                                 case IDCANCEL :\r
209                                         AskDlgSize(hDlg, &DlgSize, &HostDlgSize);\r
210                                         ImageList_Destroy(hImage);\r
211                                         EndDialog(hDlg, NO);\r
212                                         break;\r
213 \r
214                                 case HOST_NEW :\r
215                                         CopyDefaultHost(&TmpHost);\r
216                                         if(DispHostSetDlg(hDlg) == YES)\r
217                                         {\r
218                                                 if((hItem = (HTREEITEM)SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETNEXTITEM, TVGN_CARET, 0)) != NULL)\r
219                                                 {\r
220                                                         Item.hItem = hItem;\r
221                                                         Item.mask = TVIF_PARAM;\r
222                                                         SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETITEM, TVGN_CARET, (LPARAM)&Item);\r
223 \r
224                                                         TmpHost.Level = GetNodeLevel(Item.lParam);\r
225                                                         Level1 = Item.lParam + 1;\r
226                                                         CurrentHost = Level1;\r
227                                                 }\r
228                                                 else\r
229                                                 {\r
230                                                         TmpHost.Level = 0;\r
231                                                         Level1 = -1;\r
232                                                         CurrentHost = Hosts;\r
233                                                 }\r
234                                                 AddHostToList(&TmpHost, Level1, SET_LEVEL_SAME);\r
235                                                 SendAllHostNames(GetDlgItem(hDlg, HOST_LIST), CurrentHost);\r
236                                         }\r
237                                         break;\r
238 \r
239                                 case HOST_FOLDER :\r
240                                         CopyDefaultHost(&TmpHost);\r
241                                         if(InputDialogBox(group_dlg, hDlg, NULL, TmpHost.HostName, HOST_NAME_LEN+1, &Level1, IDH_HELP_TOPIC_0000001) == YES)\r
242                                         {\r
243                                                 if((hItem = (HTREEITEM)SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETNEXTITEM, TVGN_CARET, 0)) != NULL)\r
244                                                 {\r
245                                                         Item.hItem = hItem;\r
246                                                         Item.mask = TVIF_PARAM;\r
247                                                         SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETITEM, TVGN_CARET, (LPARAM)&Item);\r
248 \r
249                                                         TmpHost.Level = GetNodeLevel(Item.lParam) | SET_LEVEL_GROUP ;\r
250                                                         Level1 = Item.lParam + 1;\r
251                                                         CurrentHost = Level1;\r
252                                                 }\r
253                                                 else\r
254                                                 {\r
255                                                         TmpHost.Level = 0 | SET_LEVEL_GROUP;\r
256                                                         Level1 = -1;\r
257                                                         CurrentHost = Hosts;\r
258                                                 }\r
259                                                 AddHostToList(&TmpHost, Level1, SET_LEVEL_SAME);\r
260                                                 SendAllHostNames(GetDlgItem(hDlg, HOST_LIST), CurrentHost);\r
261                                         }\r
262                                         break;\r
263 \r
264                                 case HOST_SET :\r
265                                         if((hItem = (HTREEITEM)SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETNEXTITEM, TVGN_CARET, 0)) != NULL)\r
266                                         {\r
267                                                 Item.hItem = hItem;\r
268                                                 Item.mask = TVIF_PARAM;\r
269                                                 SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETITEM, TVGN_CARET, (LPARAM)&Item);\r
270                                                 CurrentHost = Item.lParam;\r
271 \r
272                                                 CopyHostFromList(CurrentHost, &TmpHost);\r
273                                                 Level1 = IsNodeGroup(CurrentHost);\r
274                                                 if(((Level1 == NO) && (DispHostSetDlg(hDlg) == YES)) ||\r
275                                                    ((Level1 == YES) && (InputDialogBox(group_dlg, hDlg, NULL, TmpHost.HostName, HOST_NAME_LEN+1, &Level1, IDH_HELP_TOPIC_0000001) == YES)))\r
276                                                 {\r
277                                                         UpdateHostToList(CurrentHost, &TmpHost);\r
278                                                         SendAllHostNames(GetDlgItem(hDlg, HOST_LIST), CurrentHost);\r
279                                                 }\r
280                                         }\r
281                                         break;\r
282 \r
283                                 case HOST_COPY :\r
284                                         if((hItem = (HTREEITEM)SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETNEXTITEM, TVGN_CARET, 0)) != NULL)\r
285                                         {\r
286                                                 Item.hItem = hItem;\r
287                                                 Item.mask = TVIF_PARAM;\r
288                                                 SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETITEM, TVGN_CARET, (LPARAM)&Item);\r
289                                                 CurrentHost = Item.lParam;\r
290 \r
291                                                 CopyHostFromList(CurrentHost, &TmpHost);\r
292                                                 strcpy(TmpHost.BookMark, "\0");\r
293                                                 CurrentHost++;\r
294                                                 AddHostToList(&TmpHost, CurrentHost, SET_LEVEL_SAME);\r
295                                                 SendAllHostNames(GetDlgItem(hDlg, HOST_LIST), CurrentHost);\r
296                                         }\r
297                                         break;\r
298 \r
299                                 case HOST_DEL :\r
300                                         if((hItem = (HTREEITEM)SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETNEXTITEM, TVGN_CARET, 0)) != NULL)\r
301                                         {\r
302                                                 Item.hItem = hItem;\r
303                                                 Item.mask = TVIF_PARAM;\r
304                                                 SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETITEM, TVGN_CARET, (LPARAM)&Item);\r
305                                                 CurrentHost = Item.lParam;\r
306                                                 Level1 = IsNodeGroup(CurrentHost);\r
307 \r
308                                                 if(((Level1 == YES) && (DialogBox(GetFtpInst(), MAKEINTRESOURCE(groupdel_dlg), GetMainHwnd(), ExeEscDialogProc) == YES)) ||\r
309                                                    ((Level1 == NO) && (DialogBox(GetFtpInst(), MAKEINTRESOURCE(hostdel_dlg), GetMainHwnd(), ExeEscDialogProc) == YES)))\r
310                                                 {\r
311                                                         DelHostFromList(CurrentHost);\r
312                                                         if(CurrentHost >= Hosts)\r
313                                                                 CurrentHost = max1(0, Hosts-1);\r
314                                                         SendAllHostNames(GetDlgItem(hDlg, HOST_LIST), CurrentHost);\r
315                                                 }\r
316                                         }\r
317                                         break;\r
318 \r
319                                 case HOST_UP :\r
320                                         if((hItem = (HTREEITEM)SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETNEXTITEM, TVGN_CARET, 0)) != NULL)\r
321                                         {\r
322                                                 Item.hItem = hItem;\r
323                                                 Item.mask = TVIF_PARAM;\r
324                                                 SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETITEM, TVGN_CARET, (LPARAM)&Item);\r
325                                                 CurrentHost = Item.lParam;\r
326 \r
327                                                 if(CurrentHost > 0)\r
328                                                 {\r
329                                                         Data1 = HostListTop;\r
330                                                         for(Level1 = CurrentHost; Level1 > 0; Level1--)\r
331                                                                 Data1 = GetNextNode(Data1);\r
332                                                         Level1 = GetNodeLevel(CurrentHost);\r
333 \r
334                                                         Data2 = HostListTop;\r
335                                                         for(Level2 = CurrentHost-1; Level2 > 0; Level2--)\r
336                                                                 Data2 = GetNextNode(Data2);\r
337                                                         Level2 = GetNodeLevel(CurrentHost-1);\r
338 \r
339                                                         if((Level1 == Level2) && (Data2->Set.Level & SET_LEVEL_GROUP))\r
340                                                         {\r
341                                                                 //Data2のchildへ\r
342                                                                 if(Data1->Next != NULL)\r
343                                                                         Data1->Next->Prev = Data1->Prev;\r
344                                                                 if(Data1->Prev != NULL)\r
345                                                                         Data1->Prev->Next = Data1->Next;\r
346                                                                 if((Data1->Parent != NULL) && (Data1->Parent->Child == Data1))\r
347                                                                         Data1->Parent->Child = Data1->Next;\r
348                                                                 if((Data1->Parent == NULL) && (HostListTop == Data1))\r
349                                                                         HostListTop = Data1->Next;\r
350 \r
351                                                                 Data1->Next = Data2->Child;\r
352                                                                 Data1->Prev = NULL;\r
353                                                                 Data1->Parent = Data2;\r
354                                                                 Data2->Child = Data1;\r
355                                                         }\r
356                                                         else if(Level1 < Level2)\r
357                                                         {\r
358                                                                 //Data1のPrevのChildのNextの末尾へ\r
359                                                                 Data2 = Data1->Prev->Child;\r
360                                                                 while(Data2->Next != NULL)\r
361                                                                         Data2 = Data2->Next;\r
362 \r
363                                                                 if(Data1->Next != NULL)\r
364                                                                         Data1->Next->Prev = Data1->Prev;\r
365                                                                 if(Data1->Prev != NULL)\r
366                                                                         Data1->Prev->Next = Data1->Next;\r
367                                                                 if((Data1->Parent != NULL) && (Data1->Parent->Child == Data1))\r
368                                                                         Data1->Parent->Child = Data1->Next;\r
369                                                                 if((Data1->Parent == NULL) && (HostListTop == Data1))\r
370                                                                         HostListTop = Data1->Next;\r
371 \r
372                                                                 Data2->Next = Data1;\r
373                                                                 Data1->Prev = Data2;\r
374                                                                 Data1->Next = NULL;\r
375                                                                 Data1->Parent = Data2->Parent;\r
376                                                         }\r
377                                                         else\r
378                                                         {\r
379                                                                 //Data2のprevへ\r
380                                                                 if(Data1->Next != NULL)\r
381                                                                         Data1->Next->Prev = Data1->Prev;\r
382                                                                 if(Data1->Prev != NULL)\r
383                                                                         Data1->Prev->Next = Data1->Next;\r
384                                                                 if((Data1->Parent != NULL) && (Data1->Parent->Child == Data1))\r
385                                                                         Data1->Parent->Child = Data1->Next;\r
386                                                                 if((Data1->Parent == NULL) && (HostListTop == Data1))\r
387                                                                         HostListTop = Data1->Next;\r
388 \r
389                                                                 if(Data2->Prev != NULL)\r
390                                                                         Data2->Prev->Next = Data1;\r
391                                                                 Data1->Prev = Data2->Prev;\r
392                                                                 Data2->Prev = Data1;\r
393                                                                 Data1->Next = Data2;\r
394                                                                 Data1->Parent = Data2->Parent;\r
395 \r
396                                                                 if((Data1->Parent != NULL) && (Data1->Parent->Child == Data2))\r
397                                                                         Data1->Parent->Child = Data1;\r
398                                                                 if((Data1->Parent == NULL) && (HostListTop == Data2))\r
399                                                                         HostListTop = Data1;\r
400                                                         }\r
401 \r
402                                                         CurrentHost = GetNodeNumByData(Data1);\r
403                                                         SendAllHostNames(GetDlgItem(hDlg, HOST_LIST), CurrentHost);\r
404                                                 }\r
405                                         }\r
406                                         break;\r
407 \r
408                                 case HOST_DOWN :\r
409                                         if((hItem = (HTREEITEM)SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETNEXTITEM, TVGN_CARET, 0)) != NULL)\r
410                                         {\r
411                                                 Item.hItem = hItem;\r
412                                                 Item.mask = TVIF_PARAM;\r
413                                                 SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETITEM, TVGN_CARET, (LPARAM)&Item);\r
414                                                 CurrentHost = Item.lParam;\r
415 \r
416                                                 Data1 = HostListTop;\r
417                                                 for(Level1 = CurrentHost; Level1 > 0; Level1--)\r
418                                                         Data1 = GetNextNode(Data1);\r
419                                                 Level1 = GetNodeLevel(CurrentHost);\r
420 \r
421                                                 Data2 = NULL;\r
422                                                 Level2 = SET_LEVEL_SAME;\r
423                                                 if(CurrentHost < Hosts-1)\r
424                                                 {\r
425                                                         Data2 = HostListTop;\r
426                                                         for(Level2 = CurrentHost+1; Level2 > 0; Level2--)\r
427                                                                 Data2 = GetNextNode(Data2);\r
428                                                         Level2 = GetNodeLevel(CurrentHost+1);\r
429 \r
430                                                         if(Level1 < Level2)\r
431                                                         {\r
432                                                                 if(Data1->Next != NULL)\r
433                                                                 {\r
434                                                                         //Data2 = Data1のNext\r
435                                                                         Data2 = Data1->Next;\r
436                                                                         Level2 = GetNodeLevelByData(Data2);\r
437                                                                 }\r
438                                                                 else if(Data1->Parent != NULL)\r
439                                                                 {\r
440                                                                         Data2 = NULL;\r
441                                                                         Level2 = SET_LEVEL_SAME;\r
442                                                                 }\r
443                                                         }\r
444                                                 }\r
445 \r
446                                                 if(((Data2 == NULL) && (Level1 > 0)) ||\r
447                                                    (Level1 > Level2))\r
448                                                 {\r
449                                                         //Data1のParentのNextへ\r
450                                                         Data2 = Data1->Parent;\r
451 \r
452                                                         if(Data1->Next != NULL)\r
453                                                                 Data1->Next->Prev = Data1->Prev;\r
454                                                         if(Data1->Prev != NULL)\r
455                                                                 Data1->Prev->Next = Data1->Next;\r
456                                                         if((Data1->Parent != NULL) && (Data1->Parent->Child == Data1))\r
457                                                                 Data1->Parent->Child = Data1->Next;\r
458                                                         if((Data1->Parent == NULL) && (HostListTop == Data1))\r
459                                                                 HostListTop = Data1->Next;\r
460 \r
461                                                         if(Data2->Next != NULL)\r
462                                                                 Data2->Next->Prev = Data1;\r
463                                                         Data1->Next = Data2->Next;\r
464                                                         Data2->Next = Data1;\r
465                                                         Data1->Prev = Data2;\r
466                                                         Data1->Parent = Data2->Parent;\r
467 \r
468                                                         if((Data1->Parent != NULL) && (Data1->Parent->Child == Data1))\r
469                                                                 Data1->Parent->Child = Data2;\r
470                                                         if((Data1->Parent == NULL) && (HostListTop == Data1))\r
471                                                                 HostListTop = Data2;\r
472                                                 }\r
473                                                 else if(Level1 == Level2)\r
474                                                 {\r
475                                                         if(Data2->Set.Level & SET_LEVEL_GROUP)\r
476                                                         {\r
477                                                                 //Data2のChildへ\r
478                                                                 if(Data1->Next != NULL)\r
479                                                                         Data1->Next->Prev = Data1->Prev;\r
480                                                                 if(Data1->Prev != NULL)\r
481                                                                         Data1->Prev->Next = Data1->Next;\r
482                                                                 if((Data1->Parent != NULL) && (Data1->Parent->Child == Data1))\r
483                                                                         Data1->Parent->Child = Data1->Next;\r
484                                                                 if((Data1->Parent == NULL) && (HostListTop == Data1))\r
485                                                                         HostListTop = Data1->Next;\r
486 \r
487                                                                 if(Data2->Child != NULL)\r
488                                                                         Data2->Child->Prev = Data1;\r
489                                                                 Data1->Next = Data2->Child;\r
490                                                                 Data1->Prev = NULL;\r
491                                                                 Data1->Parent = Data2;\r
492                                                                 Data2->Child = Data1;\r
493                                                         }\r
494                                                         else\r
495                                                         {\r
496                                                                 //Data2のNextへ\r
497                                                                 if(Data1->Next != NULL)\r
498                                                                         Data1->Next->Prev = Data1->Prev;\r
499                                                                 if(Data1->Prev != NULL)\r
500                                                                         Data1->Prev->Next = Data1->Next;\r
501                                                                 if((Data1->Parent != NULL) && (Data1->Parent->Child == Data1))\r
502                                                                         Data1->Parent->Child = Data1->Next;\r
503                                                                 if((Data1->Parent == NULL) && (HostListTop == Data1))\r
504                                                                         HostListTop = Data1->Next;\r
505 \r
506                                                                 if(Data2->Next != NULL)\r
507                                                                         Data2->Next->Prev = Data1;\r
508                                                                 Data1->Next = Data2->Next;\r
509                                                                 Data2->Next = Data1;\r
510                                                                 Data1->Prev = Data2;\r
511                                                                 Data1->Parent = Data2->Parent;\r
512 \r
513                                                                 if((Data1->Parent != NULL) && (Data1->Parent->Child == Data1))\r
514                                                                         Data1->Parent->Child = Data2;\r
515                                                                 if((Data1->Parent == NULL) && (HostListTop == Data1))\r
516                                                                         HostListTop = Data2;\r
517                                                         }\r
518                                                 }\r
519 \r
520                                                 CurrentHost = GetNodeNumByData(Data1);\r
521                                                 SendAllHostNames(GetDlgItem(hDlg, HOST_LIST), CurrentHost);\r
522                                         }\r
523                                         break;\r
524 \r
525                                 case HOST_LIST :\r
526                                         if(HIWORD(wParam) == LBN_DBLCLK)\r
527                                                 PostMessage(hDlg, WM_COMMAND, MAKEWORD(IDOK, 0), 0);\r
528                                         break;\r
529 \r
530                                 case IDHELP :\r
531                                         hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000027);\r
532                                         break;\r
533                         }\r
534                         SetFocus(GetDlgItem(hDlg, HOST_LIST));\r
535                         return(TRUE);\r
536 \r
537                 case WM_SIZING :\r
538                         DlgSizeChange(hDlg, &DlgSize, (RECT *)lParam, (int)wParam);\r
539                     return(TRUE);\r
540 \r
541                 case WM_SELECT_HOST :\r
542                         HitInfo.pt.x = LOWORD(lParam);\r
543                         HitInfo.pt.y = HIWORD(lParam);\r
544                         HitInfo.flags = TVHT_ONITEM;\r
545                         hItem = (HTREEITEM)SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETNEXTITEM, TVGN_CARET, 0);\r
546                         HitInfo.hItem = hItem;\r
547                         if((HTREEITEM)SendMessage(GetDlgItem(hDlg, HOST_LIST), TVM_HITTEST, 0, (LPARAM)&HitInfo) == hItem)\r
548                         {\r
549                                 if(IsWindowEnabled(GetDlgItem(hDlg, IDOK)) == TRUE)\r
550                                         PostMessage(hDlg, WM_COMMAND, MAKEWPARAM(IDOK, 0), 0);\r
551                         }\r
552                         break;\r
553 \r
554                 case WM_NOTIFY:\r
555                         // UTF-8対応\r
556 //                      tView = (NM_TREEVIEW FAR *)lParam;\r
557                         tView = (NM_TREEVIEWW FAR *)lParam;\r
558                         switch(tView->hdr.idFrom)\r
559                         {\r
560                                 case HOST_LIST :\r
561                                         tViewPos = tView->itemNew.hItem;\r
562                                         hItem = tView->itemNew.hItem;\r
563                                         switch(tView->hdr.code)\r
564                                         {\r
565                                                 // UTF-8対応\r
566 //                                              case TVN_SELCHANGED :\r
567                                                 case TVN_SELCHANGEDW :\r
568                                                         /* フォルダが選ばれたときは接続、コピーボタンは禁止 */\r
569                                                         Item.hItem = hItem;\r
570                                                         Item.mask = TVIF_PARAM;\r
571                                                         SendDlgItemMessage(hDlg, HOST_LIST, TVM_GETITEM, TVGN_CARET, (LPARAM)&Item);\r
572                                                         if(IsNodeGroup(Item.lParam) == YES)\r
573                                                         {\r
574                                                                 EnableWindow(GetDlgItem(hDlg, IDOK), FALSE);\r
575                                                                 EnableWindow(GetDlgItem(hDlg, HOST_COPY), FALSE);\r
576                                                         }\r
577                                                         else\r
578                                                         {\r
579                                                                 EnableWindow(GetDlgItem(hDlg, IDOK), TRUE);\r
580                                                                 if(AskConnecting() == NO)\r
581                                                                         EnableWindow(GetDlgItem(hDlg, HOST_COPY), TRUE);\r
582                                                         }\r
583                                                         break;\r
584                                         }\r
585                                         break;\r
586                         }\r
587                         break;\r
588         }\r
589     return(FALSE);\r
590 }\r
591 \r
592 \r
593 /*----- ホスト一覧TreeViewのメッセージ処理 ------------------------------------\r
594 *\r
595 *       Parameter\r
596 *               HWND hWnd : ウインドウハンドル\r
597 *               UINT message  : メッセージ番号\r
598 *               WPARAM wParam : メッセージの WPARAM 引数\r
599 *               LPARAM lParam : メッセージの LPARAM 引数\r
600 *\r
601 *       Return Value\r
602 *               メッセージに対応する戻り値\r
603 *----------------------------------------------------------------------------*/\r
604 \r
605 static LRESULT CALLBACK HostListWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)\r
606 {\r
607         switch (message)\r
608         {\r
609                 case WM_LBUTTONDBLCLK :\r
610                         PostMessage(GetParent(hWnd), WM_SELECT_HOST, 0, lParam);\r
611                         break;\r
612         }\r
613         return(CallWindowProc(HostListProcPtr, hWnd, message, wParam, lParam));\r
614 }\r
615 \r
616 \r
617 /*----- 次の設定番号のノードを返す --------------------------------------------\r
618 *\r
619 *       Parameter\r
620 *               HOSTLISTDATA *Pos : ノードデータ\r
621 *\r
622 *       Return Value\r
623 *               HOSTLISTDATA *次のノード\r
624 *                       NULL=次はない\r
625 *----------------------------------------------------------------------------*/\r
626 \r
627 static HOSTLISTDATA *GetNextNode(HOSTLISTDATA *Pos)\r
628 {\r
629         HOSTLISTDATA *Ret;\r
630 \r
631         Ret = NULL;\r
632         if(Pos->Child != NULL)\r
633                 Ret = Pos->Child;\r
634         else\r
635         {\r
636                 if(Pos->Next != NULL)\r
637                         Ret = Pos->Next;\r
638                 else\r
639                 {\r
640                         while(Pos->Parent != NULL)\r
641                         {\r
642                                 Pos = Pos->Parent;\r
643                                 if(Pos->Next != NULL)\r
644                                 {\r
645                                         Ret = Pos->Next;\r
646                                         break;\r
647                                 }\r
648                         }\r
649                 }\r
650         }\r
651         return(Ret);\r
652 }\r
653 \r
654 \r
655 /*----- ノードのレベル数を返す(設定番号指定) --------------------------------\r
656 *\r
657 *       Parameter\r
658 *               int Num : 設定値号番号\r
659 *\r
660 *       Return Value\r
661 *               int レベル数 (-1=設定がない)\r
662 *----------------------------------------------------------------------------*/\r
663 \r
664 static int GetNodeLevel(int Num)\r
665 {\r
666         int Ret;\r
667         HOSTLISTDATA *Pos;\r
668 \r
669         Ret = -1;\r
670         if((Num >= 0) && (Num < Hosts))\r
671         {\r
672                 Pos = GetNodeByNum(Num);\r
673                 Ret = 0;\r
674                 while(Pos->Parent != NULL)\r
675                 {\r
676                         Pos = Pos->Parent;\r
677                         Ret++;\r
678                 }\r
679         }\r
680         return(Ret);\r
681 }\r
682 \r
683 \r
684 /*----- ノードのレベル数を返す(ノードデータ指定)-----------------------------\r
685 *\r
686 *       Parameter\r
687 *               HOSTLISTDATA *Data : 設定値\r
688 *\r
689 *       Return Value\r
690 *               int レベル数\r
691 *----------------------------------------------------------------------------*/\r
692 \r
693 static int GetNodeLevelByData(HOSTLISTDATA *Data)\r
694 {\r
695         int Ret;\r
696 \r
697         Ret = 0;\r
698         while(Data->Parent != NULL)\r
699         {\r
700                 Data = Data->Parent;\r
701                 Ret++;\r
702         }\r
703         return(Ret);\r
704 }\r
705 \r
706 \r
707 /*----- ノードの設定番号を返す ------------------------------------------------\r
708 *\r
709 *       Parameter\r
710 *               HOSTLISTDATA *Data : 設定値\r
711 *\r
712 *       Return Value\r
713 *               int 設定番号\r
714 *----------------------------------------------------------------------------*/\r
715 \r
716 static int GetNodeNumByData(HOSTLISTDATA *Data)\r
717 {\r
718         int Ret;\r
719         HOSTLISTDATA *Pos;\r
720 \r
721         Ret = 0;\r
722         Pos = HostListTop;\r
723         while(Pos != Data)\r
724         {\r
725                 Pos = GetNextNode(Pos);\r
726                 Ret++;\r
727         }\r
728         return(Ret);\r
729 }\r
730 \r
731 \r
732 /*----- 指定番号のノードを返す ------------------------------------------------\r
733 *\r
734 *       Parameter\r
735 *               int Num : 設定番号\r
736 *\r
737 *       Return Value\r
738 *               HOSTLISTDATA * : 設定値\r
739 *----------------------------------------------------------------------------*/\r
740 \r
741 static HOSTLISTDATA *GetNodeByNum(int Num)\r
742 {\r
743         HOSTLISTDATA *Pos;\r
744 \r
745         Pos = HostListTop;\r
746         for(; Num > 0; Num--)\r
747                 Pos = GetNextNode(Pos);\r
748 \r
749         return(Pos);\r
750 }\r
751 \r
752 \r
753 /*----- 設定値リストの各ノードのレベル番号をセット ----------------------------\r
754 *\r
755 *       Parameter\r
756 *               int Num : 設定番号\r
757 *\r
758 *       Return Value\r
759 *               HOSTLISTDATA * : 設定値\r
760 *----------------------------------------------------------------------------*/\r
761 \r
762 static int SetNodeLevelAll(void)\r
763 {\r
764         HOSTLISTDATA *Pos;\r
765         int i;\r
766 \r
767         Pos = HostListTop;\r
768         for(i = 0; i < Hosts; i++)\r
769         {\r
770                 Pos->Set.Level &= ~SET_LEVEL_MASK;\r
771                 Pos->Set.Level |= GetNodeLevelByData(Pos);\r
772                 Pos = GetNextNode(Pos);\r
773         }\r
774         return(FFFTP_SUCCESS);\r
775 }\r
776 \r
777 \r
778 /*----- 設定値リストに追加 ----------------------------------------------------\r
779 *\r
780 *       Parameter\r
781 *               HOSTDATA *Set : 追加する設定値\r
782 *               int Pos : 追加する位置 (0~ : -1=最後)\r
783 *               int Level : レベル数 (SET_LEVEL_SAME=追加位置のものと同レベル)\r
784 *\r
785 *       Return Value\r
786 *               int ステータス\r
787 *                       FFFTP_SUCCESS/FFFTP_FAIL\r
788 *----------------------------------------------------------------------------*/\r
789 \r
790 int AddHostToList(HOSTDATA *Set, int Pos, int Level)\r
791 {\r
792         int Sts;\r
793         HOSTLISTDATA *New;\r
794         HOSTLISTDATA *Last;\r
795         int Cur;\r
796 \r
797         Sts = FFFTP_FAIL;\r
798         if((Pos >= -1) && (Pos <= Hosts))\r
799         {\r
800                 if(Pos == -1)\r
801                         Pos = Hosts;\r
802                 Level &= SET_LEVEL_MASK;\r
803 \r
804                 if((New = malloc(sizeof(HOSTLISTDATA))) != NULL)\r
805                 {\r
806                         memcpy(&New->Set, Set, sizeof(HOSTDATA));\r
807                         New->Next = NULL;\r
808                         New->Prev = NULL;\r
809                         New->Child = NULL;\r
810                         New->Parent = NULL;\r
811 \r
812                         if(HostListTop == NULL)\r
813                         {\r
814                                 if(Pos == 0)\r
815                                         HostListTop = New;\r
816                         }\r
817                         else\r
818                         {\r
819                                 if(Pos == 0)\r
820                                 {\r
821                                         New->Next = HostListTop;\r
822                                         HostListTop = New;\r
823                                 }\r
824                                 else\r
825                                 {\r
826                                         Cur = GetNodeLevel(Pos-1);\r
827                                         Last = HostListTop;\r
828                                         for(Pos--; Pos > 0; Pos--)\r
829                                                 Last = GetNextNode(Last);\r
830                                         if((Level != SET_LEVEL_SAME) && (Level > Cur))\r
831                                         {\r
832                                                 New->Next = Last->Child;\r
833                                                 New->Parent = Last;\r
834                                                 Last->Child = New;\r
835                                                 if(New->Next != NULL)\r
836                                                         New->Next->Prev = New;\r
837                                         }\r
838                                         else\r
839                                         {\r
840                                                 if((Level >= 0) && (Level < SET_LEVEL_SAME))\r
841                                                 {\r
842                                                         for(; Level < Cur; Cur--)\r
843                                                                 Last = Last->Parent;\r
844                                                 }\r
845                                                 New->Prev = Last;\r
846                                                 New->Next = Last->Next;\r
847                                                 New->Parent = Last->Parent;\r
848                                                 Last->Next = New;\r
849                                                 if(New->Next != NULL)\r
850                                                         New->Next->Prev = New;\r
851                                         }\r
852                                 }\r
853                         }\r
854                         Hosts++;\r
855                         Sts = FFFTP_SUCCESS;\r
856                 }\r
857         }\r
858         return(Sts);\r
859 }\r
860 \r
861 \r
862 /*----- 設定値リストを更新する ------------------------------------------------\r
863 *\r
864 *       Parameter\r
865 *               int Num : 設定値号番号\r
866 *               HOSTDATA *Set : 設定値をコピーするワーク\r
867 *\r
868 *       Return Value\r
869 *               int ステータス\r
870 *                       FFFTP_SUCCESS/FFFTP_FAIL\r
871 *----------------------------------------------------------------------------*/\r
872 \r
873 static int UpdateHostToList(int Num, HOSTDATA *Set)\r
874 {\r
875         int Sts;\r
876         HOSTLISTDATA *Pos;\r
877 \r
878         Sts = FFFTP_FAIL;\r
879         if((Num >= 0) && (Num < Hosts))\r
880         {\r
881                 Pos = GetNodeByNum(Num);\r
882                 memcpy(&Pos->Set, Set, sizeof(HOSTDATA));\r
883                 Sts = FFFTP_SUCCESS;\r
884         }\r
885         return(Sts);\r
886 }\r
887 \r
888 \r
889 /*----- 設定値リストから削除 --------------------------------------------------\r
890 *\r
891 *       Parameter\r
892 *               int Num : 削除する番号\r
893 *\r
894 *       Return Value\r
895 *               int ステータス\r
896 *                       FFFTP_SUCCESS/FFFTP_FAIL\r
897 *----------------------------------------------------------------------------*/\r
898 \r
899 static int DelHostFromList(int Num)\r
900 {\r
901         int Sts;\r
902         HOSTLISTDATA *Pos;\r
903 \r
904         Sts = FFFTP_FAIL;\r
905         if((Num >= 0) && (Num < Hosts))\r
906         {\r
907                 if(Num == 0)\r
908                 {\r
909                         Pos = HostListTop;\r
910                         if(Pos->Child != NULL)\r
911                                 DeleteChildAndNext(Pos->Child);\r
912                         HostListTop = Pos->Next;\r
913                 }\r
914                 else\r
915                 {\r
916                         Pos = GetNodeByNum(Num);\r
917                         if(Pos->Child != NULL)\r
918                                 DeleteChildAndNext(Pos->Child);\r
919 \r
920                         if(Pos->Next != NULL)\r
921                                 Pos->Next->Prev = Pos->Prev;\r
922                         if(Pos->Prev != NULL)\r
923                                 Pos->Prev->Next = Pos->Next;\r
924                         if((Pos->Parent != NULL) && (Pos->Parent->Child == Pos))\r
925                                 Pos->Parent->Child = Pos->Next;\r
926                 }\r
927                 free(Pos);\r
928                 Hosts--;\r
929                 Sts = FFFTP_SUCCESS;\r
930         }\r
931         return(Sts);\r
932 }\r
933 \r
934 \r
935 /*----- 設定値リストからノードデータを削除 ------------------------------------\r
936 *\r
937 *       Parameter\r
938 *               HOSTLISTDATA *Pos : 削除するノード\r
939 *\r
940 *       Return Value\r
941 *               int ステータス\r
942 *                       FFFTP_SUCCESS/FFFTP_FAIL\r
943 *\r
944 *       Note\r
945 *               Pos->Next, Pos->Childの全てのノードを削除する\r
946 *----------------------------------------------------------------------------*/\r
947 \r
948 static int DeleteChildAndNext(HOSTLISTDATA *Pos)\r
949 {\r
950         HOSTLISTDATA *Next;\r
951 \r
952         while(Pos != NULL)\r
953         {\r
954                 if(Pos->Child != NULL)\r
955                         DeleteChildAndNext(Pos->Child);\r
956 \r
957                 Next = Pos->Next;\r
958                 free(Pos);\r
959                 Hosts--;\r
960                 Pos = Next;\r
961         }\r
962         return(FFFTP_SUCCESS);\r
963 }\r
964 \r
965 \r
966 /*----- 設定値リストから設定値を取り出す --------------------------------------\r
967 *\r
968 *       Parameter\r
969 *               int Num : 設定値号番号\r
970 *               HOSTDATA *Set : 設定値をコピーするワーク\r
971 *\r
972 *       Return Value\r
973 *               int ステータス\r
974 *                       FFFTP_SUCCESS/FFFTP_FAIL\r
975 *\r
976 *       Note\r
977 *               現在ホストに接続中の時は、CopyHostFromListInConnect() を使う事\r
978 *----------------------------------------------------------------------------*/\r
979 \r
980 int CopyHostFromList(int Num, HOSTDATA *Set)\r
981 {\r
982         int Sts;\r
983         HOSTLISTDATA *Pos;\r
984 \r
985         Sts = FFFTP_FAIL;\r
986         if((Num >= 0) && (Num < Hosts))\r
987         {\r
988                 Pos = GetNodeByNum(Num);\r
989                 memcpy(Set, &Pos->Set, sizeof(HOSTDATA));\r
990                 Sts = FFFTP_SUCCESS;\r
991         }\r
992         return(Sts);\r
993 }\r
994 \r
995 \r
996 /*----- 設定値リストから設定値を取り出す --------------------------------------\r
997 *\r
998 *       Parameter\r
999 *               int Num : 設定値号番号\r
1000 *               HOSTDATA *Set : 設定値をコピーするワーク\r
1001 *\r
1002 *       Return Value\r
1003 *               int ステータス\r
1004 *                       FFFTP_SUCCESS/FFFTP_FAIL\r
1005 *\r
1006 *       Note\r
1007 *               現在ホストに接続中の時に使う\r
1008 *----------------------------------------------------------------------------*/\r
1009 \r
1010 int CopyHostFromListInConnect(int Num, HOSTDATA *Set)\r
1011 {\r
1012         int Sts;\r
1013         HOSTLISTDATA *Pos;\r
1014 \r
1015         Sts = FFFTP_FAIL;\r
1016         if((Num >= 0) && (Num < Hosts))\r
1017         {\r
1018                 Pos = GetNodeByNum(Num);\r
1019                 strcpy(Set->ChmodCmd, Pos->Set.ChmodCmd);\r
1020                 Set->Port = Pos->Set.Port;\r
1021                 Set->Anonymous = Pos->Set.Anonymous;\r
1022                 Set->KanjiCode = Pos->Set.KanjiCode;\r
1023                 Set->KanaCnv = Pos->Set.KanaCnv;\r
1024                 Set->NameKanjiCode = Pos->Set.NameKanjiCode;\r
1025                 Set->NameKanaCnv = Pos->Set.NameKanaCnv;\r
1026                 Set->Pasv = Pos->Set.Pasv;\r
1027                 Set->FireWall = Pos->Set.FireWall;\r
1028                 Set->ListCmdOnly = Pos->Set.ListCmdOnly;\r
1029                 Set->UseNLST_R = Pos->Set.UseNLST_R;\r
1030                 Set->LastDir = Pos->Set.LastDir;\r
1031                 Set->TimeZone = Pos->Set.TimeZone;\r
1032                 // 暗号化通信対応\r
1033                 Set->UseNoEncryption = Pos->Set.UseNoEncryption;\r
1034                 Set->UseFTPES = Pos->Set.UseFTPES;\r
1035                 Set->UseFTPIS = Pos->Set.UseFTPIS;\r
1036                 Set->UseSFTP = Pos->Set.UseSFTP;\r
1037                 // 同時接続対応\r
1038                 Set->MaxThreadCount = Pos->Set.MaxThreadCount;\r
1039                 // MLSD対応\r
1040                 Set->UseMLSD = Pos->Set.UseMLSD;\r
1041                 // IPv6対応\r
1042                 Set->UseIPv6 = Pos->Set.UseIPv6;\r
1043                 Sts = FFFTP_SUCCESS;\r
1044         }\r
1045         return(Sts);\r
1046 }\r
1047 \r
1048 \r
1049 /*----- 設定値リストのブックマークを更新 --------------------------------------\r
1050 *\r
1051 *       Parameter\r
1052 *               int Num : 設定値号番号\r
1053 *               char *Bmask : ブックマーク文字列\r
1054 *               int Len : ブックマーク文字列の長さ\r
1055 *\r
1056 *       Return Value\r
1057 *               int ステータス\r
1058 *                       FFFTP_SUCCESS/FFFTP_FAIL\r
1059 *----------------------------------------------------------------------------*/\r
1060 \r
1061 int SetHostBookMark(int Num, char *Bmask, int Len)\r
1062 {\r
1063         int Sts;\r
1064         HOSTLISTDATA *Pos;\r
1065 \r
1066         Sts = FFFTP_FAIL;\r
1067         if((Num >= 0) && (Num < Hosts))\r
1068         {\r
1069                 Pos = GetNodeByNum(Num);\r
1070                 memcpy(Pos->Set.BookMark, Bmask, Len);\r
1071                 Sts = FFFTP_SUCCESS;\r
1072         }\r
1073         return(Sts);\r
1074 }\r
1075 \r
1076 \r
1077 /*----- 設定値リストのブックマーク文字列を返す --------------------------------\r
1078 *\r
1079 *       Parameter\r
1080 *               int Num : 設定値号番号\r
1081 *\r
1082 *       Return Value\r
1083 *               char *ブックマーク文字列\r
1084 *----------------------------------------------------------------------------*/\r
1085 \r
1086 char *AskHostBookMark(int Num)\r
1087 {\r
1088         char *Ret;\r
1089         HOSTLISTDATA *Pos;\r
1090 \r
1091         Ret = NULL;\r
1092         if((Num >= 0) && (Num < Hosts))\r
1093         {\r
1094                 Pos = GetNodeByNum(Num);\r
1095                 Ret = Pos->Set.BookMark;\r
1096         }\r
1097         return(Ret);\r
1098 }\r
1099 \r
1100 \r
1101 /*----- 設定値リストのディレクトリを更新 --------------------------------------\r
1102 *\r
1103 *       Parameter\r
1104 *               int Num : 設定値号番号\r
1105 *               char *LocDir : ローカルのディレクトリ\r
1106 *               char *HostDir : ホストのディレクトリ\r
1107 *\r
1108 *       Return Value\r
1109 *               int ステータス\r
1110 *                       FFFTP_SUCCESS/FFFTP_FAIL\r
1111 *----------------------------------------------------------------------------*/\r
1112 \r
1113 int SetHostDir(int Num, char *LocDir, char *HostDir)\r
1114 {\r
1115         int Sts;\r
1116         HOSTLISTDATA *Pos;\r
1117 \r
1118         Sts = FFFTP_FAIL;\r
1119         if((Num >= 0) && (Num < Hosts))\r
1120         {\r
1121                 Pos = GetNodeByNum(Num);\r
1122                 strcpy(Pos->Set.LocalInitDir, LocDir);\r
1123                 strcpy(Pos->Set.RemoteInitDir, HostDir);\r
1124                 Sts = FFFTP_SUCCESS;\r
1125         }\r
1126         return(Sts);\r
1127 }\r
1128 \r
1129 \r
1130 /*----- 設定値リストのパスワードを更新 ----------------------------------------\r
1131 *\r
1132 *       Parameter\r
1133 *               int Num : 設定値号番号\r
1134 *               char *Pass : パスワード\r
1135 *\r
1136 *       Return Value\r
1137 *               int ステータス\r
1138 *                       FFFTP_SUCCESS/FFFTP_FAIL\r
1139 *----------------------------------------------------------------------------*/\r
1140 \r
1141 int SetHostPassword(int Num, char *Pass)\r
1142 {\r
1143         int Sts;\r
1144         HOSTLISTDATA *Pos;\r
1145 \r
1146         Sts = FFFTP_FAIL;\r
1147         if((Num >= 0) && (Num < Hosts))\r
1148         {\r
1149                 Pos = GetNodeByNum(Num);\r
1150                 strcpy(Pos->Set.PassWord, Pass);\r
1151                 Sts = FFFTP_SUCCESS;\r
1152         }\r
1153         return(Sts);\r
1154 }\r
1155 \r
1156 \r
1157 /*----- 指定の設定名を持つ設定の番号を返す ------------------------------------\r
1158 *\r
1159 *       Parameter\r
1160 *               char *Name : 設定名\r
1161 *\r
1162 *       Return Value\r
1163 *               int 設定番号 (0~)\r
1164 *                       -1=見つからない\r
1165 *----------------------------------------------------------------------------*/\r
1166 \r
1167 int SearchHostName(char *Name)\r
1168 {\r
1169         int Ret;\r
1170         int i;\r
1171         HOSTLISTDATA *Pos;\r
1172 \r
1173         Ret = -1;\r
1174         Pos = HostListTop;\r
1175         for(i = 0; i < Hosts; i++)\r
1176         {\r
1177                 if(strcmp(Name, Pos->Set.HostName) == 0)\r
1178                 {\r
1179                         Ret = i;\r
1180                         break;\r
1181                 }\r
1182                 Pos = GetNextNode(Pos);\r
1183         }\r
1184         return(Ret);\r
1185 }\r
1186 \r
1187 \r
1188 /*----- 設定値リストのソート方法を更新 ----------------------------------------\r
1189 *\r
1190 *       Parameter\r
1191 *               int Num : 設定値号番号\r
1192 *               int LFSort : ローカルのファイルのソート方法\r
1193 *               int LDSort : ローカルのフォルダのソート方法\r
1194 *               int RFSort : リモートのファイルのソート方法\r
1195 *               int RDSort : リモートのフォルダのソート方法\r
1196 *\r
1197 *       Return Value\r
1198 *               int ステータス\r
1199 *                       FFFTP_SUCCESS/FFFTP_FAIL\r
1200 *----------------------------------------------------------------------------*/\r
1201 \r
1202 int SetHostSort(int Num, int LFSort, int LDSort, int RFSort, int RDSort)\r
1203 {\r
1204         int Sts;\r
1205         HOSTLISTDATA *Pos;\r
1206 \r
1207         Sts = FFFTP_FAIL;\r
1208         if((Num >= 0) && (Num < Hosts))\r
1209         {\r
1210                 Pos = GetNodeByNum(Num);\r
1211                 Pos->Set.Sort = LFSort * 0x1000000 | LDSort * 0x10000 | RFSort * 0x100 | RDSort;\r
1212                 Sts = FFFTP_SUCCESS;\r
1213         }\r
1214         return(Sts);\r
1215 }\r
1216 \r
1217 \r
1218 /*----- 登録されているソート方法を分解する ------------------------------------\r
1219 *\r
1220 *       Parameter\r
1221 *               ulong Sort : ソート方法 \r
1222 *               int *LFSort : ローカルのファイルのソート方法を格納するワーク\r
1223 *               int *LDSort : ローカルのフォルダのソート方法を格納するワーク\r
1224 *               int *RFSort : リモートのファイルのソート方法を格納するワーク\r
1225 *               int *RDSort : リモートのフォルダのソート方法を格納するワーク\r
1226 *\r
1227 *       Return Value\r
1228 *               なし\r
1229 *----------------------------------------------------------------------------*/\r
1230 \r
1231 void DecomposeSortType(ulong Sort, int *LFSort, int *LDSort, int *RFSort, int *RDSort)\r
1232 {\r
1233         *LFSort = (int)((Sort / 0x1000000) & 0xFF);\r
1234         *LDSort = (int)((Sort / 0x10000) & 0xFF);\r
1235         *RFSort = (int)((Sort / 0x100) & 0xFF);\r
1236         *RDSort = (int)(Sort & 0xFF);\r
1237         return;\r
1238 }\r
1239 \r
1240 \r
1241 /*----- 現在接続中の設定番号を返す --------------------------------------------\r
1242 *\r
1243 *       Parameter\r
1244 *               なし\r
1245 *\r
1246 *       Return Value\r
1247 *               int 設定番号\r
1248 *----------------------------------------------------------------------------*/\r
1249 \r
1250 int AskCurrentHost(void)\r
1251 {\r
1252         return(ConnectingHost);\r
1253 }\r
1254 \r
1255 \r
1256 /*----- 現在接続中の設定番号をセットする --------------------------------------\r
1257 *\r
1258 *       Parameter\r
1259 *               int Num : 設定番号\r
1260 *\r
1261 *       Return Value\r
1262 *               なし\r
1263 *----------------------------------------------------------------------------*/\r
1264 \r
1265 void SetCurrentHost(int Num)\r
1266 {\r
1267         ConnectingHost = Num;\r
1268         return;\r
1269 }\r
1270 \r
1271 \r
1272 /*----- デフォルト設定値を取り出す --------------------------------------------\r
1273 *\r
1274 *       Parameter\r
1275 *               HOSTDATA *Set : 設定値をコピーするワーク\r
1276 *\r
1277 *       Return Value\r
1278 *               なし\r
1279 *----------------------------------------------------------------------------*/\r
1280 \r
1281 void CopyDefaultHost(HOSTDATA *Set)\r
1282 {\r
1283         Set->Level = 0;\r
1284         strcpy(Set->HostName, "");\r
1285         strcpy(Set->HostAdrs, "");\r
1286         strcpy(Set->UserName, "");\r
1287         strcpy(Set->PassWord, "");\r
1288         strcpy(Set->Account, "");\r
1289         strcpy(Set->LocalInitDir, DefaultLocalPath);\r
1290         strcpy(Set->RemoteInitDir, "");\r
1291         memcpy(Set->BookMark, "\0\0", 2);\r
1292         strcpy(Set->ChmodCmd, CHMOD_CMD_NOR);\r
1293         strcpy(Set->LsName, LS_FNAME);\r
1294         strcpy(Set->InitCmd, "");\r
1295         Set->Port = PORT_NOR;\r
1296         Set->Anonymous = NO;\r
1297         Set->KanjiCode = KANJI_NOCNV;\r
1298         Set->KanaCnv = YES;\r
1299         Set->NameKanjiCode = KANJI_NOCNV;\r
1300         Set->NameKanaCnv = NO;\r
1301         Set->Pasv = YES;\r
1302         Set->FireWall = NO;\r
1303         Set->ListCmdOnly = YES;\r
1304         Set->UseNLST_R = YES;\r
1305         Set->LastDir = NO;\r
1306         Set->TimeZone = 9;                              /* GMT+9 (JST) */\r
1307         Set->HostType = HTYPE_AUTO;\r
1308         Set->SyncMove = NO;\r
1309         Set->NoFullPath = NO;\r
1310         Set->Sort = SORT_NOTSAVED;\r
1311         Set->Security = SECURITY_AUTO;\r
1312         Set->Dialup = NO;\r
1313         Set->DialupAlways = NO;\r
1314         Set->DialupNotify = YES;\r
1315         strcpy(Set->DialEntry, "");\r
1316         // 暗号化通信対応\r
1317         Set->CryptMode = CRYPT_NONE;\r
1318         Set->UseNoEncryption = YES;\r
1319         Set->UseFTPES = YES;\r
1320         Set->UseFTPIS = YES;\r
1321         Set->UseSFTP = YES;\r
1322         strcpy(Set->PrivateKey, "");\r
1323         // 同時接続対応\r
1324         Set->MaxThreadCount = 1;\r
1325         // MLSD対応\r
1326         Set->Feature = 0;\r
1327         Set->UseMLSD = YES;\r
1328         // IPv6対応\r
1329         Set->UseIPv6 = YES;\r
1330         return;\r
1331 }\r
1332 \r
1333 \r
1334 /*----- 設定名一覧をウィンドウに送る ------------------------------------------\r
1335 *\r
1336 *       Parameter\r
1337 *               HWND hWnd : ウインドウハンドル\r
1338 *               int Cur : \r
1339 *\r
1340 *       Return Value\r
1341 *               なし\r
1342 *----------------------------------------------------------------------------*/\r
1343 \r
1344 static void SendAllHostNames(HWND hWnd, int Cur)\r
1345 {\r
1346         int i;\r
1347         HOSTLISTDATA *Pos;\r
1348         TV_INSERTSTRUCT tvIns;\r
1349         HTREEITEM hItem;\r
1350         HTREEITEM hItemCur;\r
1351         HTREEITEM *Level;\r
1352         int CurLevel;\r
1353 \r
1354         hItemCur = NULL;\r
1355 \r
1356         /* ちらつくので再描画禁止 */\r
1357         SendMessage(hWnd, WM_SETREDRAW, (WPARAM)FALSE, 0);\r
1358 \r
1359         SendMessage(hWnd, TVM_DELETEITEM, 0, (LPARAM)TVI_ROOT);         /* 全てを削除 */\r
1360 \r
1361         if((Level = malloc(sizeof(HTREEITEM*) * Hosts + 1)) != NULL)\r
1362         {\r
1363                 Pos = HostListTop;\r
1364                 for(i = 0; i < Hosts; i++)\r
1365                 {\r
1366                         if(Pos->Set.Level & SET_LEVEL_GROUP)\r
1367                         {\r
1368                                 tvIns.item.iImage = 0;\r
1369                                 tvIns.item.iSelectedImage = 0;\r
1370                         }\r
1371                         else\r
1372                         {\r
1373                                 tvIns.item.iImage = 2;\r
1374                                 tvIns.item.iSelectedImage = 2;\r
1375                         }\r
1376 \r
1377                         CurLevel = GetNodeLevel(i);\r
1378                         if(CurLevel == 0)\r
1379                                 tvIns.hParent = TVI_ROOT;\r
1380                         else\r
1381                                 tvIns.hParent = Level[CurLevel - 1];\r
1382 \r
1383                         tvIns.hInsertAfter = TVI_LAST;\r
1384                         tvIns.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN;\r
1385         //              tvIns.item.hItem = 0;\r
1386         //              tvIns.item.state = 0;\r
1387         //              tvIns.item.stateMask = 0;\r
1388                         tvIns.item.pszText = Pos->Set.HostName;\r
1389                         tvIns.item.cchTextMax = 0;\r
1390                         tvIns.item.cChildren = 1;\r
1391                         tvIns.item.lParam = i;\r
1392                         hItem = (HTREEITEM)SendMessage(hWnd, TVM_INSERTITEM, 0, (LPARAM)&tvIns);\r
1393 \r
1394                         if(Pos->Set.Level & SET_LEVEL_GROUP)\r
1395                                 Level[CurLevel] = hItem;\r
1396 \r
1397 //                      DoPrintf("%d = %x", i, hItem);\r
1398                         if(i == Cur)\r
1399                         {\r
1400                                 hItemCur = hItem;\r
1401                         }\r
1402                         Pos = GetNextNode(Pos);\r
1403                 }\r
1404                 free(Level);\r
1405         }\r
1406 \r
1407         /* 再描画 */\r
1408         SendMessage(hWnd, WM_SETREDRAW, (WPARAM)TRUE, 0);\r
1409 \r
1410         if(hItemCur != NULL)\r
1411         {\r
1412                 SendMessage(hWnd, TVM_SELECTITEM, TVGN_CARET, (LPARAM)hItemCur);\r
1413 //              SendMessage(hWnd, TVM_ENSUREVISIBLE, 0, (LPARAM)hItemCur);\r
1414         }\r
1415         UpdateWindow(hWnd);\r
1416 \r
1417         return;\r
1418 }\r
1419 \r
1420 \r
1421 /*----- 設定値がグループかどうかを返す ----------------------------------------\r
1422 *\r
1423 *       Parameter\r
1424 *               int Num : 設定値号番号\r
1425 *\r
1426 *       Return Value\r
1427 *               int グループかどうか\r
1428 *                       YES/NO/-1=設定値がない\r
1429 *----------------------------------------------------------------------------*/\r
1430 \r
1431 static int IsNodeGroup(int Num)\r
1432 {\r
1433         int Ret;\r
1434         HOSTLISTDATA *Pos;\r
1435 \r
1436         Ret = -1;\r
1437         if((Num >= 0) && (Num < Hosts))\r
1438         {\r
1439                 Pos = GetNodeByNum(Num);\r
1440                 Ret = (Pos->Set.Level & SET_LEVEL_GROUP) ? YES : NO;\r
1441         }\r
1442         return(Ret);\r
1443 }\r
1444 \r
1445 \r
1446 /*----- WS_FTP.INIからのインポート --------------------------------------------\r
1447 *\r
1448 *       Parameter\r
1449 *               なし\r
1450 *\r
1451 *       Return Value\r
1452 *               なし\r
1453 *----------------------------------------------------------------------------*/\r
1454 \r
1455 void ImportFromWSFTP(void)\r
1456 {\r
1457         FILE *Strm;\r
1458         char Buf[FMAX_PATH+1];\r
1459         HOSTDATA Host;\r
1460         int InHost;\r
1461 \r
1462         strcpy(Buf, "WS_FTP.INI");\r
1463         if(SelectFile(GetMainHwnd(), Buf, MSGJPN126, MSGJPN276, NULL, OFN_FILEMUSTEXIST, 0) == TRUE)\r
1464         {\r
1465                 if((Strm = fopen(Buf, "rt")) != NULL)\r
1466                 {\r
1467                         InHost = NO;\r
1468                         while(fgets(Buf, FMAX_PATH, Strm) != NULL)\r
1469                         {\r
1470                                 if(Buf[0] == '[')\r
1471                                 {\r
1472                                         if(InHost == YES)\r
1473                                         {\r
1474                                                 AddHostToList(&Host, -1, 0);\r
1475                                                 InHost = NO;\r
1476                                         }\r
1477                                         if(_stricmp(Buf, "[_config_]\n") != 0)\r
1478                                         {\r
1479                                                 CopyDefaultHost(&Host);\r
1480 \r
1481                                                 *(Buf + strlen(Buf) - 2) = NUL;\r
1482                                                 memset(Host.HostName, NUL, HOST_NAME_LEN+1);\r
1483                                                 strncpy(Host.HostName, Buf+1, HOST_NAME_LEN);\r
1484                                                 InHost = YES;\r
1485                                         }\r
1486                                 }\r
1487                                 else if(InHost == YES)\r
1488                                 {\r
1489                                         FormatIniString(Buf);\r
1490 \r
1491                                         if(_strnicmp(Buf, "HOST=", 5) == 0)\r
1492                                         {\r
1493                                                 memset(Host.HostAdrs, NUL, HOST_ADRS_LEN+1);\r
1494                                                 strncpy(Host.HostAdrs, Buf+5, HOST_ADRS_LEN);\r
1495                                         }\r
1496                                         else if(_strnicmp(Buf, "UID=", 4) == 0)\r
1497                                         {\r
1498                                                 memset(Host.UserName, NUL, USER_NAME_LEN+1);\r
1499                                                 strncpy(Host.UserName, Buf+4, USER_NAME_LEN);\r
1500                                                 if(strcmp(Host.UserName, "anonymous") == 0)\r
1501                                                         strcpy(Host.PassWord, UserMailAdrs);\r
1502                                         }\r
1503                                         else if(_strnicmp(Buf, "LOCDIR=", 7) == 0)\r
1504                                         {\r
1505                                                 memset(Host.LocalInitDir, NUL, INIT_DIR_LEN+1);\r
1506                                                 strncpy(Host.LocalInitDir, Buf+7, INIT_DIR_LEN);\r
1507                                         }\r
1508                                         else if(_strnicmp(Buf, "DIR=", 4) == 0)\r
1509                                         {\r
1510                                                 memset(Host.RemoteInitDir, NUL, INIT_DIR_LEN+1);\r
1511                                                 strncpy(Host.RemoteInitDir, Buf+4, INIT_DIR_LEN);\r
1512                                         }\r
1513                                         else if(_strnicmp(Buf, "PASVMODE=", 9) == 0)\r
1514                                                 Host.Pasv = (atoi(Buf+9) == 0) ? 0 : 1;\r
1515                                         else if(_strnicmp(Buf, "FIREWALL=", 9) == 0)\r
1516                                                 Host.FireWall = (atoi(Buf+9) == 0) ? 0 : 1;\r
1517                                 }\r
1518                         }\r
1519 \r
1520                         if(InHost == YES)\r
1521                                 AddHostToList(&Host, -1, 0);\r
1522                         fclose(Strm);\r
1523                 }\r
1524         }\r
1525         return;\r
1526 }\r
1527 \r
1528 \r
1529 \r
1530 /*----- ホスト設定のプロパティシート ------------------------------------------\r
1531 *\r
1532 *       Parameter\r
1533 *               HWND hDlg : 親ウインドウのハンドル\r
1534 *\r
1535 *       Return Value\r
1536 *               なし\r
1537 *----------------------------------------------------------------------------*/\r
1538 \r
1539 static int DispHostSetDlg(HWND hDlg)\r
1540 {\r
1541         // SFTP、FTPES、FTPIS対応\r
1542         // 同時接続対応\r
1543 //      PROPSHEETPAGE psp[5];\r
1544         PROPSHEETPAGE psp[7];\r
1545         PROPSHEETHEADER psh;\r
1546 \r
1547         // 変数が未初期化のバグ修正\r
1548         memset(&psp, 0, sizeof(psp));\r
1549         memset(&psh, 0, sizeof(psh));\r
1550 \r
1551         psp[0].dwSize = sizeof(PROPSHEETPAGE);\r
1552         psp[0].dwFlags = PSP_USETITLE | PSP_HASHELP;\r
1553         psp[0].hInstance = GetFtpInst();\r
1554         psp[0].pszTemplate = MAKEINTRESOURCE(hset_main_dlg);\r
1555         psp[0].pszIcon = NULL;\r
1556         psp[0].pfnDlgProc = MainSettingProc;\r
1557         psp[0].pszTitle = MSGJPN127;\r
1558         psp[0].lParam = 0;\r
1559         psp[0].pfnCallback = NULL;\r
1560 \r
1561         psp[1].dwSize = sizeof(PROPSHEETPAGE);\r
1562         psp[1].dwFlags = PSP_USETITLE | PSP_HASHELP;\r
1563         psp[1].hInstance = GetFtpInst();\r
1564         psp[1].pszTemplate = MAKEINTRESOURCE(hset_adv_dlg);\r
1565         psp[1].pszIcon = NULL;\r
1566         psp[1].pfnDlgProc = AdvSettingProc;\r
1567         psp[1].pszTitle = MSGJPN128;\r
1568         psp[1].lParam = 0;\r
1569         psp[1].pfnCallback = NULL;\r
1570 \r
1571         psp[2].dwSize = sizeof(PROPSHEETPAGE);\r
1572         psp[2].dwFlags = PSP_USETITLE | PSP_HASHELP;\r
1573         psp[2].hInstance = GetFtpInst();\r
1574         psp[2].pszTemplate = MAKEINTRESOURCE(hset_code_dlg);\r
1575         psp[2].pszIcon = NULL;\r
1576         psp[2].pfnDlgProc = CodeSettingProc;\r
1577         psp[2].pszTitle = MSGJPN129;\r
1578         psp[2].lParam = 0;\r
1579         psp[2].pfnCallback = NULL;\r
1580 \r
1581         psp[3].dwSize = sizeof(PROPSHEETPAGE);\r
1582         psp[3].dwFlags = PSP_USETITLE | PSP_HASHELP;\r
1583         psp[3].hInstance = GetFtpInst();\r
1584         psp[3].pszTemplate = MAKEINTRESOURCE(hset_dialup_dlg);\r
1585         psp[3].pszIcon = NULL;\r
1586         psp[3].pfnDlgProc = DialupSettingProc;\r
1587         psp[3].pszTitle = MSGJPN130;\r
1588         psp[3].lParam = 0;\r
1589         psp[3].pfnCallback = NULL;\r
1590 \r
1591         psp[4].dwSize = sizeof(PROPSHEETPAGE);\r
1592         psp[4].dwFlags = PSP_USETITLE | PSP_HASHELP;\r
1593         psp[4].hInstance = GetFtpInst();\r
1594         psp[4].pszTemplate = MAKEINTRESOURCE(hset_adv2_dlg);\r
1595         psp[4].pszIcon = NULL;\r
1596         psp[4].pfnDlgProc = Adv2SettingProc;\r
1597         psp[4].pszTitle = MSGJPN131;\r
1598         psp[4].lParam = 0;\r
1599         psp[4].pfnCallback = NULL;\r
1600 \r
1601         // SFTP、FTPES、FTPIS対応\r
1602         psp[5].dwSize = sizeof(PROPSHEETPAGE);\r
1603         psp[5].dwFlags = PSP_USETITLE | PSP_HASHELP;\r
1604         psp[5].hInstance = GetFtpInst();\r
1605         psp[5].pszTemplate = MAKEINTRESOURCE(hset_crypt_dlg);\r
1606         psp[5].pszIcon = NULL;\r
1607         psp[5].pfnDlgProc = CryptSettingProc;\r
1608         psp[5].pszTitle = MSGJPN313;\r
1609         psp[5].lParam = 0;\r
1610         psp[5].pfnCallback = NULL;\r
1611 \r
1612         // 同時接続対応\r
1613         psp[6].dwSize = sizeof(PROPSHEETPAGE);\r
1614         psp[6].dwFlags = PSP_USETITLE | PSP_HASHELP;\r
1615         psp[6].hInstance = GetFtpInst();\r
1616         psp[6].pszTemplate = MAKEINTRESOURCE(hset_adv3_dlg);\r
1617         psp[6].pszIcon = NULL;\r
1618         psp[6].pfnDlgProc = Adv3SettingProc;\r
1619         psp[6].pszTitle = MSGJPN320;\r
1620         psp[6].lParam = 0;\r
1621         psp[6].pfnCallback = NULL;\r
1622 \r
1623         psh.dwSize = sizeof(PROPSHEETHEADER);\r
1624         psh.dwFlags = PSH_HASHELP | PSH_NOAPPLYNOW | PSH_PROPSHEETPAGE;\r
1625         psh.hwndParent = hDlg;\r
1626         psh.hInstance = GetFtpInst();\r
1627         psh.pszIcon = NULL;\r
1628         psh.pszCaption = MSGJPN132;\r
1629         psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);\r
1630         psh.nStartPage = 0;\r
1631         psh.ppsp = (LPCPROPSHEETPAGE)&psp;\r
1632         psh.pfnCallback = NULL;\r
1633 \r
1634         Apply = NO;\r
1635         PropertySheet(&psh);\r
1636 \r
1637         return(Apply);\r
1638 }\r
1639 \r
1640 \r
1641 /*----- 基本設定ウインドウのコールバック --------------------------------------\r
1642 *\r
1643 *       Parameter\r
1644 *               HWND hDlg : ウインドウハンドル\r
1645 *               UINT message : メッセージ番号\r
1646 *               WPARAM wParam : メッセージの WPARAM 引数\r
1647 *               LPARAM lParam : メッセージの LPARAM 引数\r
1648 *\r
1649 *       Return Value\r
1650 *               BOOL TRUE/FALSE\r
1651 *----------------------------------------------------------------------------*/\r
1652 \r
1653 static BOOL CALLBACK MainSettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
1654 {\r
1655         long wStyle;\r
1656         char Tmp[FMAX_PATH+1];\r
1657         NMHDR *pnmhdr;\r
1658 \r
1659         switch (iMessage)\r
1660         {\r
1661                 case WM_INITDIALOG :\r
1662                         SendDlgItemMessage(hDlg, HSET_HOST, EM_LIMITTEXT, HOST_NAME_LEN, 0);\r
1663                         SendDlgItemMessage(hDlg, HSET_ADRS, EM_LIMITTEXT, HOST_ADRS_LEN, 0);\r
1664                         SendDlgItemMessage(hDlg, HSET_USER, EM_LIMITTEXT, USER_NAME_LEN, 0);\r
1665                         SendDlgItemMessage(hDlg, HSET_PASS, EM_LIMITTEXT, PASSWORD_LEN, 0);\r
1666                         SendDlgItemMessage(hDlg, HSET_LOCAL, EM_LIMITTEXT, INIT_DIR_LEN, 0);\r
1667                         SendDlgItemMessage(hDlg, HSET_REMOTE, EM_LIMITTEXT, INIT_DIR_LEN, 0);\r
1668                         SendDlgItemMessage(hDlg, HSET_HOST, WM_SETTEXT, 0, (LPARAM)TmpHost.HostName);\r
1669                         SendDlgItemMessage(hDlg, HSET_ADRS, WM_SETTEXT, 0, (LPARAM)TmpHost.HostAdrs);\r
1670                         SendDlgItemMessage(hDlg, HSET_USER, WM_SETTEXT, 0, (LPARAM)TmpHost.UserName);\r
1671                         SendDlgItemMessage(hDlg, HSET_PASS, WM_SETTEXT, 0, (LPARAM)TmpHost.PassWord);\r
1672                         SendDlgItemMessage(hDlg, HSET_LOCAL, WM_SETTEXT, 0, (LPARAM)TmpHost.LocalInitDir);\r
1673                         SendDlgItemMessage(hDlg, HSET_REMOTE, WM_SETTEXT, 0, (LPARAM)TmpHost.RemoteInitDir);\r
1674                         SendDlgItemMessage(hDlg, HSET_ANONYMOUS, BM_SETCHECK, TmpHost.Anonymous, 0);\r
1675                         SendDlgItemMessage(hDlg, HSET_LASTDIR, BM_SETCHECK, TmpHost.LastDir, 0);\r
1676                         if(AskConnecting() == NO)\r
1677                                 EnableWindow(GetDlgItem(hDlg, HSET_REMOTE_CUR), FALSE);\r
1678                         return(TRUE);\r
1679 \r
1680                 case WM_NOTIFY:\r
1681                         pnmhdr = (NMHDR FAR *)lParam;\r
1682                         switch(pnmhdr->code)\r
1683                         {\r
1684                                 case PSN_APPLY :\r
1685                                         SendDlgItemMessage(hDlg, HSET_HOST, WM_GETTEXT, HOST_NAME_LEN+1, (LPARAM)TmpHost.HostName);\r
1686                                         SendDlgItemMessage(hDlg, HSET_ADRS, WM_GETTEXT, HOST_ADRS_LEN+1, (LPARAM)TmpHost.HostAdrs);\r
1687                                         RemoveTailingSpaces(TmpHost.HostAdrs);\r
1688                                         SendDlgItemMessage(hDlg, HSET_USER, WM_GETTEXT, USER_NAME_LEN+1, (LPARAM)TmpHost.UserName);\r
1689                                         SendDlgItemMessage(hDlg, HSET_PASS, WM_GETTEXT, PASSWORD_LEN+1, (LPARAM)TmpHost.PassWord);\r
1690                                         SendDlgItemMessage(hDlg, HSET_LOCAL, WM_GETTEXT, INIT_DIR_LEN+1, (LPARAM)TmpHost.LocalInitDir);\r
1691                                         SendDlgItemMessage(hDlg, HSET_REMOTE, WM_GETTEXT, INIT_DIR_LEN+1, (LPARAM)TmpHost.RemoteInitDir);\r
1692                                         TmpHost.Anonymous = SendDlgItemMessage(hDlg, HSET_ANONYMOUS, BM_GETCHECK, 0, 0);\r
1693                                         TmpHost.LastDir = SendDlgItemMessage(hDlg, HSET_LASTDIR, BM_GETCHECK, 0, 0);\r
1694                                         if((strlen(TmpHost.HostName) == 0) && (strlen(TmpHost.HostAdrs) > 0))\r
1695                                         {\r
1696                                                 memset(TmpHost.HostName, NUL, HOST_NAME_LEN+1);\r
1697                                                 strncpy(TmpHost.HostName, TmpHost.HostAdrs, HOST_NAME_LEN);\r
1698                                         }\r
1699                                         else if((strlen(TmpHost.HostName) > 0) && (strlen(TmpHost.HostAdrs) == 0))\r
1700                                         {\r
1701                                                 memset(TmpHost.HostAdrs, NUL, HOST_ADRS_LEN+1);\r
1702                                                 strncpy(TmpHost.HostAdrs, TmpHost.HostName, HOST_ADRS_LEN);\r
1703                                         }\r
1704                                         Apply = YES;\r
1705                                         break;\r
1706 \r
1707                                 case PSN_RESET :\r
1708                                         break;\r
1709 \r
1710                                 case PSN_HELP :\r
1711                                         hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000028);\r
1712                                         break;\r
1713                         }\r
1714                         break;\r
1715 \r
1716                 case WM_COMMAND :\r
1717                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
1718                         {\r
1719                                 case HSET_LOCAL_BR :\r
1720                                         if(SelectDir(hDlg, TmpHost.LocalInitDir, INIT_DIR_LEN) == TRUE)\r
1721                                                 SendDlgItemMessage(hDlg, HSET_LOCAL, WM_SETTEXT, 0, (LPARAM)TmpHost.LocalInitDir);\r
1722                                         break;\r
1723 \r
1724                                 case HSET_REMOTE_CUR :\r
1725                                                 AskRemoteCurDir(Tmp, FMAX_PATH);\r
1726                                                 SendDlgItemMessage(hDlg, HSET_REMOTE, WM_SETTEXT, 0, (LPARAM)Tmp);\r
1727                                         break;\r
1728 \r
1729                                 case HSET_ANONYMOUS :\r
1730                                         if(SendDlgItemMessage(hDlg, HSET_ANONYMOUS, BM_GETCHECK, 0, 0) == 1)\r
1731                                         {\r
1732                                                 SendDlgItemMessage(hDlg, HSET_USER, WM_SETTEXT, 0, (LPARAM)"anonymous");\r
1733                                                 wStyle = GetWindowLong(GetDlgItem(hDlg, HSET_PASS), GWL_STYLE);\r
1734                                                 wStyle &= ~ES_PASSWORD;\r
1735                                                 SetWindowLong(GetDlgItem(hDlg, HSET_PASS), GWL_STYLE, wStyle);\r
1736                                                 SendDlgItemMessage(hDlg, HSET_PASS, WM_SETTEXT, 0, (LPARAM)UserMailAdrs);\r
1737                                         }\r
1738                                         else\r
1739                                         {\r
1740                                                 SendDlgItemMessage(hDlg, HSET_USER, WM_SETTEXT, 0, (LPARAM)"");\r
1741                                                 wStyle = GetWindowLong(GetDlgItem(hDlg, HSET_PASS), GWL_STYLE);\r
1742                                                 wStyle |= ES_PASSWORD;\r
1743                                                 SetWindowLong(GetDlgItem(hDlg, HSET_PASS), GWL_STYLE, wStyle);\r
1744                                                 SendDlgItemMessage(hDlg, HSET_PASS, WM_SETTEXT, 0, (LPARAM)"");\r
1745                                         }\r
1746                                         break;\r
1747                         }\r
1748             return(TRUE);\r
1749         }\r
1750         return(FALSE);\r
1751 }\r
1752 \r
1753 \r
1754 /*----- 拡張設定ウインドウのコールバック --------------------------------------\r
1755 *\r
1756 *       Parameter\r
1757 *               HWND hDlg : ウインドウハンドル\r
1758 *               UINT message : メッセージ番号\r
1759 *               WPARAM wParam : メッセージの WPARAM 引数\r
1760 *               LPARAM lParam : メッセージの LPARAM 引数\r
1761 *\r
1762 *       Return Value\r
1763 *               BOOL TRUE/FALSE\r
1764 *----------------------------------------------------------------------------*/\r
1765 \r
1766 static BOOL CALLBACK AdvSettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
1767 {\r
1768         NMHDR *pnmhdr;\r
1769         char Tmp[20];\r
1770         int i;\r
1771 \r
1772         switch (iMessage)\r
1773         {\r
1774                 case WM_INITDIALOG :\r
1775                         SendDlgItemMessage(hDlg, HSET_PORT, EM_LIMITTEXT, 5, 0);\r
1776                         sprintf(Tmp, "%d", TmpHost.Port);\r
1777                         SendDlgItemMessage(hDlg, HSET_PORT, WM_SETTEXT, 0, (LPARAM)Tmp);\r
1778                         SendDlgItemMessage(hDlg, HSET_ACCOUNT, EM_LIMITTEXT, ACCOUNT_LEN, 0);\r
1779                         SendDlgItemMessage(hDlg, HSET_ACCOUNT, WM_SETTEXT, 0, (LPARAM)TmpHost.Account);\r
1780                         SendDlgItemMessage(hDlg, HSET_PASV, BM_SETCHECK, TmpHost.Pasv, 0);\r
1781                         SendDlgItemMessage(hDlg, HSET_FIREWALL, BM_SETCHECK, TmpHost.FireWall, 0);\r
1782                         SendDlgItemMessage(hDlg, HSET_SYNCMOVE, BM_SETCHECK, TmpHost.SyncMove, 0);\r
1783                         for(i = -12; i <= 12; i++)\r
1784                         {\r
1785                                 if(i == 0)\r
1786                                         sprintf(Tmp, "GMT");\r
1787                                 else if(i == 9)\r
1788                                         sprintf(Tmp, MSGJPN133, i);\r
1789                                 else\r
1790                                         sprintf(Tmp, "GMT%+02d:00", i);\r
1791                                 SendDlgItemMessage(hDlg, HSET_TIMEZONE, CB_ADDSTRING, 0, (LPARAM)Tmp);\r
1792                         }\r
1793                         SendDlgItemMessage(hDlg, HSET_TIMEZONE, CB_SETCURSEL, TmpHost.TimeZone+12, 0);\r
1794 \r
1795                         SendDlgItemMessage(hDlg, HSET_SECURITY, CB_ADDSTRING, 0, (LPARAM)MSGJPN134);\r
1796                         SendDlgItemMessage(hDlg, HSET_SECURITY, CB_ADDSTRING, 0, (LPARAM)MSGJPN135);\r
1797                         SendDlgItemMessage(hDlg, HSET_SECURITY, CB_ADDSTRING, 0, (LPARAM)MSGJPN136);\r
1798                         SendDlgItemMessage(hDlg, HSET_SECURITY, CB_ADDSTRING, 0, (LPARAM)MSGJPN137);\r
1799                         SendDlgItemMessage(hDlg, HSET_SECURITY, CB_ADDSTRING, 0, (LPARAM)MSGJPN138);\r
1800                         SendDlgItemMessage(hDlg, HSET_SECURITY, CB_SETCURSEL, TmpHost.Security, 0);\r
1801                         SendDlgItemMessage(hDlg, HSET_INITCMD, EM_LIMITTEXT, INITCMD_LEN, 0);\r
1802                         SendDlgItemMessage(hDlg, HSET_INITCMD, WM_SETTEXT, 0, (LPARAM)TmpHost.InitCmd);\r
1803                         return(TRUE);\r
1804 \r
1805                 case WM_NOTIFY:\r
1806                         pnmhdr = (NMHDR FAR *)lParam;\r
1807                         switch(pnmhdr->code)\r
1808                         {\r
1809                                 case PSN_APPLY :\r
1810                                         TmpHost.Pasv = SendDlgItemMessage(hDlg, HSET_PASV, BM_GETCHECK, 0, 0);\r
1811                                         TmpHost.FireWall = SendDlgItemMessage(hDlg, HSET_FIREWALL, BM_GETCHECK, 0, 0);\r
1812                                         TmpHost.SyncMove = SendDlgItemMessage(hDlg, HSET_SYNCMOVE, BM_GETCHECK, 0, 0);\r
1813                                         SendDlgItemMessage(hDlg, HSET_PORT, WM_GETTEXT, 5+1, (LPARAM)Tmp);\r
1814                                         TmpHost.Port = atoi(Tmp);\r
1815                                         SendDlgItemMessage(hDlg, HSET_ACCOUNT, WM_GETTEXT, ACCOUNT_LEN+1, (LPARAM)TmpHost.Account);\r
1816                                         TmpHost.TimeZone = SendDlgItemMessage(hDlg, HSET_TIMEZONE, CB_GETCURSEL, 0, 0) - 12;\r
1817                                         TmpHost.Security = SendDlgItemMessage(hDlg, HSET_SECURITY, CB_GETCURSEL, 0, 0);\r
1818                                         SendDlgItemMessage(hDlg, HSET_INITCMD, WM_GETTEXT, INITCMD_LEN+1, (LPARAM)TmpHost.InitCmd);\r
1819                                         Apply = YES;\r
1820                                         break;\r
1821 \r
1822                                 case PSN_RESET :\r
1823                                         break;\r
1824 \r
1825                                 case PSN_HELP :\r
1826                                         hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000029);\r
1827                                         break;\r
1828                         }\r
1829                         break;\r
1830 \r
1831                 case WM_COMMAND :\r
1832                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
1833                         {\r
1834                                 case HSET_PORT_NOR :\r
1835                                         sprintf(Tmp, "%d", PORT_NOR);\r
1836                                         SendDlgItemMessage(hDlg, HSET_PORT, WM_SETTEXT, 0, (LPARAM)Tmp);\r
1837                                         break;\r
1838                         }\r
1839                         return(TRUE);\r
1840         }\r
1841         return(FALSE);\r
1842 }\r
1843 \r
1844 \r
1845 /*----- 文字コード設定ウインドウのコールバック --------------------------------\r
1846 *\r
1847 *       Parameter\r
1848 *               HWND hDlg : ウインドウハンドル\r
1849 *               UINT message : メッセージ番号\r
1850 *               WPARAM wParam : メッセージの WPARAM 引数\r
1851 *               LPARAM lParam : メッセージの LPARAM 引数\r
1852 *\r
1853 *       Return Value\r
1854 *               BOOL TRUE/FALSE\r
1855 *----------------------------------------------------------------------------*/\r
1856 \r
1857 static BOOL CALLBACK CodeSettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
1858 {\r
1859         NMHDR *pnmhdr;\r
1860 \r
1861         // UTF-8対応\r
1862         static const RADIOBUTTON KanjiButton[] = {\r
1863                 { HSET_NO_CNV, KANJI_NOCNV },\r
1864                 { HSET_SJIS_CNV, KANJI_SJIS },\r
1865                 { HSET_JIS_CNV, KANJI_JIS },\r
1866                 { HSET_EUC_CNV, KANJI_EUC },\r
1867                 { HSET_UTF8N_CNV, KANJI_UTF8N }\r
1868         };\r
1869         #define KANJIBUTTONS    (sizeof(KanjiButton)/sizeof(RADIOBUTTON))\r
1870 \r
1871         static const RADIOBUTTON NameKanjiButton[] = {\r
1872                 { HSET_FN_AUTO_CNV, KANJI_AUTO },\r
1873                 { HSET_FN_SJIS_CNV, KANJI_SJIS },\r
1874                 { HSET_FN_JIS_CNV, KANJI_JIS },\r
1875                 { HSET_FN_EUC_CNV, KANJI_EUC },\r
1876                 { HSET_FN_SMH_CNV, KANJI_SMB_HEX },\r
1877                 { HSET_FN_SMC_CNV, KANJI_SMB_CAP },\r
1878                 { HSET_FN_UTF8N_CNV, KANJI_UTF8N }              // UTF-8対応\r
1879         };\r
1880         #define NAMEKANJIBUTTONS        (sizeof(NameKanjiButton)/sizeof(RADIOBUTTON))\r
1881 \r
1882         switch (iMessage)\r
1883         {\r
1884                 case WM_INITDIALOG :\r
1885                         SetRadioButtonByValue(hDlg, TmpHost.KanjiCode, KanjiButton, KANJIBUTTONS);\r
1886                         SendDlgItemMessage(hDlg, HSET_HANCNV, BM_SETCHECK, TmpHost.KanaCnv, 0);\r
1887                         SetRadioButtonByValue(hDlg, TmpHost.NameKanjiCode, NameKanjiButton, NAMEKANJIBUTTONS);\r
1888                         SendDlgItemMessage(hDlg, HSET_FN_HANCNV, BM_SETCHECK, TmpHost.NameKanaCnv, 0);\r
1889                         return(TRUE);\r
1890 \r
1891                 case WM_NOTIFY:\r
1892                         pnmhdr = (NMHDR FAR *)lParam;\r
1893                         switch(pnmhdr->code)\r
1894                         {\r
1895                                 case PSN_APPLY :\r
1896                                         TmpHost.KanjiCode = AskRadioButtonValue(hDlg, KanjiButton, KANJIBUTTONS);\r
1897                                         TmpHost.KanaCnv = SendDlgItemMessage(hDlg, HSET_HANCNV, BM_GETCHECK, 0, 0);\r
1898                                         TmpHost.NameKanjiCode = AskRadioButtonValue(hDlg, NameKanjiButton, NAMEKANJIBUTTONS);\r
1899                                         TmpHost.NameKanaCnv = SendDlgItemMessage(hDlg, HSET_FN_HANCNV, BM_GETCHECK, 0, 0);\r
1900                                         Apply = YES;\r
1901                                         break;\r
1902 \r
1903                                 case PSN_RESET :\r
1904                                         break;\r
1905 \r
1906                                 case PSN_HELP :\r
1907                                         hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000030);\r
1908                                         break;\r
1909                         }\r
1910                         break;\r
1911 \r
1912                 case WM_COMMAND :\r
1913                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
1914                         {\r
1915                                 case HSET_JIS_CNV :\r
1916                                 case HSET_EUC_CNV :\r
1917                                         EnableWindow(GetDlgItem(hDlg, HSET_HANCNV), TRUE);\r
1918                                         break;\r
1919 \r
1920                                 // UTF-8対応\r
1921                                 case HSET_NO_CNV :\r
1922                                 case HSET_UTF8N_CNV :\r
1923                                         EnableWindow(GetDlgItem(hDlg, HSET_HANCNV), FALSE);\r
1924                                         break;\r
1925 \r
1926                                 case HSET_SJIS_CNV :\r
1927                                 case HSET_FN_JIS_CNV :\r
1928                                 case HSET_FN_EUC_CNV :\r
1929                                         EnableWindow(GetDlgItem(hDlg, HSET_FN_HANCNV), TRUE);\r
1930                                         break;\r
1931 \r
1932                                 case HSET_FN_AUTO_CNV :\r
1933                                 case HSET_FN_SJIS_CNV :\r
1934                                 case HSET_FN_SMH_CNV :\r
1935                                 case HSET_FN_SMC_CNV :\r
1936                                 case HSET_FN_UTF8N_CNV :        // UTF-8対応\r
1937                                         EnableWindow(GetDlgItem(hDlg, HSET_FN_HANCNV), FALSE);\r
1938                                         break;\r
1939                         }\r
1940                         return(TRUE);\r
1941         }\r
1942         return(FALSE);\r
1943 }\r
1944 \r
1945 \r
1946 /*----- ダイアルアップ設定ウインドウのコールバック ----------------------------\r
1947 *\r
1948 *       Parameter\r
1949 *               HWND hDlg : ウインドウハンドル\r
1950 *               UINT message : メッセージ番号\r
1951 *               WPARAM wParam : メッセージの WPARAM 引数\r
1952 *               LPARAM lParam : メッセージの LPARAM 引数\r
1953 *\r
1954 *       Return Value\r
1955 *               BOOL TRUE/FALSE\r
1956 *----------------------------------------------------------------------------*/\r
1957 \r
1958 static BOOL CALLBACK DialupSettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
1959 {\r
1960         NMHDR *pnmhdr;\r
1961 \r
1962         switch (iMessage)\r
1963         {\r
1964                 case WM_INITDIALOG :\r
1965                         SendDlgItemMessage(hDlg, HSET_DIALUP, BM_SETCHECK, TmpHost.Dialup, 0);\r
1966                         SendDlgItemMessage(hDlg, HSET_DIALUSETHIS, BM_SETCHECK, TmpHost.DialupAlways, 0);\r
1967                         SendDlgItemMessage(hDlg, HSET_DIALNOTIFY, BM_SETCHECK, TmpHost.DialupNotify, 0);\r
1968                         if(AskRasUsable() == NO)\r
1969                                 EnableWindow(GetDlgItem(hDlg, HSET_DIALUP), FALSE);\r
1970                         if((TmpHost.DialupAlways == NO) || (AskRasUsable() == NO))\r
1971                                 EnableWindow(GetDlgItem(hDlg, HSET_DIALNOTIFY), FALSE);\r
1972                         if((TmpHost.Dialup == NO) || (AskRasUsable() == NO))\r
1973                         {\r
1974                                 EnableWindow(GetDlgItem(hDlg, HSET_DIALENTRY), FALSE);\r
1975                                 EnableWindow(GetDlgItem(hDlg, HSET_DIALUSETHIS), FALSE);\r
1976                                 EnableWindow(GetDlgItem(hDlg, HSET_DIALNOTIFY), FALSE);\r
1977                         }\r
1978                         SetRasEntryToComboBox(hDlg, HSET_DIALENTRY, TmpHost.DialEntry);\r
1979                         return(TRUE);\r
1980 \r
1981                 case WM_NOTIFY:\r
1982                         pnmhdr = (NMHDR FAR *)lParam;\r
1983                         switch(pnmhdr->code)\r
1984                         {\r
1985                                 case PSN_APPLY :\r
1986                                         TmpHost.Dialup = SendDlgItemMessage(hDlg, HSET_DIALUP, BM_GETCHECK, 0, 0);\r
1987                                         TmpHost.DialupAlways = SendDlgItemMessage(hDlg, HSET_DIALUSETHIS, BM_GETCHECK, 0, 0);\r
1988                                         TmpHost.DialupNotify = SendDlgItemMessage(hDlg, HSET_DIALNOTIFY, BM_GETCHECK, 0, 0);\r
1989                                         SendDlgItemMessage(hDlg, HSET_DIALENTRY, WM_GETTEXT, RAS_NAME_LEN+1, (LPARAM)TmpHost.DialEntry);\r
1990                                         Apply = YES;\r
1991                                         break;\r
1992 \r
1993                                 case PSN_RESET :\r
1994                                         break;\r
1995 \r
1996                                 case PSN_HELP :\r
1997                                         hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000031);\r
1998                                         break;\r
1999                         }\r
2000                         break;\r
2001 \r
2002                 case WM_COMMAND :\r
2003                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
2004                         {\r
2005                                 case HSET_DIALUP :\r
2006                                         if(SendDlgItemMessage(hDlg, HSET_DIALUP, BM_GETCHECK, 0, 0) == 0)\r
2007                                         {\r
2008                                                 EnableWindow(GetDlgItem(hDlg, HSET_DIALENTRY), FALSE);\r
2009                                                 EnableWindow(GetDlgItem(hDlg, HSET_DIALUSETHIS), FALSE);\r
2010                                                 EnableWindow(GetDlgItem(hDlg, HSET_DIALNOTIFY), FALSE);\r
2011                                                 break;\r
2012                                         }\r
2013                                         else\r
2014                                         {\r
2015                                                 EnableWindow(GetDlgItem(hDlg, HSET_DIALENTRY), TRUE);\r
2016                                                 EnableWindow(GetDlgItem(hDlg, HSET_DIALUSETHIS), TRUE);\r
2017                                         }\r
2018                                         /* ここにbreakはない */\r
2019 \r
2020                                 case HSET_DIALUSETHIS :\r
2021                                         if(SendDlgItemMessage(hDlg, HSET_DIALUSETHIS, BM_GETCHECK, 0, 0) == 0)\r
2022                                                 EnableWindow(GetDlgItem(hDlg, HSET_DIALNOTIFY), FALSE);\r
2023                                         else\r
2024                                                 EnableWindow(GetDlgItem(hDlg, HSET_DIALNOTIFY), TRUE);\r
2025                                         break;\r
2026                         }\r
2027                         return(TRUE);\r
2028         }\r
2029         return(FALSE);\r
2030 }\r
2031 \r
2032 \r
2033 /*----- 高度設定ウインドウのコールバック --------------------------------------\r
2034 *\r
2035 *       Parameter\r
2036 *               HWND hDlg : ウインドウハンドル\r
2037 *               UINT message : メッセージ番号\r
2038 *               WPARAM wParam : メッセージの WPARAM 引数\r
2039 *               LPARAM lParam : メッセージの LPARAM 引数\r
2040 *\r
2041 *       Return Value\r
2042 *               BOOL TRUE/FALSE\r
2043 *----------------------------------------------------------------------------*/\r
2044 \r
2045 static BOOL CALLBACK Adv2SettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
2046 {\r
2047         NMHDR *pnmhdr;\r
2048         int Num;\r
2049 \r
2050         switch (iMessage)\r
2051         {\r
2052                 case WM_INITDIALOG :\r
2053                         SendDlgItemMessage(hDlg, HSET_CHMOD_CMD, EM_LIMITTEXT, CHMOD_CMD_LEN, 0);\r
2054                         SendDlgItemMessage(hDlg, HSET_CHMOD_CMD, WM_SETTEXT, 0, (LPARAM)TmpHost.ChmodCmd);\r
2055                         SendDlgItemMessage(hDlg, HSET_LS_FNAME, EM_LIMITTEXT, NLST_NAME_LEN, 0);\r
2056                         SendDlgItemMessage(hDlg, HSET_LS_FNAME, WM_SETTEXT, 0, (LPARAM)TmpHost.LsName);\r
2057                         SendDlgItemMessage(hDlg, HSET_LISTCMD, BM_SETCHECK, TmpHost.ListCmdOnly, 0);\r
2058                         if(TmpHost.ListCmdOnly == YES)\r
2059                                 EnableWindow(GetDlgItem(hDlg, HSET_NLST_R), FALSE);\r
2060                         SendDlgItemMessage(hDlg, HSET_NLST_R, BM_SETCHECK, TmpHost.UseNLST_R, 0);\r
2061                         SendDlgItemMessage(hDlg, HSET_FULLPATH, BM_SETCHECK, TmpHost.NoFullPath, 0);\r
2062                         SendDlgItemMessage(hDlg, HSET_HOSTTYPE, CB_ADDSTRING, 0, (LPARAM)MSGJPN139);\r
2063                         SendDlgItemMessage(hDlg, HSET_HOSTTYPE, CB_ADDSTRING, 0, (LPARAM)MSGJPN140);\r
2064                         SendDlgItemMessage(hDlg, HSET_HOSTTYPE, CB_ADDSTRING, 0, (LPARAM)MSGJPN141);\r
2065                         SendDlgItemMessage(hDlg, HSET_HOSTTYPE, CB_ADDSTRING, 0, (LPARAM)MSGJPN142);\r
2066                         SendDlgItemMessage(hDlg, HSET_HOSTTYPE, CB_ADDSTRING, 0, (LPARAM)MSGJPN143);\r
2067                         SendDlgItemMessage(hDlg, HSET_HOSTTYPE, CB_ADDSTRING, 0, (LPARAM)MSGJPN144);\r
2068                         SendDlgItemMessage(hDlg, HSET_HOSTTYPE, CB_ADDSTRING, 0, (LPARAM)MSGJPN289);\r
2069                         SendDlgItemMessage(hDlg, HSET_HOSTTYPE, CB_ADDSTRING, 0, (LPARAM)MSGJPN295);\r
2070                         SendDlgItemMessage(hDlg, HSET_HOSTTYPE, CB_SETCURSEL, TmpHost.HostType, 0);\r
2071                         if(TmpHost.HostType == 2)\r
2072                         {\r
2073                                 EnableWindow(GetDlgItem(hDlg, HSET_NLST_R), FALSE);\r
2074                                 EnableWindow(GetDlgItem(hDlg, HSET_LISTCMD), FALSE);\r
2075                                 EnableWindow(GetDlgItem(hDlg, HSET_FULLPATH), FALSE);\r
2076                         }\r
2077                         return(TRUE);\r
2078 \r
2079                 case WM_NOTIFY:\r
2080                         pnmhdr = (NMHDR FAR *)lParam;\r
2081                         switch(pnmhdr->code)\r
2082                         {\r
2083                                 case PSN_APPLY :\r
2084                                         SendDlgItemMessage(hDlg, HSET_CHMOD_CMD, WM_GETTEXT, CHMOD_CMD_LEN+1, (LPARAM)TmpHost.ChmodCmd);\r
2085                                         SendDlgItemMessage(hDlg, HSET_LS_FNAME, WM_GETTEXT, NLST_NAME_LEN+1, (LPARAM)TmpHost.LsName);\r
2086                                         TmpHost.ListCmdOnly = SendDlgItemMessage(hDlg, HSET_LISTCMD, BM_GETCHECK, 0, 0);\r
2087                                         TmpHost.UseNLST_R = SendDlgItemMessage(hDlg, HSET_NLST_R, BM_GETCHECK, 0, 0);\r
2088                                         TmpHost.NoFullPath = SendDlgItemMessage(hDlg, HSET_FULLPATH, BM_GETCHECK, 0, 0);\r
2089                                         TmpHost.HostType = SendDlgItemMessage(hDlg, HSET_HOSTTYPE, CB_GETCURSEL, 0, 0);\r
2090                                         Apply = YES;\r
2091                                         break;\r
2092 \r
2093                                 case PSN_RESET :\r
2094                                         break;\r
2095 \r
2096                                 case PSN_HELP :\r
2097                                         hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000032);\r
2098                                         break;\r
2099                         }\r
2100                         break;\r
2101 \r
2102                 case WM_COMMAND :\r
2103                         switch(GET_WM_COMMAND_ID(wParam, lParam))\r
2104                         {\r
2105                                 case HSET_CHMOD_NOR :\r
2106                                         SendDlgItemMessage(hDlg, HSET_CHMOD_CMD, WM_SETTEXT, 0, (LPARAM)CHMOD_CMD_NOR);\r
2107                                         break;\r
2108 \r
2109                                 case HSET_LS_FNAME_NOR :\r
2110                                         SendDlgItemMessage(hDlg, HSET_LS_FNAME, WM_SETTEXT, 0, (LPARAM)LS_FNAME);\r
2111                                         break;\r
2112 \r
2113                                 case HSET_LISTCMD :\r
2114                                         if(SendDlgItemMessage(hDlg, HSET_LISTCMD, BM_GETCHECK, 0, 0) == 0)\r
2115                                                 EnableWindow(GetDlgItem(hDlg, HSET_NLST_R), TRUE);\r
2116                                         else\r
2117                                                 EnableWindow(GetDlgItem(hDlg, HSET_NLST_R), FALSE);\r
2118                                         break;\r
2119 \r
2120                                 case HSET_HOSTTYPE :\r
2121                                         Num = SendDlgItemMessage(hDlg, HSET_HOSTTYPE, CB_GETCURSEL, 0, 0);\r
2122                                         if(Num == 2)\r
2123                                         {\r
2124                                                 EnableWindow(GetDlgItem(hDlg, HSET_NLST_R), FALSE);\r
2125                                                 EnableWindow(GetDlgItem(hDlg, HSET_LISTCMD), FALSE);\r
2126                                                 EnableWindow(GetDlgItem(hDlg, HSET_FULLPATH), FALSE);\r
2127                                         }\r
2128                                         else\r
2129                                         {\r
2130                                                 EnableWindow(GetDlgItem(hDlg, HSET_NLST_R), TRUE);\r
2131                                                 EnableWindow(GetDlgItem(hDlg, HSET_LISTCMD), TRUE);\r
2132                                                 EnableWindow(GetDlgItem(hDlg, HSET_FULLPATH), TRUE);\r
2133                                         }\r
2134                                         break;\r
2135                         }\r
2136                         return(TRUE);\r
2137         }\r
2138         return(FALSE);\r
2139 }\r
2140 \r
2141 \r
2142 // 暗号化通信対応\r
2143 static BOOL CALLBACK CryptSettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
2144 {\r
2145         NMHDR *pnmhdr;\r
2146 //      int Num;\r
2147 \r
2148         switch (iMessage)\r
2149         {\r
2150                 case WM_INITDIALOG :\r
2151                         SendDlgItemMessage(hDlg, HSET_NO_ENCRYPTION, BM_SETCHECK, TmpHost.UseNoEncryption, 0);\r
2152                         if(IsOpenSSLLoaded())\r
2153                         {\r
2154                                 SendDlgItemMessage(hDlg, HSET_FTPES, BM_SETCHECK, TmpHost.UseFTPES, 0);\r
2155                                 SendDlgItemMessage(hDlg, HSET_FTPIS, BM_SETCHECK, TmpHost.UseFTPIS, 0);\r
2156                         }\r
2157                         else\r
2158                         {\r
2159                                 SendDlgItemMessage(hDlg, HSET_FTPES, BM_SETCHECK, BST_UNCHECKED, 0);\r
2160                                 EnableWindow(GetDlgItem(hDlg, HSET_FTPES), FALSE);\r
2161                                 SendDlgItemMessage(hDlg, HSET_FTPIS, BM_SETCHECK, BST_UNCHECKED, 0);\r
2162                                 EnableWindow(GetDlgItem(hDlg, HSET_FTPIS), FALSE);\r
2163                         }\r
2164                         SendDlgItemMessage(hDlg, HSET_SFTP, BM_SETCHECK, TmpHost.UseSFTP, 0);\r
2165                         SendDlgItemMessage(hDlg, HSET_PRIVATE_KEY, WM_SETTEXT, 0, (LPARAM)TmpHost.PrivateKey);\r
2166                         // TODO: SFTP対応\r
2167                         SendDlgItemMessage(hDlg, HSET_SFTP, BM_SETCHECK, BST_UNCHECKED, 0);\r
2168                         EnableWindow(GetDlgItem(hDlg, HSET_SFTP), FALSE);\r
2169                         return(TRUE);\r
2170 \r
2171                 case WM_NOTIFY:\r
2172                         pnmhdr = (NMHDR FAR *)lParam;\r
2173                         switch(pnmhdr->code)\r
2174                         {\r
2175                                 case PSN_APPLY :\r
2176                                         TmpHost.UseNoEncryption = SendDlgItemMessage(hDlg, HSET_NO_ENCRYPTION, BM_GETCHECK, 0, 0);\r
2177                                         if(IsOpenSSLLoaded())\r
2178                                         {\r
2179                                                 TmpHost.UseFTPES = SendDlgItemMessage(hDlg, HSET_FTPES, BM_GETCHECK, 0, 0);\r
2180                                                 TmpHost.UseFTPIS = SendDlgItemMessage(hDlg, HSET_FTPIS, BM_GETCHECK, 0, 0);\r
2181                                         }\r
2182                                         // TODO: SFTP対応\r
2183 //                                      TmpHost.UseSFTP = SendDlgItemMessage(hDlg, HSET_SFTP, BM_GETCHECK, 0, 0);\r
2184                                         SendDlgItemMessage(hDlg, HSET_PRIVATE_KEY, WM_GETTEXT, PRIVATE_KEY_LEN+1, (LPARAM)TmpHost.PrivateKey);\r
2185                                         Apply = YES;\r
2186                                         break;\r
2187 \r
2188                                 case PSN_RESET :\r
2189                                         break;\r
2190 \r
2191                                 case PSN_HELP :\r
2192                                         hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000065);\r
2193                                         break;\r
2194                         }\r
2195                         break;\r
2196         }\r
2197         return(FALSE);\r
2198 }\r
2199 \r
2200 // 同時接続対応\r
2201 static BOOL CALLBACK Adv3SettingProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)\r
2202 {\r
2203         NMHDR *pnmhdr;\r
2204 //      int Num;\r
2205 \r
2206         switch (iMessage)\r
2207         {\r
2208                 case WM_INITDIALOG :\r
2209                         SendDlgItemMessage(hDlg, HSET_THREAD_COUNT, EM_LIMITTEXT, (WPARAM)1, 0);\r
2210                         SetDecimalText(hDlg, HSET_THREAD_COUNT, TmpHost.MaxThreadCount);\r
2211                         SendDlgItemMessage(hDlg, HSET_THREAD_COUNT_SPN, UDM_SETRANGE, 0, (LPARAM)MAKELONG(MAX_DATA_CONNECTION, 1));\r
2212                         return(TRUE);\r
2213 \r
2214                 case WM_NOTIFY:\r
2215                         pnmhdr = (NMHDR FAR *)lParam;\r
2216                         switch(pnmhdr->code)\r
2217                         {\r
2218                                 case PSN_APPLY :\r
2219                                         TmpHost.MaxThreadCount = GetDecimalText(hDlg, HSET_THREAD_COUNT);\r
2220                                         CheckRange2(&TmpHost.MaxThreadCount, MAX_DATA_CONNECTION, 1);\r
2221                                         Apply = YES;\r
2222                                         break;\r
2223 \r
2224                                 case PSN_RESET :\r
2225                                         break;\r
2226 \r
2227                                 case PSN_HELP :\r
2228                                         hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000066);\r
2229                                         break;\r
2230                         }\r
2231                         break;\r
2232         }\r
2233         return(FALSE);\r
2234 }\r
2235 \r