Documented GVF_SAVE_VAR alongside other flags, and removed a query/doubt
[AROS.git] / rom / usb / trident / DevWinClass.c
blobc49bdd007797471204ec8406f4edf4d4824ee7f6
2 /*****************************************************************************
3 ** This is the DevWinList custom class, a sub class of Window.mui.
4 ******************************************************************************/
6 #include "debug.h"
8 #define USE_INLINE_STDARG
9 #define __NOLIBBASE__
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>
20 #include "Trident.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[] =
37 "Trust device",
38 "Override to bus-powered",
39 "Override to self-powered",
40 NULL
44 /* /// "AllocIfEntry()" */
45 struct IfListEntry * AllocIfEntry(struct DevWinData *data, struct Node *pif, BOOL intend)
47 struct IfListEntry *iflnode;
48 iflnode = psdAllocVec(sizeof(struct IfListEntry));
49 if(iflnode)
51 iflnode->pif = pif;
52 AddTail(&data->iflist, &iflnode->node);
54 return(iflnode);
56 /* \\\ */
58 /* /// "FreeIfEntry()" */
59 void FreeIfEntry(struct DevWinData *data, struct IfListEntry *iflnode)
61 Remove(&iflnode->node);
62 psdFreeVec(iflnode);
64 /* \\\ */
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))
72 AROS_USERFUNC_INIT
74 static char buf1[12];
75 static char buf3[48];
76 static char buf4[8];
77 static char buf5[8];
78 static char buf6[8];
79 struct IconListData *data;
80 struct DevWinData *devdata = (struct DevWinData *) hook->h_Data;
82 if(iflnode)
84 IPTR clsimg;
85 IPTR ifnum;
86 IPTR ifaltnum;
87 IPTR ifclass;
88 IPTR ifsubclass;
89 IPTR ifproto;
90 STRPTR ifname;
91 IPTR ifnumeps;
92 APTR binding;
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,
99 IFA_Class, &ifclass,
100 IFA_SubClass, &ifsubclass,
101 IFA_Protocol, &ifproto,
102 IFA_InterfaceName, &ifname,
103 IFA_NumEndpoints, &ifnumeps,
104 IFA_Binding, &binding,
105 IFA_BindingClass, &bindingcls,
106 TAG_END);
107 psdSafeRawDoFmt(buf1, 12, "%ld/%ld", ifnum, ifaltnum);
108 clsimg = 5;
109 switch(ifclass)
111 case STILLIMG_CLASSCODE:
112 clsimg = 22;
113 break;
114 case BLUETOOTH_CLASSCODE:
115 clsimg = 21;
116 break;
117 case FWUPGRADE_CLASSCODE:
118 clsimg = 1;
119 break;
120 case VENDOR_CLASSCODE:
121 clsimg++;
122 case SECURITY_CLASSCODE:
123 clsimg++;
124 case SMARTCARD_CLASSCODE:
125 clsimg++;
126 case CDCDATA_CLASSCODE:
127 clsimg++;
128 case HUB_CLASSCODE:
129 clsimg++;
130 case MASSSTORE_CLASSCODE:
131 clsimg++;
132 case PRINTER_CLASSCODE:
133 clsimg++;
134 case PHYSICAL_CLASSCODE:
135 clsimg++;
136 case HID_CLASSCODE:
137 clsimg++;
138 case CDCCTRL_CLASSCODE:
139 clsimg += 2;
140 case AUDIO_CLASSCODE:
141 clsimg++;
144 psdSafeRawDoFmt(buf3, 48, "\33O[%08lx] %ld (%s)",
145 data->mimainlist[clsimg],
146 ifclass,
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);
152 *strarr++ = buf1;
153 *strarr++ = ifname;
154 *strarr++ = buf3;
155 *strarr++ = buf4;
156 *strarr++ = buf5;
157 *strarr++ = buf6;
158 if(binding)
160 *strarr = bindingcls->lib_Node.ln_Name;
161 } else {
162 *strarr = "None";
164 } else {
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";
173 return(0);
174 AROS_USERFUNC_EXIT
176 /* \\\ */
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))
184 AROS_USERFUNC_INIT
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)
193 case OM_NEW:
195 struct DevListEntry *dlnode;
196 struct IfListEntry *iflnode;
197 IPTR devadr;
198 IPTR devusbvers;
199 IPTR devclass;
200 IPTR devsubclass;
201 IPTR devproto;
202 IPTR devvendorid;
203 IPTR devprodid;
204 IPTR devversion;
205 STRPTR devmanufact;
206 STRPTR devprodname = NULL;
207 STRPTR devserial;
208 STRPTR devidstr;
209 STRPTR customname;
210 IPTR devcurrlang;
211 UWORD *devlangarray;
212 IPTR devislowspeed;
213 IPTR devishighspeed;
214 #ifdef AROS_USB30_CODE
215 IPTR devissuperspeed;
216 #endif
217 IPTR devisconnected;
218 IPTR devhasaddress;
219 IPTR devhasdevdesc;
220 IPTR devisconfigured;
221 IPTR devlowpower = 0;
222 IPTR devnumcfgs;
223 IPTR devdontpopup = 0;
224 IPTR noclassbind = 0;
225 IPTR overridepower = 0;
226 IPTR devpowerdrain = 0;
227 IPTR devpowersupply = 0;
228 IPTR devhubport = 0;
229 struct Node *devhub = NULL;
230 STRPTR devhubname = "";
232 struct Node *phw = NULL;
234 struct List *cfgs;
235 struct Node *pc;
236 IPTR cfgselfpow;
237 IPTR cfgremwake;
238 IPTR cfgnum;
239 IPTR cfgmaxpower;
240 STRPTR cfgname;
241 IPTR cfgnumifs;
243 struct List *ifs;
244 struct Node *pif;
245 struct Node *altpif;
246 struct List *altiflist;
248 APTR binding;
249 struct Library *bindingcls;
251 STRPTR textbuf1, textbuf2, textbuf3;
252 STRPTR devstate;
254 Object *oldroot = NULL;
256 if(!(obj = (Object *) DoSuperMethodA(cl, obj, msg)))
258 return(0);
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);
267 if(dlnode)
269 dlnode->devdata = data;
270 data->dlnode = dlnode;
271 data->pd = dlnode->pd;
272 psdGetAttrs(PGA_DEVICE, dlnode->pd,
273 DA_Address, &devadr,
274 DA_UsbVersion, &devusbvers,
275 DA_Class, &devclass,
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,
292 #endif
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,
309 DA_Hardware, &phw,
310 TAG_END);
311 if(devhub)
313 psdGetAttrs(PGA_DEVICE, devhub,
314 DA_ProductName, &devhubname,
315 TAG_END);
318 if(!devprodname) /* backward compatibility */
320 devprodname = customname;
322 textbuf1 = psdAllocVec(3*1024);
323 textbuf2 = &textbuf1[1*1024];
324 textbuf3 = &textbuf1[2*1024];
325 if(!textbuf1)
327 return(FALSE);
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"),
332 devserial,
333 devpowersupply, devpowerdrain);
334 if(devisconfigured)
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";
349 } else {
350 devstate = "Dead";
353 if( (devclass == HUB_CLASSCODE) && (devhubport == (IPTR)NULL)) {
355 STRPTR cmpdevicename = "";
356 STRPTR devicename = "";
357 IPTR deviceunit = 0;
359 if(phw != NULL) {
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"))),
368 #else
369 (devislowspeed ? "Lowspeed" : (devishighspeed ? "Highspeed" : "Fullspeed")),
370 #endif
371 devadr,
372 devicename, deviceunit,
373 devclass,
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);
378 } else {
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"))),
383 #else
384 (devislowspeed ? "Lowspeed" : (devishighspeed ? "Highspeed" : "Fullspeed")),
385 #endif
386 devadr,
387 devhubport, devhubname,
388 devclass,
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);
395 pc = cfgs->lh_Head;
396 textbuf3[0] = 0;
397 while(pc->ln_Succ)
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,
407 TAG_END);
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",
411 cfgnum, cfgname,
412 cfgselfpow ? "self-powered " : "bus-powered ",
413 cfgremwake ? "remote-wakeup" : "",
414 cfgmaxpower, cfgnumifs,
415 (cfgnumifs != 1) ? "s" : "");
416 pc = pc->ln_Succ;
419 data->classpopup = CreateClassPopup();
420 data->contents = VGroup,
421 Child, HGroup,
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:"),
428 Child, TextObject,
429 TextFrame,
430 MUIA_Background, MUII_TextBack,
431 MUIA_Text_Contents, textbuf1,
432 End,
433 //Child, HSpace(0),
434 Child, LabelB("State:\nSpeed:\nAddress:\nConnected:\nDevClass:\nSubclass:\nProtocol:\nUSB vers:"),
435 Child, TextObject,
436 TextFrame,
437 MUIA_Background, MUII_TextBack,
438 MUIA_Text_Contents, textbuf2,
439 End,
440 End,
441 Child, HGroup,
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"
446 "a sensible name.",
447 StringFrame,
448 //MUIA_HorizWeight, 10,
449 MUIA_CycleChain, 1,
450 MUIA_String_Contents, customname,
451 MUIA_String_AdvanceOnCR, TRUE,
452 End,
453 Child, HGroup,
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.",
458 ButtonFrame,
459 MUIA_Background, MUII_ButtonBack,
460 MUIA_CycleChain, 1,
461 MUIA_InputMode, MUIV_InputMode_RelVerify,
462 MUIA_Text_Contents, "\33c Change Name ",
463 End,
464 Child, data->resetnameobj = TextObject,
465 MUIA_ShortHelp, "Removes the custom name and restores\n"
466 "the original one that Poseidon generated.",
467 ButtonFrame,
468 MUIA_Background, MUII_ButtonBack,
469 MUIA_CycleChain, 1,
470 MUIA_InputMode, MUIV_InputMode_RelVerify,
471 MUIA_Text_Contents, "\33c Restore Name ",
472 End,
473 End,
474 End,
475 Child, HGroup,
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,
481 MUIA_CycleChain, 1,
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,
487 End,
488 Child, HSpace(0),
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,
494 MUIA_CycleChain, 1,
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,
500 End,
501 Child, HSpace(0),
502 Child, Label("Power info:"),
503 Child, data->overridepowerobj = CycleObject,
504 MUIA_CycleChain, 1,
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,
513 End,
514 End,
515 Child, HGroup,
516 Child, VGroup,
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,
524 ReadListFrame,
525 End,
526 End,
527 Child, HGroup,
528 Child, LabelB("Current language:"),
529 Child, TextObject,
530 TextFrame,
531 MUIA_Background, MUII_TextBack,
532 MUIA_Text_Contents, psdNumToStr(NTS_LANGID, devcurrlang, "<unknown>"),
533 End,
534 End,
535 End,
536 Child, HGroup,
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,
542 ReadListFrame,
543 MUIA_Floattext_Text, textbuf3,
544 End,
545 End,
546 End,
547 Child, HGroup,
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),
557 End,
558 End,
559 Child, HGroup,
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.",
566 ButtonFrame,
567 MUIA_Background, MUII_ButtonBack,
568 MUIA_CycleChain, 1,
569 MUIA_InputMode, MUIV_InputMode_RelVerify,
570 MUIA_Text_Contents, "\33c Class Scan ",
571 End,
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.",
576 MUIA_Disabled, TRUE,
577 ButtonFrame,
578 MUIA_Background, MUII_ButtonBack,
579 MUIA_CycleChain, 1,
580 MUIA_InputMode, MUIV_InputMode_RelVerify,
581 MUIA_Text_Contents, "\33c Release Binding ",
582 End,
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"
589 "list window.",
590 MUIA_Disabled, TRUE,
591 ButtonFrame,
592 MUIA_Background, MUII_ButtonBack,
593 MUIA_CycleChain, 1,
594 MUIA_InputMode, MUIV_InputMode_RelVerify,
595 MUIA_Text_Contents, "\33c Settings ",
596 End,
597 End,
598 End;
599 psdFreeVec(textbuf1);
600 if(data->contents)
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'));
608 if(devlangarray)
610 UWORD *wptr = devlangarray;
611 while(*wptr)
613 DoMethod(data->langlvobj, MUIM_List_InsertSingle,
614 psdNumToStr(NTS_LANGID, (ULONG) *wptr++, "<unknown>"), MUIV_List_Insert_Bottom);
616 } else {
617 DoMethod(data->langlvobj, MUIM_List_InsertSingle, "<none>", MUIV_List_Insert_Bottom);
619 pc = cfgs->lh_Head;
620 while(pc->ln_Succ)
622 psdGetAttrs(PGA_CONFIG, pc,
623 CA_InterfaceList, &ifs,
624 TAG_END);
626 pif = ifs->lh_Head;
627 while(pif->ln_Succ)
629 iflnode = AllocIfEntry(data, pif, FALSE);
630 if(iflnode)
632 DoMethod(data->iflvobj, MUIM_List_InsertSingle, iflnode, MUIV_List_Insert_Bottom);
634 psdGetAttrs(PGA_INTERFACE, pif,
635 IFA_AlternateIfList, &altiflist,
636 TAG_END);
637 altpif = altiflist->lh_Head;
638 while(altpif->ln_Succ)
640 iflnode = AllocIfEntry(data, altpif, TRUE);
641 if(iflnode)
643 DoMethod(data->iflvobj, MUIM_List_InsertSingle, iflnode, MUIV_List_Insert_Bottom);
646 altpif = altpif->ln_Succ;
648 pif = pif->ln_Succ;
650 pc = pc->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);
677 } else {
678 CoerceMethod(cl, obj, OM_DISPOSE);
679 return((IPTR) NULL);
682 return((IPTR) obj);
685 case OM_DISPOSE:
687 struct IfListEntry *iflnode;
688 if(data->dlnode)
690 if(data->dlnode->infowindow)
692 data->dlnode->infowindow = NULL;
694 data->dlnode->devdata = NULL;
696 if(data->classpopup)
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;
707 data->dlnode = NULL;
708 break;
711 case MUIM_DevWin_Dev_Bind:
712 psdClassScan();
713 DoMethod(obj, MUIM_DevWin_If_Activate);
714 DoMethod(data->iflvobj, MUIM_List_Redraw, MUIV_List_Redraw_All);
715 return(TRUE);
717 case MUIM_DevWin_If_Activate:
719 APTR binding;
720 struct Node *puc;
721 IPTR hascfggui = FALSE;
722 struct Library *UsbClsBase;
723 struct IfListEntry *iflnode;
725 DoMethod(data->iflvobj, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &iflnode);
726 if(iflnode)
728 psdGetAttrs(PGA_INTERFACE, iflnode->pif,
729 IFA_Binding, &binding,
730 IFA_BindingClass, &puc,
731 TAG_END);
732 set(data->unbindobj, MUIA_Disabled, !binding);
733 if(binding && puc)
735 psdGetAttrs(PGA_USBCLASS, puc,
736 UCA_ClassBase, &UsbClsBase,
737 TAG_END);
738 usbGetAttrs(UGA_CLASS, NULL,
739 UCCA_HasBindingCfgGUI, &hascfggui,
740 TAG_END);
741 set(data->cfgobj, MUIA_Disabled, !hascfggui);
742 } else {
743 set(data->cfgobj, MUIA_Disabled, TRUE);
745 set(data->iflvobj, MUIA_ContextMenu, data->classpopup);
746 } else {
747 set(data->unbindobj, MUIA_Disabled, TRUE);
748 set(data->cfgobj, MUIA_Disabled, TRUE);
749 set(data->iflvobj, MUIA_ContextMenu, NULL);
751 return(TRUE);
754 case MUIM_DevWin_If_Unbind:
756 APTR binding;
757 struct IfListEntry *iflnode;
759 DoMethod(data->iflvobj, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &iflnode);
760 if(iflnode)
762 psdGetAttrs(PGA_INTERFACE, iflnode->pif,
763 IFA_Binding, &binding,
764 TAG_END);
765 if(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);
773 return(TRUE);
776 case MUIM_DevWin_If_Config:
778 APTR binding;
779 struct Node *puc;
780 struct Library *UsbClsBase;
781 struct IfListEntry *iflnode;
783 DoMethod(data->iflvobj, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &iflnode);
784 if(iflnode)
786 psdGetAttrs(PGA_INTERFACE, iflnode->pif,
787 IFA_Binding, &binding,
788 IFA_BindingClass, &puc,
789 TAG_END);
790 if(binding && puc)
792 psdGetAttrs(PGA_USBCLASS, puc,
793 UCA_ClassBase, &UsbClsBase,
794 TAG_END);
795 usbDoMethod(UCM_OpenBindingCfgWindow, binding);
798 return(TRUE);
801 case MUIM_DevWin_If_FBind:
803 Object *mi = (Object *) (((IPTR *) msg)[1]);
804 STRPTR name = NULL;
805 STRPTR devid = NULL;
806 STRPTR ifid = NULL;
807 STRPTR devname = NULL;
808 BOOL clever;
809 struct IfListEntry *iflnode;
811 DoMethod(data->iflvobj, MUIM_List_GetEntry, MUIV_List_GetEntry_Active, &iflnode);
812 if(iflnode)
814 get(mi, MUIA_Menuitem_Title, &name);
815 if(!strcmp(name, "None"))
817 name = NULL;
819 psdGetAttrs(PGA_DEVICE, data->pd,
820 DA_ProductName, &devname,
821 DA_IDString, &devid,
822 TAG_END);
823 psdGetAttrs(PGA_INTERFACE, iflnode->pif,
824 IFA_IDString, &ifid,
825 TAG_END);
826 if(name)
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);
835 if(!clever)
837 return(FALSE);
840 if(psdSetForcedBinding(name, devid, ifid))
842 if(name)
844 psdAddErrorMsg(RETURN_OK, "Trident", "Forcing interface binding of %s to %s.", devname, name);
845 } else {
846 psdAddErrorMsg(RETURN_OK, "Trident", "Removed forced interface binding of %s.", devname);
851 return(TRUE);
854 case MUIM_DevWin_SetCustomName:
856 APTR pic;
857 STRPTR devidstr = NULL;
858 STRPTR oldname = NULL;
859 CONST_STRPTR newname = "";
860 STRPTR newnewname;
861 psdGetAttrs(PGA_DEVICE, data->pd,
862 DA_IDString, &devidstr,
863 DA_ProductName, &oldname,
864 TAG_END);
865 if(!devidstr)
867 return(FALSE);
869 get(data->cwnameobj, MUIA_String_Contents, &newname);
870 if(!(*newname))
872 newname = "Empty";
874 if(oldname && !strcmp(newname, oldname))
876 return(FALSE);
878 pic = psdGetUsbDevCfg("Trident", devidstr, NULL);
879 if(!pic)
881 psdSetUsbDevCfg("Trident", devidstr, NULL, NULL);
882 pic = psdGetUsbDevCfg("Trident", devidstr, NULL);
884 if(pic)
886 if(psdAddStringChunk(pic, IFFCHNK_NAME, newname))
888 psdAddErrorMsg(RETURN_OK, "Trident", "Set new custom name '%s'.", newname);
889 newnewname = psdCopyStr(newname);
890 if(newnewname)
892 psdSetAttrs(PGA_DEVICE, data->pd,
893 DA_ProductName, newnewname,
894 TAG_END);
895 if (oldname)
896 psdFreeVec(oldname);
900 set(data->cwnameobj, MUIA_String_Contents, newname);
901 DoMethod(data->dlnode->adata->devlistobj, MUIM_List_Redraw, MUIV_List_Redraw_All);
902 return(TRUE);
905 case MUIM_DevWin_ResetCustomName:
907 APTR pic;
908 STRPTR devidstr = NULL;
909 STRPTR oldname = NULL;
910 STRPTR origname = NULL;
911 STRPTR newname;
912 psdGetAttrs(PGA_DEVICE, data->pd,
913 DA_IDString, &devidstr,
914 DA_ProductName, &oldname,
915 DA_OrigProductName, &origname,
916 TAG_END);
917 if(!devidstr)
919 return(FALSE);
921 pic = psdGetUsbDevCfg("Trident", devidstr, NULL);
922 if(pic)
924 if(psdRemCfgChunk(pic, IFFCHNK_NAME))
926 psdAddErrorMsg(RETURN_OK, "Trident", "Custom name '%s' removed.", oldname);
927 if(origname)
929 newname = psdCopyStr(origname);
930 if(newname)
932 psdSetAttrs(PGA_DEVICE, data->pd,
933 DA_ProductName, newname,
934 TAG_END);
935 psdFreeVec(oldname);
940 psdGetAttrs(PGA_DEVICE, data->pd,
941 DA_ProductName, &oldname,
942 TAG_END);
943 set(data->cwnameobj, MUIA_String_Contents, oldname);
944 DoMethod(data->dlnode->adata->devlistobj, MUIM_List_Redraw, MUIV_List_Redraw_All);
945 return(TRUE);
948 case MUIM_DevWin_PopupInhibitChg:
949 case MUIM_DevWin_NoClassBindChg:
950 case MUIM_DevWin_PowerInfoChg:
952 IPTR dontpopup = 0;
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,
963 TAG_END);
964 return(TRUE);
968 return(DoSuperMethodA(cl,obj,msg));
969 AROS_USERFUNC_EXIT
971 /* \\\ */