Fixed another typo in 8-bit pixel handling (BYTE should have been UBYTE).
[AROS.git] / external / openurl / raPrefs / ftps.c
blobe0bbb9aac2b76ac67daed715ac400492682ef09f
1 /***************************************************************************
3 openurl.library - universal URL display and browser launcher library
4 Copyright (C) 1998-2005 by Troels Walsted Hansen, et al.
5 Copyright (C) 2005-2013 by openurl.library Open Source Team
7 This library is free software; it has been placed in the public domain
8 and you can freely redistribute it and/or modify it. Please note, however,
9 that some components may be under the LGPL or GPL license.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 openurl.library project: http://sourceforge.net/projects/openurllib/
17 $Id$
19 ***************************************************************************/
21 #include "ftps.h"
23 #include "gui_global.h"
24 #include "utility.h"
25 #include "macros.h"
27 #include <classes/window.h>
28 #include <libraries/openurl.h>
30 #include <reaction/reaction_macros.h>
32 #include <images/label.h>
33 #include <gadgets/space.h>
35 #include <gadgets/getfile.h>
37 #include <proto/dos.h>
38 #include <proto/exec.h>
39 #include <proto/label.h>
40 #include <proto/space.h>
41 #include <proto/layout.h>
42 #include <proto/window.h>
43 #include <proto/string.h>
44 #include <proto/getfile.h>
45 #include <proto/checkbox.h>
46 #include <proto/intuition.h>
47 #include <proto/utility.h>
48 #include <proto/listbrowser.h>
50 Object *edit_ftp_win;
51 struct Window *edit_ftp_window;
53 Object * make_edit_ftp_win(void)
55 return WindowObject,
56 WA_ScreenTitle, getString(MSG_App_ScreenTitle),
57 WA_Title, getString(MSG_FTP_WinTitle),
58 WA_DragBar, TRUE,
59 WA_CloseGadget, TRUE,
60 WA_SizeGadget, TRUE,
61 WA_DepthGadget, TRUE,
62 WA_Activate, TRUE,
63 // WINDOW_AppPort, AppPort,
64 WINDOW_SharedPort, AppPort,
65 WINDOW_Position, WPOS_CENTERSCREEN,
66 WINDOW_LockHeight, TRUE,
67 WINDOW_Layout, VLayoutObject,
68 LAYOUT_SpaceOuter, TRUE,
69 LAYOUT_AddChild, OBJ(OBJ_FTP_ALIGN1) = VLayoutObject,
70 LAYOUT_SpaceOuter, TRUE,
71 LAYOUT_BevelStyle, BVS_GROUP,
72 LAYOUT_Label, getString(MSG_Edit_Definitions),
74 LAYOUT_AddChild, OBJ(OBJ_FTP_NAME_STR) = StringObject,
75 GA_ID, OBJ_FTP_NAME_STR,
76 GA_RelVerify, TRUE,
77 GA_TabCycle, TRUE,
78 // STRINGA_Buffer, buffer,
79 End, // String
80 Label(getString(MSG_Edit_Name)),
82 LAYOUT_AddChild, HLayoutObject,
83 LAYOUT_SpaceInner, FALSE,
84 LAYOUT_AddChild, OBJ(OBJ_FTP_PATH_GET) = GetFileObject,
85 GA_ID, OBJ_FTP_PATH_GET,
86 GA_RelVerify, TRUE,
87 // GETFILE_TitleText, "Select Path To Browser",
88 End, // GetFile
89 LAYOUT_AddChild, OBJ(OBJ_FTP_PATH_CHOOSE) = ButtonObject,
90 GA_ID, OBJ_FTP_PATH_CHOOSE,
91 GA_RelVerify, TRUE,
92 GA_Image, &chooser_image,
93 End, // Button
94 CHILD_WeightedWidth, 0,
95 End, // HLayout
96 Label(getString(MSG_Edit_Path)),
98 LAYOUT_AddChild, HLayoutObject,
99 LAYOUT_SpaceInner, FALSE,
100 LAYOUT_AddChild, OBJ(OBJ_FTP_AREXX_STR) = StringObject,
101 GA_ID, OBJ_FTP_AREXX_STR,
102 GA_RelVerify, TRUE,
103 GA_TabCycle, TRUE,
104 // STRINGA_Buffer, buffer,
105 End, // String
106 LAYOUT_AddChild, OBJ(OBJ_FTP_AREXX_CHOOSE) = ButtonObject,
107 GA_ID, OBJ_FTP_AREXX_CHOOSE,
108 GA_RelVerify, TRUE,
109 GA_Image, &chooser_image,
110 End, // Button
111 CHILD_WeightedWidth, 0,
112 End, // HLayout
113 Label(getString(MSG_Edit_Port)),
115 LAYOUT_AddChild, HLayoutObject,
116 LAYOUT_AddChild, OBJ(OBJ_FTP_REMOVE) = CheckBoxObject,
117 GA_ID, OBJ_FTP_REMOVE,
118 GA_RelVerify, TRUE,
119 GA_Selected, TRUE,
120 End, // CheckBox
121 End, // HLayout
122 Label(getString(MSG_FTP_RemoveURLQualifier)),
123 End, // VLayout
126 LAYOUT_AddChild, OBJ(OBJ_FTP_ALIGN2) = VLayoutObject,
127 LAYOUT_SpaceOuter, TRUE,
128 LAYOUT_BevelStyle, BVS_GROUP,
129 LAYOUT_Label, getString(MSG_Edit_ARexx),
131 LAYOUT_AddChild, OBJ(OBJ_FTP_SHOW_STR) = StringObject,
132 GA_ID, OBJ_FTP_SHOW_STR,
133 GA_RelVerify, TRUE,
134 GA_TabCycle, TRUE,
135 // STRINGA_Buffer, buffer,
136 End, // String
137 Label(getString(MSG_Edit_Show)),
139 LAYOUT_AddChild, OBJ(OBJ_FTP_FRONT_STR) = StringObject,
140 GA_ID, OBJ_FTP_FRONT_STR,
141 GA_RelVerify, TRUE,
142 GA_TabCycle, TRUE,
143 // STRINGA_Buffer, buffer,
144 End, // String
145 Label(getString(MSG_Edit_Screen)),
147 LAYOUT_AddChild, HLayoutObject,
148 LAYOUT_SpaceInner, FALSE,
149 LAYOUT_AddChild, OBJ(OBJ_FTP_OPEN_STR) = StringObject,
150 GA_ID, OBJ_FTP_OPEN_STR,
151 GA_RelVerify, TRUE,
152 GA_TabCycle, TRUE,
153 // STRINGA_Buffer, buffer,
154 End, // String
155 LAYOUT_AddChild, OBJ(OBJ_FTP_OPEN_CHOOSE) = ButtonObject,
156 GA_ID, OBJ_FTP_OPEN_CHOOSE,
157 GA_RelVerify, TRUE,
158 GA_Image, &chooser_image,
159 End, // Button
160 CHILD_WeightedWidth, 0,
161 End, // HLayout
162 Label(getString(MSG_Edit_OpenURL)),
164 LAYOUT_AddChild, HLayoutObject,
165 LAYOUT_SpaceInner, FALSE,
166 LAYOUT_AddChild, OBJ(OBJ_FTP_NEW_STR) = StringObject,
167 GA_ID, OBJ_FTP_NEW_STR,
168 GA_RelVerify, TRUE,
169 GA_TabCycle, TRUE,
170 // STRINGA_Buffer, buffer,
171 End, // String
172 LAYOUT_AddChild, OBJ(OBJ_FTP_NEW_CHOOSE) = ButtonObject,
173 GA_ID, OBJ_FTP_NEW_CHOOSE,
174 GA_RelVerify, TRUE,
175 GA_Image, &chooser_image,
176 End, // Button
177 CHILD_WeightedWidth, 0,
178 End, // HLayout
179 Label(getString(MSG_Edit_NewWin)),
180 End, // VLayout
182 LAYOUT_AddChild, HLayoutObject,
183 LAYOUT_AddChild, SpaceObject,
184 SPACE_MinWidth, 2,
185 End, // Space
186 CHILD_WeightedWidth, 0,
188 LAYOUT_AddChild, HLayoutObject,
189 LAYOUT_EvenSize, TRUE,
190 LAYOUT_AddChild, Button(getString(MSG_Edit_Use),OBJ_FTP_USE),
191 CHILD_WeightedWidth, 0,
193 LAYOUT_AddChild, Button(getString(MSG_Edit_Cancel),OBJ_FTP_CANCEL),
194 CHILD_WeightedWidth, 0,
195 End, // HLayout
197 LAYOUT_AddChild, SpaceObject,
198 SPACE_MinWidth, 2,
199 End, // Space
200 CHILD_WeightedWidth, 0,
201 End, // HLayout
202 CHILD_MinWidth, 300, // sets a more attractive size for the whole Layout
204 End, // VLayout
205 WindowEnd;
208 BOOL updateFTPList(struct List * list, struct MinList PrefsFTPList)
210 struct URL_FTPNode * fn = NULL,
211 * newNode = NULL;
213 // libération de la liste
214 freeList(list);
216 // ajout des nouvelles données
217 for (fn = (struct URL_FTPNode *)PrefsFTPList.mlh_Head;
218 fn->ufn_Node.mln_Succ;
219 fn = (struct URL_FTPNode *)fn->ufn_Node.mln_Succ)
221 if((newNode = (struct URL_FTPNode*)IListBrowser->AllocListBrowserNode(3,
222 LBNA_NodeSize, sizeof(struct URL_FTPNode),
223 LBNA_CheckBox, TRUE,
224 LBNA_Checked, isFlagClear(fn->ufn_Flags, UNF_DISABLED),
225 LBNA_Column, 1,
226 LBNCA_Text, "",
227 LBNA_Column, 2,
228 LBNCA_Text, "",
229 TAG_DONE)) != NULL)
231 IExec->CopyMem(fn, newNode, sizeof(struct URL_FTPNode));
232 IListBrowser->SetListBrowserNodeAttrs((struct Node*)newNode, LBNA_Column, 1,
233 LBNCA_Text, newNode->ufn_Name,
234 LBNA_Column, 2,
235 LBNCA_Text, newNode->ufn_Path,
236 TAG_END);
238 IIntuition->SetAttrs(edit_ftp_win, WINDOW_UserData, fn, TAG_DONE);
239 IExec->AddTail(list, (struct Node*)newNode);
241 else
243 IDOS->Printf(" AllocListBrowserNode() failed\n");
244 return(FALSE);
248 return TRUE;
251 void updateFTPWindow(struct URL_FTPNode * pFTP)
253 if(pFTP != NULL)
255 gadset(GAD(OBJ_FTP_NAME_STR), edit_ftp_window, STRINGA_TextVal, pFTP->ufn_Name);
256 gadset(GAD(OBJ_FTP_PATH_GET), edit_ftp_window, GETFILE_File, pFTP->ufn_Path);
257 gadset(GAD(OBJ_FTP_AREXX_STR), edit_ftp_window, STRINGA_TextVal, pFTP->ufn_Port);
258 gadset(GAD(OBJ_FTP_REMOVE), edit_ftp_window, GA_Selected, isFlagSet(pFTP->ufn_Flags, UFNF_REMOVEFTP));
259 gadset(GAD(OBJ_FTP_SHOW_STR), edit_ftp_window, STRINGA_TextVal, pFTP->ufn_ShowCmd);
260 gadset(GAD(OBJ_FTP_FRONT_STR), edit_ftp_window, STRINGA_TextVal, pFTP->ufn_ToFrontCmd);
261 gadset(GAD(OBJ_FTP_OPEN_STR), edit_ftp_window, STRINGA_TextVal, pFTP->ufn_OpenURLCmd);
262 gadset(GAD(OBJ_FTP_NEW_STR), edit_ftp_window, STRINGA_TextVal, pFTP->ufn_OpenURLWCmd);
266 void updateFTPNode()
268 struct URL_FTPNode *pFTP;
270 if((pFTP = (struct URL_FTPNode *)iget(edit_ftp_win, WINDOW_UserData)) != NULL)
272 STRPTR strValue;
274 strValue = (STRPTR)iget(GAD(OBJ_FTP_NAME_STR), STRINGA_TextVal);
275 IUtility->Strlcpy(pFTP->ufn_Name, strValue, sizeof(pFTP->ufn_Name));
276 strValue = (STRPTR)iget(GAD(OBJ_FTP_PATH_GET), STRINGA_TextVal);
277 IUtility->Strlcpy(pFTP->ufn_Path, strValue, sizeof(pFTP->ufn_Path));
278 strValue = (STRPTR)iget(GAD(OBJ_FTP_AREXX_STR), STRINGA_TextVal);
279 IUtility->Strlcpy(pFTP->ufn_Port, strValue, sizeof(pFTP->ufn_Port));
280 strValue = (STRPTR)iget(GAD(OBJ_FTP_SHOW_STR), STRINGA_TextVal);
281 IUtility->Strlcpy(pFTP->ufn_ShowCmd, strValue, sizeof(pFTP->ufn_ShowCmd));
282 strValue = (STRPTR)iget(GAD(OBJ_FTP_FRONT_STR), STRINGA_TextVal);
283 IUtility->Strlcpy(pFTP->ufn_ToFrontCmd, strValue, sizeof(pFTP->ufn_ToFrontCmd));
284 strValue = (STRPTR)iget(GAD(OBJ_FTP_OPEN_STR), STRINGA_TextVal);
285 IUtility->Strlcpy(pFTP->ufn_OpenURLCmd, strValue, sizeof(pFTP->ufn_OpenURLCmd));
286 strValue = (STRPTR)iget(GAD(OBJ_FTP_NEW_STR), STRINGA_TextVal);
287 IUtility->Strlcpy(pFTP->ufn_OpenURLWCmd, strValue, sizeof(pFTP->ufn_OpenURLWCmd));
289 // now update the ListBrowser attributes
290 IListBrowser->SetListBrowserNodeAttrs((struct Node*)pFTP, LBNA_Column, 1,
291 LBNCA_Text, pFTP->ufn_Name,
292 LBNA_Column, 2,
293 LBNCA_Text, pFTP->ufn_Path,
294 TAG_END);