2 ** OpenURL - MUI preferences for openurl.library
4 ** Written by Troels Walsted Hansen <troels@thule.no>
5 ** Placed in the public domain.
8 ** - Alfonso Ranieri <alforan@tin.it>
9 ** - Stefan Kost <ensonic@sonicpulse.de>
11 ** Ported to OS4 by Alexandre Balaban <alexandre@balaban.name>
18 #define CATCOMP_NUMBERS
20 #include <graphics/gfxbase.h>
22 #include <libraries/openurl.h>
24 /**************************************************************************/
26 LONG __stack
= 32000; /* I think this is OK in every env */
28 struct IntuitionBase
*IntuitionBase
= NULL
;
29 struct GfxBase
*GfxBase
= NULL
;
30 struct Library
*MUIMasterBase
= NULL
;
32 struct UtilityBase
*UtilityBase
= NULL
;
34 struct Library
*UtilityBase
= NULL
;
36 struct Library
*IconBase
= NULL
;
37 struct Library
*OpenURLBase
= NULL
;
38 struct LocaleBase
*LocaleBase
= NULL
;
40 #if defined(__amigaos4__)
41 struct IntuitionIFace
*IIntuition
= NULL
;
42 struct GraphicsIFace
*IGraphics
= NULL
;
43 struct MUIMasterIFace
*IMUIMaster
= NULL
;
44 struct UtilityIFace
*IUtility
= NULL
;
45 struct IconIFace
*IIcon
= NULL
;
46 struct OpenURLIFace
*IOpenURL
= NULL
;
47 struct LocaleIFace
*ILocale
= NULL
;
50 struct MUI_CustomClass
*g_appClass
= NULL
;
51 struct MUI_CustomClass
*g_pensClass
= NULL
;
52 struct MUI_CustomClass
*g_aboutClass
= NULL
;
53 struct MUI_CustomClass
*g_winClass
= NULL
;
54 struct MUI_CustomClass
*g_appListClass
= NULL
;
55 struct MUI_CustomClass
*g_browserEditWinClass
= NULL
;
56 struct MUI_CustomClass
*g_mailerEditWinClass
= NULL
;
57 struct MUI_CustomClass
*g_FTPEditWinClass
= NULL
;
58 struct MUI_CustomClass
*g_popportClass
= NULL
;
59 struct MUI_CustomClass
*g_popphClass
= NULL
;
62 struct Catalog
*g_cat
= NULL
;
63 //ULONG g_MUI4 = FALSE;
65 /**************************************************************************/
68 openStuff(ULONG
*arg0
,ULONG
*arg1
)
72 if (!(MUIMasterBase
= OpenLibrary("muimaster.library",19)) || (MUIMasterBase
->lib_Version
<19))
77 #if defined(__amigaos4__)
78 if (!(IMUIMaster
= (struct MUIMasterIFace
*)GetInterface( MUIMasterBase
, "main", 1L, NULL
))) return MSG_Err_NoMUI
;
80 if (!(g_pool
= CreatePool(MEMF_PUBLIC
|MEMF_CLEAR
,8192,4196))) return MSG_Err_NoMem
;
84 if (!(IntuitionBase
= (struct IntuitionBase
*)OpenLibrary("intuition.library",37))) return MSG_Err_NoIntuition
;
85 if (!(GfxBase
= (struct GfxBase
*)OpenLibrary("graphics.library",37))) return MSG_Err_NoGfx
;
86 if (!(UtilityBase
= OpenLibrary("utility.library",37))) return MSG_Err_NoUtility
;
87 if (!(IconBase
= OpenLibrary("icon.library",37))) return MSG_Err_NoIcon
;
89 #if defined(__amigaos4__)
90 if (!(IIntuition
= (struct IntuitionIFace
*)GetInterface( (struct Library
*)IntuitionBase
, "main", 1L, NULL
))) return MSG_Err_NoIntuition
;
91 if (!(IGraphics
= (struct GraphicsIFace
*)GetInterface( (struct Library
*)GfxBase
, "main", 1L, NULL
))) return MSG_Err_NoGfx
;
92 if (!(IUtility
= (struct UtilityIFace
*)GetInterface( UtilityBase
, "main", 1L, NULL
))) return MSG_Err_NoUtility
;
93 if (!(IIcon
= (struct IconIFace
*)GetInterface( IconBase
, "main", 1L, NULL
))) return MSG_Err_NoIcon
;
96 if (!(OpenURLBase
= OpenLibrary(OPENURLNAME
,6)) /*||
97 ((OpenURLBase->lib_Version==OPENURLREV) && (OpenURLBase->lib_Revision<OPENURLREV))*/)
102 return MSG_Err_NoOpenURL
;
105 #if defined(__amigaos4__)
106 if (!(IOpenURL
= (struct OpenURLIFace
*)GetInterface( OpenURLBase
, "main", 1L, NULL
)))
111 return MSG_Err_NoOpenURL
;
114 // setup the AmiUpdate variable
115 SetAmiUpdateENVVariable( "Open URL" );
121 /**************************************************************************/
130 if (g_cat
) CloseCatalog(g_cat
);
132 #if defined(__amigaos4__)
135 DropInterface((struct Interface
*)ILocale
);
140 CloseLibrary((struct Library
*)LocaleBase
);
144 #if defined(__amigaos4__)
147 DropInterface((struct Interface
*)IMUIMaster
);
152 DropInterface((struct Interface
*)IIntuition
);
157 DropInterface((struct Interface
*)IUtility
);
162 DropInterface((struct Interface
*)IIcon
);
167 DropInterface((struct Interface
*)IOpenURL
);
172 if (OpenURLBase
) CloseLibrary(OpenURLBase
);
173 if (IconBase
) CloseLibrary(IconBase
);
174 if (UtilityBase
) CloseLibrary(UtilityBase
);
175 if (GfxBase
) CloseLibrary((struct Library
*)GfxBase
);
176 if (IntuitionBase
) CloseLibrary((struct Library
*)IntuitionBase
);
177 if (MUIMasterBase
) CloseLibrary(MUIMasterBase
);
179 if (g_pool
) DeletePool(g_pool
);
182 /**************************************************************************/
187 if (!initPopphClass()) return MSG_Err_PopphClass
;
188 if (!initPopportClass()) return MSG_Err_PopupPortClass
;
189 if (!initFTPEditWinClass()) return MSG_Err_NoFTPEditWinClass
;
190 if (!initMailerEditWinClass()) return MSG_Err_NoMailerEditWinClass
;
191 if (!initBrowserEditWinClass()) return MSG_Err_NoBrowserEditWinClass
;
192 if (!initAppListClass()) return MSG_Err_NoAppListClass
;
193 if (!initPensClass()) return MSG_Err_NoPensClass
;
194 if (!initWinClass()) return MSG_Err_NoWinClass
;
195 if (!initAppClass()) return MSG_Err_NoAppClass
;
200 /**************************************************************************/
205 if (g_popphClass
) disposePopphClass();
206 if (g_popportClass
) disposePopportClass();
207 if (g_FTPEditWinClass
) disposeFTPEditWinClass();
208 if (g_mailerEditWinClass
) disposeMailerEditWinClass();
209 if (g_browserEditWinClass
) disposeBrowserEditWinClass();
210 if (g_appListClass
) disposeAppListClass();
211 if (g_winClass
) disposeWinClass();
212 if (g_pensClass
) disposePensClass();
213 if (g_aboutClass
) disposeAboutClass();
214 if (g_appClass
) disposeAppClass();
217 /**************************************************************************/
221 realMain(int argc
,char **argv
)
224 main(int argc
,char **argv
)
227 ULONG error
, arg0
, arg1
;
228 int res
= RETURN_FAIL
;
232 if (!(error
= openStuff(&arg0
,&arg1
)))
234 if (!(error
= createClasses()))
238 if (app
= appObject
, End
)
242 for (signals
= 0; DoMethod(app
,MUIM_Application_NewInput
,(ULONG
)&signals
)!=MUIV_Application_ReturnID_Quit
; )
243 if (signals
&& ((signals
= Wait(signals
| SIGBREAKF_CTRL_C
)) & SIGBREAKF_CTRL_C
)) break;
245 MUI_DisposeObject(app
);
249 else error
= MSG_Err_NoApp
;
259 msnprintf(buf
,sizeof(buf
),getString(error
),arg0
,arg1
);
263 Object
*app
= ApplicationObject
,
264 MUIA_Application_UseCommodities
, FALSE
,
265 MUIA_Application_UseRexx
, FALSE
,
268 MUI_RequestA(app
,NULL
,0,getString(MSG_ErrReqTitle
),getString(MSG_ErrReqGadget
),buf
,NULL
);
270 if (app
) MUI_DisposeObject(app
);
272 else Printf("%s\n",(ULONG
)buf
);
280 /**************************************************************************/
283 #define MIN68KSTACKSIZE 16000
286 main(int argc
,char **argv
)
288 struct Task
*me
= FindTask(NULL
);
291 if (!NewGetTaskAttrsA(me
,&size
,sizeof(size
),TASKINFOTYPE_STACKSIZE_M68K
,NULL
))
294 if (size
<MIN68KSTACKSIZE
)
296 struct StackSwapStruct
*sss
;
298 if (sss
= AllocMem(sizeof(*sss
)+MIN68KSTACKSIZE
,MEMF_PUBLIC
))
302 sss
->stk_Lower
= sss
+1;
303 sss
->stk_Upper
= (ULONG
)(((UBYTE
*)(sss
+ 1))+MIN68KSTACKSIZE
);
304 sss
->stk_Pointer
= (APTR
)sss
->stk_Upper
;
306 res
= realMain(argc
,argv
);
308 FreeMem(sss
,sizeof(*sss
)+MIN68KSTACKSIZE
);
314 return realMain(argc
,argv
);
319 /***********************************************************************/