OSDN Git Service

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