OSDN Git Service

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