OSDN Git Service

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