aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-05-03 00:24:12 +0800
committerMatthew Barnes <mbarnes@redhat.com>2011-05-03 00:45:55 +0800
commitf52c1d20c671f438c05727cfcbf16f19c522d2f3 (patch)
treea8037b4c44b12948af90685125a2adbcd6390476 /e-util
parentfc0186d884b46c9fc1e4ce2df74155f974a61695 (diff)
downloadgsoc2013-evolution-f52c1d20c671f438c05727cfcbf16f19c522d2f3.tar
gsoc2013-evolution-f52c1d20c671f438c05727cfcbf16f19c522d2f3.tar.gz
gsoc2013-evolution-f52c1d20c671f438c05727cfcbf16f19c522d2f3.tar.bz2
gsoc2013-evolution-f52c1d20c671f438c05727cfcbf16f19c522d2f3.tar.lz
gsoc2013-evolution-f52c1d20c671f438c05727cfcbf16f19c522d2f3.tar.xz
gsoc2013-evolution-f52c1d20c671f438c05727cfcbf16f19c522d2f3.tar.zst
gsoc2013-evolution-f52c1d20c671f438c05727cfcbf16f19c522d2f3.zip
e_get_account_by_uid(): Also handle CamelTransport UIDs.
Enhance e_get_account_by_uid() to also accept CamelTransport UIDs. The convention we use to distinguish them is simple: Given an EAccount UID: - The CamelStore UID is the EAccount UID verbatim. - The CamelTransport UID is the EAccount UID + "-transport". So just check for a "-transport" suffix and truncate it.
Diffstat (limited to 'e-util')
-rw-r--r--e-util/e-account-utils.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/e-util/e-account-utils.c b/e-util/e-account-utils.c
index d6dfa7aea3..aedf4f1c29 100644
--- a/e-util/e-account-utils.c
+++ b/e-util/e-account-utils.c
@@ -22,6 +22,7 @@
#include "e-account-utils.h"
+#include <string.h>
#include <gconf/gconf-client.h>
static EAccountList *global_account_list;
@@ -136,10 +137,11 @@ e_get_account_by_name (const gchar *name)
* e_get_account_by_uid:
* @uid: a mail account UID
*
- * Returns the #EAccount with the given unique ID, or %NULL if no such
- * account exists.
+ * Returns the #EAccount corresponding to the given unique identity (UID),
+ * or %NULL if no such account exists. The @uid can refer to an #EAccount
+ * UID, a #CamelStore UID, or even a #CamelTransport UID.
*
- * Returns: an #EAccount having the given unique ID, or %NULL
+ * Returns: the corresponding #EAccount, or %NULL
**/
EAccount *
e_get_account_by_uid (const gchar *uid)
@@ -147,12 +149,27 @@ e_get_account_by_uid (const gchar *uid)
EAccountList *account_list;
const EAccount *account;
e_account_find_t find;
+ gchar *account_uid;
g_return_val_if_fail (uid != NULL, NULL);
+ /* EAccounts have the following invariant:
+ *
+ * CamelStore UID == EAccount UID
+ * CamelTransport UID == EAccount UID + "-transport"
+ *
+ * Therefore we can detect CamelTransport UIDs and convert them.
+ */
+ if (g_str_has_suffix (uid, "-transport"))
+ account_uid = g_strndup (uid, strlen (uid) - 10);
+ else
+ account_uid = g_strdup (uid);
+
find = E_ACCOUNT_FIND_UID;
account_list = e_get_account_list ();
- account = e_account_list_find (account_list, find, uid);
+ account = e_account_list_find (account_list, find, account_uid);
+
+ g_free (account_uid);
/* XXX EAccountList misuses const. */
return (EAccount *) account;