tracker r2047 - in branches/indexer-split: . src/trackerd
- From: mr svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r2047 - in branches/indexer-split: . src/trackerd
- Date: Tue, 12 Aug 2008 10:23:51 +0000 (UTC)
Author: mr
Date: Tue Aug 12 10:23:51 2008
New Revision: 2047
URL: http://svn.gnome.org/viewvc/tracker?rev=2047&view=rev
Log:
* src/trackerd/tracker-crawler.c:
* src/trackerd/tracker-daemon.c:
* src/trackerd/tracker-dbus.c:
* src/trackerd/tracker-main.[ch]:
* src/trackerd/tracker-processor.c:
* src/trackerd/tracker-status.[ch]: Hold all valuable states in
the status module, like is_readonly, is_first_time_index,
is_running, etc.
Modified:
branches/indexer-split/ChangeLog
branches/indexer-split/src/trackerd/tracker-crawler.c
branches/indexer-split/src/trackerd/tracker-daemon.c
branches/indexer-split/src/trackerd/tracker-dbus.c
branches/indexer-split/src/trackerd/tracker-main.c
branches/indexer-split/src/trackerd/tracker-main.h
branches/indexer-split/src/trackerd/tracker-processor.c
branches/indexer-split/src/trackerd/tracker-status.c
branches/indexer-split/src/trackerd/tracker-status.h
Modified: branches/indexer-split/src/trackerd/tracker-crawler.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-crawler.c (original)
+++ branches/indexer-split/src/trackerd/tracker-crawler.c Tue Aug 12 10:23:51 2008
@@ -32,9 +32,9 @@
#include "tracker-crawler.h"
#include "tracker-dbus.h"
#include "tracker-indexer-client.h"
-#include "tracker-main.h"
#include "tracker-monitor.h"
#include "tracker-marshal.h"
+#include "tracker-status.h"
#define TRACKER_CRAWLER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_CRAWLER, TrackerCrawlerPrivate))
@@ -417,7 +417,7 @@
priv = crawler->private;
/* If manually paused, we hold off until unpaused */
- if (tracker_get_is_paused_manually ()) {
+ if (tracker_status_get_is_paused_manually ()) {
return TRUE;
}
Modified: branches/indexer-split/src/trackerd/tracker-daemon.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-daemon.c (original)
+++ branches/indexer-split/src/trackerd/tracker-daemon.c Tue Aug 12 10:23:51 2008
@@ -397,7 +397,7 @@
* don't know if something else paused us or if it
* was the signal from our request.
*/
- tracker_set_is_paused_manually (value);
+ tracker_status_set_is_paused_manually (value);
if (value) {
org_freedesktop_Tracker_Indexer_pause_async (priv->indexer_proxy,
@@ -419,7 +419,7 @@
* readonly mode.
*/
tracker_config_set_enable_indexing (priv->config, value);
- tracker_set_is_readonly (value);
+ tracker_status_set_is_readonly (value);
g_message ("Enable indexing set to %d", value);
} else if (strcasecmp (option, "EnableWatching") == 0) {
tracker_config_set_enable_watches (priv->config, value);
Modified: branches/indexer-split/src/trackerd/tracker-dbus.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-dbus.c (original)
+++ branches/indexer-split/src/trackerd/tracker-dbus.c Tue Aug 12 10:23:51 2008
@@ -225,7 +225,7 @@
/* Third check if we are already paused, if we are there is
* no need to tell the indexer.
*/
- if (tracker_get_is_paused_manually ()) {
+ if (tracker_status_get_is_paused_manually ()) {
g_message ("Tracker is already manually paused, doing nothing");
return;
}
Modified: branches/indexer-split/src/trackerd/tracker-main.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-main.c (original)
+++ branches/indexer-split/src/trackerd/tracker-main.c Tue Aug 12 10:23:51 2008
@@ -96,11 +96,6 @@
static gchar *user_data_dir;
static gchar *sys_tmp_dir;
-static gboolean is_running;
-static gboolean is_readonly;
-static gboolean is_first_time_index;
-static gboolean is_paused_manually;
-static gboolean in_merge;
static gboolean reindex_on_shutdown;
/* Private command line parameters */
@@ -237,7 +232,7 @@
return TRACKER_RUNNING_MAIN_INSTANCE;
}
- if (!is_first_time_index &&
+ if (!tracker_status_get_is_first_time_index () &&
tracker_config_get_disable_indexing_on_battery (config)) {
g_message ("Battery in use");
g_message ("Config is set to not index on battery");
@@ -249,7 +244,7 @@
* overwritten by the config option to disable or not
* indexing on battery initially.
*/
- if (is_first_time_index &&
+ if (tracker_status_get_is_first_time_index () &&
tracker_config_get_disable_indexing_on_battery_init (config)) {
g_message ("Battery in use & reindex is needed");
g_message ("Config is set to not index on battery for initial index");
@@ -445,10 +440,10 @@
/*
* Create SQLite databases
*/
- if (!is_readonly && force_reindex) {
+ if (!tracker_status_get_is_readonly () && force_reindex) {
TrackerDBInterface *iface;
- is_first_time_index = TRUE;
+ tracker_status_set_is_readonly (TRUE);
/* Reset stats for embedded services if they are being reindexed */
@@ -468,18 +463,18 @@
}
/* Check db integrity if not previously shut down cleanly */
- if (!is_readonly &&
- !is_first_time_index &&
+ if (!tracker_status_get_is_readonly () &&
+ !tracker_status_get_is_first_time_index () &&
tracker_db_get_option_int ("IntegrityCheck") == 1) {
g_message ("Performing integrity check as the daemon was not shutdown cleanly");
/* FIXME: Finish */
}
- if (!is_readonly) {
+ if (!tracker_status_get_is_readonly ()) {
tracker_db_set_option_int ("IntegrityCheck", 1);
}
- if (is_first_time_index) {
+ if (tracker_status_get_is_first_time_index ()) {
tracker_db_set_option_int ("InitialIndex", 1);
}
@@ -577,7 +572,7 @@
static gboolean
start_cb (gpointer user_data)
{
- if (!is_running) {
+ if (!tracker_status_get_is_running ()) {
return FALSE;
}
@@ -601,6 +596,7 @@
TrackerRunningLevel runtime_level;
TrackerDBManagerFlags flags = 0;
TrackerDBIndexManagerFlags index_flags = 0;
+ gboolean is_first_time_index;
g_type_init ();
@@ -764,6 +760,8 @@
}
tracker_db_manager_init (flags, &is_first_time_index);
+ tracker_status_set_is_first_time_index (is_first_time_index);
+
if (!tracker_db_index_manager_init (index_flags,
tracker_config_get_min_bucket_count (config),
tracker_config_get_max_bucket_count (config))) {
@@ -780,11 +778,11 @@
return EXIT_FAILURE;
case TRACKER_RUNNING_READ_ONLY:
- is_readonly = TRUE;
+ tracker_status_set_is_readonly (TRUE);
break;
case TRACKER_RUNNING_MAIN_INSTANCE:
- is_readonly = FALSE;
+ tracker_status_set_is_readonly (FALSE);
break;
}
@@ -809,7 +807,7 @@
/* Set our status as running, if this is FALSE, threads stop
* doing what they do and shutdown.
*/
- is_running = TRUE;
+ tracker_status_set_is_readonly (TRUE);
/* Make Tracker available for introspection */
if (!tracker_dbus_register_objects (config,
@@ -821,7 +819,7 @@
g_message ("Waiting for DBus requests...");
- if (!is_readonly) {
+ if (!tracker_status_get_is_readonly ()) {
gint seconds;
seconds = tracker_config_get_initial_sleep (config);
@@ -843,7 +841,7 @@
tracker_status_set_and_signal (TRACKER_STATUS_IDLE);
}
- if (is_running) {
+ if (tracker_status_get_is_running ()) {
main_loop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (main_loop);
}
@@ -901,7 +899,7 @@
void
tracker_shutdown (void)
{
- is_running = FALSE;
+ tracker_status_set_is_running (FALSE);
/* FIXME: Should we stop the crawler? */
@@ -914,66 +912,6 @@
return sys_tmp_dir;
}
-gboolean
-tracker_get_is_readonly (void)
-{
- return is_readonly;
-}
-
-void
-tracker_set_is_readonly (gboolean value)
-{
- gboolean emit;
-
- emit = is_readonly != value;
-
- if (!emit) {
- return;
- }
-
- /* Set value */
- is_readonly = value;
-
- /* Signal the status change */
- tracker_status_signal ();
-}
-
-gboolean
-tracker_get_is_first_time_index (void)
-{
- return is_first_time_index;
-}
-
-gboolean
-tracker_get_in_merge (void)
-{
- return in_merge;
-}
-
-gboolean
-tracker_get_is_paused_manually (void)
-{
- return is_paused_manually;
-}
-
-void
-tracker_set_is_paused_manually (gboolean value)
-{
- gboolean emit;
-
- emit = is_paused_manually != value;
-
- if (!emit) {
- return;
- }
-
- /* Set value */
- is_paused_manually = value;
-
- /* Signal the status change */
- tracker_status_signal ();
-}
-
void
tracker_set_reindex_on_shutdown (gboolean value)
{
Modified: branches/indexer-split/src/trackerd/tracker-main.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-main.h (original)
+++ branches/indexer-split/src/trackerd/tracker-main.h Tue Aug 12 10:23:51 2008
@@ -31,15 +31,6 @@
const gchar *tracker_get_sys_tmp_dir (void);
-gboolean tracker_get_is_readonly (void);
-void tracker_set_is_readonly (gboolean value);
-
-gboolean tracker_get_is_first_time_index (void);
-gboolean tracker_get_in_merge (void);
-
-gboolean tracker_get_is_paused_manually (void);
-void tracker_set_is_paused_manually (gboolean value);
-
void tracker_set_reindex_on_shutdown (gboolean value);
G_END_DECLS
Modified: branches/indexer-split/src/trackerd/tracker-processor.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-processor.c (original)
+++ branches/indexer-split/src/trackerd/tracker-processor.c Tue Aug 12 10:23:51 2008
@@ -555,7 +555,7 @@
* events but we still queue them ready to send when we are
* unpaused.
*/
- if (tracker_get_is_paused_manually ()) {
+ if (tracker_status_get_is_paused_manually ()) {
g_message ("We are paused, sending nothing to the index until we are unpaused");
return TRUE;
}
Modified: branches/indexer-split/src/trackerd/tracker-status.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-status.c (original)
+++ branches/indexer-split/src/trackerd/tracker-status.c Tue Aug 12 10:23:51 2008
@@ -26,18 +26,58 @@
#include "tracker-daemon.h"
#include "tracker-main.h"
-static TrackerStatus status = TRACKER_STATUS_INITIALIZING;
-static TrackerConfig *status_config;
-static gpointer status_type_class;
+typedef struct {
+ TrackerStatus status;
+ gpointer type_class;
+
+ TrackerConfig *config;
+
+ gboolean is_running;
+ gboolean is_readonly;
+ gboolean is_first_time_index;
+ gboolean is_paused_manually;
+ gboolean is_paused_for_io;
+ gboolean in_merge;
+} TrackerStatusPrivate;
+
+static GStaticPrivate private_key = G_STATIC_PRIVATE_INIT;
+
+static void
+private_free (gpointer data)
+{
+ TrackerStatusPrivate *private;
+
+ private = data;
+
+ if (private->config) {
+ g_object_unref (private->config);
+ }
+
+ if (private->type_class) {
+ g_type_class_unref (private->type_class);
+ }
+
+ g_free (private);
+}
gboolean
tracker_status_init (TrackerConfig *config)
{
- GType type;
+ GType type;
+ TrackerStatusPrivate *private;
g_return_val_if_fail (TRACKER_IS_CONFIG (config), FALSE);
- status = TRACKER_STATUS_INITIALIZING;
+ private = g_static_private_get (&private_key);
+ if (private) {
+ g_warning ("Already initialized (%s)",
+ __FUNCTION__);
+ return FALSE;
+ }
+
+ private = g_new0 (TrackerStatusPrivate, 1);
+
+ private->status = TRACKER_STATUS_INITIALIZING;
/* Since we don't reference this enum anywhere, we do
* it here to make sure it exists when we call
@@ -49,9 +89,20 @@
* this is acceptable.
*/
type = tracker_status_get_type ();
- status_type_class = g_type_class_ref (type);
+ private->type_class = g_type_class_ref (type);
+
+ private->config = g_object_ref (config);
- status_config = g_object_ref (config);
+ private->is_running = FALSE;
+ private->is_readonly = FALSE;
+ private->is_first_time_index = FALSE;
+ private->is_paused_manually = FALSE;
+ private->is_paused_for_io = FALSE;
+ private->in_merge = FALSE;
+
+ g_static_private_set (&private_key,
+ private,
+ private_free);
return TRUE;
}
@@ -59,13 +110,16 @@
void
tracker_status_shutdown (void)
{
- g_object_unref (status_config);
- status_config = NULL;
+ TrackerStatusPrivate *private;
- g_type_class_unref (status_type_class);
- status_type_class = NULL;
+ private = g_static_private_get (&private_key);
+ if (!private) {
+ g_warning ("Not initialized (%s)",
+ __FUNCTION__);
+ return;
+ }
- status = TRACKER_STATUS_INITIALIZING;
+ g_static_private_free (&private_key);
}
GType
@@ -126,90 +180,284 @@
TrackerStatus
tracker_status_get (void)
{
- return status;
+ TrackerStatusPrivate *private;
+
+ private = g_static_private_get (&private_key);
+ g_return_val_if_fail (private != NULL, TRACKER_STATUS_INITIALIZING);
+
+ return private->status;
}
const gchar *
tracker_status_get_as_string (void)
{
- return tracker_status_to_string (status);
+ TrackerStatusPrivate *private;
+
+ private = g_static_private_get (&private_key);
+ g_return_val_if_fail (private != NULL, tracker_status_to_string (TRACKER_STATUS_INITIALIZING));
+
+ return tracker_status_to_string (private->status);
}
void
tracker_status_set (TrackerStatus new_status)
{
- status = new_status;
+ TrackerStatusPrivate *private;
+
+ private = g_static_private_get (&private_key);
+ g_return_if_fail (private != NULL);
+
+ private->status = new_status;
}
void
tracker_status_signal (void)
{
- GObject *object;
- gboolean pause_io;
- gboolean pause_on_battery;
-
- object = tracker_dbus_get_object (TRACKER_TYPE_DAEMON);
+ TrackerStatusPrivate *private;
+ GObject *object;
+ gboolean pause_on_battery;
- /* Pause IO is basically here to know when we are crawling
- * instead of indexing the file system. The point being that
- * we tell the indexer to pause while we crawl new files
- * created. This is redundant now since we don't do both in
- * the daemon. Should this be added back?
- */
- pause_io = status == TRACKER_STATUS_PENDING ? TRUE : FALSE;
+ private = g_static_private_get (&private_key);
+ g_return_if_fail (private != NULL);
- /* Pause on battery is a config option, not sure how to get
- * that from here or the point of passing it in the state
- * change either. This signal is going to change because we
- * shouldn't send all this crap just for a simple state
- * change. This is passed as FALSE for now.
- */
- pause_on_battery = FALSE;
+ object = tracker_dbus_get_object (TRACKER_TYPE_DAEMON);
-#if 0
- /* According to the old code, we always used:
- *
- * if (!tracker->pause_battery)
- * pause_on_battery = FALSE;
- *
- * Which means this code was never used and FALSE was ALWAYS
- * passed because tracker->pause_battery wasn't ever set to
- * anything other than FALSE.
- */
- if (tracker->first_time_index) {
- pause_on_battery = tracker_config_get_disable_indexing_on_battery_init (status_config);
+ if (private->is_first_time_index) {
+ pause_on_battery =
+ tracker_config_get_disable_indexing_on_battery_init (private->config);
} else {
- pause_on_battery = tracker_config_get_disable_indexing_on_battery (status_config);
+ pause_on_battery =
+ tracker_config_get_disable_indexing_on_battery (private->config);
}
-#endif
g_signal_emit_by_name (object,
"index-state-change",
- tracker_status_to_string (status),
- tracker_get_is_first_time_index (),
- tracker_get_in_merge (),
- tracker_get_is_paused_manually (),
- pause_on_battery, /* Pause on battery */
- pause_io, /* Pause IO */
- !tracker_get_is_readonly ());
+ tracker_status_to_string (private->status),
+ private->is_first_time_index,
+ private->in_merge,
+ private->is_paused_manually,
+ pause_on_battery,
+ private->is_paused_for_io,
+ !private->is_readonly);
}
void
tracker_status_set_and_signal (TrackerStatus new_status)
{
- gboolean emit;
+ TrackerStatusPrivate *private;
+ gboolean emit;
+
+ private = g_static_private_get (&private_key);
+ g_return_if_fail (private != NULL);
- emit = new_status != status;
+ emit = private->status != new_status;
if (!emit) {
return;
}
g_message ("State change from '%s' --> '%s'",
- tracker_status_to_string (status),
+ tracker_status_to_string (private->status),
tracker_status_to_string (new_status));
tracker_status_set (new_status);
tracker_status_signal ();
}
+gboolean
+tracker_status_get_is_readonly (void)
+{
+ TrackerStatusPrivate *private;
+
+ private = g_static_private_get (&private_key);
+ g_return_val_if_fail (private != NULL, FALSE);
+
+ return private->is_readonly;
+}
+
+void
+tracker_status_set_is_readonly (gboolean value)
+{
+ TrackerStatusPrivate *private;
+ gboolean emit;
+
+ private = g_static_private_get (&private_key);
+ g_return_if_fail (private != NULL);
+
+ emit = private->is_readonly != value;
+
+ if (!emit) {
+ return;
+ }
+
+ /* Set value */
+ private->is_readonly = value;
+
+ /* Signal the status change */
+ tracker_status_signal ();
+}
+
+gboolean
+tracker_status_get_is_running (void)
+{
+ TrackerStatusPrivate *private;
+
+ private = g_static_private_get (&private_key);
+ g_return_val_if_fail (private != NULL, FALSE);
+
+ return private->is_running;
+}
+
+void
+tracker_status_set_is_running (gboolean value)
+{
+ TrackerStatusPrivate *private;
+ gboolean emit;
+
+ private = g_static_private_get (&private_key);
+ g_return_if_fail (private != NULL);
+
+ emit = private->is_running != value;
+
+ if (!emit) {
+ return;
+ }
+
+ /* Set value */
+ private->is_running = value;
+
+ /* Signal the status change */
+ tracker_status_signal ();
+}
+
+gboolean
+tracker_status_get_is_first_time_index (void)
+{
+ TrackerStatusPrivate *private;
+
+ private = g_static_private_get (&private_key);
+ g_return_val_if_fail (private != NULL, FALSE);
+
+ return private->is_first_time_index;
+}
+
+void
+tracker_status_set_is_first_time_index (gboolean value)
+{
+ TrackerStatusPrivate *private;
+ gboolean emit;
+
+ private = g_static_private_get (&private_key);
+ g_return_if_fail (private != NULL);
+
+ emit = private->is_first_time_index != value;
+
+ if (!emit) {
+ return;
+ }
+
+ /* Set value */
+ private->is_first_time_index = value;
+
+ /* Signal the status change */
+ tracker_status_signal ();
+}
+
+gboolean
+tracker_status_get_in_merge (void)
+{
+ TrackerStatusPrivate *private;
+
+ private = g_static_private_get (&private_key);
+ g_return_val_if_fail (private != NULL, FALSE);
+
+ return private->in_merge;
+}
+
+void
+tracker_status_set_in_merge (gboolean value)
+{
+ TrackerStatusPrivate *private;
+ gboolean emit;
+
+ private = g_static_private_get (&private_key);
+ g_return_if_fail (private != NULL);
+
+ emit = private->in_merge != value;
+
+ if (!emit) {
+ return;
+ }
+
+ /* Set value */
+ private->in_merge = value;
+
+ /* Signal the status change */
+ tracker_status_signal ();
+}
+
+gboolean
+tracker_status_get_is_paused_manually (void)
+{
+ TrackerStatusPrivate *private;
+
+ private = g_static_private_get (&private_key);
+ g_return_val_if_fail (private != NULL, FALSE);
+
+ return private->is_paused_manually;
+}
+
+void
+tracker_status_set_is_paused_manually (gboolean value)
+{
+ TrackerStatusPrivate *private;
+ gboolean emit;
+
+ private = g_static_private_get (&private_key);
+ g_return_if_fail (private != NULL);
+
+ emit = private->is_paused_manually != value;
+
+ if (!emit) {
+ return;
+ }
+
+ /* Set value */
+ private->is_paused_manually = value;
+
+ /* Signal the status change */
+ tracker_status_signal ();
+}
+
+gboolean
+tracker_status_get_is_paused_for_io (void)
+{
+ TrackerStatusPrivate *private;
+
+ private = g_static_private_get (&private_key);
+ g_return_val_if_fail (private != NULL, FALSE);
+
+ return private->is_paused_for_io;
+}
+
+void
+tracker_status_set_is_paused_for_io (gboolean value)
+{
+ TrackerStatusPrivate *private;
+ gboolean emit;
+
+ private = g_static_private_get (&private_key);
+ g_return_if_fail (private != NULL);
+
+ emit = private->is_paused_for_io != value;
+
+ if (!emit) {
+ return;
+ }
+
+ /* Set value */
+ private->is_paused_for_io = value;
+
+ /* Signal the status change */
+ tracker_status_signal ();
+}
Modified: branches/indexer-split/src/trackerd/tracker-status.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-status.h (original)
+++ branches/indexer-split/src/trackerd/tracker-status.h Tue Aug 12 10:23:51 2008
@@ -41,17 +41,34 @@
} TrackerStatus;
-gboolean tracker_status_init (TrackerConfig *config);
-void tracker_status_shutdown (void);
+gboolean tracker_status_init (TrackerConfig *config);
+void tracker_status_shutdown (void);
-GType tracker_status_get_type (void) G_GNUC_CONST;
+GType tracker_status_get_type (void) G_GNUC_CONST;
+const gchar * tracker_status_to_string (TrackerStatus status);
+TrackerStatus tracker_status_get (void);
+const gchar * tracker_status_get_as_string (void);
+void tracker_status_set (TrackerStatus new_status);
+void tracker_status_set_and_signal (TrackerStatus new_status);
+void tracker_status_signal (void);
+
+gboolean tracker_status_get_is_readonly (void);
+void tracker_status_set_is_readonly (gboolean value);
+
+gboolean tracker_status_get_is_running (void);
+void tracker_status_set_is_running (gboolean value);
+
+void tracker_status_set_is_first_time_index (gboolean value);
+gboolean tracker_status_get_is_first_time_index (void);
-const gchar * tracker_status_to_string (TrackerStatus status);
-TrackerStatus tracker_status_get (void);
-const gchar * tracker_status_get_as_string (void);
-void tracker_status_set (TrackerStatus new_status);
-void tracker_status_set_and_signal (TrackerStatus new_status);
-void tracker_status_signal (void);
+gboolean tracker_status_get_in_merge (void);
+void tracker_status_set_in_merge (gboolean value);
+
+gboolean tracker_status_get_is_paused_manually (void);
+void tracker_status_set_is_paused_manually (gboolean value);
+
+gboolean tracker_status_get_is_paused_for_io (void);
+void tracker_status_set_is_paused_for_io (gboolean value);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]