00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00026
00027
00028
00029
00030
00031 #include <pthread.h>
00032 #include <liberipc/eripc.h>
00033 #include <liberipc/eripctoolbar.h>
00034 #include <liberipc/eripcicons.h>
00035 #include <liberipc/eripcbusyd.h>
00036 #include <liberipc/eripccontentlister.h>
00037 #include <liberipc/eripcviewer.h>
00038 #include "browserTypes.h"
00039 #include "contentLister.h"
00040 #include "browserLog.h"
00041 #include "toolbar.h"
00042 #include "ipcServer.h"
00043 #include "pagebar.h"
00044
00045 static erServerChannel_t theServerChannel;
00046
00047
00048 void ipcMessageReceived(gpointer data, gint source_fd, GdkInputCondition condition);
00049
00050
00051 gboolean ipc_InstallIpcServer(Ereader * browser)
00052 {
00053 int returnValue;
00054 int channel;
00055 int fd = -1;
00056
00057 BR_IPCPRINTF("entry");
00058
00059 returnValue = erIpcOpenServerChannel(ER_XHTML_VIEWER_CHANNEL, &theServerChannel);
00060
00061 if (returnValue != (-1))
00062 {
00063 fd = erIpcGetServerFd(theServerChannel);
00064
00065 BR_IPCPRINTF("erIpcGetServerFd returned %d\n", fd);
00066
00067
00068 returnValue = gdk_input_add(fd, GDK_INPUT_READ, ipcMessageReceived, (gpointer) browser);
00069
00070 BR_IPCPRINTF("gdk_input_add returned %d", returnValue);
00071 return TRUE;
00072 }
00073 else
00074 {
00075 BR_ERRORPRINTF("Could not open server channel");
00076 return FALSE;
00077 }
00078 }
00079
00080
00081
00082
00083
00084 void ipcMessageReceived(gpointer data, gint source_fd, GdkInputCondition condition)
00085 {
00086 Ereader *browser;
00087 char szBuffer[SERVER_BUFFER_SIZE];
00088 int nBuf = SERVER_BUFFER_SIZE;
00089 erIpcCmd_t command;
00090 int page;
00091 int iconID;
00092 int iconState;
00093
00094 browser = (Ereader *) data;
00095 erIpcGetMessage(theServerChannel, szBuffer, &nBuf);
00096
00097 BR_IPCPRINTF("Received %s\n", szBuffer);
00098
00099 if (vwrParseCommand(szBuffer, &command) >= 0)
00100 {
00101 switch (command.cc)
00102 {
00103 case ccVwrToolbar:
00104 iconID = atoi(command.arg[0]);
00105 iconState = atoi(command.arg[1]);
00106 BR_IPCPRINTF("Toolbar iconID [%d] iconState [%d]", iconID, iconState);
00107 gdk_threads_enter();
00108 toolbar_key_selected(iconID, iconState, browser);
00109 gdk_threads_leave();
00110 break;
00111 case ccVwrStore:
00112
00113 contentlister_request(command, browser);
00114 break;
00115 case ccVwrJumpToPage:
00116 page = atoi(command.arg[1]);
00117 BR_IPCPRINTF("PageBar JumpToPage: %d", page);
00118 gdk_threads_enter();
00119 browser_pagebar_page_selected(page, browser);
00120 gdk_threads_leave();
00121 default:
00122 BR_IPCPRINTF("UNHANDLED COMMAND %d", command.cc);
00123 break;
00124 }
00125 }
00126 else
00127 {
00128 BR_WARNPRINTF("vwrParseCommand returned < 0\n");
00129 }
00130 }