[tracker/pushplugin] Proper sent time date format , please squash me



commit 57ff8e5e32426e381378dbbfda526edae6219ab2
Author: Philip Van Hoof <philip codeminded be>
Date:   Tue Sep 22 12:40:07 2009 +0200

    Proper sent time date format , please squash me

 src/plugins/evolution/tracker-evolution-plugin.c |   65 +++++++++++----------
 1 files changed, 34 insertions(+), 31 deletions(-)
---
diff --git a/src/plugins/evolution/tracker-evolution-plugin.c b/src/plugins/evolution/tracker-evolution-plugin.c
index c7f1fd4..0f88659 100644
--- a/src/plugins/evolution/tracker-evolution-plugin.c
+++ b/src/plugins/evolution/tracker-evolution-plugin.c
@@ -168,7 +168,6 @@ typedef struct {
 
 typedef struct {
 	TrackerSparqlBuilder *sparql;
-	TrackerEvolutionPlugin *self;
 } QueuedSet;
 
 typedef struct {
@@ -178,6 +177,11 @@ typedef struct {
 	CamelFolderInfo *iter;
 } TryAgainInfo;
 
+typedef struct {
+	TrackerEvolutionPlugin *self;
+	gchar *account_uri;
+	CamelFolderInfo *iter;
+} GetFolderInfo;
 
 static GQueue *many_queue = NULL;
 static TrackerEvolutionPlugin *manager = NULL;
@@ -342,7 +346,7 @@ send_sparql_commit (TrackerEvolutionPlugin *self, gboolean update)
 
 static void
 process_fields (TrackerSparqlBuilder *sparql, gchar *uid, guint flags, 
-                gchar *sent, gchar *subject, gchar *from, gchar *to, 
+                time_t sent, gchar *subject, gchar *from, gchar *to, 
                 gchar *cc, gchar *size, CamelFolder *folder, gchar *uri)
 {
 	gchar **arr;
@@ -383,10 +387,8 @@ process_fields (TrackerSparqlBuilder *sparql, gchar *uid, guint flags,
 		tracker_sparql_builder_object_string (sparql, subject);
 	}
 
-	if (sent && g_utf8_validate (sent, -1, NULL)) {
-		tracker_sparql_builder_predicate (sparql, "nmo:receivedDate");
-		tracker_sparql_builder_object_string (sparql, sent);
-	}
+	tracker_sparql_builder_predicate (sparql, "nmo:receivedDate");
+	tracker_sparql_builder_object_date (sparql, sent);
 
 	tracker_sparql_builder_predicate (sparql, "nmo:isDeleted");
 	tracker_sparql_builder_object_boolean (sparql, (flags & CAMEL_MESSAGE_DELETED));
@@ -539,6 +541,11 @@ process_fields (TrackerSparqlBuilder *sparql, gchar *uid, guint flags,
 	}
 
 #if 0
+	/* This massively slows down Evolution, we need to do this in a queue 
+	 * instead. Therefore I'm disabling this code for now. The code does
+	 * a parse of each already-once-downloaded E-mail. This is obviously 
+	 * excessive and expensive for the performance of Evolution. */
+
 	if (folder) {
 		gchar *filen = camel_folder_get_filename (folder, uid, NULL);
 		if (filen) {
@@ -576,6 +583,7 @@ process_fields (TrackerSparqlBuilder *sparql, gchar *uid, guint flags,
 									else
 										bytes = camel_data_wrapper_decode_to_stream (wrapper, stream);
 
+									/* The validate check always fails for me, don't know why yet */
 									if (bytes > 0 && g_utf8_validate ((gchar *) mem->buffer->data, -1, NULL)) {
 										tracker_sparql_builder_subject_iri (sparql, uri);
 										tracker_sparql_builder_predicate (sparql, "nie:plainTextContent");
@@ -653,7 +661,8 @@ on_folder_summary_changed (CamelFolder *folder,
 	if (merged->len > 0) {
 
 		for (i = 0; i< merged->len; i++) {
-			gchar *subject, *to, *from, *cc, *uid = NULL, *sent, *size;
+			gchar *subject, *to, *from, *cc, *uid = NULL, *size;
+			time_t sent;
 			guint flags;
 			CamelMessageInfo *linfo;
 			const CamelTag *ctags;
@@ -676,8 +685,7 @@ on_folder_summary_changed (CamelFolder *folder,
 				flags =   (guint)   camel_message_info_flags (linfo);
 
 				/* Camel returns a time_t, I think a uint64 is the best fit here */
-				sent = g_strdup_printf ("%"G_GUINT64_FORMAT, 
-				                        (guint64) camel_message_info_date_sent (linfo));
+				sent = camel_message_info_date_sent (linfo);
 
 				/* Camel returns a uint32, so %u */
 				size = g_strdup_printf ("%u", camel_message_info_size (linfo));
@@ -785,14 +793,13 @@ static void
 queued_set_free (QueuedSet *queued_set)
 {
 	g_object_unref (queued_set->sparql);
-	g_object_unref (queued_set->self);
-
 	g_slice_free (QueuedSet, queued_set);
 }
 
 static gboolean 
 many_idle_handler (gpointer user_data)
 {
+	TrackerEvolutionPluginPrivate *priv = TRACKER_EVOLUTION_PLUGIN_GET_PRIVATE (user_data);
 	QueuedSet *queued_set = NULL;
 	gint popped;
 
@@ -806,8 +813,6 @@ many_idle_handler (gpointer user_data)
 	     queued_set != NULL && popped < QUEUED_SETS_PER_MAINLOOP; 
 	     queued_set  = g_queue_pop_head (many_queue), popped++) {
 
-		TrackerEvolutionPluginPrivate *priv = TRACKER_EVOLUTION_PLUGIN_GET_PRIVATE (queued_set->self);
-
 		/* During initial introduction the client-registrar might 
 		 * decide to crash, disconnect, stop listening. That 
 		 * would result in critical warnings so we start ignoring
@@ -821,7 +826,7 @@ many_idle_handler (gpointer user_data)
 
 			query = tracker_sparql_builder_get_result (queued_set->sparql);
 
-			send_sparql_update (queued_set->self, query);
+			send_sparql_update (user_data, query);
 		} else {
 			gint i;
 			
@@ -859,18 +864,18 @@ start_many_handler (TrackerEvolutionPlugin *self)
 	/* We just slow it down to 'once per second' (for now, we can tweak this
 	 * afterward, of course, but once per second seems to work great) */
 	 g_idle_add_full (G_PRIORITY_LOW,
-	                            many_idle_handler,
-	                            g_object_ref (self),
-	                            many_idle_destroy);
+	                  many_idle_handler,
+	                  g_object_ref (self),
+	                  many_idle_destroy);
 }
 
 /* Initial upload of more recent than last_checkout items, called in the mainloop */
 static void
 introduce_walk_folders_in_folder (TrackerEvolutionPlugin *self, 
-				  CamelFolderInfo *iter, 
-				  CamelStore *store, CamelDB *cdb_r,
-				  gchar *account_uri, 
-				  ClientRegistry *info)
+                                  CamelFolderInfo *iter, 
+                                  CamelStore *store, CamelDB *cdb_r,
+                                  gchar *account_uri, 
+                                  ClientRegistry *info)
 {
 	TrackerEvolutionPluginPrivate *priv = TRACKER_EVOLUTION_PLUGIN_GET_PRIVATE (self);
 	gchar *em_uri = em_uri_from_camel (account_uri);
@@ -895,6 +900,11 @@ introduce_walk_folders_in_folder (TrackerEvolutionPlugin *self,
 		 * allows this 'modseq' optimization (is in fact recommending
 		 * it over using Cleanup() each time) */
 
+		/* TODO: add bodystructure and then prepare a full MIME structure
+		 * using the NMO ontology, by parsing the bodystructure. 
+		 * Bodystructures can be found in %s_bodystructure when they 
+		 * exist (not guaranteed). In IMAP BODYSTRUCTURE format. */
+
 		query = sqlite3_mprintf ("SELECT uid, flags, read, deleted, "            /* 0  - 3  */
 					        "replied, important, junk, attachment, " /* 4  - 7  */
 					        "size, dsent, dreceived, subject, "      /* 8  - 11 */
@@ -915,7 +925,8 @@ introduce_walk_folders_in_folder (TrackerEvolutionPlugin *self,
 			more = FALSE;
 
 			while (ret == SQLITE_OK || ret == SQLITE_BUSY || ret == SQLITE_ROW) {
-				gchar *subject, *to, *from, *cc, *sent, *uid, *size;
+				gchar *subject, *to, *from, *cc, *uid, *size;
+				time_t sent;
 				gchar *part, *label, *p;
 				guint flags;
 
@@ -941,7 +952,7 @@ introduce_walk_folders_in_folder (TrackerEvolutionPlugin *self,
 
 					flags =   (guint  ) sqlite3_column_int  (stmt, 1);
 					size =    (gchar *) sqlite3_column_text (stmt, 8);
-					sent =    (gchar *) sqlite3_column_text (stmt, 9);
+					sent =    (time_t)  sqlite3_column_int64 (stmt, 9);
 					subject = (gchar *) sqlite3_column_text (stmt, 11);
 					from =    (gchar *) sqlite3_column_text (stmt, 12);
 					to =      (gchar *) sqlite3_column_text (stmt, 13);
@@ -1071,8 +1082,6 @@ introduce_walk_folders_in_folder (TrackerEvolutionPlugin *self,
 				queued_set->sparql = sparql; /* Keep ref */
 				sparql = NULL;
 
-				queued_set->self = g_object_ref (self);
-
 				if (!many_queue) {
 					many_queue = g_queue_new ();
 					start_handler = TRUE;
@@ -1287,12 +1296,6 @@ get_last_deleted_time (TrackerEvolutionPlugin *self)
 	return smallest;
 }
 
-typedef struct {
-	TrackerEvolutionPlugin *self;
-	gchar *account_uri;
-	CamelFolderInfo *iter;
-} GetFolderInfo;
-
 static void
 register_on_get_folder (gchar *uri, CamelFolder *folder, gpointer user_data)
 {



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