OSDN Git Service

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