[maemo-commits] [maemo-commits] r19041 - in projects/haf/trunk/libosso: debian src
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Wed Aug 5 09:24:30 EEST 2009
- Previous message: [maemo-commits] r19040 - in projects/haf/trunk/hildon-control-panel: debian src
- Next message: [maemo-commits] r19042 - projects/haf/trunk/clutter0.8/debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: kihamala Date: 2009-08-05 09:24:27 +0300 (Wed, 05 Aug 2009) New Revision: 19041 Modified: projects/haf/trunk/libosso/debian/changelog projects/haf/trunk/libosso/src/libosso.h projects/haf/trunk/libosso/src/osso-cp-plugin.c projects/haf/trunk/libosso/src/osso-cp-plugin.h projects/haf/trunk/libosso/src/osso-init.c projects/haf/trunk/libosso/src/osso-internal.h Log: new CP applet code from David Modified: projects/haf/trunk/libosso/debian/changelog =================================================================== --- projects/haf/trunk/libosso/debian/changelog 2009-08-05 06:22:29 UTC (rev 19040) +++ projects/haf/trunk/libosso/debian/changelog 2009-08-05 06:24:27 UTC (rev 19041) @@ -1,3 +1,10 @@ +libosso (2.24-1~unreleased) unstable; urgency=low + + David Kedves: + * New code for Control Panel applets, required by the new HCP. + + -- Kimmo Hämäläinen <kimmo.hamalainen at nokia.com> Tue, 4 Aug 2009 16:23:32 +0300 + libosso (2.23-1) unstable; urgency=low * Fixes: NB#122572 - new libosso API should be detectable by some define Modified: projects/haf/trunk/libosso/src/libosso.h =================================================================== --- projects/haf/trunk/libosso/src/libosso.h 2009-08-05 06:22:29 UTC (rev 19040) +++ projects/haf/trunk/libosso/src/libosso.h 2009-08-05 06:24:27 UTC (rev 19041) @@ -1204,10 +1204,8 @@ * @param osso The library context as returned by #osso_initialize. * @param filename The shared object (.so) file of the plugin. It should * include the ".so" prefix, but not a path. - * @param data The GTK top-level widget. It is needed so that the widgets - * created by the plugin can be made a child of the main application that - * utilizes the plugin. Type is a gpointer so that the plugin does not need - * to depend on GTK (in which case it should ignore the parameter). + * @param data (Deprecated) Unused, applets from now always transient + * for the hildon-control-panel window * @param user_activated If the plugin was activated by a user (as opposed to * activated by restoring software state), set to TRUE, else to FALSE. * @return the return value of the plugin on success, or #OSSO_ERROR on @@ -1219,6 +1217,7 @@ /** * This function is used to tell a plugin to save its state. + * Deprecated: controlpanel will do the state saving. * * @param osso The library context as returned by #osso_initialize. * @param filename Same as the filename parameter of #osso_cp_plugin_execute Modified: projects/haf/trunk/libosso/src/osso-cp-plugin.c =================================================================== --- projects/haf/trunk/libosso/src/osso-cp-plugin.c 2009-08-05 06:22:29 UTC (rev 19040) +++ projects/haf/trunk/libosso/src/osso-cp-plugin.c 2009-08-05 06:24:27 UTC (rev 19041) @@ -25,212 +25,35 @@ #include "osso-internal.h" #include "osso-cp-plugin.h" #include "osso-log.h" -#include <linux/limits.h> -#include <errno.h> /* hildon-control-panel RPC */ #define HCP_APPLICATION_NAME "controlpanel" #define HCP_SERVICE "com.nokia.controlpanel" #define HCP_RPC_METHOD_RUN_APPLET "run_applet" -#define HCP_RPC_METHOD_TOP_APPLICATION "top_application" -#define HCP_RPC_METHOD_SAVE_STATE_APPLET "save_state_applet" -#define HCP_RPC_METHOD_IS_APPLET_RUNNING "is_applet_running" -static gboolean -is_applet_running_in_cp (osso_context_t *osso, - const char *filename) -{ - DBusError *error = NULL; - gboolean cp_running; - osso_return_t ret; - osso_rpc_t retval; - - cp_running = dbus_bus_name_has_owner (osso->conn, - HCP_SERVICE, - error); - if (error) - { - ULOG_ERR_F("Error in dbus_bus_name_has_owner: %s", error->message); - dbus_error_free (error); - return FALSE; - } - - if (!cp_running) - return FALSE; - - - ret = osso_rpc_run_with_defaults(osso, - HCP_APPLICATION_NAME, - HCP_RPC_METHOD_IS_APPLET_RUNNING, - &retval, - DBUS_TYPE_STRING, - filename, - DBUS_TYPE_INVALID); - - if (ret != OSSO_OK) - { - ULOG_ERR_F("Error in RPC call"); - return FALSE; - } - - if (retval.type != DBUS_TYPE_BOOLEAN) - { - ULOG_ERR_F("Unexpected return value in RPC call"); - return FALSE; - } - - return retval.value.b; -} - - -static void * -try_plugin (osso_context_t *osso, const char *dir, const char *file) -{ - char libname[PATH_MAX]; - void *handle = NULL; - - if (snprintf (libname, PATH_MAX, "%s/%s", dir, file) >= PATH_MAX) - { - ULOG_ERR_F("PATH_MAX exceeded"); - return NULL; - } - - if (osso->cp_plugins) - handle = g_hash_table_lookup (osso->cp_plugins, libname); - - if (handle) - return handle; - - handle = dlopen (libname, RTLD_LAZY | RTLD_LOCAL); - if (handle == NULL) - { - ULOG_ERR_F("Unable to load library '%s': %s", libname, dlerror()); - } - - g_hash_table_insert (osso->cp_plugins, g_strdup (libname), handle); - return handle; -} - osso_return_t osso_cp_plugin_execute(osso_context_t *osso, const gchar *filename, gpointer data, gboolean user_activated) { - void *handle = NULL; - osso_return_t ret; - osso_cp_plugin_exec_f *exec = NULL; - - if (osso == NULL || filename == NULL) { - ULOG_ERR_F("invalid arguments"); - return OSSO_INVALID; - } - dprint("executing library '%s'",filename); - - /* First of all, if the applet is started as system modal (data == NULL), - * and if controlpanel is already running this applet, just top - * controlpanel */ - if (data == NULL && is_applet_running_in_cp (osso, filename)) - { - ret = osso_rpc_run_with_defaults(osso, - HCP_APPLICATION_NAME, - HCP_RPC_METHOD_TOP_APPLICATION, - NULL, - DBUS_TYPE_INVALID); - if (ret == OSSO_OK) - return OSSO_OK; - } - - - /* First try builtin path */ - handle = try_plugin (osso, OSSO_CTRLPANELPLUGINDIR, filename); - - if (handle == NULL) - { - /* Then try the directories in LIBOSSO_CP_PLUGIN_DIRS - */ - const char *dirs = getenv ("LIBOSSO_CP_PLUGIN_DIRS"); - if (dirs) - { - char *dirs_copy = strdup (dirs), *ptr = dirs_copy, *tok; - while ((tok = strsep (&ptr, ":"))) - { - handle = try_plugin (osso, tok, filename); - if (handle) - break; - } - if (dirs_copy) - free (dirs_copy); - else - ULOG_ERR_F("strdup failed"); - } - } - - if (handle == NULL) { - ULOG_ERR_F("library '%s' could not be opened", filename); - return OSSO_ERROR; - } - - dprint(".."); - fflush(stderr); - - exec = dlsym(handle, "execute"); - dprint(".."); - /* function wasn't found or it was NULL */ - if (exec == NULL) { - ULOG_ERR_F("function 'execute' not found in library"); - ret = OSSO_ERROR; - goto _exec_err1; - } - - dprint("user_activated = %s",user_activated?"TRUE":"FALSE"); - - ret = exec(osso, data, user_activated); - _exec_err1: - - return ret; + /* Just pass the execute query to the controlpanel */ + return osso_rpc_run_with_defaults (osso, + HCP_APPLICATION_NAME, + HCP_RPC_METHOD_RUN_APPLET, + NULL, + DBUS_TYPE_STRING, + filename, + DBUS_TYPE_BOOLEAN, + user_activated, + DBUS_TYPE_INVALID); } osso_return_t osso_cp_plugin_save_state(osso_context_t *osso, const gchar *filename, gpointer data) { - void *handle = NULL; - - if (osso == NULL || filename == NULL) { - ULOG_ERR_F("invalid arguments"); - return OSSO_INVALID; - } - - if (is_applet_running_in_cp (osso, filename)) - { - /* Do not save state in this case, as the applet is run - * by controlpanel, which will take care of saving its state */ - return OSSO_OK; - } - - if (osso->cp_plugins) - handle = g_hash_table_lookup(osso->cp_plugins, filename); - - if (handle) { - osso_return_t ret; - osso_cp_plugin_save_state_f *ss = NULL; - - ss = dlsym(handle, "save_state"); - - /* function wasn't found or it was NULL */ - if (ss == NULL) { - ULOG_ERR_F("symbol 'save_state' not found in library, or " - "it has a 'NULL' value"); - return OSSO_ERROR; - } - - ret = ss(osso, data); - if (ret != OSSO_OK) { - ULOG_WARN_F("'save_state' did not return OSSO_OK"); - } - return ret; - } - else { - ULOG_ERR_F("plugin '%s' was not found", filename); - return OSSO_ERROR; - } + /* Do not save state as the applet is run by controlpanel, + * which will take care of saving its state + */ + return OSSO_OK; } + Modified: projects/haf/trunk/libosso/src/osso-cp-plugin.h =================================================================== --- projects/haf/trunk/libosso/src/osso-cp-plugin.h 2009-08-05 06:22:29 UTC (rev 19040) +++ projects/haf/trunk/libosso/src/osso-cp-plugin.h 2009-08-05 06:24:27 UTC (rev 19041) @@ -27,42 +27,6 @@ #ifndef OSSO_CPPLUGIN_H #define OSSO_CPPLUGIN_H -/* includes */ -# include <stdio.h> -# include <stdlib.h> -# include <string.h> -# include <dlfcn.h> -# include <limits.h> -# include <glib.h> -# include <unistd.h> -# include <sys/types.h> -# include <sys/stat.h> -# include <fcntl.h> +#include <glib.h> -#define OSSO_CP_CLOSE_IF "com.nokia.controlpanel.close" - -/** - * The exec function template that the library expects; - * @param osso osso context - * @param data pointer to a widget - * @param user_activated True iff activated by user. - * @return OSSO_ERR, if an error occurred, OSSO_OK else - */ -typedef osso_return_t (osso_cp_plugin_exec_f)(osso_context_t * osso, - gpointer data, - gboolean user_activated); - -/** - * Function called from plugin lib when application wants to save - * state. - * - * @param osso osso_context - * @param data plugin data - * @return OSSO_OK iff everything was fine. - * - */ -typedef osso_return_t (osso_cp_plugin_save_state_f)(osso_context_t *osso, - gpointer data); - - #endif Modified: projects/haf/trunk/libosso/src/osso-init.c =================================================================== --- projects/haf/trunk/libosso/src/osso-init.c 2009-08-05 06:22:29 UTC (rev 19040) +++ projects/haf/trunk/libosso/src/osso-init.c 2009-08-05 06:24:27 UTC (rev 19041) @@ -408,7 +408,6 @@ free(osso); return NULL; } - osso->cp_plugins = g_hash_table_new(g_str_hash, g_str_equal); osso->rpc_timeout = -1; osso->next_handler_id = 1; return osso; @@ -445,7 +444,6 @@ free(osso); return NULL; } - osso->cp_plugins = g_hash_table_new(g_str_hash, g_str_equal); osso->rpc_timeout = -1; osso->next_handler_id = 1; return osso; @@ -470,9 +468,6 @@ if (osso->id_hash != NULL) { g_hash_table_destroy(osso->id_hash); } - if (osso->cp_plugins != NULL) { - g_hash_table_destroy(osso->cp_plugins); - } #ifdef LIBOSSO_DEBUG g_log_remove_handler(NULL, osso->log_handler); Modified: projects/haf/trunk/libosso/src/osso-internal.h =================================================================== --- projects/haf/trunk/libosso/src/osso-internal.h 2009-08-05 06:22:29 UTC (rev 19040) +++ projects/haf/trunk/libosso/src/osso-internal.h 2009-08-05 06:24:27 UTC (rev 19041) @@ -165,7 +165,7 @@ _osso_hw_cb_t hw_cbs; osso_hw_state_t hw_state; guint rpc_timeout; - GHashTable *cp_plugins; + GHashTable *cp_plugins; /* unused */ int next_handler_id; /* next available handler id, unique in this context */ const DBusMessage *reply_dummy, *error_dummy; @@ -195,7 +195,7 @@ _osso_hw_cb_t hw_cbs; osso_hw_state_t hw_state; guint rpc_timeout; - GHashTable *cp_plugins; + GHashTable *cp_plugins; /* unused */ int next_handler_id; /* next available handler id, unique in this context */ const DBusMessage *reply_dummy, *error_dummy;
- Previous message: [maemo-commits] r19040 - in projects/haf/trunk/hildon-control-panel: debian src
- Next message: [maemo-commits] r19042 - projects/haf/trunk/clutter0.8/debian
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]