Fixed compatibility of output.
[AROS.git] / external / openurl / prefs / mailereditwin.c
blob436a955ffff136f6e499155aee977425fb4dec0e
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 "openurl.h"
23 #define CATCOMP_NUMBERS
24 #include "locale.h"
26 #include <libraries/openurl.h>
28 #include "SDI_hook.h"
29 #include "macros.h"
31 #include "debug.h"
33 /**************************************************************************/
35 struct data
37 Object *mailerList;
39 Object *name;
40 Object *path;
41 Object *port;
43 Object *show;
44 Object *toFront;
45 Object *write;
47 Object *use;
48 Object *cancel;
50 struct URL_MailerNode *mn;
52 ULONG flags;
55 enum
57 FLG_Notifies = 1<<0,
60 /**************************************************************************/
62 static CONST_STRPTR syms[] =
64 "%a",
65 "%s",
66 "%b",
67 "%f",
68 "%u",
69 "%p",
70 NULL
73 static STRPTR names[] =
75 (STRPTR)MSG_Mailer_PopAddress,
76 (STRPTR)MSG_Mailer_Popsubject,
77 (STRPTR)MSG_Mailer_PopBodyText,
78 (STRPTR)MSG_Mailer_PopBodyFile,
79 (STRPTR)MSG_Edit_PopURL,
80 (STRPTR)MSG_Edit_PopScreen,
81 NULL
85 static IPTR mNew(struct IClass *cl, Object *obj, struct opSet *msg)
87 struct data temp;
88 struct URL_MailerNode *mn;
89 struct TagItem *attrs = msg->ops_AttrList;
91 memset(&temp,0,sizeof(temp));
93 temp.mailerList = (Object *)GetTagData(MUIA_MailerEditWin_ListObj,(IPTR)NULL,attrs);
94 if (!temp.mailerList) return 0;
96 mn = temp.mn = (struct URL_MailerNode *)GetTagData(MUIA_MailerEditWin_Mailer,(IPTR)NULL,attrs);
97 if (!mn) return 0;
99 if((obj = (Object *)DoSuperNew(cl,obj,
100 MUIA_HelpNode, "MWIN",
101 MUIA_Window_ID, MAKE_ID('E', 'D', 'M', 'L'),
102 MUIA_Window_Title, getString(MSG_Mailer_WinTitle),
103 MUIA_Window_AllowTopMenus, FALSE,
104 MUIA_Window_ScreenTitle, getString(MSG_App_ScreenTitle),
106 WindowContents, VGroup,
107 Child, ColGroup(2),
108 GroupFrameT(getString(MSG_Edit_Definitions)),
110 Child, olabel2(MSG_Edit_Name),
111 Child, temp.name = ostring(NAME_LEN,MSG_Edit_Name,MSG_Edit_Name_Help),
113 Child, olabel2(MSG_Edit_Path),
114 Child, temp.path = opopph(syms,names,PATH_LEN,MSG_Edit_Path,TRUE,MSG_Edit_Path_Help),
116 Child, olabel2(MSG_Edit_Port),
117 Child, temp.port = opopport(PORT_LEN,MSG_Edit_Port,MSG_Edit_Port_Help),
118 End,
120 Child, ColGroup(2),
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_Mailer_Write),
130 Child, temp.write = opopph(syms,names,WRITEMAILCMD_LEN,MSG_Mailer_Write,FALSE,MSG_Mailer_Write_Help),
131 End,
133 Child, ColGroup(3),
134 Child, temp.use = obutton(MSG_Edit_Use,MSG_Edit_Use_Help),
135 Child, RectangleObject, End,
136 Child, temp.cancel = obutton(MSG_Edit_Cancel,MSG_Edit_Cancel_Help),
137 End,
138 End,
139 TAG_MORE, attrs)) != NULL)
141 struct data *data = INST_DATA(cl,obj);
143 CopyMem(&temp,data,sizeof(*data));
145 set(data->name,MUIA_String_Contents,mn->umn_Name);
146 set(data->path,MUIA_String_Contents,mn->umn_Path);
147 set(data->port,MUIA_String_Contents,mn->umn_Port);
148 set(data->show,MUIA_String_Contents,mn->umn_ShowCmd);
149 set(data->toFront,MUIA_String_Contents,mn->umn_ToFrontCmd);
150 set(data->write,MUIA_String_Contents,mn->umn_WriteMailCmd);
153 return (IPTR)obj;
156 /**************************************************************************/
158 static IPTR mGet(struct IClass *cl, Object *obj, struct opGet *msg)
160 struct data *data = INST_DATA(cl,obj);
162 switch (msg->opg_AttrID)
164 case MUIA_MailerEditWin_Mailer: *msg->opg_Storage = (IPTR)data->mn; return TRUE;
165 case MUIA_App_IsSubWin: *msg->opg_Storage = TRUE; return TRUE;
166 default: return DoSuperMethodA(cl,obj,(Msg)msg);
170 /**************************************************************************/
172 static IPTR mWindow_Setup(struct IClass *cl, Object *obj, struct MUIP_Window_Setup *msg)
174 IPTR result = FALSE;
176 ENTER();
178 if(DoSuperMethodA(cl, obj, (Msg)msg))
180 struct data *data = INST_DATA(cl, obj);
182 if(isFlagClear(data->flags, FLG_Notifies))
184 DoMethod(data->use, MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)obj, 1, MUIM_MailerEditWin_Use);
185 DoMethod(data->cancel, MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)obj, 3, MUIM_Set, MUIA_Window_CloseRequest, TRUE);
187 DoMethod(obj, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, (IPTR)_app(obj), 6, MUIM_Application_PushMethod,
188 (IPTR)_app(obj), 3, MUIM_App_CloseWin, MUIA_MailerEditWin_Mailer, (IPTR)data->mn);
190 SET_FLAG(data->flags, FLG_Notifies);
192 result = TRUE;
196 RETURN(result);
197 return result;
200 /**************************************************************************/
202 static IPTR mUse(struct IClass *cl, Object *obj, UNUSED Msg msg)
204 struct data *data = INST_DATA(cl,obj);
205 struct URL_MailerNode *mn = data->mn;
206 LONG i, visible, first;
208 CLEAR_FLAG(mn->umn_Flags, UNF_NEW);
210 strlcpy(mn->umn_Name, (STRPTR)xget(data->name,MUIA_String_Contents), sizeof(mn->umn_Name));
211 strlcpy(mn->umn_Path, (STRPTR)xget(data->path,MUIA_String_Contents), sizeof(mn->umn_Path));
212 strlcpy(mn->umn_Port, (STRPTR)xget(data->port,MUIA_String_Contents), sizeof(mn->umn_Port));
214 strlcpy(mn->umn_ShowCmd, (STRPTR)xget(data->show,MUIA_String_Contents), sizeof(mn->umn_ShowCmd));
215 strlcpy(mn->umn_ToFrontCmd, (STRPTR)xget(data->toFront,MUIA_String_Contents), sizeof(mn->umn_ToFrontCmd));
216 strlcpy(mn->umn_WriteMailCmd, (STRPTR)xget(data->write,MUIA_String_Contents), sizeof(mn->umn_WriteMailCmd));
218 visible = xget(data->mailerList, MUIA_List_Visible);
219 if (visible != -1)
221 first = xget(data->mailerList, MUIA_List_First);
223 for (i = first; i<(first + visible); i++)
225 DoMethod(data->mailerList,MUIM_List_GetEntry,i,(IPTR)&mn);
226 if (!mn) break;
228 if (mn==data->mn)
230 DoMethod(data->mailerList,MUIM_List_Redraw,i);
231 break;
236 set(obj,MUIA_Window_CloseRequest,TRUE);
238 return TRUE;
241 /**************************************************************************/
243 SDISPATCHER(dispatcher)
245 switch (msg->MethodID)
247 case OM_NEW: return mNew(cl,obj,(APTR)msg);
248 case OM_GET: return mGet(cl,obj,(APTR)msg);
250 case MUIM_Window_Setup: return mWindow_Setup(cl,obj,(APTR)msg);
251 case MUIM_MailerEditWin_Use: return mUse(cl,obj,(APTR)msg);
253 default: return DoSuperMethodA(cl,obj,msg);
257 /**************************************************************************/
259 BOOL initMailerEditWinClass(void)
261 BOOL success = FALSE;
263 ENTER();
265 if((g_mailerEditWinClass = MUI_CreateCustomClass(NULL, MUIC_Window, NULL, sizeof(struct data), ENTRY(dispatcher))) != NULL)
267 localizeStrings(names);
268 success = TRUE;
271 RETURN(success);
272 return success;
275 /**************************************************************************/
277 void disposeMailerEditWinClass(void)
279 ENTER();
281 if(g_mailerEditWinClass != NULL)
282 MUI_DeleteCustomClass(g_mailerEditWinClass);
284 LEAVE();
287 /**************************************************************************/