[evolution-data-server] Bug #638948 - NNTP folder doesn't implement Expunge



commit 3ebf9b817ef6aedf18d5e6e96090658ed52a635d
Author: Milan Crha <mcrha redhat com>
Date:   Tue Jan 11 11:38:59 2011 +0100

    Bug #638948 - NNTP folder doesn't implement Expunge

 camel/camel-disco-folder.c               |   13 +++++++++++++
 camel/providers/nntp/camel-nntp-folder.c |   29 +++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 0 deletions(-)
---
diff --git a/camel/camel-disco-folder.c b/camel/camel-disco-folder.c
index 65e1031..9283010 100644
--- a/camel/camel-disco-folder.c
+++ b/camel/camel-disco-folder.c
@@ -176,6 +176,7 @@ disco_expunge_uids (CamelFolder *folder,
 
 	switch (camel_disco_store_status (CAMEL_DISCO_STORE (parent_store))) {
 	case CAMEL_DISCO_STORE_ONLINE:
+		g_return_val_if_fail (disco_folder_class->expunge_uids_online != NULL, FALSE);
 		success = disco_folder_class->expunge_uids_online (
 			folder, uids, error);
 		CAMEL_CHECK_GERROR (
@@ -183,6 +184,7 @@ disco_expunge_uids (CamelFolder *folder,
 		return success;
 
 	case CAMEL_DISCO_STORE_OFFLINE:
+		g_return_val_if_fail (disco_folder_class->expunge_uids_offline != NULL, FALSE);
 		success = disco_folder_class->expunge_uids_offline (
 			folder, uids, error);
 		CAMEL_CHECK_GERROR (
@@ -190,6 +192,7 @@ disco_expunge_uids (CamelFolder *folder,
 		return success;
 
 	case CAMEL_DISCO_STORE_RESYNCING:
+		g_return_val_if_fail (disco_folder_class->expunge_uids_resyncing != NULL, FALSE);
 		success = disco_folder_class->expunge_uids_resyncing (
 			folder, uids, error);
 		CAMEL_CHECK_GERROR (
@@ -217,6 +220,7 @@ disco_append_message_sync (CamelFolder *folder,
 
 	switch (camel_disco_store_status (CAMEL_DISCO_STORE (parent_store))) {
 	case CAMEL_DISCO_STORE_ONLINE:
+		g_return_val_if_fail (disco_folder_class->append_online != NULL, FALSE);
 		success = disco_folder_class->append_online (
 			folder, message, info,
 			appended_uid, cancellable, error);
@@ -224,6 +228,7 @@ disco_append_message_sync (CamelFolder *folder,
 		return success;
 
 	case CAMEL_DISCO_STORE_OFFLINE:
+		g_return_val_if_fail (disco_folder_class->append_offline != NULL, FALSE);
 		success = disco_folder_class->append_offline (
 			folder, message, info,
 			appended_uid, cancellable, error);
@@ -231,6 +236,7 @@ disco_append_message_sync (CamelFolder *folder,
 		return success;
 
 	case CAMEL_DISCO_STORE_RESYNCING:
+		g_return_val_if_fail (disco_folder_class->append_resyncing != NULL, FALSE);
 		success = disco_folder_class->append_resyncing (
 			folder, message, info,
 			appended_uid, cancellable, error);
@@ -286,6 +292,7 @@ disco_refresh_info_sync (CamelFolder *folder,
 		return TRUE;
 
 	disco_folder_class = CAMEL_DISCO_FOLDER_GET_CLASS (folder);
+	g_return_val_if_fail (disco_folder_class->refresh_info_online != NULL, FALSE);
 
 	success = disco_folder_class->refresh_info_online (
 		folder, cancellable, error);
@@ -314,16 +321,19 @@ disco_synchronize_sync (CamelFolder *folder,
 
 	switch (camel_disco_store_status (CAMEL_DISCO_STORE (parent_store))) {
 	case CAMEL_DISCO_STORE_ONLINE:
+		g_return_val_if_fail (disco_folder_class->sync_online != NULL, FALSE);
 		success = disco_folder_class->sync_online (folder, error);
 		CAMEL_CHECK_GERROR (folder, sync_online, success, error);
 		return success;
 
 	case CAMEL_DISCO_STORE_OFFLINE:
+		g_return_val_if_fail (disco_folder_class->sync_offline != NULL, FALSE);
 		success = disco_folder_class->sync_offline (folder, error);
 		CAMEL_CHECK_GERROR (folder, sync_offline, success, error);
 		return success;
 
 	case CAMEL_DISCO_STORE_RESYNCING:
+		g_return_val_if_fail (disco_folder_class->sync_resyncing != NULL, FALSE);
 		success = disco_folder_class->sync_resyncing (folder, error);
 		CAMEL_CHECK_GERROR (folder, sync_resyncing, success, error);
 		return success;
@@ -350,6 +360,7 @@ disco_transfer_messages_to_sync (CamelFolder *source,
 
 	switch (camel_disco_store_status (CAMEL_DISCO_STORE (parent_store))) {
 	case CAMEL_DISCO_STORE_ONLINE:
+		g_return_val_if_fail (disco_folder_class->transfer_online != NULL, FALSE);
 		success = disco_folder_class->transfer_online (
 			source, uids, dest, transferred_uids,
 			delete_originals, cancellable, error);
@@ -357,6 +368,7 @@ disco_transfer_messages_to_sync (CamelFolder *source,
 		return success;
 
 	case CAMEL_DISCO_STORE_OFFLINE:
+		g_return_val_if_fail (disco_folder_class->transfer_offline != NULL, FALSE);
 		success = disco_folder_class->transfer_offline (
 			source, uids, dest, transferred_uids,
 			delete_originals, cancellable, error);
@@ -364,6 +376,7 @@ disco_transfer_messages_to_sync (CamelFolder *source,
 		return success;
 
 	case CAMEL_DISCO_STORE_RESYNCING:
+		g_return_val_if_fail (disco_folder_class->transfer_resyncing != NULL, FALSE);
 		success = disco_folder_class->transfer_resyncing (
 			source, uids, dest, transferred_uids,
 			delete_originals, cancellable, error);
diff --git a/camel/providers/nntp/camel-nntp-folder.c b/camel/providers/nntp/camel-nntp-folder.c
index 5c0e1b3..1857c23 100644
--- a/camel/providers/nntp/camel-nntp-folder.c
+++ b/camel/providers/nntp/camel-nntp-folder.c
@@ -576,6 +576,32 @@ nntp_folder_transfer_message (CamelFolder *source,
 	return FALSE;
 }
 
+static gboolean
+nntp_folder_expunge_uids_offline (CamelFolder *folder, GPtrArray *uids, GError **error)
+{
+	CamelFolderChangeInfo *changes;
+	gint ii;
+
+	g_return_val_if_fail (folder != NULL, FALSE);
+	g_return_val_if_fail (CAMEL_IS_NNTP_FOLDER (folder), FALSE);
+	g_return_val_if_fail (uids != NULL, FALSE);
+	g_return_val_if_fail (folder->summary != NULL, FALSE);
+
+	/* can only remove deleted messages from a local cache */
+
+	changes = camel_folder_change_info_new ();
+	for (ii = 0; ii < uids->len; ii++) {
+		camel_folder_summary_remove_uid (folder->summary, uids->pdata[ii]);
+		camel_folder_change_info_remove_uid (changes, uids->pdata[ii]);
+	}
+
+	camel_folder_summary_save_to_db (folder->summary, NULL);
+	camel_folder_changed (folder, changes);
+	camel_folder_change_info_free (changes);
+
+	return TRUE;
+}
+
 static void
 camel_nntp_folder_class_init (CamelNNTPFolderClass *class)
 {
@@ -609,6 +635,9 @@ camel_nntp_folder_class_init (CamelNNTPFolderClass *class)
 	disco_folder_class->transfer_resyncing = nntp_folder_transfer_message;
 	disco_folder_class->transfer_offline = nntp_folder_transfer_message;
 	disco_folder_class->refresh_info_online = nntp_folder_refresh_info_online;
+	disco_folder_class->expunge_uids_online = nntp_folder_expunge_uids_offline;
+	disco_folder_class->expunge_uids_offline = nntp_folder_expunge_uids_offline;
+	disco_folder_class->expunge_uids_resyncing = nntp_folder_expunge_uids_offline;
 }
 
 static void



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