[evolution-data-server] Add camel_imapx_normalize_mailbox().
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Add camel_imapx_normalize_mailbox().
- Date: Mon, 9 Sep 2013 16:04:09 +0000 (UTC)
commit c435d77c62c734384a05dd559d0976d70d2789ad
Author: Matthew Barnes <mbarnes redhat com>
Date: Mon Sep 9 11:44:49 2013 -0400
Add camel_imapx_normalize_mailbox().
Converts the special INBOX mailbox to all caps, if it appears at the
beginning of 'mailbox_name'. The 'mailbox_name' string is modified in
place. The 'separator' character helps reliably identify descendants
of INBOX.
camel/camel-imapx-utils.c | 41 +++++++++++++++++++++++++++++++++++++++++
camel/camel-imapx-utils.h | 2 ++
2 files changed, 43 insertions(+), 0 deletions(-)
---
diff --git a/camel/camel-imapx-utils.c b/camel/camel-imapx-utils.c
index f88147a..a443385 100644
--- a/camel/camel-imapx-utils.c
+++ b/camel/camel-imapx-utils.c
@@ -2555,6 +2555,47 @@ camel_imapx_parse_mailbox (CamelIMAPXStream *is,
}
/**
+ * camel_imapx_normalize_mailbox:
+ * @mailbox_name: a mailbox name
+ * @separator: a mailbox separator character
+ *
+ * Converts the special INBOX mailbox to all caps, if it appears at the
+ * beginning of @mailbox_name. The @mailbox_name string is modified in
+ * place. The @separator character helps reliably identify descendants
+ * of INBOX.
+ *
+ * Since: 3.10
+ **/
+void
+camel_imapx_normalize_mailbox (gchar *mailbox_name,
+ gchar separator)
+{
+ gboolean normalize_inbox;
+
+ g_return_if_fail (mailbox_name != NULL);
+
+ /* mailbox ::= "INBOX" / astring
+ * INBOX is case-insensitive. All case variants of
+ * INBOX (e.g., "iNbOx") MUST be interpreted as INBOX
+ * not as an astring. An astring which consists of
+ * the case-insensitive sequence "I" "N" "B" "O" "X"
+ * is considered to be INBOX and not an astring.
+ */
+
+ normalize_inbox =
+ (g_ascii_strncasecmp (mailbox_name, "INBOX", 5) == 0) &&
+ (mailbox_name[5] == separator || mailbox_name[5] == '\0');
+
+ if (normalize_inbox) {
+ mailbox_name[0] = 'I';
+ mailbox_name[1] = 'N';
+ mailbox_name[2] = 'B';
+ mailbox_name[3] = 'O';
+ mailbox_name[4] = 'X';
+ }
+}
+
+/**
* camel_imapx_mailbox_is_inbox:
* @mailbox_name: a mailbox name
*
diff --git a/camel/camel-imapx-utils.h b/camel/camel-imapx-utils.h
index 506686b..70c8ab2 100644
--- a/camel/camel-imapx-utils.h
+++ b/camel/camel-imapx-utils.h
@@ -321,6 +321,8 @@ gboolean camel_imapx_command_add_qresync_parameter
gchar * camel_imapx_parse_mailbox (struct _CamelIMAPXStream *is,
GCancellable *cancellable,
GError **error);
+void camel_imapx_normalize_mailbox (gchar *mailbox_name,
+ gchar separator);
gboolean camel_imapx_mailbox_is_inbox (const gchar *mailbox_name);
gchar * camel_imapx_mailbox_to_folder_path
(const gchar *mailbox_name,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]