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 #define CATCOMP_NUMBERS
26 #include <libraries/openurl.h>
33 /**************************************************************************/
52 struct URL_FTPNode
*fn
;
62 /**************************************************************************/
64 static CONST_STRPTR syms
[] =
71 static STRPTR names
[] =
73 (STRPTR
)MSG_Edit_PopURL
,
74 (STRPTR
)MSG_Edit_PopScreen
,
78 static IPTR
mNew(struct IClass
*cl
, Object
*obj
, struct opSet
*msg
)
81 struct URL_FTPNode
*fn
;
82 struct TagItem
*attrs
= msg
->ops_AttrList
;
84 memset(&temp
,0,sizeof(temp
));
86 temp
.FTPList
= (Object
*)GetTagData(MUIA_FTPEditWin_ListObj
,(IPTR
)NULL
,attrs
);
87 if (!temp
.FTPList
) return 0;
89 fn
= temp
.fn
= (struct URL_FTPNode
*)GetTagData(MUIA_FTPEditWin_FTP
,(IPTR
)NULL
,attrs
);
93 if((obj
= (Object
*)DoSuperNew(cl
,obj
,
94 MUIA_HelpNode
, "FWIN",
95 MUIA_Window_ID
, MAKE_ID('E','D','B','R'),
96 MUIA_Window_Title
, getString(MSG_FTP_WinTitle
),
97 MUIA_Window_AllowTopMenus
, FALSE
,
98 MUIA_Window_ScreenTitle
, getString(MSG_App_ScreenTitle
),
100 WindowContents
, VGroup
,
102 GroupFrameT(getString(MSG_Edit_Definitions
)),
104 Child
, olabel2(MSG_Edit_Name
),
105 Child
, temp
.name
= ostring(NAME_LEN
,MSG_Edit_Name
,MSG_Edit_Name_Help
),
107 Child
, olabel2(MSG_Edit_Path
),
108 Child
, temp
.path
= opopph(syms
,names
,PATH_LEN
,MSG_Edit_Path
,TRUE
,MSG_Edit_Path_Help
),
110 Child
, olabel2(MSG_Edit_Port
),
111 Child
, temp
.port
= opopport(PORT_LEN
,MSG_Edit_Port
,MSG_Edit_Port_Help
),
113 Child
, olabel2(MSG_FTP_RemoveURLQualifier
),
115 Child
, temp
.removeScheme
= ocheckmark(MSG_FTP_RemoveURLQualifier
,MSG_FTP_RemoveURLQualifier_Help
),
121 GroupFrameT(getString(MSG_Edit_ARexx
)),
123 Child
, olabel2(MSG_Edit_Show
),
124 Child
, temp
.show
= ostring(SHOWCMD_LEN
,MSG_Edit_Show
,MSG_Edit_Show_Help
),
126 Child
, olabel2(MSG_Edit_Screen
),
127 Child
, temp
.toFront
= ostring(TOFRONTCMD_LEN
,MSG_Edit_Screen
,MSG_Edit_Screen_Help
),
129 Child
, olabel2(MSG_Edit_OpenURL
),
130 Child
, temp
.openURL
= opopph(syms
,names
,OPENURLCMD_LEN
,MSG_Edit_OpenURL
,FALSE
,MSG_Edit_OpenURL_Help
),
131 Child
, olabel2(MSG_Edit_NewWin
),
132 Child
, temp
.openURLNW
= opopph(syms
,names
,OPENURLWCMD_LEN
,MSG_Edit_NewWin
,FALSE
,MSG_Edit_NewWin_Help
),
136 Child
, temp
.use
= obutton(MSG_Edit_Use
,MSG_Edit_Use_Help
),
137 Child
, RectangleObject
, End
,
138 Child
, temp
.cancel
= obutton(MSG_Edit_Cancel
,MSG_Edit_Cancel_Help
),
141 TAG_MORE
, attrs
)) != NULL
)
143 struct data
*data
= INST_DATA(cl
,obj
);
145 CopyMem(&temp
,data
,sizeof(*data
));
147 set(data
->name
, MUIA_String_Contents
, fn
->ufn_Name
);
148 set(data
->path
, MUIA_String_Contents
, fn
->ufn_Path
);
149 set(data
->port
, MUIA_String_Contents
, fn
->ufn_Port
);
150 set(data
->removeScheme
, MUIA_Selected
, isFlagSet(fn
->ufn_Flags
, UFNF_REMOVEFTP
));
151 set(data
->show
, MUIA_String_Contents
, fn
->ufn_ShowCmd
);
152 set(data
->toFront
, MUIA_String_Contents
, fn
->ufn_ToFrontCmd
);
153 set(data
->openURL
, MUIA_String_Contents
, fn
->ufn_OpenURLCmd
);
154 set(data
->openURLNW
, MUIA_String_Contents
, fn
->ufn_OpenURLWCmd
);
160 /**************************************************************************/
162 static IPTR
mGet(struct IClass
*cl
, Object
*obj
, struct opGet
*msg
)
164 struct data
*data
= INST_DATA(cl
,obj
);
166 switch (msg
->opg_AttrID
)
168 case MUIA_FTPEditWin_FTP
: *msg
->opg_Storage
= (IPTR
)data
->fn
; return TRUE
;
169 case MUIA_App_IsSubWin
: *msg
->opg_Storage
= TRUE
; return TRUE
;
170 default: return DoSuperMethodA(cl
,obj
,(Msg
)msg
);
174 /**************************************************************************/
176 static IPTR
mWindow_Setup(struct IClass
*cl
, Object
*obj
, struct MUIP_Window_Setup
*msg
)
182 if(DoSuperMethodA(cl
, obj
, (Msg
)msg
))
184 struct data
*data
= INST_DATA(cl
, obj
);
186 if(isFlagClear(data
->flags
, FLG_Notifies
))
188 DoMethod(data
->use
, MUIM_Notify
, MUIA_Pressed
, FALSE
, (IPTR
)obj
, 1, MUIM_FTPEditWin_Use
);
189 DoMethod(data
->cancel
, MUIM_Notify
, MUIA_Pressed
, FALSE
,(IPTR
)obj
, 3, MUIM_Set
, MUIA_Window_CloseRequest
, TRUE
);
191 DoMethod(obj
, MUIM_Notify
, MUIA_Window_CloseRequest
,TRUE
, (IPTR
)_app(obj
), 6, MUIM_Application_PushMethod
,
192 (IPTR
)_app(obj
), 3, MUIM_App_CloseWin
, MUIA_FTPEditWin_FTP
, (IPTR
)data
->fn
);
194 SET_FLAG(data
->flags
, FLG_Notifies
);
204 /**************************************************************************/
206 static IPTR
mUse(struct IClass
*cl
, Object
*obj
, UNUSED Msg msg
)
208 struct data
*data
= INST_DATA(cl
,obj
);
209 struct URL_FTPNode
*fn
= data
->fn
;
210 LONG i
, visible
, first
;
212 CLEAR_FLAG(fn
->ufn_Flags
, UNF_NEW
);
214 strlcpy(fn
->ufn_Name
, (STRPTR
)xget(data
->name
,MUIA_String_Contents
), sizeof(fn
->ufn_Name
));
215 strlcpy(fn
->ufn_Path
, (STRPTR
)xget(data
->path
,MUIA_String_Contents
), sizeof(fn
->ufn_Path
));
216 strlcpy(fn
->ufn_Port
, (STRPTR
)xget(data
->port
,MUIA_String_Contents
), sizeof(fn
->ufn_Port
));
217 if (xget(data
->removeScheme
,MUIA_Selected
))
218 SET_FLAG(fn
->ufn_Flags
, UFNF_REMOVEFTP
);
220 CLEAR_FLAG(fn
->ufn_Flags
, UFNF_REMOVEFTP
);
222 strlcpy(fn
->ufn_ShowCmd
, (STRPTR
)xget(data
->show
,MUIA_String_Contents
), sizeof(fn
->ufn_ShowCmd
));
223 strlcpy(fn
->ufn_ToFrontCmd
, (STRPTR
)xget(data
->toFront
,MUIA_String_Contents
), sizeof(fn
->ufn_ToFrontCmd
));
224 strlcpy(fn
->ufn_OpenURLCmd
, (STRPTR
)xget(data
->openURL
,MUIA_String_Contents
), sizeof(fn
->ufn_OpenURLCmd
));
225 strlcpy(fn
->ufn_OpenURLWCmd
, (STRPTR
)xget(data
->openURLNW
,MUIA_String_Contents
), sizeof(fn
->ufn_OpenURLWCmd
));
227 visible
= xget(data
->FTPList
, MUIA_List_Visible
);
230 first
= xget(data
->FTPList
, MUIA_List_First
);
232 for (i
= first
; i
< (first
+ visible
); i
++)
234 DoMethod(data
->FTPList
,MUIM_List_GetEntry
,i
,(IPTR
)&fn
);
239 DoMethod(data
->FTPList
,MUIM_List_Redraw
,i
);
245 set(obj
,MUIA_Window_CloseRequest
,TRUE
);
250 /**************************************************************************/
252 SDISPATCHER(dispatcher
)
254 switch (msg
->MethodID
)
256 case OM_NEW
: return mNew(cl
,obj
,(APTR
)msg
);
257 case OM_GET
: return mGet(cl
,obj
,(APTR
)msg
);
259 case MUIM_Window_Setup
: return mWindow_Setup(cl
,obj
,(APTR
)msg
);
261 case MUIM_FTPEditWin_Use
: return mUse(cl
,obj
,(APTR
)msg
);
263 default: return DoSuperMethodA(cl
,obj
,msg
);
267 /**************************************************************************/
269 BOOL
initFTPEditWinClass(void)
271 BOOL success
= FALSE
;
273 if((g_FTPEditWinClass
= MUI_CreateCustomClass(NULL
, MUIC_Window
, NULL
, sizeof(struct data
), ENTRY(dispatcher
))) != NULL
)
275 localizeStrings(names
);
283 /**************************************************************************/
285 void disposeFTPEditWinClass(void)
289 if(g_FTPEditWinClass
!= NULL
)
290 MUI_DeleteCustomClass(g_FTPEditWinClass
);
295 /**************************************************************************/