10 #include <exec/types.h>
11 #include <exec/memory.h>
12 #include <exec/ports.h>
14 #include <exec/execbase.h>
15 #include <libraries/dos.h>
16 #include <libraries/dosextens.h>
17 #include <libraries/gadtools.h>
18 #include <libraries/asl.h>
19 #include <libraries/mui.h>
20 #include <devices/clipboard.h>
21 #include <workbench/workbench.h>
22 #include <workbench/icon.h>
23 #include <intuition/intuition.h>
24 #include <intuition/classusr.h>
25 #include <prefs/prefhdr.h>
27 #include <clib/alib_protos.h>
31 #include <proto/exec.h>
32 #include <proto/dos.h>
33 #include <proto/icon.h>
34 #include <proto/intuition.h>
35 #include <proto/gadtools.h>
36 #include <proto/utility.h>
37 #include <proto/asl.h>
38 #include <proto/muimaster.h>
39 #include <proto/locale.h>
40 #include <proto/scalosprefsplugin.h>
42 #include <scalos/palette.h>
43 #include <scalos/scalosprefsplugin.h>
46 #include <Year.h> // +jmc+
47 #include <scalosdebug.h>
49 struct ScalosPalette_LocaleInfo
53 struct LocaleIFace
*li_ILocale
;
56 #define ScalosPalette_NUMBERS
57 #define ScalosPalette_ARRAY
58 #define ScalosPalette_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(Object
*APP_Main
, CONST_STRPTR str
);
102 static BOOL
OpenLibraries(void);
103 static void CloseLibraries(void);
104 static STRPTR
GetLocString(ULONG MsgId
);
105 static SAVEDS(APTR
) INTERRUPT
OpenAboutMUIFunc(struct Hook
*hook
, Object
*o
, Msg msg
);
106 static struct MUI_CustomClass
*OpenPrefsModule(CONST_STRPTR FileName
);
107 static struct TagItem
*CreatePluginSubWindowArray(void);
108 static void DisposePrefsPlugin(void);
109 static BOOL
CheckMCCforPlugin(STRPTR
*UsedClasses
, size_t MaxUsedClasses
);
110 static BOOL
CheckMCCVersion(CONST_STRPTR name
, ULONG minver
, ULONG minrev
);
111 #if !defined(__SASC) &&!defined(__MORPHOS__)
112 size_t stccpy(char *dest
, const char *src
, size_t MaxLen
);
113 #endif /* !defined(__SASC) &&!defined(__MORPHOS__) */
115 //----------------------------------------------------------------------------
119 struct Library
*MUIMasterBase
;
120 T_LOCALEBASE LocaleBase
;
121 struct Library
*IconBase
;
122 struct IntuitionBase
*IntuitionBase
;
123 struct Library
*ScalosPrefsPluginBase
;
126 extern struct Library
*SysBase
;
127 struct MUIMasterIFace
*IMUIMaster
;
128 struct LocaleIFace
*ILocale
;
129 struct IconIFace
*IIcon
;
130 struct IntuitionIFace
*IIntuition
;
131 struct ScalosPrefsPluginIFace
*IScalosPrefsPlugin
;
134 static struct MUI_CustomClass
*PalettePluginClass
;
136 static struct Hook OpenAboutMUIHook
= { { NULL
, NULL
}, HOOKFUNC_DEF(OpenAboutMUIFunc
), NULL
};
138 static struct TagItem
*SubWindowTagList
;
140 static struct Catalog
*PaletteCatalog
;
142 static Object
**PluginSubWindows
;
143 static Object
*APP_Main
;
144 static Object
*WIN_Main
;
145 static Object
*WIN_AboutMUI
;
146 static Object
*Group_Plugin
;
147 static Object
*SaveButton
, *UseButton
, *CancelButton
;
148 static Object
*MenuOpen
, *MenuSaveAs
, *MenuAbout
, *MenuAboutMUI
, *MenuQuit
;
149 static Object
*MenuResetToDefaults
, *MenuLastSaved
, *MenuRestore
;
150 static Object
*MenuCreateIcons
;
152 //----------------------------------------------------------------------------
154 int main(int argc
, char *argv
[])
156 LONG Action
= Application_Return_EDIT
;
158 struct RDArgs
*rdArgs
= NULL
;
159 CONST_STRPTR GivenFileName
= NULL
;
160 BPTR oldDir
= (BPTR
)NULL
;
161 ULONG fCreateIcons
= TRUE
;
162 struct DiskObject
*PaletteDiskObject
= NULL
;
164 STRPTR UsedClasses
[32];
165 struct WBStartup
*WBenchMsg
=
166 (argc
== 0) ? (struct WBStartup
*)argv
: NULL
;
170 if (WBenchMsg
&& WBenchMsg
->sm_ArgList
)
172 static char PrgNamePath
[512];
174 struct DiskObject
*icon
;
176 if (WBenchMsg
->sm_NumArgs
> 1)
178 arg
= &WBenchMsg
->sm_ArgList
[1];
179 GivenFileName
= arg
->wa_Name
;
183 arg
= &WBenchMsg
->sm_ArgList
[0];
186 ProgramName
= PrgNamePath
;
188 NameFromLock(WBenchMsg
->sm_ArgList
[0].wa_Lock
, PrgNamePath
, sizeof(PrgNamePath
));
189 AddPart(PrgNamePath
, WBenchMsg
->sm_ArgList
[0].wa_Name
, sizeof(PrgNamePath
));
191 oldDir
= CurrentDir(arg
->wa_Lock
);
193 icon
= GetDiskObject(arg
->wa_Name
);
198 tt
= FindToolType(icon
->do_ToolTypes
, "CREATEICONS");
201 if (MatchToolValue(tt
, "NO"))
202 fCreateIcons
= FALSE
;
205 tt
= FindToolType(icon
->do_ToolTypes
, "ACTION");
208 if (MatchToolValue(tt
, "EDIT"))
209 Action
= Application_Return_EDIT
;
210 if (MatchToolValue(tt
, "USE"))
211 Action
= Application_Return_USE
;
212 if (MatchToolValue(tt
, "SAVE"))
213 Action
= Application_Return_SAVE
;
216 FreeDiskObject(icon
);
223 ProgramName
= argv
[0];
225 memset(ArgArray
, 0, sizeof(ArgArray
));
227 rdArgs
= ReadArgs("FROM,EDIT/S,USE/S,SAVE/S", ArgArray
, NULL
);
230 GivenFileName
= (CONST_STRPTR
) ArgArray
[0];
232 Action
= Application_Return_EDIT
;
234 Action
= Application_Return_USE
;
236 Action
= Application_Return_SAVE
;
239 if (NULL
== PalettePluginClass
)
240 fail(APP_Main
, "Failed to open Palette Plugin.");
242 PaletteDiskObject
= GetDiskObject(ProgramName
);
244 Group_Plugin
= NewObject(PalettePluginClass
->mcc_Class
, 0,
245 MUIA_ScalosPrefs_CreateIcons
, fCreateIcons
,
246 MUIA_ScalosPrefs_ProgramName
, (ULONG
) 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 SubWindowTagList
= CreatePluginSubWindowArray();
256 APP_Main
= ApplicationObject
,
257 MUIA_Application_Title
, GetLocString(MSGID_TITLENAME
),
258 MUIA_Application_Version
, "$VER: Scalos Palette 40.11 (" __DATE__
")" COMPILER_STRING
,
259 MUIA_Application_Copyright
, "The Scalos Team, 2000" CURRENTYEAR
,
260 MUIA_Application_Author
, "The Scalos Team",
261 MUIA_Application_Description
, "Scalos Palette preferences editor",
262 MUIA_Application_Base
, "SCALOS_PALETTE",
263 PaletteDiskObject
? MUIA_Application_DiskObject
: TAG_IGNORE
, PaletteDiskObject
,
264 #if defined(MUIA_Application_UsedClasses)
265 MUIA_Application_UsedClasses
, UsedClasses
,
266 #endif /* MUIA_Application_UsedClasses */
268 SubWindow
, WIN_Main
= WindowObject
,
269 MUIA_Window_Title
, GetLocString(MSGID_TITLENAME
),
270 MUIA_Window_ID
, MAKE_ID('M','A','I','N'),
271 WindowContents
, VGroup
,
275 Child
, SaveButton
= KeyButtonHelp(GetLocString(MSGID_SAVENAME
), 's', GetLocString(MSGID_SHORTHELP_SAVEBUTTON
)),
276 Child
, UseButton
= KeyButtonHelp(GetLocString(MSGID_USENAME
), 'u', GetLocString(MSGID_SHORTHELP_USEBUTTON
)),
277 Child
, CancelButton
= KeyButtonHelp(GetLocString(MSGID_CANCELNAME
), 'c', GetLocString(MSGID_SHORTHELP_CANCELBUTTON
)),
282 MUIA_Application_Menustrip
, MenustripObject
,
283 Child
, MenuObjectT(GetLocString(MSGID_MENU_PROJECT
)),
284 Child
, MenuOpen
= MenuitemObject
,
285 MUIA_Menuitem_Title
, GetLocString(MSGID_MENU_PROJECT_OPEN
),
286 MUIA_Menuitem_Shortcut
, GetLocString(MSGID_MENU_PROJECT_OPEN_SHORT
),
288 Child
, MenuSaveAs
= MenuitemObject
,
289 MUIA_Menuitem_Title
, GetLocString(MSGID_MENU_PROJECT_SAVEAS
),
290 MUIA_Menuitem_Shortcut
, GetLocString(MSGID_MENU_PROJECT_SAVEAS_SHORT
),
292 Child
, MenuitemObject
,
293 MUIA_Menuitem_Title
, -1,
295 Child
, MenuAbout
= MenuitemObject
,
296 MUIA_Menuitem_Title
, GetLocString(MSGID_MENU_PROJECT_ABOUT
),
298 Child
, MenuAboutMUI
= MenuitemObject
,
299 MUIA_Menuitem_Title
, GetLocString(MSGID_MENU_PROJECT_ABOUTMUI
),
301 Child
, MenuitemObject
,
302 MUIA_Menuitem_Title
, -1,
304 Child
, MenuQuit
= MenuitemObject
,
305 MUIA_Menuitem_Title
, GetLocString(MSGID_MENU_PROJECT_QUIT
),
306 MUIA_Menuitem_Shortcut
, GetLocString(MSGID_MENU_PROJECT_QUIT_SHORT
),
310 Child
, MenuObjectT(GetLocString(MSGID_MENU_EDIT
)),
311 Child
, MenuResetToDefaults
= MenuitemObject
,
312 MUIA_Menuitem_Title
, GetLocString(MSGID_MENU_EDIT_RESETTODEFAULTS
),
313 MUIA_Menuitem_Shortcut
, GetLocString(MSGID_MENU_EDIT_RESETTODEFAULTS_SHORT
),
315 Child
, MenuLastSaved
= MenuitemObject
,
316 MUIA_Menuitem_Title
, GetLocString(MSGID_MENU_EDIT_LASTSAVED
),
317 MUIA_Menuitem_Shortcut
, GetLocString(MSGID_MENU_EDIT_LASTSAVED_SHORT
),
319 Child
, MenuRestore
= MenuitemObject
,
320 MUIA_Menuitem_Title
, GetLocString(MSGID_MENU_EDIT_RESTORE
),
321 MUIA_Menuitem_Shortcut
, GetLocString(MSGID_MENU_EDIT_RESTORE_SHORT
),
324 Child
, MenuObjectT(GetLocString(MSGID_MENU_SETTINGS
)),
325 Child
, MenuCreateIcons
= MenuitemObject
,
326 MUIA_Menuitem_Title
, GetLocString(MSGID_MENU_SETTINGS_CREATEICONS
),
327 MUIA_Menuitem_Shortcut
, GetLocString(MSGID_MENU_SETTINGS_CREATEICONS_SHORT
),
328 MUIA_Menuitem_Checkit
, TRUE
,
329 MUIA_Menuitem_Checked
, fCreateIcons
,
334 SubWindowTagList
? TAG_MORE
: TAG_IGNORE
, SubWindowTagList
,
335 End
; //ApplicationObject
337 if (NULL
== APP_Main
)
339 MUI_DisposeObject(Group_Plugin
);
341 fail(APP_Main
, "Failed to create Application.");
344 set(Group_Plugin
, MUIA_ScalosPrefs_MainWindow
, (ULONG
) WIN_Main
);
345 set(Group_Plugin
, MUIA_ScalosPrefs_Application
, (ULONG
) APP_Main
);
347 DoMethod(WIN_Main
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
,
348 WIN_Main
, 3, MUIM_Set
, MUIA_Window_Open
, FALSE
);
349 DoMethod(WIN_Main
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
,
350 APP_Main
, 2, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
351 DoMethod(CancelButton
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
352 APP_Main
, 2, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
354 DoMethod(MenuQuit
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
355 APP_Main
, 2, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
357 DoMethod(SaveButton
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
358 APP_Main
, 2, MUIM_Application_ReturnID
, Application_Return_SAVE
);
360 DoMethod(UseButton
, MUIM_Notify
,MUIA_Pressed
,FALSE
,
361 APP_Main
, 2, MUIM_Application_ReturnID
, Application_Return_USE
);
363 DoMethod(MenuQuit
, MUIM_Notify
,MUIA_Menuitem_Trigger
,MUIV_EveryTime
,
364 APP_Main
, 2, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
366 DoMethod(MenuOpen
, MUIM_Notify
,MUIA_Menuitem_Trigger
,MUIV_EveryTime
,
367 Group_Plugin
, 1, MUIM_ScalosPrefs_OpenConfig
);
369 DoMethod(MenuSaveAs
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
370 Group_Plugin
, 1, MUIM_ScalosPrefs_SaveConfigAs
);
372 DoMethod(MenuResetToDefaults
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
373 Group_Plugin
, 1, MUIM_ScalosPrefs_ResetToDefaults
);
375 DoMethod(MenuLastSaved
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
376 Group_Plugin
, 1, MUIM_ScalosPrefs_LastSavedConfig
);
378 DoMethod(MenuRestore
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
379 Group_Plugin
, 1, MUIM_ScalosPrefs_RestoreConfig
);
381 DoMethod(MenuAbout
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
382 Group_Plugin
, 1, MUIM_ScalosPrefs_About
);
384 DoMethod(MenuAboutMUI
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
385 APP_Main
, 2, MUIM_CallHook
, &OpenAboutMUIHook
);
387 DoMethod(MenuCreateIcons
, MUIM_Notify
, MUIA_Menuitem_Checked
, MUIV_EveryTime
,
388 Group_Plugin
, 3, MUIM_Set
, MUIA_ScalosPrefs_CreateIcons
, MUIV_TriggerValue
);
392 DoMethod(Group_Plugin
, MUIM_ScalosPrefs_LoadNamedConfig
, GivenFileName
);
396 DoMethod(Group_Plugin
, MUIM_ScalosPrefs_LoadConfig
);
399 if (Application_Return_EDIT
== Action
)
401 set(WIN_Main
, MUIA_Window_Open
, TRUE
);
403 get(WIN_Main
, MUIA_Window_Open
, &win_opened
);
412 Action
= DoMethod(APP_Main
, MUIM_Application_NewInput
, &sigs
);
416 case MUIV_Application_ReturnID_Quit
:
417 case Application_Return_SAVE
:
418 case Application_Return_USE
:
425 sigs
= Wait(sigs
| SIGBREAKF_CTRL_C
);
427 if (sigs
& SIGBREAKF_CTRL_C
)
437 printf("failed to open main window !\n");
443 case Application_Return_SAVE
:
444 DoMethod(Group_Plugin
, MUIM_ScalosPrefs_SaveConfig
);
446 case Application_Return_USE
:
447 DoMethod(Group_Plugin
, MUIM_ScalosPrefs_UseConfig
);
451 set(WIN_Main
, MUIA_Window_Open
, FALSE
);
453 if (PaletteDiskObject
)
454 FreeDiskObject(PaletteDiskObject
);
460 fail(APP_Main
, NULL
);
465 //----------------------------------------------------------------------------
467 static VOID
fail(Object
* APP_Main
, CONST_STRPTR str
)
470 MUI_DisposeObject(APP_Main
);
472 DisposePrefsPlugin();
476 CloseCatalog(PaletteCatalog
);
477 PaletteCatalog
= NULL
;
491 static void init(void)
495 if (!OpenLibraries())
496 fail(NULL
, "Failed to open "MUIMASTER_NAME
".");
499 PaletteCatalog
= OpenCatalogA(NULL
, "Scalos/ScalosPalette.catalog", NULL
);
501 PalettePluginClass
= OpenPrefsModule("Palette.prefsplugin");
504 //----------------------------------------------------------------------------
506 static BOOL
OpenLibraries(void)
508 IntuitionBase
= (struct IntuitionBase
*) OpenLibrary("intuition.library", 39);
509 if (NULL
== IntuitionBase
)
512 IIntuition
= (struct IntuitionIFace
*)GetInterface((struct Library
*)IntuitionBase
, "main", 1, NULL
);
513 if (NULL
== IIntuition
)
517 MUIMasterBase
= OpenLibrary("zune.library", 0);
518 if (NULL
== MUIMasterBase
)
519 MUIMasterBase
= OpenLibrary(MUIMASTER_NAME
, MUIMASTER_VMIN
-1);
520 if (NULL
== MUIMasterBase
)
523 IMUIMaster
= (struct MUIMasterIFace
*)GetInterface((struct Library
*)MUIMasterBase
, "main", 1, NULL
);
524 if (NULL
== IMUIMaster
)
528 IconBase
= OpenLibrary("icon.library", 0);
529 if (NULL
== IconBase
)
532 IIcon
= (struct IconIFace
*)GetInterface((struct Library
*)IconBase
, "main", 1, NULL
);
537 LocaleBase
= (T_LOCALEBASE
) OpenLibrary("locale.library", 39);
540 ILocale
= (struct LocaleIFace
*)GetInterface((struct Library
*)LocaleBase
, "main", 1, NULL
);
547 static void CloseLibraries(void)
552 DropInterface((struct Interface
*)ILocale
);
558 CloseLibrary((struct Library
*) LocaleBase
);
564 DropInterface((struct Interface
*)IIcon
);
570 CloseLibrary(IconBase
);
576 DropInterface((struct Interface
*)IMUIMaster
);
582 CloseLibrary(MUIMasterBase
);
583 MUIMasterBase
= NULL
;
588 DropInterface((struct Interface
*)IIntuition
);
594 CloseLibrary((struct Library
*) IntuitionBase
);
595 IntuitionBase
= NULL
;
599 //----------------------------------------------------------------------------
601 static STRPTR
GetLocString(ULONG MsgId
)
603 struct ScalosPalette_LocaleInfo li
;
605 li
.li_Catalog
= PaletteCatalog
;
607 li
.li_LocaleBase
= LocaleBase
;
609 li
.li_ILocale
= ILocale
;
612 return (STRPTR
) GetScalosPaletteString(&li
, MsgId
);
615 //----------------------------------------------------------------------------
617 static SAVEDS(APTR
) INTERRUPT
OpenAboutMUIFunc(struct Hook
*hook
, Object
*o
, Msg msg
)
619 if (NULL
== WIN_AboutMUI
)
621 WIN_AboutMUI
= MUI_NewObject(MUIC_Aboutmui
,
622 MUIA_Window_RefWindow
, WIN_Main
,
623 MUIA_Aboutmui_Application
, APP_Main
,
628 set(WIN_AboutMUI
, MUIA_Window_Open
, TRUE
);
633 //----------------------------------------------------------------------------
635 static struct MUI_CustomClass
*OpenPrefsModule(CONST_STRPTR FileName
)
637 struct MUI_CustomClass
*pclass
= NULL
;
639 d1(kprintf(__FUNC__
"/%ld: FileName=<%s>\n", __LINE__
, FileName
));
642 ScalosPrefsPluginBase
= OpenLibrary(FileName
, 0);
643 d1(kprintf(__FUNC__
"/%ld: ScalosPrefsPluginBase=%08lx\n", __LINE__
, ScalosPrefsPluginBase
));
644 if (NULL
== ScalosPrefsPluginBase
)
647 IScalosPrefsPlugin
= (struct ScalosPrefsPluginIFace
*)GetInterface(
648 ScalosPrefsPluginBase
, "main", 1, NULL
652 pclass
= (struct MUI_CustomClass
*) SCAGetPrefsInfo(SCAPREFSINFO_GetClass
);
653 d1(kprintf(__FUNC__
"/%ld: PluginClass=%08lx\n", __LINE__
, ppl
->ppl_PluginClass
));
659 DisposePrefsPlugin();
665 static struct TagItem
*CreatePluginSubWindowArray(void)
667 struct TagItem
*SubWindowTagList
;
669 ULONG SubWindowCount
= 0;
672 PluginSubWindows
= (Object
**) DoMethod(Group_Plugin
, MUIM_ScalosPrefs_CreateSubWindows
);
674 for (n
=0; PluginSubWindows
&& PluginSubWindows
[n
]; n
++)
677 SubWindowTagList
= ti
= calloc(1 + SubWindowCount
, sizeof(struct TagItem
));
678 if (NULL
== SubWindowTagList
)
681 for (n
=0; PluginSubWindows
&& PluginSubWindows
[n
]; n
++)
683 ti
->ti_Tag
= MUIA_Application_Window
;
684 ti
->ti_Data
= (ULONG
) PluginSubWindows
[n
];
688 ti
->ti_Tag
= TAG_END
;
690 return SubWindowTagList
;
694 static void DisposePrefsPlugin(void)
697 if (IScalosPrefsPlugin
)
699 DropInterface((struct Interface
*)IScalosPrefsPlugin
);
700 IScalosPrefsPlugin
= NULL
;
703 if (ScalosPrefsPluginBase
)
705 d1(kprintf(__FUNC__
"/%ld: Plugin=<%s> OpenCount=%ld\n", \
706 __LINE__
, ScalosPrefsPluginBase
->lib_Node
.ln_Name
, ScalosPrefsPluginBase
->lib_OpenCnt
));
708 if (NULL
== Group_Plugin
)
709 CloseLibrary(ScalosPrefsPluginBase
);
710 ScalosPrefsPluginBase
= NULL
;
714 static BOOL
CheckMCCforPlugin(STRPTR
*UsedClasses
, size_t MaxUsedClasses
)
716 const struct MUIP_ScalosPrefs_MCCList
*RequiredMccList
= NULL
;
718 RequiredMccList
= (const struct MUIP_ScalosPrefs_MCCList
*) DoMethod(Group_Plugin
, MUIM_ScalosPrefs_GetListOfMCCs
);
720 while (RequiredMccList
&& RequiredMccList
->MccName
)
722 if (!CheckMCCVersion(RequiredMccList
->MccName
,
723 RequiredMccList
->MccMinVersion
,
724 RequiredMccList
->MccMinRevision
))
727 if (MaxUsedClasses
> 1)
729 *UsedClasses
++ = (STRPTR
) RequiredMccList
->MccName
;
741 //----------------------------------------------------------------------------
743 // Checks if a certain version of a MCC is available
744 static BOOL
CheckMCCVersion(CONST_STRPTR name
, ULONG minver
, ULONG minrev
)
748 d1(kprintf(__FILE__
"/" __FUNC__
"/%ld: %s ", name
, __LINE__
);)
754 struct Library
*base
;
757 // First we attempt to acquire the version and revision through MUI
758 Object
*obj
= MUI_NewObject((STRPTR
) name
, TAG_DONE
);
761 get(obj
, MUIA_Version
, &ver
);
762 get(obj
, MUIA_Revision
, &rev
);
764 MUI_DisposeObject(obj
);
766 if(ver
> minver
|| (ver
== minver
&& rev
>= minrev
))
768 d1(kprintf(__FILE__
"/" __FUNC__
"/%ld: v%ld.%ld found through MUIA_Version/Revision\n", __LINE__
, ver
, rev
);)
773 // If we did't get the version we wanted, let's try to open the
774 // libraries ourselves and see what happens...
775 stccpy(libname
, "PROGDIR:mui", sizeof(libname
));
776 AddPart(libname
, name
, sizeof(libname
));
778 if ((base
= OpenLibrary(&libname
[8], 0)) || (base
= OpenLibrary(&libname
[0], 0)))
780 UWORD OpenCnt
= base
->lib_OpenCnt
;
782 ver
= base
->lib_Version
;
783 rev
= base
->lib_Revision
;
787 // we add some additional check here so that eventual broken .mcc also have
788 // a chance to pass this test (i.e. Toolbar.mcc is broken)
789 if (ver
> minver
|| (ver
== minver
&& rev
>= minrev
))
791 d1(kprintf(__FILE__
"/" __FUNC__
"/%ld: v%ld.%ld found through OpenLibrary()\n", __LINE__
, ver
, rev
);)
797 if (MUI_Request(NULL
, NULL
, 0L, GetLocString(MSGID_STARTUP_FAILURE
),
798 GetLocString(MSGID_STARTUP_RETRY_QUIT_GAD
), GetLocString(MSGID_STARTUP_MCC_IN_USE
),
799 (ULONG
) name
, minver
, minrev
, ver
, rev
))
807 // Attempt to flush the library if open count is 0 or because the
808 // user wants to retry (meaning there's a chance that it's 0 now)
812 struct Library
*result
;
815 if ((result
= (struct Library
*) FindName(&((struct ExecBase
*)SysBase
)->LibList
, name
)))
822 d1(kprintf(__FILE__
"/" __FUNC__
"/%ld: couldn`t find minimum required version.\n", __LINE__
);)
824 // We're out of luck - open count is 0, we've tried to flush
825 // and still haven't got the version we want
826 if (MUI_Request(NULL
, NULL
, 0L, GetLocString(MSGID_STARTUP_FAILURE
),
827 GetLocString(MSGID_STARTUP_RETRY_QUIT_GAD
), GetLocString(MSGID_STARTUP_OLD_MCC
),
828 (ULONG
) name
, minver
, minrev
, ver
, rev
))
838 // No MCC at all - no need to attempt flush
840 if (!MUI_Request(NULL
, NULL
, 0L, GetLocString(MSGID_STARTUP_FAILURE
),
841 GetLocString(MSGID_STARTUP_RETRY_QUIT_GAD
), GetLocString(MSGID_STARTUP_MCC_NOT_FOUND
),
842 (ULONG
) name
, minver
, minrev
))
852 //----------------------------------------------------------------------------
854 #if !defined(__SASC) && !defined(__amigaos4__)
855 // Replacement for SAS/C library functions
857 #if !defined(__MORPHOS__)
858 // Replacement for SAS/C library functions
860 size_t stccpy(char *dest
, const char *src
, size_t MaxLen
)
864 while (*src
&& MaxLen
> 1)
875 #endif /*__MORPHOS__*/
877 #endif /* !defined(__SASC) && !defined(__amigaos4__) */
878 //-----------------------------------------------------------------------------