OSDN Git Service

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