#include <stdio.h>
#include <wm.h>
#include <wm_internals.h>
+#include <wm_hotkeys.h>
#define AXWIN_PORT 4101
int tmp;
// TODO: Check this
giNetworkFileHandle = open("/Devices/ip/loop/udp", OPENFLAG_READ);
- tmp = AXWIN_PORT; ioctl(giNetworkFileHandle, 4, &tmp); // TODO: Don't hard-code IOCtl number
+ if( giNetworkFileHandle != -1 )
+ {
+ tmp = AXWIN_PORT;
+ ioctl(giNetworkFileHandle, 4, &tmp); // TODO: Don't hard-code IOCtl number
+ }
}
void IPC_FillSelect(int *nfds, fd_set *set)
{
- if( giNetworkFileHandle > *nfds ) *nfds = giNetworkFileHandle;
- FD_SET(giNetworkFileHandle, set);
+ if( giNetworkFileHandle != -1 )
+ {
+ if( giNetworkFileHandle > *nfds ) *nfds = giNetworkFileHandle;
+ FD_SET(giNetworkFileHandle, set);
+ }
}
void IPC_HandleSelect(fd_set *set)
{
- if( FD_ISSET(giNetworkFileHandle, set) )
+ if( giNetworkFileHandle != -1 )
{
- char staticBuf[STATICBUF_SIZE];
- int readlen, identlen;
- char *msg;
-
- readlen = read(giNetworkFileHandle, staticBuf, sizeof(staticBuf));
-
- identlen = 4 + Net_GetAddressSize( ((uint16_t*)staticBuf)[1] );
- msg = staticBuf + identlen;
-
- IPC_Handle(&gIPC_Type_Datagram, staticBuf, readlen - identlen, (void*)msg);
-// _SysDebug("IPC_HandleSelect: UDP handled");
+ if( FD_ISSET(giNetworkFileHandle, set) )
+ {
+ char staticBuf[STATICBUF_SIZE];
+ int readlen, identlen;
+ char *msg;
+
+ readlen = read(giNetworkFileHandle, staticBuf, sizeof(staticBuf));
+
+ identlen = 4 + Net_GetAddressSize( ((uint16_t*)staticBuf)[1] );
+ msg = staticBuf + identlen;
+
+ IPC_Handle(&gIPC_Type_Datagram, staticBuf, readlen - identlen, (void*)msg);
+// _SysDebug("IPC_HandleSelect: UDP handled");
+ }
}
while(SysGetMessage(NULL, NULL))
int IPC_Msg_RegisterAction(tIPC_Client *Client, tAxWin_IPCMessage *Msg)
{
+ tIPCMsg_RegAction *info = (void*)Msg->Data;
+ tWindow *win;
+
ASSERT(Msg->ID == IPCMSG_REGACTION);
+
+ if( Msg->Size < sizeof(*info) + 1 )
+ return -1;
+
+ win = IPC_int_GetWindow(Client, Msg->Window);
+ if(!win) return 1;
+
+ if( strnlen(info->Action, Msg->Size - sizeof(*info)) == Msg->Size - sizeof(*info) )
+ return 1;
+
+ _SysDebug("RegisterAction %p:%i [%i]\"%s\"",
+ Client, Msg->Window, info->Index, info->Action
+ );
+
+ WM_Hotkey_RegisterAction(info->Action, win, info->Index);
+
return 0;
}