tracker r1527 - in branches/indexer-split: . src/tracker-indexer
- From: carlosg svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r1527 - in branches/indexer-split: . src/tracker-indexer
- Date: Thu, 29 May 2008 10:42:48 +0000 (UTC)
Author: carlosg
Date: Thu May 29 10:42:48 2008
New Revision: 1527
URL: http://svn.gnome.org/viewvc/tracker?rev=1527&view=rev
Log:
2008-05-29 Carlos Garnacho <carlos imendio com>
* src/tracker-indexer/tracker-dbus.[ch]
(tracker_dbus_register_object): Added, registers to the bus an already
created object.
(tracker_dbus_register_object) (tracker_dbus_get_object): Removed, no
longer necessary.
(dbus_register_object): Modify to register an already created object.
* src/tracker-indexer/tracker-main.c: Create the TrackerIndexer prior
to registering it in DBus, so we can pass it construct only
properties.
Modified:
branches/indexer-split/ChangeLog
branches/indexer-split/src/tracker-indexer/tracker-dbus.c
branches/indexer-split/src/tracker-indexer/tracker-dbus.h
branches/indexer-split/src/tracker-indexer/tracker-main.c
Modified: branches/indexer-split/src/tracker-indexer/tracker-dbus.c
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-dbus.c (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-dbus.c Thu May 29 10:42:48 2008
@@ -29,7 +29,6 @@
static DBusGConnection *connection;
static DBusGProxy *proxy;
-static GSList *objects;
static gboolean
dbus_register_service (DBusGProxy *proxy,
@@ -64,25 +63,21 @@
return TRUE;
}
-static gpointer
-dbus_register_object (DBusGConnection *connection,
+static gboolean
+dbus_register_object (GObject *object,
+ DBusGConnection *connection,
DBusGProxy *proxy,
- GType object_type,
const DBusGObjectInfo *info,
const gchar *path)
{
- GObject *object;
-
g_message ("Registering DBus object...");
g_message (" Path '%s'", path);
- g_message (" Type '%s'", g_type_name (object_type));
-
- object = g_object_new (object_type, NULL);
+ g_message (" Object Type '%s'", G_OBJECT_TYPE_NAME (object));
- dbus_g_object_type_install_info (object_type, info);
+ dbus_g_object_type_install_info (G_OBJECT_TYPE (object), info);
dbus_g_connection_register_g_object (connection, path, object);
- return object;
+ return TRUE;
}
static gboolean
@@ -129,7 +124,7 @@
tracker_dbus_init (void)
{
/* Don't reinitialize */
- if (objects) {
+ if (connection && proxy) {
return TRUE;
}
@@ -144,12 +139,6 @@
void
tracker_dbus_shutdown (void)
{
- if (objects) {
- g_slist_foreach (objects, (GFunc) g_object_unref, NULL);
- g_slist_free (objects);
- objects = NULL;
- }
-
if (proxy) {
g_object_unref (proxy);
proxy = NULL;
@@ -159,42 +148,22 @@
}
gboolean
-tracker_dbus_register_objects (void)
+tracker_dbus_register_object (GObject *object)
{
- GObject *object;
-
if (!connection || !proxy) {
g_critical ("DBus support must be initialized before registering objects!");
return FALSE;
}
- /* Add org.freedesktop.Tracker.Indexer */
- if (!(object = dbus_register_object (connection,
- proxy,
- TRACKER_TYPE_INDEXER,
- &dbus_glib_tracker_indexer_object_info,
- TRACKER_INDEXER_PATH))) {
- return FALSE;
- }
-
- objects = g_slist_prepend (objects, object);
-
- /* Reverse list since we added objects at the top each time */
- objects = g_slist_reverse (objects);
-
- return TRUE;
-}
-
-GObject *
-tracker_dbus_get_object (GType type)
-{
- GSList *l;
-
- for (l = objects; l; l = l->next) {
- if (G_OBJECT_TYPE (l->data) == type) {
- return l->data;
- }
+ if (TRACKER_IS_INDEXER (object)) {
+ return dbus_register_object (object,
+ connection,
+ proxy,
+ &dbus_glib_tracker_indexer_object_info,
+ TRACKER_INDEXER_PATH);
+ } else {
+ g_warning ("Object not handled by DBus");
}
- return NULL;
+ return FALSE;
}
Modified: branches/indexer-split/src/tracker-indexer/tracker-dbus.h
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-dbus.h (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-dbus.h Thu May 29 10:42:48 2008
@@ -28,8 +28,7 @@
gboolean tracker_dbus_init (void);
void tracker_dbus_shutdown (void);
-gboolean tracker_dbus_register_objects (void);
-GObject *tracker_dbus_get_object (GType type);
+gboolean tracker_dbus_register_object (GObject *object);
G_END_DECLS
Modified: branches/indexer-split/src/tracker-indexer/tracker-main.c
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-main.c (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-main.c Thu May 29 10:42:48 2008
@@ -186,7 +186,7 @@
main (gint argc, gchar *argv[])
{
TrackerConfig *config;
- GObject *indexer;
+ TrackerIndexer *indexer;
GOptionContext *context;
GError *error = NULL;
gchar *summary = NULL;
@@ -264,6 +264,8 @@
return EXIT_FAILURE;
}
+ initialize_indexer ();
+
#ifdef HAVE_IOPRIO
/* Set IO priority */
tracker_ioprio_init ();
@@ -282,17 +284,15 @@
str ? str : "no error given");
}
+ indexer = tracker_indexer_new (reindex);
+
/* Make Tracker available for introspection */
- if (!tracker_dbus_register_objects ()) {
+ if (!tracker_dbus_register_object (G_OBJECT (indexer))) {
return EXIT_FAILURE;
}
- initialize_indexer ();
-
/* Create the indexer and run the main loop */
- indexer = tracker_dbus_get_object (TRACKER_TYPE_INDEXER);
- g_object_set (G_OBJECT (indexer), "reindex", reindex, NULL);
g_signal_connect (indexer, "finished",
G_CALLBACK (indexer_finished_cb), NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]