tracker r2437 - in trunk: . data/dbus src/tracker-indexer src/trackerd
- From: carlosg svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r2437 - in trunk: . data/dbus src/tracker-indexer src/trackerd
- Date: Mon, 3 Nov 2008 16:23:04 +0000 (UTC)
Author: carlosg
Date: Mon Nov 3 16:23:04 2008
New Revision: 2437
URL: http://svn.gnome.org/viewvc/tracker?rev=2437&view=rev
Log:
2008-11-03 Carlos Garnacho <carlos imendio com>
* data/dbus/tracker-indexer.xml: Add "reason" parameter to ::Paused.
* src/tracker-indexer/tracker-indexer.c: Add "Low batt" state. Add
extra parameter to ::paused and emit it for any state that could
be relevant for the daemon. Same for ::continued.
* src/trackerd/tracker-daemon.c (indexer_paused_cb): Change status
depending on the reason for the indexer to be paused.
(indexer_continued_cb): And make it continue here.
* src/trackerd/tracker-status.[ch]: Add "Disk full" and "Low batt" to
TrackerStatus enum.
* src/trackerd/tracker-dbus.c: Miscellaneous changes.
Modified:
trunk/ChangeLog
trunk/data/dbus/tracker-indexer.xml
trunk/src/tracker-indexer/tracker-indexer.c
trunk/src/trackerd/tracker-daemon.c
trunk/src/trackerd/tracker-dbus.c
trunk/src/trackerd/tracker-status.c
trunk/src/trackerd/tracker-status.h
Modified: trunk/data/dbus/tracker-indexer.xml
==============================================================================
--- trunk/data/dbus/tracker-indexer.xml (original)
+++ trunk/data/dbus/tracker-indexer.xml Mon Nov 3 16:23:04 2008
@@ -71,7 +71,9 @@
<arg type="u" name="items_remaining" />
</signal>
<signal name="Started" />
- <signal name="Paused" />
+ <signal name="Paused">
+ <arg type="s" name="reason" />
+ </signal>
<signal name="Continued" />
<signal name="Finished">
<arg type="d" name="elapsed_time" />
Modified: trunk/src/tracker-indexer/tracker-indexer.c
==============================================================================
--- trunk/src/tracker-indexer/tracker-indexer.c (original)
+++ trunk/src/tracker-indexer/tracker-indexer.c Mon Nov 3 16:23:04 2008
@@ -168,7 +168,8 @@
TRACKER_INDEXER_STATE_FLUSHING = 1 << 0,
TRACKER_INDEXER_STATE_PAUSED = 1 << 1,
TRACKER_INDEXER_STATE_DISK_FULL = 1 << 2,
- TRACKER_INDEXER_STATE_STOPPED = 1 << 3
+ TRACKER_INDEXER_STATE_STOPPED = 1 << 3,
+ TRACKER_INDEXER_STATE_LOW_BATT = 1 << 4
};
enum {
@@ -538,9 +539,9 @@
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (TrackerIndexerClass, paused),
NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
+ g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE,
- 0);
+ 1, G_TYPE_STRING);
signals[CONTINUED] =
g_signal_new ("continued",
G_OBJECT_CLASS_TYPE (object_class),
@@ -2206,10 +2207,7 @@
state = indexer->private->state;
- if ((state & TRACKER_INDEXER_STATE_FLUSHING) ||
- (state & TRACKER_INDEXER_STATE_DISK_FULL) ||
- (state & TRACKER_INDEXER_STATE_STOPPED) ||
- (state & TRACKER_INDEXER_STATE_PAUSED)) {
+ if (state != 0) {
check_disk_space_stop (indexer);
signal_status_timeout_stop (indexer);
stop_scheduled_flush (indexer);
@@ -2240,16 +2238,52 @@
state_set_flags (TrackerIndexer *indexer,
TrackerIndexerState state)
{
+ guint old_state;
+
+ old_state = indexer->private->state;
indexer->private->state |= state;
state_check (indexer);
+
+ /* Just emit ::paused for the states that
+ * could be relevant outside the indexer
+ */
+ if ((! (old_state & TRACKER_INDEXER_STATE_PAUSED)) &&
+ (! (old_state & TRACKER_INDEXER_STATE_DISK_FULL)) &&
+ (! (old_state & TRACKER_INDEXER_STATE_LOW_BATT)) &&
+ (state & TRACKER_INDEXER_STATE_PAUSED ||
+ state & TRACKER_INDEXER_STATE_DISK_FULL ||
+ state & TRACKER_INDEXER_STATE_LOW_BATT)) {
+ const gchar *reason = NULL;
+
+ if (state & TRACKER_INDEXER_STATE_DISK_FULL) {
+ reason = "Disk full";
+ } else if (state & TRACKER_INDEXER_STATE_LOW_BATT) {
+ reason = "Battery low";
+ }
+
+ g_signal_emit (indexer, signals[PAUSED], 0, reason);
+ }
}
static void
state_unset_flags (TrackerIndexer *indexer,
TrackerIndexerState state)
{
+ guint old_state, new_state;
+
+ old_state = indexer->private->state;
indexer->private->state &= ~(state);
+ new_state = indexer->private->state;
state_check (indexer);
+
+ if ((old_state & TRACKER_INDEXER_STATE_PAUSED ||
+ old_state & TRACKER_INDEXER_STATE_DISK_FULL ||
+ old_state & TRACKER_INDEXER_STATE_LOW_BATT) &&
+ (! (new_state & TRACKER_INDEXER_STATE_PAUSED)) &&
+ (! (new_state & TRACKER_INDEXER_STATE_DISK_FULL)) &&
+ (! (new_state & TRACKER_INDEXER_STATE_LOW_BATT))) {
+ g_signal_emit (indexer, signals[CONTINUED], 0);
+ }
}
void
@@ -2265,15 +2299,11 @@
tracker_db_index_set_paused (indexer->private->file_index, FALSE);
tracker_db_index_set_paused (indexer->private->email_index, FALSE);
-
- g_signal_emit (indexer, signals[CONTINUED], 0);
} else if (!running && !(state & TRACKER_INDEXER_STATE_PAUSED)) {
state_set_flags (indexer, TRACKER_INDEXER_STATE_PAUSED);
tracker_db_index_set_paused (indexer->private->file_index, TRUE);
tracker_db_index_set_paused (indexer->private->email_index, TRUE);
-
- g_signal_emit (indexer, signals[PAUSED], 0);
}
}
Modified: trunk/src/trackerd/tracker-daemon.c
==============================================================================
--- trunk/src/trackerd/tracker-daemon.c (original)
+++ trunk/src/trackerd/tracker-daemon.c Mon Nov 3 16:23:04 2008
@@ -58,19 +58,18 @@
LAST_SIGNAL
};
-static void tracker_daemon_finalize (GObject *object);
-static void indexer_pause_cb (DBusGProxy *proxy,
- GError *error,
- gpointer user_data);
-static void indexer_continue_cb (DBusGProxy *proxy,
- GError *error,
- gpointer user_data);
-static void indexer_paused_cb (DBusGProxy *proxy,
- GError *error,
- gpointer user_data);
-static void indexer_continued_cb (DBusGProxy *proxy,
- GError *error,
- gpointer user_data);
+static void tracker_daemon_finalize (GObject *object);
+static void indexer_pause_cb (DBusGProxy *proxy,
+ GError *error,
+ gpointer user_data);
+static void indexer_continue_cb (DBusGProxy *proxy,
+ GError *error,
+ gpointer user_data);
+static void indexer_paused_cb (DBusGProxy *proxy,
+ const gchar *reason,
+ gpointer user_data);
+static void indexer_continued_cb (DBusGProxy *proxy,
+ gpointer user_data);
static guint signals[LAST_SIGNAL] = {0};
@@ -343,19 +342,27 @@
}
static void
-indexer_paused_cb (DBusGProxy *proxy,
- GError *error,
- gpointer user_data)
-{
- g_message ("The indexer has paused");
+indexer_paused_cb (DBusGProxy *proxy,
+ const gchar *reason,
+ gpointer user_data)
+{
+ g_message ("The indexer has paused (Reason: %s)", reason);
+
+ if (reason) {
+ if (strcmp (reason, "Disk full") == 0) {
+ tracker_status_set_and_signal (TRACKER_STATUS_DISK_FULL);
+ } else if (strcmp (reason, "Battery low") == 0) {
+ tracker_status_set_and_signal (TRACKER_STATUS_LOW_BATT);
+ }
+ }
}
static void
indexer_continued_cb (DBusGProxy *proxy,
- GError *error,
gpointer user_data)
{
g_message ("The indexer has continued");
+ tracker_status_set_and_signal (TRACKER_STATUS_INDEXING);
}
/*
Modified: trunk/src/trackerd/tracker-dbus.c
==============================================================================
--- trunk/src/trackerd/tracker-dbus.c (original)
+++ trunk/src/trackerd/tracker-dbus.c Mon Nov 3 16:23:04 2008
@@ -200,8 +200,13 @@
DBusGProxy *proxy;
GError *error = NULL;
gboolean set_paused = TRUE;
+ TrackerStatus status;
- if (tracker_status_get () != TRACKER_STATUS_INDEXING) {
+ status = tracker_status_get ();
+
+ if (status != TRACKER_STATUS_INDEXING &&
+ status != TRACKER_STATUS_DISK_FULL &&
+ status != TRACKER_STATUS_LOW_BATT) {
return;
}
@@ -484,6 +489,7 @@
G_TYPE_INVALID);
dbus_g_proxy_add_signal (proxy_for_indexer,
"Paused",
+ G_TYPE_STRING,
G_TYPE_INVALID);
dbus_g_proxy_add_signal (proxy_for_indexer,
"Continued",
Modified: trunk/src/trackerd/tracker-status.c
==============================================================================
--- trunk/src/trackerd/tracker-status.c (original)
+++ trunk/src/trackerd/tracker-status.c Mon Nov 3 16:23:04 2008
@@ -150,6 +150,12 @@
{ TRACKER_STATUS_SHUTDOWN,
"TRACKER_STATUS_SHUTDOWN",
"Shutdown" },
+ { TRACKER_STATUS_DISK_FULL,
+ "TRACKER_STATUS_DISK_FULL",
+ "Disk full" },
+ { TRACKER_STATUS_LOW_BATT,
+ "TRACKER_STATUS_LOW_BATT",
+ "Battery low" },
{ 0, NULL, NULL }
};
Modified: trunk/src/trackerd/tracker-status.h
==============================================================================
--- trunk/src/trackerd/tracker-status.h (original)
+++ trunk/src/trackerd/tracker-status.h Mon Nov 3 16:23:04 2008
@@ -37,7 +37,9 @@
TRACKER_STATUS_PENDING,
TRACKER_STATUS_OPTIMIZING,
TRACKER_STATUS_IDLE,
- TRACKER_STATUS_SHUTDOWN
+ TRACKER_STATUS_SHUTDOWN,
+ TRACKER_STATUS_DISK_FULL,
+ TRACKER_STATUS_LOW_BATT
} TrackerStatus;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]