update experimental gcc 6 patch to gcc 6.1.0 release
[AROS.git] / workbench / tools / SysExplorer / enum_storage.c
blob8a93a2dc560baed5cf47c11f64c3bb15619f709d
1 /*
2 Copyright (C) 2015-2016, The AROS Development Team.
3 $Id$
4 */
6 #define DEBUG 0
7 #include <aros/debug.h>
9 #include <proto/alib.h>
10 #include <proto/dos.h>
11 #include <proto/exec.h>
12 #include <proto/muimaster.h>
13 #include <proto/oop.h>
14 #include <proto/utility.h>
15 #include <proto/intuition.h>
17 #include <mui/NListtree_mcc.h>
18 #include <mui/NListview_mcc.h>
19 #include <utility/tagitem.h>
20 #include <utility/hooks.h>
22 #include <hidd/hidd.h>
23 #include <hidd/storage.h>
24 #include <hidd/ata.h>
26 #include "locale.h"
27 #include "classes.h"
28 #include "enums.h"
30 struct List storageList;
32 OOP_AttrBase HiddATABusAB;
33 OOP_AttrBase HiddATAUnitAB;
35 const struct OOP_ABDescr storage_abd[] =
37 {IID_Hidd_ATABus , &HiddATABusAB },
38 {IID_Hidd_ATAUnit, &HiddATAUnitAB},
39 {NULL , NULL }
42 static void addATAUnit(OOP_Object *dev, ULONG attrID, struct MUI_NListtree_TreeNode *parent)
44 OOP_Object *unit = NULL;
46 D(bug("[SysExplorer:Storage] ataunit: \n"));
48 OOP_GetAttr(dev, attrID, (IPTR *)&unit);
49 if (unit)
51 struct InsertObjectMsg msg =
53 .obj = unit,
54 .winClass = ATAUnitWindow_CLASS
56 CONST_STRPTR name;
58 OOP_GetAttr(unit, aHidd_ATAUnit_Model, (IPTR *)&name);
59 DoMethod(hidd_tree, MUIM_NListtree_Insert, name, &msg,
60 parent, MUIV_NListtree_Insert_PrevNode_Tail, 0);
64 static void ataBusEnum(OOP_Object *dev, struct MUI_NListtree_TreeNode *parent)
66 D(bug("[SysExplorer:Storage] atabus: \n"));
68 addATAUnit(dev, aHidd_ATABus_Master, parent);
69 addATAUnit(dev, aHidd_ATABus_Slave , parent);
72 AROS_UFH3S(BOOL, storageenumFunc,
73 AROS_UFHA(struct Hook *, h, A0),
74 AROS_UFHA(OOP_Object*, obj, A2),
75 AROS_UFHA(void *, parent, A1))
77 AROS_USERFUNC_INIT
79 BOOL objValid = TRUE;
80 CONST_STRPTR name = NULL;
81 struct MUI_NListtree_TreeNode *tn;
82 ULONG flags = 0;
83 struct InsertObjectMsg msg =
85 .obj = obj,
86 .winClass = NULL
88 struct ClassHandlerNode *clHandlers = FindObjectHandler(obj, h->h_Data);
90 D(bug("[SysExplorer:Storage] enum: list @ 0x%p\n", h->h_Data));
91 D(bug("[SysExplorer:Storage] enum: handler @ 0x%p\n", clHandlers));
93 if (clHandlers)
95 if (clHandlers->muiClass)
96 msg.winClass = *(clHandlers->muiClass);
97 if (clHandlers->enumFunc)
98 flags = TNF_LIST|TNF_OPEN;
99 if (clHandlers->validFunc)
100 objValid = clHandlers->validFunc(obj, &flags);
103 if (objValid)
105 /* This is either HW or HIDD subclass */
106 OOP_GetAttr(obj, aHW_ClassName, (IPTR *)&name);
107 if (!name)
108 OOP_GetAttr(obj, aHidd_HardwareName, (IPTR *)&name);
110 tn = (APTR)DoMethod(hidd_tree, MUIM_NListtree_Insert, name, &msg,
111 parent, MUIV_NListtree_Insert_PrevNode_Sorted, flags);
112 D(bug("Inserted TreeNode 0x%p <%s> UserData 0x%p\n", tn, tn->tn_Name, tn->tn_User));
114 /* If we have enumerator for this class, call it now */
115 if (clHandlers && clHandlers->enumFunc && (flags & TNF_LIST))
116 clHandlers->enumFunc(obj, tn);
118 return FALSE; /* Continue enumeration */
120 AROS_USERFUNC_EXIT
123 static struct Hook storageenum_hook =
125 .h_Entry = storageenumFunc,
126 .h_Data = &storageList
129 static void storageEnum(OOP_Object *obj, struct MUI_NListtree_TreeNode *tn)
131 D(bug("[SysExplorer:Storage] enumerating..\n"));
132 D(bug("[SysExplorer:Storage] storage class list @ 0x%p\n", storageenum_hook.h_Data));
133 HW_EnumDrivers(obj, &storageenum_hook, tn);
136 BOOL storageenum_init(void)
138 struct ClassHandlerNode *storageclassNode;
140 D(bug("[SysExplorer:Storage] Initialising..\n"));
142 NEWLIST(&storageList);
143 D(bug("[SysExplorer:Storage] class list @ 0x%p\n", &storageList));
144 OOP_ObtainAttrBases(storage_abd);
146 storageclassNode = AllocMem(sizeof(struct ClassHandlerNode), MEMF_CLEAR);
147 storageclassNode->ch_Node.ln_Name = CLID_HW_ATA;
148 storageclassNode->muiClass = &GenericWindow_CLASS;
149 storageclassNode->enumFunc = storageEnum;
150 Enqueue(&storageList, &storageclassNode->ch_Node);
152 storageclassNode = AllocMem(sizeof(struct ClassHandlerNode), MEMF_CLEAR);
153 storageclassNode->ch_Node.ln_Name = CLID_Hidd_ATABus;
154 storageclassNode->muiClass = &ATAWindow_CLASS;
155 storageclassNode->enumFunc = ataBusEnum;
156 Enqueue(&storageList, &storageclassNode->ch_Node);
158 RegisterClassHandler(CLID_Hidd_Storage, 90, NULL, storageEnum, NULL);
159 return 2;
162 ADD2INIT(storageenum_init, 10);