2 Copyright © 2002-2003, The AROS Development Team. All rights reserved.
6 #include <proto/exec.h>
7 #include <proto/intuition.h>
8 #include <proto/alib.h>
12 #include "muimiamipanel_intern.h"
13 #include "muimiamipanel_message.h"
16 MiamiPanelFun(struct MiamiPanelBase_intern
*MiamiPanelBaseIntern
, ULONG id
, ...)
18 #if defined(__MORPHOS__) || defined(__AROS__)
27 case MIAMIPANELV_CallBack_Code_HideMainGUI
:
28 case MIAMIPANELV_CallBack_Code_ShowMainGUI
:
29 case MIAMIPANELV_CallBack_Code_ClosePanel
:
30 case MIAMIPANELV_CallBack_Code_QuitMiami
:
34 case MIAMIPANELV_CallBack_Code_UnitOnline
:
35 case MIAMIPANELV_CallBack_Code_UnitOffline
:
43 #if defined(__MORPHOS__) || defined(__AROS__)
46 if (*(UWORD *)MiamiPanelBaseIntern->mpb_asynccb >= (UWORD)0xFF00) REG_A7 -= 4;
48 ((ULONG *)REG_A7)[-1] = (ULONG)va->overflow_arg_area;
49 ((ULONG *)REG_A7)[-2] = (ULONG)num;
50 ((ULONG *)REG_A7)[-3] = (ULONG)id;
54 MyEmulHandle->EmulCallDirect68k(MiamiPanelBaseIntern->mpb_asynccb);
57 if (*(UWORD *)MiamiPanelBaseIntern->mpb_asynccb >= (UWORD)0xFF00) REG_A7 += 4;
61 va
= (UBYTE
*)(&id
+1);
62 (*MiamiPanelBaseIntern
->mpb_asynccb
)(id
,num
,va
);
68 /****************************************************************************/
76 struct sizes sizes
[] =
78 MPV_Msg_Type_Cleanup
, sizeof(struct MPS_Msg
),
79 MPV_Msg_Type_AddInterface
, sizeof(struct MPS_Msg_AddInterface
),
80 MPV_Msg_Type_DelInterface
, sizeof(struct MPS_Msg_DelInterface
),
81 MPV_Msg_Type_SetInterfaceState
, sizeof(struct MPS_Msg_SetInterfaceState
),
82 MPV_Msg_Type_SetInterfaceSpeed
, sizeof(struct MPS_Msg_SetInterfaceSpeed
),
83 MPV_Msg_Type_InterfaceReport
, sizeof(struct MPS_Msg_InterfaceReport
),
84 MPV_Msg_Type_ToFront
, sizeof(struct MPS_Msg
),
85 MPV_Msg_Type_InhibitRefresh
, sizeof(struct MPS_Msg_InhibitRefresh
),
86 MPV_Msg_Type_GetCoord
, sizeof(struct MPS_Msg_GetCoord
),
87 MPV_Msg_Type_Event
, sizeof(struct MPS_Msg_Event
),
88 MPV_Msg_Type_RefreshName
, sizeof(struct MPS_Msg_RefreshName
),
91 void DoCommand(struct MiamiPanelBase_intern
*MiamiPanelBaseIntern
, ULONG id
,...)
93 #if defined(__MORPHOS__) || defined(__AROS__)
102 struct MsgPort reply
;
104 ULONG size
, istoreply
;
107 if (id
<MPV_Msg_Type_Last
) size
= sizes
[id
].size
;
110 ObtainSemaphore(&MiamiPanelBaseIntern
->mpb_libSem
);
112 if (!MiamiPanelBaseIntern
->mpb_port
)
114 ReleaseSemaphore(&MiamiPanelBaseIntern
->mpb_libSem
);
118 if (AttemptSemaphore(&MiamiPanelBaseIntern
->mpb_procSem
))
120 ReleaseSemaphore(&MiamiPanelBaseIntern
->mpb_procSem
);
121 ReleaseSemaphore(&MiamiPanelBaseIntern
->mpb_libSem
);
125 if (!(msg
= createMsg(size
, MiamiPanelBaseIntern
)))
127 // We break the rules here: Cleanup must be got
128 if (id
==MPV_Msg_Type_Cleanup
)
129 DoMethod(MiamiPanelBaseIntern
->mpb_app
, MUIM_Application_PushMethod
,
130 (ULONG
)MiamiPanelBaseIntern
->mpb_app
,
131 2, MUIM_Application_ReturnID
, MUIV_Application_ReturnID_Quit
);
133 ReleaseSemaphore(&MiamiPanelBaseIntern
->mpb_libSem
);
139 #if defined(__MORPHOS__) || defined(__AROS__)
142 va
= (ULONG
*)(&id
+1);
147 case MPV_Msg_Type_Cleanup
:
148 case MPV_Msg_Type_ToFront
:
151 case MPV_Msg_Type_AddInterface
:
153 struct MPS_Msg_AddInterface
*m
= (struct MPS_Msg_AddInterface
*)msg
;
155 #if defined(__MORPHOS__) || defined(__AROS__)
156 m
->unit
= va_arg(va
,long);
157 m
->name
= va_arg(va
,UBYTE
*);
158 m
->state
= va_arg(va
,long);
159 m
->ontime
= va_arg(va
,long);
160 m
->speed
= va_arg(va
,UBYTE
*);
163 m
->name
= (UBYTE
*)*va
++;
166 m
->speed
= (UBYTE
*)*va
;
173 case MPV_Msg_Type_InterfaceReport
:
175 struct MPS_Msg_InterfaceReport
*m
= (struct MPS_Msg_InterfaceReport
*)msg
;
177 #if defined(__MORPHOS__) || defined(__AROS__)
178 m
->unit
= va_arg(va
,long);
179 m
->rate
= va_arg(va
,long);
180 m
->now
= va_arg(va
,long);
181 m
->total
.hi
= va_arg(va
,ULONG
);
182 m
->total
.lo
= va_arg(va
,ULONG
);
194 case MPV_Msg_Type_DelInterface
:
196 struct MPS_Msg_DelInterface
*m
= (struct MPS_Msg_DelInterface
*)msg
;
198 #if defined(__MORPHOS__) || defined(__AROS__)
199 m
->unit
= va_arg(va
,long);
207 case MPV_Msg_Type_SetInterfaceState
:
209 struct MPS_Msg_SetInterfaceState
*m
= (struct MPS_Msg_SetInterfaceState
*)msg
;
211 #if defined(__MORPHOS__) || defined(__AROS__)
212 m
->unit
= va_arg(va
,long);
213 m
->state
= va_arg(va
,long);
214 m
->ontime
= va_arg(va
,long);
224 case MPV_Msg_Type_SetInterfaceSpeed
:
226 struct MPS_Msg_SetInterfaceSpeed
*m
= (struct MPS_Msg_SetInterfaceSpeed
*)msg
;
228 #if defined(__MORPHOS__) || defined(__AROS__)
229 m
->unit
= va_arg(va
,long);
230 m
->speed
= va_arg(va
,UBYTE
*);
233 m
->speed
= (UBYTE
*)*va
;
241 case MPV_Msg_Type_RefreshName
:
243 struct MPS_Msg_RefreshName
*m
= (struct MPS_Msg_RefreshName
*)msg
;
245 #if defined(__MORPHOS__) || defined(__AROS__)
246 m
->unit
= va_arg(va
,long);
247 m
->name
= va_arg(va
,UBYTE
*);
250 m
->name
= (UBYTE
*)*va
;
258 case MPV_Msg_Type_InhibitRefresh
:
260 struct MPS_Msg_InhibitRefresh
*m
= (struct MPS_Msg_InhibitRefresh
*)msg
;
262 #if defined(__MORPHOS__) || defined(__AROS__)
263 m
->val
= va_arg(va
,long);
272 #if defined(__MORPHOS__) || defined(__AROS__)
278 if ((sig
= AllocSignal(-1))<0)
280 freeMsg(msg
, MiamiPanelBaseIntern
);
281 ReleaseSemaphore(&MiamiPanelBaseIntern
->mpb_libSem
);
285 INITPORT(&reply
, sig
);
286 INITMESSAGE(msg
, &reply
,size
);
287 msg
->flags
|= MPV_Msg_Flags_Reply
;
292 PutMsg(MiamiPanelBaseIntern
->mpb_port
, (struct Message
*)msg
);
297 freeMsg(msg
, MiamiPanelBaseIntern
);
301 ReleaseSemaphore(&MiamiPanelBaseIntern
->mpb_libSem
);