tracker r2054 - in branches/indexer-split: . data/dbus src/tracker-indexer
- From: carlosg svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r2054 - in branches/indexer-split: . data/dbus src/tracker-indexer
- Date: Tue, 12 Aug 2008 12:49:21 +0000 (UTC)
Author: carlosg
Date: Tue Aug 12 12:49:21 2008
New Revision: 2054
URL: http://svn.gnome.org/viewvc/tracker?rev=2054&view=rev
Log:
2008-08-12 Carlos Garnacho <carlos imendio com>
* data/dbus/tracker-indexer.xml: Add Shutdown method.
* src/tracker-indexer/tracker-indexer.[ch] (tracker_indexer_stop)
(tracker_indexer_shutdown): Added internal and DBus method. Also added
a gboolean parameter to ::finished so we know whether the indexing was
interrupted.
* src/tracker-indexer/tracker-marshal.list: modify marshaller for
::finished.
* src/tracker-indexer/tracker-main.c (indexer_finished_cb): Quit
immediately if the indexing was interrupted.
* src/tracker-indexer/tracker-dbus.c (name_owner_changed_cb)
(dbus_register_object): Listen for changes in the daemon service
ownership. If the daemon dissapears, shut down the indexer.
Modified:
branches/indexer-split/ChangeLog
branches/indexer-split/data/dbus/tracker-indexer.xml
branches/indexer-split/src/tracker-indexer/tracker-dbus.c
branches/indexer-split/src/tracker-indexer/tracker-indexer.c
branches/indexer-split/src/tracker-indexer/tracker-indexer.h
branches/indexer-split/src/tracker-indexer/tracker-main.c
branches/indexer-split/src/tracker-indexer/tracker-marshal.list
Modified: branches/indexer-split/data/dbus/tracker-indexer.xml
==============================================================================
--- branches/indexer-split/data/dbus/tracker-indexer.xml (original)
+++ branches/indexer-split/data/dbus/tracker-indexer.xml Tue Aug 12 12:49:21 2008
@@ -53,6 +53,9 @@
<method name="Continue">
<annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
</method>
+ <method name="Shutdown">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ </method>
<!-- Signals -->
<signal name="Status">
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 Tue Aug 12 12:49:21 2008
@@ -63,6 +63,21 @@
return TRUE;
}
+static void
+name_owner_changed_cb (DBusGProxy *proxy,
+ gchar *name,
+ gchar *old_owner,
+ gchar *new_owner,
+ gpointer user_data)
+{
+ if (strcmp (name, TRACKER_DAEMON_SERVICE) == 0 && (!new_owner || !*new_owner)) {
+ /* Tracker daemon has dissapeared from
+ * the bus, shutdown the indexer.
+ */
+ tracker_indexer_stop (TRACKER_INDEXER (user_data));
+ }
+}
+
static gboolean
dbus_register_object (GObject *object,
DBusGConnection *connection,
@@ -77,6 +92,13 @@
dbus_g_object_type_install_info (G_OBJECT_TYPE (object), info);
dbus_g_connection_register_g_object (connection, path, object);
+ dbus_g_proxy_add_signal (proxy, "NameOwnerChanged",
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_INVALID);
+
+ dbus_g_proxy_connect_signal (proxy, "NameOwnerChanged",
+ G_CALLBACK (name_owner_changed_cb),
+ object, NULL);
return TRUE;
}
Modified: branches/indexer-split/src/tracker-indexer/tracker-indexer.c
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-indexer.c (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-indexer.c Tue Aug 12 12:49:21 2008
@@ -494,11 +494,12 @@
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (TrackerIndexerClass, finished),
NULL, NULL,
- tracker_marshal_VOID__DOUBLE_UINT,
+ tracker_marshal_VOID__DOUBLE_UINT_BOOL,
G_TYPE_NONE,
- 2,
+ 3,
G_TYPE_DOUBLE,
- G_TYPE_UINT);
+ G_TYPE_UINT,
+ G_TYPE_BOOLEAN);
signals[MODULE_STARTED] =
g_signal_new ("module-started",
G_OBJECT_CLASS_TYPE (object_class),
@@ -555,15 +556,12 @@
}
static void
-check_stopped (TrackerIndexer *indexer)
+check_stopped (TrackerIndexer *indexer,
+ gboolean interrupted)
{
gchar *str;
gdouble seconds_elapsed;
- if (indexer->private->idle_id == 0) {
- return;
- }
-
/* Flush remaining items */
schedule_flush (indexer, TRUE);
@@ -572,7 +570,10 @@
seconds_elapsed = g_timer_elapsed (indexer->private->timer, NULL);
/* Clean up source ID */
- indexer->private->idle_id = 0;
+ if (indexer->private->idle_id != 0) {
+ g_source_remove (indexer->private->idle_id);
+ indexer->private->idle_id = 0;
+ }
/* Print out how long it took us */
str = tracker_seconds_to_string (seconds_elapsed, FALSE);
@@ -585,7 +586,8 @@
/* Finally signal done */
g_signal_emit (indexer, signals[FINISHED], 0,
seconds_elapsed,
- indexer->private->files_indexed);
+ indexer->private->files_indexed,
+ interrupted);
}
static gboolean
@@ -1442,7 +1444,7 @@
process_module_emit_signals (indexer, NULL);
/* Signal stopped and clean up */
- check_stopped (indexer);
+ check_stopped (indexer, FALSE);
check_disk_space_stop (indexer);
return FALSE;
@@ -1509,6 +1511,14 @@
}
void
+tracker_indexer_stop (TrackerIndexer *indexer)
+{
+ g_return_if_fail (TRACKER_IS_INDEXER (indexer));
+
+ check_stopped (indexer, TRUE);
+}
+
+void
tracker_indexer_pause (TrackerIndexer *indexer,
DBusGMethodInvocation *context,
GError **error)
@@ -1776,3 +1786,22 @@
dbus_g_method_return (context);
tracker_dbus_request_success (request_id);
}
+
+void
+tracker_indexer_shutdown (TrackerIndexer *indexer,
+ DBusGMethodInvocation *context,
+ GError **error)
+{
+ guint request_id;
+
+ tracker_dbus_async_return_if_fail (TRACKER_IS_INDEXER (indexer), FALSE);
+
+ request_id = tracker_dbus_get_next_request_id ();
+ tracker_dbus_request_new (request_id,
+ "DBus request to shutdown the indexer");
+
+ tracker_indexer_stop (indexer);
+
+ dbus_g_method_return (context);
+ tracker_dbus_request_success (request_id);
+}
Modified: branches/indexer-split/src/tracker-indexer/tracker-indexer.h
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-indexer.h (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-indexer.h Tue Aug 12 12:49:21 2008
@@ -25,6 +25,7 @@
#include <glib-object.h>
#include <dbus/dbus-glib.h>
+#define TRACKER_DAEMON_SERVICE "org.freedesktop.Tracker"
#define TRACKER_INDEXER_SERVICE "org.freedesktop.Tracker.Indexer"
#define TRACKER_INDEXER_PATH "/org/freedesktop/Tracker/Indexer"
#define TRACKER_INDEXER_INTERFACE "org.freedesktop.Tracker.Indexer"
@@ -75,7 +76,10 @@
gboolean tracker_indexer_get_running (TrackerIndexer *indexer);
void tracker_indexer_set_running (TrackerIndexer *indexer,
gboolean running);
+void tracker_indexer_stop (TrackerIndexer *indexer);
+void tracker_indexer_process_all (TrackerIndexer *indexer);
+/* DBus methods */
void tracker_indexer_pause (TrackerIndexer *indexer,
DBusGMethodInvocation *context,
GError **error);
@@ -86,7 +90,6 @@
void tracker_indexer_continue (TrackerIndexer *indexer,
DBusGMethodInvocation *context,
GError **error);
-void tracker_indexer_process_all (TrackerIndexer *indexer);
void tracker_indexer_files_check (TrackerIndexer *indexer,
const gchar *module,
GStrv files,
@@ -116,6 +119,9 @@
GStrv values,
DBusGMethodInvocation *context,
GError **error);
+void tracker_indexer_shutdown (TrackerIndexer *indexer,
+ DBusGMethodInvocation *context,
+ GError **error);
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 Tue Aug 12 12:49:21 2008
@@ -202,10 +202,17 @@
indexer_finished_cb (TrackerIndexer *indexer,
gdouble seconds_elapsed,
guint items_indexed,
+ gboolean interrupted,
gpointer user_data)
{
g_message ("Finished indexing sent items");
+ if (interrupted) {
+ g_message ("Indexer was told to shutdown");
+ g_main_loop_quit (main_loop);
+ return;
+ }
+
if (quit_timeout_id) {
g_message ("Cancelling previous quit timeout");
g_source_remove (quit_timeout_id);
Modified: branches/indexer-split/src/tracker-indexer/tracker-marshal.list
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-marshal.list (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-marshal.list Tue Aug 12 12:49:21 2008
@@ -1,2 +1,2 @@
-VOID:DOUBLE,UINT
+VOID:DOUBLE,UINT,BOOL
VOID:DOUBLE,STRING,UINT,UINT
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]