00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00032 #include <pthread.h>
00033 #include <liberipc/eripc.h>
00034 #include <liberipc/eripctoolbar.h>
00035 #include <liberipc/eripcicons.h>
00036 #include <liberipc/eripcbusyd.h>
00037 #include <liberipc/eripccontentlister.h>
00038 #include <liberipc/eripcviewer.h>
00039
00040 #include "ScribbleLog.h"
00041 #include "ScribbleIPC.h"
00042
00043 #include "ScribbleUI.h"
00044 #include "ScribbleIPC.h"
00045 #include "ScribbleDefine.h"
00046
00047 static erServerChannel_t srvChannel;
00048 static gint srvInputTag;
00049
00050
00051 void ipcMessageReceived(gpointer data, gint source_fd,
00052 GdkInputCondition condition)
00053 {
00054 char szBuffer[SCRIB_SERVER_BUFFER_SIZE];
00055 int nBuf = SCRIB_SERVER_BUFFER_SIZE;
00056 erIpcCmd_t command;
00057 int iconID;
00058 int iconState;
00059
00060 PScribbleUICtx pScribbleUICtx=(PScribbleUICtx)data;
00061
00062 erIpcGetMessage(srvChannel, szBuffer, &nBuf);
00063 SB_IPCPRINTF("get msg ok\n");
00064 if (vwrParseCommand(szBuffer, &command) >= 0)
00065 {
00066 switch ((int) command.cc)
00067 {
00068 case ccVwrJumpToPage:
00069 SB_IPCPRINTF("\nServiceCallBack: ccVwrJumpToPage %d\n",
00070 atoi(command.arg[1]));
00071 resetCurrentPage(pScribbleUICtx,atoi(command.arg[1]) );
00072 SB_IPCPRINTF("reset page ok\n");
00073 break;
00074 case ccVwrToolbar:
00075 iconID = atoi(command.arg[0]);
00076 iconState = atoi(command.arg[1]);
00077 SB_IPCPRINTF("Toolbar iconID [%d] iconState [%d]", \
00078 iconID, iconState);
00079 toolbar_key_selected(iconID, iconState, pScribbleUICtx);
00080 break;
00081 default:
00082 SB_ERRORPRINTF("UNKNOWN COMMAND\n");
00083 }
00084 }
00085 }
00086
00087
00088 gboolean installIpcServer(PScribbleUICtx pScribbleUICtx)
00089 {
00090 int iRet = 0;
00091 int fd = -1;
00092
00093 SB_IPCPRINTF("__start__\n");
00094 iRet = erIpcOpenServerChannel(ER_SCRIBBLE_CHANNEL,
00095 &srvChannel);
00096 if (iRet != 0)
00097 {
00098 SB_ERRORPRINTF("erIpcOpenServerChannel returned %d\n", iRet);
00099 return iRet;
00100 }
00101 fd = erIpcGetServerFd(srvChannel);
00102
00103 srvInputTag = gdk_input_add(fd, GDK_INPUT_READ,
00104 ipcMessageReceived, (gpointer) pScribbleUICtx);
00105 SB_IPCPRINTF("__finish__\n");
00106 return iRet;
00107 }
00108
00109
00110 void stopIpcServer(void)
00111 {
00112 int fd = erIpcGetServerFd(srvChannel);
00113
00114 SB_IPCPRINTF("__start__\n");
00115 gdk_input_remove(srvInputTag);
00116 close(fd);
00117 SB_IPCPRINTF("__finish__\n");
00118 }