support.c File Reference

This file implements a variety of support wrapper functionality. More...

#include "internal.h"
#include "eripc_support.h"
Include dependency graph for support.c:

Go to the source code of this file.

Defines

#define DBUS_SERVICE_SYSTEM_CONTROL   "com.irexnet.sysd"
#define DBUS_SERVICE_POPUP_MENU   "com.irexnet.popupmenu"
#define MAKE_VARARG_CALL(destination, message,...)
#define MAKE_VARARG_CALL_1S(destination, message, s1)
#define MAKE_VARARG_CALL_2S(destination, message, s1, s2)
#define MAKE_VARARG_CALL_3S(destination, message, s1, s2, s3)
#define MAKE_SIGNAL_VARARG_CALL(interface, message,...)
#define MAKE_VARARG_WAIT_CALL(interface, message, reply_parser,...)
#define MAKE_BUSY_TIMEOUT_START(seconds)
#define MAKE_BUSY_TIMEOUT_END()

Functions

static int parse_reply_capabilities (eripc_event_info_t *reply, eripc_device_caps_t *dev_caps)
static int parse_reply_start (eripc_event_info_t *reply, char **err_message)
static char * fix_name (const char *raw_name)
eripc_client_context_teripc_client_context_new (const char *raw_name, const char *version, const char *raw_service, const char *raw_path, const char *raw_interface, eripc_callback_function_t *callbacks)
void eripc_client_context_free (eripc_client_context_t *ccontext, eripc_callback_function_t *callbacks)
const gchar * eripc_error_string (eripc_error_t errorcode)
gboolean eripc_menu_add_menu (eripc_client_context_t *ccontext, const char *name, const char *group1, const char *group2, const char *group3, const char *group4)
gboolean eripc_menu_remove_menu (eripc_client_context_t *ccontext, const char *name)
gboolean eripc_menu_add_group (eripc_client_context_t *ccontext, const char *name, const char *parent, const char *image)
gboolean eripc_menu_add_item (eripc_client_context_t *ccontext, const char *name, const char *parent, const char *image)
gboolean eripc_menu_set_menu_label (eripc_client_context_t *ccontext, const char *name, const char *label)
gboolean eripc_menu_set_group_label (eripc_client_context_t *ccontext, const char *name, const char *label)
gboolean eripc_menu_set_item_label (eripc_client_context_t *ccontext, const char *name, const char *parent, const char *label)
gboolean eripc_menu_show_menu (eripc_client_context_t *ccontext, const char *name)
gboolean eripc_menu_set_group_state (eripc_client_context_t *ccontext, const char *name, const char *state)
gboolean eripc_menu_set_item_state (eripc_client_context_t *ccontext, const char *name, const char *parent, const char *state)
gboolean eripc_menu_set_pagecounter (eripc_client_context_t *ccontext, int cur_page, int num_pages, gboolean boundary_check)
gboolean eripc_menu_set_statusitem_state (eripc_client_context_t *ccontext, const char *item, const char *state)
gboolean eripc_sysd_set_menu_state (eripc_client_context_t *ccontext, const char *state)
gboolean eripc_sysd_mount_sd_card (eripc_client_context_t *ccontext, gboolean show_index_splash)
gboolean eripc_sysd_unmount_sd_card (eripc_client_context_t *ccontext)
gboolean eripc_sysd_set_busy (eripc_client_context_t *ccontext, const char *state, const char *message)
gboolean eripc_sysd_reset_busy (eripc_client_context_t *ccontext)
gboolean eripc_sysd_set_bg_busy (eripc_client_context_t *ccontext)
gboolean eripc_sysd_reset_bg_busy (eripc_client_context_t *ccontext)
gboolean eripc_sysd_set_keyboard (eripc_client_context_t *ccontext, const char *state)
gboolean eripc_sysd_startup_complete (eripc_client_context_t *ccontext, const int pid, const gboolean is_multidoc, const int xid)
gint eripc_sysd_start_task (eripc_client_context_t *ccontext, const gchar *cmd_line, const gchar *work_dir, const gchar *label, const gchar *thumbnail_path, gchar **err_message)
gboolean eripc_sysd_stop_task (eripc_client_context_t *ccontext, const char *cmd_line)
gint eripc_sysd_open_url (eripc_client_context_t *ccontext, const gchar *url, const gchar *label, const gchar *back_text, gchar **err_message)
gboolean eripc_sysd_get_device_capabilities (eripc_client_context_t *ccontext, eripc_device_caps_t *caps)
gboolean eripc_sysd_conn_connect (eripc_client_context_t *ccontext, const char *medium, const char *profile)
gboolean eripc_sysd_conn_disconnect (eripc_client_context_t *ccontext)
gboolean eripc_sysd_conn_status_request (eripc_client_context_t *ccontext)

Detailed Description

This file implements a variety of support wrapper functionality.

Definition in file support.c.


Define Documentation

#define DBUS_SERVICE_POPUP_MENU   "com.irexnet.popupmenu"

Definition at line 34 of file support.c.

#define DBUS_SERVICE_SYSTEM_CONTROL   "com.irexnet.sysd"

Copyright (C) 2008 iRex Technologies B.V. All rights reserved.

Based on code found in libosso library by Kimmo Hämäläinen <kimmo.hamalainen@nokia.com>

Definition at line 33 of file support.c.

 
#define MAKE_BUSY_TIMEOUT_END (  ) 
Value:
{                                                          \
    if (timeout_set)                                       \
        eripc_set_timeout(ccontext->context, old_timeout); \
}

Reset busy and change IPC timeout back to original value before the matching MAKE_BUSY_TIMEOUT_START()

Definition at line 156 of file support.c.

Referenced by eripc_sysd_open_url(), and eripc_sysd_start_task().

#define MAKE_BUSY_TIMEOUT_START ( seconds   ) 
Value:
{                                                                      \
    result = eripc_get_timeout(ccontext->context, &old_timeout);       \
    if (result == ERIPC_ERROR_SUCCESS)                                 \
    {                                                                  \
        result = eripc_set_timeout(ccontext->context, (seconds)*1000); \
        timeout_set = (result == ERIPC_ERROR_SUCCESS);                 \
    }                                                                  \
}

Set busy and change IPC timeout to seconds. Pair with MAKE_BUSY_TIMEOUT_END()

Definition at line 142 of file support.c.

Referenced by eripc_sysd_open_url(), and eripc_sysd_start_task().

#define MAKE_SIGNAL_VARARG_CALL ( interface,
message,
...   ) 
Value:
{                                                                       \
    g_assert( ccontext );                                               \
    if (eripc_send_signal_varargs(                                      \
                ccontext->context,                                      \
                ERIPC_BUS_SESSION,                                      \
                ccontext->path,                                         \
                interface,                                              \
                message,                                                \
                __VA_ARGS__) != ERIPC_ERROR_SUCCESS)                    \
    {                                                                   \
        ULOG_DEBUG_F("eripc_send_signal_varargs failed"); \
        return FALSE;                                                   \
    }                                                                   \
    return TRUE;                                                        \
}

Make a simple function body that calls eripc_send_signal_varargs. Checks the return value and returns TRUE on success, FALSE otherwise

Expects a eripc_client_context_t* ccontext local available.

Definition at line 97 of file support.c.

Referenced by eripc_sysd_startup_complete().

#define MAKE_VARARG_CALL ( destination,
message,
...   ) 
Value:
{                                                                 \
    g_assert( ccontext );                                         \
    if (eripc_send_varargs(                                       \
                ccontext->context,                                \
                NULL,                                             \
                NULL,                                             \
                ERIPC_BUS_SESSION,                                \
                destination,                                      \
                message,                                          \
                __VA_ARGS__) != ERIPC_ERROR_SUCCESS)              \
    {                                                             \
        ULOG_DEBUG_F("eripc_send_varargs failed");  \
        return FALSE;                                             \
    }                                                             \
    return TRUE;                                                  \
}

Make a simple function body that calls eripc_send_varargs. Checks the return value and returns TRUE on success, FALSE otherwise

Expects a eripc_client_context_t* ccontext local available.

Definition at line 46 of file support.c.

Referenced by eripc_menu_add_group(), eripc_menu_add_item(), eripc_menu_add_menu(), eripc_menu_set_pagecounter(), eripc_sysd_mount_sd_card(), eripc_sysd_reset_bg_busy(), eripc_sysd_reset_busy(), eripc_sysd_set_bg_busy(), and eripc_sysd_unmount_sd_card().

#define MAKE_VARARG_CALL_1S ( destination,
message,
s1   ) 
Value:
MAKE_VARARG_CALL(destination, message,            \
                     ERIPC_TYPE_STRING, s1,           \
                     ERIPC_TYPE_INVALID);

Convenience function for the common case of MAKE_VARARG_CALL with one string arg

Definition at line 67 of file support.c.

Referenced by eripc_menu_remove_menu(), eripc_menu_show_menu(), eripc_sysd_conn_disconnect(), eripc_sysd_conn_status_request(), eripc_sysd_set_keyboard(), eripc_sysd_set_menu_state(), and eripc_sysd_stop_task().

#define MAKE_VARARG_CALL_2S ( destination,
message,
s1,
s2   ) 
Value:

Convenience function for the common case of MAKE_VARARG_CALL with two string args

Definition at line 75 of file support.c.

Referenced by eripc_menu_set_group_label(), eripc_menu_set_group_state(), eripc_menu_set_menu_label(), eripc_menu_set_statusitem_state(), and eripc_sysd_set_busy().

#define MAKE_VARARG_CALL_3S ( destination,
message,
s1,
s2,
s3   ) 
Value:

Convenience function for the common case of MAKE_VARARG_CALL with three string args

Definition at line 84 of file support.c.

Referenced by eripc_menu_set_item_label(), eripc_menu_set_item_state(), and eripc_sysd_conn_connect().

#define MAKE_VARARG_WAIT_CALL ( interface,
message,
reply_parser,
...   ) 
Value:
{                                                                             \
    eripc_event_info_t *reply = NULL;                                         \
    result = eripc_send_varargs_and_wait(                                     \
                                ccontext->context,                            \
                                &reply,                                       \
                                ERIPC_BUS_SESSION,                            \
                                interface,                                    \
                                message,                                      \
                                __VA_ARGS__);                                 \
    if (result != ERIPC_ERROR_SUCCESS)                                        \
        ULOG_DEBUG_F("eripc_send_varargs_and_wait failed");     \
    else if (reply == NULL || reply->args == NULL)                            \
        ULOG_DEBUG_F("sysd returns OK but no reply structure"); \
    else                                                                      \
        retval = reply_parser;                                                \
    eripc_event_info_free(ccontext->context, reply);                          \
}

Make a function body that calls eripc_send_varargs_and_wait. Parse the reply using the reply_parser function.

Expects eripc_client_context_t* ccontext, int retval, char** err_message locals available.

Definition at line 120 of file support.c.

Referenced by eripc_sysd_get_device_capabilities(), eripc_sysd_open_url(), and eripc_sysd_start_task().


Function Documentation

static char* fix_name ( const char *  raw_name  )  [static]

Definition at line 166 of file support.c.

References name, and ULOG_CRIT_F.

Referenced by eripc_client_context_new().

00167 {
00168     char *name = strdup(raw_name);
00169     if (name == NULL) {
00170         ULOG_CRIT_F("fix_name failed: out of memory");
00171         return NULL;
00172     }
00173     
00174     // replace dashes (-) with underscores (_) as dbus chokes on dashes
00175     unsigned int i;
00176     for (i=0; i<strlen(name); i++)
00177     {
00178         if (name[i] == '-')
00179             name[i] = '_';
00180     }
00181     return name;
00182 }

Here is the caller graph for this function:

static int parse_reply_capabilities ( eripc_event_info_t reply,
eripc_device_caps_t dev_caps 
) [static]

Definition at line 585 of file support.c.

References eripc_event_info_t::args, eripc_arg_t::b, ERIPC_TYPE_BOOL, ERIPC_TYPE_INVALID, eripc_device_caps_t::has_3g, eripc_device_caps_t::has_bluetooth, eripc_device_caps_t::has_stylus, eripc_device_caps_t::has_wifi, eripc_arg_t::type, ULOG_DEBUG_F, and eripc_arg_t::value.

Referenced by eripc_sysd_get_device_capabilities().

00586 {
00587     int i; 
00588     gboolean ok = TRUE;
00589     const eripc_arg_t *arg = NULL;
00590 
00591     // parse the reply strcuture
00592     for ( i = 0, arg = reply->args ;
00593                  arg->type != ERIPC_TYPE_INVALID ;
00594           i++,   arg++ )
00595     {
00596         ok = FALSE;
00597         switch (i)
00598         {
00599             case 0:
00600                 if (arg->type == ERIPC_TYPE_BOOL)
00601                 {
00602                     dev_caps->has_stylus = arg->value.b ? TRUE : FALSE;
00603                     ok = TRUE;
00604                 }
00605                 break;
00606             case 1:
00607                 if (arg->type == ERIPC_TYPE_BOOL)
00608                 {
00609                     dev_caps->has_wifi = arg->value.b ? TRUE : FALSE;
00610                     ok = TRUE;
00611                 }
00612                 break;
00613             case 2:
00614                 if (arg->type == ERIPC_TYPE_BOOL)
00615                 {
00616                     dev_caps->has_bluetooth = arg->value.b ? TRUE : FALSE;
00617                     ok = TRUE;
00618                 }
00619                 break;
00620             case 3:
00621                 if (arg->type == ERIPC_TYPE_BOOL)
00622                 {
00623                     dev_caps->has_3g = arg->value.b ? TRUE : FALSE;
00624                     ok = TRUE;
00625                 }
00626                 break;
00627             default:
00628                 ; // ignore
00629         }
00630         if (!ok)
00631         {
00632             ULOG_DEBUG_F("unexpected argument");
00633         }
00634     }
00635     return ok ? 0 : 1;
00636 }

Here is the caller graph for this function:

static int parse_reply_start ( eripc_event_info_t reply,
char **  err_message 
) [static]

Parse the reply from an "startTask" or "openUrl" eripc calls

Definition at line 511 of file support.c.

References eripc_event_info_t::args, ERIPC_TYPE_INT, ERIPC_TYPE_STRING, eripc_arg_t::i, eripc_arg_t::s, eripc_arg_t::type, ULOG_DEBUG_F, and eripc_arg_t::value.

Referenced by eripc_sysd_open_url(), and eripc_sysd_start_task().

00512 {
00513     int retval = 0;
00514     if (reply->args[0].type == ERIPC_TYPE_INT) 
00515     {
00516         retval = reply->args[0].value.i;
00517         if (reply->args[1].type == ERIPC_TYPE_STRING) 
00518         {
00519             gchar *message = reply->args[1].value.s;
00520             if ( (message != NULL) && (err_message != NULL))
00521             {
00522                 *err_message = g_strdup(message);
00523             }
00524         }
00525     }
00526     else
00527     {
00528         ULOG_DEBUG_F("unexpected reply argument");
00529     }
00530     return retval;
00531 }

Here is the caller graph for this function:

Generated by  doxygen 1.6.2-20100208