#include <liberipc/eripc.h>
Go to the source code of this file.
Defines | |
#define | DBUS_APPL_NAME PACKAGE_NAME |
#define | DBUS_SERVICE "com.irexnet." DBUS_APPL_NAME |
#define | DBUS_PATH "/com/irexnet/" DBUS_APPL_NAME |
#define | DBUS_INTERFACE "com.irexnet." DBUS_APPL_NAME |
#define | DBUS_SERVICE_SYSTEM_CONTROL "com.irexnet.sysd" |
#define | DBUS_SERVICE_CTB "com.irexnet.ctb" |
Functions | |
void | ipc_set_services (void) |
Setup IPC connection and register API functions. | |
void | ipc_unset_services (void) |
Unregister API functions. | |
void | ipc_send_task_activated (int xid) |
void | ipc_send_item_activated (const char *iname, const char *pname, const char *mname, const char *state, const char *service) |
Send menuItemActivated to service. | |
void | ipc_send_status_item_activated (const char *iname, const char *state, const char *service) |
Send statusItemActivated to service. | |
void | ipc_send_startup_complete (void) |
Send startupComplete. | |
gboolean | ipc_sys_start_task (const gchar *cmd_line, const gchar *work_dir, const gchar *label, const gchar *thumbnail_path) |
Send message startTask to system control, usually to open a document in the relevant viewer application. | |
gboolean | ipc_get_battery_state (gint *level, gchar **state, gint *timeleft) |
Get current battery state and level and update statusbar icon. | |
void | ipc_send_page_change (const gchar *dir) |
void | ipc_send_reply (eripc_context_t *context, const char *message_id, gboolean result) |
gboolean | ipc_get_device_capabilities (gboolean *has_stylus, gboolean *has_wifi, gboolean *has_bluetooth, gboolean *has_3g) |
void | ipc_send_request_popup (const char *state) |
void | ipc_set_enabled (gboolean enabled) |
gboolean | ipc_is_enabled (void) |
gchar * | ipc_get_orientation (void) |
void | ipc_set_orientation (const gchar *orientation) |
void | ipc_sys_standby (void) |
#define DBUS_APPL_NAME PACKAGE_NAME |
File Name : ipc.h
Description: The dbus-based eripc functions Copyright (C) 2008 iRex Technologies B.V. All rights reserved.
Definition at line 47 of file popupmenu/include/ipc.h.
#define DBUS_INTERFACE "com.irexnet." DBUS_APPL_NAME |
Definition at line 50 of file popupmenu/include/ipc.h.
#define DBUS_PATH "/com/irexnet/" DBUS_APPL_NAME |
Definition at line 49 of file popupmenu/include/ipc.h.
#define DBUS_SERVICE "com.irexnet." DBUS_APPL_NAME |
Definition at line 48 of file popupmenu/include/ipc.h.
#define DBUS_SERVICE_CTB "com.irexnet.ctb" |
Definition at line 53 of file popupmenu/include/ipc.h.
#define DBUS_SERVICE_SYSTEM_CONTROL "com.irexnet.sysd" |
Definition at line 52 of file popupmenu/include/ipc.h.
gboolean ipc_get_battery_state | ( | gint * | level, | |
gchar ** | state, | |||
gint * | timeleft | |||
) |
Get current battery state and level and update statusbar icon.
---------------------------------------------------------------------------
Name : ipc_get_battery_state
[out] | level | Current battery level |
[out] | state | Current charging state, string must be freed |
[out] | timeleft | Minutes to empty (discharing) of -1 (charging) |
--------------------------------------------------------------------------
Definition at line 369 of file popupmenu/src/ipc.c.
Referenced by handle_status_item(), main(), and on_check_low_battery().
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 }
gboolean ipc_get_device_capabilities | ( | gboolean * | has_stylus, | |
gboolean * | has_wifi, | |||
gboolean * | has_bluetooth, | |||
gboolean * | has_3g | |||
) |
Definition at line 494 of file popupmenu/src/ipc.c.
References ERIPC_ERROR_SUCCESS, eripc_sysd_get_device_capabilities(), eripc_device_caps_t::has_3g, eripc_device_caps_t::has_bluetooth, eripc_device_caps_t::has_stylus, and eripc_device_caps_t::has_wifi.
Referenced by add_system_status_items(), and main().
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 }
gchar* ipc_get_orientation | ( | void | ) |
Definition at line 417 of file popupmenu/src/ipc.c.
References eripc_event_info_t::args, eripc_client_context_t::context, DBUS_SERVICE_SYSTEM_CONTROL, ERIPC_BUS_SESSION, ERIPC_ERROR_SUCCESS, eripc_event_info_free(), eripc_send_varargs_and_wait(), ERIPC_TYPE_INVALID, ERIPC_TYPE_STRING, LOGPRINTF, and eripc_arg_t::s.
Referenced by dialog_create().
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 }
gboolean ipc_is_enabled | ( | void | ) |
Definition at line 1275 of file popupmenu/src/ipc.c.
References g_enabled.
Referenced by on_leftbutton_press(), on_popup_button_press(), on_rightbutton_press(), and status_pressed_event().
01276 { 01277 return g_enabled; 01278 }
void ipc_send_item_activated | ( | const char * | iname, | |
const char * | pname, | |||
const char * | mname, | |||
const char * | state, | |||
const char * | service | |||
) |
Send menuItemActivated to service.
---------------------------------------------------------------------------
Name : ipc_send_item_activated
iname | Item name | |
pname | Parent group name | |
mname | Current menu name | |
state | Current state of the menu item | |
service | IPC service name |
--------------------------------------------------------------------------
Definition at line 219 of file popupmenu/src/ipc.c.
References eripc_client_context_t::context, ERIPC_BUS_SESSION, eripc_error_string(), ERIPC_ERROR_SUCCESS, eripc_send_varargs(), ERIPC_TYPE_INVALID, ERIPC_TYPE_STRING, ERRORPRINTF, and LOGPRINTF.
Referenced by handle_status_item(), and on_item_activate().
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 }
void ipc_send_page_change | ( | const gchar * | dir | ) |
Definition at line 466 of file popupmenu/src/ipc.c.
References eripc_client_context_t::context, ERIPC_BUS_SESSION, eripc_error_string(), ERIPC_ERROR_SUCCESS, eripc_send_varargs(), ERIPC_TYPE_INVALID, ERIPC_TYPE_STRING, ERRORPRINTF, LOGPRINTF, menustore_get_current_service(), and service.
Referenced by on_leftbutton_press(), and on_rightbutton_press().
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 }
void ipc_send_reply | ( | eripc_context_t * | context, | |
const char * | message_id, | |||
gboolean | result | |||
) |
Definition at line 529 of file popupmenu/src/ipc.c.
Referenced by add_group_cb(), add_item_cb(), add_menu_cb(), add_task_cb(), cb_closed_window(), cb_conn_add_profile(), cb_conn_connect(), cb_conn_disconnect(), cb_conn_edit_profile(), cb_conn_signal(), cb_conn_status(), cb_conn_status_request(), cb_menu_item_activated(), cb_menu_request_popup(), cb_opened_window(), cb_sys_battery_state(), cb_sys_beep(), cb_sys_card_mount(), cb_sys_card_unmount(), cb_sys_lock_sensors(), cb_sys_reset_bg_busy(), cb_sys_reset_fg_busy(), cb_sys_rotate(), cb_sys_set_bg_busy(), cb_sys_set_busy_led(), cb_sys_set_fg_busy(), cb_sys_set_keyboard(), cb_sys_set_stylus(), cb_sys_shutdown(), cb_sys_signal_strength(), cb_sys_standby(), cb_task_activate(), cb_task_rename(), cb_task_stop(), confirm_install_drz_cb(), confirm_install_update_cb(), confirm_usbconnect_cb(), on_dialog_close(), on_dialog_response(), on_window_close_callback(), remove_group_cb(), remove_item_cb(), remove_menu_cb(), remove_task_cb(), set_busy_show_cb(), set_group_label_cb(), set_group_state_cb(), set_item_label_cb(), set_item_state_cb(), set_message_show_cb(), set_popup_show_cb(), set_splash_show_cb(), set_statusitem_show_cb(), set_statusitem_state_cb(), set_task_to_top_cb(), show_menu_cb(), task_stop(), update_page_counter_cb(), and updates_finished_cb().
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 }
void ipc_send_request_popup | ( | const char * | state | ) |
Definition at line 330 of file popupmenu/src/ipc.c.
References eripc_sysd_set_menu_state(), and LOGPRINTF.
Referenced by dialog_message_confirm(), dialog_message_confirm_destroy(), dialog_message_info(), dialog_message_info_destroy(), dialog_splash_remove(), on_popup_button_press(), and show_splash().
00331 { 00332 LOGPRINTF("entry state [%s]", state); 00333 eripc_sysd_set_menu_state(eripcClient, state); 00334 }
void ipc_send_startup_complete | ( | void | ) |
Send startupComplete.
---------------------------------------------------------------------------
Name : ipc_send_startup_complete
-- |
--------------------------------------------------------------------------
Definition at line 362 of file popupmenu/src/ipc.c.
References eripc_sysd_startup_complete(), and LOGPRINTF.
Referenced by on_startup_complete().
00363 { 00364 LOGPRINTF("entry"); 00365 eripc_sysd_startup_complete(eripcClient, getpid(), FALSE, 0); 00366 }
void ipc_send_status_item_activated | ( | const char * | iname, | |
const char * | state, | |||
const char * | service | |||
) |
Send statusItemActivated to service.
---------------------------------------------------------------------------
Name : ipc_send_status_item_activated
iname | Status item name | |
state | Current state of the menu item | |
service | IPC service name |
--------------------------------------------------------------------------
Definition at line 337 of file popupmenu/src/ipc.c.
References eripc_client_context_t::context, ERIPC_BUS_SESSION, eripc_error_string(), ERIPC_ERROR_SUCCESS, eripc_send_varargs(), ERIPC_TYPE_INVALID, ERIPC_TYPE_STRING, ERRORPRINTF, and LOGPRINTF.
Referenced by handle_status_item().
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 }
void ipc_send_task_activated | ( | int | xid | ) |
Definition at line 207 of file popupmenu/src/ipc.c.
References eripc_client_context_t::context, DBUS_SERVICE_SYSTEM_CONTROL, ERIPC_BUS_SESSION, eripc_error_string(), ERIPC_ERROR_SUCCESS, eripc_send_int(), and ERRORPRINTF.
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 }
void ipc_set_enabled | ( | gboolean | enabled | ) |
Definition at line 1266 of file popupmenu/src/ipc.c.
References g_enabled.
Referenced by popup_set_popup_show().
01267 { 01268 g_enabled = enabled; 01269 #if MACHINE_IS_DR1000S || MACHINE_IS_DR1000SW 01270 taskbar_enable(enabled); 01271 #endif 01272 }
void ipc_set_orientation | ( | const gchar * | orientation | ) |
Definition at line 446 of file popupmenu/src/ipc.c.
References eripc_client_context_t::context, DBUS_SERVICE_SYSTEM_CONTROL, ERIPC_BUS_SESSION, eripc_error_string(), ERIPC_ERROR_SUCCESS, eripc_send_varargs(), ERIPC_TYPE_INVALID, ERIPC_TYPE_STRING, ERRORPRINTF, and LOGPRINTF.
Referenced by dialog_splash_remove(), and show_splash().
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 }
void ipc_set_services | ( | void | ) |
Setup IPC connection and register API functions.
---------------------------------------------------------------------------
Name : ipc_set_services
-- |
--------------------------------------------------------------------------
File Name : index_ipc.h
Description: The dbus-based eripc functions Copyright (C) 2009 IREX Technologies B.V. All rights reserved.---------------------------------------------------------------------------
Name : ipc_set_services
None |
--------------------------------------------------------------------------
Definition at line 95 of file index_ipc.c.
00096 { 00097 eripcClient = eripc_client_context_new( 00098 DBUS_APPL_NAME, 00099 "1.0", 00100 DBUS_SERVICE, 00101 DBUS_PATH, 00102 DBUS_INTERFACE, 00103 service_functions); 00104 }
void ipc_sys_standby | ( | void | ) |
Definition at line 317 of file popupmenu/src/ipc.c.
References eripc_client_context_t::context, DBUS_SERVICE_SYSTEM_CONTROL, ERIPC_BUS_SESSION, eripc_send_varargs(), ERIPC_TYPE_INVALID, and LOGPRINTF.
Referenced by on_menu_key_press().
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 }
gboolean ipc_sys_start_task | ( | const gchar * | cmd_line, | |
const gchar * | work_dir, | |||
const gchar * | label, | |||
const gchar * | thumbnail_path | |||
) |
Send message startTask to system control, usually to open a document in the relevant viewer application.
---------------------------------------------------------------------------
Name : ipc_sys_start_task
[in] | cmd_line | - command-line to launch the task (executable + options) |
[in] | work_dir | - working directory in which to start this task |
[in] | label | - text to show in popup menu |
[in] | thumbnail_path | - the file containing the thumbnail to show in popup menu |
--------------------------------------------------------------------------
Definition at line 244 of file popupmenu/src/ipc.c.
References eripc_event_info_t::args, eripc_client_context_t::context, DBUS_SERVICE_SYSTEM_CONTROL, ERIPC_BUS_SESSION, ERIPC_ERROR_SUCCESS, eripc_get_timeout(), eripc_send_varargs_and_wait(), eripc_set_timeout(), ERIPC_TYPE_INT, ERIPC_TYPE_INVALID, ERIPC_TYPE_STRING, ERRORPRINTF, eripc_arg_t::i, LOGPRINTF, eripc_arg_t::value, and WARNPRINTF.
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 }
void ipc_unset_services | ( | void | ) |
Unregister API functions.
---------------------------------------------------------------------------
Name : ipc_unset_services
-- |
--------------------------------------------------------------------------
Definition at line 108 of file index_ipc.c.
00109 { 00110 eripc_client_context_free(eripcClient, service_functions); 00111 }