tracker r1424 - in branches/indexer-split: . src/trackerd
- From: mr svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r1424 - in branches/indexer-split: . src/trackerd
- Date: Wed, 14 May 2008 12:00:06 +0100 (BST)
Author: mr
Date: Wed May 14 11:00:06 2008
New Revision: 1424
URL: http://svn.gnome.org/viewvc/tracker?rev=1424&view=rev
Log:
* src/trackerd/tracker-email-evolution.c:
* src/trackerd/tracker-email-modest.c:
* src/trackerd/tracker-email-thunderbird.c:
* src/trackerd/tracker-email.[ch]: Pass the TrackerConfig to the
init() function to avoid using tracker->config.
* src/trackerd/tracker-process-files.c: Don't try to set up signal
handlers for the HAL object if we don't have HAL support compiled
in to Tracker.
Modified:
branches/indexer-split/ChangeLog
branches/indexer-split/src/trackerd/tracker-db-sqlite.c
branches/indexer-split/src/trackerd/tracker-db-sqlite.h
branches/indexer-split/src/trackerd/tracker-email-evolution.c
branches/indexer-split/src/trackerd/tracker-email-modest.c
branches/indexer-split/src/trackerd/tracker-email-thunderbird.c
branches/indexer-split/src/trackerd/tracker-email.c
branches/indexer-split/src/trackerd/tracker-email.h
branches/indexer-split/src/trackerd/tracker-main.c
branches/indexer-split/src/trackerd/tracker-main.h
branches/indexer-split/src/trackerd/tracker-process-files.c
branches/indexer-split/src/trackerd/tracker-service-manager.c
branches/indexer-split/src/trackerd/tracker-service-manager.h
branches/indexer-split/src/trackerd/tracker-xesam.c
branches/indexer-split/src/trackerd/tracker-xesam.h
Modified: branches/indexer-split/src/trackerd/tracker-db-sqlite.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-db-sqlite.c (original)
+++ branches/indexer-split/src/trackerd/tracker-db-sqlite.c Wed May 14 11:00:06 2008
@@ -827,18 +827,6 @@
return TRUE;
}
-
-void
-tracker_db_thread_init (void)
-{
-// sqlite3_enable_shared_cache (1);
-}
-
-void
-tracker_db_finalize (void)
-{
-}
-
void
tracker_db_close (TrackerDBInterface *iface)
{
Modified: branches/indexer-split/src/trackerd/tracker-db-sqlite.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-db-sqlite.h (original)
+++ branches/indexer-split/src/trackerd/tracker-db-sqlite.h Wed May 14 11:00:06 2008
@@ -92,10 +92,7 @@
/* Module wide ops */
gboolean tracker_db_needs_setup (void);
gboolean tracker_db_common_need_build (void);
-gboolean tracker_db_load_prepared_queries (void);
-void tracker_db_thread_init (void);
-void tracker_db_thread_end (void);
-void tracker_db_finalize (void);
+gboolean tracker_db_load_prepared_queries (void);
void tracker_create_common_db (void);
void tracker_db_get_static_data (DBConnection *db_con);
Modified: branches/indexer-split/src/trackerd/tracker-email-evolution.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-email-evolution.c (original)
+++ branches/indexer-split/src/trackerd/tracker-email-evolution.c Wed May 14 11:00:06 2008
@@ -237,10 +237,12 @@
*********************************************************************************************/
gboolean
-tracker_email_init (void)
+tracker_email_init (TrackerConfig *config)
{
EvolutionConfig *conf;
+ g_return_val_if_fail (TRACKER_IS_CONFIG (config), FALSE);
+
if (evolution_config) {
return TRUE;
}
Modified: branches/indexer-split/src/trackerd/tracker-email-modest.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-email-modest.c (original)
+++ branches/indexer-split/src/trackerd/tracker-email-modest.c Wed May 14 11:00:06 2008
@@ -220,10 +220,12 @@
*********************************************************************************************/
gboolean
-tracker_email_init (void)
+tracker_email_init (TrackerConfig *config)
{
ModestConfig *conf;
+ g_return_val_if_fail (TRACKER_IS_CONFIG (config), FALSE);
+
if (modest_config) {
return TRUE;
}
Modified: branches/indexer-split/src/trackerd/tracker-email-thunderbird.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-email-thunderbird.c (original)
+++ branches/indexer-split/src/trackerd/tracker-email-thunderbird.c Wed May 14 11:00:06 2008
@@ -103,8 +103,10 @@
*********************************************************************************************/
gboolean
-tracker_email_init (void)
+tracker_email_init (TrackerConfig *config)
{
+ g_return_val_if_fail (TRACKER_IS_CONFIG (config), FALSE);
+
if (!thunderbird_mail_dir) {
thunderbird_mail_dir = g_build_filename (g_get_home_dir (), THUNDERBIRD_MAIL_DIR_S, NULL);
}
Modified: branches/indexer-split/src/trackerd/tracker-email.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-email.c (original)
+++ branches/indexer-split/src/trackerd/tracker-email.c Wed May 14 11:00:06 2008
@@ -28,12 +28,9 @@
#include "tracker-email-utils.h"
#include "tracker-main.h"
-extern Tracker *tracker;
-
static GModule *module = NULL;
-
-/* must be called before any work on files containing mails */
+/* Must be called before any work on files containing mails */
void
tracker_email_add_service_directories (DBConnection *db_con)
{
@@ -47,7 +44,6 @@
}
}
-
void
tracker_email_end_email_watching (void)
{
@@ -82,17 +78,19 @@
}
gboolean
-tracker_email_init (void)
+tracker_email_init (TrackerConfig *config)
{
TrackerMailInit func;
const gchar *email_client;
gchar *module_name, *module_path;
gboolean result = FALSE;
+ g_return_val_if_fail (TRACKER_IS_CONFIG (config), FALSE);
+
if (module)
return result;
- email_client = tracker_config_get_email_client (tracker->config);
+ email_client = tracker_config_get_email_client (config);
if (!email_client)
return result;
@@ -128,6 +126,14 @@
return result;
}
+void
+tracker_email_shutdown (void)
+{
+ /* Nothing to do here it seems, this function is here for
+ * completeness.
+ */
+}
+
const gchar *
tracker_email_get_name (void)
{
Modified: branches/indexer-split/src/trackerd/tracker-email.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-email.h (original)
+++ branches/indexer-split/src/trackerd/tracker-email.h Wed May 14 11:00:06 2008
@@ -23,6 +23,7 @@
#include "config.h"
+#include <libtracker-common/tracker-config.h>
#include <libtracker-db/tracker-db-file-info.h>
#include "tracker-utils.h"
@@ -37,12 +38,13 @@
TrackerDBFileInfo *info);
typedef const gchar * (* TrackerMailGetName) (void);
-gboolean tracker_email_init (void);
+gboolean tracker_email_init (TrackerConfig *config);
+void tracker_email_shutdown (void);
void tracker_email_add_service_directories (DBConnection *db_con);
void tracker_email_end_email_watching (void);
gboolean tracker_email_file_is_interesting (TrackerDBFileInfo *info);
gboolean tracker_email_index_file (DBConnection *db_con,
- TrackerDBFileInfo *info);
+ TrackerDBFileInfo *info);
const gchar *tracker_email_get_name (void);
G_END_DECLS
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 Wed May 14 11:00:06 2008
@@ -757,9 +757,6 @@
tracker_db_set_option_int (main_thread_db_con, "IntegrityCheck", 0);
tracker_db_close (main_thread_db_con->db);
-
- /* This must be called after all other db functions */
- tracker_db_finalize ();
}
static void
@@ -893,6 +890,11 @@
tracker_xesam_init ();
tracker_cache_init ();
tracker_service_manager_init ();
+ tracker_email_init (tracker->config);
+
+#ifdef HAVE_HAL
+ tracker->hal = tracker_hal_new ();
+#endif /* HAVE_HAL */
initialise_directories (&need_index);
initialise_threading ();
@@ -958,9 +960,6 @@
sanity_check_option_values ();
- /* Set thread safe DB connection */
- tracker_db_thread_init ();
-
if (!tracker_db_load_prepared_queries ()) {
tracker_error ("Could not initialize database engine!");
return EXIT_FAILURE;
@@ -968,13 +967,6 @@
initialise_databases (need_index);
- tracker_email_init ();
-
-#ifdef HAVE_HAL
- /* Create tracker HAL object */
- tracker->hal = tracker_hal_new ();
-#endif
-
/* Set our status as running, if this is FALSE, threads stop
* doing what they do and shutdown.
*/
@@ -1032,26 +1024,10 @@
/* Set kill timeout */
g_timeout_add_full (G_PRIORITY_LOW, 20000, shutdown_timeout_cb, NULL, NULL);
- tracker_cache_shutdown ();
-
- shutdown_threads (thread);
shutdown_indexer ();
shutdown_databases ();
+ shutdown_threads (thread);
shutdown_directories ();
- shutdown_locations ();
-
- /* Clean up other struct members */
- if (tracker->file_process_queue) {
- g_async_queue_unref (tracker->file_process_queue);
- }
-
- if (tracker->file_metadata_queue) {
- g_async_queue_unref (tracker->file_metadata_queue);
- }
-
- if (tracker->dir_queue) {
- g_async_queue_unref (tracker->dir_queue);
- }
/* Shutdown major subsystems */
if (tracker->hal) {
@@ -1059,16 +1035,35 @@
tracker->hal = NULL;
}
+ tracker_email_shutdown ();
+ tracker_dbus_shutdown ();
+ tracker_service_manager_shutdown ();
+ tracker_cache_shutdown ();
+ tracker_xesam_shutdown ();
+ tracker_db_manager_term ();
+ tracker_nfs_lock_term ();
+ tracker_log_term ();
+
tracker_language_free (tracker->language);
if (tracker->config) {
g_object_unref (tracker->config);
}
- tracker_db_manager_term ();
+ shutdown_locations ();
- tracker_nfs_lock_term ();
- tracker_log_term ();
+ /* Clean up other struct members */
+ if (tracker->file_process_queue) {
+ g_async_queue_unref (tracker->file_process_queue);
+ }
+
+ if (tracker->file_metadata_queue) {
+ g_async_queue_unref (tracker->file_metadata_queue);
+ }
+
+ if (tracker->dir_queue) {
+ g_async_queue_unref (tracker->dir_queue);
+ }
return EXIT_SUCCESS;
}
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 Wed May 14 11:00:06 2008
@@ -131,8 +131,6 @@
GMutex *metadata_check_mutex;
GMutex *metadata_signal_mutex;
GCond *metadata_signal_cond;
-
- GHashTable *xesam_sessions;
} Tracker;
void tracker_shutdown (void);
Modified: branches/indexer-split/src/trackerd/tracker-process-files.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-process-files.c (original)
+++ branches/indexer-split/src/trackerd/tracker-process-files.c Wed May 14 11:00:06 2008
@@ -684,7 +684,7 @@
#ifdef HAVE_HAL
l1 = tracker_hal_get_mounted_directory_roots (tracker->hal);
l2 = tracker_hal_get_removable_device_roots (tracker->hal);
-#endif
+#endif /* HAVE_HAL */
/* The options to index removable media and the index mounted
* directories are both mutually exclusive even though
@@ -1523,12 +1523,14 @@
}
}
+#ifdef HAVE_HAL
g_signal_connect (tracker->hal, "mount-point-added",
G_CALLBACK (process_mount_point_added_cb),
tracker);
g_signal_connect (tracker->hal, "mount-point-removed",
G_CALLBACK (process_mount_point_removed_cb),
tracker);
+#endif /* HAVE_HAL */
/* Start processing */
g_mutex_unlock (tracker->files_signal_mutex);
@@ -1712,12 +1714,14 @@
tracker_db_file_info_unref (info);
}
+#ifdef HAVE_HAL
g_signal_handlers_disconnect_by_func (tracker->hal,
process_mount_point_added_cb,
tracker);
g_signal_handlers_disconnect_by_func (tracker->hal,
process_mount_point_removed_cb,
tracker);
+#endif /* HAVE_HAL */
xdg_mime_shutdown ();
Modified: branches/indexer-split/src/trackerd/tracker-service-manager.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-service-manager.c (original)
+++ branches/indexer-split/src/trackerd/tracker-service-manager.c Wed May 14 11:00:06 2008
@@ -123,7 +123,7 @@
}
void
-tracker_service_manager_term (void)
+tracker_service_manager_shutdown (void)
{
g_hash_table_remove_all (service_directory_table);
g_hash_table_remove_all (service_id_table);
Modified: branches/indexer-split/src/trackerd/tracker-service-manager.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-service-manager.h (original)
+++ branches/indexer-split/src/trackerd/tracker-service-manager.h Wed May 14 11:00:06 2008
@@ -29,7 +29,7 @@
G_BEGIN_DECLS
void tracker_service_manager_init (void);
-void tracker_service_manager_term (void);
+void tracker_service_manager_shutdown (void);
void tracker_service_manager_add_service (TrackerService *service,
GSList *mimes,
GSList *mime_prefixes);
Modified: branches/indexer-split/src/trackerd/tracker-xesam.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-xesam.c (original)
+++ branches/indexer-split/src/trackerd/tracker-xesam.c Wed May 14 11:00:06 2008
@@ -29,7 +29,9 @@
extern Tracker *tracker;
-static gboolean live_search_handler_running = FALSE;
+
+static GHashTable *xesam_sessions;
+static gboolean live_search_handler_running = FALSE;
GQuark
tracker_xesam_error_quark (void)
@@ -40,10 +42,24 @@
void
tracker_xesam_init (void)
{
- tracker->xesam_sessions = g_hash_table_new_full (
- g_str_hash, g_str_equal,
- (GDestroyNotify) g_free,
- (GDestroyNotify ) g_object_unref);
+ if (xesam_sessions) {
+ return;
+ }
+
+ xesam_sessions = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) g_object_unref);
+}
+
+void
+tracker_xesam_shutdown (void)
+{
+ if (!xesam_sessions) {
+ return;
+ }
+
+ g_hash_table_unref (xesam_sessions);
}
TrackerXesamSession *
@@ -56,9 +72,9 @@
session = tracker_xesam_session_new ();
tracker_xesam_session_set_id (session, tracker_xesam_generate_unique_key ());
- g_hash_table_insert (tracker->xesam_sessions,
- g_strdup (tracker_xesam_session_get_id (session)),
- g_object_ref (session));
+ g_hash_table_insert (xesam_sessions,
+ g_strdup (tracker_xesam_session_get_id (session)),
+ g_object_ref (session));
if (session_id)
*session_id = g_strdup (tracker_xesam_session_get_id (session));
@@ -69,28 +85,35 @@
void
tracker_xesam_close_session (const gchar *session_id, GError **error)
{
- gpointer inst = g_hash_table_lookup (tracker->xesam_sessions, session_id);
- if (!inst)
- g_set_error (error, TRACKER_XESAM_ERROR,
- TRACKER_XESAM_ERROR_SESSION_ID_NOT_REGISTERED,
- "Session ID is not registered");
- else
- g_hash_table_remove (tracker->xesam_sessions, session_id);
-}
+ gpointer session;
+ session = g_hash_table_lookup (xesam_sessions, session_id);
+ if (!session) {
+ g_set_error (error,
+ TRACKER_XESAM_ERROR,
+ TRACKER_XESAM_ERROR_SESSION_ID_NOT_REGISTERED,
+ "Session ID is not registered");
+ } else {
+ g_hash_table_remove (xesam_sessions, session_id);
+ }
+}
TrackerXesamSession *
tracker_xesam_get_session (const gchar *session_id, GError **error)
{
- TrackerXesamSession *retval = g_hash_table_lookup (tracker->xesam_sessions, session_id);
- if (retval)
- g_object_ref (retval);
- else
- g_set_error (error, TRACKER_XESAM_ERROR,
- TRACKER_XESAM_ERROR_SESSION_ID_NOT_REGISTERED,
- "Session ID is not registered");
+ TrackerXesamSession *session;
+
+ session = g_hash_table_lookup (xesam_sessions, session_id);
+ if (session) {
+ g_object_ref (session);
+ } else {
+ g_set_error (error,
+ TRACKER_XESAM_ERROR,
+ TRACKER_XESAM_ERROR_SESSION_ID_NOT_REGISTERED,
+ "Session ID is not registered");
+ }
- return retval;
+ return session;
}
TrackerXesamSession *
@@ -98,122 +121,160 @@
TrackerXesamLiveSearch **search_in,
GError **error)
{
- TrackerXesamSession *retval = NULL;
- GList * sessions = g_hash_table_get_values (tracker->xesam_sessions);
+ TrackerXesamSession *session = NULL;
+ GList *sessions;
+
+ sessions = g_hash_table_get_values (xesam_sessions);
while (sessions) {
- TrackerXesamLiveSearch *search = tracker_xesam_session_get_search (sessions->data, search_id, NULL);
- if (search) {
+ TrackerXesamLiveSearch *search;
+ search = tracker_xesam_session_get_search (sessions->data, search_id, NULL);
+ if (search) {
/* Search got a reference added already */
- if (search_in)
+ if (search_in) {
*search_in = search;
- else
+ } else {
g_object_unref (search);
+ }
- retval = g_object_ref (sessions->data);
+ session = g_object_ref (sessions->data);
break;
}
+
sessions = g_list_next (sessions);
}
g_list_free (sessions);
- if (!retval)
- g_set_error (error, TRACKER_XESAM_ERROR,
- TRACKER_XESAM_ERROR_SEARCH_ID_NOT_REGISTERED,
- "Search ID is not registered");
+ if (!session) {
+ g_set_error (error,
+ TRACKER_XESAM_ERROR,
+ TRACKER_XESAM_ERROR_SEARCH_ID_NOT_REGISTERED,
+ "Search ID is not registered");
+ }
- return retval;
+ return session;
}
-
TrackerXesamLiveSearch *
tracker_xesam_get_live_search (const gchar *search_id, GError **error)
{
- TrackerXesamLiveSearch *retval = NULL;
- GList * sessions = g_hash_table_get_values (tracker->xesam_sessions);
+ TrackerXesamLiveSearch *search = NULL;
+ GList *sessions;
+
+ sessions = g_hash_table_get_values (xesam_sessions);
while (sessions) {
- TrackerXesamLiveSearch *search = tracker_xesam_session_get_search (sessions->data, search_id, NULL);
- if (search) {
+ TrackerXesamLiveSearch *p;
+
+ p = tracker_xesam_session_get_search (sessions->data, search_id, NULL);
+ if (p) {
/* Search got a reference added already */
- retval = search;
+ search = p;
break;
}
+
sessions = g_list_next (sessions);
}
g_list_free (sessions);
- if (!retval)
- g_set_error (error, TRACKER_XESAM_ERROR,
- TRACKER_XESAM_ERROR_SEARCH_ID_NOT_REGISTERED,
- "Search ID is not registered");
+ if (!search) {
+ g_set_error (error,
+ TRACKER_XESAM_ERROR,
+ TRACKER_XESAM_ERROR_SEARCH_ID_NOT_REGISTERED,
+ "Search ID is not registered");
+ }
- return retval;
+ return search;
}
static gboolean
live_search_handler (gpointer data)
{
- gboolean reason_to_live = FALSE;
- GList * sessions = g_hash_table_get_values (tracker->xesam_sessions);
TrackerDBResultSet *result_set;
- TrackerDBusXesam *proxy = TRACKER_DBUS_XESAM (tracker_dbus_get_object (TRACKER_TYPE_DBUS_XESAM));
- DBConnection *db_con = NULL;
+ TrackerDBusXesam *proxy;
+ DBConnection *db_con = NULL;
+ GList *sessions;
+ gboolean reason_to_live = FALSE;
+
+ sessions = g_hash_table_get_values (xesam_sessions);
+ proxy = TRACKER_DBUS_XESAM (tracker_dbus_get_object (TRACKER_TYPE_DBUS_XESAM));
- if (!proxy)
+ if (!proxy) {
return FALSE;
+ }
g_object_get (proxy, "db-connection", &db_con, NULL);
- if (!db_con)
+ if (!db_con) {
return FALSE;
+ }
result_set = tracker_db_get_events (db_con);
if (result_set && tracker_db_result_set_get_n_rows (result_set) > 0) {
-
reason_to_live = TRUE;
while (sessions) {
- GList *searches = tracker_xesam_session_get_searches (sessions->data);
- while (searches) {
- GArray *added = NULL, *removed = NULL, *modified = NULL;
- TrackerXesamLiveSearch *search = searches->data;
+ GList *searches;
- tracker_xesam_live_search_match_with_events (search, result_set, &added, &removed, &modified);
+ searches = tracker_xesam_session_get_searches (sessions->data);
- if (added && added->len > 0)
+ while (searches) {
+ TrackerXesamLiveSearch *search;
+ GArray *added = NULL;
+ GArray *removed = NULL;
+ GArray *modified = NULL;
+
+ search = searches->data;
+ tracker_xesam_live_search_match_with_events (search,
+ result_set,
+ &added,
+ &removed,
+ &modified);
+
+ if (added && added->len > 0) {
tracker_xesam_live_search_emit_hits_added (search, added->len);
- if (added)
+ }
+
+ if (added) {
g_array_free (added, TRUE);
+ }
- if (removed && removed->len > 0)
+ if (removed && removed->len > 0) {
tracker_xesam_live_search_emit_hits_removed (search, removed);
- if (removed)
+ }
+
+ if (removed) {
g_array_free (removed, TRUE);
+ }
- if (modified && modified->len > 0)
+ if (modified && modified->len > 0) {
tracker_xesam_live_search_emit_hits_modified (search, modified);
- if (modified)
- g_array_free (modified, TRUE);
+ }
+ if (modified) {
+ g_array_free (modified, TRUE);
+ }
searches = g_list_next (searches);
}
+
g_list_free (searches);
sessions = g_list_next (sessions);
}
+
g_list_free (sessions);
tracker_db_delete_handled_events (db_con, result_set);
}
- if (result_set)
+ if (result_set) {
g_object_unref (result_set);
+ }
return reason_to_live;
}
@@ -235,15 +296,15 @@
* thread do it too (although untested).
*
* In case of a thread we could use usleep() and stop the thread if
- * we didn't get a wakeup-call nor we had items to process this loop */
-
+ * we didn't get a wakeup-call nor we had items to process this loop
+ */
if (!live_search_handler_running) {
live_search_handler_running = TRUE;
g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE,
- 2000, /* 2 seconds */
- live_search_handler,
- NULL,
- live_search_handler_destroy);
+ 2000, /* 2 seconds */
+ live_search_handler,
+ NULL,
+ live_search_handler_destroy);
}
}
Modified: branches/indexer-split/src/trackerd/tracker-xesam.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-xesam.h (original)
+++ branches/indexer-split/src/trackerd/tracker-xesam.h Wed May 14 11:00:06 2008
@@ -42,6 +42,7 @@
GQuark tracker_xesam_error_quark (void);
void tracker_xesam_init (void);
+void tracker_xesam_shutdown (void);
TrackerXesamSession* tracker_xesam_create_session (TrackerDBusXesam *dbus_proxy,
gchar **session_id,
GError **error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]