[tracker/collation-gconf-locale] tracker-store, libtracker-data: Improve status reporting



commit 7d22a69221f40686a28c00131d469c2f66893507
Author: Aleksander Morgado <aleksander lanedo com>
Date:   Mon Nov 15 19:11:37 2010 +0100

    tracker-store, libtracker-data: Improve status reporting

 src/libtracker-data/tracker-data-manager.c |   75 +++++++++++++++++++++-------
 src/libtracker-data/tracker-data-manager.h |    5 +-
 src/libtracker-data/tracker-db-manager.c   |   11 +++-
 src/libtracker-data/tracker-db-manager.h   |    3 +-
 src/tracker-control/tracker-control.c      |   11 +++-
 src/tracker-store/tracker-locale-change.c  |    4 +-
 src/tracker-store/tracker-main.c           |    2 +-
 src/tracker-store/tracker-status.c         |    4 +-
 8 files changed, 86 insertions(+), 29 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index e2ae2d5..886dd87 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -694,7 +694,7 @@ tracker_data_ontology_load_statement (const gchar *ontology_path,
 				}
 
 				/* This doesn't detect removed rdfs:subClassOf situations, it
-				 * only checks whether no new ones are being added. For 
+				 * only checks whether no new ones are being added. For
 				 * detecting the removal of a rdfs:subClassOf, please check the
 				 * tracker_data_ontology_process_changes_pre_db stuff */
 
@@ -810,7 +810,7 @@ tracker_data_ontology_load_statement (const gchar *ontology_path,
 		}
 
 		/* This doesn't detect removed tracker:domainIndex situations, it
-		 * only checks whether no new ones are being added. For 
+		 * only checks whether no new ones are being added. For
 		 * detecting the removal of a tracker:domainIndex, please check the
 		 * tracker_data_ontology_process_changes_pre_db stuff */
 
@@ -962,7 +962,7 @@ tracker_data_ontology_load_statement (const gchar *ontology_path,
 		}
 
 		/* This doesn't detect removed nrl:maxCardinality situations, it
-		 * only checks whether the existing one got changed. For 
+		 * only checks whether the existing one got changed. For
 		 * detecting the removal of a nrl:maxCardinality, please check the
 		 * tracker_data_ontology_process_changes_pre_db stuff */
 
@@ -3161,7 +3161,9 @@ get_new_service_id (TrackerDBInterface *iface)
 }
 
 static void
-tracker_data_manager_recreate_indexes (void)
+tracker_data_manager_recreate_indexes (TrackerBusyCallback    busy_callback,
+                                       gpointer               busy_user_data,
+                                       const gchar           *busy_status)
 {
 	TrackerProperty **properties;
 	guint n_properties;
@@ -3188,13 +3190,20 @@ tracker_data_manager_recreate_indexes (void)
 		         field_name);
 
 		fix_indexed (properties [i]);
+
+		if (busy_callback) {
+			busy_callback (busy_status,
+			               (gdouble)((gdouble)i/(gdouble)n_properties),
+			               busy_user_data);
+		}
 	}
 	g_debug ("  Finished index re-creation...");
 }
 
 gboolean
-tracker_data_manager_reload (TrackerBusyCallback busy_callback,
-                             gpointer            busy_user_data)
+tracker_data_manager_reload (TrackerBusyCallback  busy_callback,
+                             gpointer             busy_user_data,
+                             const gchar         *busy_operation)
 {
 	TrackerDBManagerFlags flags;
 	guint select_cache_size;
@@ -3218,7 +3227,7 @@ tracker_data_manager_reload (TrackerBusyCallback busy_callback,
 	                                    update_cache_size,
 	                                    busy_callback,
 	                                    busy_user_data,
-	                                    "Reloading data manager");
+	                                    busy_operation);
 
 	g_message ("  %s reloading data manager",
 	           status ? "Succeeded" : "Failed");
@@ -3234,7 +3243,7 @@ tracker_data_manager_init (TrackerDBManagerFlags  flags,
                            guint                  update_cache_size,
                            TrackerBusyCallback    busy_callback,
                            gpointer               busy_user_data,
-                           const gchar           *busy_status)
+                           const gchar           *busy_operation)
 {
 	TrackerDBInterface *iface;
 	gboolean is_first_time_index, read_journal, check_ontology;
@@ -3246,6 +3255,7 @@ tracker_data_manager_init (TrackerDBManagerFlags  flags,
 	gint max_id = 0;
 	gboolean read_only;
 	GHashTable *uri_id_map = NULL;
+	gchar *busy_status;
 
 	tracker_data_update_init ();
 
@@ -3265,12 +3275,27 @@ tracker_data_manager_init (TrackerDBManagerFlags  flags,
 
 	read_journal = FALSE;
 
-	if (!tracker_db_manager_init (flags, &is_first_time_index, FALSE,
-	                              select_cache_size, update_cache_size,
-	                              busy_callback, busy_user_data)) {
+	if (!tracker_db_manager_init (flags,
+	                              &is_first_time_index,
+	                              FALSE,
+	                              select_cache_size,
+	                              update_cache_size,
+	                              busy_callback,
+	                              busy_user_data,
+	                              busy_operation)) {
 		return FALSE;
 	}
 
+	/* Report OPERATION - STATUS */
+	if (busy_callback) {
+		busy_status = g_strdup_printf ("%s - %s",
+		                               busy_operation,
+		                               "Initializing data manager");
+		busy_callback (busy_status, 0, busy_user_data);
+		g_free (busy_status);
+	}
+
+
 #if HAVE_TRACKER_FTS
 	tracker_fts_set_map_function (tracker_ontologies_get_uri_by_id);
 #endif
@@ -3584,7 +3609,7 @@ tracker_data_manager_init (TrackerDBManagerFlags  flags,
 						                                  update_cache_size,
 						                                  busy_callback,
 						                                  busy_user_data,
-						                                  busy_status);
+						                                  busy_operation);
 					}
 
 					if (ontology_error) {
@@ -3643,7 +3668,7 @@ tracker_data_manager_init (TrackerDBManagerFlags  flags,
 					                                  update_cache_size,
 					                                  busy_callback,
 					                                  busy_user_data,
-					                                  busy_status);
+					                                  busy_operation);
 				}
 
 				if (ontology_error) {
@@ -3726,7 +3751,7 @@ tracker_data_manager_init (TrackerDBManagerFlags  flags,
 				                                  update_cache_size,
 				                                  busy_callback,
 				                                  busy_user_data,
-				                                  busy_status);
+				                                  busy_operation);
 			}
 
 			if (ontology_error) {
@@ -3744,7 +3769,6 @@ tracker_data_manager_init (TrackerDBManagerFlags  flags,
 			tracker_data_ontology_process_changes_post_import (seen_classes, seen_properties);
 		}
 
-
 		tracker_data_ontology_free_seen (seen_classes);
 		tracker_data_ontology_free_seen (seen_properties);
 
@@ -3760,9 +3784,15 @@ tracker_data_manager_init (TrackerDBManagerFlags  flags,
 	}
 
 	if (read_journal) {
+		/* Report OPERATION - STATUS */
+		busy_status = g_strdup_printf ("%s - %s",
+		                               busy_operation,
+		                               "Replaying journal");
 		/* Start replay */
-
-		tracker_data_replay_journal (busy_callback, busy_user_data, busy_status);
+		tracker_data_replay_journal (busy_callback,
+		                             busy_user_data,
+		                             busy_status);
+		g_free (busy_status);
 
 		in_journal_replay = FALSE;
 
@@ -3774,10 +3804,18 @@ tracker_data_manager_init (TrackerDBManagerFlags  flags,
 
 	/* If locale changed, re-create indexes */
 	if (!read_only && tracker_db_manager_locale_changed ()) {
+		/* Report OPERATION - STATUS */
+		busy_status = g_strdup_printf ("%s - %s",
+		                               busy_operation,
+		                               "Recreating indexes");
 		/* No need to reset the collator in the db interface,
 		 * as this is only executed during startup, which should
 		 * already have the proper locale set in the collator */
-		tracker_data_manager_recreate_indexes ();
+		tracker_data_manager_recreate_indexes (busy_callback,
+		                                       busy_user_data,
+		                                       busy_status);
+		g_free (busy_status);
+
 		tracker_db_manager_set_current_locale ();
 	}
 
@@ -3785,6 +3823,7 @@ tracker_data_manager_init (TrackerDBManagerFlags  flags,
 
 	g_free (ontologies_dir);
 
+	/* This is the only one which doesn't show the 'OPERATION' part */
 	if (busy_callback) {
 		busy_callback ("Idle", 1, busy_user_data);
 	}
diff --git a/src/libtracker-data/tracker-data-manager.h b/src/libtracker-data/tracker-data-manager.h
index beb6daf..30f97c9 100644
--- a/src/libtracker-data/tracker-data-manager.h
+++ b/src/libtracker-data/tracker-data-manager.h
@@ -53,10 +53,11 @@ gboolean tracker_data_manager_init                   (TrackerDBManagerFlags  fla
                                                       guint                  update_cache_size,
                                                       TrackerBusyCallback    busy_callback,
                                                       gpointer               busy_user_data,
-                                                      const gchar           *busy_status);
+                                                      const gchar           *busy_operation);
 void     tracker_data_manager_shutdown               (void);
 gboolean tracker_data_manager_reload                 (TrackerBusyCallback    busy_callback,
-                                                      gpointer               busy_user_data);
+                                                      gpointer               busy_user_data,
+                                                      const gchar           *busy_operation);
 
 G_END_DECLS
 
diff --git a/src/libtracker-data/tracker-db-manager.c b/src/libtracker-data/tracker-db-manager.c
index 227ae4b..877682e 100644
--- a/src/libtracker-data/tracker-db-manager.c
+++ b/src/libtracker-data/tracker-db-manager.c
@@ -709,7 +709,8 @@ tracker_db_manager_init (TrackerDBManagerFlags  flags,
                          guint                  select_cache_size,
                          guint                  update_cache_size,
                          TrackerBusyCallback    busy_callback,
-                         gpointer               busy_user_data)
+                         gpointer               busy_user_data,
+                         const gchar           *busy_operation)
 {
 	GType               etype;
 	TrackerDBVersion    version;
@@ -899,6 +900,7 @@ tracker_db_manager_init (TrackerDBManagerFlags  flags,
 				struct stat st;
 				GError *error = NULL;
 				TrackerDBStatement *stmt;
+				gchar *busy_status;
 
 				if (g_stat (dbs[i].abs_filename, &st) == 0) {
 					size = st.st_size;
@@ -917,10 +919,15 @@ tracker_db_manager_init (TrackerDBManagerFlags  flags,
 
 				loaded = TRUE;
 
+				/* Report OPERATION - STATUS */
+				busy_status = g_strdup_printf ("%s - %s",
+				                               busy_operation,
+				                               "Integrity checking");
 				tracker_db_interface_set_busy_handler (dbs[i].iface,
 				                                       busy_callback,
-				                                       "Integrity checking",
+				                                       busy_status,
 				                                       busy_user_data);
+				g_free (busy_status);
 
 				stmt = tracker_db_interface_create_statement (dbs[i].iface, TRACKER_DB_STATEMENT_CACHE_TYPE_NONE, &error,
 				                                              "PRAGMA integrity_check(1)");
diff --git a/src/libtracker-data/tracker-db-manager.h b/src/libtracker-data/tracker-db-manager.h
index 70e8977..49d095e 100644
--- a/src/libtracker-data/tracker-db-manager.h
+++ b/src/libtracker-data/tracker-db-manager.h
@@ -56,7 +56,8 @@ gboolean            tracker_db_manager_init                   (TrackerDBManagerF
                                                                guint                  select_cache_size,
                                                                guint                  update_cache_size,
                                                                TrackerBusyCallback    busy_callback,
-                                                               gpointer               busy_user_data);
+                                                               gpointer               busy_user_data,
+                                                               const gchar           *busy_operation);
 void                tracker_db_manager_shutdown               (void);
 void                tracker_db_manager_remove_all             (gboolean               rm_journal);
 void                tracker_db_manager_optimize               (void);
diff --git a/src/tracker-control/tracker-control.c b/src/tracker-control/tracker-control.c
index e835323..51027d3 100644
--- a/src/tracker-control/tracker-control.c
+++ b/src/tracker-control/tracker-control.c
@@ -303,7 +303,7 @@ main (int argc, char **argv)
 	 */
 	if (kill_option != TERM_NONE ||
 	    terminate_option != TERM_NONE ||
-	    (!start && !remove_config && !reindex_mime_types && 
+	    (!start && !remove_config && !reindex_mime_types &&
 	     !print_version && !index_file)) {
 		pids = get_pids ();
 		str = g_strdup_printf (g_dngettext (NULL,
@@ -438,7 +438,14 @@ main (int argc, char **argv)
 		g_object_unref (db_config);
 
 		/* Clean up (select_cache_size and update_cache_size don't matter here) */
-		if (!tracker_db_manager_init (TRACKER_DB_MANAGER_REMOVE_ALL, NULL, FALSE, 100, 100, NULL, NULL)) {
+		if (!tracker_db_manager_init (TRACKER_DB_MANAGER_REMOVE_ALL,
+		                              NULL,
+		                              FALSE,
+		                              100,
+		                              100,
+		                              NULL,
+		                              NULL,
+		                              NULL)) {
 			return EXIT_FAILURE;
 		}
 
diff --git a/src/tracker-store/tracker-locale-change.c b/src/tracker-store/tracker-locale-change.c
index cbecbd4..7235e2c 100644
--- a/src/tracker-store/tracker-locale-change.c
+++ b/src/tracker-store/tracker-locale-change.c
@@ -61,7 +61,9 @@ tracker_locale_change_process_cb (gpointer user_data)
 
 	g_message ("Processing locale change...");
 	/* Reload! This will regenerate indexes with the new locale */
-	tracker_data_manager_reload (busy_callback, busy_user_data);
+	tracker_data_manager_reload (busy_callback,
+	                             busy_user_data,
+	                             "Changing locale");
 
 	if (ctxt->resources) {
 		tracker_events_init (ctxt->getter);
diff --git a/src/tracker-store/tracker-main.c b/src/tracker-store/tracker-main.c
index 2c01733..341753e 100644
--- a/src/tracker-store/tracker-main.c
+++ b/src/tracker-store/tracker-main.c
@@ -504,7 +504,7 @@ main (gint argc, gchar *argv[])
 	                                update_cache_size,
 	                                busy_callback,
 	                                busy_user_data,
-	                                "Journal replaying")) {
+	                                "Initializing")) {
 
 		g_object_unref (db_config);
 		g_object_unref (notifier);
diff --git a/src/tracker-store/tracker-status.c b/src/tracker-store/tracker-status.c
index 4658ee6..418139d 100644
--- a/src/tracker-store/tracker-status.c
+++ b/src/tracker-store/tracker-status.c
@@ -183,7 +183,7 @@ tracker_status_get_callback (TrackerStatus *object, gpointer *user_data)
 	return tracker_status_callback;
 }
 
-void 
+void
 tracker_status_get_progress  (TrackerStatus    *object,
                               DBusGMethodInvocation  *context,
                               GError                **error)
@@ -199,7 +199,7 @@ tracker_status_get_progress  (TrackerStatus    *object,
 }
 
 
-void 
+void
 tracker_status_get_status  (TrackerStatus    *object,
                             DBusGMethodInvocation  *context,
                             GError                **error)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]