6 #include "poseidon.library.h"
8 #include <libraries/mui.h>
9 #include <intuition/intuition.h>
10 #include <intuition/intuitionbase.h>
11 #include <libraries/gadtools.h>
12 #include <datatypes/soundclass.h>
15 #include <proto/alib.h>
16 #include <proto/muimaster.h>
17 #include <proto/exec.h>
18 #include <proto/dos.h>
19 #include <proto/datatypes.h>
20 #include <proto/intuition.h>
21 #include <proto/utility.h>
22 #include <proto/usbclass.h>
26 #define NewList NEWLIST
32 #define MUIMasterBase po->po_MUIBase
33 #define DataTypesBase po->po_DTBase
34 #define IntuitionBase po->po_IntBase
36 extern struct ExecBase
*SysBase
;
38 /* /// "pPoPoGUITask()" */
39 AROS_UFH0(void, pPoPoGUITask
)
42 struct Task
*thistask
;
46 struct PubScreenNode
*pubscr
;
47 BOOL hasworkbench
= FALSE
;
49 thistask
= FindTask(NULL
);
51 ps
= thistask
->tc_UserData
;
52 SetTaskPri(thistask
, 0);
55 NewList(&po
->po_GadgetList
);
56 NewList(&po
->po_Sounds
);
58 if(!(IntuitionBase
= OpenLibrary("intuition.library", 39)))
60 KPRINTF(10, ("Couldn't open intuition.library.\n"));
61 pPoPoGUITaskCleanup(ps
);
65 scrlist
= LockPubScreenList();
66 pubscr
= (struct PubScreenNode
*) scrlist
->lh_Head
;
67 while(pubscr
->psn_Node
.ln_Succ
)
69 if(strcmp(pubscr
->psn_Node
.ln_Name
, "Workbench") == 0)
71 if(pubscr
->psn_Screen
)
77 pubscr
= (struct PubScreenNode
*) pubscr
->psn_Node
.ln_Succ
;
79 UnlockPubScreenList();
83 KPRINTF(10, ("No screen open yet.\n"));
84 pPoPoGUITaskCleanup(ps
);
88 if(!(MUIMasterBase
= OpenLibrary(MUIMASTER_NAME
, MUIMASTER_VMIN
)))
90 KPRINTF(10, ("Couldn't open muimaster.library.\n"));
91 pPoPoGUITaskCleanup(ps
);
95 if(!(DataTypesBase
= OpenLibrary("datatypes.library", 39)))
97 KPRINTF(10, ("Couldn't open datatypes.library.\n"));
98 pPoPoGUITaskCleanup(ps
);
102 if(!(po
->po_MsgPort
= CreateMsgPort()))
104 KPRINTF(10, ("Couldn't create MsgPort.\n"));
105 pPoPoGUITaskCleanup(ps
);
109 po
->po_EventHandler
= psdAddEventHandler(po
->po_MsgPort
, EHMF_ADDDEVICE
|EHMF_REMDEVICE
|EHMF_ADDBINDING
|EHMF_CONFIGCHG
|EHMF_DEVICEDEAD
|EHMF_DEVICELOWPW
);
110 if(!po
->po_EventHandler
)
112 KPRINTF(10, ("Couldn't add EventHandler.\n"));
113 pPoPoGUITaskCleanup(ps
);
117 if(!(po
->po_TimerMsgPort
= CreateMsgPort()))
119 KPRINTF(10, ("Couldn't create MsgPort.\n"));
120 pPoPoGUITaskCleanup(ps
);
124 if(!(po
->po_TimerIOReq
= (struct timerequest
*) CreateIORequest(po
->po_TimerMsgPort
, sizeof(struct timerequest
))))
126 KPRINTF(10, ("Couldn't create TimerIOReq.\n"));
127 pPoPoGUITaskCleanup(ps
);
131 if(OpenDevice("timer.device", UNIT_VBLANK
, (struct IORequest
*) po
->po_TimerIOReq
, 0))
133 KPRINTF(10, ("Couldn't open timer.device.\n"));
134 pPoPoGUITaskCleanup(ps
);
137 po
->po_TimerIOReq
->tr_node
.io_Message
.mn_Node
.ln_Type
= NT_REPLYMSG
;
138 po
->po_TimerIOReq
->tr_node
.io_Message
.mn_Node
.ln_Name
= "PoPo";
139 po
->po_TimerIOReq
->tr_node
.io_Command
= TR_ADDREQUEST
;
141 if(!(po
->po_PoPoClass
= MUI_CreateCustomClass(NULL
, MUIC_Area
, NULL
, sizeof(struct PoPoData
), PoPoDispatcher
)))
143 KPRINTF(10, ("Couldn't create PoPo Class\n"));
144 pPoPoGUITaskCleanup(ps
);
147 po
->po_PoPoClass
->mcc_Class
->cl_UserData
= (IPTR
) ps
;
149 po
->po_AppObj
= ApplicationObject
,
150 MUIA_Application_Title
, (IPTR
)"PoPo -- Poseidon Popup Provider",
151 MUIA_Application_Version
, (IPTR
)VERSION_STRING
,
152 MUIA_Application_Copyright
, (IPTR
)"©2004-2009 Chris Hodges",
153 MUIA_Application_Author
, (IPTR
)"Chris Hodges <chrisly@platon42.de>",
154 MUIA_Application_Description
, (IPTR
)"Opens annoying windows",
155 MUIA_Application_Base
, (IPTR
)"POPO",
156 MUIA_Application_HelpFile
, (IPTR
)"HELP:Poseidon.guide",
157 MUIA_Application_Menustrip
, (IPTR
)MenustripObject
,
158 Child
, (IPTR
)MenuObjectT((IPTR
)"Project"),
159 Child
, (IPTR
)(po
->po_AboutMI
= MenuitemObject
,
160 MUIA_Menuitem_Title
, (IPTR
)"About...",
161 MUIA_Menuitem_Shortcut
, (IPTR
)"?",
163 Child
, (IPTR
)MenuitemObject
,
164 MUIA_Menuitem_Title
, (IPTR
)NM_BARLABEL
,
166 Child
, (IPTR
)(po
->po_CloseMI
= MenuitemObject
,
167 MUIA_Menuitem_Title
, (IPTR
)"Close",
168 MUIA_Menuitem_Shortcut
, (IPTR
)"Q",
171 Child
, (IPTR
)MenuObjectT((IPTR
)"Settings"),
172 Child
, (IPTR
)(po
->po_TridentMI
= MenuitemObject
,
173 MUIA_Menuitem_Title
, (IPTR
)"Open Trident",
174 MUIA_Menuitem_Shortcut
, (IPTR
)"O",
176 Child
, (IPTR
)MenuitemObject
,
177 MUIA_Menuitem_Title
, (IPTR
)NM_BARLABEL
,
179 Child
, (IPTR
)(po
->po_MUIPrefsMI
= MenuitemObject
,
180 MUIA_Menuitem_Title
, (IPTR
)"MUI Settings",
181 MUIA_Menuitem_Shortcut
, (IPTR
)"M",
186 SubWindow
, (IPTR
)(po
->po_WindowObj
= WindowObject
,
187 MUIA_Window_ID
, MAKE_ID('P','O','P','O'),
188 MUIA_Window_Title
, (IPTR
)"Poseidon Popups",
189 MUIA_HelpNode
, (IPTR
)"main",
191 WindowContents
, (IPTR
)VGroup
,
192 Child
, (IPTR
)(po
->po_PoPoObj
= NewObject(po
->po_PoPoClass
->mcc_Class
, 0, MUIA_ShowMe
, FALSE
, TAG_END
)),
193 Child
, (IPTR
)(po
->po_GroupObj
= VGroup
,
195 Child
, (IPTR
)HSpace(0),
196 Child
, (IPTR
)Label("Messages"),
197 Child
, (IPTR
)HSpace(0),
201 Child
, (IPTR
)(po
->po_StickyObj
= ImageObject
, ImageButtonFrame
,
202 MUIA_Background
, MUII_ButtonBack
,
204 MUIA_InputMode
, MUIV_InputMode_Toggle
,
205 MUIA_Image_Spec
, MUII_CheckMark
,
206 MUIA_Image_FreeVert
, TRUE
,
207 MUIA_Selected
, FALSE
,
208 MUIA_ShowSelState
, FALSE
,
210 Child
, (IPTR
)Label("Hold on"),
212 MUIA_Group_SameWidth
, TRUE
,
213 Child
, (IPTR
)(po
->po_SaveObj
= TextObject
, ButtonFrame
,
214 MUIA_Disabled
, (ps
->ps_SavedConfigHash
== ps
->ps_ConfigHash
),
215 MUIA_Background
, MUII_ButtonBack
,
217 MUIA_InputMode
, MUIV_InputMode_RelVerify
,
218 MUIA_Text_Contents
, (IPTR
)"\33c Save Prefs ",
220 Child
, (IPTR
)(po
->po_CloseObj
= TextObject
, ButtonFrame
,
221 MUIA_Background
, MUII_ButtonBack
,
223 MUIA_InputMode
, MUIV_InputMode_RelVerify
,
224 MUIA_Text_Contents
, (IPTR
)"\33c Close ",
234 KPRINTF(10, ("Couldn't create application\n"));
235 pPoPoGUITaskCleanup(ps
);
239 DoMethod(po
->po_WindowObj
, MUIM_Notify
, MUIA_Window_CloseRequest
, TRUE
,
240 po
->po_AppObj
, 2, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
241 DoMethod(po
->po_SaveObj
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
242 po
->po_PoPoObj
, 1, MUIM_PoPo_SavePrefs
);
243 DoMethod(po
->po_CloseObj
, MUIM_Notify
, MUIA_Pressed
, FALSE
,
244 po
->po_AppObj
, 2, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
245 DoMethod(po
->po_StickyObj
, MUIM_Notify
, MUIA_Selected
, MUIV_EveryTime
,
246 po
->po_PoPoObj
, 1, MUIM_PoPo_Sticky
);
248 DoMethod(po
->po_AboutMI
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
249 po
->po_PoPoObj
, 1, MUIM_PoPo_About
);
250 DoMethod(po
->po_CloseMI
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
251 po
->po_AppObj
, 2, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
252 DoMethod(po
->po_TridentMI
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
253 po
->po_PoPoObj
, 1, MUIM_PoPo_OpenTrident
);
254 DoMethod(po
->po_MUIPrefsMI
, MUIM_Notify
, MUIA_Menuitem_Trigger
, MUIV_EveryTime
,
255 po
->po_AppObj
, 2, MUIM_Application_OpenConfigWindow
, 0);
263 struct PsdPoPoGadgets
*pog
;
264 struct timeval currtime
;
266 po
->po_Task
= thistask
;
268 if(po
->po_ReadySigTask
)
270 Signal(po
->po_ReadySigTask
, 1L<<po
->po_ReadySignal
);
274 //set(po->po_WindowObj, MUIA_Window_Open, TRUE);
275 po
->po_TimerIOReq
->tr_time
.tv_micro
= 500*1000;
276 SendIO(&po
->po_TimerIOReq
->tr_node
);
277 sigmask
= (1UL<<po
->po_MsgPort
->mp_SigBit
)|(1UL<<po
->po_TimerMsgPort
->mp_SigBit
);
280 retid
= DoMethod(po
->po_AppObj
, MUIM_Application_NewInput
, &sigs
);
284 if(CheckIO(&po
->po_TimerIOReq
->tr_node
))
286 WaitIO(&po
->po_TimerIOReq
->tr_node
);
287 po
->po_TimerIOReq
->tr_time
.tv_micro
= 500*1000;
288 SendIO(&po
->po_TimerIOReq
->tr_node
);
290 CurrentTime(&currtime
.tv_secs
, &currtime
.tv_micro
);
291 pog
= (struct PsdPoPoGadgets
*) po
->po_GadgetList
.lh_Head
;
292 while(pog
->pog_Node
.ln_Succ
)
294 if((currtime
.tv_secs
> pog
->pog_TimeoutTime
.tv_secs
) ||
295 ((currtime
.tv_secs
== pog
->pog_TimeoutTime
.tv_secs
) &&
296 (currtime
.tv_micro
> pog
->pog_TimeoutTime
.tv_micro
)))
298 pFreePoPoGadgets(ps
, pog
);
299 pog
= (struct PsdPoPoGadgets
*) po
->po_GadgetList
.lh_Head
;
301 pog
= (struct PsdPoPoGadgets
*) pog
->pog_Node
.ln_Succ
;
305 if(po
->po_GadgetList
.lh_Head
->ln_Succ
)
307 if(po
->po_OpenRequest
)
311 if(ps
->ps_GlobalCfg
->pgc_PopupActivateWin
)
313 set(po
->po_WindowObj
, MUIA_Window_Activate
, TRUE
);
315 set(po
->po_WindowObj
, MUIA_Window_Activate
, FALSE
);
317 set(po
->po_StickyObj
, MUIA_Selected
, FALSE
);
318 set(po
->po_WindowObj
, MUIA_Window_Open
, TRUE
);
321 if(ps
->ps_GlobalCfg
->pgc_PopupWinToFront
)
323 DoMethod(po
->po_WindowObj
, MUIM_Window_ToFront
);
326 po
->po_OpenRequest
= FALSE
;
331 set(po
->po_WindowObj
, MUIA_Window_Open
, FALSE
);
336 sigs
= Wait(sigs
| sigmask
| SIGBREAKF_CTRL_C
);
337 if(sigs
& SIGBREAKF_CTRL_C
)
342 if(retid
== MUIV_Application_ReturnID_Quit
)
344 set(po
->po_WindowObj
, MUIA_Window_Open
, FALSE
);
345 /* remove all thingies */
346 pog
= (struct PsdPoPoGadgets
*) po
->po_GadgetList
.lh_Head
;
347 while(pog
->pog_Node
.ln_Succ
)
349 pFreePoPoGadgets(ps
, pog
);
350 pog
= (struct PsdPoPoGadgets
*) po
->po_GadgetList
.lh_Head
;
353 if((ps
->ps_GlobalCfg
->pgc_PopupDeviceNew
== PGCP_NEVER
) &&
354 (!ps
->ps_GlobalCfg
->pgc_PopupDeviceDeath
) &&
355 (!ps
->ps_GlobalCfg
->pgc_PopupDeviceGone
))
357 psdAddErrorMsg0(RETURN_OK
, (STRPTR
) "PoPo", "PoPo has been abandoned (is it you, stuntzi?).");
362 set(po
->po_WindowObj
, MUIA_Window_Open
, FALSE
);
364 pPoPoGUITaskCleanup(ps
);
369 /* /// "pPoPoGUITaskCleanup()" */
370 void pPoPoGUITaskCleanup(LIBBASETYPEPTR ps
)
372 struct PsdPoPo
*po
= &ps
->ps_PoPo
;
373 struct PsdPoPoGadgets
*pog
;
374 struct PsdPoPoSound
*pps
;
376 pog
= (struct PsdPoPoGadgets
*) po
->po_GadgetList
.lh_Head
;
377 while(pog
->pog_Node
.ln_Succ
)
379 pFreePoPoGadgets(ps
, pog
);
380 pog
= (struct PsdPoPoGadgets
*) po
->po_GadgetList
.lh_Head
;
383 pps
= (struct PsdPoPoSound
*) po
->po_Sounds
.lh_Head
;
384 while(pps
->pps_Node
.ln_Succ
)
386 pPoPoFreeSound(ps
, pps
);
387 pps
= (struct PsdPoPoSound
*) po
->po_Sounds
.lh_Head
;
390 if(po
->po_TimerIOReq
)
392 if(po
->po_TimerIOReq
->tr_node
.io_Device
)
394 AbortIO(&po
->po_TimerIOReq
->tr_node
);
395 WaitIO(&po
->po_TimerIOReq
->tr_node
);
396 CloseDevice((struct IORequest
*) po
->po_TimerIOReq
);
398 DeleteIORequest((struct IORequest
*) po
->po_TimerIOReq
);
399 po
->po_TimerIOReq
= NULL
;
401 if(po
->po_TimerMsgPort
)
403 DeleteMsgPort(po
->po_TimerMsgPort
);
404 po
->po_TimerMsgPort
= NULL
;
407 if(po
->po_EventHandler
)
409 psdRemEventHandler(po
->po_EventHandler
);
410 po
->po_EventHandler
= NULL
;
414 DeleteMsgPort(po
->po_MsgPort
);
415 po
->po_MsgPort
= NULL
;
419 MUI_DisposeObject(po
->po_AppObj
);
420 po
->po_AppObj
= NULL
;
424 MUI_DeleteCustomClass(po
->po_PoPoClass
);
425 po
->po_PoPoClass
= NULL
;
429 CloseLibrary(DataTypesBase
);
430 DataTypesBase
= NULL
;
434 CloseLibrary(MUIMasterBase
);
435 MUIMasterBase
= NULL
;
439 CloseLibrary(IntuitionBase
);
440 IntuitionBase
= NULL
;
444 if(po
->po_ReadySigTask
)
446 Signal(po
->po_ReadySigTask
, 1L<<po
->po_ReadySignal
);
451 /* /// "pPoPoLoadSound()" */
452 struct PsdPoPoSound
* pPoPoLoadSound(LIBBASETYPEPTR ps
, STRPTR name
)
454 struct PsdPoPo
*po
= &ps
->ps_PoPo
;
455 struct PsdPoPoSound
*pps
;
456 if((pps
= psdAllocVec(sizeof(struct PsdPoPoSound
))))
458 if((pps
->pps_Node
.ln_Name
= psdCopyStr(name
)))
460 AddTail(&po
->po_Sounds
, &pps
->pps_Node
);
461 pps
->pps_DTHandle
= NewDTObject(name
,
462 DTA_SourceType
, DTST_FILE
,
463 DTA_GroupID
, GID_SOUND
,
466 if(!pps
->pps_DTHandle
)
468 psdAddErrorMsg(RETURN_ERROR
, "PoPo", "Could not load soundfile '%s'.", name
);
478 /* /// "pPoPoPlaySound()" */
479 BOOL
pPoPoPlaySound(LIBBASETYPEPTR ps
, STRPTR name
)
481 struct PsdPoPo
*po
= &ps
->ps_PoPo
;
482 struct PsdPoPoSound
*pps
;
483 struct dtTrigger playmsg
;
485 pps
= (struct PsdPoPoSound
*) FindName(&po
->po_Sounds
, name
);
488 pps
= pPoPoLoadSound(ps
, name
);
494 if(!pps
->pps_DTHandle
)
499 SetAttrs(pps
->pps_DTHandle
,
502 playmsg
.MethodID
= DTM_TRIGGER
;
503 playmsg
.dtt_GInfo
= NULL
;
504 playmsg
.dtt_Function
= STM_PLAY
;
505 playmsg
.dtt_Data
= NULL
;
506 DoMethodA(pps
->pps_DTHandle
, (Msg
) &playmsg
);
511 /* /// "pPoPoFreeSound()" */
512 void pPoPoFreeSound(LIBBASETYPEPTR ps
, struct PsdPoPoSound
*pps
)
514 struct PsdPoPo
*po
= &ps
->ps_PoPo
;
515 Remove(&pps
->pps_Node
);
516 if(pps
->pps_DTHandle
)
518 DisposeDTObject(pps
->pps_DTHandle
);
520 psdFreeVec(pps
->pps_Node
.ln_Name
);
525 /* /// "pIsDeviceStillValid()" */
526 BOOL
pIsDeviceStillValid(LIBBASETYPEPTR ps
, struct PsdDevice
*pd
)
528 struct PsdDevice
*tmppd
= NULL
;
529 while((tmppd
= psdGetNextDevice(tmppd
)))
540 /* /// "pIsClassStillValid()" */
541 BOOL
pIsClassStillValid(LIBBASETYPEPTR ps
, struct Library
*ucb
)
543 struct PsdUsbClass
*puc
= (struct PsdUsbClass
*) ps
->ps_Classes
.lh_Head
;
544 while(puc
->puc_Node
.ln_Succ
)
546 if(puc
->puc_ClassBase
== ucb
)
550 puc
= (struct PsdUsbClass
*) puc
->puc_Node
.ln_Succ
;
556 /* /// "pRemoveOldBox()" */
557 void pRemoveOldBox(LIBBASETYPEPTR ps
, struct PsdDevice
*pd
)
559 struct PsdPoPo
*po
= &ps
->ps_PoPo
;
560 struct PsdPoPoGadgets
*pog
;
561 // try to remove adding message, if it still existing
562 pog
= (struct PsdPoPoGadgets
*) po
->po_GadgetList
.lh_Head
;
563 while(pog
->pog_Node
.ln_Succ
)
565 if(pog
->pog_Device
== pd
)
567 pFreePoPoGadgets(ps
, pog
);
568 pog
= (struct PsdPoPoGadgets
*) po
->po_GadgetList
.lh_Head
;
570 pog
= (struct PsdPoPoGadgets
*) pog
->pog_Node
.ln_Succ
;
576 /* /// "pGenerateAddBox()" */
577 struct PsdPoPoGadgets
* pGenerateAddBox(LIBBASETYPEPTR ps
, struct PsdDevice
*pd
, struct PsdPoPoGadgets
*pog
)
579 struct PsdPoPo
*po
= &ps
->ps_PoPo
;
584 STRPTR wholebodyinfo
;
585 STRPTR gad
[4] = { NULL
, NULL
, NULL
, NULL
};
589 BOOL lowpower
= FALSE
;
591 BOOL updatetime
= FALSE
;
592 STRPTR oldbody
= NULL
;
594 ULONG methods
[4] = { MUIM_PoPo_ConfigureBinding
, MUIM_PoPo_ConfigureClass
, MUIM_PoPo_ShutUp
, MUIM_PoPo_RemInfo
};
596 bindingsstr
= pBindingsString(ps
, pd
);
597 configstate
= pCheckConfigurable(ps
, pd
);
599 lowpower
= pd
->pd_Flags
& PDFF_LOWPOWER
;
600 isdead
= pd
->pd_Flags
& PDFF_DEAD
;
602 body
= "A new USB device was detected:\n\n\33b%s\33n\n\n";
605 lpwarn
= "\n\n\33bWARNING: Detected low power situation!";
611 deadwarn
= "\n\n\33bWARNING: Device seems to be dead!";
618 bindinginfo
= psdCopyStrFmt("It is bound to \33b%s\33n", bindingsstr
);
620 bindinginfo
= psdCopyStr("No class seems responsible (yet)!");
624 psdFreeVec(bindingsstr
);
627 if(!(bodyinfo
= psdCopyStrFmt(body
, pd
->pd_ProductStr
)))
629 psdFreeVec(bindingsstr
);
630 psdFreeVec(bindinginfo
);
633 if(!(wholebodyinfo
= psdCopyStrFmt("%s%s%s%s", bodyinfo
, bindinginfo
, lpwarn
, deadwarn
)))
635 psdFreeVec(bindingsstr
);
636 psdFreeVec(bindinginfo
);
637 psdFreeVec(bodyinfo
);
640 if(configstate
& PPF_HasBindingGUI
)
642 gad
[0] = "Set Device Prefs";
644 if(configstate
& PPF_HasBindConfig
)
646 gad
[0] = "Change Device Prefs";
648 if(configstate
& PPF_HasClassGUI
)
650 gad
[1] = "Set Class Prefs";
652 if(configstate
& PPF_HasClsConfig
)
654 gad
[1] = "Change Class Prefs";
656 if(isdead
|| lowpower
)
658 gad
[0] = "Disable Port";
659 methods
[0] = MUIM_PoPo_DisablePort
;
662 if(isdead
&& (!lowpower
))
664 gad
[1] = "Powercycle Port";
665 methods
[1] = MUIM_PoPo_PowerCyclePort
;
667 gad
[2] = "No PopUps!";
671 pog
= pAllocPoPoGadgets(ps
, wholebodyinfo
, gad
);
674 pog
->pog_Device
= pd
;
677 get(pog
->pog_BodyObj
, MUIA_Text_Contents
, &oldbody
);
678 if(strcmp(oldbody
, wholebodyinfo
))
680 set(pog
->pog_BodyObj
, MUIA_Text_Contents
, wholebodyinfo
);
683 for(cnt
= 0; cnt
< 4; cnt
++)
687 set(pog
->pog_GadgetObj
[cnt
], MUIA_Text_Contents
, gad
[cnt
]);
688 set(pog
->pog_GadgetObj
[cnt
], MUIA_ShowMe
, TRUE
);
690 set(pog
->pog_GadgetObj
[cnt
], MUIA_ShowMe
, FALSE
);
696 for(cnt
= 0; cnt
< 4; cnt
++)
698 DoMethod(pog
->pog_GadgetObj
[cnt
], MUIM_KillNotify
, MUIA_Pressed
);
701 DoMethod(pog
->pog_GadgetObj
[cnt
], MUIM_Notify
, MUIA_Pressed
,
702 FALSE
, po
->po_AppObj
, 5, MUIM_Application_PushMethod
,
703 po
->po_PoPoObj
, 2, methods
[cnt
], pog
);
708 psdFreeVec(bindingsstr
);
709 psdFreeVec(bindinginfo
);
710 psdFreeVec(bodyinfo
);
711 psdFreeVec(wholebodyinfo
);
713 /* Everything after this depends on having gadgets */
718 if(updatetime
&& pog
)
720 CurrentTime(&pog
->pog_TimeoutTime
.tv_secs
, &pog
->pog_TimeoutTime
.tv_micro
);
721 if(ps
->ps_GlobalCfg
->pgc_PopupCloseDelay
)
723 pog
->pog_TimeoutTime
.tv_secs
+= ps
->ps_GlobalCfg
->pgc_PopupCloseDelay
;
725 pog
->pog_TimeoutTime
.tv_secs
+= 60*60*24;
729 if((ps
->ps_GlobalCfg
->pgc_PopupDeviceNew
>= PGCP_ISNEW
) && pd
->pd_IsNewToMe
)
731 pog
->pog_ShowMe
= TRUE
;
733 if((ps
->ps_GlobalCfg
->pgc_PopupDeviceNew
>= PGCP_ERROR
) && (isdead
|| lowpower
))
735 pog
->pog_ShowMe
= TRUE
;
737 switch(ps
->ps_GlobalCfg
->pgc_PopupDeviceNew
)
745 if(configstate
& PPF_HasBinding
)
749 // break missing on purpose
750 case PGCP_HASBINDING
:
751 if(configstate
& PPF_HasBinding
)
753 pog
->pog_ShowMe
= TRUE
;
758 if(configstate
& PPF_HasBindingGUI
)
760 if(!(configstate
& PPF_HasBindConfig
))
762 pog
->pog_ShowMe
= TRUE
;
764 break; // don't ask, if there is an unset default class config
766 if(configstate
& PPF_HasClassGUI
)
768 if(!(configstate
& PPF_HasClsConfig
))
770 pog
->pog_ShowMe
= TRUE
;
776 if(configstate
& (PPF_HasClassGUI
|PPF_HasBindingGUI
))
778 pog
->pog_ShowMe
= TRUE
;
783 pog
->pog_ShowMe
= TRUE
;
793 /* /// "pEventHandler()" */
794 void pEventHandler(LIBBASETYPEPTR ps
)
796 struct PsdPoPo
*po
= &ps
->ps_PoPo
;
797 struct PsdDevice
*pd
;
798 struct PsdEventNote
*pen
;
799 struct PsdPoPoGadgets
*pog
;
802 BOOL addsound
= FALSE
;
803 BOOL remsound
= FALSE
;
804 BOOL cfgchanged
= FALSE
;
806 /* delete removed devices first */
809 pog
= (struct PsdPoPoGadgets
*) po
->po_GadgetList
.lh_Head
;
810 while(pog
->pog_Node
.ln_Succ
)
814 /* verify that device is still there */
815 if(!pIsDeviceStillValid(ps
, pog
->pog_Device
))
818 pFreePoPoGadgets(ps
, pog
);
819 pog
= (struct PsdPoPoGadgets
*) po
->po_GadgetList
.lh_Head
;
823 pog
= (struct PsdPoPoGadgets
*) pog
->pog_Node
.ln_Succ
;
827 while((pen
= (struct PsdEventNote
*) GetMsg(po
->po_MsgPort
)))
829 eventmask
|= (1L<<pen
->pen_Event
);
830 switch(pen
->pen_Event
)
834 pd
= (struct PsdDevice
*) pen
->pen_Param1
;
835 if(pIsDeviceStillValid(ps
, pd
))
837 pRemoveOldBox(ps
, pd
);
838 if(pd
->pd_PoPoCfg
.poc_InhibitPopup
)
843 pog
= pGenerateAddBox(ps
, pd
, NULL
);
848 pog
->pog_Device
= pd
;
849 if(pog
->pog_ShowMe
&& (!pog
->pog_WaitBinding
))
851 po
->po_OpenRequest
= TRUE
;
857 case EHMB_DEVICEDEAD
:
858 case EHMB_DEVICELOWPW
:
860 BOOL lowpower
= FALSE
;
862 BOOL autodis
= FALSE
;
865 STRPTR gads
[4] = { NULL
, NULL
, NULL
, "Ignore" };
866 STRPTR autodismsg
= "";
868 pd
= (struct PsdDevice
*) pen
->pen_Param1
;
869 if(!pIsDeviceStillValid(ps
, pd
))
873 lowpower
= pd
->pd_Flags
& PDFF_LOWPOWER
;
874 isdead
= pd
->pd_Flags
& PDFF_DEAD
;
875 if(!(lowpower
|| isdead
))
879 if((ps
->ps_GlobalCfg
->pgc_AutoDisableLP
&& lowpower
) ||
880 (ps
->ps_GlobalCfg
->pgc_AutoDisableDead
&& isdead
) ||
881 (ps
->ps_GlobalCfg
->pgc_AutoRestartDead
&& isdead
))
883 struct Library
*UsbClsBase
;
884 struct PsdDevice
*hubpd
= pd
->pd_Hub
;
886 if(hubpd
->pd_DevBinding
)
888 UsbClsBase
= hubpd
->pd_ClsBinding
->puc_ClassBase
;
889 if(pIsClassStillValid(ps
, UsbClsBase
))
891 if(ps
->ps_GlobalCfg
->pgc_AutoRestartDead
&& isdead
)
893 usbDoMethod((ULONG
) UCM_HubPowerCyclePort
, hubpd
, pd
->pd_HubPort
);
894 psdAddErrorMsg(RETURN_WARN
, ps
->ps_Library
.lib_Node
.ln_Name
,
895 "Automatically powercycling port for '%s' due to death event.",
897 autodismsg
= "\n\n\33bAutomatically powercycling port!\33n";
899 usbDoMethod((ULONG
) UCM_HubDisablePort
, hubpd
, pd
->pd_HubPort
);
900 psdAddErrorMsg(RETURN_WARN
, ps
->ps_Library
.lib_Node
.ln_Name
,
901 "Automatically disabling port for '%s' due lowpower/death event.",
903 autodismsg
= "\n\n\33bAutomatically disabling port!\33n";
910 if(pd
->pd_PoPoCfg
.poc_InhibitPopup
)
916 if((ps
->ps_GlobalCfg
->pgc_PopupDeviceNew
< PGCP_ERROR
) && (!ps
->ps_GlobalCfg
->pgc_PopupDeviceDeath
))
921 pRemoveOldBox(ps
, pd
);
922 gads
[0] = "Disable Port";
923 devname
= pd
->pd_ProductStr
;
926 devname
= "Unknown Soldier";
928 if(lowpower
&& isdead
)
930 body
= psdCopyStrFmt("\33bWARNING: Detected LOW POWER situation\33n\n\nfor USB device\n\n\33b%s\33n\n\nand it has \33bdropped dead already\33n!%s", devname
, autodismsg
);
934 body
= psdCopyStrFmt("\33bWARNING: Detected LOW POWER situation\33n\n\nfor USB device\n\n\33b%s\33n\n\nand this might cause failures!%s", devname
, autodismsg
);
936 body
= psdCopyStrFmt("\33bWARNING: DEAD DEVICE!\33n\n\nUSB device\n\n\33b%s\33n\n\ndropped dead for no apparent reason!%s", devname
, autodismsg
);
937 gads
[1] = "Powercycle Port";
939 pog
= pAllocPoPoGadgets(ps
, body
, gads
);
948 set(pog
->pog_GadgetObj
[0], MUIA_Disabled
, TRUE
);
949 pog
->pog_Device
= NULL
; // to keep the message on the screen
951 pog
->pog_Device
= pd
;
953 DoMethod(pog
->pog_GadgetObj
[0], MUIM_Notify
, MUIA_Pressed
, FALSE
,
954 po
->po_AppObj
, 5, MUIM_Application_PushMethod
, po
->po_PoPoObj
, 2, MUIM_PoPo_DisablePort
, pog
);
957 DoMethod(pog
->pog_GadgetObj
[1], MUIM_Notify
, MUIA_Pressed
, FALSE
,
958 po
->po_AppObj
, 5, MUIM_Application_PushMethod
, po
->po_PoPoObj
, 2, MUIM_PoPo_PowerCyclePort
, pog
);
960 DoMethod(pog
->pog_GadgetObj
[3], MUIM_Notify
, MUIA_Pressed
, FALSE
,
961 po
->po_AppObj
, 5, MUIM_Application_PushMethod
, po
->po_PoPoObj
, 2, MUIM_PoPo_RemInfo
, pog
);
962 po
->po_OpenRequest
= TRUE
;
968 pd
= (struct PsdDevice
*) pen
->pen_Param1
;
969 pRemoveOldBox(ps
, pd
);
970 if(pd
->pd_PoPoCfg
.poc_InhibitPopup
)
975 if(!ps
->ps_GlobalCfg
->pgc_PopupDeviceGone
)
979 if(pd
->pd_ProductStr
)
981 body
= psdCopyStrFmt("The USB device\n\n\33b%s\33n\n\nhas been removed!", pd
->pd_ProductStr
);
983 //psdFreeVec(pd->pd_ProductStr);
984 //pd->pd_ProductStr = NULL;
986 body
= psdCopyStr("An USB device has been removed,\nbut I cannot recall its name.");
990 STRPTR gads
[4] = { NULL
, NULL
, NULL
, "Bye bye!" };
991 pog
= pAllocPoPoGadgets(ps
, body
, gads
);
997 DoMethod(pog
->pog_GadgetObj
[3], MUIM_Notify
, MUIA_Pressed
, FALSE
,
998 po
->po_AppObj
, 5, MUIM_Application_PushMethod
, po
->po_PoPoObj
, 2, MUIM_PoPo_RemInfo
, pog
);
999 po
->po_OpenRequest
= TRUE
;
1004 case EHMB_ADDBINDING
:
1005 case EHMB_REMBINDING
:
1007 pog
= (struct PsdPoPoGadgets
*) po
->po_GadgetList
.lh_Head
;
1008 while(pog
->pog_Node
.ln_Succ
)
1010 if(pog
->pog_Device
== (struct PsdDevice
*) pen
->pen_Param1
)
1012 if(!pIsDeviceStillValid(ps
, pog
->pog_Device
))
1016 if(pog
->pog_Device
->pd_PoPoCfg
.poc_InhibitPopup
)
1020 pGenerateAddBox(ps
, pog
->pog_Device
, pog
);
1023 po
->po_OpenRequest
= TRUE
;
1027 pog
= (struct PsdPoPoGadgets
*) pog
->pog_Node
.ln_Succ
;
1032 case EHMB_CONFIGCHG
:
1041 ReplyMsg(&pen
->pen_Msg
);
1046 if(po
->po_InsertSndFile
)
1048 if(*po
->po_InsertSndFile
)
1050 pPoPoPlaySound(ps
, po
->po_InsertSndFile
);
1056 if(po
->po_RemoveSndFile
)
1058 if(*po
->po_RemoveSndFile
)
1060 pPoPoPlaySound(ps
, po
->po_RemoveSndFile
);
1066 set(po
->po_SaveObj
, MUIA_Disabled
, (ps
->ps_SavedConfigHash
== ps
->ps_ConfigHash
));
1071 /* /// "pBindingsString()" */
1072 STRPTR
pBindingsString(LIBBASETYPEPTR ps
, struct PsdDevice
*pd
)
1074 STRPTR oldstr
= NULL
;
1075 STRPTR newstr
= NULL
;
1076 struct PsdConfig
*pc
;
1077 struct PsdInterface
*pif
;
1079 if(pd
->pd_DevBinding
)
1081 if(pd
->pd_Flags
& PDFF_APPBINDING
)
1083 return(psdCopyStr(((struct PsdAppBinding
*) pd
->pd_DevBinding
)->pab_Task
->tc_Node
.ln_Name
));
1085 return(psdCopyStr(pd
->pd_ClsBinding
->puc_ClassBase
->lib_Node
.ln_Name
));
1088 pc
= (struct PsdConfig
*) pd
->pd_Configs
.lh_Head
;
1089 while(pc
->pc_Node
.ln_Succ
)
1091 pif
= (struct PsdInterface
*) pc
->pc_Interfaces
.lh_Head
;
1092 while(pif
->pif_Node
.ln_Succ
)
1094 if(pif
->pif_IfBinding
)
1098 newstr
= psdCopyStrFmt("%s, %s", oldstr
, pif
->pif_ClsBinding
->puc_ClassBase
->lib_Node
.ln_Name
);
1102 oldstr
= psdCopyStr(pif
->pif_ClsBinding
->puc_ClassBase
->lib_Node
.ln_Name
);
1105 pif
= (struct PsdInterface
*) pif
->pif_Node
.ln_Succ
;
1107 pc
= (struct PsdConfig
*) pc
->pc_Node
.ln_Succ
;
1114 /* /// "pCheckConfigurable()" */
1115 ULONG
pCheckConfigurable(LIBBASETYPEPTR ps
, struct PsdDevice
*pd
)
1118 ULONG hasbindinggui
;
1120 struct PsdConfig
*pc
;
1121 struct PsdInterface
*pif
;
1122 struct Library
*UsbClsBase
;
1126 if(pd
->pd_DevBinding
)
1128 if(!(pd
->pd_Flags
& PDFF_APPBINDING
))
1130 UsbClsBase
= pd
->pd_ClsBinding
->puc_ClassBase
;
1132 hasclassgui
= FALSE
;
1133 hasbindinggui
= FALSE
;
1134 if(pIsClassStillValid(ps
, UsbClsBase
))
1136 usbGetAttrs(UGA_CLASS
, NULL
,
1137 UCCA_HasClassCfgGUI
, &hasclassgui
,
1138 UCCA_HasBindingCfgGUI
, &hasbindinggui
,
1139 UCCA_UsingDefaultCfg
, &noconfig
,
1141 result
|= PPF_HasBinding
;
1144 result
|= PPF_HasClassGUI
;
1147 result
|= PPF_HasClsConfig
;
1152 result
|= PPF_HasBindingGUI
;
1153 usbGetAttrs(UGA_BINDING
, pd
->pd_DevBinding
,
1154 UCBA_UsingDefaultCfg
, &noconfig
,
1158 result
|= PPF_HasBindConfig
;
1164 pc
= (struct PsdConfig
*) pd
->pd_Configs
.lh_Head
;
1165 while(pc
->pc_Node
.ln_Succ
)
1167 pif
= (struct PsdInterface
*) pc
->pc_Interfaces
.lh_Head
;
1168 while(pif
->pif_Node
.ln_Succ
)
1170 if(pif
->pif_IfBinding
)
1172 UsbClsBase
= pif
->pif_ClsBinding
->puc_ClassBase
;
1174 hasclassgui
= FALSE
;
1175 hasbindinggui
= FALSE
;
1176 if(pIsClassStillValid(ps
, UsbClsBase
))
1178 usbGetAttrs(UGA_CLASS
, NULL
,
1179 UCCA_HasClassCfgGUI
, &hasclassgui
,
1180 UCCA_HasBindingCfgGUI
, &hasbindinggui
,
1181 UCCA_UsingDefaultCfg
, &noconfig
,
1183 result
|= PPF_HasBinding
;
1186 result
|= PPF_HasClassGUI
;
1189 result
|= PPF_HasClsConfig
;
1194 result
|= PPF_HasBindingGUI
;
1195 usbGetAttrs(UGA_BINDING
, pif
->pif_IfBinding
,
1196 UCBA_UsingDefaultCfg
, &noconfig
,
1200 result
|= PPF_HasBindConfig
;
1205 pif
= (struct PsdInterface
*) pif
->pif_Node
.ln_Succ
;
1207 pc
= (struct PsdConfig
*) pc
->pc_Node
.ln_Succ
;
1215 /* /// "pOpenBindingsConfigGUI()" */
1216 void pOpenBindingsConfigGUI(LIBBASETYPEPTR ps
, struct PsdDevice
*pd
)
1218 struct PsdConfig
*pc
;
1219 struct PsdInterface
*pif
;
1220 struct Library
*UsbClsBase
;
1223 if(!pIsDeviceStillValid(ps
, pd
))
1228 if(pd
->pd_DevBinding
)
1230 if(!(pd
->pd_Flags
& PDFF_APPBINDING
))
1232 UsbClsBase
= pd
->pd_ClsBinding
->puc_ClassBase
;
1233 if(pIsClassStillValid(ps
, UsbClsBase
))
1235 usbGetAttrs(UGA_CLASS
, NULL
,
1236 UCCA_HasBindingCfgGUI
, &hascfggui
,
1240 usbDoMethod(UCM_OpenBindingCfgWindow
, pd
->pd_DevBinding
);
1245 pc
= (struct PsdConfig
*) pd
->pd_Configs
.lh_Head
;
1246 while(pc
->pc_Node
.ln_Succ
)
1248 pif
= (struct PsdInterface
*) pc
->pc_Interfaces
.lh_Head
;
1249 while(pif
->pif_Node
.ln_Succ
)
1251 if(pif
->pif_IfBinding
)
1253 UsbClsBase
= pif
->pif_ClsBinding
->puc_ClassBase
;
1254 if(pIsClassStillValid(ps
, UsbClsBase
))
1256 usbGetAttrs(UGA_CLASS
, NULL
,
1257 UCCA_HasBindingCfgGUI
, &hascfggui
,
1261 usbDoMethod(UCM_OpenBindingCfgWindow
, pif
->pif_IfBinding
);
1265 pif
= (struct PsdInterface
*) pif
->pif_Node
.ln_Succ
;
1267 pc
= (struct PsdConfig
*) pc
->pc_Node
.ln_Succ
;
1274 /* /// "pOpenClassesConfigGUI()" */
1275 void pOpenClassesConfigGUI(LIBBASETYPEPTR ps
, struct PsdDevice
*pd
)
1277 struct PsdConfig
*pc
;
1278 struct PsdInterface
*pif
;
1279 struct Library
*UsbClsBase
;
1283 if(!pIsDeviceStillValid(ps
, pd
))
1289 if(pd
->pd_DevBinding
)
1291 if(!(pd
->pd_Flags
& PDFF_APPBINDING
))
1293 UsbClsBase
= pd
->pd_ClsBinding
->puc_ClassBase
;
1294 if(pIsClassStillValid(ps
, UsbClsBase
))
1296 usbGetAttrs(UGA_CLASS
, NULL
,
1297 UCCA_HasClassCfgGUI
, &hascfggui
,
1301 usbDoMethod(UCM_OpenCfgWindow
);
1306 pc
= (struct PsdConfig
*) pd
->pd_Configs
.lh_Head
;
1307 while(pc
->pc_Node
.ln_Succ
)
1309 pif
= (struct PsdInterface
*) pc
->pc_Interfaces
.lh_Head
;
1310 while(pif
->pif_Node
.ln_Succ
)
1312 if(pif
->pif_IfBinding
)
1314 UsbClsBase
= pif
->pif_ClsBinding
->puc_ClassBase
;
1315 if(pIsClassStillValid(ps
, UsbClsBase
))
1317 usbGetAttrs(UGA_CLASS
, NULL
,
1318 UCCA_HasClassCfgGUI
, &hascfggui
,
1322 usbDoMethod(UCM_OpenCfgWindow
);
1326 pif
= (struct PsdInterface
*) pif
->pif_Node
.ln_Succ
;
1328 pc
= (struct PsdConfig
*) pc
->pc_Node
.ln_Succ
;
1335 /* /// "pDisableDevicePopup()" */
1336 void pDisableDevicePopup(LIBBASETYPEPTR ps
, struct PsdDevice
*pd
)
1338 if(!pIsDeviceStillValid(ps
, pd
))
1342 psdSetAttrs(PGA_DEVICE
, pd
, DA_InhibitPopup
, TRUE
, TAG_END
);
1346 /* /// "pAllocPoPoGadgets()" */
1347 struct PsdPoPoGadgets
* pAllocPoPoGadgets(LIBBASETYPEPTR ps
, STRPTR body
, STRPTR
*gad
)
1349 struct PsdPoPo
*po
= &ps
->ps_PoPo
;
1350 struct PsdPoPoGadgets
*pog
;
1351 if((pog
= (struct PsdPoPoGadgets
*) psdAllocVec(sizeof(struct PsdPoPoGadgets
))))
1355 Child
, (IPTR
)(pog
->pog_BodyObj
= TextObject
,
1356 MUIA_Frame
, MUIV_Frame_Text
,
1357 MUIA_Background
, MUII_TextBack
,
1358 MUIA_Text_PreParse
, (IPTR
)"\33c",
1359 MUIA_Text_Contents
, (IPTR
)body
,
1361 Child
, (IPTR
)(HGroup
,
1362 MUIA_Group_SameWidth
, TRUE
,
1363 Child
, (IPTR
)(pog
->pog_GadgetObj
[0] = TextObject
, ButtonFrame
,
1364 MUIA_Background
, MUII_ButtonBack
,
1366 MUIA_InputMode
, MUIV_InputMode_RelVerify
,
1367 MUIA_Text_PreParse
, (IPTR
)"\33c",
1368 MUIA_Text_Contents
, (IPTR
)(gad
[0] ? gad
[0] : (STRPTR
) ""),
1369 MUIA_ShowMe
, (IPTR
)gad
[0],
1371 Child
, (IPTR
)(pog
->pog_GadgetObj
[1] = TextObject
, ButtonFrame
,
1372 MUIA_Background
, MUII_ButtonBack
,
1374 MUIA_InputMode
, MUIV_InputMode_RelVerify
,
1375 MUIA_Text_PreParse
, (IPTR
)"\33c",
1376 MUIA_Text_Contents
, (IPTR
)(gad
[1] ? gad
[1] : (STRPTR
) ""),
1377 MUIA_ShowMe
, (IPTR
)gad
[1],
1379 Child
, (IPTR
)(pog
->pog_GadgetObj
[2] = TextObject
, ButtonFrame
,
1380 MUIA_Background
, MUII_ButtonBack
,
1382 MUIA_InputMode
, MUIV_InputMode_RelVerify
,
1383 MUIA_Text_PreParse
, (IPTR
)"\33c",
1384 MUIA_Text_Contents
, (IPTR
)(gad
[2] ? gad
[2] : (STRPTR
) ""),
1385 MUIA_ShowMe
, (IPTR
)gad
[2],
1387 Child
, (IPTR
)(pog
->pog_GadgetObj
[3] = TextObject
, ButtonFrame
,
1388 MUIA_Background
, MUII_ButtonBack
,
1390 MUIA_InputMode
, MUIV_InputMode_RelVerify
,
1391 MUIA_Text_PreParse
, (IPTR
)"\33c",
1392 MUIA_Text_Contents
, (IPTR
)(gad
[3] ? gad
[3] : (STRPTR
) ""),
1393 MUIA_ShowMe
, (IPTR
)gad
[3],
1397 Child
, (IPTR
)(BalanceObject
,
1402 if(!pog
->pog_GroupObj
)
1407 DoMethod(po
->po_GroupObj
, MUIM_Group_InitChange
);
1408 DoMethod(po
->po_GroupObj
, OM_ADDMEMBER
, pog
->pog_GroupObj
);
1409 DoMethod(po
->po_GroupObj
, MUIM_Group_ExitChange
);
1410 AddTail(&po
->po_GadgetList
, &pog
->pog_Node
);
1411 CurrentTime(&pog
->pog_TimeoutTime
.tv_secs
, &pog
->pog_TimeoutTime
.tv_micro
);
1412 if(ps
->ps_GlobalCfg
->pgc_PopupCloseDelay
&& (!po
->po_Sticky
))
1414 pog
->pog_TimeoutTime
.tv_secs
+= ps
->ps_GlobalCfg
->pgc_PopupCloseDelay
;
1416 pog
->pog_TimeoutTime
.tv_secs
+= 60*60*24;
1423 /* /// "pFreePoPoGadgets()" */
1424 void pFreePoPoGadgets(LIBBASETYPEPTR ps
, struct PsdPoPoGadgets
*pog
)
1426 struct PsdPoPo
*po
= &ps
->ps_PoPo
;
1427 Remove(&pog
->pog_Node
);
1428 DoMethod(po
->po_GroupObj
, MUIM_Group_InitChange
);
1429 DoMethod(po
->po_GroupObj
, OM_REMMEMBER
, pog
->pog_GroupObj
);
1430 DoMethod(po
->po_GroupObj
, MUIM_Group_ExitChange
);
1431 MUI_DisposeObject(pog
->pog_GroupObj
);
1436 /* /// "PoPoDispatcher()" */
1437 AROS_UFH3(IPTR
, PoPoDispatcher
,
1438 AROS_UFHA(struct IClass
*, cl
, A0
),
1439 AROS_UFHA(Object
*, obj
, A2
),
1440 AROS_UFHA(Msg
, msg
, A1
))
1443 struct PsdPoPoGadgets
*pog
;
1444 struct PsdPoPoGadgets
*tmppog
;
1445 LIBBASETYPEPTR ps
= (LIBBASETYPEPTR
) cl
->cl_UserData
;
1446 struct PsdPoPo
*po
= &ps
->ps_PoPo
;
1449 switch(msg
->MethodID
)
1452 if(!(obj
= (Object
*)DoSuperMethodA(cl
,obj
,msg
)))
1456 case MUIM_PoPo_SavePrefs
:
1457 psdSaveCfgToDisk(NULL
, FALSE
);
1458 set(po
->po_SaveObj
, MUIA_Disabled
, (ps
->ps_SavedConfigHash
== ps
->ps_ConfigHash
));
1461 case MUIM_PoPo_Sticky
:
1462 get(po
->po_StickyObj
, MUIA_Selected
, &sticky
);
1463 po
->po_Sticky
= sticky
;
1464 pog
= (struct PsdPoPoGadgets
*) po
->po_GadgetList
.lh_Head
;
1465 while(pog
->pog_Node
.ln_Succ
)
1467 CurrentTime(&pog
->pog_TimeoutTime
.tv_secs
, &pog
->pog_TimeoutTime
.tv_micro
);
1468 if(ps
->ps_GlobalCfg
->pgc_PopupCloseDelay
&& (!po
->po_Sticky
))
1470 pog
->pog_TimeoutTime
.tv_secs
+= ps
->ps_GlobalCfg
->pgc_PopupCloseDelay
;
1472 pog
->pog_TimeoutTime
.tv_secs
+= 60*60*24;
1474 pog
= (struct PsdPoPoGadgets
*) pog
->pog_Node
.ln_Succ
;
1478 case MUIM_PoPo_ConfigureBinding
:
1479 pog
= (struct PsdPoPoGadgets
*) ((IPTR
*) msg
)[1];
1480 //KPRINTF(20, ("Config Po=%08lx, Pog=%08lx, PS=%08lx\n", po, pog, ps));
1481 pog
->pog_TimeoutTime
.tv_secs
+= 60*60*24;
1482 pOpenBindingsConfigGUI(ps
, pog
->pog_Device
);
1485 case MUIM_PoPo_ConfigureClass
:
1486 pog
= (struct PsdPoPoGadgets
*) ((IPTR
*) msg
)[1];
1487 //KPRINTF(20, ("Config Po=%08lx, Pog=%08lx, PS=%08lx\n", po, pog, ps));
1488 pog
->pog_TimeoutTime
.tv_secs
+= 60*60*24;
1489 pOpenClassesConfigGUI(ps
, pog
->pog_Device
);
1492 case MUIM_PoPo_ShutUp
:
1493 pog
= (struct PsdPoPoGadgets
*) ((IPTR
*) msg
)[1];
1494 pDisableDevicePopup(ps
, pog
->pog_Device
);
1495 pRemoveOldBox(ps
, pog
->pog_Device
);
1498 case MUIM_PoPo_RemInfo
:
1499 pog
= (struct PsdPoPoGadgets
*) ((IPTR
*) msg
)[1];
1500 //KPRINTF(20, ("RemInfo Po=%08lx, Pog=%08lx, PS=%08lx\n", po, pog, ps));
1501 tmppog
= (struct PsdPoPoGadgets
*) po
->po_GadgetList
.lh_Head
;
1502 while(tmppog
->pog_Node
.ln_Succ
)
1506 pFreePoPoGadgets(ps
, pog
);
1509 tmppog
= (struct PsdPoPoGadgets
*) tmppog
->pog_Node
.ln_Succ
;
1513 case MUIM_PoPo_DisablePort
:
1514 case MUIM_PoPo_PowerCyclePort
:
1516 struct PsdDevice
*pd
;
1517 struct Library
*UsbClsBase
;
1518 BOOL disable
= (msg
->MethodID
== MUIM_PoPo_DisablePort
);
1520 pog
= (struct PsdPoPoGadgets
*) ((IPTR
*) msg
)[1];
1521 pd
= pog
->pog_Device
;
1522 set(pog
->pog_GadgetObj
[0], MUIA_Disabled
, TRUE
);
1523 if(pog
->pog_GadgetObj
[1] && (!disable
))
1525 set(pog
->pog_GadgetObj
[1], MUIA_Disabled
, TRUE
);
1528 if(pIsDeviceStillValid(ps
, pd
))
1530 struct PsdDevice
*hubpd
= pd
->pd_Hub
;
1531 if(hubpd
->pd_DevBinding
)
1533 UsbClsBase
= hubpd
->pd_ClsBinding
->puc_ClassBase
;
1534 if(pIsClassStillValid(ps
, UsbClsBase
))
1536 usbDoMethod((ULONG
) (disable
? UCM_HubDisablePort
: UCM_HubPowerCyclePort
), hubpd
, pd
->pd_HubPort
);
1541 pog
->pog_TimeoutTime
.tv_secs
+= 60*60*24;
1546 case MUIM_PoPo_About
:
1547 MUI_RequestA(po
->po_AppObj
, po
->po_WindowObj
, 0, NULL
, "Blimey!", "PoPo -- The Poseidon Popup Provider\n\nWritten by Chris Hodges.\n\nWichtig ist, was hinten rauskommt (Helmut Kohl).", NULL
);
1550 case MUIM_PoPo_OpenTrident
:
1552 struct Library
*DOSBase
;
1553 if((DOSBase
= OpenLibrary("dos.library", 39)))
1556 if((fhandle
= Open("NIL:", MODE_READWRITE
)))
1558 if(SystemTags("Trident",
1559 NP_StackSize
, 32*1024,
1566 MUI_RequestA(po
->po_AppObj
, po
->po_WindowObj
, 0, NULL
, "Oh no!", "Bugger!\n\nI tried hard to load Trident,\nbut there was Cryptonite somewhere!", NULL
);
1569 CloseLibrary(DOSBase
);
1574 return(DoSuperMethodA(cl
,obj
,msg
));