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/
19 ***************************************************************************/
23 #include "gui_global.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>
51 struct Window
*edit_ftp_window
;
53 Object
* make_edit_ftp_win(void)
56 WA_ScreenTitle
, getString(MSG_App_ScreenTitle
),
57 WA_Title
, getString(MSG_FTP_WinTitle
),
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
,
78 // STRINGA_Buffer, buffer,
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
,
87 // GETFILE_TitleText, "Select Path To Browser",
89 LAYOUT_AddChild
, OBJ(OBJ_FTP_PATH_CHOOSE
) = ButtonObject
,
90 GA_ID
, OBJ_FTP_PATH_CHOOSE
,
92 GA_Image
, &chooser_image
,
94 CHILD_WeightedWidth
, 0,
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
,
104 // STRINGA_Buffer, buffer,
106 LAYOUT_AddChild
, OBJ(OBJ_FTP_AREXX_CHOOSE
) = ButtonObject
,
107 GA_ID
, OBJ_FTP_AREXX_CHOOSE
,
109 GA_Image
, &chooser_image
,
111 CHILD_WeightedWidth
, 0,
113 Label(getString(MSG_Edit_Port
)),
115 LAYOUT_AddChild
, HLayoutObject
,
116 LAYOUT_AddChild
, OBJ(OBJ_FTP_REMOVE
) = CheckBoxObject
,
117 GA_ID
, OBJ_FTP_REMOVE
,
122 Label(getString(MSG_FTP_RemoveURLQualifier
)),
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
,
135 // STRINGA_Buffer, buffer,
137 Label(getString(MSG_Edit_Show
)),
139 LAYOUT_AddChild
, OBJ(OBJ_FTP_FRONT_STR
) = StringObject
,
140 GA_ID
, OBJ_FTP_FRONT_STR
,
143 // STRINGA_Buffer, buffer,
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
,
153 // STRINGA_Buffer, buffer,
155 LAYOUT_AddChild
, OBJ(OBJ_FTP_OPEN_CHOOSE
) = ButtonObject
,
156 GA_ID
, OBJ_FTP_OPEN_CHOOSE
,
158 GA_Image
, &chooser_image
,
160 CHILD_WeightedWidth
, 0,
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
,
170 // STRINGA_Buffer, buffer,
172 LAYOUT_AddChild
, OBJ(OBJ_FTP_NEW_CHOOSE
) = ButtonObject
,
173 GA_ID
, OBJ_FTP_NEW_CHOOSE
,
175 GA_Image
, &chooser_image
,
177 CHILD_WeightedWidth
, 0,
179 Label(getString(MSG_Edit_NewWin
)),
182 LAYOUT_AddChild
, HLayoutObject
,
183 LAYOUT_AddChild
, SpaceObject
,
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,
197 LAYOUT_AddChild
, SpaceObject
,
200 CHILD_WeightedWidth
, 0,
202 CHILD_MinWidth
, 300, // sets a more attractive size for the whole Layout
208 BOOL
updateFTPList(struct List
* list
, struct MinList PrefsFTPList
)
210 struct URL_FTPNode
* fn
= NULL
,
213 // libération de la liste
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
),
224 LBNA_Checked
, isFlagClear(fn
->ufn_Flags
, UNF_DISABLED
),
231 IExec
->CopyMem(fn
, newNode
, sizeof(struct URL_FTPNode
));
232 IListBrowser
->SetListBrowserNodeAttrs((struct Node
*)newNode
, LBNA_Column
, 1,
233 LBNCA_Text
, newNode
->ufn_Name
,
235 LBNCA_Text
, newNode
->ufn_Path
,
238 IIntuition
->SetAttrs(edit_ftp_win
, WINDOW_UserData
, fn
, TAG_DONE
);
239 IExec
->AddTail(list
, (struct Node
*)newNode
);
243 IDOS
->Printf(" AllocListBrowserNode() failed\n");
251 void updateFTPWindow(struct URL_FTPNode
* pFTP
)
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
);
268 struct URL_FTPNode
*pFTP
;
270 if((pFTP
= (struct URL_FTPNode
*)iget(edit_ftp_win
, WINDOW_UserData
)) != NULL
)
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
,
293 LBNCA_Text
, pFTP
->ufn_Path
,