10 #include <exec/types.h>
11 #include <exec/memory.h>
12 #include <exec/ports.h>
14 #include <exec/execbase.h>
16 #include <libraries/dos.h>
17 #include <libraries/dosextens.h>
18 #include <libraries/gadtools.h>
19 #include <libraries/asl.h>
20 #include <libraries/mui.h>
21 #include <devices/clipboard.h>
22 #include <workbench/workbench.h>
23 #include <workbench/icon.h>
24 #include <intuition/intuition.h>
25 #include <intuition/classusr.h>
26 #include <prefs/prefhdr.h>
28 #include <clib/alib_protos.h>
32 #include <proto/exec.h>
33 #include <proto/dos.h>
34 #include <proto/icon.h>
35 #include <proto/intuition.h>
36 #include <proto/gadtools.h>
37 #include <proto/utility.h>
38 #include <proto/asl.h>
39 #include <proto/muimaster.h>
40 #include <proto/locale.h>
41 #include <proto/scalosprefsplugin.h>
44 #include <Year.h> // +jmc+
45 #include <scalosdebug.h>
47 #include <scalos/scalosprefsplugin.h>
49 struct ScalosFileTypes_LocaleInfo
53 struct LocaleIFace
*li_ILocale
;
56 #define ScalosFileTypes_NUMBERS
57 #define ScalosFileTypes_ARRAY
58 #define ScalosFileTypes_CODE
59 #include STR(SCALOSLOCALE)
61 //----------------------------------------------------------------------------
63 #define Sizeof(array) (sizeof(array) / sizeof((array)[0]))
65 //----------------------------------------------------------------------------
67 #if !defined(__amigaos4__) && !defined(__AROS__)
70 long _stack
= 16384; // minimum stack size, used by SAS/C startup code
73 //----------------------------------------------------------------------------
75 // local data structures
77 #define KeyButtonHelp(name,key,HelpText)\
80 MUIA_Font, MUIV_Font_Button,\
81 MUIA_Text_Contents, name,\
82 MUIA_Text_PreParse, "\33c",\
83 MUIA_Text_HiChar , key,\
84 MUIA_ControlChar , key,\
85 MUIA_CycleChain , TRUE, \
86 MUIA_InputMode , MUIV_InputMode_RelVerify,\
87 MUIA_Background , MUII_ButtonBack,\
88 MUIA_ShortHelp, HelpText,\
92 #define Application_Return_EDIT 0
93 #define Application_Return_USE 1001
94 #define Application_Return_SAVE 1002
96 //----------------------------------------------------------------------------
100 static void init(void);
101 static void fail(APTR APP_Main
, CONST_STRPTR str
);
102 static BOOL
OpenLibraries(void);
103 static void CloseLibraries(void);
104 static SAVEDS(APTR
) INTERRUPT
OpenAboutMUIFunc(struct Hook
*hook
, Object
*o
, Msg msg
);
105 static STRPTR
GetLocString(ULONG MsgId
);
106 //static void TranslateStringArray(STRPTR *stringArray);
107 static struct MUI_CustomClass
*OpenPrefsModule(CONST_STRPTR FileName
);
108 static struct TagItem
*CreatePluginSubWindowArray(void);
109 static void DisposePrefsPlugin(void);
110 static BOOL
CheckMCCforPlugin(STRPTR
*UsedClasses
, size_t MaxUsedClasses
);
111 static BOOL
CheckMCCVersion(CONST_STRPTR name
, ULONG minver
, ULONG minrev
);
112 #if !defined(__SASC) &&!defined(__MORPHOS__)
113 size_t stccpy(char *dest
, const char *src
, size_t MaxLen
);
114 #endif /* !defined(__SASC) &&!defined(__MORPHOS__) */
116 //----------------------------------------------------------------------------
120 struct Library
*MUIMasterBase
;
121 T_LOCALEBASE LocaleBase
;
122 struct Library
*IconBase
;
123 struct IntuitionBase
*IntuitionBase
;
124 struct Library
*ScalosPrefsPluginBase
;
127 extern struct Library
*SysBase
;
128 struct MUIMasterIFace
*IMUIMaster
;
129 struct LocaleIFace
*ILocale
;
130 struct IconIFace
*IIcon
;
131 struct IntuitionIFace
*IIntuition
;
132 struct ScalosPrefsPluginIFace
*IScalosPrefsPlugin
;
135 static struct Catalog
*FileTypesCatalog
;
137 static struct Hook AboutMUIHook
= { { NULL
, NULL
}, HOOKFUNC_DEF(OpenAboutMUIFunc
), NULL
};
139 static struct MUI_CustomClass
*FileTypesPluginClass
;
141 static struct TagItem
*SubWindowTagList
;
143 static APTR Group_Plugin
;
144 static APTR Group_Buttons2
;
145 static Object
**PluginSubWindows
;
146 static APTR APP_Main
;
147 static APTR WIN_Main
;
148 static APTR WIN_AboutMUI
;
149 static APTR WIN_Splash
; // +jmc+
150 static APTR TEXT_Splash
; // +jmc+
151 static APTR SaveButton
, UseButton
, CancelButton
;
152 static APTR MenuOpen
, MenuSaveAs
;
153 static APTR MenuAbout
, MenuAboutMUI
, MenuQuit
;
154 static APTR MenuResetToDefaults
, MenuLastSaved
, MenuRestore
;
155 static APTR MenuCreateIcons
;
157 //----------------------------------------------------------------------------
159 int main(int argc
, char *argv
[])
161 LONG Action
= Application_Return_EDIT
;
163 struct RDArgs
*rdArgs
= NULL
;
164 CONST_STRPTR GivenFileName
= NULL
;
165 BPTR oldDir
= (BPTR
)NULL
;
166 ULONG fCreateIcons
= TRUE
;
167 struct DiskObject
*FileTypesDiskObject
= NULL
;
168 struct DiskObject
*icon
= NULL
;
170 STRPTR UsedClasses
[32];
171 struct WBStartup
*WBenchMsg
=
172 (argc
== 0) ? (struct WBStartup
*)argv
: NULL
;
176 if (WBenchMsg
&& WBenchMsg
->sm_ArgList
)
178 static char PrgNamePath
[512];
181 if (WBenchMsg
->sm_NumArgs
> 1)
183 arg
= &WBenchMsg
->sm_ArgList
[1];
184 GivenFileName
= arg
->wa_Name
;
188 arg
= &WBenchMsg
->sm_ArgList
[0];
191 ProgramName
= PrgNamePath
;
193 NameFromLock(WBenchMsg
->sm_ArgList
[0].wa_Lock
, PrgNamePath
, sizeof(PrgNamePath
));
194 AddPart(PrgNamePath
, WBenchMsg
->sm_ArgList
[0].wa_Name
, sizeof(PrgNamePath
));
196 oldDir
= CurrentDir(arg
->wa_Lock
);
197 icon
= GetDiskObject(arg
->wa_Name
);
202 tt
= FindToolType(icon
->do_ToolTypes
, "CREATEICONS");
205 if (MatchToolValue(tt
, "NO"))
206 fCreateIcons
= FALSE
;
209 tt
= FindToolType(icon
->do_ToolTypes
, "ACTION");
212 if (MatchToolValue(tt
, "EDIT"))
213 Action
= Application_Return_EDIT
;
214 if (MatchToolValue(tt
, "USE"))
215 Action
= Application_Return_USE
;
216 if (MatchToolValue(tt
, "SAVE"))
217 Action
= Application_Return_SAVE
;
225 ProgramName
= argv
[0];
227 memset(ArgArray
, 0, sizeof(ArgArray
));
229 rdArgs
= ReadArgs("FROM,EDIT/S,USE/S,SAVE/S", ArgArray
, NULL
);
232 GivenFileName
= (CONST_STRPTR
) ArgArray
[0];
234 Action
= Application_Return_EDIT
;
236 Action
= Application_Return_USE
;
238 Action
= Application_Return_SAVE
;
241 if (NULL
== FileTypesPluginClass
)
242 fail(APP_Main
, "Failed to open FileTypes Plugin.");
244 Group_Plugin
= NewObject(FileTypesPluginClass
->mcc_Class
, 0,
245 MUIA_ScalosPrefs_CreateIcons
, fCreateIcons
,
246 MUIA_ScalosPrefs_ProgramName
, (IPTR
) ProgramName
,
248 if (NULL
== Group_Plugin
)
249 fail(APP_Main
, "Failed to create Group_Plugin.");
251 if (!CheckMCCforPlugin(UsedClasses
, Sizeof(UsedClasses
)))
252 fail(APP_Main
, "Required MCC missing.");
254 FileTypesDiskObject
= GetDiskObject(ProgramName
);
256 SubWindowTagList
= CreatePluginSubWindowArray();
258 APP_Main
= ApplicationObject
,
259 MUIA_Application_Title
, (IPTR
)GetLocString(MSGID_TITLENAME
),
260 MUIA_Application_Version
, (IPTR
)"$VER: Scalos FileTypes Prefs V40.24 (" __DATE__
")" COMPILER_STRING
,
261 MUIA_Application_Copyright
, (IPTR
)"The Scalos Team, 2000" CURRENTYEAR
,
262 MUIA_Application_Author
, (IPTR
)"The Scalos Team",
263 MUIA_Application_Description
, (IPTR
)"Scalos FileTypes preferences editor",
264 MUIA_Application_Base
, (IPTR
)"SCALOS_FILETYPES",
265 FileTypesDiskObject
? MUIA_Application_DiskObject
: TAG_IGNORE
, (IPTR
)FileTypesDiskObject
,
266 #if defined(MUIA_Application_UsedClasses)
267 MUIA_Application_UsedClasses
, UsedClasses
,
268 #endif /* MUIA_Application_UsedClasses */
270 SubWindow
, (IPTR
)(WIN_Main
= WindowObject
,
271 MUIA_Window_Title
, (IPTR
)GetLocString(MSGID_TITLENAME
),
272 MUIA_Window_ID
, MAKE_ID('M','A','I','N'),
273 MUIA_Window_AppWindow
, TRUE
,
274 WindowContents
, (IPTR
)(VGroup
,
275 Child
, (IPTR
)Group_Plugin
,
277 Child
, (IPTR
)(Group_Buttons2
= HGroup
,
278 MUIA_Group_SameWidth
, TRUE
,
279 Child
, (IPTR
)(SaveButton
= KeyButtonHelp(GetLocString(MSGID_SAVENAME
),
280 's', GetLocString(MSGID_SHORTHELP_SAVEBUTTON
))),
281 Child
, (IPTR
)(UseButton
= KeyButtonHelp(GetLocString(MSGID_USENAME
),
282 'u', GetLocString(MSGID_SHORTHELP_USEBUTTON
))),
283 Child
, (IPTR
)(CancelButton
= KeyButtonHelp(GetLocString(MSGID_CANCELNAME
),
284 'c', GetLocString(MSGID_SHORTHELP_CANCELBUTTON
))),
289 // -----------------------------------------------------------------------------------------------
291 SubWindow
, (IPTR
)(WIN_Splash
= WindowObject
,
292 MUIA_Window_AppWindow
, FALSE
,
293 MUIA_Window_CloseGadget
, FALSE
,
294 MUIA_Window_DepthGadget
, FALSE
,
295 MUIA_Window_DragBar
, FALSE
,
296 MUIA_Window_NoMenus
, TRUE
,
297 MUIA_Window_LeftEdge
, MUIV_Window_LeftEdge_Centered
,
298 MUIA_Window_TopEdge
, MUIV_Window_TopEdge_Centered
,
300 WindowContents
, (IPTR
)(VGroup
,
301 Child
, (IPTR
)(TEXT_Splash
= TextObject
,
303 MUIA_Text_Contents
, (IPTR
) GetLocString(MSGID_SPLASHWINDOW_LOADING_FILETYPES_PREFS
),
309 // -----------------------------------------------------------------------------------------------
311 MUIA_Application_Menustrip
, (IPTR
)(MenustripObject
,
312 Child
, (IPTR
)(MenuObjectT(GetLocString(MSGID_MENU_PROJECT
)),
313 Child
, (IPTR
)(MenuOpen
= MenuitemObject
,
314 MUIA_Menuitem_Title
, (IPTR
)GetLocString(MSGID_MENU_PROJECT_OPEN
),
315 MUIA_Menuitem_Shortcut
, (IPTR
)GetLocString(MSGID_MENU_PROJECT_OPEN_SHORT
),
317 Child
, (IPTR
)(MenuSaveAs
= MenuitemObject
,
318 MUIA_Menuitem_Title
, (IPTR
)GetLocString(MSGID_MENU_PROJECT_SAVEAS
),
319 MUIA_Menuitem_Shortcut
, (IPTR
)GetLocString(MSGID_MENU_PROJECT_SAVEAS_SHORT
),
321 Child
, (IPTR
)(MenuitemObject
,
322 MUIA_Menuitem_Title
, -1,
324 Child
, (IPTR
)(MenuAbout
= MenuitemObject
,
325 MUIA_Menuitem_Title
, (IPTR
)GetLocString(MSGID_MENU_PROJECT_ABOUT
),
327 Child
, (IPTR
)(MenuAboutMUI
= MenuitemObject
,
328 MUIA_Menuitem_Title
, (IPTR
)GetLocString(MSGID_MENU_PROJECT_ABOUTMUI
),
330 Child
, (IPTR
)(MenuitemObject
,
331 MUIA_Menuitem_Title
, -1,
333 Child
, (IPTR
)(MenuQuit
= MenuitemObject
,
334 MUIA_Menuitem_Title
, (IPTR
)GetLocString(MSGID_MENU_PROJECT_QUIT
),
335 MUIA_Menuitem_Shortcut
, (IPTR
)GetLocString(MSGID_MENU_PROJECT_QUIT_SHORT
),
339 Child
, (IPTR
)(MenuObjectT(GetLocString(MSGID_MENU_EDIT
)),
340 Child
, (IPTR
)(MenuResetToDefaults
= MenuitemObject
,
341 MUIA_Menuitem_Title
, (IPTR
)GetLocString(MSGID_MENU_EDIT_RESETTODEFAULTS
),
342 MUIA_Menuitem_Shortcut
, (IPTR
)GetLocString(MSGID_MENU_EDIT_RESETTODEFAULTS_SHORT
),
344 Child
, (IPTR
)(MenuLastSaved
= MenuitemObject
,
345 MUIA_Menuitem_Title
, (IPTR
)GetLocString(MSGID_MENU_EDIT_LASTSAVED
),
346 MUIA_Menuitem_Shortcut
, (IPTR
)GetLocString(MSGID_MENU_EDIT_LASTSAVED_SHORT
),
348 Child
, (IPTR
)(MenuRestore
= MenuitemObject
,
349 MUIA_Menuitem_Title
, (IPTR
)GetLocString(MSGID_MENU_EDIT_RESTORE
),
350 MUIA_Menuitem_Shortcut
, (IPTR
)GetLocString(MSGID_MENU_EDIT_RESTORE_SHORT
),
353 Child
, (IPTR
)(MenuObjectT(GetLocString(MSGID_MENU_SETTINGS
)),
354 Child
, (IPTR
)(MenuCreateIcons
= MenuitemObject
,
355 MUIA_Menuitem_Title
, (IPTR
)GetLocString(MSGID_MENU_SETTINGS_CREATEICONS
),
356 MUIA_Menuitem_Shortcut
, (IPTR
)GetLocString(MSGID_MENU_SETTINGS_CREATEICONS_SHORT
),
357 MUIA_Menuitem_Checkit
, TRUE
,
358 MUIA_Menuitem_Checked
, fCreateIcons
,
361 End
), //MenuStripObject
363 SubWindowTagList
? TAG_MORE
: TAG_IGNORE
, (IPTR
)SubWindowTagList
,
364 End
; //ApplicationObject
366 if (NULL
== APP_Main
)
368 MUI_DisposeObject(Group_Plugin
);
370 fail(APP_Main
, "Failed to create Application.");
373 // +jmc+ open Splash window
374 set(WIN_Splash
, MUIA_Window_Open
, TRUE
);
376 set(Group_Plugin
, MUIA_ScalosPrefs_MainWindow
, (IPTR
) WIN_Main
);
377 set(Group_Plugin
, MUIA_ScalosPrefs_Application
, (IPTR
) APP_Main
);
379 DoMethod(Group_Plugin
, MUIM_ScalosPrefs_PageActive
, TRUE
);
381 DoMethod(WIN_Main
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
,
382 WIN_Main
, 3, MUIM_Set
, MUIA_Window_Open
, FALSE
);
383 DoMethod(WIN_Main
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
,
384 APP_Main
, 2, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
385 DoMethod(CancelButton
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
386 APP_Main
, 2, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
388 DoMethod(MenuQuit
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
389 APP_Main
, 2, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
391 DoMethod(SaveButton
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
392 APP_Main
, 2, MUIM_Application_ReturnID
, Application_Return_SAVE
);
394 DoMethod(UseButton
, MUIM_Notify
,MUIA_Pressed
, FALSE
,
395 APP_Main
, 2, MUIM_Application_ReturnID
, Application_Return_USE
);
397 DoMethod(MenuOpen
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
398 Group_Plugin
, 1, MUIM_ScalosPrefs_OpenConfig
);
400 DoMethod(MenuSaveAs
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
401 Group_Plugin
, 1, MUIM_ScalosPrefs_SaveConfigAs
);
403 DoMethod(MenuResetToDefaults
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
404 Group_Plugin
, 1, MUIM_ScalosPrefs_ResetToDefaults
);
406 DoMethod(MenuLastSaved
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
407 Group_Plugin
, 1, MUIM_ScalosPrefs_LastSavedConfig
);
409 DoMethod(MenuRestore
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
410 Group_Plugin
, 1, MUIM_ScalosPrefs_RestoreConfig
);
412 DoMethod(MenuAbout
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
413 Group_Plugin
, 1, MUIM_ScalosPrefs_About
);
415 DoMethod(MenuAboutMUI
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
416 APP_Main
, 2, MUIM_CallHook
, &AboutMUIHook
);
418 DoMethod(MenuCreateIcons
, MUIM_Notify
, MUIA_Menuitem_Checked
, MUIV_EveryTime
,
419 Group_Plugin
, 3, MUIM_Set
, MUIA_ScalosPrefs_CreateIcons
, MUIV_TriggerValue
);
421 d1(kprintf(__FUNC__
"/%ld: \n", __LINE__
));
425 DoMethod(Group_Plugin
, MUIM_ScalosPrefs_ParseToolTypes
, icon
->do_ToolTypes
);
430 DoMethod(Group_Plugin
, MUIM_ScalosPrefs_LoadNamedConfig
, GivenFileName
);
434 DoMethod(Group_Plugin
, MUIM_ScalosPrefs_LoadConfig
);
437 if (Application_Return_EDIT
== Action
)
439 set(WIN_Main
, MUIA_Window_Open
, TRUE
);
441 get(WIN_Main
, MUIA_Window_Open
, &win_opened
);
443 // +jmc+ close Splash window
444 set(WIN_Splash
, MUIA_Window_Open
, FALSE
);
453 Action
= DoMethod(APP_Main
, MUIM_Application_NewInput
, &sigs
);
457 case MUIV_Application_ReturnID_Quit
:
458 case Application_Return_SAVE
:
459 case Application_Return_USE
:
466 sigs
= Wait(sigs
| SIGBREAKF_CTRL_C
);
468 if (sigs
& SIGBREAKF_CTRL_C
)
478 printf("failed to open main window !\n");
484 case Application_Return_SAVE
:
485 set(TEXT_Splash
, MUIA_Text_Contents
, (IPTR
) GetLocString(MSGID_SPLASHWINDOW_SAVING_FILETYPES_PREFS
)); // +jmc+
486 set(WIN_Splash
, MUIA_Window_Open
, TRUE
); // +jmc+
487 DoMethod(Group_Plugin
, MUIM_ScalosPrefs_SaveConfig
);
489 case Application_Return_USE
:
490 set(TEXT_Splash
, MUIA_Text_Contents
, (IPTR
) GetLocString(MSGID_SPLASHWINDOW_APPLYING_FILETYPES_PREFS
)); // +jmc+
491 set(WIN_Splash
, MUIA_Window_Open
, TRUE
); // +jmc+
492 DoMethod(Group_Plugin
, MUIM_ScalosPrefs_UseConfig
);
496 set(WIN_Main
, MUIA_Window_Open
, FALSE
);
497 set(WIN_Splash
, MUIA_Window_Open
, FALSE
); // +jmc+
499 if (FileTypesDiskObject
)
500 FreeDiskObject(FileTypesDiskObject
);
502 FreeDiskObject(icon
);
508 fail(APP_Main
, NULL
);
514 static VOID
fail(APTR APP_Main
, CONST_STRPTR str
)
517 MUI_DisposeObject(APP_Main
);
519 DisposePrefsPlugin();
521 if (FileTypesCatalog
)
523 CloseCatalog(FileTypesCatalog
);
524 FileTypesCatalog
= NULL
;
539 static void init(void)
541 if (!OpenLibraries())
542 fail(NULL
, "Failed to open "MUIMASTER_NAME
".");
545 FileTypesCatalog
= OpenCatalogA(NULL
, "Scalos/ScalosFileTypes.catalog", NULL
);
547 FileTypesPluginClass
= OpenPrefsModule("FileTypes.prefsplugin");
551 static BOOL
OpenLibraries(void)
553 IntuitionBase
= (struct IntuitionBase
*) OpenLibrary("intuition.library", 39);
554 if (NULL
== IntuitionBase
)
557 IIntuition
= (struct IntuitionIFace
*) GetInterface((struct Library
*)IntuitionBase
, "main", 1, NULL
);
558 if (NULL
== IIntuition
)
562 MUIMasterBase
= OpenLibrary("zune.library", 0);
563 if (NULL
== MUIMasterBase
)
564 MUIMasterBase
= OpenLibrary(MUIMASTER_NAME
, MUIMASTER_VMIN
-1);
565 if (NULL
== MUIMasterBase
)
568 IMUIMaster
= (struct MUIMasterIFace
*) GetInterface((struct Library
*)MUIMasterBase
, "main", 1, NULL
);
569 if (NULL
== IMUIMaster
)
573 IconBase
= OpenLibrary("icon.library", 0);
574 if (NULL
== IconBase
)
577 IIcon
= (struct IconIFace
*) GetInterface((struct Library
*)IconBase
, "main", 1, NULL
);
582 LocaleBase
= (T_LOCALEBASE
) OpenLibrary("locale.library", 39);
585 ILocale
= (struct LocaleIFace
*) GetInterface((struct Library
*)LocaleBase
, "main", 1, NULL
);
592 static void CloseLibraries(void)
597 DropInterface((struct Interface
*)ILocale
);
603 CloseLibrary((struct Library
*) LocaleBase
);
609 DropInterface((struct Interface
*)IIcon
);
615 CloseLibrary(IconBase
);
621 DropInterface((struct Interface
*)IMUIMaster
);
627 CloseLibrary(MUIMasterBase
);
628 MUIMasterBase
= NULL
;
633 DropInterface((struct Interface
*)IIntuition
);
639 CloseLibrary((struct Library
*) IntuitionBase
);
640 IntuitionBase
= NULL
;
644 //----------------------------------------------------------------------------
646 static STRPTR
GetLocString(ULONG MsgId
)
648 struct ScalosFileTypes_LocaleInfo li
;
650 li
.li_Catalog
= FileTypesCatalog
;
652 li
.li_LocaleBase
= LocaleBase
;
654 li
.li_ILocale
= ILocale
;
657 return (STRPTR
) GetScalosFileTypesString(&li
, MsgId
);
660 static void TranslateStringArray(STRPTR *stringArray)
664 *stringArray = GetLocString((IPTR) *stringArray);
669 //----------------------------------------------------------------------------
671 static SAVEDS(APTR
) INTERRUPT
OpenAboutMUIFunc(struct Hook
*hook
, Object
*o
, Msg msg
)
673 if (NULL
== WIN_AboutMUI
)
675 WIN_AboutMUI
= MUI_NewObject(MUIC_Aboutmui
,
676 MUIA_Window_RefWindow
, WIN_Main
,
677 MUIA_Aboutmui_Application
, APP_Main
,
682 set(WIN_AboutMUI
, MUIA_Window_Open
, TRUE
);
687 //----------------------------------------------------------------------------
689 static struct MUI_CustomClass
*OpenPrefsModule(CONST_STRPTR FileName
)
691 struct MUI_CustomClass
*pclass
= NULL
;
693 d1(kprintf(__FUNC__
"/%ld: FileName=<%s>\n", __LINE__
, FileName
));
696 ScalosPrefsPluginBase
= OpenLibrary(FileName
, 0);
697 d1(kprintf(__FUNC__
"/%ld: ScalosPrefsPluginBase=%08lx\n", __LINE__
, ScalosPrefsPluginBase
));
698 if (NULL
== ScalosPrefsPluginBase
)
701 IScalosPrefsPlugin
= (struct ScalosPrefsPluginIFace
*)GetInterface(
702 ScalosPrefsPluginBase
, "main", 1, NULL
706 pclass
= (struct MUI_CustomClass
*) SCAGetPrefsInfo(SCAPREFSINFO_GetClass
);
707 d1(kprintf(__FUNC__
"/%ld: PluginClass=%08lx\n", __LINE__
, ppl
->ppl_PluginClass
));
713 DisposePrefsPlugin();
719 static struct TagItem
*CreatePluginSubWindowArray(void)
721 struct TagItem
*SubWindowTagList
;
723 ULONG SubWindowCount
= 0;
726 PluginSubWindows
= (Object
**) DoMethod(Group_Plugin
, MUIM_ScalosPrefs_CreateSubWindows
);
728 for (n
=0; PluginSubWindows
&& PluginSubWindows
[n
]; n
++)
731 SubWindowTagList
= ti
= calloc(1 + SubWindowCount
, sizeof(struct TagItem
));
732 if (NULL
== SubWindowTagList
)
735 for (n
=0; PluginSubWindows
&& PluginSubWindows
[n
]; n
++)
737 ti
->ti_Tag
= MUIA_Application_Window
;
738 ti
->ti_Data
= (IPTR
) PluginSubWindows
[n
];
742 ti
->ti_Tag
= TAG_END
;
744 return SubWindowTagList
;
748 static void DisposePrefsPlugin(void)
751 if (IScalosPrefsPlugin
)
753 DropInterface((struct Interface
*)IScalosPrefsPlugin
);
754 IScalosPrefsPlugin
= NULL
;
757 if (ScalosPrefsPluginBase
)
759 d1(kprintf(__FUNC__
"/%ld: Plugin=<%s> OpenCount=%ld\n", \
760 __LINE__
, ScalosPrefsPluginBase
->lib_Node
.ln_Name
, ScalosPrefsPluginBase
->lib_OpenCnt
));
762 if (NULL
== Group_Plugin
)
763 CloseLibrary(ScalosPrefsPluginBase
);
764 ScalosPrefsPluginBase
= NULL
;
768 //----------------------------------------------------------------------------
770 static BOOL
CheckMCCforPlugin(STRPTR
*UsedClasses
, size_t MaxUsedClasses
)
772 const struct MUIP_ScalosPrefs_MCCList
*RequiredMccList
= NULL
;
774 RequiredMccList
= (const struct MUIP_ScalosPrefs_MCCList
*) DoMethod(Group_Plugin
, MUIM_ScalosPrefs_GetListOfMCCs
);
776 while (RequiredMccList
&& RequiredMccList
->MccName
)
778 if (!CheckMCCVersion(RequiredMccList
->MccName
,
779 RequiredMccList
->MccMinVersion
,
780 RequiredMccList
->MccMinRevision
))
783 if (MaxUsedClasses
> 1)
785 *UsedClasses
++ = (STRPTR
) RequiredMccList
->MccName
;
797 //----------------------------------------------------------------------------
799 // Checks if a certain version of a MCC is available
800 static BOOL
CheckMCCVersion(CONST_STRPTR name
, ULONG minver
, ULONG minrev
)
804 d1(kprintf(__FILE__
"/" __FUNC__
"/%ld: %s ", name
, __LINE__
);)
810 struct Library
*base
;
813 // First we attempt to acquire the version and revision through MUI
814 Object
*obj
= MUI_NewObject((STRPTR
) name
, TAG_DONE
);
817 get(obj
, MUIA_Version
, &ver
);
818 get(obj
, MUIA_Revision
, &rev
);
820 MUI_DisposeObject(obj
);
822 if(ver
> minver
|| (ver
== minver
&& rev
>= minrev
))
824 d1(kprintf(__FILE__
"/" __FUNC__
"/%ld: v%ld.%ld found through MUIA_Version/Revision\n", __LINE__
, ver
, rev
);)
829 // If we did't get the version we wanted, let's try to open the
830 // libraries ourselves and see what happens...
831 stccpy(libname
, "PROGDIR:mui", sizeof(libname
));
832 AddPart(libname
, name
, sizeof(libname
));
834 if ((base
= OpenLibrary(&libname
[8], 0)) || (base
= OpenLibrary(&libname
[0], 0)))
836 UWORD OpenCnt
= base
->lib_OpenCnt
;
838 ver
= base
->lib_Version
;
839 rev
= base
->lib_Revision
;
843 // we add some additional check here so that eventual broken .mcc also have
844 // a chance to pass this test (i.e. Toolbar.mcc is broken)
845 if (ver
> minver
|| (ver
== minver
&& rev
>= minrev
))
847 d1(kprintf(__FILE__
"/" __FUNC__
"/%ld: v%ld.%ld found through OpenLibrary()\n", __LINE__
, ver
, rev
);)
853 if (MUI_Request(NULL
, NULL
, 0L, GetLocString(MSGID_STARTUP_FAILURE
),
854 GetLocString(MSGID_STARTUP_RETRY_QUIT_GAD
), GetLocString(MSGID_STARTUP_MCC_IN_USE
),
855 (IPTR
) name
, minver
, minrev
, ver
, rev
))
863 // Attempt to flush the library if open count is 0 or because the
864 // user wants to retry (meaning there's a chance that it's 0 now)
868 struct Library
*result
;
871 if ((result
= (struct Library
*) FindName(&((struct ExecBase
*)SysBase
)->LibList
, name
)))
878 d1(kprintf(__FILE__
"/" __FUNC__
"/%ld: couldn`t find minimum required version.\n", __LINE__
);)
880 // We're out of luck - open count is 0, we've tried to flush
881 // and still haven't got the version we want
882 if (MUI_Request(NULL
, NULL
, 0L, GetLocString(MSGID_STARTUP_FAILURE
),
883 GetLocString(MSGID_STARTUP_RETRY_QUIT_GAD
), GetLocString(MSGID_STARTUP_OLD_MCC
),
884 (IPTR
) name
, minver
, minrev
, ver
, rev
))
894 // No MCC at all - no need to attempt flush
896 if (!MUI_Request(NULL
, NULL
, 0L, GetLocString(MSGID_STARTUP_FAILURE
),
897 GetLocString(MSGID_STARTUP_RETRY_QUIT_GAD
), GetLocString(MSGID_STARTUP_MCC_NOT_FOUND
),
898 (IPTR
) name
, minver
, minrev
))
908 //----------------------------------------------------------------------------
910 #if !defined(__SASC) && !defined(__amigaos4__)
911 // Replacement for SAS/C library functions
913 #if !defined(__MORPHOS__)
914 // Replacement for SAS/C library functions
916 size_t stccpy(char *dest
, const char *src
, size_t MaxLen
)
920 while (*src
&& MaxLen
> 1)
931 #endif /*__MORPHOS__*/
933 #endif /* !defined(__SASC) && !defined(__amigaos4__) */
934 //-----------------------------------------------------------------------------