tracker r1407 - in branches/indexer-split: . src/tracker-indexer src/trackerd



Author: mr
Date: Tue May 13 13:21:24 2008
New Revision: 1407
URL: http://svn.gnome.org/viewvc/tracker?rev=1407&view=rev

Log:
	* src/trackerd/Makefile.am:
	* src/trackerd/tracker-cache.c:
	* src/trackerd/tracker-index-stage.[ch]:
	* src/trackerd/tracker-main.[ch]:
	* src/trackerd/tracker-metadata.c:
	* src/trackerd/tracker-process-files.c: Added TrackerIndexStage
	type to hold the current indexer state and type information.


Added:
   branches/indexer-split/src/trackerd/tracker-index-stage.c
   branches/indexer-split/src/trackerd/tracker-index-stage.h
Modified:
   branches/indexer-split/ChangeLog
   branches/indexer-split/src/tracker-indexer/tracker-indexer-module.c
   branches/indexer-split/src/tracker-indexer/tracker-indexer-module.h
   branches/indexer-split/src/tracker-indexer/tracker-indexer.c
   branches/indexer-split/src/tracker-indexer/tracker-indexer.h
   branches/indexer-split/src/trackerd/Makefile.am
   branches/indexer-split/src/trackerd/tracker-cache.c
   branches/indexer-split/src/trackerd/tracker-main.c
   branches/indexer-split/src/trackerd/tracker-main.h
   branches/indexer-split/src/trackerd/tracker-metadata.c
   branches/indexer-split/src/trackerd/tracker-process-files.c

Modified: branches/indexer-split/src/tracker-indexer/tracker-indexer-module.c
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-indexer-module.c	(original)
+++ branches/indexer-split/src/tracker-indexer/tracker-indexer-module.c	Tue May 13 13:21:24 2008
@@ -1,6 +1,8 @@
-/* Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2008, Mr Jamie McCracken (jamiemcc gnome org)
  * Copyright (C) 2008, Nokia
-
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public
  * License as published by the Free Software Foundation; either
@@ -18,6 +20,7 @@
  */
 
 #include <gmodule.h>
+
 #include "tracker-indexer-module.h"
 
 typedef const gchar * (* Foo) (void);

Modified: branches/indexer-split/src/tracker-indexer/tracker-indexer-module.h
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-indexer-module.h	(original)
+++ branches/indexer-split/src/tracker-indexer/tracker-indexer-module.h	Tue May 13 13:21:24 2008
@@ -1,6 +1,8 @@
-/* Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2008, Mr Jamie McCracken (jamiemcc gnome org)
  * Copyright (C) 2008, Nokia
-
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public
  * License as published by the Free Software Foundation; either

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 May 13 13:21:24 2008
@@ -1,4 +1,6 @@
-/* Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* 
+ * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
  * Copyright (C) 2008, Nokia
 
  * This library is free software; you can redistribute it and/or
@@ -40,9 +42,12 @@
  */
 
 #include <stdlib.h>
+
 #include <gmodule.h>
+
 #include <libtracker-common/tracker-config.h>
 #include <libtracker-db/tracker-db-interface-sqlite.h>
+
 #include "tracker-indexer.h"
 #include "tracker-indexer-module.h"
 

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 May 13 13:21:24 2008
@@ -1,4 +1,6 @@
-/* Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
  * Copyright (C) 2008, Nokia
 
  * This library is free software; you can redistribute it and/or
@@ -46,14 +48,11 @@
 	void (*finished) (TrackerIndexer *indexer);
 };
 
-GType                 tracker_indexer_get_type       (void) G_GNUC_CONST;
-
-TrackerIndexer *      tracker_indexer_new            (void);
-
-void                  tracker_indexer_set_running    (TrackerIndexer      *indexer,
-						      gboolean             running);
-gboolean              tracker_indexer_get_running    (TrackerIndexer      *indexer);
-
+GType           tracker_indexer_get_type    (void) G_GNUC_CONST;
+TrackerIndexer *tracker_indexer_new         (void);
+void            tracker_indexer_set_running (TrackerIndexer *indexer,
+                                             gboolean        running);
+gboolean        tracker_indexer_get_running (TrackerIndexer *indexer);
 
 G_END_DECLS
 

Modified: branches/indexer-split/src/trackerd/Makefile.am
==============================================================================
--- branches/indexer-split/src/trackerd/Makefile.am	(original)
+++ branches/indexer-split/src/trackerd/Makefile.am	Tue May 13 13:21:24 2008
@@ -38,20 +38,6 @@
 	tracker-hal.h
 endif
 
-db_sources =								\
-	tracker-indexer.c						\
-	tracker-indexer.h						\
-	tracker-cache.c							\
-	tracker-cache.h							\
-	tracker-parser.c						\
-	tracker-parser.h						\
-	tracker-db-sqlite.c						\
-	tracker-db-sqlite.h						\
-	tracker-db-manager.c						\
-	tracker-db-manager.h						\
-	tracker-db-email.c						\
-	tracker-db-email.h
-
 mail_modulesdir = $(libdir)/tracker/mail-modules
 mail_modules_LTLIBRARIES = \
 	libemail-evolution.la \
@@ -85,11 +71,18 @@
 	$(win_sources)							\
 	$(unix_sources)							\
 	$(hal_sources)							\
-	$(db_sources)							\
 	tracker-apps.c							\
 	tracker-apps.h							\
+	tracker-cache.c							\
+	tracker-cache.h							\
 	tracker-db.c							\
 	tracker-db.h							\
+	tracker-db-email.c						\
+	tracker-db-email.h						\
+	tracker-db-sqlite.c						\
+	tracker-db-sqlite.h						\
+	tracker-db-manager.c						\
+	tracker-db-manager.h						\
 	tracker-dbus.c							\
 	tracker-dbus.h							\
 	tracker-dbus-daemon.c						\
@@ -108,11 +101,17 @@
 	tracker-email.h							\
 	tracker-email-utils.c						\
 	tracker-email-utils.h						\
+	tracker-indexer.c						\
+	tracker-indexer.h						\
+	tracker-index-stage.c						\
+	tracker-index-stage.h						\
 	tracker-main.c							\
 	tracker-main.h							\
 	tracker-marshal-main.c						\
 	tracker-metadata.c						\
 	tracker-metadata.h						\
+	tracker-parser.c						\
+	tracker-parser.h						\
 	tracker-process-files.c						\
 	tracker-process-files.h						\
 	tracker-query-tree.c						\

Modified: branches/indexer-split/src/trackerd/tracker-cache.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-cache.c	(original)
+++ branches/indexer-split/src/trackerd/tracker-cache.c	Tue May 13 13:21:24 2008
@@ -379,7 +379,7 @@
 			sleep = TRUE;
 		}
 
-		if (tracker->index_status > INDEX_APPLICATIONS && 
+		if (tracker_index_stage_get () > TRACKER_INDEX_STAGE_APPLICATIONS && 
                     tracker_should_pause ()) {
 			if (db_con) {
 				stopped_trans = TRUE;

Added: branches/indexer-split/src/trackerd/tracker-index-stage.c
==============================================================================
--- (empty file)
+++ branches/indexer-split/src/trackerd/tracker-index-stage.c	Tue May 13 13:21:24 2008
@@ -0,0 +1,125 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2008, Mr Jamie McCracken (jamiemcc gnome org)
+ * Copyright (C) 2008, Nokia
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA  02110-1301, USA.
+ */
+
+#include "config.h"
+
+#include <libtracker-common/tracker-log.h>
+
+#include "tracker-index-stage.h"
+
+/* FIXME: shouldn't we have a proper 'initial' stage? */
+static TrackerIndexStage index_stage = TRACKER_INDEX_STAGE_CONFIG;
+
+GType
+tracker_index_stage_get_type (void)
+{
+        static GType etype = 0;
+
+        if (etype == 0) {
+                static const GEnumValue values[] = {
+                        { TRACKER_INDEX_STAGE_CONFIG,
+                          "TRACKER_INDEX_STAGE_CONFIG",
+                          "Config" },
+                        { TRACKER_INDEX_STAGE_APPLICATIONS,
+                          "TRACKER_INDEX_STAGE_APPLICATIONS",
+                          "Applications" },
+                        { TRACKER_INDEX_STAGE_FILES,
+                          "TRACKER_INDEX_STAGE_FILES",
+                          "Files" },
+                        { TRACKER_INDEX_STAGE_WEBHISTORY,
+                          "TRACKER_INDEX_STAGE_WEBHISTORY",
+                          "Web History" },
+                        { TRACKER_INDEX_STAGE_CRAWL_FILES,
+                          "TRACKER_INDEX_STAGE_CRAWL_FILES",
+                          "Crawl Files" },
+                        { TRACKER_INDEX_STAGE_CONVERSATIONS,
+                          "TRACKER_INDEX_STAGE_CONVERSATIONS",
+                          "Conversations" },
+                        { TRACKER_INDEX_STAGE_EXTERNAL,
+                          "TRACKER_INDEX_STAGE_EXTERNAL",
+                          "External?" },
+                        { TRACKER_INDEX_STAGE_EMAILS,
+                          "TRACKER_INDEX_STAGE_EMAILS",
+                          "Emails" },
+                        { TRACKER_INDEX_STAGE_FINISHED,
+                          "TRACKER_INDEX_STAGE_FINISHED",
+                          "Finished" },
+                        { 0, NULL, NULL }
+                };
+
+                etype = g_enum_register_static ("TrackerIndexStage", values);
+
+                /* Since we don't reference this enum anywhere, we do
+                 * it here to make sure it exists when we call
+                 * g_type_class_peek(). This wouldn't be necessary if
+                 * it was a param in a GObject for example.
+                 * 
+                 * This does mean that we are leaking by 1 reference
+                 * here and should clean it up, but it doesn't grow so
+                 * this is acceptable. 
+                 */
+                
+                g_type_class_ref (etype);
+        }
+
+        return etype;
+}
+
+const gchar *
+tracker_index_stage_to_string (TrackerIndexStage stage)
+{
+        GType       type;
+        GEnumClass *enum_class;
+        GEnumValue *enum_value;
+
+        type = tracker_index_stage_get_type ();
+        enum_class = G_ENUM_CLASS (g_type_class_peek (type));
+        enum_value = g_enum_get_value (enum_class, stage);
+        
+        if (!enum_value) {
+                enum_value = g_enum_get_value (enum_class, TRACKER_INDEX_STAGE_FINISHED);
+        }
+
+        return enum_value->value_nick;
+}
+
+TrackerIndexStage
+tracker_index_stage_get (void)
+{
+        return index_stage;
+}
+
+const gchar *
+tracker_index_stage_get_as_string (void)
+{
+        return tracker_index_stage_to_string (index_stage);
+}
+
+void
+tracker_index_stage_set (TrackerIndexStage new_stage)
+{
+	tracker_log ("Index stage changing from '%s' to '%s'",
+		     tracker_index_stage_to_string (index_stage),
+		     tracker_index_stage_to_string (new_stage));
+
+        index_stage = new_stage;
+}
+

Added: branches/indexer-split/src/trackerd/tracker-index-stage.h
==============================================================================
--- (empty file)
+++ branches/indexer-split/src/trackerd/tracker-index-stage.h	Tue May 13 13:21:24 2008
@@ -0,0 +1,52 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* 
+ * Copyright (C) 2008, Mr Jamie McCracken (jamiemcc gnome org)
+ * Copyright (C) 2008, Nokia
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA  02110-1301, USA.
+ */
+
+#ifndef __TRACKERD_INDEX_STAGE_H__
+#define __TRACKERD_INDEX_STAGE_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define TRACKER_TYPE_INDEX_STAGE (tracker_index_stage_get_type ())
+
+typedef enum {
+	TRACKER_INDEX_STAGE_CONFIG,
+	TRACKER_INDEX_STAGE_APPLICATIONS,
+	TRACKER_INDEX_STAGE_FILES,
+	TRACKER_INDEX_STAGE_WEBHISTORY,
+	TRACKER_INDEX_STAGE_CRAWL_FILES,
+	TRACKER_INDEX_STAGE_CONVERSATIONS,	
+	TRACKER_INDEX_STAGE_EXTERNAL,	
+	TRACKER_INDEX_STAGE_EMAILS,
+	TRACKER_INDEX_STAGE_FINISHED
+} TrackerIndexStage;
+
+GType         tracker_index_stage_get_type       (void) G_GNUC_CONST;
+
+const gchar * tracker_index_stage_to_string      (TrackerIndexStage  stage);
+TrackerIndexStage tracker_index_stage_get            (void);
+const gchar * tracker_index_stage_get_as_string  (void);
+void          tracker_index_stage_set            (TrackerIndexStage  new_stage);
+
+G_END_DECLS
+
+#endif /* __TRACKERD_INDEX_STAGE_H__ */

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 May 13 13:21:24 2008
@@ -532,8 +532,6 @@
 	tracker->reindex = FALSE;
 	tracker->in_merge = FALSE;
 
-	tracker->index_status = INDEX_CONFIG;
-
 	tracker->black_list_timer_active = FALSE;	
 
 	tracker->pause_manual = FALSE;

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 May 13 13:21:24 2008
@@ -35,6 +35,7 @@
 
 #include "tracker-parser.h"
 #include "tracker-indexer.h"
+#include "tracker-index-stage.h"
 #include "tracker-hal.h"
 
 /* default performance options */
@@ -43,18 +44,6 @@
 
 G_BEGIN_DECLS
 
-typedef enum {
-	INDEX_CONFIG,
-	INDEX_APPLICATIONS,
-	INDEX_FILES,
-	INDEX_WEBHISTORY,
-	INDEX_CRAWL_FILES,
-	INDEX_CONVERSATIONS,	
-	INDEX_EXTERNAL,	
-	INDEX_EMAILS,
-	INDEX_FINISHED
-} IndexStatus;
-
 typedef struct {
  	gboolean         is_running; 
 	gboolean         readonly;
@@ -110,8 +99,6 @@
 	gint              mbox_count; 
 	gint              mbox_processed;
 
-	IndexStatus       index_status; 
-
 	gint	          grace_period; 
 	gboolean          request_waiting;
 

Modified: branches/indexer-split/src/trackerd/tracker-metadata.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-metadata.c	(original)
+++ branches/indexer-split/src/trackerd/tracker-metadata.c	Tue May 13 13:21:24 2008
@@ -33,6 +33,7 @@
 
 #include <libtracker-common/tracker-log.h>
 #include <libtracker-common/tracker-file-utils.h>
+#include <libtracker-common/tracker-os-dependant.h>
 
 #include "tracker-metadata.h"
 #include "tracker-utils.h"

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	Tue May 13 13:21:24 2008
@@ -636,7 +636,7 @@
 
         process_queue_files_foreach (uri, tracker);
 
-	if (tracker->index_status != INDEX_EMAILS) {
+	if (tracker_index_stage_get () != TRACKER_INDEX_STAGE_EMAILS) {
                 tracker->folders_processed++;
         }
 }
@@ -1035,7 +1035,7 @@
                 return;
         }
 	
-        tracker->index_status = INDEX_EMAILS;
+        tracker_index_stage_set (TRACKER_INDEX_STAGE_EMAILS);
         
         /* Signal progress */
         daemon = tracker_dbus_get_object (TRACKER_TYPE_DBUS_DAEMON);
@@ -1077,8 +1077,9 @@
 static gboolean
 process_files (Tracker *tracker)
 {
-        DBConnection *db_con;
-        GObject      *object;
+        DBConnection      *db_con;
+        GObject           *object;
+        TrackerIndexStage  stage;
 
         db_con = tracker->index_db;
         object = tracker_dbus_get_object (TRACKER_TYPE_DBUS_DAEMON);
@@ -1098,46 +1099,49 @@
                 }
         }
         
-        if (tracker->index_status != INDEX_FINISHED) {
+        stage = tracker_index_stage_get ();
+
+        if (stage != TRACKER_INDEX_STAGE_FINISHED) {
                 g_mutex_unlock (tracker->files_check_mutex);
                 
-                switch (tracker->index_status) {
-                case INDEX_CONFIG:
+                switch (stage) {
+                case TRACKER_INDEX_STAGE_CONFIG:
                         process_index_config (tracker);
                         break;
                         
-                case INDEX_APPLICATIONS: 
+                case TRACKER_INDEX_STAGE_APPLICATIONS: 
                         process_index_applications (tracker);
                         break;
                         
-                case INDEX_FILES: 
+                case TRACKER_INDEX_STAGE_FILES: 
                         process_index_files (tracker);
                         break;
                         
-                case INDEX_CRAWL_FILES:
+                case TRACKER_INDEX_STAGE_CRAWL_FILES:
                         process_index_crawl_files (tracker);
                         break;
                         
-                case INDEX_CONVERSATIONS:
+                case TRACKER_INDEX_STAGE_CONVERSATIONS:
                         process_index_conversations (tracker);
                         break;
                         
-                case INDEX_WEBHISTORY: 
+                case TRACKER_INDEX_STAGE_WEBHISTORY: 
                         process_index_webhistory (tracker);
                         break;
                         
-                case INDEX_EXTERNAL:
+                case TRACKER_INDEX_STAGE_EXTERNAL:
                         break;
                         
-                case INDEX_EMAILS:
+                case TRACKER_INDEX_STAGE_EMAILS:
                         process_index_emails (tracker);
                         break;
 			
-                case INDEX_FINISHED:
+                case TRACKER_INDEX_STAGE_FINISHED:
                         break;
                 }
                 
-                tracker->index_status++;
+                tracker_index_stage_set (++stage);
+
                 return TRUE;
         }
         
@@ -1162,7 +1166,7 @@
                 return FALSE;
         }
         
-        tracker->index_status = INDEX_FILES;
+        tracker_index_stage_set (TRACKER_INDEX_STAGE_FILES);
 
         /* Signal progress */
         g_signal_emit_by_name (object,
@@ -1173,7 +1177,7 @@
                                tracker->folders_processed,
                                tracker->folders_count);
 
-        tracker->index_status = INDEX_FINISHED;
+        tracker_index_stage_set (TRACKER_INDEX_STAGE_FINISHED);
         
         if (tracker->is_running && tracker->first_time_index) {
                 gint time_taken;
@@ -1271,7 +1275,7 @@
                     tracker_process_files_should_be_watched (tracker->config, info->uri)) {
                         g_async_queue_push (tracker->dir_queue, g_strdup (info->uri));
                         
-                        if (tracker->index_status != INDEX_EMAILS) {
+                        if (tracker_index_stage_get () != TRACKER_INDEX_STAGE_EMAILS) {
                                 tracker->folders_count++;
                         }
                 }
@@ -1557,7 +1561,7 @@
 
         tracker_log ("Proceeding with indexing...");
 
-	tracker->index_status = INDEX_CONFIG;
+	tracker_index_stage_set (TRACKER_INDEX_STAGE_CONFIG);
 
         object = tracker_dbus_get_object (TRACKER_TYPE_DBUS_DAEMON);
 



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