Initial import of Scalos. To decrease size I have
[AROS-Contrib.git] / scalos / main / DeviceWindowClass.c
blob0326566bf0003f63ae966c0e734ea0cc077663e8
1 // DeviceWindowClass.c
2 // $Date$
3 // $Revision$
6 #include <exec/types.h>
7 #include <graphics/gels.h>
8 #include <graphics/rastport.h>
9 #include <intuition/classes.h>
10 #include <intuition/classusr.h>
11 #include <utility/hooks.h>
12 #include <intuition/gadgetclass.h>
13 #include <intuition/newmouse.h>
14 #include <workbench/workbench.h>
15 #include <workbench/startup.h>
16 #include <cybergraphx/cybergraphics.h>
17 #include <dos/dostags.h>
18 #include <dos/datetime.h>
20 #define __USE_SYSBASE
22 #include <proto/dos.h>
23 #include <proto/exec.h>
24 #include <proto/layers.h>
25 #include <proto/intuition.h>
26 #include <proto/graphics.h>
27 #include <proto/utility.h>
28 #include <proto/locale.h>
29 #include <proto/iconobject.h>
30 #include <proto/cybergraphics.h>
31 #include "debug.h"
32 #include <proto/scalos.h>
34 #include <clib/alib_protos.h>
36 #include <defs.h>
37 #include <datatypes/iconobject.h>
38 #include <scalos/scalos.h>
40 #include <stdlib.h>
41 #include <stdio.h>
42 #include <string.h>
44 #include <DefIcons.h>
46 #include "scalos_structures.h"
47 #include "FsAbstraction.h"
48 #include "functions.h"
49 #include "locale.h"
50 #include "Variables.h"
52 //----------------------------------------------------------------------------
54 // local data definitions
56 struct DeviceWindowClassInstance
58 ULONG dwci_Dummy;
61 //----------------------------------------------------------------------------
63 // local functions
65 static SAVEDS(ULONG) INTERRUPT DeviceWindowClass_Dispatcher(Class *cl, Object *o, Msg msg);
66 static ULONG DeviceWindowClass_ReadIconList(Class *cl, Object *o, Msg msg);
67 static ULONG DeviceWindowClass_ReadIcon(Class *cl, Object *o, Msg msg);
68 static ULONG DeviceWindowClass_RemIcon(Class *cl, Object *o, Msg msg);
69 static ULONG DeviceWindowClass_RemIcon2(Class *cl, Object *o, Msg msg);
70 static ULONG DeviceWindowClass_Ping(Class *cl, Object *o, Msg msg);
71 static ULONG DeviceWindowClass_Message(Class *cl, Object *o, Msg msg);
72 static ULONG DeviceWindowClass_New(Class *cl, Object *o, Msg msg);
73 static ULONG DeviceWindowClass_Dispose(Class *cl, Object *o, Msg msg);
74 static ULONG DeviceWindowClass_CheckUpdate(Class *cl, Object *o, Msg msg);
75 static ULONG DeviceWindowClass_Update(Class *cl, Object *o, Msg msg);
76 static struct ScaIconNode *ReadDevIcon_Device(struct internalScaWindowTask *iwt, struct ScaDeviceIcon *di);
77 static struct ScaIconNode *ReadDevIcon_Volume(struct internalScaWindowTask *iwt, struct ScaDeviceIcon *di);
78 static struct ScaIconNode *DevIconOk2(struct internalScaWindowTask *iwt, struct ScaDeviceIcon *di, Object *iconObj);
79 static LONG ReadDevBackdrop(struct internalScaWindowTask *iwt, struct ScaIconNode *DevIn);
80 static struct ScaIconNode *CreateBackdropIcon(struct internalScaWindowTask *iwt,
81 struct BackDropList *bdl, struct ScaIconNode *DevIn,
82 CONST_STRPTR BackdropIconName, STRPTR fName);
83 static Object *ReadDefaultVolumeIcon(struct internalScaWindowTask *iwt, struct ScaDeviceIcon *di, STRPTR DevName);
84 static Object *ReadDefaultDeviceIcon(struct internalScaWindowTask *iwt, struct ScaDeviceIcon *di, STRPTR DevName);
85 static Object *ReadDiskIcon(struct internalScaWindowTask *iwt, struct ScaDeviceIcon *di, STRPTR DevName);
86 static Object *ReadDefaultIcon(struct internalScaWindowTask *iwt, struct ScaDeviceIcon *di, STRPTR DevName);
87 static void FreeBackdropIcon(struct ScaBackdropIcon *bdi);
88 static BOOL CreateSbi(struct ScaIconNode *DevIn, struct ScaIconNode *in);
89 static struct ScaIconNode *IconAlreadyExists(struct internalScaWindowTask *iwt, struct ScaDeviceIcon *di);
90 static BOOL FindIconInDrawerWindows(BPTR dirLock, CONST_STRPTR IconName);
91 static Object *ReadDefaultIconByName(struct internalScaWindowTask *iwt, CONST_STRPTR iconName, STRPTR DevName);
92 static BOOL StartDeviceIconNotify(struct internalScaWindowTask *iwt, struct ScaDeviceIcon *di);
93 static void SetDeviceIconSupportsFlags(struct ScaIconNode *in);
94 static void SetBackdropIconSupportsFlags(struct internalScaWindowTask *iwt,
95 struct BackDropList *bdl, struct ScaIconNode *in);
97 //----------------------------------------------------------------------------
99 // public data items :
101 //----------------------------------------------------------------------------
104 struct ScalosClass *initDeviceWindowClass(const struct PluginClass *plug)
106 struct ScalosClass *DeviceWindowClass;
108 DeviceWindowClass = SCA_MakeScalosClass(plug->plug_classname,
109 plug->plug_superclassname,
110 sizeof(struct DeviceWindowClassInstance),
111 NULL);
113 if (DeviceWindowClass)
115 // initialize the cl_Dispatcher Hook
116 SETHOOKFUNC(DeviceWindowClass->sccl_class->cl_Dispatcher, DeviceWindowClass_Dispatcher);
119 return DeviceWindowClass;
123 static SAVEDS(ULONG) INTERRUPT DeviceWindowClass_Dispatcher(Class *cl, Object *o, Msg msg)
125 ULONG Result;
127 switch (msg->MethodID)
129 case OM_NEW:
130 Result = DeviceWindowClass_New(cl, o, msg);
131 break;
133 case OM_DISPOSE:
134 Result = DeviceWindowClass_Dispose(cl, o, msg);
135 break;
137 case SCCM_IconWin_ReadIconList:
138 Result = DeviceWindowClass_ReadIconList(cl, o, msg);
139 break;
141 case SCCM_DeviceWin_ReadIcon:
142 Result = DeviceWindowClass_ReadIcon(cl, o, msg);
143 break;
145 case SCCM_Ping:
146 Result = DeviceWindowClass_Ping(cl, o, msg);
147 break;
149 case SCCM_Message:
150 Result = DeviceWindowClass_Message(cl, o, msg);
151 break;
153 case SCCM_IconWin_NewViewMode:
154 Result = 0;
155 break;
157 case SCCM_IconWin_Update:
158 Result = DeviceWindowClass_Update(cl, o, msg);
159 break;
161 case SCCM_IconWin_ImmediateCheckUpdate:
162 Result = DeviceWindowClass_CheckUpdate(cl, o, msg);
163 break;
165 case SCCM_DeviceWin_RemIcon:
166 Result = DeviceWindowClass_RemIcon(cl, o, msg);
167 break;
169 case SCCM_IconWin_RemIcon:
170 // Only supports left-out icons
171 Result = DeviceWindowClass_RemIcon2(cl, o, msg);
172 break;
174 default:
175 Result = DoSuperMethodA(cl, o, msg);
176 break;
179 return Result;
183 static ULONG DeviceWindowClass_ReadIconList(Class *cl, Object *o, Msg msg)
185 struct internalScaWindowTask *iwt = (struct internalScaWindowTask *) ((struct ScaRootList *) o)->rl_WindowTask;
186 struct ScaDeviceIcon *sdi, *diNext;
187 struct ScaIconNode *NotShownIconList = NULL;
189 d1(kprintf("%s/%s/%ld: Start iwt=%08lx ws=%08lx <%s>\n", \
190 __FILE__, __FUNC__, __LINE__, iwt, iwt->iwt_WindowTask.mt_WindowStruct, iwt->iwt_WinTitle));
192 SplashAddUser();
194 d1(kprintf("%s/%s/%ld: \n", __FILE__, __FUNC__, __LINE__));
196 SplashDisplayProgress(GetLocString(MSGID_PROGRESS_READDEVICEICONS), 0);
198 d1(kprintf("%s/%s/%ld: \n", __FILE__, __FUNC__, __LINE__));
200 DoMethod(iwt->iwt_DevListObject, SCCM_DeviceList_Generate, &iwt->iwt_DevIconList);
202 d1(kprintf("%s/%s/%ld: \n", __FILE__, __FUNC__, __LINE__));
204 for (sdi = iwt->iwt_DevIconList; sdi; sdi = diNext)
206 diNext = (struct ScaDeviceIcon *) sdi->di_Node.mln_Succ;
208 d1(kprintf("%s/%s/%ld: di=%08lx <%s> Flags=%04lx\n", __FILE__, __FUNC__, __LINE__, \
209 sdi, sdi->di_Volume, sdi->di_Flags));
211 if (DIBF_DontDisplay & sdi->di_Flags)
213 // remove icon from iwt_DevIconList
214 d1(kprintf("%s/%s/%ld: Remove di=%08lx <%s> di_Flags=%08lx\n", __FILE__, __FUNC__, __LINE__, sdi, sdi->di_Device, sdi->di_Flags));
215 RemoveDeviceIcon(iwt, sdi, &NotShownIconList);
217 else
219 d1(kprintf("%s/%s/%ld: Add di=%08lx <%s> di_Flags=%08lx\n", __FILE__, __FUNC__, __LINE__, sdi, sdi->di_Device, sdi->di_Flags));
220 DoMethod(iwt->iwt_WindowTask.mt_MainObject, SCCM_DeviceWin_ReadIcon, sdi);
223 FreeIconList(iwt, &NotShownIconList);
225 d1(kprintf("%s/%s/%ld: \n", __FILE__, __FUNC__, __LINE__));
227 DoMethod(iwt->iwt_WindowTask.mt_MainObject, SCCM_IconWin_CleanUp);
229 d1(kprintf("%s/%s/%ld: \n", __FILE__, __FUNC__, __LINE__));
231 DoMethod(iwt->iwt_WindowTask.mt_MainObject, SCCM_IconWin_SetVirtSize, SETVIRTF_AdjustBottomSlider | SETVIRTF_AdjustRightSlider);
233 d1(kprintf("%s/%s/%ld: \n", __FILE__, __FUNC__, __LINE__));
235 SplashDisplayProgress(GetLocString(MSGID_PROGRESS_ENDREADDEVICEICONS), 0);
237 d1(kprintf("%s/%s/%ld: \n", __FILE__, __FUNC__, __LINE__));
239 SplashRemoveUser();
241 d1(kprintf("%s/%s/%ld: Finished iwt=%08lx <%s>\n", __FILE__, __FUNC__, __LINE__, iwt, iwt->iwt_WinTitle));
243 return 0;
247 static ULONG DeviceWindowClass_ReadIcon(Class *cl, Object *o, Msg msg)
249 struct internalScaWindowTask *iwt = (struct internalScaWindowTask *) ((struct ScaRootList *) o)->rl_WindowTask;
250 struct msg_DevWinReadIcon *dri = (struct msg_DevWinReadIcon *) msg;
251 struct ScaIconNode *in;
253 d1(kprintf("%s/%s/%ld: iwt=%08lx <%s>\n", __FILE__, __FUNC__, __LINE__, iwt, iwt->iwt_WinTitle));
254 d1(KPrintF("%s/%s/%ld: iwt=%08lx di=%08lx <%s>\n", __FILE__, __FUNC__, __LINE__, iwt, dri->dri_DeviceNode, dri->dri_DeviceNode->di_Device));
255 d1(KPrintF("%s/%s/%ld: deviceNode=%08lx <%s> diskType=%08lx\n", __FILE__, __FUNC__, __LINE__, \
256 dri->dri_DeviceNode, dri->dri_DeviceNode->di_Device, dri->dri_DeviceNode->di_Info->id_DiskType));
258 in = IconAlreadyExists(iwt, dri->dri_DeviceNode);
259 if (in)
261 ScalosUnLockIconList(iwt);
263 return 1;
266 d1(KPrintF("%s/%s/%ld: iwt=%08lx <%s> di_Volume=%08lx\n", __FILE__, __FUNC__, __LINE__, iwt, iwt->iwt_WinTitle, dri->dri_DeviceNode->di_Volume));
268 if (dri->dri_DeviceNode->di_Volume)
269 ReadDevIcon_Volume(iwt, dri->dri_DeviceNode);
270 else
271 ReadDevIcon_Device(iwt, dri->dri_DeviceNode);
273 d1(KPrintF("%s/%s/%ld: iwt=%08lx <%s>\n", __FILE__, __FUNC__, __LINE__, iwt, iwt->iwt_WinTitle));
275 return 1;
279 static ULONG DeviceWindowClass_RemIcon(Class *cl, Object *o, Msg msg)
281 struct internalScaWindowTask *iwt = (struct internalScaWindowTask *) ((struct ScaRootList *) o)->rl_WindowTask;
282 struct msg_DevWinRemIcon *dri = (struct msg_DevWinRemIcon *) msg;
283 struct ScaIconNode *dummyIconList = NULL;
285 d1(kprintf("%s/%s/%ld: iwt=%08lx lock=%08lx IconName=<%s>\n", \
286 __FILE__, __FUNC__, __LINE__, iwt, dri->dri_IconNode, GetIconName(dri->dri_IconNode)));
288 ScalosLockIconListExclusive(iwt);
290 SCA_MoveIconNode(&iwt->iwt_WindowTask.wt_IconList, &dummyIconList, dri->dri_IconNode);
292 RemoveIcons(iwt, &dummyIconList); // visually erase icons
294 debugLock_d1(dri->dri_IconNode->in_Lock);
296 FreeIconNode(iwt, &dummyIconList, dri->dri_IconNode);
298 ScalosUnLockIconList(iwt);
300 DoMethod(iwt->iwt_WindowTask.mt_MainObject, SCCM_IconWin_SetVirtSize,
301 SETVIRTF_AdjustRightSlider | SETVIRTF_AdjustBottomSlider);
303 return 1;
307 static ULONG DeviceWindowClass_RemIcon2(Class *cl, Object *o, Msg msg)
309 struct internalScaWindowTask *iwt = (struct internalScaWindowTask *) ((struct ScaRootList *) o)->rl_WindowTask;
310 struct msg_RemIcon *mri = (struct msg_RemIcon *) msg;
311 struct ScaIconNode *in, *inNext;
312 BOOL Found = FALSE;
314 d1(KPrintF("%s/%s/%ld: iwt=%08lx lock=%08lx IconName=<%s>\n", \
315 __FILE__, __FUNC__, __LINE__, iwt, mri->mri_Lock, mri->mri_Name));
317 ScalosLockIconListExclusive(iwt);
319 for (in = iwt->iwt_WindowTask.wt_IconList; in; in=inNext)
321 d1(kprintf("%s/%s/%ld: in_Name=%08lx\n", __FILE__, __FUNC__, __LINE__, in->in_Name));
323 inNext = (struct ScaIconNode *) in->in_Node.mln_Succ;
325 if (in->in_Lock && (LOCK_SAME == SameLock(in->in_Lock, mri->mri_Lock))
326 && in->in_Name && 0 == Stricmp((STRPTR) mri->mri_Name, in->in_Name))
328 struct ScaIconNode *dummyIconList = NULL;
330 d1(KPrintF("%s/%s/%ld: FOUND in=%08lx\n", __FILE__, __FUNC__, __LINE__, in));
332 Found = TRUE;
334 SCA_MoveIconNode(&iwt->iwt_WindowTask.wt_IconList, &dummyIconList, in);
336 RemoveIcons(iwt, &dummyIconList); // visually erase icons
338 debugLock_d1(in->in_Lock);
339 RewriteBackdrop(in);
341 FreeIconNode(iwt, &dummyIconList, in);
345 ScalosUnLockIconList(iwt);
347 if (Found)
349 DoMethod(iwt->iwt_WindowTask.mt_MainObject, SCCM_IconWin_SetVirtSize,
350 SETVIRTF_AdjustRightSlider | SETVIRTF_AdjustBottomSlider);
353 return 1;
357 static ULONG DeviceWindowClass_Ping(Class *cl, Object *o, Msg msg)
359 struct internalScaWindowTask *iwt = (struct internalScaWindowTask *) ((struct ScaRootList *) o)->rl_WindowTask;
361 d1(KPrintF("%s/%s/%ld: iwt=%08lx <%s>\n", __FILE__, __FUNC__, __LINE__, iwt, iwt->iwt_WinTitle));
363 if (++iwt->iwt_dRefreshCount >= CurrentPrefs.pref_DiskRefresh)
365 iwt->iwt_dRefreshCount = 0;
367 IDCMPDiskInserted(iwt, NULL);
370 return DoSuperMethodA(cl, o, msg);
374 static ULONG DeviceWindowClass_Message(Class *cl, Object *o, Msg msg)
376 struct internalScaWindowTask *iwt = (struct internalScaWindowTask *) ((struct ScaRootList *) o)->rl_WindowTask;
377 struct msg_Message *msm = (struct msg_Message *) msg;
379 d1(kprintf("%s/%s/%ld: iwt=%08lx <%s>\n", __FILE__, __FUNC__, __LINE__, iwt, iwt->iwt_WinTitle));
381 switch (msm->msm_iMsg->Class)
383 case IDCMP_DISKINSERTED:
384 case IDCMP_DISKREMOVED:
385 IDCMPDiskInserted(iwt, NULL);
386 break;
389 return DoSuperMethodA(cl, o, msg);
393 static ULONG DeviceWindowClass_New(Class *cl, Object *o, Msg msg)
395 d1(kprintf("%s/%s/%ld: START o=%08lx\n", __FILE__, __FUNC__, __LINE__, o));
397 o = (Object *) DoSuperMethodA(cl, o, msg);
399 if (o)
401 struct internalScaWindowTask *iwt = (struct internalScaWindowTask *) ((struct ScaRootList *) o)->rl_WindowTask;
402 struct ScaWindowStruct *ws = iwt->iwt_WindowTask.mt_WindowStruct;
403 struct opSet *ops = (struct opSet *) msg;
404 ULONG n;
406 d1(kprintf("%s/%s/%ld: iwt=%08lx <%s> o=%08lx\n", __FILE__, __FUNC__, __LINE__, iwt, iwt->iwt_WinTitle, o));
408 SplashDisplayProgress(GetLocString(MSGID_PROGRESS_INITDEVICEWINDOW), 0);
410 // desktop window is ALWAYS displayed as icons
411 ws->ws_Viewmodes = IDTV_ViewModes_Icon;
413 iwt->iwt_DevListObject = (Object *) SCA_NewScalosObject("DeviceList.sca", ops->ops_AttrList);
415 iwt->iwt_IDCMPFlags |= IDCMP_DISKINSERTED | IDCMP_DISKREMOVED;
416 iwt->iwt_NeedsTimerFlag = TRUE;
417 ws->ws_Flags |= WSV_FlagF_NeedsTimerMsg;
419 iwt->iwt_IconFont = IconWindowFont;
420 iwt->iwt_IconTTFont = IconWindowTTFont;
422 // initialize iwt_IconLayoutInfo
423 memset(&iwt->iwt_IconLayoutInfo.ili_LayoutArea, 0, sizeof(iwt->iwt_IconLayoutInfo.ili_LayoutArea));
424 memset(&iwt->iwt_IconLayoutInfo.ili_Restricted, 0, sizeof(iwt->iwt_IconLayoutInfo.ili_Restricted));
426 for (n = 0; n < Sizeof(iwt->iwt_IconLayoutInfo.ili_IconTypeLayoutModes); n++)
428 if (n < Sizeof(CurrentPrefs.pref_DeviceWindowLayoutModes))
429 iwt->iwt_IconLayoutInfo.ili_IconTypeLayoutModes[n] = CurrentPrefs.pref_DeviceWindowLayoutModes[n];
430 else
431 iwt->iwt_IconLayoutInfo.ili_IconTypeLayoutModes[n] = ICONLAYOUT_Columns; //default
434 d1(kprintf("%s/%s/%ld: DevListObject=%08lx\n", __FILE__, __FUNC__, __LINE__, iwt->iwt_DevListObject));
436 if (NULL == iwt->iwt_DevListObject)
438 DoMethod(o, OM_DISPOSE);
439 o = NULL;
443 d1(kprintf("%s/%s/%ld: END o=%08lx\n", __FILE__, __FUNC__, __LINE__, o));
445 return (ULONG) o;
449 static ULONG DeviceWindowClass_Dispose(Class *cl, Object *o, Msg msg)
451 struct internalScaWindowTask *iwt = (struct internalScaWindowTask *) ((struct ScaRootList *) o)->rl_WindowTask;
453 d1(kprintf("%s/%s/%ld: iwt=%08lx <%s>\n", __FILE__, __FUNC__, __LINE__, iwt, iwt->iwt_WinTitle));
455 SCA_DisposeScalosObject(iwt->iwt_DevListObject);
456 iwt->iwt_DevListObject = NULL;
458 return DoSuperMethodA(cl, o, msg);
462 static ULONG DeviceWindowClass_CheckUpdate(Class *cl, Object *o, Msg msg)
464 struct internalScaWindowTask *iwt = (struct internalScaWindowTask *) ((struct ScaRootList *) o)->rl_WindowTask;
466 d1(kprintf("%s/%s/%ld: iwt=%08lx <%s>\n", __FILE__, __FUNC__, __LINE__, iwt, iwt->iwt_WinTitle));
468 return DeviceWindowCheckUpdate(iwt);
472 static ULONG DeviceWindowClass_Update(Class *cl, Object *o, Msg msg)
474 struct internalScaWindowTask *iwt = (struct internalScaWindowTask *) ((struct ScaRootList *) o)->rl_WindowTask;
475 ULONG Result, ReadResult;
476 struct ScaIconNode *in, *inNext;
477 ULONG IconType;
479 d1(KPrintF("%s/%s/%ld: START iwt=%08lx <%s>\n", __FILE__, __FUNC__, __LINE__, iwt, iwt->iwt_WinTitle));
481 UpdateIconOverlays(iwt);
483 if (NULL == iwt->iwt_WindowTask.wt_Window)
484 return 0;
486 ScalosLockIconListExclusive(iwt);
488 d1(Forbid(); KPrintF("%s/%s/%ld: iwt=%08lx MsgList Head=%08lx TailPred=%08lx\n", \
489 __FILE__, __FUNC__, __LINE__, iwt, iwt->iwt_WindowTask.wt_IconPort->mp_MsgList.lh_Head, \
490 iwt->iwt_WindowTask.wt_IconPort->mp_MsgList.lh_TailPred); Permit());
492 for (in=iwt->iwt_WindowTask.wt_IconList; in; in = inNext)
494 inNext = (struct ScaIconNode *) in->in_Node.mln_Succ;
496 GetAttr(IDTA_Type, in->in_Icon, &IconType);
498 if (WBAPPICON != IconType)
499 FreeIconNode(iwt, &iwt->iwt_WindowTask.wt_IconList, in);
502 d1(Forbid(); KPrintF("%s/%s/%ld: iwt=%08lx MsgList Head=%08lx TailPred=%08lx\n", \
503 __FILE__, __FUNC__, __LINE__, iwt, iwt->iwt_WindowTask.wt_IconPort->mp_MsgList.lh_Head, \
504 iwt->iwt_WindowTask.wt_IconPort->mp_MsgList.lh_TailPred); Permit());
506 for (in=iwt->iwt_WindowTask.wt_LateIconList; in; in = inNext)
508 inNext = (struct ScaIconNode *) in->in_Node.mln_Succ;
510 GetAttr(IDTA_Type, in->in_Icon, &IconType);
512 if (WBAPPICON != IconType)
513 FreeIconNode(iwt, &iwt->iwt_WindowTask.wt_LateIconList, in);
516 d1(Forbid(); KPrintF("%s/%s/%ld: iwt=%08lx MsgList Head=%08lx TailPred=%08lx\n", \
517 __FILE__, __FUNC__, __LINE__, iwt, iwt->iwt_WindowTask.wt_IconPort->mp_MsgList.lh_Head, \
518 iwt->iwt_WindowTask.wt_IconPort->mp_MsgList.lh_TailPred); Permit());
520 ScalosUnLockIconList(iwt);
522 IconActive = FALSE;
524 SetAttrs(iwt->iwt_WindowTask.mt_MainObject,
525 SCCA_IconWin_Reading, TRUE,
526 TAG_END);
528 SetMenuOnOff(iwt);
530 if (iwt->iwt_WindowTask.wt_Window)
532 EraseRect(iwt->iwt_WindowTask.wt_Window->RPort,
533 0, 0,
534 iwt->iwt_WindowTask.wt_Window->Width - 1,
535 iwt->iwt_WindowTask.wt_Window->Height - 1);
538 RefreshIcons(iwt, NULL);
540 ReadResult = DoMethod(iwt->iwt_WindowTask.mt_MainObject, SCCM_IconWin_ReadIconList, 0L);
542 SetAttrs(iwt->iwt_WindowTask.mt_MainObject,
543 SCCA_IconWin_Reading, FALSE,
544 TAG_END);
546 SetMenuOnOff(iwt);
548 if (ScanDirIsError(ReadResult))
550 Result = 1;
551 iwt->iwt_CloseWindow = TRUE;
553 else
555 Result = 0;
556 DoMethod(iwt->iwt_WindowTask.mt_MainObject, SCCM_IconWin_SetVirtSize, SETVIRTF_AdjustBottomSlider | SETVIRTF_AdjustRightSlider);
559 d1(KPrintF("%s/%s/%ld: END iwt=%08lx <%s>\n", __FILE__, __FUNC__, __LINE__, iwt, iwt->iwt_WinTitle));
561 return Result;
565 static struct ScaIconNode *ReadDevIcon_Device(struct internalScaWindowTask *iwt, struct ScaDeviceIcon *di)
567 struct ScaIconNode *in = NULL;
568 STRPTR DevName;
569 Object *iconObj;
571 d1(kprintf("%s/%s/%ld: iwt=%08lx di=%08lx <%s>\n", __FILE__, __FUNC__, __LINE__, iwt, di, di->di_Device));
573 do {
574 DevName = AllocPathBuffer();
575 if (NULL == DevName)
576 break;
578 stccpy(DevName, di->di_Device, Max_PathLen - 4);
580 d1(kprintf("%s/%s/%ld: DevName=<%s>\n", __FILE__, __FUNC__, __LINE__, DevName));
582 if (MAKE_ID('B','A','D',0) == di->di_Info->id_DiskType)
583 SafeStrCat(DevName, GetLocString(MSGID_DISK_UNREADABLE), Max_PathLen);
584 else if (MAKE_ID('B','U','S','Y') == di->di_Info->id_DiskType)
585 SafeStrCat(DevName, GetLocString(MSGID_DISK_BUSY), Max_PathLen);
586 else if (MAKE_ID('N','D','O','S') == di->di_Info->id_DiskType) // +jmc+
587 SafeStrCat(DevName, GetLocString(MSGID_DISK_NDOS), Max_PathLen);
588 else
589 strncat(DevName, (STRPTR) &di->di_Info->id_DiskType, 4);
591 // GetDefIconObject()
592 iconObj = GetDefIconObjectTags(WBKICK,
593 IDTA_InnerBottom, CurrentPrefs.pref_ImageBorders.Bottom,
594 IDTA_InnerRight, CurrentPrefs.pref_ImageBorders.Right,
595 IDTA_InnerTop, CurrentPrefs.pref_ImageBorders.Top,
596 IDTA_InnerLeft, CurrentPrefs.pref_ImageBorders.Left,
597 IDTA_HalfShinePen, PalettePrefs.pal_PensList[PENIDX_HSHINEPEN],
598 IDTA_HalfShadowPen, PalettePrefs.pal_PensList[PENIDX_HSHADOWPEN],
599 IDTA_FrameTypeSel, CurrentPrefs.pref_FrameTypeSel,
600 IDTA_FrameType, CurrentPrefs.pref_FrameType,
601 IDTA_TextSkip, CurrentPrefs.pref_TextSkip,
602 IDTA_MultiLineText, (ULONG) CurrentPrefs.pref_IconTextMuliLine,
603 IDTA_TextPen, PalettePrefs.pal_PensList[PENIDX_ICONTEXTPEN],
604 IDTA_TextPenSel, PalettePrefs.pal_PensList[PENIDX_ICONTEXTPENSEL],
605 IDTA_TextPenShadow, PalettePrefs.pal_PensList[PENIDX_ICONTEXTSHADOWPEN],
606 IDTA_TextPenOutline, PalettePrefs.pal_PensList[PENIDX_ICONTEXTOUTLINEPEN],
607 IDTA_TextPenBgSel, PalettePrefs.pal_PensList[PENIDX_ICONTEXTPENBGSEL],
608 IDTA_SelectedTextRectangle, CurrentPrefs.pref_SelectedTextRectangle,
609 IDTA_SelTextRectBorderX, CurrentPrefs.pref_SelTextRectBorderX,
610 IDTA_SelTextRectBorderY, CurrentPrefs.pref_SelTextRectBorderY,
611 IDTA_SelTextRectRadius, CurrentPrefs.pref_SelTextRectRadius,
612 IDTA_TextMode, CurrentPrefs.pref_TextMode,
613 IDTA_TextDrawMode, FontPrefs.fprf_TextDrawMode,
614 IDTA_TextBackPen, FontPrefs.fprf_FontBackPen,
615 DTA_Name, (ULONG) di->di_Device,
616 IDTA_Text, (ULONG) DevName,
617 IDTA_Font, (ULONG) iwt->iwt_IconFont,
618 IDTA_Fonthandle, (ULONG) &iwt->iwt_IconTTFont,
619 IDTA_FontHook, (ULONG) (TTEngineBase ? &ScalosFontHook : NULL),
620 IDTA_SizeConstraints, (ULONG) &iwt->iwt_WindowTask.mt_WindowStruct->ws_IconSizeConstraints,
621 IDTA_ScalePercentage, iwt->iwt_WindowTask.mt_WindowStruct->ws_IconScaleFactor,
622 TAG_END);
623 if (NULL == iconObj)
624 break;
626 in = DevIconOk2(iwt, di, iconObj);
627 } while (0);
629 if (DevName)
630 FreePathBuffer(DevName);
632 return in;
636 static struct ScaIconNode *ReadDevIcon_Volume(struct internalScaWindowTask *iwt, struct ScaDeviceIcon *di)
638 BPTR dLock;
639 BPTR oldDir = NOT_A_LOCK;
640 STRPTR DevName = NULL;
641 struct ScaIconNode *in = NULL;
642 Object *iconObj = NULL;
644 d1(kprintf("%s/%s/%ld: iwt=%08lx di=%08lx <%s>\n", __FILE__, __FUNC__, __LINE__, iwt, di, di->di_Volume));
646 do {
647 dLock = Lock(di->di_Device, ACCESS_READ);
648 if ((BPTR)NULL == dLock)
649 break;
651 debugLock_d1(dLock);
653 oldDir = CurrentDir(dLock);
655 DevName = AllocPathBuffer();
656 if (NULL == DevName)
657 break;
659 stccpy(DevName, di->di_Volume, Max_PathLen - 1);
660 StripTrailingColon(DevName);
662 d1(KPrintF("%s/%s/%ld: DevName=<%s>\n", __FILE__, __FUNC__, __LINE__, DevName));
663 d1(KPrintF("%s/%s/%ld: pref_DefIconsFirst=%ld\n", __FILE__, __FUNC__, __LINE__, CurrentPrefs.pref_DefIconsFirst));
665 if (CurrentPrefs.pref_DefIconsFirst)
667 iconObj = ReadDefaultVolumeIcon(iwt, di, DevName);
668 d1(KPrintF("%s/%s/%ld: iconObj=%08lx\n", __FILE__, __FUNC__, __LINE__, iconObj));
670 if (NULL == iconObj)
671 iconObj = ReadDefaultDeviceIcon(iwt, di, DevName);
673 d1(KPrintF("%s/%s/%ld: iconObj=%08lx\n", __FILE__, __FUNC__, __LINE__, iconObj));
674 if (NULL == iconObj)
675 iconObj = ReadDiskIcon(iwt, di, DevName);
677 else
679 iconObj = ReadDiskIcon(iwt, di, DevName);
681 d1(KPrintF("%s/%s/%ld: iconObj=%08lx\n", __FILE__, __FUNC__, __LINE__, iconObj));
682 if (NULL == iconObj)
683 iconObj = ReadDefaultVolumeIcon(iwt, di, DevName);
685 d1(KPrintF("%s/%s/%ld: iconObj=%08lx\n", __FILE__, __FUNC__, __LINE__, iconObj));
686 if (NULL == iconObj)
687 iconObj = ReadDefaultDeviceIcon(iwt, di, DevName);
690 d1(KPrintF("%s/%s/%ld: iconObj=%08lx\n", __FILE__, __FUNC__, __LINE__, iconObj));
691 if (NULL == iconObj)
693 iconObj = ReturnDefIconObjTags(dLock, "",
694 IDTA_InnerBottom, CurrentPrefs.pref_ImageBorders.Bottom,
695 IDTA_InnerRight, CurrentPrefs.pref_ImageBorders.Right,
696 IDTA_InnerTop, CurrentPrefs.pref_ImageBorders.Top,
697 IDTA_InnerLeft, CurrentPrefs.pref_ImageBorders.Left,
698 IDTA_HalfShinePen, PalettePrefs.pal_PensList[PENIDX_HSHINEPEN],
699 IDTA_HalfShadowPen, PalettePrefs.pal_PensList[PENIDX_HSHADOWPEN],
700 IDTA_FrameTypeSel, CurrentPrefs.pref_FrameTypeSel,
701 IDTA_FrameType, CurrentPrefs.pref_FrameType,
702 IDTA_TextSkip, CurrentPrefs.pref_TextSkip,
703 IDTA_MultiLineText, (ULONG) CurrentPrefs.pref_IconTextMuliLine,
704 IDTA_TextPen, PalettePrefs.pal_PensList[PENIDX_ICONTEXTPEN],
705 IDTA_TextPenSel, PalettePrefs.pal_PensList[PENIDX_ICONTEXTPENSEL],
706 IDTA_TextPenShadow, PalettePrefs.pal_PensList[PENIDX_ICONTEXTSHADOWPEN],
707 IDTA_TextPenOutline, PalettePrefs.pal_PensList[PENIDX_ICONTEXTOUTLINEPEN],
708 IDTA_TextPenBgSel, PalettePrefs.pal_PensList[PENIDX_ICONTEXTPENBGSEL],
709 IDTA_SelectedTextRectangle, CurrentPrefs.pref_SelectedTextRectangle,
710 IDTA_SelTextRectBorderX, CurrentPrefs.pref_SelTextRectBorderX,
711 IDTA_SelTextRectBorderY, CurrentPrefs.pref_SelTextRectBorderY,
712 IDTA_SelTextRectRadius, CurrentPrefs.pref_SelTextRectRadius,
713 IDTA_TextMode, CurrentPrefs.pref_TextMode,
714 IDTA_TextDrawMode, FontPrefs.fprf_TextDrawMode,
715 IDTA_TextBackPen, FontPrefs.fprf_FontBackPen,
716 DTA_Name, (ULONG) di->di_Device,
717 IDTA_Text, (ULONG) DevName,
718 IDTA_Font, (ULONG) iwt->iwt_IconFont,
719 IDTA_Fonthandle, (ULONG) &iwt->iwt_IconTTFont,
720 IDTA_FontHook, (ULONG) (TTEngineBase ? &ScalosFontHook : NULL),
721 IDTA_SizeConstraints, (ULONG) &iwt->iwt_WindowTask.mt_WindowStruct->ws_IconSizeConstraints,
722 IDTA_ScalePercentage, iwt->iwt_WindowTask.mt_WindowStruct->ws_IconScaleFactor,
723 TAG_END);
726 d1(KPrintF("%s/%s/%ld: iconObj=%08lx\n", __FILE__, __FUNC__, __LINE__, iconObj));
727 if (NULL == iconObj)
728 iconObj = ReadDefaultIcon(iwt, di, DevName);
729 } while (0);
731 if (iconObj)
732 in = DevIconOk2(iwt, di, iconObj);
734 if (IS_VALID_LOCK(oldDir))
735 CurrentDir(oldDir);
736 if (dLock)
737 UnLock(dLock);
738 if (DevName)
739 FreePathBuffer(DevName);
741 return in;
745 // try to read <pref_DefIconPath>/<VolumeName>.info
746 static Object *ReadDefaultVolumeIcon(struct internalScaWindowTask *iwt, struct ScaDeviceIcon *di, STRPTR DevName)
748 Object *iconObj;
749 STRPTR iconName = DevName + strlen(DevName) + 1;
750 size_t iconNameLen = Max_PathLen - strlen(DevName) - 2;
752 stccpy(iconName, CurrentPrefs.pref_DefIconPath, iconNameLen);
753 d1(kprintf("%s/%s/%ld: iconName=<%s> Len=%ld\n", __FILE__, __FUNC__, __LINE__, iconName, iconNameLen));
754 AddPart(iconName, "", iconNameLen);
755 d1(kprintf("%s/%s/%ld: iconName=<%s> Len=%ld\n", __FILE__, __FUNC__, __LINE__, iconName, iconNameLen));
756 SafeStrCat(iconName, "def_", iconNameLen);
757 d1(kprintf("%s/%s/%ld: iconName=<%s> Len=%ld\n", __FILE__, __FUNC__, __LINE__, iconName, iconNameLen));
758 SafeStrCat(iconName, di->di_Volume, iconNameLen);
759 d1(kprintf("%s/%s/%ld: iconName=<%s> Len=%ld\n", __FILE__, __FUNC__, __LINE__, iconName, iconNameLen));
760 StripTrailingColon(iconName);
762 d1(kprintf("%s/%s/%ld: iconName=<%s>\n", __FILE__, __FUNC__, __LINE__, iconName));
764 iconObj = ReadDefaultIconByName(iwt, iconName, DevName);
766 if (NULL == iconObj)
768 // Try again, but remove spaces from di->di_Volume
769 STRPTR dlp;
770 CONST_STRPTR slp;
771 size_t Len;
773 stccpy(iconName, CurrentPrefs.pref_DefIconPath, iconNameLen);
774 AddPart(iconName, "", iconNameLen);
775 SafeStrCat(iconName, "def_", iconNameLen);
777 Len = iconNameLen - 1 - strlen(iconName);
779 dlp = iconName + strlen(iconName);
780 slp = di->di_Volume;
781 while (Len && *slp)
783 if (' ' != *slp)
785 *dlp++ = *slp;
786 Len--;
788 slp++;
790 StripTrailingColon(iconName);
792 d1(kprintf("%s/%s/%ld: iconName=<%s>\n", __FILE__, __FUNC__, __LINE__, iconName));
794 iconObj = ReadDefaultIconByName(iwt, iconName, DevName);
797 d1(kprintf("%s/%s/%ld: iconObj=%08lx\n", __FILE__, __FUNC__, __LINE__, iconObj));
799 return iconObj;
803 // try to read <pref_DefIconPath>/<DeviceName>.info
804 static Object *ReadDefaultDeviceIcon(struct internalScaWindowTask *iwt, struct ScaDeviceIcon *di, STRPTR DevName)
806 Object *iconObj;
807 STRPTR iconName = DevName + strlen(DevName) + 1;
808 size_t iconNameLen = Max_PathLen - strlen(DevName) - 2;
810 stccpy(iconName, CurrentPrefs.pref_DefIconPath, iconNameLen);
811 AddPart(iconName, "", iconNameLen);
812 SafeStrCat(iconName, "def_", iconNameLen);
813 SafeStrCat(iconName, di->di_Device, iconNameLen);
814 StripTrailingColon(iconName);
816 d1(kprintf("%s/%s/%ld: iconName=<%s>\n", __FILE__, __FUNC__, __LINE__, iconName));
818 iconObj = ReadDefaultIconByName(iwt, iconName, DevName);
820 d1(kprintf("%s/%s/%ld: iconObj=%08lx\n", __FILE__, __FUNC__, __LINE__, iconObj));
822 return iconObj;
826 // try to read "disk.info" icon from volume
827 static Object *ReadDiskIcon(struct internalScaWindowTask *iwt, struct ScaDeviceIcon *di, STRPTR DevName)
829 Object *iconObj;
831 d1(kprintf("%s/%s/%ld: iwt=%08lx di=%08lx <%s>\n", __FILE__, __FUNC__, __LINE__, iwt, di, di->di_Volume));
833 // NewIconObject()
834 iconObj = NewIconObjectTags("disk",
835 IDTA_InnerBottom, CurrentPrefs.pref_ImageBorders.Bottom,
836 IDTA_InnerRight, CurrentPrefs.pref_ImageBorders.Right,
837 IDTA_InnerTop, CurrentPrefs.pref_ImageBorders.Top,
838 IDTA_InnerLeft, CurrentPrefs.pref_ImageBorders.Left,
839 IDTA_HalfShinePen, PalettePrefs.pal_PensList[PENIDX_HSHINEPEN],
840 IDTA_HalfShadowPen, PalettePrefs.pal_PensList[PENIDX_HSHADOWPEN],
841 IDTA_FrameTypeSel, CurrentPrefs.pref_FrameTypeSel,
842 IDTA_FrameType, CurrentPrefs.pref_FrameType,
843 IDTA_TextSkip, CurrentPrefs.pref_TextSkip,
844 IDTA_MultiLineText, (ULONG) CurrentPrefs.pref_IconTextMuliLine,
845 IDTA_TextPen, PalettePrefs.pal_PensList[PENIDX_ICONTEXTPEN],
846 IDTA_TextPenSel, PalettePrefs.pal_PensList[PENIDX_ICONTEXTPENSEL],
847 IDTA_TextPenShadow, PalettePrefs.pal_PensList[PENIDX_ICONTEXTSHADOWPEN],
848 IDTA_TextPenOutline, PalettePrefs.pal_PensList[PENIDX_ICONTEXTOUTLINEPEN],
849 IDTA_TextPenBgSel, PalettePrefs.pal_PensList[PENIDX_ICONTEXTPENBGSEL],
850 IDTA_SelectedTextRectangle, CurrentPrefs.pref_SelectedTextRectangle,
851 IDTA_SelTextRectBorderX, CurrentPrefs.pref_SelTextRectBorderX,
852 IDTA_SelTextRectBorderY, CurrentPrefs.pref_SelTextRectBorderY,
853 IDTA_SelTextRectRadius, CurrentPrefs.pref_SelTextRectRadius,
854 IDTA_TextMode, CurrentPrefs.pref_TextMode,
855 IDTA_TextDrawMode, FontPrefs.fprf_TextDrawMode,
856 IDTA_TextBackPen, FontPrefs.fprf_FontBackPen,
857 IDTA_Font, (ULONG) iwt->iwt_IconFont,
858 IDTA_Fonthandle, (ULONG) &iwt->iwt_IconTTFont,
859 IDTA_FontHook, (ULONG) (TTEngineBase ? &ScalosFontHook : NULL),
860 IDTA_SupportedIconTypes, CurrentPrefs.pref_SupportedIconTypes,
861 IDTA_SizeConstraints, (ULONG) &iwt->iwt_WindowTask.mt_WindowStruct->ws_IconSizeConstraints,
862 IDTA_ScalePercentage, iwt->iwt_WindowTask.mt_WindowStruct->ws_IconScaleFactor,
863 TAG_END);
865 d1(kprintf("%s/%s/%ld: iconObj=%08lx\n", __FILE__, __FUNC__, __LINE__, iconObj));
867 if (iconObj)
869 ULONG IconType;
871 GetAttr(IDTA_Type, iconObj, &IconType);
873 d1(kprintf("%s/%s/%ld: iconObj=%08lx IconType=%ld\n", __FILE__, __FUNC__, __LINE__, iconObj, IconType));
875 if (WBDISK == IconType)
877 SetAttrs(iconObj,
878 IDTA_Text, (ULONG) DevName,
879 TAG_END);
881 else
883 DisposeIconObject(iconObj);
884 iconObj = NULL;
888 d1(kprintf("%s/%s/%ld: iconObj=%08lx\n", __FILE__, __FUNC__, __LINE__, iconObj));
890 return iconObj;
894 // try to get default WBDISK icon
895 static Object *ReadDefaultIcon(struct internalScaWindowTask *iwt, struct ScaDeviceIcon *di, STRPTR DevName)
897 Object *iconObj;
898 ULONG IconType = WBDISK;
900 d1(kprintf("%s/%s/%ld: iwt=%08lx di=%08lx <%s>\n", __FILE__, __FUNC__, __LINE__, iwt, di, di->di_Volume));
902 switch (di->di_Info->id_DiskType)
904 case ID_NOT_REALLY_DOS:
905 case ID_KICKSTART_DISK:
906 IconType = WBKICK;
907 break;
910 // GetDefIconObject()
911 iconObj = GetDefIconObjectTags(IconType,
912 IDTA_InnerBottom, CurrentPrefs.pref_ImageBorders.Bottom,
913 IDTA_InnerRight, CurrentPrefs.pref_ImageBorders.Right,
914 IDTA_InnerTop, CurrentPrefs.pref_ImageBorders.Top,
915 IDTA_InnerLeft, CurrentPrefs.pref_ImageBorders.Left,
916 IDTA_HalfShinePen, PalettePrefs.pal_PensList[PENIDX_HSHINEPEN],
917 IDTA_HalfShadowPen, PalettePrefs.pal_PensList[PENIDX_HSHADOWPEN],
918 IDTA_FrameTypeSel, CurrentPrefs.pref_FrameTypeSel,
919 IDTA_FrameType, CurrentPrefs.pref_FrameType,
920 IDTA_TextSkip, CurrentPrefs.pref_TextSkip,
921 IDTA_MultiLineText, (ULONG) CurrentPrefs.pref_IconTextMuliLine,
922 IDTA_TextPen, PalettePrefs.pal_PensList[PENIDX_ICONTEXTPEN],
923 IDTA_TextPenSel, PalettePrefs.pal_PensList[PENIDX_ICONTEXTPENSEL],
924 IDTA_TextPenShadow, PalettePrefs.pal_PensList[PENIDX_ICONTEXTSHADOWPEN],
925 IDTA_TextPenOutline, PalettePrefs.pal_PensList[PENIDX_ICONTEXTOUTLINEPEN],
926 IDTA_TextPenBgSel, PalettePrefs.pal_PensList[PENIDX_ICONTEXTPENBGSEL],
927 IDTA_SelectedTextRectangle, CurrentPrefs.pref_SelectedTextRectangle,
928 IDTA_SelTextRectBorderX, CurrentPrefs.pref_SelTextRectBorderX,
929 IDTA_SelTextRectBorderY, CurrentPrefs.pref_SelTextRectBorderY,
930 IDTA_SelTextRectRadius, CurrentPrefs.pref_SelTextRectRadius,
931 IDTA_TextMode, CurrentPrefs.pref_TextMode,
932 IDTA_TextDrawMode, FontPrefs.fprf_TextDrawMode,
933 IDTA_TextBackPen, FontPrefs.fprf_FontBackPen,
934 DTA_Name, (ULONG) di->di_Device,
935 IDTA_Text, (ULONG) DevName,
936 IDTA_Font, (ULONG) iwt->iwt_IconFont,
937 IDTA_Fonthandle, (ULONG) &iwt->iwt_IconTTFont,
938 IDTA_FontHook, (ULONG) (TTEngineBase ? &ScalosFontHook : NULL),
939 TAG_END);
941 if (iconObj)
943 SetAttrs(iconObj,
944 IDTA_Type, WBDISK,
945 TAG_END);
948 d1(kprintf("%s/%s/%ld: iconObj=%08lx\n", __FILE__, __FUNC__, __LINE__, iconObj));
950 return iconObj;
954 static struct ScaIconNode *DevIconOk2(struct internalScaWindowTask *iwt, struct ScaDeviceIcon *di, Object *iconObj)
956 struct ScaIconNode *in;
957 STRPTR tt;
958 ULONG IconType;
959 struct ExtGadget *gg = (struct ExtGadget *) iconObj;
961 d1(kprintf("%s/%s/%ld: iwt=%08lx di=%08lx iconObj=%08lx\n", __FILE__, __FUNC__, __LINE__, iwt, di, iconObj));
963 tt = NULL;
964 if (DoMethod(iconObj, IDTM_FindToolType, "SCALOS_NOTEXT", &tt))
966 d1(kprintf("%s/%s/%ld: SCALOS_NOTEXT\n", __FILE__, __FUNC__, __LINE__));
968 SetAttrs(iconObj,
969 IDTA_Text, NULL,
970 TAG_END);
973 d1(kprintf("%s/%s/%ld: iwt=%08lx di=%08lx iconObj=%08lx\n", __FILE__, __FUNC__, __LINE__, iwt, di, iconObj));
975 DoMethod(iwt->iwt_WindowTask.mt_MainObject, SCCM_IconWin_LayoutIcon, iconObj, IOLAYOUTF_NormalImage);
977 ScalosLockIconListExclusive(iwt);
979 d1(KPrintF("%s/%s/%ld: iwt=%08lx di=%08lx iconObj=%08lx\n", __FILE__, __FUNC__, __LINE__, iwt, di, iconObj));
981 if (IsNoIconPosition(gg))
982 in = SCA_AllocIconNode(&iwt->iwt_WindowTask.wt_LateIconList);
983 else
984 in = SCA_AllocIconNode(&iwt->iwt_WindowTask.wt_IconList);
985 if (NULL == in)
987 ScalosUnLockIconList(iwt);
988 return in;
991 SetAttrs(iconObj,
992 IDTA_Type, WBDISK,
993 TAG_END);
995 StartDeviceIconNotify(iwt, di);
997 SetIconName(iconObj, in);
999 in->in_Icon = di->di_Icon = iconObj;
1000 in->in_DeviceIcon = di;
1001 // in->in_FileType = (struct TypeNode *) WBDISK;
1002 in->in_FileType = DefIconsIdentify(BNULL, di->di_Volume, WBDISK);
1003 in->in_Flags |= INF_Identified;
1005 d1(KPrintF("%s/%s/%ld: <%s> in_FileType=%08lx\n", __FILE__, __FUNC__, __LINE__, GetIconName(in), in->in_FileType));
1006 DateStamp(&in->in_DateStamp);
1008 if (!ClassCheckInfoData(di->di_Info))
1010 in->in_Flags |= INF_VolumeWriteProtected;
1011 AddIconOverlay(in->in_Icon, ICONOVERLAYF_ReadOnly);
1014 SetDeviceIconSupportsFlags(in);
1016 if (!(in->in_SupportFlags & INF_SupportsOpen))
1018 struct ExtGadget *gg = (struct ExtGadget *) in->in_Icon;
1020 gg->Flags |= GFLG_DISABLED;
1023 d1(kprintf("%s/%s/%ld: <%s> SupportFlags=%08lx\n", __FILE__, __FUNC__, __LINE__, \
1024 GetIconName(in), in->in_SupportFlags));
1026 tt = NULL;
1027 if (DoMethod(iconObj, IDTM_FindToolType, "SCALOS_NODRAG", &tt))
1029 in->in_Flags |= INF_Sticky;
1032 ScalosUnLockIconList(iwt);
1034 if (!IsNoIconPosition(gg))
1036 d1(kprintf("%s/%s/%ld: \n", __FILE__, __FUNC__, __LINE__));
1038 if ((!iwt->iwt_BackDrop || !CheckPosition(iwt, in)) && !CheckOverlap(iwt, in))
1039 DoMethod(iwt->iwt_WindowTask.mt_MainObject, SCCM_IconWin_DrawIcon, iconObj);
1042 GetAttr(IDTA_Type, iconObj, &IconType);
1044 if (WBDISK == IconType)
1046 // Read and display backdrop icons
1047 ReadDevBackdrop(iwt, in);
1050 return in;
1054 static LONG ReadDevBackdrop(struct internalScaWindowTask *iwt, struct ScaIconNode *DevIn)
1056 STRPTR fName = NULL;
1057 struct BackDropList bdl;
1058 LONG Result;
1059 BPTR oldDir = NOT_A_LOCK;
1060 BPTR vLock;
1062 d1(kprintf("%s/%s/%ld: START iwt=%08lx DevIn=%08lx <%s> in_DeviceIcon=%08lx\n", \
1063 __FILE__, __FUNC__, __LINE__, iwt, DevIn, DevIn->in_Name, DevIn->in_DeviceIcon));
1065 BackDropInitList(&bdl);
1067 do {
1068 struct ChainedLine *cnl;
1070 d1(kprintf("%s/%s/%ld: di_Device=<%s>\n", __FILE__, __FUNC__, __LINE__, DevIn->in_DeviceIcon->di_Device));
1072 vLock = Lock(DevIn->in_DeviceIcon->di_Device, ACCESS_READ);
1073 d1(kprintf("%s/%s/%ld: vLock=%08lx\n", __FILE__, __FUNC__, __LINE__, vLock));
1074 debugLock_d1(vLock);
1075 if (BNULL == vLock)
1077 Result = IoErr();
1078 d1(kprintf("%s/%s/%ld: vLock=NULL, Result=%ld\n", __FILE__, __FUNC__, __LINE__, Result));
1079 break;
1082 oldDir = CurrentDir(vLock);
1084 Result = BackdropLoadList(&bdl);
1085 if (RETURN_OK != Result)
1087 d1(kprintf("%s/%s/%ld: BackdropLoadList() failed, Result=%ld\n", __FILE__, __FUNC__, __LINE__, Result));
1088 break;
1091 fName = AllocPathBuffer();
1092 if (NULL == fName)
1094 Result = ERROR_NO_FREE_STORE;
1095 d1(kprintf("%s/%s/%ld: AllocPathBuffer() failed, Result=%ld\n", __FILE__, __FUNC__, __LINE__, Result));
1096 break;
1099 for (cnl = (struct ChainedLine *) bdl.bdl_LinesList.lh_Head;
1100 RETURN_OK == Result && cnl != (struct ChainedLine *) &bdl.bdl_LinesList.lh_Tail;
1101 cnl = (struct ChainedLine *) cnl->cnl_Node.ln_Succ)
1103 d1(kprintf("%s/%s/%ld: Line=<%s>\n", __FILE__, __FUNC__, __LINE__, cnl->cnl_Line));
1104 CreateBackdropIcon(iwt, &bdl, DevIn, cnl->cnl_Line, fName);
1106 } while (0);
1108 if (DevIn && DevIn->in_DeviceIcon)
1110 d1(kprintf("%s/%s/%ld: setting DIBF_BackdropReadComplete flag\n", __FILE__, __FUNC__, __LINE__));
1111 DevIn->in_DeviceIcon->di_Flags |= DIBF_BackdropReadComplete;
1114 BackdropFreeList(&bdl);
1116 d1(kprintf("%s/%s/%ld: vLock=%08lx\n", __FILE__, __FUNC__, __LINE__, vLock));
1118 if (IS_VALID_LOCK(oldDir))
1119 CurrentDir(oldDir);
1120 if (vLock)
1121 UnLock(vLock);
1122 if (fName)
1123 FreePathBuffer(fName);
1125 d1(kprintf("%s/%s/%ld: END Result=%ld\n", __FILE__, __FUNC__, __LINE__, Result));
1127 return Result;
1131 static struct ScaIconNode *CreateBackdropIcon(struct internalScaWindowTask *iwt,
1132 struct BackDropList *bdl, struct ScaIconNode *DevIn,
1133 CONST_STRPTR BackdropIconName, STRPTR fName)
1135 char ch;
1136 STRPTR lp;
1137 STRPTR tt;
1138 ULONG IconType;
1139 Object *iconObj = NULL;
1140 struct ScaIconNode *in = NULL;
1141 struct ExtGadget *gg;
1142 BPTR dirLock = (BPTR)NULL;
1143 BPTR oldDir = NOT_A_LOCK;
1144 BPTR iLock; // +++ JMC 28.11.2004
1145 T_ExamineData *fib = NULL; // +++ JMC 28.11.2004
1148 d1(kprintf("%s/%s/%ld: START BackdropIconName=<%s>\n", __FILE__, __FUNC__, __LINE__, BackdropIconName));
1150 do {
1152 if (strlen(BackdropIconName) < 1)
1153 break;
1155 stccpy(fName, BackdropIconName, Max_PathLen - 1);
1157 lp = PathPart(fName);
1158 ch = *lp;
1159 *lp = '\0';
1161 d1(kprintf("%s/%s/%ld: PathPart=<%s>\n", __FILE__, __FUNC__, __LINE__, fName));
1163 dirLock = Lock(fName, ACCESS_READ);
1166 *lp = ch;
1167 debugLock_d1(dirLock);
1168 if ((BPTR)NULL == dirLock)
1169 break;
1171 oldDir = CurrentDir(dirLock);
1173 lp = FilePart(fName);
1174 d1(kprintf("%s/%s/%ld: FilePart=<%s>\n", __FILE__, __FUNC__, __LINE__, lp));
1176 //-----------------------------------------------------------------------------
1177 // +++ JMC 28.11.2004
1178 // Check if the object got
1179 // a Hidden protection bit activated before to display it on desktop.
1181 if (CurrentPrefs.pref_HideProtectHiddenFlag)
1183 if (!ScalosExamineBegin(&fib))
1184 if (NULL == fib)
1186 d1(kprintf("%s/%s/%ld: AllocDosObject failed\n", __FILE__, __FUNC__, __LINE__));
1187 break;
1189 iLock = Lock(PathPart(fName), SHARED_LOCK);
1190 if (iLock)
1192 ScalosExamineLock(iLock, &fib);
1193 if (ScalosExamineGetProtection(fib) & FIBF_HIDDEN)
1195 d1(kprintf("%s/%s/%ld: <%s> FIBF_HIDDEN found!\n", __FILE__, __FUNC__, __LINE__, PathPart(fName)));
1196 UnLock(iLock);
1197 break;
1199 UnLock(iLock);
1203 //-----------------------------------------------------------------------------
1205 if (FindIconInDrawerWindows(dirLock, lp))
1207 d1(kprintf("%s/%s/%ld: <%s> Icon found in drawer window!\n", __FILE__, __FUNC__, __LINE__, PathPart(fName)));
1208 break;
1211 iconObj = NewIconObjectTags(lp,
1212 IDTA_Text, (ULONG) lp,
1213 IDTA_InnerBottom, CurrentPrefs.pref_ImageBorders.Bottom,
1214 IDTA_InnerRight, CurrentPrefs.pref_ImageBorders.Right,
1215 IDTA_InnerTop, CurrentPrefs.pref_ImageBorders.Top,
1216 IDTA_InnerLeft, CurrentPrefs.pref_ImageBorders.Left,
1217 IDTA_HalfShinePen, PalettePrefs.pal_PensList[PENIDX_HSHINEPEN],
1218 IDTA_HalfShadowPen, PalettePrefs.pal_PensList[PENIDX_HSHADOWPEN],
1219 IDTA_FrameTypeSel, CurrentPrefs.pref_FrameTypeSel,
1220 IDTA_FrameType, CurrentPrefs.pref_FrameType,
1221 IDTA_TextSkip, CurrentPrefs.pref_TextSkip,
1222 IDTA_MultiLineText, (ULONG) CurrentPrefs.pref_IconTextMuliLine,
1223 IDTA_TextPen, PalettePrefs.pal_PensList[PENIDX_ICONTEXTPEN],
1224 IDTA_TextPenSel, PalettePrefs.pal_PensList[PENIDX_ICONTEXTPENSEL],
1225 IDTA_TextPenShadow, PalettePrefs.pal_PensList[PENIDX_ICONTEXTSHADOWPEN],
1226 IDTA_TextPenOutline, PalettePrefs.pal_PensList[PENIDX_ICONTEXTOUTLINEPEN],
1227 IDTA_TextPenBgSel, PalettePrefs.pal_PensList[PENIDX_ICONTEXTPENBGSEL],
1228 IDTA_SelectedTextRectangle, CurrentPrefs.pref_SelectedTextRectangle,
1229 IDTA_SelTextRectBorderX, CurrentPrefs.pref_SelTextRectBorderX,
1230 IDTA_SelTextRectBorderY, CurrentPrefs.pref_SelTextRectBorderY,
1231 IDTA_SelTextRectRadius, CurrentPrefs.pref_SelTextRectRadius,
1232 IDTA_TextMode, CurrentPrefs.pref_TextMode,
1233 IDTA_TextDrawMode, FontPrefs.fprf_TextDrawMode,
1234 IDTA_TextBackPen, FontPrefs.fprf_FontBackPen,
1235 IDTA_Font, (ULONG) iwt->iwt_IconFont,
1236 IDTA_Fonthandle, (ULONG) &iwt->iwt_IconTTFont,
1237 IDTA_FontHook, (ULONG) (TTEngineBase ? &ScalosFontHook : NULL),
1238 IDTA_SupportedIconTypes, CurrentPrefs.pref_SupportedIconTypes,
1239 IDTA_SizeConstraints, (ULONG) &iwt->iwt_WindowTask.mt_WindowStruct->ws_IconSizeConstraints,
1240 IDTA_ScalePercentage, iwt->iwt_WindowTask.mt_WindowStruct->ws_IconScaleFactor,
1241 IDTA_OverlayType, ICONOVERLAYF_LeftOut,
1242 TAG_END);
1244 d1(kprintf("%s/%s/%ld: iconObj=%08lx\n", __FILE__, __FUNC__, __LINE__, iconObj));
1245 if (NULL == iconObj)
1246 break;
1248 gg = (struct ExtGadget *) iconObj;
1250 GetAttr(IDTA_Type, iconObj, &IconType);
1252 d1(kprintf("%s/%s/%ld: IconType=%ld\n", __FILE__, __FUNC__, __LINE__, IconType));
1253 if (WBDISK == IconType)
1254 break;
1256 tt = NULL;
1257 if (DoMethod(iconObj, IDTM_FindToolType, "SCALOS_NOTEXT", &tt))
1259 d1(kprintf("%s/%s/%ld: SCALOS_NOTEXT\n", __FILE__, __FUNC__, __LINE__));
1260 SetAttrs(iconObj,
1261 IDTA_Text, NULL,
1262 TAG_END);
1265 DoMethod(iwt->iwt_WindowTask.mt_MainObject, SCCM_IconWin_LayoutIcon, iconObj, IOLAYOUTF_NormalImage);
1267 ScalosLockIconListExclusive(iwt);
1269 if (IsNoIconPosition(gg))
1270 in = SCA_AllocIconNode(&iwt->iwt_WindowTask.wt_LateIconList);
1271 else
1272 in = SCA_AllocIconNode(&iwt->iwt_WindowTask.wt_IconList);
1273 if (NULL == in)
1274 break;
1276 SetIconName(iconObj, in);
1278 DateStamp(&in->in_DateStamp);
1280 in->in_Icon = iconObj;
1281 in->in_Lock = CurrentDir(oldDir);
1282 oldDir = NOT_A_LOCK;
1283 dirLock = (BPTR)NULL; // do not UnLock() !!!s
1285 if (WBTOOL == IconType || WBPROJECT == IconType)
1287 in->in_Flags |= INF_File;
1290 SetBackdropIconSupportsFlags(iwt, bdl, in);
1292 tt = NULL;
1293 if (DoMethod(iconObj, IDTM_FindToolType, "SCALOS_NODRAG", &tt))
1295 in->in_Flags |= INF_Sticky;
1298 if (!ClassCheckInfoData(DevIn->in_DeviceIcon->di_Info))
1300 in->in_Flags |= INF_VolumeWriteProtected;
1301 AddIconOverlay(in->in_Icon, ICONOVERLAYF_ReadOnly);
1304 ScalosUnLockIconList(iwt);
1306 if (!IsNoIconPosition(gg))
1308 d1(kprintf("%s/%s/%ld: \n", __FILE__, __FUNC__, __LINE__));
1310 if ((!iwt->iwt_BackDrop || !CheckPosition(iwt, in)) && !CheckOverlap(iwt, in))
1311 DoMethod(iwt->iwt_WindowTask.mt_MainObject, SCCM_IconWin_DrawIcon, iconObj);
1314 CreateSbi(DevIn, in);
1316 iconObj = NULL;
1317 } while (0);
1319 if (IS_VALID_LOCK(oldDir))
1320 CurrentDir(oldDir);
1321 if (dirLock)
1322 UnLock(dirLock);
1323 if (iconObj)
1324 DisposeIconObject(iconObj);
1325 ScalosExamineEnd(&fib);
1327 d1(kprintf("%s/%s/%ld: END in=%08lx\n", __FILE__, __FUNC__, __LINE__, in));
1329 return in;
1333 // Frees everything inside the ScaBackdropIcon, but does not free the node itself !!
1334 static void FreeBackdropIcon(struct ScaBackdropIcon *bdi)
1336 d1(kprintf("%s/%s/%ld: bdi=%08lx sbi_NotifyReq=%08lx sbi_DrawerName=%08lx <%s>\n", \
1337 __FILE__, __FUNC__, __LINE__, bdi, bdi->sbi_NotifyReq, bdi->sbi_DrawerName, bdi->sbi_DrawerName));
1339 if (NULL == bdi)
1340 return;
1342 if (bdi->sbi_NotifyReq)
1344 ScalosEndNotify(bdi->sbi_NotifyReq);
1346 ScalosFree(bdi->sbi_NotifyReq);
1347 bdi->sbi_NotifyReq = NULL;
1349 if (bdi->sbi_DrawerName)
1351 FreePathBuffer(bdi->sbi_DrawerName);
1352 bdi->sbi_DrawerName = NULL;
1357 void FreeBackdropIconList(struct ScaBackdropIcon **bdiList)
1359 struct ScaBackdropIcon *bdi, *bdiNext;
1361 d1(kprintf("%s/%s/%ld: START *bdiList=%08lx\n", __FILE__, __FUNC__, __LINE__, *bdiList));
1363 for (bdi=*bdiList; bdi; bdi = bdiNext)
1365 bdiNext = (struct ScaBackdropIcon *) bdi->sbi_Node.mln_Succ;
1367 d1(kprintf("%s/%s/%ld: bdi=%08lx bdiNext=%08lx\n", __FILE__, __FUNC__, __LINE__, bdi, bdiNext));
1369 FreeBackdropIcon(bdi);
1370 SCA_FreeNode((struct ScalosNodeList *) bdiList, &bdi->sbi_Node);
1373 d1(kprintf("%s/%s/%ld: END *bdiList=%08lx\n", __FILE__, __FUNC__, __LINE__, *bdiList));
1377 // remove ScalosBackdropIcon from in_IconList of the parent device icon
1378 void RemoveScalosBackdropIcon(struct ScaIconNode *in)
1380 struct internalScaWindowTask *iwtMain;
1381 struct ScaBackdropIcon *bdiList = NULL;
1382 struct ScaIconNode *inDev;
1384 d1(kprintf("%s/%s/%ld: in=%08lx <%s>\n", __FILE__, __FUNC__, __LINE__, in, GetIconName(in)));
1386 if (NULL== iInfos.xii_iinfos.ii_MainWindowStruct)
1387 return;
1389 iwtMain = (struct internalScaWindowTask *) iInfos.xii_iinfos.ii_MainWindowStruct->ws_WindowTask;
1391 ScalosLockIconListExclusive(iwtMain);
1393 for (inDev=iwtMain->iwt_WindowTask.wt_IconList; inDev; inDev = (struct ScaIconNode *) inDev->in_Node.mln_Succ)
1395 if (inDev->in_IconList)
1397 struct ScaBackdropIcon *sbi, *sbiNext;
1399 for (sbi=inDev->in_IconList; sbi; sbi = sbiNext)
1401 sbiNext = (struct ScaBackdropIcon *) sbi->sbi_Node.mln_Succ;
1403 if (sbi->sbi_Icon == in->in_Icon)
1405 d1(kprintf("%s/%s/%ld: sbi=%08lx sbi_NotifyReq=%08lx sbi_DrawerName=%08lx <%s>\n",\
1406 __FILE__, __FUNC__, __LINE__, sbi, sbi->sbi_NotifyReq, sbi->sbi_DrawerName, sbi->sbi_DrawerName));
1408 SCA_MoveNode((struct ScalosNodeList *)(APTR) &inDev->in_IconList,
1409 (struct ScalosNodeList *)(APTR) &bdiList,
1410 &sbi->sbi_Node);
1412 d1(kprintf("%s/%s/%ld: sbi=%08lx sbi_NotifyReq=%08lx sbi_DrawerName=%08lx <%s>\n",\
1413 __FILE__, __FUNC__, __LINE__, sbi, sbi->sbi_NotifyReq, sbi->sbi_DrawerName, sbi->sbi_DrawerName));
1419 d1(kprintf("%s/%s/%ld: bdiList=%08lx\n", __FILE__, __FUNC__, __LINE__, bdiList));
1421 FreeBackdropIconList(&bdiList);
1423 ScalosUnLockIconList(iwtMain);
1427 // Create <ScaBackdropIcon> entry for <in> in <DevIn->in_IconList>
1428 static BOOL CreateSbi(struct ScaIconNode *DevIn, struct ScaIconNode *in)
1430 struct internalScaWindowTask *iwtMain = (struct internalScaWindowTask *) iInfos.xii_iinfos.ii_MainWindowStruct->ws_WindowTask;
1431 struct ScaBackdropIcon *bdi;
1432 BOOL NotifySuccess = FALSE;
1433 BOOL Success = FALSE;
1435 d1(kprintf("%s/%s/%ld: DevIn=%08lx <%s> in=%08lx <%s>\n", \
1436 __FILE__, __FUNC__, __LINE__, DevIn, GetIconName(DevIn), in, GetIconName(in)));
1438 do {
1439 bdi = (struct ScaBackdropIcon *) SCA_AllocNode((struct ScalosNodeList *) &DevIn->in_IconList,
1440 sizeof(struct ScaBackdropIcon) - sizeof(struct MinNode));
1441 if (NULL == bdi)
1442 break;
1444 bdi->sbi_Icon = in->in_Icon;
1446 bdi->sbi_NotifyReq = ScalosAlloc(sizeof(struct NotifyRequest));
1447 if (NULL == bdi->sbi_NotifyReq)
1448 break;
1450 memset(bdi->sbi_NotifyReq, 0, sizeof(struct NotifyRequest));
1452 d1(kprintf("%s/%s/%ld: bdi=%08lx NotifyReq=%08lx\n", \
1453 __FILE__, __FUNC__, __LINE__, bdi, bdi->sbi_NotifyReq));
1455 bdi->sbi_DrawerName = AllocPathBuffer();
1456 if (NULL == bdi->sbi_DrawerName)
1457 break;
1459 d1(kprintf("%s/%s/%ld: sbi=%08lx sbi_DrawerName=%08lx\n", __FILE__, __FUNC__, __LINE__, bdi, bdi->sbi_DrawerName));
1461 if (!NameFromLock(in->in_Lock, bdi->sbi_DrawerName, MAX_FileName-1))
1462 break;
1464 bdi->sbi_NotifyReq->nr_Name = bdi->sbi_DrawerName;
1465 bdi->sbi_NotifyReq->nr_stuff.nr_Msg.nr_Port = iwtMain->iwt_WindowTask.wt_IconPort;
1466 bdi->sbi_NotifyReq->nr_Flags = NRF_SEND_MESSAGE;
1467 bdi->sbi_NotifyReq->nr_UserData = (ULONG)NULL;
1469 d1(kprintf("%s/%s/%ld: starting notification on <%s>\n", \
1470 __FILE__, __FUNC__, __LINE__, bdi->sbi_NotifyReq->nr_Name));
1472 Success = TRUE;
1474 if (!StartNotify(bdi->sbi_NotifyReq))
1475 break;
1477 d1(kprintf("%s/%s/%ld: started notification on <%s>\n", \
1478 __FILE__, __FUNC__, __LINE__, bdi->sbi_NotifyReq->nr_Name));
1480 NotifySuccess = TRUE;
1481 } while (0);
1483 if (Success)
1485 if (!NotifySuccess)
1487 if (bdi->sbi_NotifyReq)
1489 ScalosFree(bdi->sbi_NotifyReq);
1490 bdi->sbi_NotifyReq = NULL;
1494 d1(kprintf("%s/%s/%ld: sbi=%08lx sbi_DrawerName=%08lx\n", __FILE__, __FUNC__, __LINE__, bdi, bdi->sbi_DrawerName));
1496 else
1498 if (bdi)
1500 if (bdi->sbi_DrawerName)
1502 FreePathBuffer(bdi->sbi_DrawerName);
1503 bdi->sbi_DrawerName = NULL;
1505 if (bdi->sbi_NotifyReq)
1507 ScalosFree(bdi->sbi_NotifyReq);
1508 bdi->sbi_NotifyReq = NULL;
1511 SCA_FreeNode((struct ScalosNodeList *) &DevIn->in_IconList, &bdi->sbi_Node);
1515 d1(kprintf("%s/%s/%ld: Success=%ld NotifySuccess=%ld\n", __FILE__, __FUNC__, __LINE__, Success, NotifySuccess));
1517 return NotifySuccess;
1521 // Look for Device icon for <in>,
1522 // and create <ScaBackdropIcon> entry for <in>
1523 void CreateSbiForIcon(struct ScaIconNode *in)
1525 struct internalScaWindowTask *iwtMain = (struct internalScaWindowTask *) iInfos.xii_iinfos.ii_MainWindowStruct->ws_WindowTask;
1526 struct ScaIconNode *inDev;
1527 BOOL Finished = FALSE;
1529 d1(kprintf("%s/%s/%ld: START in=%08lx <%s>\n", __FILE__, __FUNC__, __LINE__, in, GetIconName(in)));
1530 debugLock_d1(in->in_Lock);
1532 if ((BPTR)NULL == in->in_Lock)
1533 return; // only useful for left-out icons
1535 ScalosLockIconListExclusive(iwtMain);
1537 for (inDev=iwtMain->iwt_WindowTask.wt_IconList; !Finished && inDev; inDev = (struct ScaIconNode *) inDev->in_Node.mln_Succ)
1539 if (inDev->in_DeviceIcon)
1541 BPTR DeviceIconLock = DiskInfoLock(inDev);
1543 if (DeviceIconLock)
1545 LONG IsSameLock;
1547 d1(kprintf("%s/%s/%ld: inDev=%08lx <%s>\n", __FILE__, __FUNC__, __LINE__, inDev, GetIconName(inDev)));
1549 IsSameLock = ScaSameLock(DeviceIconLock, in->in_Lock);
1550 d1(kprintf("%s/%s/%ld: SameLock()=%ld\n", __FILE__, __FUNC__, __LINE__, IsSameLock));
1552 switch (IsSameLock)
1554 case LOCK_SAME_VOLUME:
1555 case LOCK_SAME:
1556 d1(kprintf("%s/%s/%ld: \n", __FILE__, __FUNC__, __LINE__));
1557 CreateSbi(inDev, in);
1558 Finished = TRUE;
1559 break;
1560 default:
1561 break;
1564 UnLock(DeviceIconLock);
1569 ScalosUnLockIconList(iwtMain);
1571 d1(kprintf("%s/%s/%ld: END\n", __FILE__, __FUNC__, __LINE__));
1576 static struct ScaIconNode *IconAlreadyExists(struct internalScaWindowTask *iwt, struct ScaDeviceIcon *di)
1578 struct ScaIconNode *in;
1579 struct ScaIconNode *inFound = NULL;
1581 ScalosLockIconListShared(iwt);
1583 d1(kprintf("%s/%s/%ld:\n", __FILE__, __FUNC__, __LINE__));
1585 for (in=iwt->iwt_WindowTask.wt_IconList; NULL == inFound && in; in = (struct ScaIconNode *) in->in_Node.mln_Succ)
1587 if (in->in_DeviceIcon && in->in_DeviceIcon->di_Handler == di->di_Handler)
1589 d1(kprintf("%s/%s/%ld: Found in=%08lx <%s>\n", __FILE__, __FUNC__, __LINE__, in, GetIconName(in)));
1590 inFound = in;
1594 if (NULL == inFound)
1595 ScalosUnLockIconList(iwt);
1597 return inFound;
1601 static BOOL FindIconInDrawerWindows(BPTR dirLock, CONST_STRPTR IconName)
1603 struct ScaWindowStruct *ws;
1604 BOOL Found = FALSE;
1606 SCA_LockWindowList(SCA_LockWindowList_Shared);
1608 for (ws=winlist.wl_WindowStruct; !Found && ws; ws = (struct ScaWindowStruct *) ws->ws_Node.mln_Succ)
1610 struct internalScaWindowTask *iwtx = (struct internalScaWindowTask *) ws->ws_WindowTask;
1612 if (ws->ws_Lock && LOCK_SAME == SameLock(dirLock, ws->ws_Lock))
1614 struct ScaIconNode *in;
1616 ScalosLockIconListShared(iwtx);
1618 for (in=iwtx->iwt_WindowTask.wt_IconList; !Found && in; in = (struct ScaIconNode *) in->in_Node.mln_Succ)
1620 if (0 == Stricmp((STRPTR) IconName, (STRPTR) GetIconName(in)))
1621 Found = TRUE;
1624 ScalosUnLockIconList(iwtx);
1628 if (!Found)
1630 // Search in desktop window if backdrop icon is already present
1631 struct internalScaWindowTask *iwtx;
1632 struct ScaIconNode *in;
1634 ws = iInfos.xii_iinfos.ii_MainWindowStruct;
1635 iwtx = (struct internalScaWindowTask *) ws->ws_WindowTask;
1637 ScalosLockIconListShared(iwtx);
1639 for (in=iwtx->iwt_WindowTask.wt_IconList; !Found && in; in = (struct ScaIconNode *) in->in_Node.mln_Succ)
1641 if (in->in_Lock && LOCK_SAME == SameLock(dirLock, in->in_Lock)
1642 && (0 == Stricmp((STRPTR) IconName, (STRPTR) GetIconName(in))))
1643 Found = TRUE;
1646 ScalosUnLockIconList(iwtx);
1648 SCA_UnLockWindowList();
1650 return Found;
1654 static Object *ReadDefaultIconByName(struct internalScaWindowTask *iwt, CONST_STRPTR iconName, STRPTR DevName)
1656 Object *iconObj;
1658 d1(kprintf("%s/%s/%ld: iconName=<%s>\n", __FILE__, __FUNC__, __LINE__, iconName));
1660 iconObj = NewIconObjectTags(iconName,
1661 IDTA_InnerBottom, CurrentPrefs.pref_ImageBorders.Bottom,
1662 IDTA_InnerRight, CurrentPrefs.pref_ImageBorders.Right,
1663 IDTA_InnerTop, CurrentPrefs.pref_ImageBorders.Top,
1664 IDTA_InnerLeft, CurrentPrefs.pref_ImageBorders.Left,
1665 IDTA_HalfShinePen, PalettePrefs.pal_PensList[PENIDX_HSHINEPEN],
1666 IDTA_HalfShadowPen, PalettePrefs.pal_PensList[PENIDX_HSHADOWPEN],
1667 IDTA_FrameTypeSel, CurrentPrefs.pref_FrameTypeSel,
1668 IDTA_FrameType, CurrentPrefs.pref_FrameType,
1669 IDTA_TextSkip, CurrentPrefs.pref_TextSkip,
1670 IDTA_MultiLineText, (ULONG) CurrentPrefs.pref_IconTextMuliLine,
1671 IDTA_TextPen, PalettePrefs.pal_PensList[PENIDX_ICONTEXTPEN],
1672 IDTA_TextPenSel, PalettePrefs.pal_PensList[PENIDX_ICONTEXTPENSEL],
1673 IDTA_TextPenShadow, PalettePrefs.pal_PensList[PENIDX_ICONTEXTSHADOWPEN],
1674 IDTA_TextPenOutline, PalettePrefs.pal_PensList[PENIDX_ICONTEXTOUTLINEPEN],
1675 IDTA_TextPenBgSel, PalettePrefs.pal_PensList[PENIDX_ICONTEXTPENBGSEL],
1676 IDTA_SelectedTextRectangle, CurrentPrefs.pref_SelectedTextRectangle,
1677 IDTA_SelTextRectBorderX, CurrentPrefs.pref_SelTextRectBorderX,
1678 IDTA_SelTextRectBorderY, CurrentPrefs.pref_SelTextRectBorderY,
1679 IDTA_SelTextRectRadius, CurrentPrefs.pref_SelTextRectRadius,
1680 IDTA_TextMode, CurrentPrefs.pref_TextMode,
1681 IDTA_TextDrawMode, FontPrefs.fprf_TextDrawMode,
1682 IDTA_TextBackPen, FontPrefs.fprf_FontBackPen,
1683 IDTA_Font, (ULONG) iwt->iwt_IconFont,
1684 IDTA_Fonthandle, (ULONG) &iwt->iwt_IconTTFont,
1685 IDTA_FontHook, (ULONG) (TTEngineBase ? &ScalosFontHook : NULL),
1686 IDTA_SupportedIconTypes, CurrentPrefs.pref_SupportedIconTypes,
1687 IDTA_SizeConstraints, (ULONG) &iwt->iwt_WindowTask.mt_WindowStruct->ws_IconSizeConstraints,
1688 IDTA_ScalePercentage, iwt->iwt_WindowTask.mt_WindowStruct->ws_IconScaleFactor,
1689 TAG_END);
1691 if (iconObj)
1693 ULONG IconType;
1695 GetAttr(IDTA_Type, iconObj, &IconType);
1697 d1(kprintf("%s/%s/%ld: iconObj=%08lx IconType=%ld\n", __FILE__, __FUNC__, __LINE__, iconObj, IconType));
1699 SetAttrs(iconObj,
1700 IDTA_Type, WBDISK,
1701 IDTA_Text, (ULONG) DevName,
1702 TAG_END);
1705 d1(kprintf("%s/%s/%ld: iconObj=%08lx\n", __FILE__, __FUNC__, __LINE__, iconObj));
1707 return iconObj;
1711 static BOOL StartDeviceIconNotify(struct internalScaWindowTask *iwt, struct ScaDeviceIcon *di)
1713 BOOL Success = FALSE;
1715 if (di->di_NotifyReq.nr_Name)
1717 ScalosEndNotify(&di->di_NotifyReq);
1718 memset(&di->di_NotifyReq, 0, sizeof(di->di_NotifyReq));
1720 if (di->di_DiskIconName)
1722 FreePathBuffer(di->di_DiskIconName);
1723 di->di_DiskIconName = NULL;
1726 do {
1727 BPTR fLock;
1728 CONST_STRPTR NotifyReqName = "disk.info";
1730 di->di_DiskIconName = AllocPathBuffer();
1731 if (NULL == di->di_DiskIconName)
1732 break;
1734 fLock = Lock(NotifyReqName, ACCESS_READ);
1735 if (BNULL != fLock)
1737 if (!NameFromLock(fLock, di->di_DiskIconName, Max_PathLen))
1739 FreePathBuffer(di->di_DiskIconName);
1740 di->di_DiskIconName = NULL;
1743 UnLock(fLock);
1745 else
1747 stccpy(di->di_DiskIconName, di->di_Device, Max_PathLen);
1748 AddPart(di->di_DiskIconName, NotifyReqName, Max_PathLen);
1751 d1(kprintf("%s/%s/%ld: start notify for <%s>\n", __FILE__, __FUNC__, __LINE__, di->di_Device));
1753 di->di_NotifyReq.nr_Name = di->di_Device;
1754 di->di_NotifyReq.nr_stuff.nr_Msg.nr_Port = iwt->iwt_WindowTask.wt_IconPort;
1755 di->di_NotifyReq.nr_Flags = NRF_SEND_MESSAGE;
1757 Success = StartNotify(&di->di_NotifyReq);
1758 } while (0);
1760 return Success;
1764 static void SetDeviceIconSupportsFlags(struct ScaIconNode *in)
1766 if (NULL == in)
1767 return;
1769 in->in_SupportFlags |= INF_SupportsOpen | INF_SupportsCopy | INF_SupportsInformation
1770 | INF_SupportsSnapshot | INF_SupportsUnSnapshot | INF_SupportsRename;
1772 if (in->in_DeviceIcon)
1774 if (ID_WRITE_PROTECTED != in->in_DeviceIcon->di_Info->id_DiskState)
1775 in->in_SupportFlags |= INF_SupportsFormatDisk;
1777 d1(kprintf("%s/%s/%ld: <%s> DiskType=%08lx DiskState=%08lx\n", __FILE__, __FUNC__, __LINE__, \
1778 GetIconName(in), in->in_DeviceIcon->di_Info->id_DiskType, in->in_DeviceIcon->di_Info->id_DiskState));
1780 SetIconSupportsFlags(in, ClassCheckInfoData(in->in_DeviceIcon->di_Info));
1782 if (NULL == in->in_DeviceIcon->di_Volume)
1784 in->in_SupportFlags |= INF_SupportsFormatDisk;
1785 in->in_SupportFlags &= ~(INF_SupportsOpen | INF_SupportsCopy | INF_SupportsInformation
1786 | INF_SupportsSnapshot | INF_SupportsUnSnapshot | INF_SupportsRename);
1792 static void SetBackdropIconSupportsFlags(struct internalScaWindowTask *iwt,
1793 struct BackDropList *bdl, struct ScaIconNode *in)
1795 BOOL isWriteable;
1797 if (NULL == in)
1798 return;
1800 isWriteable = ClassIsDiskWritable(in->in_Lock);
1802 in->in_SupportFlags |= INF_SupportsOpen | INF_SupportsCopy | INF_SupportsInformation;
1804 d1(kprintf("%s/%s/%ld: <%s> isWriteable=%ld\n", __FILE__, __FUNC__, __LINE__, GetIconName(in), isWriteable));
1805 if (isWriteable)
1807 in->in_SupportFlags |= INF_SupportsSnapshot | INF_SupportsUnSnapshot
1808 | INF_SupportsDelete | INF_SupportsRename;
1810 d1(kprintf("%s/%s/%ld: \n", __FILE__, __FUNC__, __LINE__));
1812 if (IsPermanentBackDropIcon(iwt, bdl, in->in_Lock, GetIconName(in)))
1814 d1(kprintf("%s/%s/%ld: \n", __FILE__, __FUNC__, __LINE__));
1815 in->in_SupportFlags |= INF_SupportsPutAway;
1816 in->in_SupportFlags &= ~INF_SupportsLeaveOut;
1818 else
1820 d1(kprintf("%s/%s/%ld: \n", __FILE__, __FUNC__, __LINE__));
1821 in->in_SupportFlags &= ~INF_SupportsPutAway;
1822 in->in_SupportFlags |= INF_SupportsLeaveOut;
1826 SetIconSupportsFlags(in, isWriteable);