[evolution/wip/gsettings] Drop 'folder_uri' param from em_utils_folder_is_drafts().



commit 9cf4104e04ae93c5b1dcb7a5d41accb507cf0199
Author: Matthew Barnes <mbarnes redhat com>
Date:   Tue May 3 08:59:35 2011 -0400

    Drop 'folder_uri' param from em_utils_folder_is_drafts().

 mail/e-mail-folder-pane.c                |    4 ++--
 mail/e-mail-paned-view.c                 |    2 +-
 mail/e-mail-reader-utils.c               |    4 ++--
 mail/e-mail-reader.c                     |    6 +++---
 mail/em-composer-utils.c                 |    7 +++----
 mail/em-folder-tree-model.c              |    2 +-
 mail/em-utils.c                          |   16 +++++++++-------
 mail/em-utils.h                          |    2 +-
 mail/mail-folder-cache.c                 |    7 ++-----
 modules/mail/e-mail-shell-view-private.c |    2 +-
 plugins/itip-formatter/itip-formatter.c  |    4 ++--
 11 files changed, 27 insertions(+), 29 deletions(-)
---
diff --git a/mail/e-mail-folder-pane.c b/mail/e-mail-folder-pane.c
index 1212312..4035e48 100644
--- a/mail/e-mail-folder-pane.c
+++ b/mail/e-mail-folder-pane.c
@@ -90,7 +90,7 @@ mail_paned_view_open_selected_mail (EMailPanedView *view)
 
 	folder = e_mail_reader_get_folder (reader);
 	folder_uri = e_mail_reader_get_folder_uri (reader);
-	if (em_utils_folder_is_drafts (folder, folder_uri) ||
+	if (em_utils_folder_is_drafts (folder) ||
 		em_utils_folder_is_outbox (folder, folder_uri) ||
 		em_utils_folder_is_templates (folder, folder_uri)) {
 		em_utils_edit_messages (shell, folder, uids, TRUE);
@@ -120,7 +120,7 @@ mail_paned_view_open_selected_mail (EMailPanedView *view)
 			(CamelVeeMessageInfo *) info, &real_uid);
 		real_folder_uri = camel_folder_get_uri (real_folder);
 
-		if (em_utils_folder_is_drafts (real_folder, real_folder_uri) ||
+		if (em_utils_folder_is_drafts (real_folder) ||
 			em_utils_folder_is_outbox (real_folder, real_folder_uri)) {
 			GPtrArray *edits;
 
diff --git a/mail/e-mail-paned-view.c b/mail/e-mail-paned-view.c
index 62d3e67..06da0a0 100644
--- a/mail/e-mail-paned-view.c
+++ b/mail/e-mail-paned-view.c
@@ -782,7 +782,7 @@ mail_paned_view_update_view_instance (EMailView *view)
 	e_filename_make_safe (view_id);
 
 	outgoing_folder =
-		em_utils_folder_is_drafts (folder, folder_uri) ||
+		em_utils_folder_is_drafts (folder) ||
 		em_utils_folder_is_outbox (folder, folder_uri) ||
 		em_utils_folder_is_sent (folder, folder_uri);
 
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index 7f7d57d..9be062d 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -241,7 +241,7 @@ e_mail_reader_open_selected (EMailReader *reader)
 		return 0;
 	}
 
-	if (em_utils_folder_is_drafts (folder, folder_uri) ||
+	if (em_utils_folder_is_drafts (folder) ||
 		em_utils_folder_is_outbox (folder, folder_uri) ||
 		em_utils_folder_is_templates (folder, folder_uri)) {
 		em_utils_edit_messages (shell, folder, uids, TRUE);
@@ -272,7 +272,7 @@ e_mail_reader_open_selected (EMailReader *reader)
 			(CamelVeeMessageInfo *) info, &real_uid);
 		real_folder_uri = camel_folder_get_uri (real_folder);
 
-		if (em_utils_folder_is_drafts (real_folder, real_folder_uri) ||
+		if (em_utils_folder_is_drafts (real_folder) ||
 			em_utils_folder_is_outbox (real_folder, real_folder_uri)) {
 			GPtrArray *edits;
 
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index b9e77b8..c3ad316 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -924,7 +924,7 @@ action_mail_message_edit_cb (GtkAction *action,
 	shell_backend = E_SHELL_BACKEND (backend);
 	shell = e_shell_backend_get_shell (shell_backend);
 
-	replace = em_utils_folder_is_drafts (folder, folder_uri);
+	replace = em_utils_folder_is_drafts (folder);
 	em_utils_edit_messages (shell, folder, uids, replace);
 }
 
@@ -2930,7 +2930,7 @@ mail_reader_set_folder (EMailReader *reader,
 		folder_uri = camel_folder_get_uri (folder);
 
 	outgoing = folder != NULL && folder_uri != NULL && (
-		em_utils_folder_is_drafts (folder, folder_uri) ||
+		em_utils_folder_is_drafts (folder) ||
 		em_utils_folder_is_outbox (folder, folder_uri) ||
 		em_utils_folder_is_sent (folder, folder_uri));
 
@@ -3806,7 +3806,7 @@ e_mail_reader_check_state (EMailReader *reader)
 	}
 
 	drafts_or_outbox =
-		em_utils_folder_is_drafts (folder, folder_uri) ||
+		em_utils_folder_is_drafts (folder) ||
 		em_utils_folder_is_outbox (folder, folder_uri);
 
 	/* Initialize this flag based on whether there are any
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index 31a4029..68d5c00 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -1138,14 +1138,13 @@ edit_message (EShell *shell,
 
 	composer = e_msg_composer_new_with_message (shell, message, NULL);
 
-	if (message_uid != NULL) {
+	if (message_uid != NULL && em_utils_folder_is_drafts (folder)) {
 		const gchar *folder_uri;
 
 		folder_uri = camel_folder_get_uri (folder);
 
-		if (em_utils_folder_is_drafts (folder, folder_uri))
-			e_msg_composer_set_draft_headers (
-				composer, folder_uri, message_uid);
+		e_msg_composer_set_draft_headers (
+			composer, folder_uri, message_uid);
 	}
 
 	composer_set_no_change (composer);
diff --git a/mail/em-folder-tree-model.c b/mail/em-folder-tree-model.c
index 072f5e4..4240dc0 100644
--- a/mail/em-folder-tree-model.c
+++ b/mail/em-folder-tree-model.c
@@ -694,7 +694,7 @@ em_folder_tree_model_set_folder_info (EMFolderTreeModel *model,
 	unread = fi->unread;
 	if (mail_folder_cache_get_folder_from_uri (
 		folder_cache, fi->uri, &folder) && folder) {
-		is_drafts = em_utils_folder_is_drafts (folder, fi->uri);
+		is_drafts = em_utils_folder_is_drafts (folder);
 
 		if (is_drafts || em_utils_folder_is_outbox (folder, fi->uri)) {
 			gint total;
diff --git a/mail/em-utils.c b/mail/em-utils.c
index 676a0f6..ba496dc 100644
--- a/mail/em-utils.c
+++ b/mail/em-utils.c
@@ -1051,22 +1051,24 @@ em_utils_folder_is_templates (CamelFolder *folder, const gchar *uri)
 
 /**
  * em_utils_folder_is_drafts:
- * @folder: folder
- * @uri: uri for this folder, if known
+ * @folder: a #CamelFolder
  *
  * Decides if @folder is a Drafts folder.
  *
  * Returns %TRUE if this is a Drafts folder or %FALSE otherwise.
  **/
 gboolean
-em_utils_folder_is_drafts (CamelFolder *folder, const gchar *uri)
+em_utils_folder_is_drafts (CamelFolder *folder)
 {
 	CamelFolder *local_drafts_folder;
 	CamelSession *session;
 	CamelStore *store;
 	EAccountList *account_list;
 	EIterator *iterator;
-	gint is_drafts = FALSE;
+	gchar *folder_uri;
+	gboolean is_drafts = FALSE;
+
+	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), FALSE);
 
 	local_drafts_folder =
 		e_mail_local_get_folder (E_MAIL_LOCAL_FOLDER_DRAFTS);
@@ -1074,8 +1076,7 @@ em_utils_folder_is_drafts (CamelFolder *folder, const gchar *uri)
 	if (folder == local_drafts_folder)
 		return TRUE;
 
-	if (folder == NULL || uri == NULL)
-		return FALSE;
+	folder_uri = e_mail_folder_uri_from_folder (folder);
 
 	store = camel_folder_get_parent_store (folder);
 	session = camel_service_get_session (CAMEL_SERVICE (store));
@@ -1095,7 +1096,7 @@ em_utils_folder_is_drafts (CamelFolder *folder, const gchar *uri)
 			drafts_uri = em_uri_to_camel (
 				account->drafts_folder_uri);
 			is_drafts = e_mail_folder_uri_equal (
-				session, drafts_uri, uri);
+				session, drafts_uri, folder_uri);
 			g_free (drafts_uri);
 		}
 
@@ -1103,6 +1104,7 @@ em_utils_folder_is_drafts (CamelFolder *folder, const gchar *uri)
 	}
 
 	g_object_unref (iterator);
+	g_free (folder_uri);
 
 	return is_drafts;
 }
diff --git a/mail/em-utils.h b/mail/em-utils.h
index 12fa7b3..744bfe6 100644
--- a/mail/em-utils.h
+++ b/mail/em-utils.h
@@ -62,7 +62,7 @@ void em_utils_selection_get_uidlist (GtkSelectionData *data, EMailSession *sessi
 void em_utils_selection_set_urilist (GtkSelectionData *data, CamelFolder *folder, GPtrArray *uids);
 void em_utils_selection_get_urilist (GtkSelectionData *data, CamelFolder *folder);
 
-gboolean em_utils_folder_is_drafts (CamelFolder *folder, const gchar *uri);
+gboolean em_utils_folder_is_drafts (CamelFolder *folder);
 gboolean em_utils_folder_is_templates (CamelFolder *folder, const gchar *uri);
 gboolean em_utils_folder_is_sent (CamelFolder *folder, const gchar *uri);
 gboolean em_utils_folder_is_outbox (CamelFolder *folder, const gchar *uri);
diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c
index 1a6e48d..c23030b 100644
--- a/mail/mail-folder-cache.c
+++ b/mail/mail-folder-cache.c
@@ -264,8 +264,7 @@ update_1folder (MailFolderCache *self,
 
 		d(printf("update 1 folder '%s'\n", folder->full_name));
 		if ((self->priv->count_trash && (CAMEL_IS_VTRASH_FOLDER (folder)))
-		    || (is_drafts = em_utils_folder_is_drafts (
-			folder, info ? info->uri : NULL))
+		    || (is_drafts = em_utils_folder_is_drafts (folder))
 		    || (is_outbox = em_utils_folder_is_outbox (
 			folder, info ? info->uri : NULL))
 		    || (self->priv->count_sent && em_utils_folder_is_sent (
@@ -289,9 +288,7 @@ update_1folder (MailFolderCache *self,
 			else
 				unread = camel_folder_get_unread_message_count (folder);
 		}
-	} else if (info && !em_utils_folder_is_drafts (NULL, info->uri) &&
-		!em_utils_folder_is_outbox (NULL, info->uri))
-		unread = info->unread;
+	}
 
 	d(printf("folder updated: unread %d: '%s'\n", unread, mfi->full_name));
 
diff --git a/modules/mail/e-mail-shell-view-private.c b/modules/mail/e-mail-shell-view-private.c
index c67dc76..b56a562 100644
--- a/modules/mail/e-mail-shell-view-private.c
+++ b/modules/mail/e-mail-shell-view-private.c
@@ -1169,7 +1169,7 @@ e_mail_shell_view_update_sidebar (EMailShellView *mail_shell_view)
 				num_junked), num_junked);
 
 	/* "Drafts" folder */
-	} else if (em_utils_folder_is_drafts (folder, folder_uri)) {
+	} else if (em_utils_folder_is_drafts (folder)) {
 		g_string_append_printf (
 			buffer, ngettext ("%d draft", "%d drafts",
 			num_visible), num_visible);
diff --git a/plugins/itip-formatter/itip-formatter.c b/plugins/itip-formatter/itip-formatter.c
index f2455ad..f63f962 100644
--- a/plugins/itip-formatter/itip-formatter.c
+++ b/plugins/itip-formatter/itip-formatter.c
@@ -2286,7 +2286,7 @@ in_proper_folder (CamelFolder *folder)
 			  /* or anything else except of sent, outbox or drafts folder */
 			  (!em_utils_folder_is_sent (folder, folder_uri) &&
 			   !em_utils_folder_is_outbox (folder, folder_uri) &&
-			   !em_utils_folder_is_drafts (folder, folder_uri))
+			   !em_utils_folder_is_drafts (folder))
 			));
 	} else {
 		/* cannot check for Inbox folder here */
@@ -2294,7 +2294,7 @@ in_proper_folder (CamelFolder *folder)
 		      (CAMEL_IS_VEE_FOLDER (folder)) || (
 		      !em_utils_folder_is_sent (folder, folder_uri) &&
 		      !em_utils_folder_is_outbox (folder, folder_uri) &&
-		      !em_utils_folder_is_drafts (folder, folder_uri)));
+		      !em_utils_folder_is_drafts (folder)));
 	}
 
 	return res;



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