2 /*****************************************************************************
3 ** This is the CfgList custom class, a sub class of List.mui.
4 ******************************************************************************/
8 #define USE_INLINE_STDARG
10 #include <proto/muimaster.h>
11 #include <proto/exec.h>
12 #include <proto/dos.h>
13 #include <proto/poseidon.h>
14 #include <proto/intuition.h>
15 #include <proto/graphics.h>
16 #include <proto/usbclass.h>
17 #include <proto/icon.h>
18 #include <proto/utility.h>
21 #include "ActionClass.h"
22 #include "IconListClass.h"
23 #include "DevWinClass.h"
24 #include "CfgListClass.h"
27 extern struct ExecBase
*SysBase
;
28 extern struct Library
*ps
;
29 extern struct IntuitionBase
*IntuitionBase
;
31 /* /// "CheckDragAccept()" */
32 BOOL
CheckDragAccept(Object
*obj
, LONG targetentry
)
34 struct PrefsListEntry
*targetplnode
= NULL
;
35 struct PrefsListEntry
*sourceplnode
= NULL
;
36 ULONG sourceid
, targetid
;
37 IPTR sourceentry
= -1;
39 get(obj
, MUIA_List_Active
, &sourceentry
);
40 if((((LONG
) sourceentry
) < 0) || (targetentry
< 0))
44 DoMethod(obj
, MUIM_List_GetEntry
, sourceentry
, &sourceplnode
);
45 DoMethod(obj
, MUIM_List_GetEntry
, targetentry
, &targetplnode
);
46 if((!(sourceplnode
&& targetplnode
)) || (sourceplnode
== targetplnode
))
50 sourceid
= sourceplnode
->chunkid
;
51 targetid
= targetplnode
->chunkid
;
55 case IFFFORM_DEVICECFG
:
56 if(targetid
== IFFFORM_DEVICECFG
)
62 case IFFFORM_DEVCFGDATA
:
63 if((targetid
== IFFFORM_DEVICECFG
) ||
64 (targetid
== IFFFORM_DEVCFGDATA
))
70 case IFFFORM_IFCFGDATA
:
71 if((targetid
== IFFFORM_DEVICECFG
) ||
72 (targetid
== IFFFORM_IFCFGDATA
))
78 case IFFCHNK_FORCEDBIND
:
79 if((targetid
== IFFFORM_DEVICECFG
) ||
80 (targetid
== IFFFORM_DEVCFGDATA
) ||
81 (targetid
== IFFFORM_IFCFGDATA
) ||
82 (targetid
== IFFCHNK_FORCEDBIND
))
92 /* /// "ApplyDragAction()" */
93 BOOL
ApplyDragAction(Object
*obj
, LONG targetentry
)
95 struct PrefsListEntry
*targetplnode
= NULL
;
96 struct PrefsListEntry
*sourceplnode
= NULL
;
97 ULONG sourceid
, targetid
;
98 IPTR sourceentry
= -1;
100 APTR pic
, spic
, tpic
;
103 get(obj
, MUIA_List_Active
, &sourceentry
);
104 if((((LONG
) sourceentry
) < 0) || (targetentry
< 0))
108 DoMethod(obj
, MUIM_List_GetEntry
, sourceentry
, &sourceplnode
);
109 DoMethod(obj
, MUIM_List_GetEntry
, targetentry
, &targetplnode
);
110 if((!(sourceplnode
&& targetplnode
)) || (sourceplnode
== targetplnode
))
114 sourceid
= sourceplnode
->chunkid
;
115 targetid
= targetplnode
->chunkid
;
119 case IFFFORM_DEVICECFG
:
120 if(targetid
== IFFFORM_DEVICECFG
)
122 result
= MUI_Request(_app(obj
), _win(obj
), 0, NULL
, _(MSG_APPLYDRAGACTION_DEVICECFG
),_(MSG_APPLYDRAGACTION_DEVICECFG_HELP
), targetplnode
->id
, sourceplnode
->id
);
129 pic
= psdFindCfgForm(NULL
, IFFFORM_DEVICECFG
);
132 if(psdMatchStringChunk(pic
, IFFCHNK_DEVID
, targetplnode
->devid
))
136 if(psdMatchStringChunk(pic
, IFFCHNK_DEVID
, sourceplnode
->devid
))
140 pic
= psdNextCfgForm(pic
);
146 // delete old contents
149 while((pic
= psdFindCfgForm(tpic
, IFFFORM_DEVCFGDATA
)))
153 while((pic
= psdFindCfgForm(tpic
, IFFFORM_IFCFGDATA
)))
159 // copy device cfg data
160 pic
= psdFindCfgForm(spic
, IFFFORM_DEVCFGDATA
);
163 form
= psdWriteCfg(pic
);
166 psdAddCfgEntry(tpic
, form
);
169 pic
= psdNextCfgForm(pic
);
171 // copy interface cfg data
172 pic
= psdFindCfgForm(spic
, IFFFORM_IFCFGDATA
);
175 form
= psdWriteCfg(pic
);
178 psdAddCfgEntry(tpic
, form
);
181 pic
= psdNextCfgForm(pic
);
187 case IFFFORM_IFCFGDATA
:
188 case IFFFORM_DEVCFGDATA
:
189 if((targetid
== IFFFORM_DEVCFGDATA
) || (targetid
== IFFFORM_IFCFGDATA
))
191 if(strcmp(sourceplnode
->owner
, targetplnode
->owner
))
193 result
= MUI_RequestA(_app(obj
), _win(obj
), 0, NULL
, _(MSG_APPLYDRAGACTION_DEVCFGDATA
),_(MSG_APPLYDRAGACTION_DEVCFGDATA_HELP
), NULL
);
198 targetid
= IFFFORM_DEVICECFG
;
200 result
= MUI_Request(_app(obj
), _win(obj
), 0, NULL
, _(MSG_APPLYDRAGACTION_DEVCFGDATA_REPLACE
),_(MSG_APPLYDRAGACTION_DEVCFGDATA_REPLACE_HELP
), targetplnode
->id
, sourceplnode
->id
);
206 pic
= psdGetUsbDevCfg(sourceplnode
->owner
, sourceplnode
->devid
, sourceplnode
->ifid
);
209 form
= psdWriteCfg(pic
);
212 psdSetUsbDevCfg(sourceplnode
->owner
, targetplnode
->devid
, targetplnode
->ifid
, form
);
219 if(targetid
== IFFFORM_DEVICECFG
)
221 pic
= psdGetUsbDevCfg(sourceplnode
->owner
, targetplnode
->devid
, sourceplnode
->ifid
);
224 result
= MUI_Request(_app(obj
), _win(obj
), 0, NULL
, _(MSG_APPLYDRAGACTION_DEVICECFG_REPLACE
),_(MSG_APPLYDRAGACTION_DEVICECFG_REPLACE_HELP
), targetplnode
->id
, sourceplnode
->id
);
226 result
= MUI_Request(_app(obj
), _win(obj
), 0, NULL
, _(MSG_APPLYDRAGACTION_DEVICECFG_ADD
),_(MSG_APPLYDRAGACTION_DEVICECFG_ADD_HELP
), sourceplnode
->id
, targetplnode
->id
);
232 pic
= psdGetUsbDevCfg(sourceplnode
->owner
, sourceplnode
->devid
, sourceplnode
->ifid
);
235 form
= psdWriteCfg(pic
);
238 psdSetUsbDevCfg(sourceplnode
->owner
, targetplnode
->devid
, sourceplnode
->ifid
, form
);
246 case IFFCHNK_FORCEDBIND
:
247 if((targetid
== IFFFORM_DEVICECFG
) ||
248 (targetid
== IFFFORM_DEVCFGDATA
) ||
249 (targetid
== IFFFORM_IFCFGDATA
) ||
250 (targetid
== IFFCHNK_FORCEDBIND
))
252 psdSetForcedBinding(sourceplnode
->owner
, targetplnode
->devid
, targetplnode
->ifid
);
261 /* /// "CfgListDispatcher()" */
262 AROS_UFH3(IPTR
, CfgListDispatcher
,
263 AROS_UFHA(struct IClass
*, cl
, A0
),
264 AROS_UFHA(Object
*, obj
, A2
),
265 AROS_UFHA(Msg
, msg
, A1
))
268 // There should never be an uninitialized pointer, but just in case, try to get an mungwall hit if so.
269 struct CfgListData
*data
= (struct CfgListData
*) 0xABADCAFE;
271 // on OM_NEW the obj pointer will be void, so don't try to get the data base in this case.
272 if(msg
->MethodID
!= OM_NEW
) data
= INST_DATA(cl
,obj
);
274 switch(msg
->MethodID
)
277 if(!(obj
= (Object
*) DoSuperMethodA(cl
,obj
,msg
)))
282 data
->cl_Dragging
= TRUE
;
285 case MUIM_DragFinish
:
286 data
->cl_Dragging
= FALSE
;
291 struct MUI_List_TestPos_Result tpr
;
297 return(MUIV_DragQuery_Refuse
);
299 DoMethod(obj
, MUIM_List_TestPos
, win
->MouseX
, win
->MouseY
, &tpr
);
300 return((IPTR
) (CheckDragAccept(obj
, tpr
.entry
) ? MUIV_DragQuery_Accept
: MUIV_DragQuery_Refuse
));
303 #ifndef MUI_LPR_FULLDROP
304 #define MUI_LPR_FULLDROP (1<<15)
306 case MUIM_List_TestPos
:
308 struct MUIP_List_TestPos
*tpmsg
= (struct MUIP_List_TestPos
*) msg
;
309 struct MUI_List_TestPos_Result
*res
= tpmsg
->res
;
311 rc
= DoSuperMethodA(cl
, obj
, msg
);
312 if(data
->cl_Dragging
&& (res
->entry
!= -1))
314 if(!CheckDragAccept(obj
, res
->entry
))
316 res
->entry
= -1; // illegal combination
318 res
->flags
|= MUI_LPR_FULLDROP
;
326 //struct MUIP_DragDrop *ddmsg = (struct MUIP_DragDrop *) msg;
327 struct MUI_List_TestPos_Result tpr
;
335 DoMethod(obj
, MUIM_List_TestPos
, win
->MouseX
, win
->MouseY
, &tpr
);
336 //DoMethod(obj, MUIM_List_TestPos, ddmsg->x, ddmsg->y, &tpr);
337 if(CheckDragAccept(obj
, tpr
.entry
))
339 ApplyDragAction(obj
, tpr
.entry
);
341 MUI_RequestA(_app(obj
), _win(obj
), 0, NULL
, _(MSG_CFGLISTDISPATCHER_OOPS
),_(MSG_CFGLISTDISPATCHER_OOPS_HELP
), NULL
);
348 return(DoSuperMethodA(cl
,obj
,msg
));