Index: src/plugins/evolution/tracker-evolution-registrar.h =================================================================== --- src/plugins/evolution/tracker-evolution-registrar.h (revision 2873) +++ src/plugins/evolution/tracker-evolution-registrar.h (working copy) @@ -30,6 +30,7 @@ #include +#include #include "tracker-evolution-common.h" G_BEGIN_DECLS Index: src/plugins/evolution/tracker-evolution.h =================================================================== --- src/plugins/evolution/tracker-evolution.h (revision 2873) +++ src/plugins/evolution/tracker-evolution.h (working copy) @@ -1,42 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2008, Nokia - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - * Authors: - * Philip Van Hoof - */ - -#ifndef __LIBTRACKER_EVOLUTION_H__ -#define __LIBTRACKER_EVOLUTION_H__ - -#if !defined (TRACKER_ENABLE_INTERNALS) && !defined (TRACKER_COMPILATION) -#error "TRACKER_ENABLE_INTERNALS not defined, this must be defined to use tracker's internal functions" -#endif - -#include - -#include - -G_BEGIN_DECLS - -void tracker_evolution_init (TrackerConfig *config); -void tracker_evolution_shutdown (void); - -G_END_DECLS - -#endif /* __LIBTRACKER_EVOLUTION_H__ */ Index: src/plugins/evolution/tracker-evolution-plugin.xml =================================================================== --- src/plugins/evolution/tracker-evolution-plugin.xml (revision 2873) +++ src/plugins/evolution/tracker-evolution-plugin.xml (working copy) @@ -1,6 +1,6 @@ - + Index: src/plugins/evolution/Makefile.am =================================================================== --- src/plugins/evolution/Makefile.am (revision 2873) +++ src/plugins/evolution/Makefile.am (working copy) @@ -24,36 +24,46 @@ eplugin_LTLIBRARIES = liborg-freedesktop-Tracker-evolution-plugin.la -noinst_LTLIBRARIES = libtracker-evolution.la libtracker-evolution-indexer.la +module_flags = -module -avoid-version -no-undefined -libtracker_evolution_indexer_la_SOURCES = \ +pushd_modulesdir = $(libdir)/tracker/push-modules/daemon +pushi_modulesdir = $(libdir)/tracker/push-modules/indexer + +pushd_modules_LTLIBRARIES = libtracker-evolution-daemon-module.la +pushi_modules_LTLIBRARIES = libtracker-evolution-indexer-module.la + +libtracker_evolution_indexer_module_la_SOURCES = \ tracker-evolution-indexer.c \ tracker-evolution-indexer.h \ tracker-evolution-registrar-glue.h \ tracker-evolution-common.h -libtracker_evolution_la_SOURCES = \ - tracker-evolution.c \ - tracker-evolution.h \ +libtracker_evolution_daemon_module_la_SOURCES = \ tracker-evolution-registrar.c \ tracker-evolution-registrar.h \ tracker-evolution-common.h \ tracker-evolution-registrar-glue.h -libtracker_evolution_la_LIBADD = \ +libtracker_evolution_daemon_module_la_LDFLAGS = $(module_flags) + +libtracker_evolution_daemon_module_la_LIBADD = \ $(top_builddir)/src/libtracker-data/libtracker-data.la \ $(top_builddir)/src/libtracker-db/libtracker-db.la \ $(top_builddir)/src/libtracker-common/libtracker-common.la \ + $(GMODULE_LIBS) \ $(DBUS_LIBS) \ $(GTHREAD_LIBS) \ $(GIO_LIBS) \ $(GLIB2_LIBS) \ $(RAPTOR_LIBS) -libtracker_evolution_indexer_la_LIBADD = \ +libtracker_evolution_indexer_module_la_LDFLAGS = $(module_flags) + +libtracker_evolution_indexer_module_la_LIBADD = \ $(top_builddir)/src/libtracker-data/libtracker-data.la \ $(top_builddir)/src/libtracker-db/libtracker-db.la \ $(top_builddir)/src/libtracker-common/libtracker-common.la \ + $(GMODULE_LIBS) \ $(DBUS_LIBS) \ $(GTHREAD_LIBS) \ $(GIO_LIBS) \ Index: src/plugins/evolution/tracker-evolution-indexer.c =================================================================== --- src/plugins/evolution/tracker-evolution-indexer.c (revision 2873) +++ src/plugins/evolution/tracker-evolution-indexer.c (working copy) @@ -40,6 +40,7 @@ /* This is okay, we run in-process of the indexer: we can access its symbols */ #include +#include #include #include "tracker-evolution-indexer.h" @@ -592,8 +593,8 @@ } void -tracker_evolution_storer_init (TrackerConfig *config, - TrackerIndexer *indexer) +tracker_push_module_create (TrackerConfig *config, + TrackerIndexer *indexer) { GError *error = NULL; DBusGConnection *connection; @@ -619,7 +620,7 @@ } void -tracker_evolution_storer_shutdown (void) +tracker_push_module_shutdown (void) { if (idx_indexer) g_object_unref (idx_indexer); Index: src/plugins/evolution/tracker-evolution-registrar.xml =================================================================== --- src/plugins/evolution/tracker-evolution-registrar.xml (revision 2873) +++ src/plugins/evolution/tracker-evolution-registrar.xml (working copy) @@ -1,6 +1,6 @@ - + Index: src/plugins/evolution/tracker-evolution-registrar.c =================================================================== --- src/plugins/evolution/tracker-evolution-registrar.c (revision 2873) +++ src/plugins/evolution/tracker-evolution-registrar.c (working copy) @@ -23,21 +23,36 @@ #include "config.h" +#include +#include + #include +#include + +#include + #define __TRACKER_EVOLUTION_REGISTRAR_C__ + #include "tracker-evolution-registrar.h" #include "tracker-evolution-registrar-glue.h" -const DBusGMethodInfo *registrar_methods = dbus_glib_tracker_evolution_registrar_methods; - #define TRACKER_EVOLUTION_REGISTRAR_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_EVOLUTION_REGISTRAR, TrackerEvolutionRegistrarPrivate)) -G_DEFINE_TYPE (TrackerEvolutionRegistrar, tracker_evolution_registrar, G_TYPE_OBJECT) +#define TRACKER_TYPE_EVOLUTION_PUSH_REGISTRAR (tracker_evolution_push_registrar_get_type ()) +#define TRACKER_EVOLUTION_PUSH_REGISTRAR(module) (G_TYPE_CHECK_INSTANCE_CAST ((module), TRACKER_TYPE_EVOLUTION_PUSH_REGISTRAR, TrackerEvolutionPushRegistrar)) -/* This runs in-process of trackerd. It simply proxies everything to the indexer - * who wont always be running. Which is why this is needed (trackerd is always - * running, so it's more suitable to respond to Evolution's requests). */ +typedef struct TrackerEvolutionPushRegistrar TrackerEvolutionPushRegistrar; +typedef struct TrackerEvolutionPushRegistrarClass TrackerEvolutionPushRegistrarClass; +struct TrackerEvolutionPushRegistrar { + TrackerPushRegistrar parent_instance; +}; + +struct TrackerEvolutionPushRegistrarClass { + TrackerPushRegistrarClass parent_class; +}; + + typedef struct { DBusGProxy *idx_proxy; DBusGConnection *connection; @@ -48,6 +63,15 @@ PROP_CONNECTION }; +static GType tracker_evolution_push_registrar_get_type (void) G_GNUC_CONST; + +G_DEFINE_TYPE (TrackerEvolutionRegistrar, tracker_evolution_registrar, G_TYPE_OBJECT) +G_DEFINE_TYPE (TrackerEvolutionPushRegistrar, tracker_evolution_push_registrar, TRACKER_TYPE_PUSH_REGISTRAR); + +/* This runs in-process of trackerd. It simply proxies everything to the indexer + * who wont always be running. Which is why this is needed (trackerd is always + * running, so it's more suitable to respond to Evolution's requests). */ + static void tracker_evolution_registrar_finalize (GObject *object) { @@ -253,3 +277,120 @@ dbus_g_method_return (context); } + + +static void +on_manager_destroy (DBusGProxy *proxy, gpointer user_data) +{ + return; +} + +static void +tracker_evolution_push_registrar_enable (TrackerPushRegistrar *registrar, + DBusGConnection *connection, + DBusGProxy *dbus_proxy, + GError **error) +{ + GError *nerror = NULL; + guint result; + DBusGProxy *manager_proxy; + GObject *object; + + tracker_push_registrar_set_object (registrar, NULL); + tracker_push_registrar_set_manager (registrar, NULL); + + manager_proxy = dbus_g_proxy_new_for_name (connection, + TRACKER_EVOLUTION_MANAGER_SERVICE, + TRACKER_EVOLUTION_MANAGER_PATH, + TRACKER_EVOLUTION_MANAGER_INTERFACE); + + /* Creation of the registrar */ + if (!org_freedesktop_DBus_request_name (dbus_proxy, + TRACKER_EVOLUTION_REGISTRAR_SERVICE, + DBUS_NAME_FLAG_DO_NOT_QUEUE, + &result, &nerror)) { + + g_critical ("Could not setup DBus, %s in use\n", + TRACKER_EVOLUTION_REGISTRAR_SERVICE); + + goto handle_error; + } + + if (nerror) + goto handle_error; + + object = g_object_new (TRACKER_TYPE_EVOLUTION_REGISTRAR, + "connection", connection, NULL); + + dbus_g_object_type_install_info (G_OBJECT_TYPE (object), + &dbus_glib_tracker_evolution_registrar_object_info); + + dbus_g_connection_register_g_object (connection, + TRACKER_EVOLUTION_REGISTRAR_PATH, + object); + + /* Registration of the registrar to the manager */ + dbus_g_proxy_call_no_reply (manager_proxy, "Register", + G_TYPE_OBJECT, object, + G_TYPE_UINT, (guint) tracker_data_manager_get_db_option_int ("EvolutionLastModseq"), + G_TYPE_INVALID, + G_TYPE_INVALID); + + /* If while we had a proxy for the manager the manager shut itself down, + * then we'll get rid of our registrar too, in on_manager_destroy */ + + g_signal_connect (manager_proxy, "destroy", + G_CALLBACK (on_manager_destroy), registrar); + + tracker_push_registrar_set_object (registrar, object); + tracker_push_registrar_set_manager (registrar, manager_proxy); + + g_object_unref (object); /* sink own */ + g_object_unref (manager_proxy); /* sink own */ + + handle_error: + + if (nerror) + g_propagate_error (error, nerror); +} + +static void +tracker_evolution_push_registrar_disable (TrackerPushRegistrar *registrar) +{ + tracker_push_registrar_set_object (registrar, NULL); + tracker_push_registrar_set_manager (registrar, NULL); +} + +static void +tracker_evolution_push_registrar_class_init (TrackerEvolutionPushRegistrarClass *klass) +{ + TrackerPushRegistrarClass *p_class = TRACKER_PUSH_REGISTRAR_CLASS (klass); + + p_class->enable = tracker_evolution_push_registrar_enable; + p_class->disable = tracker_evolution_push_registrar_disable; +} + +static void +tracker_evolution_push_registrar_init (TrackerEvolutionPushRegistrar *registrar) +{ + return; +} + +TrackerPushRegistrar * +tracker_push_module_create (void) +{ + GObject *object; + + object = g_object_new (TRACKER_TYPE_EVOLUTION_PUSH_REGISTRAR, NULL); + + tracker_push_registrar_set_service (TRACKER_PUSH_REGISTRAR (object), + TRACKER_EVOLUTION_MANAGER_SERVICE); + + return TRACKER_PUSH_REGISTRAR (object); +} + +void +tracker_push_module_shutdown (TrackerPushRegistrar *registrar) +{ + tracker_evolution_push_registrar_disable (registrar); +} Index: src/plugins/evolution/tracker-evolution.c =================================================================== --- src/plugins/evolution/tracker-evolution.c (revision 2873) +++ src/plugins/evolution/tracker-evolution.c (working copy) @@ -1,360 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2008, Nokia - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - * Authors: - * Philip Van Hoof - */ - -#include "config.h" - -#include -#include - -#include - -#include "tracker-evolution.h" -#include "tracker-evolution-registrar.h" - -typedef struct { - TrackerConfig *config; - DBusGConnection *connection; - gboolean is_enabled; - DBusGProxy *dbus_proxy; - DBusGProxy *manager_proxy; - GObject *object; - gboolean deactivating; -} EvolutionSupportPrivate; - -static GStaticPrivate private_key = G_STATIC_PRIVATE_INIT; - -static guint -get_stored_last_modseq (void) -{ - return (guint) tracker_data_manager_get_db_option_int ("EvolutionLastModseq"); -} - -static void -deactivate_registrar (void) -{ - EvolutionSupportPrivate *private; - - private = g_static_private_get (&private_key); - g_return_if_fail (private != NULL); - - if (private->object) { - g_object_unref (private->object); - private->object = NULL; - } - - if (private->manager_proxy && !private->deactivating) - g_object_unref (private->manager_proxy); - - private->manager_proxy = NULL; -} - -static void -deactivate_dbus_client (void) -{ - EvolutionSupportPrivate *private; - - private = g_static_private_get (&private_key); - g_return_if_fail (private != NULL); - - deactivate_registrar (); - - if (private->dbus_proxy) { - g_object_unref (private->dbus_proxy); - private->dbus_proxy = NULL; - } -} - -static void -on_manager_destroy (DBusGProxy *proxy, gpointer user_data) -{ - EvolutionSupportPrivate *private; - gboolean old_setting; - - private = g_static_private_get (&private_key); - g_return_if_fail (private != NULL); - - old_setting = private->deactivating; - - private->deactivating = TRUE; - deactivate_registrar (); - private->deactivating = old_setting; -} - - -static void -activate_registrar (void) -{ - EvolutionSupportPrivate *private; - - private = g_static_private_get (&private_key); - g_return_if_fail (private != NULL); - - if (private->object) - return; - - private->manager_proxy = - dbus_g_proxy_new_for_name (private->connection, - TRACKER_EVOLUTION_MANAGER_SERVICE, - TRACKER_EVOLUTION_MANAGER_PATH, - TRACKER_EVOLUTION_MANAGER_INTERFACE); - - /* If while we had a proxy for the manager the manager shut itself down, - * then we'll get rid of our registrar too, in on_manager_destroy */ - - g_signal_connect (private->manager_proxy, "destroy", - G_CALLBACK (on_manager_destroy), NULL); - - if (private->manager_proxy) { - GError *error = NULL; - guint result; - - /* Creation of the registrar */ - if (!org_freedesktop_DBus_request_name (private->dbus_proxy, - TRACKER_EVOLUTION_REGISTRAR_SERVICE, - DBUS_NAME_FLAG_DO_NOT_QUEUE, - &result, &error)) { - g_critical ("Could not setup DBus, %s in use\n", TRACKER_EVOLUTION_REGISTRAR_SERVICE); - goto error_handler; - } - - if (error) - goto error_handler; - - private->object = g_object_new (TRACKER_TYPE_EVOLUTION_REGISTRAR, - "connection", private->connection, - NULL); - - dbus_g_object_type_install_info (G_OBJECT_TYPE (private->object), - ®istrar_methods); - dbus_g_connection_register_g_object (private->connection, - TRACKER_EVOLUTION_REGISTRAR_PATH, - private->object); - - /* Registration of the registrar to the manager */ - dbus_g_proxy_call_no_reply (private->manager_proxy, "Register", - G_TYPE_OBJECT, private->object, /* TRACKER_EVOLUTION_REGISTRAR_PATH, */ - G_TYPE_UINT, get_stored_last_modseq (), - G_TYPE_INVALID, - G_TYPE_INVALID); - - error_handler: - - if (error) { - g_critical ("Could not setup DBus, %s\n", error->message); - g_error_free (error); - } - } -} - -static void -name_owner_changed_cb (DBusGProxy *proxy, - gchar *name, - gchar *old_owner, - gchar *new_owner, - gpointer user_data) -{ - - /* If we receive a NameOwnerChanged about the manager's service */ - - if (g_strcmp0 (name, TRACKER_EVOLUTION_MANAGER_SERVICE) == 0) { - if (tracker_is_empty_string (new_owner) && !tracker_is_empty_string (old_owner)) - deactivate_registrar (); - if (tracker_is_empty_string (old_owner) && !tracker_is_empty_string (new_owner)) - activate_registrar (); - } -} - -static void -list_names_reply_cb (DBusGProxy *proxy, - DBusGProxyCall *call, - gpointer user_data) -{ - GError *error = NULL; - GStrv names = NULL; - guint i = 0; - - dbus_g_proxy_end_call (proxy, call, &error, - G_TYPE_STRV, &names, - G_TYPE_INVALID); - - if (error) { - g_warning ("%s", error->message); - g_error_free (error); - if (names) - g_strfreev (names); - return; - } - - while (names[i] != NULL) { - /* If the manager's service is found, start the registrar */ - if (g_strcmp0 (names[i], TRACKER_EVOLUTION_MANAGER_SERVICE) == 0) { - activate_registrar (); - break; - } - i++; - } - - g_strfreev (names); -} - -static void -activate_dbus_client (void) -{ - EvolutionSupportPrivate *private; - - private = g_static_private_get (&private_key); - g_return_if_fail (private != NULL); - - private->dbus_proxy = dbus_g_proxy_new_for_name (private->connection, - DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, - DBUS_INTERFACE_DBUS); - - /* We listen for NameOwnerChanged to know when the manager's service - * comes up and to know when it goes down */ - - dbus_g_proxy_add_signal (private->dbus_proxy, "NameOwnerChanged", - G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, - G_TYPE_INVALID); - - dbus_g_proxy_connect_signal (private->dbus_proxy, "NameOwnerChanged", - G_CALLBACK (name_owner_changed_cb), - NULL, NULL); - - /* If the manager service is up and running, then list_names_reply_cb - * will execute activate_registrar, as it'll appear in the results of - * the ListNames DBus function. If not then we will just wait for the - * NameOwnerChanged to emit that the manager's service has came up. */ - - dbus_g_proxy_begin_call (private->dbus_proxy, "ListNames", - list_names_reply_cb, NULL, NULL, - G_TYPE_INVALID, - G_TYPE_INVALID); -} - -static gboolean -is_enabled (TrackerConfig *config) -{ - const gchar *module_name = "Evolution"; - - /* If none of the disabled modules include the Evolution module, - * we assume we are enabled in the configuration. - */ - if (!tracker_module_config_get_enabled (module_name)) { - return FALSE; - } - - if (g_slist_find_custom (tracker_config_get_disabled_modules (config), - module_name, - (GCompareFunc) strcmp)) { - return FALSE; - } - - return TRUE; -} - -static void -disabled_notify (GObject *pspec, - GParamSpec *gobject, - gpointer user_data) -{ - EvolutionSupportPrivate *private; - gboolean new_value; - - private = g_static_private_get (&private_key); - g_return_if_fail (private != NULL); - - new_value = is_enabled (private->config); - - if (private->is_enabled != new_value) { - if (private->is_enabled) { - /* If we were enabled, disable */ - deactivate_dbus_client (); - } else { - /* If we were disabled, enable */ - activate_dbus_client (); - } - private->is_enabled = new_value; - } - - g_message ("Evolution support service %s", - private->is_enabled ? "enabled" : "disabled"); -} - -static void -free_private (EvolutionSupportPrivate *private) -{ - dbus_g_connection_unref (private->connection); - g_object_unref (private->config); - g_free (private); -} - -void -tracker_evolution_init (TrackerConfig *config) -{ - DBusGConnection *connection; - GError *error = NULL; - - connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); - - if (!error) { - EvolutionSupportPrivate *private; - - private = g_new0 (EvolutionSupportPrivate, 1); - - private->deactivating = FALSE; - private->config = g_object_ref (config); - private->is_enabled = is_enabled (config); - private->connection = dbus_g_connection_ref (connection); - - g_static_private_set (&private_key, - private, - (GDestroyNotify) free_private); - - /* Hook configuration changes */ - g_signal_connect (private->config, "notify::disabled-modules", - G_CALLBACK (disabled_notify), - NULL); - - /* If in configuration we are enabled now */ - if (private->is_enabled) - activate_dbus_client (); - } else { - g_critical ("Could not setup DBus, %s\n", error->message); - g_error_free (error); - } -} - -void -tracker_evolution_shutdown () -{ - EvolutionSupportPrivate *private; - - private = g_static_private_get (&private_key); - g_return_if_fail (private != NULL); - - if (private->is_enabled) - deactivate_dbus_client (); - - g_static_private_set (&private_key, NULL, NULL); -} Index: src/tracker-indexer/tracker-push.c =================================================================== --- src/tracker-indexer/tracker-push.c (revision 0) +++ src/tracker-indexer/tracker-push.c (revision 0) @@ -0,0 +1,154 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Copyright (C) 2008, Nokia + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * Authors: + * Philip Van Hoof + */ + +#include "config.h" + +#include +#include +#include + +#include "tracker-push.h" + +typedef struct { + TrackerConfig *config; + TrackerIndexer *indexer; + GList *modules; +} PushSupportPrivate; + +typedef struct { + void (*create) (TrackerConfig *config, TrackerIndexer *indexer); + void (*shutdown) (void); + GModule *module; +} PushModule; + +static GStaticPrivate private_key = G_STATIC_PRIVATE_INIT; + +static void +unload_modules (PushSupportPrivate *private) +{ + GList *copy = private->modules; + + while (copy) { + PushModule *p_module = copy->data; + + p_module->shutdown (); + + g_module_close (p_module->module); + g_slice_free (PushModule, p_module); + + copy = g_list_next (copy); + } + + g_list_free (private->modules); + private->modules = NULL; +} + +static void +load_modules (PushSupportPrivate *private) +{ + GError *error = NULL; + GDir *dir = g_dir_open (PUSHI_MODULES_DIR, 0, &error); + const gchar *name; + + if (error) + goto handle_error; + + while ((name = g_dir_read_name (dir)) != NULL) { + if (g_str_has_suffix (name, G_MODULE_SUFFIX)) { + gchar *path = g_build_filename (PUSHI_MODULES_DIR, name, NULL); + PushModule *p_module = g_slice_new (PushModule); + + p_module->module = g_module_open (path, G_MODULE_BIND_LOCAL); + + if (!g_module_symbol (p_module->module, "tracker_push_module_shutdown", + (gpointer *) &p_module->shutdown) || + !g_module_symbol (p_module->module, "tracker_push_module_create", + (gpointer *) &p_module->create)) { + + g_warning ("Could not load module symbols for '%s': %s", + path, g_module_error ()); + + g_module_close (p_module->module); + g_slice_free (PushModule, p_module); + + } else { + g_module_make_resident (p_module->module); + + p_module->create (private->config, private->indexer); + + private->modules = g_list_prepend (private->modules, + p_module); + } + + g_free (path); + } + } + + handle_error: + + if (error) { + g_debug ("%s\n", error->message); + g_error_free (error); + } +} + +static void +free_private (PushSupportPrivate *private) +{ + if (private->config) + g_object_unref (private->config); + if (private->indexer) + g_object_unref (private->indexer); + + g_free (private); +} + +void +tracker_push_init (TrackerConfig *config, TrackerIndexer *indexer) +{ + PushSupportPrivate *private; + + private = g_new0 (PushSupportPrivate, 1); + + g_static_private_set (&private_key, + private, + (GDestroyNotify) free_private); + + private->indexer = g_object_ref (indexer); + private->config = g_object_ref (config); + + load_modules (private); +} + +void +tracker_push_shutdown () +{ + PushSupportPrivate *private; + + private = g_static_private_get (&private_key); + g_return_if_fail (private != NULL); + + unload_modules (private); + + g_static_private_set (&private_key, NULL, NULL); +} Index: src/tracker-indexer/tracker-push.h =================================================================== --- src/tracker-indexer/tracker-push.h (revision 0) +++ src/tracker-indexer/tracker-push.h (revision 0) @@ -0,0 +1,41 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Copyright (C) 2008, Nokia + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * Authors: + * Philip Van Hoof + */ + +#ifndef __TRACKER_INDEXER_PUSH_H__ +#define __TRACKER_INDEXER_PUSH_H__ + +#include +#include + +G_BEGIN_DECLS + +void tracker_push_init (TrackerConfig *config, TrackerIndexer *indexer); +void tracker_push_shutdown (void); + +void tracker_push_module_create (TrackerConfig *config, + TrackerIndexer *indexer); +void tracker_push_module_shutdown (void); + +G_END_DECLS + +#endif /* __TRACKER_INDEXER_PUSH_H__ */ Index: src/tracker-indexer/tracker-main.c =================================================================== --- src/tracker-indexer/tracker-main.c (revision 2873) +++ src/tracker-indexer/tracker-main.c (working copy) @@ -46,10 +46,10 @@ #include #include -#include #include "tracker-dbus.h" #include "tracker-indexer.h" +#include "tracker-push.h" #define ABOUT \ "Tracker " PACKAGE_VERSION "\n" \ @@ -383,9 +383,7 @@ tracker_data_manager_init (config, language, file_index, email_index); -#ifdef HAVE_EVOLUTION_PLUGIN - tracker_evolution_storer_init (config, indexer); -#endif + tracker_push_init (config, indexer); tracker_turtle_init (); @@ -412,9 +410,7 @@ tracker_data_manager_shutdown (); -#ifdef HAVE_EVOLUTION_PLUGIN - tracker_evolution_storer_shutdown (); -#endif + tracker_push_shutdown (); tracker_thumbnailer_shutdown (); tracker_dbus_shutdown (); Index: src/tracker-indexer/Makefile.am =================================================================== --- src/tracker-indexer/Makefile.am (revision 2873) +++ src/tracker-indexer/Makefile.am (working copy) @@ -8,6 +8,7 @@ -DLIBDIR=\""$(libdir)"\" \ -DLOCALEDIR=\""$(localedir)"\" \ -DINDEXER_MODULES_DIR=\""$(libdir)/tracker/indexer-modules"\" \ + -DPUSHI_MODULES_DIR=\""$(libdir)/tracker/push-modules/indexer"\" \ -DLIBEXEC_PATH=\""$(libexecdir)"\" \ -DG_LOG_DOMAIN=\"Tracker\" \ -DTRACKER_COMPILATION \ @@ -48,13 +49,10 @@ tracker-module-metadata-private.h \ tracker-marshal-main.c \ tracker-removable-device.c \ - tracker-removable-device.h + tracker-removable-device.h \ + tracker-push.c \ + tracker-push.h -if HAVE_EVOLUTION_PLUGIN -plugin_libs = \ - $(top_builddir)/src/plugins/evolution/libtracker-evolution-indexer.la -endif - tracker_indexer_LDADD = \ $(plugin_libs) \ libtracker-module.la \ Index: src/trackerd/tracker-push.c =================================================================== --- src/trackerd/tracker-push.c (revision 2870) +++ src/trackerd/tracker-push.c (working copy) @@ -26,161 +26,173 @@ #include #include -#include +#include "tracker-push.h" +#include "tracker-push-registrar.h" -#include "tracker-evolution.h" -#include "tracker-evolution-registrar.h" typedef struct { TrackerConfig *config; DBusGConnection *connection; - gboolean is_enabled; DBusGProxy *dbus_proxy; - DBusGProxy *manager_proxy; - GObject *object; - gboolean deactivating; -} EvolutionSupportPrivate; + GList *modules; +} PushSupportPrivate; +typedef struct { + TrackerPushRegistrar* (*create) (void); + void (*shutdown) (TrackerPushRegistrar *registrar); + TrackerPushRegistrar *registrar; + GModule *module; +} PushModule; + static GStaticPrivate private_key = G_STATIC_PRIVATE_INIT; -static guint -get_stored_last_modseq (void) -{ - return (guint) tracker_data_manager_get_db_option_int ("EvolutionLastModseq"); -} - static void -deactivate_registrar (void) +unload_modules (PushSupportPrivate *private) { - EvolutionSupportPrivate *private; + GList *copy = private->modules; - private = g_static_private_get (&private_key); - g_return_if_fail (private != NULL); + while (copy) { + PushModule *p_module = copy->data; - if (private->object) { - g_object_unref (private->object); - private->object = NULL; - } + p_module->shutdown (p_module->registrar); - if (private->manager_proxy && !private->deactivating) - g_object_unref (private->manager_proxy); + g_object_unref (p_module->registrar); + g_module_close (p_module->module); + g_slice_free (PushModule, p_module); - private->manager_proxy = NULL; + copy = g_list_next (copy); + } + + g_list_free (private->modules); + private->modules = NULL; } static void -deactivate_dbus_client (void) +load_modules (PushSupportPrivate *private) { - EvolutionSupportPrivate *private; + GError *error = NULL; + GDir *dir = g_dir_open (PUSHD_MODULES_DIR, 0, &error); + const gchar *name; - private = g_static_private_get (&private_key); - g_return_if_fail (private != NULL); + if (error) + goto handle_error; - deactivate_registrar (); + while ((name = g_dir_read_name (dir)) != NULL) { + if (g_str_has_suffix (name, G_MODULE_SUFFIX)) { + gchar *path = g_build_filename (PUSHD_MODULES_DIR, name, NULL); + PushModule *p_module = g_slice_new (PushModule); - if (private->dbus_proxy) { - g_object_unref (private->dbus_proxy); - private->dbus_proxy = NULL; - } -} + p_module->module = g_module_open (path, G_MODULE_BIND_LOCAL); -static void -on_manager_destroy (DBusGProxy *proxy, gpointer user_data) -{ - EvolutionSupportPrivate *private; - gboolean old_setting; + if (!g_module_symbol (p_module->module, "tracker_push_module_shutdown", + (gpointer *) &p_module->shutdown) || + !g_module_symbol (p_module->module, "tracker_push_module_create", + (gpointer *) &p_module->create)) { - private = g_static_private_get (&private_key); - g_return_if_fail (private != NULL); + g_warning ("Could not load module symbols for '%s': %s", + path, g_module_error ()); - old_setting = private->deactivating; + g_module_close (p_module->module); + g_slice_free (PushModule, p_module); - private->deactivating = TRUE; - deactivate_registrar (); - private->deactivating = old_setting; -} + } else { + g_module_make_resident (p_module->module); + p_module->registrar = p_module->create (); + private->modules = g_list_prepend (private->modules, + p_module); + } + + g_free (path); + } + } + + handle_error: + + if (error) { + g_debug ("%s\n", error->message); + g_error_free (error); + } +} + static void -activate_registrar (void) +name_owner_changed_cb (DBusGProxy *proxy, + gchar *name, + gchar *old_owner, + gchar *new_owner, + gpointer user_data) { - EvolutionSupportPrivate *private; + GList *copy; + PushSupportPrivate *private; + gboolean found = FALSE; private = g_static_private_get (&private_key); g_return_if_fail (private != NULL); - if (private->object) - return; + /* If we receive a NameOwnerChanged about the manager's service */ - private->manager_proxy = - dbus_g_proxy_new_for_name (private->connection, - TRACKER_EVOLUTION_MANAGER_SERVICE, - TRACKER_EVOLUTION_MANAGER_PATH, - TRACKER_EVOLUTION_MANAGER_INTERFACE); + copy = private->modules; - /* If while we had a proxy for the manager the manager shut itself down, - * then we'll get rid of our registrar too, in on_manager_destroy */ + while (copy && !found) { + PushModule *p_module = copy->data; + TrackerPushRegistrar *registrar = p_module->registrar; + const gchar *service = tracker_push_registrar_get_service (registrar); - g_signal_connect (private->manager_proxy, "destroy", - G_CALLBACK (on_manager_destroy), NULL); + if (g_strcmp0 (name, service) == 0) { - if (private->manager_proxy) { - GError *error = NULL; - guint result; + if (tracker_is_empty_string (new_owner) && !tracker_is_empty_string (old_owner)) { + tracker_push_registrar_disable (registrar); + } - /* Creation of the registrar */ - if (!org_freedesktop_DBus_request_name (private->dbus_proxy, - TRACKER_EVOLUTION_REGISTRAR_SERVICE, - DBUS_NAME_FLAG_DO_NOT_QUEUE, - &result, &error)) { - g_critical ("Could not setup DBus, %s in use\n", TRACKER_EVOLUTION_REGISTRAR_SERVICE); - goto error_handler; + if (tracker_is_empty_string (old_owner) && !tracker_is_empty_string (new_owner)) { + GError *error = NULL; + + tracker_push_registrar_enable (registrar, + private->connection, + private->dbus_proxy, + &error); + + if (error) { + g_debug ("%s\n", error->message); + g_error_free (error); + } + } + + found = TRUE; } - if (error) - goto error_handler; + copy = g_list_next (copy); + } - private->object = g_object_new (TRACKER_TYPE_EVOLUTION_REGISTRAR, - "connection", private->connection, - NULL); + if (!found) { + copy = private->modules; - dbus_g_object_type_install_info (G_OBJECT_TYPE (private->object), - ®istrar_methods); - dbus_g_connection_register_g_object (private->connection, - TRACKER_EVOLUTION_REGISTRAR_PATH, - private->object); + /* If the manager's service is found, start the registrar */ - /* Registration of the registrar to the manager */ - dbus_g_proxy_call_no_reply (private->manager_proxy, "Register", - G_TYPE_OBJECT, private->object, /* TRACKER_EVOLUTION_REGISTRAR_PATH, */ - G_TYPE_UINT, get_stored_last_modseq (), - G_TYPE_INVALID, - G_TYPE_INVALID); + while (copy) { + PushModule *p_module = copy->data; + TrackerPushRegistrar *registrar = p_module->registrar; + const gchar *service = tracker_push_registrar_get_service (registrar); - error_handler: + if (g_strcmp0 (name, service) == 0) { + GError *error = NULL; - if (error) { - g_critical ("Could not setup DBus, %s\n", error->message); - g_error_free (error); - } - } -} + tracker_push_registrar_enable (registrar, + private->connection, + private->dbus_proxy, + &error); -static void -name_owner_changed_cb (DBusGProxy *proxy, - gchar *name, - gchar *old_owner, - gchar *new_owner, - gpointer user_data) -{ + if (error) { + g_debug ("%s\n", error->message); + g_error_free (error); + } - /* If we receive a NameOwnerChanged about the manager's service */ + break; + } - if (g_strcmp0 (name, TRACKER_EVOLUTION_MANAGER_SERVICE) == 0) { - if (tracker_is_empty_string (new_owner) && !tracker_is_empty_string (old_owner)) - deactivate_registrar (); - if (tracker_is_empty_string (old_owner) && !tracker_is_empty_string (new_owner)) - activate_registrar (); + copy = g_list_next (copy); + } } } @@ -189,10 +201,15 @@ DBusGProxyCall *call, gpointer user_data) { + PushSupportPrivate *private; GError *error = NULL; GStrv names = NULL; guint i = 0; + gboolean found = FALSE; + private = g_static_private_get (&private_key); + g_return_if_fail (private != NULL); + dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRV, &names, G_TYPE_INVALID); @@ -205,140 +222,99 @@ return; } - while (names[i] != NULL) { + while (names[i] != NULL && !found) { + GList *copy = private->modules; + /* If the manager's service is found, start the registrar */ - if (g_strcmp0 (names[i], TRACKER_EVOLUTION_MANAGER_SERVICE) == 0) { - activate_registrar (); - break; - } - i++; - } - g_strfreev (names); -} + while (copy) { + PushModule *p_module = copy->data; + TrackerPushRegistrar *registrar = p_module->registrar; + const gchar *service = tracker_push_registrar_get_service (registrar); -static void -activate_dbus_client (void) -{ - EvolutionSupportPrivate *private; + if (g_strcmp0 (names[i], service) == 0) { + GError *lerror = NULL; - private = g_static_private_get (&private_key); - g_return_if_fail (private != NULL); + tracker_push_registrar_enable (registrar, + private->connection, + private->dbus_proxy, + &lerror); - private->dbus_proxy = dbus_g_proxy_new_for_name (private->connection, - DBUS_SERVICE_DBUS, - DBUS_PATH_DBUS, - DBUS_INTERFACE_DBUS); + if (lerror) { + g_debug ("%s\n", lerror->message); + g_error_free (lerror); + } - /* We listen for NameOwnerChanged to know when the manager's service - * comes up and to know when it goes down */ + found = TRUE; + break; + } - dbus_g_proxy_add_signal (private->dbus_proxy, "NameOwnerChanged", - G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, - G_TYPE_INVALID); - - dbus_g_proxy_connect_signal (private->dbus_proxy, "NameOwnerChanged", - G_CALLBACK (name_owner_changed_cb), - NULL, NULL); - - /* If the manager service is up and running, then list_names_reply_cb - * will execute activate_registrar, as it'll appear in the results of - * the ListNames DBus function. If not then we will just wait for the - * NameOwnerChanged to emit that the manager's service has came up. */ - - dbus_g_proxy_begin_call (private->dbus_proxy, "ListNames", - list_names_reply_cb, NULL, NULL, - G_TYPE_INVALID, - G_TYPE_INVALID); -} - -static gboolean -is_enabled (TrackerConfig *config) -{ - const gchar *module_name = "Evolution"; - - /* If none of the disabled modules include the Evolution module, - * we assume we are enabled in the configuration. - */ - if (!tracker_module_config_get_enabled (module_name)) { - return FALSE; - } - - if (g_slist_find_custom (tracker_config_get_disabled_modules (config), - module_name, - (GCompareFunc) strcmp)) { - return FALSE; - } - - return TRUE; -} - -static void -disabled_notify (GObject *pspec, - GParamSpec *gobject, - gpointer user_data) -{ - EvolutionSupportPrivate *private; - gboolean new_value; - - private = g_static_private_get (&private_key); - g_return_if_fail (private != NULL); - - new_value = is_enabled (private->config); - - if (private->is_enabled != new_value) { - if (private->is_enabled) { - /* If we were enabled, disable */ - deactivate_dbus_client (); - } else { - /* If we were disabled, enable */ - activate_dbus_client (); + copy = g_list_next (copy); } - private->is_enabled = new_value; + i++; } - g_message ("Evolution support service %s", - private->is_enabled ? "enabled" : "disabled"); + g_strfreev (names); } static void -free_private (EvolutionSupportPrivate *private) +free_private (PushSupportPrivate *private) { - dbus_g_connection_unref (private->connection); - g_object_unref (private->config); + if (private->connection) + dbus_g_connection_unref (private->connection); + if (private->config) + g_object_unref (private->config); g_free (private); } void -tracker_evolution_init (TrackerConfig *config) +tracker_push_init (TrackerConfig *config) { DBusGConnection *connection; GError *error = NULL; + PushSupportPrivate *private; + private = g_new0 (PushSupportPrivate, 1); + + g_static_private_set (&private_key, + private, + (GDestroyNotify) free_private); + + load_modules (private); + connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); if (!error) { - EvolutionSupportPrivate *private; - private = g_new0 (EvolutionSupportPrivate, 1); - - private->deactivating = FALSE; private->config = g_object_ref (config); - private->is_enabled = is_enabled (config); private->connection = dbus_g_connection_ref (connection); - g_static_private_set (&private_key, - private, - (GDestroyNotify) free_private); + private->dbus_proxy = dbus_g_proxy_new_for_name (private->connection, + DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS); - /* Hook configuration changes */ - g_signal_connect (private->config, "notify::disabled-modules", - G_CALLBACK (disabled_notify), - NULL); + /* We listen for NameOwnerChanged to know when the manager's service + * comes up and to know when it goes down */ - /* If in configuration we are enabled now */ - if (private->is_enabled) - activate_dbus_client (); + dbus_g_proxy_add_signal (private->dbus_proxy, "NameOwnerChanged", + G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_INVALID); + + dbus_g_proxy_connect_signal (private->dbus_proxy, "NameOwnerChanged", + G_CALLBACK (name_owner_changed_cb), + NULL, NULL); + + /* If the manager service is up and running, then list_names_reply_cb + * will execute activate_registrar, as it'll appear in the results of + * the ListNames DBus function. If not then we will just wait for the + * NameOwnerChanged to emit that the manager's service has came up. */ + + dbus_g_proxy_begin_call (private->dbus_proxy, "ListNames", + list_names_reply_cb, NULL, NULL, + G_TYPE_INVALID, + G_TYPE_INVALID); + } else { g_critical ("Could not setup DBus, %s\n", error->message); g_error_free (error); @@ -346,15 +322,19 @@ } void -tracker_evolution_shutdown () +tracker_push_shutdown (void) { - EvolutionSupportPrivate *private; + PushSupportPrivate *private; private = g_static_private_get (&private_key); g_return_if_fail (private != NULL); - if (private->is_enabled) - deactivate_dbus_client (); + if (private->dbus_proxy) { + g_object_unref (private->dbus_proxy); + private->dbus_proxy = NULL; + } + unload_modules (private); + g_static_private_set (&private_key, NULL, NULL); } Index: src/trackerd/tracker-push-registrar.c =================================================================== --- src/trackerd/tracker-push-registrar.c (revision 0) +++ src/trackerd/tracker-push-registrar.c (revision 0) @@ -0,0 +1,331 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Copyright (C) 2008, Nokia + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * Authors: + * Philip Van Hoof + */ + +#include "tracker-push-registrar.h" + +#define TRACKER_PUSH_REGISTRAR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TRACKER_TYPE_PUSH_REGISTRAR, TrackerPushRegistrarPrivate)) + +typedef struct TrackerPushRegistrarPrivate TrackerPushRegistrarPrivate; + +struct TrackerPushRegistrarPrivate { + DBusGProxy *manager_proxy; + GObject *object; + const gchar *service; +}; + +enum { + PROP_0, + PROP_MANAGER, + PROP_OBJECT, + PROP_SERVICE +}; + +static void tracker_push_registrar_finalize (GObject *object); +static void tracker_push_registrar_constructed (GObject *object); +static void tracker_push_registrar_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void tracker_push_registrar_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); + +G_DEFINE_TYPE (TrackerPushRegistrar, tracker_push_registrar, G_TYPE_OBJECT) + +static void +tracker_push_registrar_class_init (TrackerPushRegistrarClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->finalize = tracker_push_registrar_finalize; + + object_class->constructed = tracker_push_registrar_constructed; + object_class->set_property = tracker_push_registrar_set_property; + object_class->get_property = tracker_push_registrar_get_property; + + g_object_class_install_property (object_class, + PROP_MANAGER, + g_param_spec_object ("manager", + "Manager", + "Manager ", + G_TYPE_OBJECT, + G_PARAM_READWRITE)); + + g_object_class_install_property (object_class, + PROP_OBJECT, + g_param_spec_object ("object", + "Object", + "Object ", + G_TYPE_OBJECT, + G_PARAM_READWRITE)); + + g_object_class_install_property (object_class, + PROP_MANAGER, + g_param_spec_string ("service", + "Service", + "Service ", + NULL, + G_PARAM_READWRITE)); + + g_type_class_add_private (object_class, sizeof (TrackerPushRegistrarPrivate)); +} + +static void +tracker_push_registrar_init (TrackerPushRegistrar *registrar) +{ +} + +static void +tracker_push_registrar_finalize (GObject *object) +{ + TrackerPushRegistrarPrivate *priv; + + priv = TRACKER_PUSH_REGISTRAR_GET_PRIVATE (object); + + if (priv->object) + g_object_unref (priv->object); + + if (priv->manager_proxy) + g_object_unref (priv->manager_proxy); + + G_OBJECT_CLASS (tracker_push_registrar_parent_class)->finalize (object); +} + +static void +tracker_push_registrar_constructed (GObject *object) +{ + if (G_OBJECT_CLASS (tracker_push_registrar_parent_class)->constructed) { + G_OBJECT_CLASS (tracker_push_registrar_parent_class)->constructed (object); + } +} + +static void +tracker_push_registrar_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + TrackerPushRegistrarPrivate *priv; + + priv = TRACKER_PUSH_REGISTRAR_GET_PRIVATE (object); + + switch (prop_id) { + case PROP_MANAGER: + tracker_push_registrar_set_manager (TRACKER_PUSH_REGISTRAR (object), + g_value_get_object (value)); + break; + case PROP_OBJECT: + tracker_push_registrar_set_object (TRACKER_PUSH_REGISTRAR (object), + g_value_get_object (value)); + break; + case PROP_SERVICE: + tracker_push_registrar_set_service (TRACKER_PUSH_REGISTRAR (object), + g_value_get_string (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +static void +tracker_push_registrar_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + TrackerPushRegistrarPrivate *priv; + + priv = TRACKER_PUSH_REGISTRAR_GET_PRIVATE (object); + + switch (prop_id) { + case PROP_MANAGER: + g_value_set_object (value, priv->manager_proxy); + break; + case PROP_OBJECT: + g_value_set_object (value, priv->object); + break; + case PROP_SERVICE: + g_value_set_static_string (value, priv->service); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + } +} + +/** + * tracker_push_registrar_get_service: + * @registrar: A #TrackerPushRegistrar + * + * Returns the DBus service that @registrar consumes. + * + * Returns: The DBus service name. + **/ +G_CONST_RETURN gchar * +tracker_push_registrar_get_service (TrackerPushRegistrar *registrar) +{ + TrackerPushRegistrarPrivate *priv; + + priv = TRACKER_PUSH_REGISTRAR_GET_PRIVATE (registrar); + + return priv->service; +} + +/** + * tracker_push_registrar_get_object: + * @registrar: A #TrackerPushRegistrar + * + * Returns the DBus object that @registrar provides + * + * Returns: The DBus object. + **/ +GObject * +tracker_push_registrar_get_object (TrackerPushRegistrar *registrar) +{ + TrackerPushRegistrarPrivate *priv; + + priv = TRACKER_PUSH_REGISTRAR_GET_PRIVATE (registrar); + + return priv->object; +} + +/** + * tracker_push_registrar_get_manager: + * @registrar: A #TrackerPushRegistrar + * + * Returns the DBus proxy to the DBus object that @registrar consumes + * + * Returns: The DBus proxy. + **/ +DBusGProxy * +tracker_push_registrar_get_manager (TrackerPushRegistrar *registrar) +{ + TrackerPushRegistrarPrivate *priv; + + priv = TRACKER_PUSH_REGISTRAR_GET_PRIVATE (registrar); + + return priv->manager_proxy; +} + +/** + * tracker_push_registrar_set_service: + * @registrar: A #TrackerPushRegistrar + * @service: a DBus service string + * + * Set the DBus service string that @registrar will consumes + * + **/ +void +tracker_push_registrar_set_service (TrackerPushRegistrar *registrar, + const gchar *service) +{ + TrackerPushRegistrarPrivate *priv; + + priv = TRACKER_PUSH_REGISTRAR_GET_PRIVATE (registrar); + + priv->service = service; +} + +/** + * tracker_push_registrar_set_object: + * @registrar: A #TrackerPushRegistrar + * @object: a DBus object + * + * Set the DBus object created + **/ +void +tracker_push_registrar_set_object (TrackerPushRegistrar *registrar, + GObject *object) +{ + TrackerPushRegistrarPrivate *priv; + + priv = TRACKER_PUSH_REGISTRAR_GET_PRIVATE (registrar); + + if (priv->object) + g_object_unref (priv->object); + + if (object) + priv->object = g_object_ref (object); + else + priv->object = NULL; +} + +/** + * tracker_push_registrar_set_manager: + * @registrar: A #TrackerPushRegistrar + * @manager: a DBus proxy + * + * Set the DBus proxy to the manager DBus object being consumed + **/ +void +tracker_push_registrar_set_manager (TrackerPushRegistrar *registrar, + DBusGProxy *manager) +{ + TrackerPushRegistrarPrivate *priv; + + priv = TRACKER_PUSH_REGISTRAR_GET_PRIVATE (registrar); + + if (priv->manager_proxy) + g_object_unref (priv->manager_proxy); + + if (manager) + priv->manager_proxy = g_object_ref (manager); + else + priv->manager_proxy = NULL; +} + +/** + * tracker_push_registrar_enable: + * @registrar: A #TrackerPushRegistrar + * + * Enables the feature + * + **/ +void +tracker_push_registrar_enable (TrackerPushRegistrar *registrar, + DBusGConnection *connection, + DBusGProxy *dbus_proxy, + GError **error) +{ + if (TRACKER_PUSH_REGISTRAR_GET_CLASS (registrar)->enable) { + + TRACKER_PUSH_REGISTRAR_GET_CLASS (registrar)->enable (registrar, + connection, + dbus_proxy, + error); + } +} + +/** + * tracker_push_registrar_disable: + * @registrar: A #TrackerPushRegistrar + * + * Disables the feature + * + **/ +void +tracker_push_registrar_disable (TrackerPushRegistrar *registrar) +{ + if (TRACKER_PUSH_REGISTRAR_GET_CLASS (registrar)->disable) + TRACKER_PUSH_REGISTRAR_GET_CLASS (registrar)->disable (registrar); +} Index: src/trackerd/tracker-main.c =================================================================== --- src/trackerd/tracker-main.c (revision 2873) +++ src/trackerd/tracker-main.c (working copy) @@ -56,7 +56,7 @@ #include #include -#include +#include #include "tracker-crawler.h" #include "tracker-dbus.h" @@ -1127,9 +1127,7 @@ return EXIT_FAILURE; } -#ifdef HAVE_EVOLUTION_PLUGIN - tracker_evolution_init (config); -#endif + tracker_push_init (config); g_message ("Waiting for DBus requests..."); @@ -1201,11 +1199,9 @@ shutdown_directories (); /* Shutdown major subsystems */ - -#ifdef HAVE_EVOLUTION_PLUGIN - tracker_evolution_shutdown (); -#endif + tracker_push_shutdown (); + tracker_cleanup_shutdown (); tracker_xesam_manager_shutdown (); tracker_dbus_shutdown (); Index: src/trackerd/tracker-push.h =================================================================== --- src/trackerd/tracker-push.h (revision 2870) +++ src/trackerd/tracker-push.h (working copy) @@ -21,22 +21,25 @@ * Philip Van Hoof */ -#ifndef __LIBTRACKER_EVOLUTION_H__ -#define __LIBTRACKER_EVOLUTION_H__ +#ifndef __TRACKERD_PUSH_H__ +#define __TRACKERD_PUSH_H__ #if !defined (TRACKER_ENABLE_INTERNALS) && !defined (TRACKER_COMPILATION) #error "TRACKER_ENABLE_INTERNALS not defined, this must be defined to use tracker's internal functions" #endif #include +#include +#include +#include #include G_BEGIN_DECLS -void tracker_evolution_init (TrackerConfig *config); -void tracker_evolution_shutdown (void); +void tracker_push_init (TrackerConfig *config); +void tracker_push_shutdown (void); G_END_DECLS -#endif /* __LIBTRACKER_EVOLUTION_H__ */ +#endif /* __TRACKERD_PUSH_H__ */ Index: src/trackerd/tracker-push-registrar.h =================================================================== --- src/trackerd/tracker-push-registrar.h (revision 0) +++ src/trackerd/tracker-push-registrar.h (revision 0) @@ -0,0 +1,83 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Copyright (C) 2008, Nokia + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * Authors: + * Philip Van Hoof + */ + +#ifndef __TRACKER_PUSH_REGISTRAR_H__ +#define __TRACKER_PUSH_REGISTRAR_H__ + +#include +#include +#include + +G_BEGIN_DECLS + +#define TRACKER_TYPE_PUSH_REGISTRAR (tracker_push_registrar_get_type()) +#define TRACKER_PUSH_REGISTRAR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TRACKER_TYPE_PUSH_REGISTRAR, TrackerPushRegistrar)) +#define TRACKER_PUSH_REGISTRAR_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), TRACKER_TYPE_PUSH_REGISTRAR, TrackerPushRegistrarClass)) +#define TRACKER_IS_PUSH_REGISTRAR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TRACKER_TYPE_PUSH_REGISTRAR)) +#define TRACKER_IS_PUSH_REGISTRAR_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), TRACKER_TYPE_PUSH_REGISTRAR)) +#define TRACKER_PUSH_REGISTRAR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TRACKER_TYPE_PUSH_REGISTRAR, TrackerPushRegistrarClass)) + +typedef struct TrackerPushRegistrar TrackerPushRegistrar; +typedef struct TrackerPushRegistrarClass TrackerPushRegistrarClass; + +struct TrackerPushRegistrar { + GObject parent_instance; +}; + +struct TrackerPushRegistrarClass { + GObjectClass parent_class; + + void (*enable) (TrackerPushRegistrar *registrar, + DBusGConnection *connection, + DBusGProxy *dbus_proxy, + GError **error); + + void (*disable) (TrackerPushRegistrar *registrar); +}; + +GType tracker_push_registrar_get_type (void) G_GNUC_CONST; + +G_CONST_RETURN gchar * tracker_push_registrar_get_service (TrackerPushRegistrar *registrar); +GObject * tracker_push_registrar_get_object (TrackerPushRegistrar *registrar); +DBusGProxy * tracker_push_registrar_get_manager (TrackerPushRegistrar *registrar); + +void tracker_push_registrar_set_service (TrackerPushRegistrar *registrar, + const gchar *service); +void tracker_push_registrar_set_object (TrackerPushRegistrar *registrar, + GObject *object); +void tracker_push_registrar_set_manager (TrackerPushRegistrar *registrar, + DBusGProxy *manager); + + +void tracker_push_registrar_enable (TrackerPushRegistrar *registrar, + DBusGConnection *connection, + DBusGProxy *dbus_proxy, + GError **error); +void tracker_push_registrar_disable (TrackerPushRegistrar *registrar); + +TrackerPushRegistrar * tracker_push_module_create (void); +void tracker_push_module_shutdown (TrackerPushRegistrar *registrar); + +G_END_DECLS + +#endif /* __TRACKER_PUSH_REGISTRAR_H__ */ Index: src/trackerd/Makefile.am =================================================================== --- src/trackerd/Makefile.am (revision 2873) +++ src/trackerd/Makefile.am (working copy) @@ -5,6 +5,7 @@ -DLIBDIR=\""$(libdir)"\" \ -DLOCALEDIR=\""$(localedir)"\" \ -DMAIL_MODULES_DIR=\""$(libdir)"/tracker/mail-modules\" \ + -DPUSHD_MODULES_DIR=\""$(libdir)/tracker/push-modules/daemon"\" \ -DG_LOG_DOMAIN=\"Tracker\" \ -DTRACKER_COMPILATION \ -I$(top_srcdir)/src \ @@ -18,7 +19,8 @@ $(GMODULE_CFLAGS) \ $(GTHREAD_CFLAGS) \ $(RAPTOR_CFLAGS) \ - $(GLIB2_CFLAGS) + $(GLIB2_CFLAGS) \ + -I$(top_srcdir)/src/plugins/evolution/ if HAVE_INOTIFY inotify_libs = $(top_builddir)/src/libinotify/libinotify.la @@ -66,7 +68,11 @@ tracker-xesam-live-search.c \ tracker-xesam-live-search.h \ tracker-cleanup.c \ - tracker-cleanup.h + tracker-cleanup.h \ + tracker-push.c \ + tracker-push.h \ + tracker-push-registrar.c \ + tracker-push-registrar.h if OS_WIN32 trackerd_win_libs = -lws2_32 -lkernel32