OSDN Git Service

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