2 /*****************************************************************************
3 ** This is the DevWinList custom class, a sub class of Window.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"
26 extern struct ExecBase
*SysBase
;
27 extern struct Library
*ps
;
28 extern struct IntuitionBase
*IntuitionBase
;
29 extern struct Library
*UtilityBase
;
30 /* extern struct IntuitionBase *IntuitionBase; */
31 extern struct DosLibrary
*DOSBase
;
33 #define NewList(list) NEWLIST(list)
35 static char *overridepowerstrings
[] =
38 "Override to bus-powered",
39 "Override to self-powered",
44 /* /// "AllocIfEntry()" */
45 struct IfListEntry
* AllocIfEntry(struct DevWinData
*data
, struct Node
*pif
, BOOL intend
)
47 struct IfListEntry
*iflnode
;
48 iflnode
= psdAllocVec(sizeof(struct IfListEntry
));
52 AddTail(&data
->iflist
, &iflnode
->node
);
58 /* /// "FreeIfEntry()" */
59 void FreeIfEntry(struct DevWinData
*data
, struct IfListEntry
*iflnode
)
61 Remove(&iflnode
->node
);
66 /* /// "InterfaceListDisplayHook()" */
67 AROS_UFH3(LONG
, InterfaceListDisplayHook
,
68 AROS_UFHA(struct Hook
*, hook
, A0
),
69 AROS_UFHA(char **, strarr
, A2
),
70 AROS_UFHA(struct IfListEntry
*, iflnode
, A1
))
79 struct IconListData
*data
;
80 struct DevWinData
*devdata
= (struct DevWinData
*) hook
->h_Data
;
93 struct Library
*bindingcls
;
94 data
= (struct IconListData
*) INST_DATA(IconListClass
->mcc_Class
, devdata
->iflvobj
);
96 psdGetAttrs(PGA_INTERFACE
, iflnode
->pif
,
97 IFA_InterfaceNum
, &ifnum
,
98 IFA_AlternateNum
, &ifaltnum
,
100 IFA_SubClass
, &ifsubclass
,
101 IFA_Protocol
, &ifproto
,
102 IFA_InterfaceName
, &ifname
,
103 IFA_NumEndpoints
, &ifnumeps
,
104 IFA_Binding
, &binding
,
105 IFA_BindingClass
, &bindingcls
,
107 psdSafeRawDoFmt(buf1
, 12, "%ld/%ld", ifnum
, ifaltnum
);
111 case STILLIMG_CLASSCODE
:
114 case BLUETOOTH_CLASSCODE
:
117 case FWUPGRADE_CLASSCODE
:
120 case VENDOR_CLASSCODE
:
122 case SECURITY_CLASSCODE
:
124 case SMARTCARD_CLASSCODE
:
126 case CDCDATA_CLASSCODE
:
130 case MASSSTORE_CLASSCODE
:
132 case PRINTER_CLASSCODE
:
134 case PHYSICAL_CLASSCODE
:
138 case CDCCTRL_CLASSCODE
:
140 case AUDIO_CLASSCODE
:
144 psdSafeRawDoFmt(buf3
, 48, "\33O[%08lx] %ld (%s)",
145 data
->mimainlist
[clsimg
],
147 psdNumToStr(NTS_COMBOCLASS
, (ifclass
<<NTSCCS_CLASS
)|(ifsubclass
<<NTSCCS_SUBCLASS
)|(ifproto
<<NTSCCS_PROTO
)|
148 NTSCCF_CLASS
|NTSCCF_SUBCLASS
|NTSCCF_PROTO
, "None"));
149 psdSafeRawDoFmt(buf4
, 8, "%ld", ifsubclass
);
150 psdSafeRawDoFmt(buf5
, 8, "%ld", ifproto
);
151 psdSafeRawDoFmt(buf6
, 8, "%ld", ifnumeps
);
160 *strarr
= bindingcls
->lib_Node
.ln_Name
;
165 *strarr
++ = "\33l\33uNum";
166 *strarr
++ = "\33l\33uName";
167 *strarr
++ = "\33l\33uClass";
168 *strarr
++ = "\33l\33uSub";
169 *strarr
++ = "\33l\33uProto";
170 *strarr
++ = "\33l\33uEPs";
171 *strarr
= "\33l\33uBinding";
178 /* /// "DevWinDispatcher()" */
179 AROS_UFH3(IPTR
, DevWinDispatcher
,
180 AROS_UFHA(struct IClass
*, cl
, A0
),
181 AROS_UFHA(Object
*, obj
, A2
),
182 AROS_UFHA(Msg
, msg
, A1
))
185 // There should never be an uninitialized pointer, but just in case, try to get an mungwall hit if so.
186 struct DevWinData
*data
= (struct DevWinData
*) 0xABADCAFE;
188 // on OM_NEW the obj pointer will be void, so don't try to get the data base in this case.
189 if(msg
->MethodID
!= OM_NEW
) data
= INST_DATA(cl
,obj
);
191 switch(msg
->MethodID
)
195 struct DevListEntry
*dlnode
;
196 struct IfListEntry
*iflnode
;
206 STRPTR devprodname
= NULL
;
214 #ifdef AROS_USB30_CODE
215 IPTR devissuperspeed
;
220 IPTR devisconfigured
;
221 IPTR devlowpower
= 0;
223 IPTR devdontpopup
= 0;
224 IPTR noclassbind
= 0;
225 IPTR overridepower
= 0;
226 IPTR devpowerdrain
= 0;
227 IPTR devpowersupply
= 0;
229 struct Node
*devhub
= NULL
;
230 STRPTR devhubname
= "";
232 struct Node
*phw
= NULL
;
246 struct List
*altiflist
;
249 struct Library
*bindingcls
;
251 STRPTR textbuf1
, textbuf2
, textbuf3
;
254 Object
*oldroot
= NULL
;
256 if(!(obj
= (Object
*) DoSuperMethodA(cl
, obj
, msg
)))
260 data
= INST_DATA(cl
, obj
);
261 NewList(&data
->iflist
);
262 data
->InterfaceDisplayHook
.h_Data
= data
;
263 data
->InterfaceDisplayHook
.h_Entry
= (APTR
) InterfaceListDisplayHook
;
265 dlnode
= (struct DevListEntry
*) GetTagData(MUIA_DevWin_DevEntry
, (IPTR
) NULL
, ((struct opSet
*) msg
)->ops_AttrList
);
269 dlnode
->devdata
= data
;
270 data
->dlnode
= dlnode
;
271 data
->pd
= dlnode
->pd
;
272 psdGetAttrs(PGA_DEVICE
, dlnode
->pd
,
274 DA_UsbVersion
, &devusbvers
,
276 DA_SubClass
, &devsubclass
,
277 DA_Protocol
, &devproto
,
278 DA_VendorID
, &devvendorid
,
279 DA_ProductID
, &devprodid
,
280 DA_Version
, &devversion
,
281 DA_Manufacturer
, &devmanufact
,
282 DA_OrigProductName
, &devprodname
,
283 DA_ProductName
, &customname
,
284 DA_SerialNumber
, &devserial
,
285 DA_IDString
, &devidstr
,
286 DA_CurrLangID
, &devcurrlang
,
287 DA_LangIDArray
, &devlangarray
,
288 DA_IsLowspeed
, &devislowspeed
,
289 DA_IsHighspeed
, &devishighspeed
,
290 #ifdef AROS_USB30_CODE
291 DA_IsSuperspeed
, &devissuperspeed
,
293 DA_IsConnected
, &devisconnected
,
294 DA_HasAddress
, &devhasaddress
,
295 DA_HasDevDesc
, &devhasdevdesc
,
296 DA_IsConfigured
, &devisconfigured
,
297 DA_LowPower
, &devlowpower
,
298 DA_NumConfigs
, &devnumcfgs
,
299 DA_ConfigList
, &cfgs
,
300 DA_Binding
, &binding
,
301 DA_BindingClass
, &bindingcls
,
302 DA_InhibitPopup
, &devdontpopup
,
303 DA_InhibitClassBind
, &noclassbind
,
304 DA_OverridePowerInfo
, &overridepower
,
305 DA_PowerSupply
, &devpowersupply
,
306 DA_PowerDrained
, &devpowerdrain
,
307 DA_AtHubPortNumber
, &devhubport
,
308 DA_HubDevice
, &devhub
,
313 psdGetAttrs(PGA_DEVICE
, devhub
,
314 DA_ProductName
, &devhubname
,
318 if(!devprodname
) /* backward compatibility */
320 devprodname
= customname
;
322 textbuf1
= psdAllocVec(3*1024);
323 textbuf2
= &textbuf1
[1*1024];
324 textbuf3
= &textbuf1
[2*1024];
329 psdSafeRawDoFmt(textbuf1
, 1024, "%s\n%ld (=0x%04lx)\n%04lx\n%s\n%ld (=0x%04lx)\n%s\n%s\n%ld mA supply / %ldmA drained",
330 devprodname
, devprodid
, devprodid
, devversion
, devmanufact
, devvendorid
, devvendorid
,
331 psdNumToStr(NTS_VENDORID
, (LONG
) devvendorid
, "unknown"),
333 devpowersupply
, devpowerdrain
);
336 devstate
= "Configured";
338 else if(devhasdevdesc
)
340 devstate
= "DevDescriptor";
342 else if(devhasaddress
)
344 devstate
= "Valid addr";
346 else if(devisconnected
)
348 devstate
= "Connected";
353 if( (devclass
== HUB_CLASSCODE
) && (devhubport
== (IPTR
)NULL
)) {
355 STRPTR cmpdevicename
= "";
356 STRPTR devicename
= "";
360 psdGetAttrs(PGA_HARDWARE
, phw
, HA_DeviceName
, &cmpdevicename
, HA_DeviceUnit
, &deviceunit
, TAG_END
);
361 devicename
= FilePart(cmpdevicename
);
364 psdSafeRawDoFmt(textbuf2
, 1024, "%s%s\n%s\n%ld\nRoot hub of %s unit %ld\n%ld (%s)\n%ld\n%ld\n%04lx",
365 devstate
, (devlowpower
? " (Lowpower)" : ""),
366 #ifdef AROS_USB30_CODE
367 (devislowspeed
? "Lowspeed" : (devissuperspeed
? "Superspeed" : (devishighspeed
? "Highspeed" : "Fullspeed"))),
369 (devislowspeed
? "Lowspeed" : (devishighspeed
? "Highspeed" : "Fullspeed")),
372 devicename
, deviceunit
,
374 psdNumToStr(NTS_COMBOCLASS
,
375 (devclass
<<NTSCCS_CLASS
)|(devsubclass
<<NTSCCS_SUBCLASS
)|(devproto
<<NTSCCS_PROTO
)|
376 NTSCCF_CLASS
|NTSCCF_SUBCLASS
|NTSCCF_PROTO
, "None"),
377 devsubclass
, devproto
, devusbvers
);
379 psdSafeRawDoFmt(textbuf2
, 1024, "%s%s\n%s\n%ld\nPort %ld at %s\n%ld (%s)\n%ld\n%ld\n%04lx",
380 devstate
, (devlowpower
? " (Lowpower)" : ""),
381 #ifdef AROS_USB30_CODE
382 (devislowspeed
? "Lowspeed" : (devissuperspeed
? "Superspeed" : (devishighspeed
? "Highspeed" : "Fullspeed"))),
384 (devislowspeed
? "Lowspeed" : (devishighspeed
? "Highspeed" : "Fullspeed")),
387 devhubport
, devhubname
,
389 psdNumToStr(NTS_COMBOCLASS
,
390 (devclass
<<NTSCCS_CLASS
)|(devsubclass
<<NTSCCS_SUBCLASS
)|(devproto
<<NTSCCS_PROTO
)|
391 NTSCCF_CLASS
|NTSCCF_SUBCLASS
|NTSCCF_PROTO
, "None"),
392 devsubclass
, devproto
, devusbvers
);
399 psdGetAttrs(PGA_CONFIG
, pc
,
400 CA_SelfPowered
, &cfgselfpow
,
401 CA_RemoteWakeup
, &cfgremwake
,
402 CA_ConfigNum
, &cfgnum
,
403 CA_MaxPower
, &cfgmaxpower
,
404 CA_ConfigName
, &cfgname
,
405 CA_NumInterfaces
, &cfgnumifs
,
406 CA_InterfaceList
, &ifs
,
409 psdSafeRawDoFmt(&textbuf3
[strlen(textbuf3
)], (ULONG
) 1024-strlen(textbuf3
),
410 "Config %ld (%s)\n Attributes: %s%s\n MaxPower: %ld mA\n %ld interface%s.\n",
412 cfgselfpow
? "self-powered " : "bus-powered ",
413 cfgremwake
? "remote-wakeup" : "",
414 cfgmaxpower
, cfgnumifs
,
415 (cfgnumifs
!= 1) ? "s" : "");
419 data
->classpopup
= CreateClassPopup();
420 data
->contents
= VGroup
,
422 MUIA_ShortHelp
, "These fields show some general information\n"
423 "on the USB device. Note that strings are not\n"
424 "mandatory and might be artificially created\n"
425 "from the product and vendor IDs.",
426 MUIA_FrameTitle
, "General device information",
427 Child
, LabelB("Product name:\nProduct ID:\nProduct version:\nManufacturer:\nVendor:\n\nSerial #:\nPower State:"),
430 MUIA_Background
, MUII_TextBack
,
431 MUIA_Text_Contents
, textbuf1
,
434 Child
, LabelB("State:\nSpeed:\nAddress:\nConnected:\nDevClass:\nSubclass:\nProtocol:\nUSB vers:"),
437 MUIA_Background
, MUII_TextBack
,
438 MUIA_Text_Contents
, textbuf2
,
442 Child
, Label("Custom Device Name:"),
443 Child
, data
->cwnameobj
= StringObject
,
444 MUIA_ShortHelp
, "You can enter a more readable name\n"
445 "here, if the device does not provide\n"
448 //MUIA_HorizWeight, 10,
450 MUIA_String_Contents
, customname
,
451 MUIA_String_AdvanceOnCR
, TRUE
,
454 MUIA_Group_SameWidth
, TRUE
,
455 Child
, data
->changenameobj
= TextObject
,
456 MUIA_ShortHelp
, "Click on this button to change the name of the\n"
457 "name of the device to the new one.",
459 MUIA_Background
, MUII_ButtonBack
,
461 MUIA_InputMode
, MUIV_InputMode_RelVerify
,
462 MUIA_Text_Contents
, "\33c Change Name ",
464 Child
, data
->resetnameobj
= TextObject
,
465 MUIA_ShortHelp
, "Removes the custom name and restores\n"
466 "the original one that Poseidon generated.",
468 MUIA_Background
, MUII_ButtonBack
,
470 MUIA_InputMode
, MUIV_InputMode_RelVerify
,
471 MUIA_Text_Contents
, "\33c Restore Name ",
476 Child
, Label("Disable class bindings:"),
477 Child
, data
->noclassbindobj
= ImageObject
, ImageButtonFrame
,
478 MUIA_ShortHelp
, "Skips this device during class scan,\n"
479 "making it available for application bindings.",
480 MUIA_Background
, MUII_ButtonBack
,
482 MUIA_InputMode
, MUIV_InputMode_Toggle
,
483 MUIA_Image_Spec
, MUII_CheckMark
,
484 MUIA_Image_FreeVert
, TRUE
,
485 MUIA_Selected
, noclassbind
,
486 MUIA_ShowSelState
, FALSE
,
489 Child
, Label("Inhibit popup:"),
490 Child
, data
->dontpopupobj
= ImageObject
, ImageButtonFrame
,
491 MUIA_ShortHelp
, "Inhibits a popup window appearing\n"
492 "for this particular device.",
493 MUIA_Background
, MUII_ButtonBack
,
495 MUIA_InputMode
, MUIV_InputMode_Toggle
,
496 MUIA_Image_Spec
, MUII_CheckMark
,
497 MUIA_Image_FreeVert
, TRUE
,
498 MUIA_Selected
, devdontpopup
,
499 MUIA_ShowSelState
, FALSE
,
502 Child
, Label("Power info:"),
503 Child
, data
->overridepowerobj
= CycleObject
,
505 MUIA_ShortHelp
, "Some devices and hubs give wrong information\n"
506 "about being self-powered, when they're actually\n"
507 "bus-powered, making me lose my hair.\n"
508 "Hence, you can override the information the\n"
509 "device gives about itself, allowing the power\n"
510 "management to work nicely.",
511 MUIA_Cycle_Entries
, overridepowerstrings
,
512 MUIA_Cycle_Active
, overridepower
,
517 MUIA_ShortHelp
, "This is a list of supported languages\n"
518 "for the USB device. It's not manadatory\n"
519 "and in fact cheap devices won't even use\n"
520 "any string descriptors in their firmware.",
521 Child
, data
->langlvobj
= ListviewObject
,
522 MUIA_FrameTitle
, "Supported languages",
523 MUIA_Listview_List
, ListObject
,
528 Child
, LabelB("Current language:"),
531 MUIA_Background
, MUII_TextBack
,
532 MUIA_Text_Contents
, psdNumToStr(NTS_LANGID
, devcurrlang
, "<unknown>"),
537 MUIA_ShortHelp
, "USB devices are able to support\n"
538 "different configurations. However,\n"
539 "this is really rare.",
540 MUIA_FrameTitle
, "Configurations",
541 Child
, data
->cfglvobj
= FloattextObject
,
543 MUIA_Floattext_Text
, textbuf3
,
548 Child
, ListviewObject
,
549 MUIA_ShortHelp
, "This is a list of so called interfaces\n"
550 "the device has. USB devices can be built\n"
551 "as compound, so that each interface has\n"
552 "different functions. Each interface can be\n"
553 "bound to a different class.",
554 MUIA_FrameTitle
, "Interfaces",
555 MUIA_Listview_List
, data
->iflvobj
=
556 NewObject(IconListClass
->mcc_Class
, 0, MUIA_ContextMenu
, data
->classpopup
, InputListFrame
, MUIA_List_MinLineHeight
, 16, MUIA_List_Format
, "BAR,BAR,BAR,BAR,BAR,BAR,", MUIA_List_Title
, TRUE
,MUIA_List_DisplayHook
, &data
->InterfaceDisplayHook
, TAG_END
),
560 MUIA_Group_SameWidth
, TRUE
,
561 Child
, data
->clsscanobj
= TextObject
,
562 MUIA_ShortHelp
, "Clicking on this button will start a class scan. This means that\n"
563 "each device will be examined if it matches some of the standard\n"
564 "classes in the system. In this case, a binding will be established\n"
565 "and the functionality will be added to the system automatically.",
567 MUIA_Background
, MUII_ButtonBack
,
569 MUIA_InputMode
, MUIV_InputMode_RelVerify
,
570 MUIA_Text_Contents
, "\33c Class Scan ",
572 Child
, data
->unbindobj
= TextObject
,
573 MUIA_ShortHelp
, "Manually removes an interface binding. This can be\n"
574 "useful to temporarily deactivate a device.\n"
575 "Use 'Class Scan' to reactivate the binding.",
578 MUIA_Background
, MUII_ButtonBack
,
580 MUIA_InputMode
, MUIV_InputMode_RelVerify
,
581 MUIA_Text_Contents
, "\33c Release Binding ",
583 Child
, data
->cfgobj
= TextObject
,
584 MUIA_ShortHelp
, "If there is an interface binding and the class\n"
585 "supports a configuration GUI. Clicking on this\n"
586 "button will open the interface preferences window.\n\n"
587 "Note well, that the corrsponding button for the\n"
588 "device binding settings can be found in the device\n"
592 MUIA_Background
, MUII_ButtonBack
,
594 MUIA_InputMode
, MUIV_InputMode_RelVerify
,
595 MUIA_Text_Contents
, "\33c Settings ",
599 psdFreeVec(textbuf1
);
602 set(obj
, MUIA_Window_IsSubWindow
, FALSE
);
603 set(obj
, MUIA_Window_Title
, devidstr
);
604 get(obj
, MUIA_Window_RootObject
, &oldroot
);
605 set(obj
, MUIA_Window_RootObject
, data
->contents
);
606 DoMethod(oldroot
, OM_DISPOSE
);
607 set(obj
, MUIA_Window_ID
, MAKE_ID('D','I','N','F'));
610 UWORD
*wptr
= devlangarray
;
613 DoMethod(data
->langlvobj
, MUIM_List_InsertSingle
,
614 psdNumToStr(NTS_LANGID
, (ULONG
) *wptr
++, "<unknown>"), MUIV_List_Insert_Bottom
);
617 DoMethod(data
->langlvobj
, MUIM_List_InsertSingle
, "<none>", MUIV_List_Insert_Bottom
);
622 psdGetAttrs(PGA_CONFIG
, pc
,
623 CA_InterfaceList
, &ifs
,
629 iflnode
= AllocIfEntry(data
, pif
, FALSE
);
632 DoMethod(data
->iflvobj
, MUIM_List_InsertSingle
, iflnode
, MUIV_List_Insert_Bottom
);
634 psdGetAttrs(PGA_INTERFACE
, pif
,
635 IFA_AlternateIfList
, &altiflist
,
637 altpif
= altiflist
->lh_Head
;
638 while(altpif
->ln_Succ
)
640 iflnode
= AllocIfEntry(data
, altpif
, TRUE
);
643 DoMethod(data
->iflvobj
, MUIM_List_InsertSingle
, iflnode
, MUIV_List_Insert_Bottom
);
646 altpif
= altpif
->ln_Succ
;
653 DoMethod(data
->clsscanobj
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
654 obj
, 1, MUIM_DevWin_Dev_Bind
);
655 DoMethod(data
->unbindobj
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
656 obj
, 1, MUIM_DevWin_If_Unbind
);
657 DoMethod(data
->cfgobj
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
658 obj
, 2, MUIM_DevWin_If_Config
);
659 DoMethod(data
->iflvobj
, MUIM_Notify
, MUIA_Listview_DoubleClick
, TRUE
,
660 obj
, 1, MUIM_DevWin_If_Config
);
661 DoMethod(data
->iflvobj
, MUIM_Notify
, MUIA_List_Active
, MUIV_EveryTime
,
662 obj
, 1, MUIM_DevWin_If_Activate
);
663 DoMethod(data
->iflvobj
, MUIM_Notify
, MUIA_ContextMenuTrigger
, MUIV_EveryTime
,
664 obj
, 2, MUIM_DevWin_If_FBind
, MUIV_TriggerValue
);
665 DoMethod(data
->cwnameobj
, MUIM_Notify
, MUIA_String_Acknowledge
, MUIV_EveryTime
,
666 obj
, 1, MUIM_DevWin_SetCustomName
);
667 DoMethod(data
->changenameobj
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
668 obj
, 1, MUIM_DevWin_SetCustomName
);
669 DoMethod(data
->resetnameobj
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
670 obj
, 1, MUIM_DevWin_ResetCustomName
);
671 DoMethod(data
->dontpopupobj
, MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
672 obj
, 1, MUIM_DevWin_PopupInhibitChg
);
673 DoMethod(data
->noclassbindobj
, MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
674 obj
, 1, MUIM_DevWin_NoClassBindChg
);
675 DoMethod(data
->overridepowerobj
, MUIM_Notify
, MUIA_Cycle_Active
, MUIV_EveryTime
,
676 obj
, 1, MUIM_DevWin_PowerInfoChg
);
678 CoerceMethod(cl
, obj
, OM_DISPOSE
);
687 struct IfListEntry
*iflnode
;
690 if(data
->dlnode
->infowindow
)
692 data
->dlnode
->infowindow
= NULL
;
694 data
->dlnode
->devdata
= NULL
;
698 DoMethod(data
->classpopup
, OM_DISPOSE
);
699 data
->classpopup
= NULL
;
701 iflnode
= (struct IfListEntry
*) data
->iflist
.lh_Head
;
702 while(iflnode
->node
.ln_Succ
)
704 FreeIfEntry(data
, iflnode
);
705 iflnode
= (struct IfListEntry
*) data
->iflist
.lh_Head
;
711 case MUIM_DevWin_Dev_Bind
:
713 DoMethod(obj
, MUIM_DevWin_If_Activate
);
714 DoMethod(data
->iflvobj
, MUIM_List_Redraw
, MUIV_List_Redraw_All
);
717 case MUIM_DevWin_If_Activate
:
721 IPTR hascfggui
= FALSE
;
722 struct Library
*UsbClsBase
;
723 struct IfListEntry
*iflnode
;
725 DoMethod(data
->iflvobj
, MUIM_List_GetEntry
, MUIV_List_GetEntry_Active
, &iflnode
);
728 psdGetAttrs(PGA_INTERFACE
, iflnode
->pif
,
729 IFA_Binding
, &binding
,
730 IFA_BindingClass
, &puc
,
732 set(data
->unbindobj
, MUIA_Disabled
, !binding
);
735 psdGetAttrs(PGA_USBCLASS
, puc
,
736 UCA_ClassBase
, &UsbClsBase
,
738 usbGetAttrs(UGA_CLASS
, NULL
,
739 UCCA_HasBindingCfgGUI
, &hascfggui
,
741 set(data
->cfgobj
, MUIA_Disabled
, !hascfggui
);
743 set(data
->cfgobj
, MUIA_Disabled
, TRUE
);
745 set(data
->iflvobj
, MUIA_ContextMenu
, data
->classpopup
);
747 set(data
->unbindobj
, MUIA_Disabled
, TRUE
);
748 set(data
->cfgobj
, MUIA_Disabled
, TRUE
);
749 set(data
->iflvobj
, MUIA_ContextMenu
, NULL
);
754 case MUIM_DevWin_If_Unbind
:
757 struct IfListEntry
*iflnode
;
759 DoMethod(data
->iflvobj
, MUIM_List_GetEntry
, MUIV_List_GetEntry_Active
, &iflnode
);
762 psdGetAttrs(PGA_INTERFACE
, iflnode
->pif
,
763 IFA_Binding
, &binding
,
767 psdReleaseIfBinding(iflnode
->pif
);
768 set(data
->unbindobj
, MUIA_Disabled
, TRUE
);
769 set(data
->cfgobj
, MUIA_Disabled
, TRUE
);
770 DoMethod(data
->iflvobj
, MUIM_List_Redraw
, MUIV_List_Redraw_All
);
776 case MUIM_DevWin_If_Config
:
780 struct Library
*UsbClsBase
;
781 struct IfListEntry
*iflnode
;
783 DoMethod(data
->iflvobj
, MUIM_List_GetEntry
, MUIV_List_GetEntry_Active
, &iflnode
);
786 psdGetAttrs(PGA_INTERFACE
, iflnode
->pif
,
787 IFA_Binding
, &binding
,
788 IFA_BindingClass
, &puc
,
792 psdGetAttrs(PGA_USBCLASS
, puc
,
793 UCA_ClassBase
, &UsbClsBase
,
795 usbDoMethod(UCM_OpenBindingCfgWindow
, binding
);
801 case MUIM_DevWin_If_FBind
:
803 Object
*mi
= (Object
*) (((IPTR
*) msg
)[1]);
807 STRPTR devname
= NULL
;
809 struct IfListEntry
*iflnode
;
811 DoMethod(data
->iflvobj
, MUIM_List_GetEntry
, MUIV_List_GetEntry_Active
, &iflnode
);
814 get(mi
, MUIA_Menuitem_Title
, &name
);
815 if(!strcmp(name
, "None"))
819 psdGetAttrs(PGA_DEVICE
, data
->pd
,
820 DA_ProductName
, &devname
,
823 psdGetAttrs(PGA_INTERFACE
, iflnode
->pif
,
828 clever
= MUI_RequestA(_app(obj
), obj
, 0, NULL
, "I'm not dumb!|I'll reconsider",
829 "You are about to establish a forced \33binterface\33n\n"
830 "binding. As most people are not capable of reading the\n"
831 "manual and they cause more harm than good,\n"
832 "please make sure you know, what you're doing\n"
833 "and not breaking things (and then bugger me with\n"
834 "silly emails).", NULL
);
840 if(psdSetForcedBinding(name
, devid
, ifid
))
844 psdAddErrorMsg(RETURN_OK
, "Trident", "Forcing interface binding of %s to %s.", devname
, name
);
846 psdAddErrorMsg(RETURN_OK
, "Trident", "Removed forced interface binding of %s.", devname
);
854 case MUIM_DevWin_SetCustomName
:
857 STRPTR devidstr
= NULL
;
858 STRPTR oldname
= NULL
;
859 CONST_STRPTR newname
= "";
861 psdGetAttrs(PGA_DEVICE
, data
->pd
,
862 DA_IDString
, &devidstr
,
863 DA_ProductName
, &oldname
,
869 get(data
->cwnameobj
, MUIA_String_Contents
, &newname
);
874 if(oldname
&& !strcmp(newname
, oldname
))
878 pic
= psdGetUsbDevCfg("Trident", devidstr
, NULL
);
881 psdSetUsbDevCfg("Trident", devidstr
, NULL
, NULL
);
882 pic
= psdGetUsbDevCfg("Trident", devidstr
, NULL
);
886 if(psdAddStringChunk(pic
, IFFCHNK_NAME
, newname
))
888 psdAddErrorMsg(RETURN_OK
, "Trident", "Set new custom name '%s'.", newname
);
889 newnewname
= psdCopyStr(newname
);
892 psdSetAttrs(PGA_DEVICE
, data
->pd
,
893 DA_ProductName
, newnewname
,
900 set(data
->cwnameobj
, MUIA_String_Contents
, newname
);
901 DoMethod(data
->dlnode
->adata
->devlistobj
, MUIM_List_Redraw
, MUIV_List_Redraw_All
);
905 case MUIM_DevWin_ResetCustomName
:
908 STRPTR devidstr
= NULL
;
909 STRPTR oldname
= NULL
;
910 STRPTR origname
= NULL
;
912 psdGetAttrs(PGA_DEVICE
, data
->pd
,
913 DA_IDString
, &devidstr
,
914 DA_ProductName
, &oldname
,
915 DA_OrigProductName
, &origname
,
921 pic
= psdGetUsbDevCfg("Trident", devidstr
, NULL
);
924 if(psdRemCfgChunk(pic
, IFFCHNK_NAME
))
926 psdAddErrorMsg(RETURN_OK
, "Trident", "Custom name '%s' removed.", oldname
);
929 newname
= psdCopyStr(origname
);
932 psdSetAttrs(PGA_DEVICE
, data
->pd
,
933 DA_ProductName
, newname
,
940 psdGetAttrs(PGA_DEVICE
, data
->pd
,
941 DA_ProductName
, &oldname
,
943 set(data
->cwnameobj
, MUIA_String_Contents
, oldname
);
944 DoMethod(data
->dlnode
->adata
->devlistobj
, MUIM_List_Redraw
, MUIV_List_Redraw_All
);
948 case MUIM_DevWin_PopupInhibitChg
:
949 case MUIM_DevWin_NoClassBindChg
:
950 case MUIM_DevWin_PowerInfoChg
:
953 IPTR noclassbind
= 0;
954 IPTR overridepower
= 0;
955 get(data
->dontpopupobj
, MUIA_Selected
, &dontpopup
);
956 get(data
->noclassbindobj
, MUIA_Selected
, &noclassbind
);
957 get(data
->overridepowerobj
, MUIA_Cycle_Active
, &overridepower
);
959 psdSetAttrs(PGA_DEVICE
, data
->pd
,
960 DA_InhibitPopup
, dontpopup
,
961 DA_InhibitClassBind
, noclassbind
,
962 DA_OverridePowerInfo
, overridepower
,
968 return(DoSuperMethodA(cl
,obj
,msg
));