[evolution] Simplify vfolder_adduri_desc().



commit b700aaf9aa14a2634f926f2385b1bc8d663bfd31
Author: Matthew Barnes <mbarnes redhat com>
Date:   Thu May 5 16:48:37 2011 -0400

    Simplify vfolder_adduri_desc().

 mail/mail-vfolder.c |   69 +++++++++++++++++++++++----------------------------
 1 files changed, 31 insertions(+), 38 deletions(-)
---
diff --git a/mail/mail-vfolder.c b/mail/mail-vfolder.c
index 6958e82..9295f8b 100644
--- a/mail/mail-vfolder.c
+++ b/mail/mail-vfolder.c
@@ -203,46 +203,39 @@ struct _adduri_msg {
 static gchar *
 vfolder_adduri_desc (struct _adduri_msg *m)
 {
-	gchar *euri, *desc = NULL;
-
-	/* Yuck yuck.  Lookup the account name and use that to describe the path */
-	/* We really need to normalise this across all of camel and evolution :-/ */
-	euri = em_uri_from_camel (m->uri);
-	if (euri) {
-		CamelURL *url = camel_url_new (euri, NULL);
-
-		if (url) {
-			const gchar *loc = NULL;
-
-			if (url->host && !strcmp(url->host, "local")
-			    && url->user && !strcmp(url->user, "local")) {
-				loc = _("On This Computer");
-			} else {
-				gchar *uid;
-				const EAccount *account;
-
-				if (url->user == NULL)
-					uid = g_strdup (url->host);
-				else
-					uid = g_strdup_printf("%s %s", url->user, url->host);
-
-				account = e_get_account_by_uid (uid);
-				g_free (uid);
-				if (account != NULL)
-					loc = account->name;
-			}
+	EAccount *account;
+	CamelStore *store;
+	CamelSession *session;
+	const gchar *store_name;
+	const gchar *uid;
+	gchar *folder_name;
+	gchar *description;
+	gboolean success;
 
-			if (loc && url->path)
-				desc = g_strdup_printf(_("Updating Search Folders for '%s:%s'"), loc, url->path);
-			camel_url_free (url);
-		}
-		g_free (euri);
-	}
+	session = CAMEL_SESSION (m->session);
+
+	success = e_mail_folder_uri_parse (
+		session, m->uri, &store, &folder_name, NULL);
+
+	if (!success)
+		return NULL;
+
+	uid = camel_service_get_uid (CAMEL_SERVICE (store));
+	account = e_get_account_by_uid (uid);
+
+	if (account != NULL)
+		store_name = account->name;
+	else
+		store_name = _("On This Computer");
+
+	description = g_strdup_printf (
+		_("Updating Search Folders for '%s' : %s"),
+		store_name, folder_name);
 
-	if (desc == NULL)
-		desc = g_strdup_printf(_("Updating Search Folders for '%s'"), m->uri);
+	g_object_unref (store);
+	g_free (folder_name);
 
-	return desc;
+	return description;
 }
 
 static void



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