[evolution/wip/gsettings] Use e_mail_folder_uri_from_folder() instead of camel_folder_get_uri().



commit b59648863b0f48360e4015269e7991c6a8d4b213
Author: Matthew Barnes <mbarnes redhat com>
Date:   Tue May 3 19:24:58 2011 -0400

    Use e_mail_folder_uri_from_folder() instead of camel_folder_get_uri().

 mail/e-mail-notebook-view.c |   10 +++++--
 mail/e-mail-paned-view.c    |    5 ++-
 mail/e-mail-reader.c        |    6 +----
 mail/em-composer-utils.c    |   18 ++++++++++-----
 mail/mail-config.c          |    3 +-
 mail/mail-folder-cache.c    |   52 +++++++++++++++++++------------------------
 6 files changed, 48 insertions(+), 46 deletions(-)
---
diff --git a/mail/e-mail-notebook-view.c b/mail/e-mail-notebook-view.c
index d6e4b4a..582e0af 100644
--- a/mail/e-mail-notebook-view.c
+++ b/mail/e-mail-notebook-view.c
@@ -1099,7 +1099,7 @@ mail_notebook_view_set_folder (EMailReader *reader,
 {
 	EMailNotebookViewPrivate *priv;
 	GtkWidget *new_view;
-	const gchar *folder_uri;
+	gchar *folder_uri;
 #if HAVE_CLUTTER
 	EMailTab *tab;
 	ClutterActor *clone;
@@ -1111,8 +1111,10 @@ mail_notebook_view_set_folder (EMailReader *reader,
 
 	priv = E_MAIL_NOTEBOOK_VIEW (reader)->priv;
 
-	folder_uri = camel_folder_get_uri (folder);
+	folder_uri = e_mail_folder_uri_from_folder (folder);
 	new_view = g_hash_table_lookup (priv->views, folder_uri);
+	g_free (folder_uri);
+
 	if (new_view) {
 		gint curr = emnv_get_page_num (E_MAIL_NOTEBOOK_VIEW (reader), new_view);
 #if HAVE_CLUTTER
@@ -1241,7 +1243,9 @@ mail_notebook_view_set_folder (EMailReader *reader,
 
 #endif
 		e_mail_reader_set_folder (E_MAIL_READER (priv->current_view), folder);
-		g_hash_table_insert (priv->views, g_strdup (folder_uri), priv->current_view);
+
+		folder_uri = e_mail_folder_uri_from_folder (folder);
+		g_hash_table_insert (priv->views, folder_uri, priv->current_view);
 		g_signal_connect (
 			priv->current_view, "changed",
 			G_CALLBACK (reconnect_changed_event), reader);
diff --git a/mail/e-mail-paned-view.c b/mail/e-mail-paned-view.c
index ef09919..589b522 100644
--- a/mail/e-mail-paned-view.c
+++ b/mail/e-mail-paned-view.c
@@ -479,8 +479,8 @@ mail_paned_view_set_folder (EMailReader *reader,
 	EMailReaderInterface *default_interface;
 	GtkWidget *message_list;
 	GKeyFile *key_file;
+	gchar *folder_uri;
 	gchar *group_name;
-	const gchar *folder_uri;
 	const gchar *key;
 	gboolean value;
 	GError *error = NULL;
@@ -519,9 +519,10 @@ mail_paned_view_set_folder (EMailReader *reader,
 
 	/* Restore the folder's preview and threaded state. */
 
-	folder_uri = camel_folder_get_uri (folder);
+	folder_uri = e_mail_folder_uri_from_folder (folder);
 	key_file = e_shell_view_get_state_key_file (shell_view);
 	group_name = g_strdup_printf ("Folder %s", folder_uri);
+	g_free (folder_uri);
 
 	key = STATE_KEY_GROUP_BY_THREADS;
 	value = g_key_file_get_boolean (key_file, group_name, key, &error);
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index 808deda..fd85f5f 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -2885,7 +2885,6 @@ mail_reader_set_folder (EMailReader *reader,
 	GtkWidget *message_list;
 	EMailBackend *backend;
 	EShell *shell;
-	const gchar *folder_uri = NULL;
 	gboolean outgoing;
 
 	priv = E_MAIL_READER_GET_PRIVATE (reader);
@@ -2906,10 +2905,7 @@ mail_reader_set_folder (EMailReader *reader,
 	if (folder == previous_folder)
 		return;
 
-	if (folder != NULL)
-		folder_uri = camel_folder_get_uri (folder);
-
-	outgoing = folder != NULL && folder_uri != NULL && (
+	outgoing = folder != NULL && (
 		em_utils_folder_is_drafts (folder) ||
 		em_utils_folder_is_outbox (folder) ||
 		em_utils_folder_is_sent (folder));
diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c
index d1f8666..9d2b660 100644
--- a/mail/em-composer-utils.c
+++ b/mail/em-composer-utils.c
@@ -1158,12 +1158,14 @@ edit_message (EShell *shell,
 	composer = e_msg_composer_new_with_message (shell, message, NULL);
 
 	if (message_uid != NULL && em_utils_folder_is_drafts (folder)) {
-		const gchar *folder_uri;
+		gchar *folder_uri;
 
-		folder_uri = camel_folder_get_uri (folder);
+		folder_uri = e_mail_folder_uri_from_folder (folder);
 
 		e_msg_composer_set_draft_headers (
 			composer, folder_uri, message_uid);
+
+		g_free (folder_uri);
 	}
 
 	composer_set_no_change (composer);
@@ -1434,7 +1436,7 @@ forward_non_attached (EShell *shell,
 {
 	CamelMimeMessage *message;
 	EMsgComposer *composer = NULL;
-	const gchar *folder_uri;
+	gchar *folder_uri;
 	gchar *subject, *text, *forward;
 	gint i;
 	guint32 flags;
@@ -1442,7 +1444,7 @@ forward_non_attached (EShell *shell,
 	if (messages->len == 0)
 		return NULL;
 
-	folder_uri = camel_folder_get_uri (folder);
+	folder_uri = e_mail_folder_uri_from_folder (folder);
 
 	flags = EM_FORMAT_QUOTE_HEADERS | EM_FORMAT_QUOTE_KEEP_SIG;
 	if (style == E_MAIL_FORWARD_STYLE_QUOTED)
@@ -1484,6 +1486,8 @@ forward_non_attached (EShell *shell,
 		g_free (subject);
 	}
 
+	g_free (folder_uri);
+
 	return composer;
 }
 
@@ -2761,12 +2765,14 @@ em_utils_reply_to_message (EShell *shell,
 	g_object_unref (message);
 
 	if (folder != NULL) {
-		const gchar *folder_uri;
+		gchar *folder_uri;
 
-		folder_uri = camel_folder_get_uri (folder);
+		folder_uri = e_mail_folder_uri_from_folder (folder);
 
 		e_msg_composer_set_source_headers (
 			composer, folder_uri, uid, flags);
+
+		g_free (folder_uri);
 	}
 
 	composer_set_no_change (composer);
diff --git a/mail/mail-config.c b/mail/mail-config.c
index ac5d078..56d0105 100644
--- a/mail/mail-config.c
+++ b/mail/mail-config.c
@@ -38,6 +38,7 @@
 #include <gconf/gconf-client.h>
 
 #include "e-mail-local.h"
+#include "e-mail-folder-utils.h"
 #include "mail-config.h"
 #include "mail-folder-cache.h"
 #include "mail-tools.h"
@@ -338,7 +339,7 @@ mail_config_folder_to_cachename (CamelFolder *folder, const gchar *prefix)
 	const gchar *config_dir;
 
 	config_dir = mail_session_get_config_dir ();
-	url = g_strdup (camel_folder_get_uri (folder));
+	url = e_mail_folder_uri_from_folder (folder);
 	e_filename_make_safe (url);
 	basename = g_strdup_printf ("%s%s", prefix, url);
 	filename = g_build_filename (config_dir, "folders", basename, NULL);
diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c
index dff0e00..87f2292 100644
--- a/mail/mail-folder-cache.c
+++ b/mail/mail-folder-cache.c
@@ -50,6 +50,7 @@
 #include "mail-tools.h"
 
 #include "em-utils.h"
+#include "e-mail-folder-utils.h"
 #include "e-mail-local.h"
 #include "e-mail-session.h"
 #include "e-mail-store-utils.h"
@@ -879,9 +880,8 @@ store_go_online_cb (CamelStore *store,
 }
 
 struct _find_info {
-	const gchar *uri;
+	const gchar *folder_uri;
 	struct _folder_info *fi;
-	CamelURL *url;
 };
 
 /* look up on each storeinfo using proper hash function for that stores uri's */
@@ -890,23 +890,19 @@ storeinfo_find_folder_info (CamelStore *store,
                             struct _store_info *si,
                             struct _find_info *fi)
 {
-	CamelProvider *provider;
-	CamelService *service;
-	CamelURL *url;
+	gchar *folder_name;
+	gboolean success;
 
-	service = CAMEL_SERVICE (store);
-	url = camel_service_get_camel_url (service);
-	provider = camel_service_get_provider (service);
+	if (fi->fi != NULL)
+		return;
 
-	if (fi->fi == NULL) {
-		if (provider->url_equal (fi->url, url)) {
-			gchar *path = fi->url->fragment ?
-				fi->url->fragment : fi->url->path;
+	success = e_mail_folder_uri_parse (
+		camel_service_get_session (CAMEL_SERVICE (store)),
+		fi->folder_uri, NULL, &folder_name, NULL);
 
-			if (path[0] == '/')
-				path++;
-			fi->fi = g_hash_table_lookup (si->folders, path);
-		}
+	if (success) {
+		fi->fi = g_hash_table_lookup (si->folders, folder_name);
+		g_free (folder_name);
 	}
 }
 
@@ -1295,13 +1291,11 @@ mail_folder_cache_get_folder_from_uri (MailFolderCache *self,
                                        const gchar *uri,
                                        CamelFolder **folderp)
 {
-	struct _find_info fi = { uri, NULL, NULL };
+	struct _find_info fi = { uri, NULL };
 
 	if (self->priv->stores == NULL)
 		return FALSE;
 
-	fi.url = camel_url_new (uri, NULL);
-
 	g_mutex_lock (self->priv->stores_mutex);
 	g_hash_table_foreach (
 		self->priv->stores, (GHFunc)
@@ -1314,8 +1308,6 @@ mail_folder_cache_get_folder_from_uri (MailFolderCache *self,
 	}
 	g_mutex_unlock (self->priv->stores_mutex);
 
-	camel_url_free (fi.url);
-
 	return fi.fi != NULL;
 }
 
@@ -1324,13 +1316,14 @@ mail_folder_cache_get_folder_info_flags (MailFolderCache *self,
                                          CamelFolder *folder,
                                          gint *flags)
 {
-	const gchar *uri = camel_folder_get_uri (folder);
-	struct _find_info fi = { uri, NULL, NULL };
+	struct _find_info fi = { NULL, NULL };
+	gchar *folder_uri;
 
 	if (self->priv->stores == NULL)
 		return FALSE;
 
-	fi.url = camel_url_new (uri, NULL);
+	folder_uri = e_mail_folder_uri_from_folder (folder);
+	fi.folder_uri = folder_uri;
 
 	g_mutex_lock (self->priv->stores_mutex);
 	g_hash_table_foreach (
@@ -1344,7 +1337,7 @@ mail_folder_cache_get_folder_info_flags (MailFolderCache *self,
 	}
 	g_mutex_unlock (self->priv->stores_mutex);
 
-	camel_url_free (fi.url);
+	g_free (folder_uri);
 
 	return fi.fi != NULL;
 }
@@ -1356,8 +1349,8 @@ mail_folder_cache_get_folder_has_children (MailFolderCache *self,
                                            CamelFolder *folder,
                                            gboolean *found)
 {
-	const gchar *uri = camel_folder_get_uri (folder);
-	struct _find_info fi = { uri, NULL, NULL };
+	struct _find_info fi = { NULL, NULL };
+	gchar *folder_uri;
 
 	g_return_val_if_fail (self != NULL, FALSE);
 	g_return_val_if_fail (folder != NULL, FALSE);
@@ -1365,7 +1358,8 @@ mail_folder_cache_get_folder_has_children (MailFolderCache *self,
 	if (self->priv->stores == NULL)
 		return FALSE;
 
-	fi.url = camel_url_new (uri, NULL);
+	folder_uri = e_mail_folder_uri_from_folder (folder);
+	fi.folder_uri = folder_uri;
 
 	g_mutex_lock (self->priv->stores_mutex);
 	g_hash_table_foreach (
@@ -1375,7 +1369,7 @@ mail_folder_cache_get_folder_has_children (MailFolderCache *self,
 		*found = fi.fi != NULL;
 	g_mutex_unlock (self->priv->stores_mutex);
 
-	camel_url_free (fi.url);
+	g_free (folder_uri);
 
 	return fi.fi != NULL && fi.fi->has_children;
 }



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