popupmenu/src/ipc.c

Go to the documentation of this file.
00001 /*
00002  * File Name: ipc.c
00003  */
00004 
00005 /*
00006  * This file is part of popupmenu.
00007  *
00008  * popupmenu is free software: you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation, either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * popupmenu is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00020  */
00021 
00022 /**
00023  * Copyright (C) 2008 iRex Technologies B.V.
00024  * All rights reserved.
00025  */
00026  
00027 //----------------------------------------------------------------------------
00028 // Include Files
00029 //----------------------------------------------------------------------------
00030 
00031 #include "config.h"
00032  
00033 // system include files, between < >
00034 #include <gdk/gdkkeysyms.h>
00035 #include <gtk/gtk.h>
00036 #include <stdlib.h>
00037 #include <string.h>
00038 #include <sys/types.h>
00039 #include <unistd.h>
00040 
00041 // ereader include files, between < >
00042 #include <libergtk/ergtk.h>
00043 #include <liberipc/eripc.h>
00044 #include <liberipc/eripc_support.h>
00045 
00046 // local include files, between " "
00047 #include "log.h"
00048 #include "dialog.h"
00049 #include "ipc.h"
00050 #include "i18n.h"
00051 #include "menustore.h"
00052 #include "popup.h"
00053 #include "statusbar.h"
00054 #if MACHINE_IS_DR1000S || MACHINE_IS_DR1000SW
00055 #include "taskbar.h"
00056 #endif
00057 
00058 
00059 //----------------------------------------------------------------------------
00060 // Type Declarations
00061 //----------------------------------------------------------------------------
00062 
00063 #define CHECK_ARG_STRING(x) \
00064     if (arg_array[x].type != ERIPC_TYPE_STRING || arg_array[x].value.s == NULL) { \
00065         ERRORPRINTF("arg %d is not a string", x); \
00066         return; \
00067     }
00068 
00069 #define CHECK_ARG_INT(x) \
00070     if (arg_array[x].type != ERIPC_TYPE_INT) { \
00071         ERRORPRINTF("arg %d is not an integer", x); \
00072         return; \
00073     }
00074 
00075 //----------------------------------------------------------------------------
00076 // Global Constants
00077 //----------------------------------------------------------------------------
00078 
00079  
00080 //----------------------------------------------------------------------------
00081 // Static Variables
00082 //----------------------------------------------------------------------------
00083 
00084 static eripc_client_context_t *eripcClient = NULL;
00085 
00086 
00087 //============================================================================
00088 // Local Function Definitions
00089 //============================================================================
00090 
00091 static void add_group_cb            (eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00092 static void add_item_cb             (eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00093 static void add_menu_cb             (eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00094 static void add_task_cb             (eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00095 static void remove_group_cb         (eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00096 static void remove_item_cb          (eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00097 static void remove_menu_cb          (eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00098 static void remove_task_cb          (eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00099 static void rename_task_cb          (eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00100 static void set_task_to_top_cb      (eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00101 static void set_group_state_cb      (eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00102 static void set_group_label_cb      (eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00103 static void set_item_state_cb       (eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00104 static void set_item_label_cb       (eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00105 static void set_popup_show_cb       (eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00106 static void show_menu_cb            (eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00107 static void set_busy_show_cb        (eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00108 static void set_splash_show_cb      (eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00109 static void set_message_show_cb     (eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00110 static void set_statusitem_state_cb (eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00111 static void set_statusitem_show_cb  (eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00112 static void update_page_counter_cb(eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00113 static void confirm_usbconnect_cb   (eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00114 static void confirm_install_drz_cb  (eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00115 static void confirm_install_update_cb (eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00116 static void updates_finished_cb (eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00117 
00118 static void cb_sys_battery_state    (eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00119 static void cb_sys_usb_state        (eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00120 static void cb_sys_changed_locale   (eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00121 static void cb_sys_changed_orientation(eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00122 #if MACHINE_IS_DR1000S || MACHINE_IS_DR1000SW
00123 static void cb_sys_volume_mounted   (eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00124 static void cb_sys_volume_unmounted (eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00125 #endif
00126 static void cb_sys_signal_strength  (eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00127 
00128 static void testing_list_menu_items_cb(eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00129 static void testing_route_menu_item_cb(eripc_context_t *context, const eripc_event_info_t *info, void *user_data);
00130 
00131 // Exported DBUS API list
00132 static eripc_callback_function_t service_functions[] = {
00133         // message handlers (method calls to this service)
00134         { add_group_cb,                     "addGroup",                     NULL,              0 },
00135         { add_item_cb,                      "addItem",                      NULL,              0 },
00136         { add_menu_cb,                      "addMenu",                      NULL,              0 },
00137         { add_task_cb,                      "addTask",                      NULL,              0 },
00138         { remove_group_cb,                  "removeGroup",                  NULL,              0 },
00139         { remove_item_cb,                   "removeItem",                   NULL,              0 },
00140         { remove_menu_cb,                   "removeMenu",                   NULL,              0 },
00141         { remove_task_cb,                   "removeTask",                   NULL,              0 },
00142         { rename_task_cb,                   "renameTask",                   NULL,              0 },
00143         { set_task_to_top_cb,               "setTaskToTop",                 NULL,              0 },
00144         { set_group_state_cb,               "setGroupState",                NULL,              0 },
00145         { set_group_label_cb,               "setGroupLabel",                NULL,              0 },
00146         { set_item_state_cb,                "setItemState",                 NULL,              0 },
00147         { set_item_label_cb,                "setItemLabel",                 NULL,              0 },
00148         { set_popup_show_cb,                "setPopupShow",                 NULL,              0 },
00149         { show_menu_cb,                     "showMenu",                     NULL,              0 },
00150         { set_busy_show_cb,                 "setBusyShow",                  NULL,              0 },
00151         { set_splash_show_cb,               "setSplashShow",                NULL,              0 },
00152         { set_message_show_cb,              "setMessageShow",               NULL,              0 },
00153         { set_statusitem_state_cb,          "setStatusItemState",           NULL,              0 },
00154         { set_statusitem_show_cb,           "setStatusItemShow",            NULL,              0 },
00155         { confirm_usbconnect_cb,            "confirmUsbConnect",            NULL,              0 },
00156         { update_page_counter_cb,           "updatePageCounter",            NULL,              0 },
00157         { confirm_install_update_cb,        "confirmInstallUpdate",         NULL,              0 },
00158         { confirm_install_drz_cb,           "confirmInstallDrz",            NULL,              0 },
00159         { updates_finished_cb,              "updatesFinished",              NULL,              0 },
00160 #if MACHINE_IS_DR1000S || MACHINE_IS_DR1000SW
00161         { cb_sys_volume_mounted,   "        sysVolumeMounted",              NULL,              0 },
00162 #endif
00163         // signal handlers (broadcasted from given service)
00164         { cb_sys_battery_state,             "sysBatteryState",              DBUS_SERVICE_SYSTEM_CONTROL, 0 },
00165         { cb_sys_usb_state,                 "sysUsbState",                  DBUS_SERVICE_SYSTEM_CONTROL, 0 },
00166         { cb_sys_changed_locale,            "sysChangedLocale",             DBUS_SERVICE_SYSTEM_CONTROL, 0 },
00167         { cb_sys_changed_orientation,       "sysChangedOrientation",        DBUS_SERVICE_SYSTEM_CONTROL, 0 },
00168 #if MACHINE_IS_DR1000S || MACHINE_IS_DR1000SW
00169         { cb_sys_volume_mounted,            "sysVolumeMounted",             DBUS_SERVICE_SYSTEM_CONTROL, 0 },
00170         { cb_sys_volume_unmounted,          "sysVolumeUnmounted",           DBUS_SERVICE_SYSTEM_CONTROL, 0 },
00171 #endif    
00172         { cb_sys_signal_strength,           "sysSignalStrength",            DBUS_SERVICE_SYSTEM_CONTROL, 0 },
00173         // for testing
00174         { testing_list_menu_items_cb,       "testingListMenuItems",         NULL,                        0 },
00175         { testing_route_menu_item_cb,       "testingRouteToMenuItem",       NULL,                        0 },
00176         { NULL, NULL, NULL, 0 }
00177     };
00178 
00179 static gboolean g_enabled = TRUE;
00180 
00181     
00182 //============================================================================
00183 // Functions Implementation
00184 //============================================================================
00185 
00186 void ipc_set_services(void)
00187 {
00188     eripcClient = eripc_client_context_new(
00189                     DBUS_APPL_NAME,
00190                     "1.0",
00191                     DBUS_SERVICE,
00192                     DBUS_PATH,
00193                     DBUS_INTERFACE,
00194                     service_functions);    
00195     
00196     // allow two seconds for responses of synchronous (blocking) calls
00197     eripc_set_timeout(eripcClient->context, 2000);
00198 }
00199 
00200 
00201 void ipc_unset_services(void)
00202 {
00203     eripc_client_context_free(eripcClient, service_functions);
00204 }
00205 
00206 
00207 void ipc_send_task_activated(int xid)
00208 {
00209     eripc_error_t result = eripc_send_int(eripcClient->context, NULL, NULL,
00210             ERIPC_BUS_SESSION, DBUS_SERVICE_SYSTEM_CONTROL,
00211             "activateTask", xid);
00212     if (result != ERIPC_ERROR_SUCCESS) 
00213     {
00214         ERRORPRINTF("Error launching the eripc handler (%s)", eripc_error_string(result));
00215     }
00216 }
00217 
00218 
00219 void ipc_send_item_activated(const char *iname, const char *pname, const char *mname, const char *state, const char *service)
00220 {
00221     LOGPRINTF("Send menuItemActivated message to %s: %s, %s %s, state %s", 
00222               service, iname, pname, mname, state);
00223     
00224     eripc_error_t result = eripc_send_varargs(eripcClient->context, 
00225                                 NULL,
00226                                 NULL,
00227                                 ERIPC_BUS_SESSION,
00228                                 service,
00229                                 "menuItemActivated",
00230                                 ERIPC_TYPE_STRING, iname,
00231                                 ERIPC_TYPE_STRING, pname,
00232                                 ERIPC_TYPE_STRING, mname,
00233                                 ERIPC_TYPE_STRING, state,
00234                                 ERIPC_TYPE_INVALID);
00235     
00236     if (result != ERIPC_ERROR_SUCCESS) 
00237     {
00238         ERRORPRINTF("Error launching the eripc handler (%s)", eripc_error_string(result));
00239     }
00240 }
00241 
00242 
00243 // start task (application)
00244 gboolean ipc_sys_start_task ( const gchar  *cmd_line,
00245                               const gchar  *work_dir,
00246                               const gchar  *label,
00247                               const gchar  *thumbnail_path )
00248 {
00249     gboolean            ok = TRUE;    // return value
00250     eripc_error_t       result;
00251     eripc_event_info_t  *reply = NULL;
00252     const eripc_arg_t   *arg_array = NULL;
00253     int                 old_timeout = 0;
00254     gboolean            timeout_set = FALSE;
00255     
00256     WARNPRINTF("entry: cmd_line [%s] work_dir [%s] label [%s] thumbnail_path [%s]",
00257                        cmd_line,     work_dir,     label,     thumbnail_path       );
00258     g_assert( eripcClient->context );
00259     g_assert( cmd_line && *cmd_line );
00260     
00261     // set ipc timeout to "long"
00262     eripc_error_t eripc_get_timeout (eripc_context_t *context, int *timeout);
00263     result = eripc_get_timeout(eripcClient->context, &old_timeout);
00264     if (result == ERIPC_ERROR_SUCCESS)
00265     {
00266         result = eripc_set_timeout(eripcClient->context, 60*1000);
00267         if (result == ERIPC_ERROR_SUCCESS)
00268         {
00269             timeout_set = TRUE;
00270         }
00271     }
00272     
00273     result = eripc_send_varargs_and_wait( eripcClient->context,
00274                                           &reply,                // reply structure
00275                                           ERIPC_BUS_SESSION,
00276                                           DBUS_SERVICE_SYSTEM_CONTROL,
00277                                           "startTask",
00278                                           ERIPC_TYPE_STRING, cmd_line,
00279                                           ERIPC_TYPE_STRING, work_dir,
00280                                           ERIPC_TYPE_STRING, label,
00281                                           ERIPC_TYPE_STRING, thumbnail_path,
00282                                           ERIPC_TYPE_INVALID );
00283     
00284     if (result != ERIPC_ERROR_SUCCESS) 
00285     {
00286         ERRORPRINTF("eripc_send_varargs_and_wait returns [%d]", result);
00287     }
00288     else if (reply == NULL || reply->args == NULL)
00289     {
00290         ERRORPRINTF("sysd returns OK but no reply structure");
00291     }
00292     else
00293     {
00294         // parse the reply strcuture
00295         arg_array = reply->args;
00296         if (arg_array[0].type == ERIPC_TYPE_INT)
00297         {
00298             ok = arg_array[0].value.i;
00299         }
00300         else
00301         {
00302             ERRORPRINTF("unexpected argument: type [%d]", arg_array[0].type);
00303         }
00304     }    
00305     
00306     // restore ipc timeout
00307     if (timeout_set)
00308     {
00309         eripc_set_timeout(eripcClient->context, old_timeout);
00310     }
00311   
00312     LOGPRINTF("leave: ok [%d]", ok);
00313     return ok;
00314 }
00315 
00316 
00317 void ipc_sys_standby()
00318 {
00319     LOGPRINTF("entry");
00320     eripc_send_varargs(eripcClient->context,
00321                        NULL,
00322                        NULL,
00323                        ERIPC_BUS_SESSION,
00324                        DBUS_SERVICE_SYSTEM_CONTROL,
00325                        "sysStandby", 
00326                        ERIPC_TYPE_INVALID);
00327 }
00328 
00329 
00330 void ipc_send_request_popup(const char *state)
00331 {
00332     LOGPRINTF("entry state [%s]", state);
00333     eripc_sysd_set_menu_state(eripcClient, state);
00334 }
00335 
00336 
00337 void ipc_send_status_item_activated(const char *iname, const char *state, const char *service)
00338 {
00339     eripc_error_t result;
00340 
00341     LOGPRINTF("entry");
00342     
00343     result = eripc_send_varargs(eripcClient->context, 
00344                                 NULL,
00345                                 NULL,
00346                                 ERIPC_BUS_SESSION,
00347                                 service,
00348                                 "statusItemActivated",
00349                                 ERIPC_TYPE_STRING, iname,
00350                                 ERIPC_TYPE_STRING, state,
00351                                 ERIPC_TYPE_INVALID);
00352     
00353     LOGPRINTF("Sent statusItemActivated message to %s: %s, state %s", service, iname, state);
00354     
00355     if (result != ERIPC_ERROR_SUCCESS) 
00356     {
00357         ERRORPRINTF("Error launching the eripc handler (%s)", eripc_error_string(result));
00358     }
00359 }
00360 
00361 
00362 void ipc_send_startup_complete(void)
00363 {
00364     LOGPRINTF("entry");
00365     eripc_sysd_startup_complete(eripcClient, getpid(), FALSE, 0);
00366 }
00367 
00368 
00369 gboolean ipc_get_battery_state(gint *level, gchar **state, gint *timeleft)
00370 {
00371     eripc_error_t retval;
00372     eripc_event_info_t *info = NULL;
00373     gboolean result = FALSE;
00374     
00375     LOGPRINTF("entry");
00376     
00377     retval = eripc_send_varargs_and_wait(eripcClient->context,
00378                                          &info,
00379                                          ERIPC_BUS_SESSION,
00380                                          DBUS_SERVICE_SYSTEM_CONTROL,
00381                                          "sysGetBatteryState",
00382                                          ERIPC_TYPE_INVALID);
00383 
00384     if (retval == ERIPC_ERROR_SUCCESS) 
00385     {
00386         const eripc_arg_t *arg_array = info->args;
00387         
00388         if ((arg_array[0].type == ERIPC_TYPE_INT) && 
00389             (arg_array[1].type == ERIPC_TYPE_STRING) &&
00390             (arg_array[2].type == ERIPC_TYPE_INT))
00391         {
00392             *level = arg_array[0].value.i;
00393             *state = g_strdup(arg_array[1].value.s);
00394             if (timeleft != NULL)
00395             {
00396                 *timeleft = arg_array[2].value.i;
00397                 LOGPRINTF("Reply received: battery at %d%% %s, time left: %d", *level, *state, *timeleft);
00398             }
00399             else
00400             {
00401                 LOGPRINTF("Reply received: battery at %d%% %s", *level, *state);
00402             }
00403             
00404             result = TRUE;
00405         }
00406     }
00407     else
00408     {
00409         ERRORPRINTF("Error launching eripc handler: %s", eripc_error_string(retval));
00410     }
00411     
00412     eripc_event_info_free(eripcClient->context, info);
00413     return result;
00414 }
00415 
00416 
00417 gchar *ipc_get_orientation(void)
00418 {
00419     eripc_error_t retval;
00420     eripc_event_info_t *info = NULL;
00421     gchar *result = NULL;
00422     
00423     LOGPRINTF("entry");
00424     
00425     retval = eripc_send_varargs_and_wait(eripcClient->context,
00426                                          &info,
00427                                          ERIPC_BUS_SESSION,
00428                                          DBUS_SERVICE_SYSTEM_CONTROL,
00429                                          "sysGetOrientation",
00430                                          ERIPC_TYPE_INVALID);
00431 
00432     if (retval == ERIPC_ERROR_SUCCESS) 
00433     {
00434         const eripc_arg_t *arg_array = info->args;
00435         if (arg_array[0].type == ERIPC_TYPE_STRING)
00436         {
00437             result = g_strdup(arg_array[0].value.s);
00438         }
00439     }
00440     
00441     eripc_event_info_free(eripcClient->context, info);
00442     return result;
00443 }
00444 
00445 
00446 void ipc_set_orientation(const gchar *orientation)
00447 {
00448     LOGPRINTF("entry");
00449     
00450     eripc_error_t result = eripc_send_varargs(eripcClient->context,
00451                                             NULL,
00452                                             NULL,
00453                                             ERIPC_BUS_SESSION,
00454                                             DBUS_SERVICE_SYSTEM_CONTROL,
00455                                             "sysRotate",
00456                                             ERIPC_TYPE_STRING, orientation,
00457                                             ERIPC_TYPE_INVALID);
00458 
00459     if (result != ERIPC_ERROR_SUCCESS) 
00460     {
00461         ERRORPRINTF("Error launching the eripc handler (%s)", eripc_error_string(result));
00462     }
00463 }
00464 
00465 
00466 void ipc_send_page_change(const gchar* dir)
00467 {
00468     LOGPRINTF("entry");
00469     
00470     const gchar *service = menustore_get_current_service();
00471     if (service && (service[0]!='\0'))
00472     {
00473         eripc_error_t result = eripc_send_varargs(eripcClient->context,
00474                                                 NULL,
00475                                                 NULL,
00476                                                 ERIPC_BUS_SESSION,
00477                                                 service,
00478                                                 "pageChange",
00479                                                 ERIPC_TYPE_STRING, dir,
00480                                                 ERIPC_TYPE_INVALID);
00481 
00482         if (result != ERIPC_ERROR_SUCCESS) 
00483         {
00484             ERRORPRINTF("Error launching the eripc handler (%s)", eripc_error_string(result));
00485         }
00486     }
00487     else
00488     {
00489         LOGPRINTF("Current IPC service unknown");
00490     }
00491 }
00492 
00493 
00494 gboolean ipc_get_device_capabilities(gboolean *has_stylus, gboolean *has_wifi, gboolean *has_bluetooth, gboolean *has_3g) 
00495 {
00496     eripc_device_caps_t er_dev_caps;
00497     
00498     eripc_error_t result = eripc_sysd_get_device_capabilities(eripcClient, &er_dev_caps);
00499 
00500     if (result != ERIPC_ERROR_SUCCESS) 
00501     {
00502         return FALSE;
00503     }
00504     
00505     if (has_stylus)
00506     {
00507         *has_stylus = er_dev_caps.has_stylus;
00508     }
00509     
00510     if (has_wifi)
00511     {
00512         *has_wifi = er_dev_caps.has_wifi;
00513     }
00514     
00515     if (has_bluetooth)
00516     {
00517         *has_bluetooth = er_dev_caps.has_bluetooth;
00518     }
00519         
00520     if (has_3g)
00521     {
00522         *has_3g = er_dev_caps.has_3g;
00523     }
00524         
00525     return TRUE;    
00526 }
00527 
00528 
00529 void ipc_send_reply(eripc_context_t *context, const char *message_id, gboolean result)
00530 {
00531     LOGPRINTF("entry, reply %d", result);
00532     
00533     if (message_id)
00534     {
00535         LOGPRINTF("Sending reply %s to: %s, context %p", (result == TRUE ? "TRUE":"FALSE"), message_id, context);
00536 
00537         eripc_error_t retval = eripc_reply_bool(context, message_id, result);
00538         if (retval != ERIPC_ERROR_SUCCESS) 
00539         {
00540             ERRORPRINTF("Error sending reply to message: %s", eripc_error_string(retval));
00541         }
00542     }
00543     else
00544     {
00545         LOGPRINTF("Result is %s but no reply was requested", (result == TRUE ? "TRUE":"FALSE"));
00546     }
00547 }
00548 
00549 
00550 //============================================================================
00551 // Local Function Implementation
00552 //============================================================================
00553 
00554 static void add_group_cb(eripc_context_t *context,  const eripc_event_info_t *info, void *user_data)
00555 {
00556     const eripc_arg_t *arg_array = info->args;
00557     LOGPRINTF("entry");
00558     
00559     CHECK_ARG_STRING(0);
00560     CHECK_ARG_STRING(1);
00561     CHECK_ARG_STRING(2);
00562     CHECK_ARG_STRING(3);
00563     
00564     gboolean result = menustore_add_group(arg_array[0].value.s, 
00565                                      arg_array[1].value.s, 
00566                                      arg_array[2].value.s, 
00567                                      arg_array[3].value.s);
00568     ipc_send_reply(context, info->message_id, result);
00569 }
00570 
00571 
00572 static void add_item_cb(eripc_context_t *context, const eripc_event_info_t *info, void *user_data)
00573 {
00574     const eripc_arg_t *arg_array = info->args;
00575     LOGPRINTF("entry");
00576 
00577     CHECK_ARG_STRING(0);
00578     CHECK_ARG_STRING(1);
00579     CHECK_ARG_STRING(2);
00580     CHECK_ARG_STRING(3);
00581     gboolean result = menustore_add_item(arg_array[0].value.s, 
00582                                     arg_array[1].value.s, 
00583                                     arg_array[2].value.s, 
00584                                     arg_array[3].value.s);
00585     ipc_send_reply(context, info->message_id, result);
00586 }
00587 
00588 
00589 static void add_menu_cb(eripc_context_t *context,  const eripc_event_info_t *info, void *user_data)
00590 {
00591     const eripc_arg_t *arg_array = info->args;
00592     LOGPRINTF("entry");
00593     
00594     CHECK_ARG_STRING(0);
00595     CHECK_ARG_STRING(1);
00596     CHECK_ARG_STRING(2);
00597     CHECK_ARG_STRING(3);
00598     CHECK_ARG_STRING(4);
00599     CHECK_ARG_STRING(5);
00600     CHECK_ARG_STRING(6);
00601     gboolean result = menustore_add_menu(arg_array[0].value.s, 
00602                                     arg_array[1].value.s, 
00603                                     arg_array[2].value.s, 
00604                                     arg_array[3].value.s, 
00605                                     arg_array[4].value.s, 
00606                                     arg_array[5].value.s, 
00607                                     arg_array[6].value.s);
00608     ipc_send_reply(context, info->message_id, result);
00609 }
00610 
00611 
00612 static void add_task_cb(eripc_context_t *context, const eripc_event_info_t *info, void *user_data)
00613 {
00614     const eripc_arg_t *arg_array = info->args;
00615     LOGPRINTF("entry");
00616 
00617     CHECK_ARG_INT(0);
00618     CHECK_ARG_STRING(1);
00619 #if MACHINE_IS_DR1000S || MACHINE_IS_DR1000SW
00620     int xid = arg_array[0].value.i;
00621     const char* label =  arg_array[1].value.s;
00622     taskbar_add_task(xid, label);
00623 #endif
00624     ipc_send_reply(context, info->message_id, TRUE);
00625 }
00626 
00627 
00628 static void remove_group_cb(eripc_context_t *context,  const eripc_event_info_t *info, void *user_data)
00629 {
00630     const eripc_arg_t *arg_array = info->args;
00631     LOGPRINTF("entry");
00632 
00633     CHECK_ARG_STRING(0);
00634     gboolean result = menustore_remove_group(arg_array[0].value.s);
00635     ipc_send_reply(context, info->message_id, result);
00636 }
00637 
00638 
00639 static void remove_item_cb(eripc_context_t *context,  const eripc_event_info_t *info, void *user_data)
00640 {
00641     const eripc_arg_t *arg_array = info->args;
00642     LOGPRINTF("entry");
00643     
00644     CHECK_ARG_STRING(0);
00645     CHECK_ARG_STRING(1);
00646     gboolean result = menustore_remove_item(arg_array[0].value.s,
00647                                      arg_array[1].value.s);
00648     ipc_send_reply(context, info->message_id, result);
00649 }
00650 
00651 
00652 static void remove_menu_cb(eripc_context_t *context,  const eripc_event_info_t *info, void *user_data)
00653 {
00654     const eripc_arg_t *arg_array = info->args;
00655     LOGPRINTF("entry");
00656     
00657     CHECK_ARG_STRING(0);
00658     gboolean result = menustore_remove_menu(arg_array[0].value.s);
00659     ipc_send_reply(context, info->message_id, result);
00660 }
00661 
00662 
00663 static void remove_task_cb(eripc_context_t *context, const eripc_event_info_t *info, void *user_data)
00664 {
00665     const eripc_arg_t *arg_array = info->args;
00666     LOGPRINTF("entry");
00667     
00668     CHECK_ARG_INT(0);   // xid
00669 #if MACHINE_IS_DR1000S || MACHINE_IS_DR1000SW
00670     int xid = arg_array[0].value.i;
00671     taskbar_remove_task(xid);
00672 #endif
00673     ipc_send_reply(context, info->message_id, TRUE);
00674 }
00675 
00676 
00677 static void rename_task_cb(eripc_context_t *context, const eripc_event_info_t *info, void *user_data)
00678 {
00679     const eripc_arg_t *arg_array = info->args;
00680     LOGPRINTF("entry");
00681 
00682     CHECK_ARG_INT(0);       // xid
00683     CHECK_ARG_STRING(1);    // label
00684 #if MACHINE_IS_DR1000S || MACHINE_IS_DR1000SW
00685     taskbar_rename_task(arg_array[0].value.i, arg_array[1].value.s);
00686 #endif
00687 }
00688 
00689 
00690 static void set_task_to_top_cb(eripc_context_t *context, const eripc_event_info_t *info, void *user_data)
00691 {
00692     const eripc_arg_t *arg_array = info->args;
00693     LOGPRINTF("entry");
00694     
00695     CHECK_ARG_INT(0);
00696 #if MACHINE_IS_DR1000S || MACHINE_IS_DR1000SW
00697     int xid = arg_array[0].value.i;
00698     taskbar_select_task(xid);
00699 #endif
00700     ipc_send_reply(context, info->message_id, TRUE);
00701 }
00702 
00703 
00704 static void set_group_state_cb(eripc_context_t *context,  const eripc_event_info_t *info, void *user_data)
00705 {
00706     const eripc_arg_t *arg_array = info->args;
00707     LOGPRINTF("entry");
00708 
00709     CHECK_ARG_STRING(0);
00710     CHECK_ARG_STRING(1);
00711     gboolean result = menustore_set_group_state(arg_array[0].value.s, 
00712                                            arg_array[1].value.s);
00713     ipc_send_reply(context, info->message_id, result);
00714 }
00715 
00716 
00717 static void set_group_label_cb(eripc_context_t *context,  const eripc_event_info_t *info, void *user_data)
00718 {
00719     const eripc_arg_t *arg_array = info->args;
00720     LOGPRINTF("entry");
00721 
00722     CHECK_ARG_STRING(0);
00723     CHECK_ARG_STRING(1);
00724     gboolean result = menustore_set_group_label(arg_array[0].value.s, 
00725                                            arg_array[1].value.s);
00726     ipc_send_reply(context, info->message_id, result);
00727 }
00728 
00729 
00730 static void set_item_state_cb(eripc_context_t *context,  const eripc_event_info_t *info, void *user_data)
00731 {
00732     const eripc_arg_t *arg_array = info->args;
00733     LOGPRINTF("entry");
00734 
00735     CHECK_ARG_STRING(0);
00736     CHECK_ARG_STRING(1);
00737     CHECK_ARG_STRING(2);
00738     gboolean result = menustore_set_item_state(arg_array[0].value.s, 
00739                                           arg_array[1].value.s,
00740                                           arg_array[2].value.s);
00741     ipc_send_reply(context, info->message_id, result);
00742 }
00743 
00744 
00745 static void set_item_label_cb(eripc_context_t *context,  const eripc_event_info_t *info, void *user_data)
00746 {
00747     const eripc_arg_t *arg_array = info->args;
00748     LOGPRINTF("entry");
00749 
00750     CHECK_ARG_STRING(0);
00751     CHECK_ARG_STRING(1);
00752     CHECK_ARG_STRING(2);
00753     gboolean result = menustore_set_item_label(arg_array[0].value.s, 
00754                                           arg_array[1].value.s,
00755                                           arg_array[2].value.s);
00756     ipc_send_reply(context, info->message_id, result);
00757 }
00758 
00759 
00760 static void set_popup_show_cb(eripc_context_t *context,  const eripc_event_info_t *info, void *user_data)
00761 {
00762     const eripc_arg_t *arg_array = info->args;
00763     LOGPRINTF("entry");
00764 
00765     CHECK_ARG_STRING(0);
00766     gboolean result = popup_set_popup_show(arg_array[0].value.s);
00767     ipc_send_reply(context, info->message_id, result);
00768 }
00769 
00770 
00771 static void set_busy_show_cb(eripc_context_t *context,  const eripc_event_info_t *info, void *user_data)
00772 {
00773     const eripc_arg_t *arg_array = info->args;
00774     gboolean retval = FALSE;
00775     static gboolean should_unblock = FALSE;
00776     LOGPRINTF("entry");
00777     
00778     CHECK_ARG_STRING(0);
00779     if (g_ascii_strcasecmp(arg_array[0].value.s, "show") == 0) 
00780     {
00781         gchar *busy_msg = _("Please wait...");
00782 
00783         if ((arg_array[1].type == ERIPC_TYPE_STRING) 
00784          && (arg_array[1].value.s != NULL) 
00785          && (arg_array[1].value.s[0] != '\0'))
00786         {
00787             busy_msg = arg_array[1].value.s;
00788         }
00789 
00790         if (!popup_get_popup_block())
00791         {
00792             popup_set_popup_block(TRUE);
00793             should_unblock = TRUE;
00794         }
00795         popup_set_popup_show("hide");
00796         dialog_wait_show(busy_msg);
00797         retval = TRUE;
00798     }
00799     else if (g_ascii_strcasecmp(arg_array[0].value.s, "hide") == 0)
00800     {
00801         dialog_wait_close();
00802         if (should_unblock)
00803         {
00804             popup_set_popup_block(FALSE);
00805             should_unblock = FALSE;
00806         }
00807         retval = TRUE;
00808     }
00809     else
00810     {
00811         ERRORPRINTF("state unknown: %s", arg_array[0].value.s);
00812     }        
00813     ipc_send_reply(context, info->message_id, retval);
00814 }
00815 
00816 
00817 static void set_splash_show_cb(eripc_context_t *context,  const eripc_event_info_t *info, void *user_data)
00818 {
00819     const eripc_arg_t *arg_array = info->args;
00820     LOGPRINTF("entry");
00821     gboolean retval = FALSE;
00822     
00823     CHECK_ARG_STRING(0);
00824     if (strcmp(arg_array[0].value.s,"hide") == 0)
00825     {
00826         dialog_splash_remove();
00827     }
00828     else
00829     {
00830         retval = dialog_splash_show(arg_array[0].value.s);
00831     }
00832 
00833     ipc_send_reply(context, info->message_id, retval);
00834 }
00835 
00836 
00837 static void set_message_show_cb(eripc_context_t *context,  const eripc_event_info_t *info, void *user_data)
00838 {
00839     const eripc_arg_t *arg_array = info->args;
00840     LOGPRINTF("entry");
00841 
00842     CHECK_ARG_STRING(0);
00843     gchar *prompt = arg_array[0].value.s;
00844     GtkWidget *retval = NULL;
00845     if (g_ascii_strcasecmp(prompt, "udserror") == 0)
00846     {
00847         retval = dialog_message_info(GTK_MESSAGE_ERROR, NULL, _("An unexpected error has occurred; your documents must be closed."),
00848                                      context, info->message_id);
00849     }
00850     else if (g_ascii_strcasecmp(prompt, "indexerror") == 0)
00851     {
00852         retval = dialog_message_info(GTK_MESSAGE_ERROR, NULL, _("Thumbnails for one or more documents could not be generated; thumbnail generation has been aborted."),
00853                                      context, info->message_id);
00854     }
00855     else if (g_ascii_strcasecmp(prompt, "browsererror") == 0)
00856     {
00857         retval = dialog_message_info(GTK_MESSAGE_ERROR, NULL, _("An unexpected error has occurred; the web browser has been closed."),
00858                                      context, info->message_id);
00859     }
00860     else if (g_ascii_strcasecmp(prompt, "sdfullwarn") == 0)
00861     {
00862         retval = dialog_message_info(GTK_MESSAGE_WARNING, NULL, _("The SD card is almost full. You might want to delete files to free space."),
00863                                      context, info->message_id);
00864     }
00865     else if (g_ascii_strcasecmp(prompt, "flightmode") == 0)
00866     {
00867         retval = dialog_message_info(GTK_MESSAGE_WARNING, NULL, 
00868         _("Airplane mode is on and the device will not connect to networks.\n"
00869           "Turn airplane mode off by tapping on the icon at the bottom of the screen."),
00870                                      context, info->message_id);
00871     }
00872     else if (g_ascii_strcasecmp(prompt, "3glowconnect") == 0)
00873     {
00874         retval = dialog_message_info(GTK_MESSAGE_WARNING, NULL, 
00875         _("There is not sufficient battery power to access the network.\n"
00876           "Connect to a power source to charge."),
00877                                      context, info->message_id);
00878     }
00879     else if (g_ascii_strcasecmp(prompt, "3glowwarning") == 0)
00880     {
00881         retval = dialog_message_info(GTK_MESSAGE_WARNING, NULL, 
00882         _("The battery power is running low.\n"
00883           "Connect to a power source to continue using the network."),
00884                                      context, info->message_id);
00885     }
00886     else if (g_ascii_strcasecmp(prompt, "3glowdisconnected") == 0)
00887     {
00888         retval = dialog_message_info(GTK_MESSAGE_WARNING, NULL, 
00889         _("There is no longer sufficient battery power to continue using the network.\n"
00890           "The device is disconnected from the network."),
00891                                      context, info->message_id);
00892     }
00893     else if (g_ascii_strncasecmp(prompt, "3gcooloff_", strlen("3gcooloff_")) == 0)
00894     {
00895         retval = dialog_message_info(GTK_MESSAGE_WARNING, NULL, 
00896         _("Unable to connect to the network.\n"
00897           "Please try again in a couple of minutes."),
00898                                      context, info->message_id);
00899     }
00900     else if (g_ascii_strcasecmp(prompt, "3gsarlimit") == 0)
00901     {
00902         retval = dialog_message_info(GTK_MESSAGE_WARNING, NULL, 
00903         _("The network connection has been lost.\n"
00904           "Please try again in a couple of minutes."),
00905                                      context, info->message_id);
00906     }
00907     else if (g_ascii_strcasecmp(prompt, "hide") == 0)
00908     {
00909         dialog_message_info_close();
00910         ipc_send_reply(context, info->message_id, TRUE);
00911         return;
00912     }
00913     else
00914     {
00915         WARNPRINTF("unknown dialog request: %s", prompt);
00916     }
00917 
00918     // delay user response unless an error has occurred but return an error immediately
00919     if (retval == NULL)
00920     {
00921         ipc_send_reply(context, info->message_id, TRUE);
00922     }
00923 }
00924 
00925 
00926 static void show_menu_cb(eripc_context_t *context, const eripc_event_info_t *info, void *user_data)
00927 {
00928     const eripc_arg_t *arg_array = info->args;
00929     LOGPRINTF("entry");
00930 
00931     CHECK_ARG_STRING(0);
00932     menustore_set_current_menu(arg_array[0].value.s);
00933 #if MACHINE_IS_DR1000S || MACHINE_IS_DR1000SW
00934     statusbar_update_toolbar();
00935 #endif
00936     statusbar_hide_pagecounter();
00937     ipc_send_reply(context, info->message_id, TRUE);
00938 }
00939 
00940 
00941 static void set_statusitem_state_cb(eripc_context_t *context, const eripc_event_info_t *info, void *user_data)
00942 {
00943     const eripc_arg_t *arg_array = info->args;
00944     LOGPRINTF("entry");
00945 
00946     CHECK_ARG_STRING(0);
00947     CHECK_ARG_STRING(1);
00948     gboolean result = statusbar_item_set_state(arg_array[0].value.s,
00949                                           arg_array[1].value.s);
00950     ipc_send_reply(context, info->message_id, result);
00951 }
00952 
00953 
00954 static void set_statusitem_show_cb(eripc_context_t *context, const eripc_event_info_t *info, void *user_data)
00955 {
00956     const eripc_arg_t *arg_array = info->args;
00957     LOGPRINTF("entry");
00958 
00959     CHECK_ARG_STRING(0);
00960     CHECK_ARG_STRING(1);
00961     gboolean result = statusbar_item_show(arg_array[0].value.s, arg_array[1].value.s);
00962     ipc_send_reply(context, info->message_id, result);
00963 }
00964 
00965 
00966 static void update_page_counter_cb(eripc_context_t *context, const eripc_event_info_t *info, void *user_data)
00967 {
00968     const eripc_arg_t *arg_array = info->args;
00969     LOGPRINTF("entry");
00970 
00971     CHECK_ARG_INT(0);
00972     CHECK_ARG_INT(1);
00973 
00974     gint cur_page  = arg_array[0].value.i;
00975     gint num_pages = arg_array[1].value.i;
00976 
00977     // Boundary check is disabled temporary for reflowable documents, meanings
00978     // that the navigation arrows are not disabled on the first and last page,
00979     // because previous or next screens can still be available.
00980     gboolean boundary_check = TRUE;
00981     if (arg_array[2].type == ERIPC_TYPE_BOOL)
00982     {
00983         boundary_check = arg_array[2].value.b;
00984     }
00985 
00986     statusbar_update_pagecounter(cur_page, num_pages, boundary_check);
00987     ipc_send_reply(context, info->message_id, TRUE);
00988 }
00989 
00990 
00991 static void confirm_usbconnect_cb(eripc_context_t *context, const eripc_event_info_t *info, void *user_data)
00992 {
00993     const eripc_arg_t *arg_array = info->args;
00994     LOGPRINTF("entry");
00995 
00996     CHECK_ARG_STRING(0);
00997     static gboolean result = FALSE;
00998     if (g_ascii_strcasecmp(arg_array[0].value.s, "show") == 0) 
00999     {
01000         gchar *message = g_strconcat(_("Now Charging...\n"
01001                                        "\n"
01002                                        "Are you connecting to a computer in order to manage your device?\n"
01003                                        "(All open files and applications will be saved and closed when "
01004                                        "connecting).\n"),
01005                                     NULL);
01006         
01007         result = dialog_message_confirm(NULL, message, context, info->message_id, _("Cancel"), _("Connect"));
01008         g_free(message);
01009     }
01010     else if (g_ascii_strcasecmp(arg_array[0].value.s, "hide") == 0)
01011     {
01012         dialog_message_confirm_close();
01013         result = TRUE;
01014     }
01015     else
01016     {
01017         ERRORPRINTF("state unknown: %s", arg_array[0].value.s);
01018     }        
01019 
01020     // delay user response unless an error has occurred but return an error immediately
01021     if (result == FALSE)
01022     {
01023         ipc_send_reply(context, info->message_id, FALSE);
01024     }
01025 }
01026 
01027 
01028 static void confirm_install_drz_cb(eripc_context_t *context, const eripc_event_info_t *info, void *user_data)
01029 {
01030     const eripc_arg_t *arg_array = info->args;
01031     static gboolean result = FALSE;
01032     
01033     LOGPRINTF("entry");
01034     
01035     if ( (arg_array[0].type == ERIPC_TYPE_STRING) && (arg_array[0].value.s != NULL) )
01036     {
01037         if (g_ascii_strcasecmp(arg_array[0].value.s, "show") == 0) 
01038         {
01039             gchar *message = g_strconcat(_("New installable file(s) found.\n\n"),
01040                                          _("Do you wish to install now?"),
01041                                         NULL);
01042             
01043             result = dialog_message_confirm(NULL, message, context, info->message_id, _("Cancel"), _("Install"));
01044             g_free(message);
01045         }
01046         else if (g_ascii_strcasecmp(arg_array[0].value.s, "hide") == 0)
01047         {
01048             dialog_message_confirm_close();
01049             result = TRUE;
01050         }
01051         else
01052         {
01053             ERRORPRINTF("state unknown: %s", arg_array[0].value.s);
01054         }        
01055     }
01056 
01057     // delay user response unless an error has occurred but return an error immediately
01058     //
01059     if (result == FALSE)
01060     {
01061         ipc_send_reply(context, info->message_id, FALSE);
01062     }
01063 }
01064 
01065 
01066 static void confirm_install_update_cb(eripc_context_t *context, const eripc_event_info_t *info, void *user_data)
01067 {
01068     const eripc_arg_t *arg_array = info->args;
01069     LOGPRINTF("entry");
01070 
01071     CHECK_ARG_STRING(0);
01072     static gboolean result = FALSE;
01073     if (g_ascii_strcasecmp(arg_array[0].value.s, "show") == 0) 
01074     {
01075         gchar *message = g_strconcat(_("A new firmware update has been found. To install it, the device must be restarted.\n\n"),
01076                                      _("Do you wish to restart the device now?"),
01077                                     NULL);
01078         
01079         result = dialog_message_confirm(NULL, message, context, info->message_id, _("Cancel"), _("Restart"));
01080         g_free(message);
01081     }
01082     else if (g_ascii_strcasecmp(arg_array[0].value.s, "hide") == 0)
01083     {
01084         dialog_message_confirm_close();
01085         result = TRUE;
01086     }
01087     else
01088     {
01089         ERRORPRINTF("state unknown: %s", arg_array[0].value.s);
01090     }        
01091 
01092     // delay user response unless an error has occurred but return an error immediately
01093     //
01094     if (result == FALSE)
01095     {
01096         ipc_send_reply(context, info->message_id, FALSE);
01097     }
01098 }
01099 
01100 
01101 static void updates_finished_cb(eripc_context_t *context, const eripc_event_info_t *info, void *user_data)
01102 {
01103 #if MACHINE_IS_DR1000S || MACHINE_IS_DR1000SW
01104     statusbar_update_toolbar();
01105 #endif
01106     ipc_send_reply(context, info->message_id, TRUE);
01107 }
01108 
01109 
01110 static void cb_sys_battery_state(eripc_context_t *context, const eripc_event_info_t *info, void *user_data)
01111 {
01112     const eripc_arg_t *arg_array = info->args;
01113     LOGPRINTF("entry");
01114 
01115     CHECK_ARG_INT(0);
01116     CHECK_ARG_STRING(1);
01117     gint  level  = arg_array[0].value.i;
01118     gchar *state = arg_array[1].value.s;
01119 
01120     LOGPRINTF("Battery level %d, state %s", level, state);
01121 
01122     statusbar_update_battery_state(level, state);
01123     ipc_send_reply(context, info->message_id, FALSE);
01124 }
01125 
01126 
01127 static void cb_sys_signal_strength(eripc_context_t *context, const eripc_event_info_t *info, void *user_data)
01128 {
01129     const eripc_arg_t *arg_array = info->args;
01130     LOGPRINTF("entry");
01131 
01132     CHECK_ARG_INT(0);
01133     CHECK_ARG_STRING(1);
01134     gint  strength  = arg_array[0].value.i;
01135     gchar *medium = arg_array[1].value.s;
01136 
01137     LOGPRINTF("Signal strength on %s is %d", medium, strength);
01138 
01139     statusbar_update_signal_strength(medium, strength);
01140     ipc_send_reply(context, info->message_id, FALSE);
01141 }
01142 
01143 
01144 static void cb_sys_usb_state(eripc_context_t *context, const eripc_event_info_t *info, void *user_data)
01145 {
01146     const eripc_arg_t *arg_array = info->args;
01147     LOGPRINTF("entry");
01148 
01149     CHECK_ARG_STRING(0);
01150     gchar *state = arg_array[0].value.s;
01151     LOGPRINTF("USB state %s", state);
01152 
01153     if (g_ascii_strcasecmp(state, "mounted") == 0) 
01154     {
01155         popup_set_popup_block(TRUE);
01156     }
01157     else
01158     {
01159         popup_set_popup_block(FALSE);
01160     }
01161 }
01162 
01163 
01164 static void cb_sys_changed_locale(eripc_context_t *context, const eripc_event_info_t *info, void *user_data)
01165 {
01166     const eripc_arg_t *arg_array = info->args;
01167     LOGPRINTF("entry");
01168 
01169     CHECK_ARG_STRING(0);
01170 
01171     const char *locale = arg_array[0].value.s;
01172     const char *old_locale = g_getenv("LANG");
01173     if (!old_locale || (strcmp(old_locale, locale) != 0))
01174     {
01175         LOGPRINTF("Locale has changed to %s", locale);
01176 
01177         // set locale in environment 
01178         g_setenv("LANG", locale, TRUE);
01179         setlocale(LC_ALL, "");
01180 
01181         // update texts
01182         menustore_set_text();
01183         statusbar_set_text();
01184 #if MACHINE_IS_DR1000S || MACHINE_IS_DR1000SW
01185         taskbar_update_locale();
01186 #endif
01187     }
01188 }
01189 
01190 
01191 static void cb_sys_changed_orientation(eripc_context_t *context, const eripc_event_info_t *info, void *user_data)
01192 {
01193     const eripc_arg_t *arg_array = info->args;
01194     LOGPRINTF("entry");
01195 
01196     CHECK_ARG_STRING(0);
01197 
01198     const char* orientation = arg_array[0].value.s;
01199     if (orientation)
01200     {
01201         dialog_rotated(orientation);
01202     }
01203 }
01204 
01205 
01206 #if MACHINE_IS_DR1000S || MACHINE_IS_DR1000SW
01207 static void cb_sys_volume_mounted(eripc_context_t *context, const eripc_event_info_t *info, void *user_data)
01208 {
01209     const eripc_arg_t *arg_array = info->args;
01210     LOGPRINTF("entry");
01211 
01212     CHECK_ARG_STRING(0);
01213     char *volume = arg_array[0].value.s;
01214     LOGPRINTF("Volume mounted: %s", volume);
01215 
01216     if ((volume != NULL) && (strcmp(volume, "/media/mmcblk0p1") == 0))
01217     {
01218         menustore_set_item_state("eject_card", "system_bottom", "normal");
01219     }
01220 }
01221 
01222 
01223 static void cb_sys_volume_unmounted(eripc_context_t *context, const eripc_event_info_t *info, void *user_data)
01224 {
01225     const eripc_arg_t *arg_array = info->args;
01226     LOGPRINTF("entry");
01227 
01228     CHECK_ARG_STRING(0);
01229     char *volume = arg_array[0].value.s;
01230 
01231     LOGPRINTF("Volume unmounted: %s", volume);
01232     if ((volume != NULL) && (strcmp(volume, "/media/mmcblk0p1") == 0))
01233     {
01234         menustore_set_item_state("eject_card", "system_bottom", "disabled");
01235     }
01236 }
01237 #endif
01238 
01239 
01240 static void testing_list_menu_items_cb(eripc_context_t *context, const eripc_event_info_t *info, void *user_data)
01241 {
01242     const char* list = "no debug";
01243 #if (LOGGING_ON)
01244     testing_taskbar_print();
01245 #endif
01246 #if (TESTING_ON)
01247     list = testing_menustore_print();
01248 #endif
01249     eripc_reply_string(context, info->message_id, list);
01250 }
01251 
01252 
01253 static void testing_route_menu_item_cb(eripc_context_t *context, const eripc_event_info_t *info, void *user_data)
01254 {
01255     const char* route = "no debug";
01256 #if (TESTING_ON)
01257     const eripc_arg_t *arg_array = info->args;
01258     CHECK_ARG_STRING(0);
01259     CHECK_ARG_STRING(1);
01260     route = testing_menustore_get_route(arg_array[0].value.s, arg_array[1].value.s);
01261 #endif
01262     eripc_reply_string(context, info->message_id, route);
01263 }
01264 
01265 
01266 void ipc_set_enabled(gboolean enabled)
01267 {
01268     g_enabled = enabled;
01269 #if MACHINE_IS_DR1000S || MACHINE_IS_DR1000SW
01270     taskbar_enable(enabled);
01271 #endif
01272 }
01273 
01274 
01275 gboolean ipc_is_enabled(void)
01276 {
01277     return g_enabled;
01278 }
01279 
Generated by  doxygen 1.6.2-20100208