[evolution-data-server] Add camel_imapx_folder_path_to_mailbox().



commit 468fbfeb72008b54c457e531be3ecb9d1f7ff03f
Author: Matthew Barnes <mbarnes redhat com>
Date:   Wed Sep 11 10:00:36 2013 -0400

    Add camel_imapx_folder_path_to_mailbox().
    
    Converts a folder path to an IMAP mailbox name, which just replaces all
    slashes with the mailbox separator character.  If the mailbox separator
    character appears in the folder path, it is replaced with a slash.

 camel/camel-imapx-utils.c |   29 +++++++++++++++++++++++++++++
 camel/camel-imapx-utils.h |    3 +++
 2 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/camel/camel-imapx-utils.c b/camel/camel-imapx-utils.c
index be0167e..ae30ca4 100644
--- a/camel/camel-imapx-utils.c
+++ b/camel/camel-imapx-utils.c
@@ -2659,6 +2659,35 @@ camel_imapx_mailbox_to_folder_path (const gchar *mailbox_name,
        return folder_path;
 }
 
+/**
+ * camel_imapx_folder_path_to_mailbox:
+ * @folder_path: a Camel folder path
+ * @separator: mailbox separator character
+ *
+ * Converts @folder_path to an IMAP mailbox name, which just replaces
+ * all slash ('/') characters with @separator.  If @separator appears
+ * in @folder_path, it is replaced with '/'.  Free the returned string
+ * with g_free().
+ *
+ * Returns: a newly-allocated IMAP mailbox name
+ *
+ * Since: 3.10
+ **/
+gchar *
+camel_imapx_folder_path_to_mailbox (const gchar *folder_path,
+                                    gchar separator)
+{
+       g_return_val_if_fail (folder_path != NULL, NULL);
+
+       /* XXX For now, all we're really doing in these conversions is
+        *     flip-flopping separator characters.  So we can just call
+        *     camel_imapx_mailbox_to_folder_path() on a folder path to
+        *     get the mailbox name.  But it is better to have separate
+        *     functions: 1) for readability, and 2) so we don't become
+        *     too dependent on this flip-flopping behavior. */
+       return camel_imapx_mailbox_to_folder_path (folder_path, separator);
+}
+
 gboolean
 camel_imapx_parse_quota (CamelIMAPXStream *is,
                          GCancellable *cancellable,
diff --git a/camel/camel-imapx-utils.h b/camel/camel-imapx-utils.h
index 9777898..a57de22 100644
--- a/camel/camel-imapx-utils.h
+++ b/camel/camel-imapx-utils.h
@@ -328,6 +328,9 @@ gboolean    camel_imapx_mailbox_is_inbox    (const gchar *mailbox_name);
 gchar *                camel_imapx_mailbox_to_folder_path
                                                (const gchar *mailbox_name,
                                                 gchar separator);
+gchar *                camel_imapx_folder_path_to_mailbox
+                                               (const gchar *folder_path,
+                                                gchar separator);
 
 /* ********************************************************************** */
 


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