00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00026
00027
00028
00029
00030
00031
00032 #include <stdio.h>
00033
00034 #include <glib.h>
00035 #include <gdk/gdk.h>
00036 #include <gtk/gtk.h>
00037
00038 #include <liberipc/eripc.h>
00039 #include <liberipc/eripcviewer.h>
00040 #include <liberipc/eripctoolbar.h>
00041 #include <liberipc/eripcbusyd.h>
00042 #include <liberipc/eripccontentlister.h>
00043 #include <libermanifest/ermanifest.h>
00044
00045 #include "contentListerLog.h"
00046 #include "erbusy.h"
00047 #include "displayUpdate.h"
00048 #include "stack.h"
00049 #include "viewer.h"
00050 #include "history.h"
00051 #include "erConnect.h"
00052 #include "system.h"
00053 #include "gtkPincodeScreen.h"
00054 #include "control.h"
00055 #include "programManager.h"
00056 #include "erMSDisk.h"
00057 #include "regValue.h"
00058 #include "toolbar.h"
00059 #include "button.h"
00060 #include "click.h"
00061
00062
00063
00064 static erClientChannel_t theBrowserChannel;
00065 static erServerChannel_t theServerChannel;
00066
00067
00068 static int viewerGetChannel(char *viewer);
00069 void viewerMessageReceived(gpointer data, gint source_fd, GdkInputCondition condition);
00070
00071 gboolean viewerInit(char *viewer)
00072 {
00073 int channel;
00074
00075 channel = viewerGetChannel(viewer);
00076
00077 if (channel > 0)
00078 {
00079
00080 if (erIpcStartClient(channel, &theBrowserChannel) == 0)
00081 {
00082 CL_IPCPRINTF("channel %d opened", channel);
00083 return TRUE;
00084 }
00085 }
00086 return FALSE;
00087 }
00088
00089 gboolean viewerStore(char *viewer, st_ContentType_e contentType)
00090 {
00091 int channel;
00092
00093 CL_IPCPRINTF("entry - %s - %d", viewer, contentType);
00094
00095 channel = viewerGetChannel(viewer);
00096
00097 if (channel > 0)
00098 {
00099
00100
00101
00102
00103
00104 vwrStore(theBrowserChannel, ER_CONTENT_LISTER_UA_ID, contentType, NULL);
00105 }
00106
00107 return TRUE;
00108
00109 }
00110
00111 gboolean viewerInstallIpcServer()
00112 {
00113 int returnValue;
00114 int fd = -1;
00115
00116 CL_IPCPRINTF("entry");
00117
00118 returnValue = erIpcOpenServerChannel(ER_CONTENTLISTER_CHANNEL, &theServerChannel);
00119
00120 if (returnValue != (-1))
00121 {
00122 fd = erIpcGetServerFd(theServerChannel);
00123
00124 CL_IPCPRINTF("erIpcGetServerFd returned %d\n", fd);
00125
00126
00127 returnValue = gdk_input_add(fd, GDK_INPUT_READ, viewerMessageReceived, (gpointer) theServerChannel);
00128
00129 CL_IPCPRINTF("gdk_input_add returned %d", returnValue);
00130 return TRUE;
00131 }
00132 else
00133 {
00134 CL_ERRORPRINTF("Could not open server channel");
00135 return FALSE;
00136 }
00137 }
00138
00139
00140
00141
00142
00143 void viewerMessageReceived(gpointer data, gint source_fd, GdkInputCondition condition)
00144 {
00145 char szBuffer[SERVER_BUFFER_SIZE];
00146 int nBuf = SERVER_BUFFER_SIZE;
00147 erIpcCmd_t command;
00148 int index;
00149 st_ContentType_e contentType;
00150 char *location;
00151 char *item;
00152 eCcBusyState status;
00153
00154 CL_IPCPRINTF("entry");
00155 erIpcGetMessage((erServerChannel_t) data, szBuffer, &nBuf);
00156
00157 CL_IPCPRINTF("Received [%s]", szBuffer);
00158
00159 if (clParseCommand(szBuffer, &command) >= 0)
00160 {
00161 CL_IPCPRINTF("command.cc [%d]", command.cc);
00162 switch (command.cc)
00163 {
00164 case ccClStore:
00165 CL_IPCPRINTF("STORE - nArg %d", command.nArg);
00166
00167 if (command.nArg == 4)
00168 {
00169 for (index = 0; index < command.nArg; index++)
00170 {
00171 CL_IPCPRINTF("command.arg[%d]=%s", index, command.arg[index]);
00172 }
00173
00174 contentType = atoi(command.arg[1]);
00175 item = command.arg[2];
00176 location = command.arg[3];
00177
00178 CL_IPCPRINTF("contentType=%d location=%s", contentType, location);
00179 hsSetLocation(contentType, location);
00180 }
00181 else
00182 {
00183 CL_WARNPRINTF("ccclStore invalid argument count %d", command.nArg);
00184 }
00185 break;
00186
00187 case ccClMSDiskSetConnected:
00188 {
00189 int connected = atoi(command.arg[0]);
00190 CL_IPCPRINTF("msdisk: connected = %d\n", connected);
00191 erMSDiskSetConnected(connected);
00192 break;
00193 }
00194
00195 case ccClGotoPage:
00196 {
00197 int page = atoi(command.arg[0]);
00198 CL_IPCPRINTF("Contentlister Goto Page: %d\n", page);
00199 gdk_threads_enter();
00200 erbusy_blink();
00201 ctrl_goto_page(page);
00202 gdk_threads_leave();
00203 break;
00204 }
00205
00206 case ccClBatteryLow:
00207 {
00208 eCcClBatteryAction action = atoi(command.arg[0]);
00209 int percentage = atoi(command.arg[1]);
00210 int time_left = atoi(command.arg[2]);
00211 CL_IPCPRINTF("BatteryLow: action [%d] perc [%d] time [%d]", action, percentage, time_left);
00212 gdk_threads_enter();
00213 if (action == ccClBattery_warning)
00214 {
00215 ctrl_battery_low_screen(percentage, time_left, FALSE);
00216 }
00217 else if (action == ccClBattery_shutdown)
00218 {
00219 ctrl_battery_low_screen(percentage, time_left, TRUE);
00220 }
00221 gdk_threads_leave();
00222 }
00223
00224 case ccClToolbarIcon:
00225 {
00226 int iconID = atoi(command.arg[0]);
00227 int iconState = atoi(command.arg[1]);
00228 CL_TBPRINTF("ccClToolbarIcon: iconID [%d] iconState [%d]", iconID, iconState);
00229 gdk_threads_enter();
00230 ctrl_on_icon_clicked(iconID, iconState);
00231 gdk_threads_leave();
00232 break;
00233 }
00234
00235 case ccClStoragePresent:
00236 {
00237 st_ContentType_e storageType = ctrl_get_storageType(command.arg[0]);
00238 gboolean storagePresent = atoi(command.arg[1]) ? TRUE : FALSE;
00239 gdk_threads_enter();
00240 ctrl_storage_changed(storageType, storagePresent);
00241 gdk_threads_leave();
00242 break;
00243 }
00244
00245 case ccClToolbarSynchronised:
00246 gdk_threads_enter();
00247 ctrl_on_toolbar_synchronised();
00248 gdk_threads_leave();
00249 break;
00250
00251 case ccClBusyIndicator:
00252 if (command.nArg == 1)
00253 {
00254 status = atoi(command.arg[0]);
00255 if (status == ccBusyState_Off)
00256 {
00257 CL_LOGPRINTF("enable key buffering for busybar off");
00258 gdk_threads_enter();
00259 button_enable_key_buffering(TRUE);
00260 gdk_threads_leave();
00261 }
00262 else if (status == ccBusyState_Blink)
00263 {
00264 CL_LOGPRINTF("disable key buffering for busybar blink");
00265 gdk_threads_enter();
00266 button_enable_key_buffering(FALSE);
00267 gdk_threads_leave();
00268 }
00269 }
00270 break;
00271
00272 case ccClDisplayUpdated:
00273 CL_LOGPRINTF("enable key buffering for display updated");
00274 gdk_threads_enter();
00275 button_enable_key_buffering(TRUE);
00276 gdk_threads_leave();
00277 break;
00278
00279 case ccClNewContent:
00280 CL_LOGPRINTF("enable key buffering for display updated\n");
00281 gdk_threads_enter();
00282 ctrl_new_content_received();
00283 gdk_threads_leave();
00284 break;
00285
00286 case ccClPenClick:
00287 click_pen();
00288 break;
00289
00290 case ccClEnableAudio:
00291 {
00292 int volume = atoi(command.arg[0]);
00293 CL_LOGPRINTF("enable/disable volume=%d", volume);
00294 handle_sound_settings_changed(volume);
00295 break;
00296 }
00297
00298 default:
00299 CL_ERRORPRINTF("UNKNOWN IPC COMMAND %d", command.cc);
00300 break;
00301 }
00302 }
00303 CL_IPCPRINTF("done");
00304 }
00305
00306
00314 static int viewerGetChannel(char *viewer)
00315 {
00316 int channel = -1;
00317
00318 CL_IPCPRINTF("entry %s", viewer);
00319
00320 if (strncmp(BROWSER_APP, viewer, UAID_MAX_SIZE) == 0)
00321 {
00322 channel = ER_XHTML_VIEWER_CHANNEL;
00323 }
00324 else
00325 {
00326 CL_WARNPRINTF("%s unkown viewer", viewer);
00327 }
00328 return channel;
00329 }