[evolution] Remove mail_tools_folder_to_url().



commit ed45d23b84053e1c341db3eb5520311d314ca1ae
Author: Matthew Barnes <mbarnes redhat com>
Date:   Mon Oct 11 22:08:12 2010 -0400

    Remove mail_tools_folder_to_url().
    
    Use camel_folder_get_uri() instead.

 mail/e-mail-folder-pane.c               |    5 +--
 mail/e-mail-paned-view.c                |    4 ++-
 mail/e-mail-reader-utils.c              |    5 +--
 mail/mail-config.c                      |   14 +-----------
 mail/mail-config.h                      |    2 -
 mail/mail-folder-cache.c                |    6 +---
 mail/mail-tools.c                       |   32 -------------------------------
 mail/mail-tools.h                       |    2 -
 mail/message-list.c                     |   14 ++++++------
 modules/mail/e-mail-shell-view.c        |   12 +++-------
 plugins/itip-formatter/itip-formatter.c |   18 +++++++---------
 11 files changed, 30 insertions(+), 84 deletions(-)
---
diff --git a/mail/e-mail-folder-pane.c b/mail/e-mail-folder-pane.c
index a8c2a3d..54d5cc4 100644
--- a/mail/e-mail-folder-pane.c
+++ b/mail/e-mail-folder-pane.c
@@ -107,7 +107,7 @@ mail_paned_view_open_selected_mail (EMailPanedView *view)
 		const gchar *uid = uids->pdata[ii];
 		CamelFolder *real_folder;
 		CamelMessageInfo *info;
-		gchar *real_folder_uri;
+		const gchar *real_folder_uri;
 		gchar *real_uid;
 
 		if (!CAMEL_IS_VEE_FOLDER (folder)) {
@@ -122,7 +122,7 @@ mail_paned_view_open_selected_mail (EMailPanedView *view)
 		real_folder = camel_vee_folder_get_location (
 			CAMEL_VEE_FOLDER (folder),
 			(CamelVeeMessageInfo *) info, &real_uid);
-		real_folder_uri = mail_tools_folder_to_url (real_folder);
+		real_folder_uri = camel_folder_get_uri (real_folder);
 
 		if (em_utils_folder_is_drafts (real_folder, real_folder_uri) ||
 			em_utils_folder_is_outbox (real_folder, real_folder_uri)) {
@@ -137,7 +137,6 @@ mail_paned_view_open_selected_mail (EMailPanedView *view)
 			g_ptr_array_add (views, g_strdup (uid));
 		}
 
-		g_free (real_folder_uri);
 		camel_folder_free_message_info (folder, info);
 	}
 
diff --git a/mail/e-mail-paned-view.c b/mail/e-mail-paned-view.c
index d63109d..9782a8d 100644
--- a/mail/e-mail-paned-view.c
+++ b/mail/e-mail-paned-view.c
@@ -718,7 +718,9 @@ mail_paned_view_update_view_instance (EMailView *view)
 		priv->view_instance = NULL;
 	}
 
-	view_id = mail_config_folder_to_safe_url (folder);
+	view_id = g_strdup (folder_uri);
+	e_filename_make_safe (view_id);
+
 	if (e_shell_settings_get_boolean (shell_settings, "mail-global-view-setting"))
 		view_instance = e_shell_view_new_view_instance (shell_view, "global_view_setting");
 	else
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c
index 44351c2..162e78b 100644
--- a/mail/e-mail-reader-utils.c
+++ b/mail/e-mail-reader-utils.c
@@ -260,7 +260,7 @@ e_mail_reader_open_selected (EMailReader *reader)
 		const gchar *uid = uids->pdata[ii];
 		CamelFolder *real_folder;
 		CamelMessageInfo *info;
-		gchar *real_folder_uri;
+		const gchar *real_folder_uri;
 		gchar *real_uid;
 
 		if (!CAMEL_IS_VEE_FOLDER (folder)) {
@@ -275,7 +275,7 @@ e_mail_reader_open_selected (EMailReader *reader)
 		real_folder = camel_vee_folder_get_location (
 			CAMEL_VEE_FOLDER (folder),
 			(CamelVeeMessageInfo *) info, &real_uid);
-		real_folder_uri = mail_tools_folder_to_url (real_folder);
+		real_folder_uri = camel_folder_get_uri (real_folder);
 
 		if (em_utils_folder_is_drafts (real_folder, real_folder_uri) ||
 			em_utils_folder_is_outbox (real_folder, real_folder_uri)) {
@@ -290,7 +290,6 @@ e_mail_reader_open_selected (EMailReader *reader)
 			g_ptr_array_add (views, g_strdup (uid));
 		}
 
-		g_free (real_folder_uri);
 		camel_folder_free_message_info (folder, info);
 	}
 
diff --git a/mail/mail-config.c b/mail/mail-config.c
index a89722d..fae6bda 100644
--- a/mail/mail-config.c
+++ b/mail/mail-config.c
@@ -522,24 +522,14 @@ mail_config_service_set_save_passwd (EAccountService *service, gboolean save_pas
 }
 
 gchar *
-mail_config_folder_to_safe_url (CamelFolder *folder)
-{
-	gchar *url;
-
-	url = mail_tools_folder_to_url (folder);
-	e_filename_make_safe (url);
-
-	return url;
-}
-
-gchar *
 mail_config_folder_to_cachename (CamelFolder *folder, const gchar *prefix)
 {
 	gchar *url, *basename, *filename;
 	const gchar *config_dir;
 
 	config_dir = mail_session_get_config_dir ();
-	url = mail_config_folder_to_safe_url (folder);
+	url = g_strdup (camel_folder_get_uri (folder));
+	e_filename_make_safe (url);
 	basename = g_strdup_printf ("%s%s", prefix, url);
 	filename = g_build_filename (config_dir, "folders", basename, NULL);
 	g_free (basename);
diff --git a/mail/mail-config.h b/mail/mail-config.h
index 8fa7359..6c597a6 100644
--- a/mail/mail-config.h
+++ b/mail/mail-config.h
@@ -94,8 +94,6 @@ EAccountService *
 /* static utility functions */
 gchar *		mail_config_folder_to_cachename	(CamelFolder *folder,
 						 const gchar *prefix);
-gchar *		mail_config_folder_to_safe_url	(CamelFolder *folder);
-
 gint		mail_config_get_sync_timeout	(void);
 
 void		mail_config_reload_junk_headers	(CamelSession *session);
diff --git a/mail/mail-folder-cache.c b/mail/mail-folder-cache.c
index 8aed1b5..7ff29c3 100644
--- a/mail/mail-folder-cache.c
+++ b/mail/mail-folder-cache.c
@@ -1327,7 +1327,7 @@ mail_folder_cache_get_folder_info_flags (MailFolderCache *self,
                                          CamelFolder *folder,
                                          gint *flags)
 {
-	gchar *uri = mail_tools_folder_to_url (folder);
+	const gchar *uri = camel_folder_get_uri (folder);
 	struct _find_info fi = { uri, NULL, NULL };
 
 	if (self->priv->stores == NULL)
@@ -1348,7 +1348,6 @@ mail_folder_cache_get_folder_info_flags (MailFolderCache *self,
 	g_mutex_unlock (self->priv->stores_mutex);
 
 	camel_url_free (fi.url);
-	g_free (uri);
 
 	return fi.fi != NULL;
 }
@@ -1360,7 +1359,7 @@ mail_folder_cache_get_folder_has_children (MailFolderCache *self,
                                            CamelFolder *folder,
                                            gboolean *found)
 {
-	gchar *uri = mail_tools_folder_to_url (folder);
+	const gchar *uri = camel_folder_get_uri (folder);
 	struct _find_info fi = { uri, NULL, NULL };
 
 	g_return_val_if_fail (self != NULL, FALSE);
@@ -1380,7 +1379,6 @@ mail_folder_cache_get_folder_has_children (MailFolderCache *self,
 	g_mutex_unlock (self->priv->stores_mutex);
 
 	camel_url_free (fi.url);
-	g_free (uri);
 
 	return fi.fi != NULL && fi.fi->has_children;
 }
diff --git a/mail/mail-tools.c b/mail/mail-tools.c
index c005c27..23b2a8c 100644
--- a/mail/mail-tools.c
+++ b/mail/mail-tools.c
@@ -232,35 +232,3 @@ mail_tool_make_message_attachment (CamelMimeMessage *message)
 
 	return part;
 }
-
-/* FIXME: This should be a property on CamelFolder */
-gchar *
-mail_tools_folder_to_url (CamelFolder *folder)
-{
-	CamelService *service;
-	CamelStore *parent_store;
-	const gchar *full_name;
-	CamelURL *url;
-	gchar *out;
-
-	g_return_val_if_fail (CAMEL_IS_FOLDER (folder), NULL);
-
-	full_name = camel_folder_get_full_name (folder);
-	parent_store = camel_folder_get_parent_store (folder);
-	service = CAMEL_SERVICE (parent_store);
-
-	url = camel_url_copy (service->url);
-	if (service->provider->url_flags  & CAMEL_URL_FRAGMENT_IS_PATH) {
-		camel_url_set_fragment (url, full_name);
-	} else {
-		gchar *name = g_alloca (strlen (full_name)+2);
-
-		sprintf(name, "/%s", full_name);
-		camel_url_set_path (url, name);
-	}
-
-	out = camel_url_to_string (url, CAMEL_URL_HIDE_ALL);
-	camel_url_free (url);
-
-	return out;
-}
diff --git a/mail/mail-tools.h b/mail/mail-tools.h
index 096ec7f..f943d96 100644
--- a/mail/mail-tools.h
+++ b/mail/mail-tools.h
@@ -39,6 +39,4 @@ gchar *mail_tool_generate_forward_subject (CamelMimeMessage *msg);
 /* Make a message into an attachment */
 CamelMimePart *mail_tool_make_message_attachment (CamelMimeMessage *message);
 
-gchar *mail_tools_folder_to_url (CamelFolder *folder);
-
 #endif
diff --git a/mail/message-list.c b/mail/message-list.c
index 5a9af96..6200e89 100644
--- a/mail/message-list.c
+++ b/mail/message-list.c
@@ -1646,7 +1646,8 @@ ml_tree_value_at_ex (ETreeModel *etm,
 		CamelURL *curl;
 		EAccount *account;
 		gchar *location = NULL;
-		gchar *euri, *url;
+		const gchar *uri;
+		gchar *euri;
 
 		if (CAMEL_IS_VEE_FOLDER (message_list->folder)) {
 			folder = camel_vee_folder_get_location ((CamelVeeFolder *)message_list->folder, (CamelVeeMessageInfo *)msg_info, NULL);
@@ -1654,24 +1655,23 @@ ml_tree_value_at_ex (ETreeModel *etm,
 			folder = message_list->folder;
 		}
 
-		url = mail_tools_folder_to_url (folder);
-		euri = em_uri_from_camel (url);
+		uri = camel_folder_get_uri (folder);
+		euri = em_uri_from_camel (uri);
 
-		account = mail_config_get_account_by_source_url (url);
+		account = mail_config_get_account_by_source_url (uri);
 
 		if (account) {
-			curl = camel_url_new (url, NULL);
+			curl = camel_url_new (uri, NULL);
 			location = g_strconcat (account->name, ":", curl->path, NULL);
 		} else {
 			/* Local account */
-			euri = em_uri_from_camel (url);
+			euri = em_uri_from_camel (uri);
 			curl = camel_url_new (euri, NULL);
 			if (curl->host && !strcmp(curl->host, "local") && curl->user && !strcmp(curl->user, "local"))
 				location = g_strconcat (_("On This Computer"), ":",curl->path, NULL);
 		}
 
 		camel_url_free (curl);
-		g_free (url);
 		g_free (euri);
 
 		return location;
diff --git a/modules/mail/e-mail-shell-view.c b/modules/mail/e-mail-shell-view.c
index 4696a39..cdfdd59 100644
--- a/modules/mail/e-mail-shell-view.c
+++ b/modules/mail/e-mail-shell-view.c
@@ -603,13 +603,11 @@ all_accounts:
 		CAMEL_FOLDER (search_folder), list,
 		priv->search_account_cancel);
 
-	uri = mail_tools_folder_to_url (CAMEL_FOLDER (search_folder));
+	folder_uri = camel_folder_get_uri (CAMEL_FOLDER (search_folder));
 
 	mail_shell_view_show_search_results_folder (
 		E_MAIL_SHELL_VIEW (shell_view),
-		CAMEL_FOLDER (search_folder), uri);
-
-	g_free (uri);
+		CAMEL_FOLDER (search_folder), folder_uri);
 
 	goto execute;
 
@@ -756,13 +754,11 @@ current_account:
 		CAMEL_FOLDER (search_folder), list,
 		priv->search_account_cancel);
 
-	uri = mail_tools_folder_to_url (CAMEL_FOLDER (search_folder));
+	folder_uri = camel_folder_get_uri (CAMEL_FOLDER (search_folder));
 
 	mail_shell_view_show_search_results_folder (
 		E_MAIL_SHELL_VIEW (shell_view),
-		CAMEL_FOLDER (search_folder), uri);
-
-	g_free (uri);
+		CAMEL_FOLDER (search_folder), folder_uri);
 
 execute:
 
diff --git a/plugins/itip-formatter/itip-formatter.c b/plugins/itip-formatter/itip-formatter.c
index 2c95876..2c52241 100644
--- a/plugins/itip-formatter/itip-formatter.c
+++ b/plugins/itip-formatter/itip-formatter.c
@@ -2236,14 +2236,14 @@ check_is_instance (icalcomponent *icalcomp)
 static gboolean
 in_proper_folder (CamelFolder *folder)
 {
+	const gchar *folder_uri;
 	gboolean res = TRUE;
 	gint flags = 0;
-	gchar *uri;
 
 	if (!folder)
 		return FALSE;
 
-	uri = mail_tools_folder_to_url (folder);
+	folder_uri = camel_folder_get_uri (folder);
 
 	if (mail_folder_cache_get_folder_info_flags (mail_folder_cache_get_default (),
 						     folder, &flags)) {
@@ -2255,21 +2255,19 @@ in_proper_folder (CamelFolder *folder)
 			  /* or any other virtual folder */
 			  CAMEL_IS_VEE_FOLDER (folder) ||
 			  /* or anything else except of sent, outbox or drafts folder */
-			  (!em_utils_folder_is_sent (folder, uri) &&
-			   !em_utils_folder_is_outbox (folder, uri) &&
-			   !em_utils_folder_is_drafts (folder, uri))
+			  (!em_utils_folder_is_sent (folder, folder_uri) &&
+			   !em_utils_folder_is_outbox (folder, folder_uri) &&
+			   !em_utils_folder_is_drafts (folder, folder_uri))
 			));
 	} else {
 		/* cannot check for Inbox folder here */
 		res = (folder->folder_flags & (CAMEL_FOLDER_IS_TRASH | CAMEL_FOLDER_IS_JUNK)) == 0 && (
 		      (CAMEL_IS_VEE_FOLDER (folder)) || (
-		      !em_utils_folder_is_sent (folder, uri) &&
-		      !em_utils_folder_is_outbox (folder, uri) &&
-		      !em_utils_folder_is_drafts (folder, uri)));
+		      !em_utils_folder_is_sent (folder, folder_uri) &&
+		      !em_utils_folder_is_outbox (folder, folder_uri) &&
+		      !em_utils_folder_is_drafts (folder, folder_uri)));
 	}
 
-	g_free (uri);
-
 	return res;
 }
 



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