Enlightenment CVS committal Author : kwo Project : e16 Module : e
Dir : e16/e/src Modified Files: comms.c comms.h ipc.c ipc.h Log Message: Shuffle comms/ipc stuff around a bit. =================================================================== RCS file: /cvs/e/e16/e/src/comms.c,v retrieving revision 1.84 retrieving revision 1.85 diff -u -3 -r1.84 -r1.85 --- comms.c 29 Sep 2007 16:37:49 -0000 1.84 +++ comms.c 28 Nov 2007 19:28:54 -0000 1.85 @@ -23,6 +23,7 @@ */ #include "E.h" #include "comms.h" +#include "ipc.h" #include "e16-ecore_hints.h" #include "e16-ecore_list.h" #include "xwin.h" @@ -35,7 +36,6 @@ char *clientname; char *version; char *info; - char replied; }; static Ecore_List *client_list = NULL; @@ -202,11 +202,20 @@ } static void +ClientIpcReply(void *data, const char *str) +{ + Client *c = (Client *) data; + + if (!str) + str = ""; + CommsSend(c, str); +} + +static void ClientHandleComms(XClientMessageEvent * ev) { Client *c; char *s; - const char *s1, *s2; s = ClientCommsGet(&c, ev); if (!s) @@ -222,8 +231,10 @@ goto done; } - if (!HandleIPC(s, c)) + if (!IpcExecReply(s, ClientIpcReply, c)) { + const char *s1, *s2; + s1 = (c->clientname) ? c->clientname : "UNKNOWN"; s2 = (c->version) ? c->version : "UNKNOWN"; DialogOK(_("E IPC Error"), @@ -330,17 +341,7 @@ if (!c) return; - c->replied = 1; CommsDoSend(c->xwin, s); -} - -void -CommsFlush(Client * c) -{ - if (!c || c->replied) - return; - - CommsDoSend(c->xwin, ""); } /* =================================================================== RCS file: /cvs/e/e16/e/src/comms.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- comms.h 18 May 2007 08:25:02 -0000 1.1 +++ comms.h 28 Nov 2007 19:28:54 -0000 1.2 @@ -28,12 +28,8 @@ void CommsInit(void); void CommsSend(Client * c, const char *s); -void CommsFlush(Client * c); void CommsSendToMasterWM(const char *s); void CommsBroadcast(const char *s); void CommsBroadcastToSlaveWMs(const char *s); - -/* ipc.c */ -int HandleIPC(const char *params, Client * c); #endif /* _COMMS_H_ */ =================================================================== RCS file: /cvs/e/e16/e/src/ipc.c,v retrieving revision 1.303 retrieving revision 1.304 diff -u -3 -r1.303 -r1.304 --- ipc.c 29 Sep 2007 19:13:21 -0000 1.303 +++ ipc.c 28 Nov 2007 19:28:54 -0000 1.304 @@ -24,7 +24,6 @@ #include "E.h" #include "aclass.h" #include "borders.h" /* FIXME - Should not be here */ -#include "comms.h" #include "desktops.h" #include "emodule.h" #include "eobj.h" @@ -43,30 +42,34 @@ #define SS(s) ((s) ? (s) : NoText) static const char NoText[] = "-NONE-"; -static size_t ipc_bufsiz; -static char *ipc_bufptr; +static char *ipc_bufptr = NULL; +static size_t ipc_bufsiz = 0; +static char ipc_active = 0; static void IpcPrintInit(void) { - ipc_bufsiz = 0; ipc_bufptr = NULL; + ipc_bufsiz = 0; + ipc_active = 1; } static void -IpcPrintFlush(Client * c) +IpcPrintDone(void) { - if (ipc_bufptr == NULL) - return; - - ipc_bufptr[ipc_bufsiz] = '\0'; - - if (c) - CommsSend(c, ipc_bufptr); - Efree(ipc_bufptr); - ipc_bufsiz = 0; ipc_bufptr = NULL; + ipc_bufsiz = 0; + ipc_active = 0; +} + +static const char * +IpcPrintGetBuffer(void) +{ + if (!ipc_bufptr) + return NULL; + ipc_bufptr[ipc_bufsiz] = '\0'; + return ipc_bufptr; } void @@ -76,6 +79,9 @@ int len; va_list args; + if (!ipc_active) + return; + va_start(args, fmt); len = Evsnprintf(tmp, sizeof(tmp), fmt, args); va_end(args); @@ -1632,8 +1638,8 @@ * you shouldn't have to touch this function * - Mandrake */ -int -HandleIPC(const char *params, Client * c) +static int +IpcExec(const char *params) { int i, num, ok; char cmd[128]; @@ -1641,9 +1647,7 @@ const IpcItem **lst, *ipc; if (EDebug(EDBUG_TYPE_IPC)) - Eprintf("HandleIPC: %s\n", params); - - IpcPrintInit(); + Eprintf("IpcExec: %s\n", params); cmd[0] = 0; num = 0; @@ -1669,8 +1673,18 @@ if (!ok && params) ok = IPC_Compat(params); - IpcPrintFlush(c); - CommsFlush(c); + return ok; +} + +int +IpcExecReply(const char *params, IpcReplyFunc * reply, void *data) +{ + int ok; + + IpcPrintInit(); + ok = IpcExec(params); + reply(data, IpcPrintGetBuffer()); + IpcPrintDone(); return ok; } @@ -1678,13 +1692,13 @@ int EFunc(EWin * ewin, const char *params) { - int err; + int ok; SetContextEwin(ewin); - err = HandleIPC(params, NULL); + ok = IpcExec(params); SetContextEwin(NULL); - return err; + return ok; } static void =================================================================== RCS file: /cvs/e/e16/e/src/ipc.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- ipc.h 18 May 2007 08:25:02 -0000 1.1 +++ ipc.h 28 Nov 2007 19:28:54 -0000 1.2 @@ -42,6 +42,9 @@ const IpcItem *lst; } IpcItemList; +typedef void (IpcReplyFunc) (void *data, const char *str); +int IpcExecReply(const char *params, IpcReplyFunc * reply, + void *data); void __PRINTF__ IpcPrintf(const char *fmt, ...); int EFunc(EWin * ewin, const char *params); ------------------------------------------------------------------------- SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future. http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs