[maemo-commits] [maemo-commits] r15954 - in projects/haf/branches/hildon-thumbnail/daemonize: . daemon daemon/plugins
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Tue Sep 2 17:47:38 EEST 2008
- Previous message: [maemo-commits] r15953 - projects/haf/tags/gtk+
- Next message: [maemo-commits] r15955 - in projects/haf/branches/hildon-thumbnail/daemonize: . daemon
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: pvanhoof Date: 2008-09-02 17:47:35 +0300 (Tue, 02 Sep 2008) New Revision: 15954 Removed: projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugins/image-png.xml Modified: projects/haf/branches/hildon-thumbnail/daemonize/ChangeLog projects/haf/branches/hildon-thumbnail/daemonize/configure.ac projects/haf/branches/hildon-thumbnail/daemonize/daemon/hildon-thumbnail-daemon.c projects/haf/branches/hildon-thumbnail/daemonize/daemon/hildon-thumbnail-plugin.c projects/haf/branches/hildon-thumbnail/daemonize/daemon/hildon-thumbnail-plugin.h projects/haf/branches/hildon-thumbnail/daemonize/daemon/manager.c projects/haf/branches/hildon-thumbnail/daemonize/daemon/manager.h projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugins/Makefile.am projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugins/default.c projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugins/default.h projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.c projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.h Log: 2008-09-02 Philip Van Hoof <philip at codeminded.be> * daemon/hildon-thumbnail-plugin.h * daemon/hildon-thumbnail-daemon.c * daemon/thumbnailer.h * daemon/manager.h * daemon/plugins/image-png.xml * daemon/plugins/default.c * daemon/plugins/Makefile.am * daemon/plugins/default.h * daemon/thumbnailer.c * daemon/manager.c * daemon/hildon-thumbnail-plugin.c * configure.ac: More infrastructure and initial architecture work Modified: projects/haf/branches/hildon-thumbnail/daemonize/ChangeLog =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/ChangeLog 2008-09-02 13:54:47 UTC (rev 15953) +++ projects/haf/branches/hildon-thumbnail/daemonize/ChangeLog 2008-09-02 14:47:35 UTC (rev 15954) @@ -1,41 +1,56 @@ 2008-09-02 Philip Van Hoof <philip at codeminded.be> - daemon/thumbnailer.h - daemon/manager.h - daemon/thumbnailer.c - daemon/manager.c: Bugfix, DBusGConnection is not a GObject + * daemon/hildon-thumbnail-plugin.h + * daemon/hildon-thumbnail-daemon.c + * daemon/thumbnailer.h + * daemon/manager.h + * daemon/plugins/image-png.xml + * daemon/plugins/default.c + * daemon/plugins/Makefile.am + * daemon/plugins/default.h + * daemon/thumbnailer.c + * daemon/manager.c + * daemon/hildon-thumbnail-plugin.c + * configure.ac: More infrastructure and initial architecture work 2008-09-02 Philip Van Hoof <philip at codeminded.be> - daemon/hildon-thumbnail-daemon.c - daemon/plugins/image-png.xml - daemon/plugins/default.c - daemon/dbus-utils.h - daemon/thumbnailer.c - daemon/manager.c - daemon/generic.c - daemon/thumbnailer.h - daemon/manager.h - daemon/generic.h - daemon/manager.xml - daemon/thumbnailer.xml - daemon/Makefile.am - daemon/generic.xml - daemon/dbus-utils.c: Some major refactoring and setting up of initial + * daemon/thumbnailer.h + * daemon/manager.h + * daemon/thumbnailer.c + * daemon/manager.c: Bugfix, DBusGConnection is not a GObject + +2008-09-02 Philip Van Hoof <philip at codeminded.be> + + * daemon/hildon-thumbnail-daemon.c + * daemon/plugins/image-png.xml + * daemon/plugins/default.c + * daemon/dbus-utils.h + * daemon/thumbnailer.c + * daemon/manager.c + * daemon/generic.c + * daemon/thumbnailer.h + * daemon/manager.h + * daemon/generic.h + * daemon/manager.xml + * daemon/thumbnailer.xml + * daemon/Makefile.am + * daemon/generic.xml + * daemon/dbus-utils.c: Some major refactoring and setting up of initial infrastructure 2008-09-01 Philip Van Hoof <philip at codeminded.be> - daemon/hildon-thumbnail-daemon.c - daemon/plugins/image-png.xml - daemon/plugins/default.c - daemon/plugins/default.h - daemon/generic.h - daemon/Makefile.am - daemon/generic.xml - daemon/generic.c - daemon/org.freedesktop.Thumbnailer.service.in - daemon/org.freedesktop.thumbnailer.service.in: Installed a + * daemon/hildon-thumbnail-daemon.c + * daemon/plugins/image-png.xml + * daemon/plugins/default.c + * daemon/plugins/default.h + * daemon/generic.h + * daemon/Makefile.am + * daemon/generic.xml + * daemon/generic.c + * daemon/org.freedesktop.Thumbnailer.service.in + * daemon/org.freedesktop.thumbnailer.service.in: Installed a org.freedesktop.thumbnailer.generic, according to changed specifications Modified: projects/haf/branches/hildon-thumbnail/daemonize/configure.ac =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/configure.ac 2008-09-02 13:54:47 UTC (rev 15953) +++ projects/haf/branches/hildon-thumbnail/daemonize/configure.ac 2008-09-02 14:47:35 UTC (rev 15954) @@ -60,7 +60,7 @@ # N -GLIB_CHECK="glib-2.0 >= 2.4.0 gthread-2.0" +GLIB_CHECK="gio-2.0 glib-2.0 >= 2.4.0 gthread-2.0" PKG_CHECK_MODULES(GLIB, $GLIB_CHECK) AC_SUBST(GLIB_LIBS) AC_SUBST(GLIB_CFLAGS) Modified: projects/haf/branches/hildon-thumbnail/daemonize/daemon/hildon-thumbnail-daemon.c =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/daemon/hildon-thumbnail-daemon.c 2008-09-02 13:54:47 UTC (rev 15953) +++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/hildon-thumbnail-daemon.c 2008-09-02 14:47:35 UTC (rev 15954) @@ -51,6 +51,7 @@ GMainLoop *main_loop; GError *error = NULL; Manager *manager; + Thumbnailer *thumbnailer; DBusGProxy *manager_proxy; /* TODO: dynamically load plugins, and detect when new ones get @@ -58,7 +59,7 @@ * shut down) */ manager_do_init (connection, &manager, &error); - thumbnailer_do_init (connection, manager, &error); + thumbnailer_do_init (connection, manager, &thumbnailer, &error); module = hildon_thumbnail_plugin_load ("default"); @@ -68,16 +69,13 @@ MANAGER_INTERFACE); hildon_thumbnail_plugin_do_init (module, - connection, - manager_proxy, + thumbnailer, &error); - g_object_unref (manager_proxy); - main_loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (main_loop); - hildon_thumbnail_plugin_do_stop (module); + hildon_thumbnail_plugin_do_stop (module, thumbnailer); manager_do_stop (); thumbnailer_do_stop (); Modified: projects/haf/branches/hildon-thumbnail/daemonize/daemon/hildon-thumbnail-plugin.c =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/daemon/hildon-thumbnail-plugin.c 2008-09-02 13:54:47 UTC (rev 15953) +++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/hildon-thumbnail-plugin.c 2008-09-02 14:47:35 UTC (rev 15954) @@ -29,26 +29,58 @@ return module; } -typedef void (*InitFunc) (DBusGConnection *connection, DBusGProxy *manager, GError **error); +typedef void (*InitFunc) (GError **error); +typedef GStrv (*SupportedFunc) (void); void -hildon_thumbnail_plugin_do_init (GModule *module, DBusGConnection *connection, DBusGProxy *manager, GError **error) +hildon_thumbnail_plugin_do_init (GModule *module, Thumbnailer *thumbnailer, GError **error) { InitFunc func; if (g_module_symbol (module, "hildon_thumbnail_plugin_init", (gpointer *) &func)) { - (func) (connection, manager, error); + GStrv supported = NULL; + SupportedFunc supported_func; + + if (g_module_symbol (module, "hildon_thumbnail_plugin_supported", (gpointer *) &supported_func)) { + guint i = 0; + + supported = (supported_func) (); + + if (supported) { + while (supported[i] != NULL) { + + thumbnailer_register_plugin (thumbnailer, + supported[i], + module); + i++; + } + } + + (func) (error); + } } } +typedef void (*CreateFunc) (GStrv uris, create_cb callback, gpointer user_data); + +void +hildon_thumbnail_plugin_do_create (GModule *module, GStrv uris, create_cb callback, gpointer user_data) +{ + CreateFunc func; + if (g_module_symbol (module, "hildon_thumbnail_plugin_create", (gpointer *) &func)) { + (func) (uris, callback, user_data); + } +} + typedef void (*StopFunc) (void); void -hildon_thumbnail_plugin_do_stop (GModule *module) +hildon_thumbnail_plugin_do_stop (GModule *module, Thumbnailer *thumbnailer) { StopFunc func; if (g_module_symbol (module, "hildon_thumbnail_plugin_stop", (gpointer *) &func)) { + thumbnailer_unregister_plugin (thumbnailer, module); (func) (); } } Modified: projects/haf/branches/hildon-thumbnail/daemonize/daemon/hildon-thumbnail-plugin.h =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/daemon/hildon-thumbnail-plugin.h 2008-09-02 13:54:47 UTC (rev 15953) +++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/hildon-thumbnail-plugin.h 2008-09-02 14:47:35 UTC (rev 15954) @@ -29,15 +29,23 @@ #include <gmodule.h> #include <dbus/dbus-glib-bindings.h> +#include "thumbnailer.h" + G_BEGIN_DECLS -GModule * hildon_thumbnail_plugin_load (const gchar *module_name); -void hildon_thumbnail_plugin_do_init (GModule *module, - DBusGConnection *connection, - DBusGProxy *manager, - GError **error); -void hildon_thumbnail_plugin_do_stop (GModule *module); +typedef void (*create_cb) (GStrv thumb_paths, GError *error, gpointer user_data); +GModule * hildon_thumbnail_plugin_load (const gchar *module_name); + +void hildon_thumbnail_plugin_do_init (GModule *module, + Thumbnailer *thumbnailer, + GError **error); +void hildon_thumbnail_plugin_do_create (GModule *module, GStrv uris, + create_cb callback, + gpointer user_data); +void hildon_thumbnail_plugin_do_stop (GModule *module, + Thumbnailer *thumbnailer); + G_END_DECLS #endif Modified: projects/haf/branches/hildon-thumbnail/daemonize/daemon/manager.c =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/daemon/manager.c 2008-09-02 13:54:47 UTC (rev 15953) +++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/manager.c 2008-09-02 14:47:35 UTC (rev 15954) @@ -26,28 +26,17 @@ PROP_CONNECTION }; -GHashTable* -manager_get_handlers (Manager *object) +DBusGProxy* +manager_get_handler (Manager *object, const gchar *mime_type) { ManagerPrivate *priv = MANAGER_GET_PRIVATE (object); - return g_hash_table_ref (priv->handlers); + DBusGProxy *proxy = g_hash_table_lookup (priv->handlers, mime_type); + if (proxy) + g_object_ref (proxy); + return proxy; } -/* -static void -on_proxy_name_owner_changed (DBusGProxy *proxy, - const gchar *name_owner, - const gchar *name_lost, - const gchar *name_aquired, - Manager *object) -{ - ManagerPrivate *priv = MANAGER_GET_PRIVATE (object); - if (name_lost && strlen (name_lost) > 0) - g_hash_table_remove (priv->handlers, name_lost); -} -*/ - static gboolean do_remove_or_not (gpointer key, gpointer value, gpointer user_data) { @@ -83,23 +72,11 @@ mime_type, mime_proxy); - g_print ("Register: %s\n", sender); - g_free (sender); g_signal_connect (mime_proxy, "destroy", G_CALLBACK (service_gone), object); -/* - dbus_g_proxy_add_signal (mime_proxy, "NameOwnerChanged", - G_TYPE_STRING, G_TYPE_STRING, - G_TYPE_STRING, G_TYPE_INVALID); - - dbus_g_proxy_connect_signal (mime_proxy, "NameOwnerChanged", - G_CALLBACK (on_proxy_name_owner_changed), - object, - NULL); -*/ } static void Modified: projects/haf/branches/hildon-thumbnail/daemonize/daemon/manager.h =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/daemon/manager.h 2008-09-02 13:54:47 UTC (rev 15953) +++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/manager.h 2008-09-02 14:47:35 UTC (rev 15954) @@ -24,7 +24,7 @@ GType manager_get_type (void); void manager_register (Manager *object, gchar *mime_type, DBusGMethodInvocation *context); -GHashTable* manager_get_handlers (Manager *object); +DBusGProxy* manager_get_handler (Manager *object, const gchar *mime_type); void manager_do_stop (void); void manager_do_init (DBusGConnection *connection, Manager **manager, GError **error); Modified: projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugins/Makefile.am =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugins/Makefile.am 2008-09-02 13:54:47 UTC (rev 15953) +++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugins/Makefile.am 2008-09-02 14:47:35 UTC (rev 15954) @@ -9,16 +9,7 @@ plugins_LTLIBRARIES = libhildon-thumbnailer-default.la -%-glue.h: $(top_srcdir)/daemon/plugins/%.xml - $(DBUSBINDINGTOOL) --mode=glib-server --output=$@ --prefix=$(subst -,_,$*) $^ - -BUILT_SOURCES = image-png-glue.h -CLEANFILES = $(BUILT_SOURCES) -configdir = $(datadir)/hildon-thumbnail -config_DATA = image-png.xml -EXTRA_DIST = $(BUILT_SOURCES) $(config_DATA) - -libhildon_thumbnailer_default_la_SOURCES = default.c image-png-glue.h default.h +libhildon_thumbnailer_default_la_SOURCES = default.c default.h libhildon_thumbnailer_default_la_LDFLAGS = $(plugin_flags) libhildon_thumbnailer_default_la_LIBADD = \ $(PGK_LIBS) \ Modified: projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugins/default.c =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugins/default.c 2008-09-02 13:54:47 UTC (rev 15953) +++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugins/default.c 2008-09-02 14:47:35 UTC (rev 15954) @@ -3,32 +3,60 @@ #include <hildon-thumbnail-factory.h> #include "default.h" -#include "image-png-glue.h" #include "hildon-thumbnail-plugin.h" -G_DEFINE_TYPE (ImagePng, image_png, G_TYPE_OBJECT) +static const gchar* supported[2] = { "image/png" , NULL }; -#define DEFAULT_PNG_SERVICE "org.freedesktop.thumbnailer" -#define DEFAULT_PNG_PATH "/org/freedesktop/thumbnailer/png" -#define DEFAULT_PNG_INTERFACE "org.freedesktop.thumbnailer" -void -image_png_create (ImagePng *object, GStrv urls, DBusGMethodInvocation *context) +const gchar** +hildon_thumbnail_plugin_supported (void) { - g_print ("CREATE PNG\n"); + return supported; } -static void -image_png_class_init (ImagePngClass *klass) +typedef struct { + GStrv uris; + create_cb cb; + gpointer user_data; +} CreateInfo; + + +static gboolean +on_finished (CreateInfo *info) { + // Returning back the same uris is of course not right :). The first + // param should be set with the uris made for the uris in info->uris, + // else the second parameter, the error, must be set + + info->cb (info->uris, NULL, info->user_data); + + return FALSE; } static void -image_png_init (ImagePng *object) +on_destroy (CreateInfo *info) { + g_slice_free (CreateInfo, info); } +void +hildon_thumbnail_plugin_create (GStrv uris, create_cb callback, gpointer user_data) +{ + CreateInfo *info = g_slice_new (CreateInfo); + info->uris = uris; + info->cb = callback; + info->user_data = user_data; + + // This is of course a dummy implementation + + g_idle_add_full (G_PRIORITY_DEFAULT, + (GSourceFunc) on_finished, + info, + (GDestroyNotify) on_destroy); +} + + void hildon_thumbnail_plugin_stop (void) { @@ -36,32 +64,6 @@ void -hildon_thumbnail_plugin_init (DBusGConnection *connection, DBusGProxy *manager, GError **error) +hildon_thumbnail_plugin_init (GError **error) { - guint result; - DBusGProxy *proxy; - GObject *object; - - proxy = dbus_g_proxy_new_for_name (connection, - DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, - DBUS_INTERFACE_DBUS); - - org_freedesktop_DBus_request_name (proxy, DEFAULT_PNG_SERVICE, - DBUS_NAME_FLAG_DO_NOT_QUEUE, - &result, error); - - object = g_object_new (image_png_get_type (), NULL); - - dbus_g_object_type_install_info (G_OBJECT_TYPE (object), - &dbus_glib_image_png_object_info); - - dbus_g_connection_register_g_object (connection, - DEFAULT_PNG_PATH, - object); - - g_print ("Do reg: image/png\n"); - dbus_g_proxy_call (manager, "Register", error, - G_TYPE_STRING, - "image/png"); } Modified: projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugins/default.h =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugins/default.h 2008-09-02 13:54:47 UTC (rev 15953) +++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugins/default.h 2008-09-02 14:47:35 UTC (rev 15954) @@ -1,19 +1,5 @@ #ifndef __DEFAULT_H__ #define __DEFAULT_H__ -typedef struct ImagePng ImagePng; -typedef struct ImagePngClass ImagePngClass; -struct ImagePng { - GObject parent; -}; - -struct ImagePngClass { - GObjectClass parent; -}; - -void image_png_create (ImagePng *object, GStrv urls, DBusGMethodInvocation *context); -void image_png_move (ImagePng *object, GStrv from_urls, GStrv to_urls, DBusGMethodInvocation *context); -void image_png_delete (ImagePng *object, GStrv urls, DBusGMethodInvocation *context); - #endif Deleted: projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugins/image-png.xml =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugins/image-png.xml 2008-09-02 13:54:47 UTC (rev 15953) +++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/plugins/image-png.xml 2008-09-02 14:47:35 UTC (rev 15954) @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<node name="/"> - <interface name="org.freedesktop.thumbnailer.image-png"> - <method name="Create"> - <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/> - <arg type="as" name="uris" direction="in" /> - </method> - </interface> -</node> Modified: projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.c =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.c 2008-09-02 13:54:47 UTC (rev 15953) +++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.c 2008-09-02 14:47:35 UTC (rev 15954) @@ -1,9 +1,14 @@ #include <glib.h> + +#include <gio/gio.h> + #include <dbus/dbus-glib-bindings.h> #include "manager.h" #include "thumbnailer.h" #include "thumbnailer-glue.h" +#include "hildon-thumbnail-plugin.h" +#include "dbus-utils.h" #define THUMBNAILER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TYPE_THUMBNAILER, ThumbnailerPrivate)) @@ -13,6 +18,7 @@ DBusGProxy *proxy; DBusGConnection *connection; Manager *manager; + GHashTable *plugins; } ThumbnailerPrivate; enum { @@ -23,9 +29,179 @@ }; +void +thumbnailer_register_plugin (Thumbnailer *object, const gchar *mime_type, GModule *plugin) +{ + ThumbnailerPrivate *priv = THUMBNAILER_GET_PRIVATE (object); + + g_print ("reg:%s\n", mime_type); + g_hash_table_insert (priv->plugins, + g_strdup (mime_type), + plugin); +} + +static gboolean +do_delete_or_not (gpointer key, gpointer value, gpointer user_data) +{ + if (value == user_data) + return TRUE; + return FALSE; +} + +void +thumbnailer_unregister_plugin (Thumbnailer *object, GModule *plugin) +{ + ThumbnailerPrivate *priv = THUMBNAILER_GET_PRIVATE (object); + + g_hash_table_foreach_remove (priv->plugins, + do_delete_or_not, + plugin); +} + +typedef struct { + DBusGProxy *proxy; + DBusGMethodInvocation *context; +} ProxyCallInfo; + + +static void +on_create_finished (DBusGProxy *proxy, DBusGProxyCall *call_id, ProxyCallInfo *info) +{ + GError *error = NULL; + GStrv thumb_urls = NULL; + + dbus_g_proxy_end_call (proxy, call_id, + &error, + G_TYPE_STRV, + &thumb_urls); + + if (error) { + dbus_g_method_return_error (info->context, error); + g_clear_error (&error); + } else + dbus_g_method_return (info->context, thumb_urls); + + g_strfreev (thumb_urls); +} + +static void +on_create_destroy (ProxyCallInfo *info) +{ + g_object_unref (info->proxy); + g_slice_free (ProxyCallInfo, info); +} + +static void +on_plugin_finished (const GStrv thumb_urls, GError *error, DBusGMethodInvocation *context) +{ + if (error) { + dbus_g_method_return_error (context, error); + g_clear_error (&error); + } else + dbus_g_method_return (context, thumb_urls); +} + + +static gchar * +get_mime_type (const gchar *path) +{ + GFileInfo *info; + GFile *file; + GError *error = NULL; + gchar *content_type; + + file = g_file_new_for_path (path); + info = g_file_query_info (file, + G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, + G_FILE_QUERY_INFO_NONE, + NULL, &error); + + if (error) { + g_warning ("Error guessing mimetype for '%s': %s\n", path, error->message); + g_error_free (error); + + return g_strdup ("unknown"); + } + + content_type = g_strdup (g_file_info_get_content_type (info)); + + g_object_unref (info); + g_object_unref (file); + + if (!content_type) { + return g_strdup ("unknown"); + } + + return content_type; +} + void thumbnailer_create (Thumbnailer *object, GStrv urls, DBusGMethodInvocation *context) { + ThumbnailerPrivate *priv = THUMBNAILER_GET_PRIVATE (object); + GHashTable *hash = g_hash_table_new (g_str_hash, g_str_equal); + guint i = 0; + GHashTableIter iter; + gpointer key, value; + + while (urls[i] != NULL) { + GList *urls_for_mime; + gchar *mime_type = get_mime_type (urls[i]); + urls_for_mime = g_hash_table_lookup (hash, mime_type); + urls_for_mime = g_list_prepend (urls_for_mime, urls[i]); + g_hash_table_replace (hash, mime_type, urls_for_mime); + } + + g_hash_table_iter_init (&iter, hash); + + while (g_hash_table_iter_next (&iter, &key, &value)) { + GList *urlm = value, *copy = urlm; + GStrv urlss = (GStrv) g_malloc0 (sizeof (gchar *) * (g_list_length (urlm) + 1)); + DBusGProxy *proxy; + + i = 0; + + while (copy) { + urlss[i] = copy->data; + i++; + copy = g_list_next (copy); + } + + g_list_free (urlm); + + proxy = manager_get_handler (priv->manager, key); + + if (proxy) { + ProxyCallInfo *info = g_slice_new (ProxyCallInfo); + + info->context = context; + info->proxy = proxy; + + dbus_g_proxy_begin_call (proxy, "Create", + (DBusGProxyCallNotify) on_create_finished, + info, + (GDestroyNotify) on_create_destroy, + G_TYPE_STRV, + urlss); + + } else { + GModule *module = g_hash_table_lookup (priv->plugins, key); + if (module) { + hildon_thumbnail_plugin_do_create (module, urlss, + (create_cb) on_plugin_finished, + context); + } else { + GError *error = NULL; + g_set_error (&error, + DBUS_ERROR, 0, + "No handler"); + dbus_g_method_return_error (context, error); + g_clear_error (&error); + } + } + } + + g_hash_table_unref (hash); } void @@ -46,6 +222,7 @@ g_object_unref (priv->manager); g_object_unref (priv->proxy); g_object_unref (priv->connection); + g_hash_table_unref (priv->plugins); G_OBJECT_CLASS (thumbnailer_parent_class)->finalize (object); } @@ -167,7 +344,11 @@ static void thumbnailer_init (Thumbnailer *object) { + ThumbnailerPrivate *priv = THUMBNAILER_GET_PRIVATE (object); + priv->plugins = g_hash_table_new_full (g_str_hash, g_str_equal, + (GDestroyNotify) g_free, + NULL); } @@ -179,7 +360,7 @@ void -thumbnailer_do_init (DBusGConnection *connection, Manager *manager, GError **error) +thumbnailer_do_init (DBusGConnection *connection, Manager *manager, Thumbnailer **thumbnailer, GError **error) { guint result; DBusGProxy *proxy; @@ -203,6 +384,10 @@ dbus_g_object_type_install_info (G_OBJECT_TYPE (object), &dbus_glib_thumbnailer_object_info); - dbus_g_connection_register_g_object (connection, THUMBNAILER_PATH, object); + dbus_g_connection_register_g_object (connection, + THUMBNAILER_PATH, + object); + *thumbnailer = THUMBNAILER (object); + } Modified: projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.h =================================================================== --- projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.h 2008-09-02 13:54:47 UTC (rev 15953) +++ projects/haf/branches/hildon-thumbnail/daemonize/daemon/thumbnailer.h 2008-09-02 14:47:35 UTC (rev 15954) @@ -1,6 +1,8 @@ #ifndef __THUMBNAILER_H__ #define __THUMBNAILER_H__ +#include <gmodule.h> + #include "manager.h" #define THUMBNAILER_SERVICE "org.freedesktop.thumbnailer" @@ -29,7 +31,10 @@ void thumbnailer_move (Thumbnailer *object, GStrv from_urls, GStrv to_urls, DBusGMethodInvocation *context); void thumbnailer_delete (Thumbnailer *object, GStrv urls, DBusGMethodInvocation *context); +void thumbnailer_register_plugin (Thumbnailer *object, const gchar *mime_type, GModule *plugin); +void thumbnailer_unregister_plugin (Thumbnailer *object, GModule *plugin); + void thumbnailer_do_stop (void); -void thumbnailer_do_init (DBusGConnection *connection, Manager *manager, GError **error); +void thumbnailer_do_init (DBusGConnection *connection, Manager *manager, Thumbnailer **thumbnailer, GError **error); #endif
- Previous message: [maemo-commits] r15953 - projects/haf/tags/gtk+
- Next message: [maemo-commits] r15955 - in projects/haf/branches/hildon-thumbnail/daemonize: . daemon
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]