Re: [evolution-patches] 73498/72968 Connector Mail Offline



Changes done on top of previous patch, looks ok for me.
-Sushma.

Ahmed Sarfraaz wrote:

This patch looks fine, except for 2 things, which i have now fixed in
this new patch.

1. Moved the state file creation to be done much earlier in the
folder_construct so that the state is saved even in offline.

2. exchange_entry_play_append now stores back the message info from
journal cache to the real cache.


--Sarfraaz

Regards
Sarfraaz Ahmed
JP Rosevear <jpr novell com> 03/16/05 9:44 AM >>>
Missing patch from Jeff.

-JP
------------------------------------------------------------------------

? camel/camel-exchange-provider.c.surf
? camel/camel-exchange-store.c.save
Index: camel/camel-exchange-folder.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/camel/camel-exchange-folder.c,v
retrieving revision 1.15
diff -u -p -u -r1.15 camel-exchange-folder.c
--- camel/camel-exchange-folder.c	28 Feb 2005 15:20:39 -0000	1.15
+++ camel/camel-exchange-folder.c	16 Mar 2005 06:56:08 -0000
@@ -50,7 +50,6 @@ static CamelOfflineFolderClass *parent_c
/* Returns the class for a CamelFolder */
#define CF_CLASS(so) CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(so))

-static void refresh_info (CamelFolder *folder, CamelException *ex);
static void folder_sync (CamelFolder *folder, gboolean expunge,
			 CamelException *ex);
static void exchange_expunge (CamelFolder *folder, CamelException *ex);
@@ -81,7 +80,7 @@ static void   transfer_messages_the_hard
					      GPtrArray **transferred_uids,
					      gboolean delete_originals,
					      CamelException *ex);
-static void exchange_refresh_info (CamelFolder *folder, CamelException *ex);
+static void refresh_info (CamelFolder *folder, CamelException *ex);
static void exchange_sync (CamelFolder *folder, gboolean expunge, CamelException *ex);

static void
@@ -98,7 +97,7 @@ class_init (CamelFolderClass *camel_fold
	camel_folder_class->search_by_uids = search_by_uids;
	camel_folder_class->search_free = search_free;
	camel_folder_class->transfer_messages_to = transfer_messages_to;
-	camel_folder_class->refresh_info = exchange_refresh_info;
+	camel_folder_class->refresh_info = refresh_info;
	camel_folder_class->sync = exchange_sync;
}

@@ -198,7 +197,9 @@ static void
refresh_info (CamelFolder *folder, CamelException *ex)
{
	CamelExchangeFolder *exch = CAMEL_EXCHANGE_FOLDER (folder);
-
+	
+	camel_offline_journal_replay (exch->journal, NULL);
+	
	camel_stub_send (exch->stub, ex, CAMEL_STUB_CMD_REFRESH_FOLDER,
			 CAMEL_STUB_ARG_FOLDER, folder->full_name,
			 CAMEL_STUB_ARG_END);
@@ -617,9 +618,8 @@ transfer_messages_to (CamelFolder *sourc
			
			if (!(message = get_message (source, camel_message_info_uid (info), ex)))
				break;
-
- camel_exchange_journal_transfer (journal, (CamelExchangeFolder *)source, - message, info, uids->pdata[i], NULL, ex);
+			
+			camel_exchange_journal_append (journal, message, info, NULL, ex);
			camel_object_unref (message);

			if (camel_exception_is_set (ex))
@@ -627,7 +627,7 @@ transfer_messages_to (CamelFolder *sourc
			
			if (delete_originals)
				camel_folder_set_message_flags (source, camel_message_info_uid (info),
-					CAMEL_MESSAGE_DELETED, CAMEL_MESSAGE_DELETED);
+								CAMEL_MESSAGE_DELETED, CAMEL_MESSAGE_DELETED);
		}
		goto end;
 	}
@@ -920,7 +920,7 @@ camel_exchange_folder_construct (CamelFo
{
	CamelExchangeFolder *exch = (CamelExchangeFolder *)folder;
	const char *short_name;
-	char *summary_file, *journal_file;
+	char *summary_file, *journal_file, *path;
	GPtrArray *summary, *uids;
	GByteArray *flags;
	guint32 folder_flags;
@@ -968,6 +968,11 @@ camel_exchange_folder_construct (CamelFo
		return FALSE;
	}

+	path = g_build_filename (folder_dir, "cmeta", NULL);
+	camel_object_set (folder, NULL, CAMEL_OBJECT_STATE_FILE, path, NULL);
+	g_free (path);
+	camel_object_state_read (folder);
+
	exch->thread_index_to_message_id =
		g_hash_table_new (g_str_hash, g_str_equal);

@@ -1041,14 +1046,8 @@ camel_exchange_folder_construct (CamelFo

	if (camel_exchange_summary_get_readonly (folder->summary))
		folder->permanent_flags = 0;
-
+	
	return TRUE;
-}
-
-static void -exchange_refresh_info (CamelFolder *folder, CamelException *ex)
-{
-	refresh_info (folder, ex);
}

static void Index: camel/camel-exchange-journal.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/camel/camel-exchange-journal.c,v
retrieving revision 1.2
diff -u -p -u -r1.2 camel-exchange-journal.c
--- camel/camel-exchange-journal.c	24 Jan 2005 14:22:38 -0000	1.2
+++ camel/camel-exchange-journal.c	16 Mar 2005 06:56:08 -0000
@@ -109,8 +109,6 @@ exchange_entry_free (CamelOfflineJournal
	CamelExchangeJournalEntry *exchange_entry = (CamelExchangeJournalEntry *) entry;
	
	g_free (exchange_entry->uid);
-	g_free (exchange_entry->original_uid);
-	g_free (exchange_entry->folder_name);
	g_free (exchange_entry);
}

@@ -130,14 +128,6 @@ exchange_entry_load (CamelOfflineJournal
			goto exception;
		
		break;
-	case CAMEL_EXCHANGE_JOURNAL_ENTRY_TRANSFER:
-		if (camel_file_util_decode_string (in, &entry->uid) == -1)
-			goto exception;
-		if (camel_file_util_decode_string (in, &entry->original_uid) == -1)
-			goto exception;
-		if (camel_file_util_decode_string (in, &entry->folder_name) == -1)
-			goto exception;
-		break;
	default:
		goto exception;
	}
@@ -146,9 +136,6 @@ exchange_entry_load (CamelOfflineJournal
	
 exception:
	
-	if (entry->type == CAMEL_EXCHANGE_JOURNAL_ENTRY_TRANSFER)
-		g_free (entry->folder_name);
-
	g_free (entry->uid);
	g_free (entry);
	
@@ -168,13 +155,6 @@ exchange_entry_write (CamelOfflineJourna
		if (camel_file_util_encode_string (out, exchange_entry->uid))
			return -1;
		break;
-	case CAMEL_EXCHANGE_JOURNAL_ENTRY_TRANSFER:
-		if (camel_file_util_encode_string (out, exchange_entry->uid))
-			return -1;
-		if (camel_file_util_encode_string (out, exchange_entry->original_uid))
-			return -1;
-		if (camel_file_util_encode_string (out, exchange_entry->folder_name))
-			return -1;
	default:
		g_assert_not_reached ();
	}
@@ -199,9 +179,10 @@ exchange_entry_play_append (CamelOffline
	CamelExchangeFolder *exchange_folder = (CamelExchangeFolder *) journal->folder;
	CamelFolder *folder = journal->folder;
	CamelMimeMessage *message;
-	CamelMessageInfo *info;
+	CamelMessageInfo *info, *real;
	CamelStream *stream;
	CamelException lex;
+	char *uid = NULL;
	
	/* if the message isn't in the cache, the user went behind our backs so "not our problem" */
	if (!exchange_folder->cache || !(stream = camel_data_cache_get (exchange_folder->cache, "cache", entry->uid, ex)))
@@ -222,14 +203,20 @@ exchange_entry_play_append (CamelOffline
	}
	
	camel_exception_init (&lex);
-	camel_folder_append_message (folder, message, info, NULL, &lex);
-	camel_message_info_free (info);
+	camel_folder_append_message (folder, message, info, &uid, &lex);
	camel_object_unref (message);
	
	if (camel_exception_is_set (&lex)) {
		camel_exception_xfer (ex, &lex);
		return -1;
	}
+
+	if (uid != NULL && (real = camel_folder_summary_uid (folder->summary, uid))) {
+			
+		exchange_message_info_dup_to ((CamelMessageInfoBase *) real, (CamelMessageInfoBase *) info);
+	}
+	camel_message_info_free (info);
+	g_free (uid);
	
 done:
	
@@ -239,61 +226,6 @@ exchange_entry_play_append (CamelOffline
	return 0;
}

-static int -exchange_entry_play_transfer (CamelOfflineJournal *journal, CamelExchangeJournalEntry *entry, CamelException *ex)
-{
-	CamelExchangeFolder *exchange_folder = (CamelExchangeFolder *) journal->folder;
-	CamelFolder *folder = journal->folder;
-	CamelExchangeMessageInfo *real;
-	CamelMessageInfoBase *info;
-	GPtrArray *xuids, *uids;
-	CamelException lex;
-	CamelFolder *src;
-
-	if (!(info = (CamelMessageInfoBase *) camel_folder_summary_uid (folder->summary, entry->uid))) {
-		/* Note: this should never happen, but rather than crash lets make a new info */
-		info = camel_message_info_new (NULL);
-	}
-
-	if (entry->folder_name && (src = camel_store_get_folder (folder->parent_store, folder->name, 0, ex))) {
-		uids = g_ptr_array_sized_new (1);
-		g_ptr_array_add (uids, entry->original_uid);
-
-		camel_exception_init (&lex);
-		camel_folder_transfer_messages_to (src, uids, folder, &xuids, FALSE, &lex);
-		if (!camel_exception_is_set (&lex)) {
-			real = (CamelExchangeMessageInfo *) camel_folder_summary_uid (folder->summary, xuids->pdata[0]);
-		
-			/* Transfer flags and uids */
-			exchange_message_info_dup_to ((CamelMessageInfoBase *) real, (CamelMessageInfoBase *) info);
-			camel_message_info_free (real);
-		} else {
-			camel_exception_xfer (ex, &lex);
-			goto exception;
-		}
-
-		g_ptr_array_free (xuids, TRUE);
-		g_ptr_array_free (uids, TRUE);
-		camel_object_unref (src);
-	} else if (!entry->folder_name) {
-		camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, _("No folder name found\n"));
-		goto exception;
-	}
-
-	/* message was successfully transferred, remove the fake item from the cache/summary */
-	camel_folder_summary_remove_uid (folder->summary, entry->uid);
-	camel_data_cache_remove (exchange_folder->cache, "cache", entry->uid, NULL);
-	camel_message_info_free (info);
-
-	return 0;
-
-exception:
-	
-	camel_message_info_free (info);
-
-	return -1;
-}
-
static int
exchange_entry_play (CamelOfflineJournal *journal, EDListNode *entry, CamelException *ex)
{
@@ -302,8 +234,6 @@ exchange_entry_play (CamelOfflineJournal
	switch (exchange_entry->type) {
	case CAMEL_EXCHANGE_JOURNAL_ENTRY_APPEND:
		return exchange_entry_play_append (journal, exchange_entry, ex);
-	case CAMEL_EXCHANGE_JOURNAL_ENTRY_TRANSFER:
-		return exchange_entry_play_transfer (journal, exchange_entry, ex);
	default:
		g_assert_not_reached ();
		return -1;
@@ -383,7 +313,7 @@ update_cache (CamelExchangeJournal *exch

void
camel_exchange_journal_append (CamelExchangeJournal *exchange_journal, CamelMimeMessage *message,
-			    const CamelMessageInfo *mi, char **appended_uid, CamelException *ex)
+			       const CamelMessageInfo *mi, char **appended_uid, CamelException *ex)
{
	CamelOfflineJournal *journal = (CamelOfflineJournal *) exchange_journal;
	CamelExchangeJournalEntry *entry;
@@ -402,28 +332,3 @@ camel_exchange_journal_append (CamelExch
		*appended_uid = g_strdup (uid);

}
-
-void -camel_exchange_journal_transfer (CamelExchangeJournal *exchange_journal, CamelExchangeFolder *source_folder,
-				CamelMimeMessage *message, const CamelMessageInfo *mi,
-				const char *original_uid, char **transferred_uid, CamelException *ex)
-{
-	CamelOfflineJournal *journal = (CamelOfflineJournal *) exchange_journal;
-	CamelExchangeJournalEntry *entry;
-	char *uid;
-	
-	if (!update_cache (exchange_journal, message, mi, &uid, ex))
-		return;
-
-	entry = g_new (CamelExchangeJournalEntry, 1);
-	entry->type = CAMEL_EXCHANGE_JOURNAL_ENTRY_TRANSFER;
-	entry->uid = uid;
-	entry->original_uid = g_strdup (original_uid);
-	entry->folder_name = g_strdup (((CamelFolder *)source_folder)->name);
-
-	e_dlist_addtail (&journal->queue, (EDListNode *) entry);
-	
-	if (transferred_uid)
-		*transferred_uid = g_strdup (uid);	
-}
-
Index: camel/camel-exchange-journal.h
===================================================================
RCS file: /cvs/gnome/evolution-exchange/camel/camel-exchange-journal.h,v
retrieving revision 1.2
diff -u -p -u -r1.2 camel-exchange-journal.h
--- camel/camel-exchange-journal.h	24 Jan 2005 14:22:38 -0000	1.2
+++ camel/camel-exchange-journal.h	16 Mar 2005 06:56:08 -0000
@@ -50,7 +50,6 @@ typedef struct _CamelExchangeJournalEntr

enum {
	CAMEL_EXCHANGE_JOURNAL_ENTRY_APPEND,
-	CAMEL_EXCHANGE_JOURNAL_ENTRY_TRANSFER
};

struct _CamelExchangeJournalEntry {
@@ -59,8 +58,6 @@ struct _CamelExchangeJournalEntry {
	int type;

	char *uid;
-	char *original_uid;
-	char *folder_name;
};

struct _CamelExchangeJournal {
@@ -80,11 +77,7 @@ CamelOfflineJournal *camel_exchange_jour

/* interfaces for adding a journal entry */
void camel_exchange_journal_append (CamelExchangeJournal *journal, CamelMimeMessage *message, - const CamelMessageInfo *mi, char **appended_uid, CamelException *ex);
-
-void camel_exchange_journal_transfer (CamelExchangeJournal *journal, CamelExchangeFolder *source_folder, - CamelMimeMessage *message, const CamelMessageInfo *mi, const char *original_uid,
-				char **transferred_uid, CamelException *ex);
+				    const CamelMessageInfo *mi, char **appended_uid, CamelException *ex);

#ifdef __cplusplus
}




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