[evolution-data-server] Add CamelIMAPXNamespace.



commit bd73ad0cbafb1706b0f1e2f60c44594059953be8
Author: Matthew Barnes <mbarnes redhat com>
Date:   Mon Aug 19 08:04:48 2013 -0400

    Add CamelIMAPXNamespace.
    
    Encapsulates an IMAP namespace, which consists of a namespace category
    (personal/other users/shared), a mailbox prefix string, and a mailbox
    separator character.

 camel/Makefile.am                       |    2 +
 camel/camel-imapx-namespace.c           |  196 +++++++++++++++++++++++++++++++
 camel/camel-imapx-namespace.h           |  109 +++++++++++++++++
 camel/camel.h                           |    1 +
 docs/reference/camel/camel-docs.sgml    |    1 +
 docs/reference/camel/camel-sections.txt |   23 ++++
 docs/reference/camel/camel.types        |    1 +
 7 files changed, 333 insertions(+), 0 deletions(-)
---
diff --git a/camel/Makefile.am b/camel/Makefile.am
index 88f5383..c759499 100644
--- a/camel/Makefile.am
+++ b/camel/Makefile.am
@@ -175,6 +175,7 @@ libcamel_1_2_la_SOURCES =                   \
        camel-imapx-folder.c                    \
        camel-imapx-job.c                       \
        camel-imapx-list-response.c             \
+       camel-imapx-namespace.c                 \
        camel-imapx-search.c                    \
        camel-imapx-server.c                    \
        camel-imapx-settings.c                  \
@@ -307,6 +308,7 @@ libcamelinclude_HEADERS =                   \
        camel-imapx-folder.h                    \
        camel-imapx-job.h                       \
        camel-imapx-list-response.h             \
+       camel-imapx-namespace.h                 \
        camel-imapx-search.h                    \
        camel-imapx-server.h                    \
        camel-imapx-settings.h                  \
diff --git a/camel/camel-imapx-namespace.c b/camel/camel-imapx-namespace.c
new file mode 100644
index 0000000..c86165b
--- /dev/null
+++ b/camel/camel-imapx-namespace.c
@@ -0,0 +1,196 @@
+/*
+ * camel-imapx-namespace.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+/**
+ * SECTION: camel-imapx-namespace
+ * @include: camel/camel.h
+ * @short_description: Stores an IMAP namespace
+ *
+ * #CamelIMAPXNamespace encapsulates an IMAP namespace, which consists of a
+ * namespace category (personal/other users/shared), a mailbox prefix string,
+ * and a mailbox separator character.
+ **/
+
+#include "camel-imapx-namespace.h"
+
+#define CAMEL_IMAPX_NAMESPACE_GET_PRIVATE(obj) \
+       (G_TYPE_INSTANCE_GET_PRIVATE \
+       ((obj), CAMEL_TYPE_IMAPX_NAMESPACE, CamelIMAPXNamespacePrivate))
+
+struct _CamelIMAPXNamespacePrivate {
+       CamelIMAPXNamespaceCategory category;
+       gchar *prefix;
+       gchar separator;
+};
+
+G_DEFINE_TYPE (
+       CamelIMAPXNamespace,
+       camel_imapx_namespace,
+       G_TYPE_OBJECT)
+
+static void
+imapx_namespace_finalize (GObject *object)
+{
+       CamelIMAPXNamespacePrivate *priv;
+
+       priv = CAMEL_IMAPX_NAMESPACE_GET_PRIVATE (object);
+
+       g_free (priv->prefix);
+
+       /* Chain up to parent's finalize() method. */
+       G_OBJECT_CLASS (camel_imapx_namespace_parent_class)->finalize (object);
+}
+
+static void
+camel_imapx_namespace_class_init (CamelIMAPXNamespaceClass *class)
+{
+       GObjectClass *object_class;
+
+       g_type_class_add_private (class, sizeof (CamelIMAPXNamespacePrivate));
+
+       object_class = G_OBJECT_CLASS (class);
+       object_class->finalize = imapx_namespace_finalize;
+}
+
+static void
+camel_imapx_namespace_init (CamelIMAPXNamespace *namespace)
+{
+       namespace->priv = CAMEL_IMAPX_NAMESPACE_GET_PRIVATE (namespace);
+}
+
+/**
+ * camel_imapx_namespace_new:
+ * @category: a #CamelIMAPXNamespaceCategory
+ * @prefix: a mailbox prefix string
+ * @separator: a mailbox path separator character
+ *
+ * Creates a new #CamelIMAPXNamespace from @category, @prefix and @separator.
+ *
+ * Returns: a new #CamelIMAPXNamespace
+ *
+ * Since: 3.12
+ **/
+CamelIMAPXNamespace *
+camel_imapx_namespace_new (CamelIMAPXNamespaceCategory category,
+                           const gchar *prefix,
+                           gchar separator)
+{
+       CamelIMAPXNamespace *namespace;
+
+       g_return_val_if_fail (prefix != NULL, NULL);
+       g_return_val_if_fail (separator != '\0', NULL);
+
+       /* Not bothering with GObject properties for this class. */
+
+       namespace = g_object_new (CAMEL_TYPE_IMAPX_NAMESPACE, NULL);
+       namespace->priv->category = category;
+       namespace->priv->prefix = g_strdup (prefix);
+       namespace->priv->separator = separator;
+
+       return namespace;
+}
+
+/**
+ * camel_imapx_namespace_equal:
+ * @namespace_a: a #CamelIMAPXNamespace
+ * @namespace_b: another #CamelIMAPXNamespace
+ *
+ * Returns whether @namespace_a and @namespace_b are equivalent, meaning
+ * they share the same category, prefix string, and path separator character.
+ *
+ * Returns: %TRUE if @namespace_a and @namespace_b are equal
+ *
+ * Since: 3.12
+ **/
+gboolean
+camel_imapx_namespace_equal (CamelIMAPXNamespace *namespace_a,
+                             CamelIMAPXNamespace *namespace_b)
+{
+       g_return_val_if_fail (CAMEL_IS_IMAPX_NAMESPACE (namespace_a), FALSE);
+       g_return_val_if_fail (CAMEL_IS_IMAPX_NAMESPACE (namespace_b), FALSE);
+
+       if (namespace_a == namespace_b)
+               return TRUE;
+
+       if (namespace_a->priv->category != namespace_b->priv->category)
+               return FALSE;
+
+       if (namespace_a->priv->separator != namespace_b->priv->separator)
+               return FALSE;
+
+       return g_str_equal (
+               namespace_a->priv->prefix,
+               namespace_b->priv->prefix);
+}
+
+/**
+ * camel_imapx_namespace_get_category:
+ * @namespace_: a #CamelIMAPXNamespace
+ *
+ * Returns the #CamelIMAPXNamespaceCategory for @namespace.
+ *
+ * Returns: a #CamelIMAPXNamespaceCategory
+ *
+ * Since: 3.12
+ **/
+CamelIMAPXNamespaceCategory
+camel_imapx_namespace_get_category (CamelIMAPXNamespace *namespace)
+{
+       g_return_val_if_fail (
+               CAMEL_IS_IMAPX_NAMESPACE (namespace),
+               CAMEL_IMAPX_NAMESPACE_PERSONAL);
+
+       return namespace->priv->category;
+}
+
+/**
+ * camel_imapx_namespace_get_prefix:
+ * @namespace_: a #CamelIMAPXNamespace
+ *
+ * Returns the mailbox prefix string for @namespace.
+ *
+ * Returns: a mailbox prefix string
+ *
+ * Since: 3.12
+ **/
+const gchar *
+camel_imapx_namespace_get_prefix (CamelIMAPXNamespace *namespace)
+{
+       g_return_val_if_fail (CAMEL_IS_IMAPX_NAMESPACE (namespace), NULL);
+
+       return namespace->priv->prefix;
+}
+
+/**
+ * camel_imapx_namespace_get_separator:
+ * @namespace_: a #CamelIMAPXNamespace
+ *
+ * Returns the mailbox path separator charactor for @namespace.
+ *
+ * Returns: the mailbox path separator character
+ *
+ * Since: 3.12
+ **/
+gchar
+camel_imapx_namespace_get_separator (CamelIMAPXNamespace *namespace)
+{
+       g_return_val_if_fail (CAMEL_IS_IMAPX_NAMESPACE (namespace), '\0');
+
+       return namespace->priv->separator;
+}
+
diff --git a/camel/camel-imapx-namespace.h b/camel/camel-imapx-namespace.h
new file mode 100644
index 0000000..ca15dca
--- /dev/null
+++ b/camel/camel-imapx-namespace.h
@@ -0,0 +1,109 @@
+/*
+ * camel-imapx-namespace.h
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the program; if not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+#if !defined (__CAMEL_H_INSIDE__) && !defined (CAMEL_COMPILATION)
+#error "Only <camel/camel.h> can be included directly."
+#endif
+
+#ifndef CAMEL_IMAPX_NAMESPACE_H
+#define CAMEL_IMAPX_NAMESPACE_H
+
+#include <glib-object.h>
+
+/* Standard GObject macros */
+#define CAMEL_TYPE_IMAPX_NAMESPACE \
+       (camel_imapx_namespace_get_type ())
+#define CAMEL_IMAPX_NAMESPACE(obj) \
+       (G_TYPE_CHECK_INSTANCE_CAST \
+       ((obj), CAMEL_TYPE_IMAPX_NAMESPACE, CamelIMAPXNamespace))
+#define CAMEL_IMAPX_NAMESPACE_CLASS(cls) \
+       (G_TYPE_CHECK_CLASS_CAST \
+       ((cls), CAMEL_TYPE_IMAPX_NAMESPACE, CamelIMAPXNamespaceClass))
+#define CAMEL_IS_IMAPX_NAMESPACE(obj) \
+       (G_TYPE_CHECK_INSTANCE_TYPE \
+       ((obj), CAMEL_TYPE_IMAPX_NAMESPACE))
+#define CAMEL_IS_IMAPX_NAMESPACE_CLASS(cls) \
+       (G_TYPE_CHECK_CLASS_TYPE \
+       ((cls), CAMEL_TYPE_IMAPX_NAMESPACE))
+#define CAMEL_IMAPX_NAMESPACE_GET_CLASS(obj) \
+       (G_TYPE_INSTANCE_GET_CLASS \
+       ((obj), CAMEL_TYPE_IMAPX_NAMESPACE, CamelIMAPXNamespaceClass))
+
+G_BEGIN_DECLS
+
+/**
+ * CamelIMAPXNamespaceCategory:
+ * @CAMEL_IMAPX_NAMESPACE_PERSONAL:
+ *   Mailboxes belonging to the authenticated user.
+ * @CAMEL_IMAPX_NAMESPACE_OTHER_USERS:
+ *   Personal mailboxes belonging to other users.
+ * @CAMEL_IMAPX_NAMESPACE_SHARED:
+ *   Mailboxes intended to be shared amongst users.
+ *
+ * Refer to <ulink url="http://tools.ietf.org/html/rfc2342";>RFC 2342</ulink>
+ * for more detailed namespace class descriptions.
+ **/
+typedef enum {
+       CAMEL_IMAPX_NAMESPACE_PERSONAL,
+       CAMEL_IMAPX_NAMESPACE_OTHER_USERS,
+       CAMEL_IMAPX_NAMESPACE_SHARED
+} CamelIMAPXNamespaceCategory;
+
+typedef struct _CamelIMAPXNamespace CamelIMAPXNamespace;
+typedef struct _CamelIMAPXNamespaceClass CamelIMAPXNamespaceClass;
+typedef struct _CamelIMAPXNamespacePrivate CamelIMAPXNamespacePrivate;
+
+/**
+ * CamelIMAPXNamespace:
+ *
+ * Contains only private data that should be read and manipulated using the
+ * functions below.
+ *
+ * Since: 3.12
+ **/
+struct _CamelIMAPXNamespace {
+       GObject parent;
+       CamelIMAPXNamespacePrivate *priv;
+};
+
+struct _CamelIMAPXNamespaceClass {
+       GObjectClass parent_class;
+};
+
+GType          camel_imapx_namespace_get_type
+                                       (void) G_GNUC_CONST;
+CamelIMAPXNamespace *
+               camel_imapx_namespace_new
+                                       (CamelIMAPXNamespaceCategory category,
+                                        const gchar *prefix,
+                                        gchar separator);
+gboolean       camel_imapx_namespace_equal
+                                       (CamelIMAPXNamespace *namespace_a,
+                                        CamelIMAPXNamespace *namespace_b);
+CamelIMAPXNamespaceCategory
+               camel_imapx_namespace_get_category
+                                       (CamelIMAPXNamespace *namespace_);
+const gchar *  camel_imapx_namespace_get_prefix
+                                       (CamelIMAPXNamespace *namespace_);
+gchar          camel_imapx_namespace_get_separator
+                                       (CamelIMAPXNamespace *namespace_);
+
+G_END_DECLS
+
+#endif /* CAMEL_IMAPX_NAMESPACE_H */
+
diff --git a/camel/camel.h b/camel/camel.h
index b698fae..9dbf660 100644
--- a/camel/camel.h
+++ b/camel/camel.h
@@ -142,6 +142,7 @@
 #include <camel/camel-imapx-job.h>
 #include <camel/camel-imapx-folder.h>
 #include <camel/camel-imapx-list-response.h>
+#include <camel/camel-imapx-namespace.h>
 #include <camel/camel-imapx-search.h>
 #include <camel/camel-imapx-server.h>
 #include <camel/camel-imapx-status-response.h>
diff --git a/docs/reference/camel/camel-docs.sgml b/docs/reference/camel/camel-docs.sgml
index 314716b..9215379 100644
--- a/docs/reference/camel/camel-docs.sgml
+++ b/docs/reference/camel/camel-docs.sgml
@@ -200,6 +200,7 @@
       <xi:include href="xml/camel-imapx-command.xml"/>
       <xi:include href="xml/camel-imapx-folder.xml"/>
       <xi:include href="xml/camel-imapx-job.xml"/>
+      <xi:include href="xml/camel-imapx-namespace.xml"/>
       <xi:include href="xml/camel-imapx-search.xml"/>
       <xi:include href="xml/camel-imapx-server.xml"/>
       <xi:include href="xml/camel-imapx-settings.xml"/>
diff --git a/docs/reference/camel/camel-sections.txt b/docs/reference/camel/camel-sections.txt
index 073c543..3dc11e3 100644
--- a/docs/reference/camel/camel-sections.txt
+++ b/docs/reference/camel/camel-sections.txt
@@ -865,6 +865,29 @@ CamelIMAPXListResponsePrivate
 </SECTION>
 
 <SECTION>
+<FILE>camel-imapx-namespace</FILE>
+<TITLE>CamelIMAPXNamespace</TITLE>
+CamelIMAPXNamespace
+CamelIMAPXNamespaceCategory
+camel_imapx_namespace_new
+camel_imapx_namespace_equal
+camel_imapx_namespace_get_category
+camel_imapx_namespace_get_prefix
+camel_imapx_namespace_get_separator
+<SUBSECTION Standard>
+CAMEL_IMAPX_NAMESPACE
+CAMEL_IS_IMAPX_NAMESPACE
+CAMEL_TYPE_IMAPX_NAMESPACE
+CAMEL_IMAPX_NAMESPACE_CLASS
+CAMEL_IS_IMAPX_NAMESPACE_CLASS
+CAMEL_IMAPX_NAMESPACE_GET_CLASS
+CamelIMAPXNamespaceClass
+camel_imapx_namespace_get_type
+<SUBSECTION Private>
+CamelIMAPXNamespacePrivate
+</SECTION>
+
+<SECTION>
 <FILE>camel-imapx-search</FILE>
 <TITLE>CamelIMAPXSearch</TITLE>
 CamelIMAPXSearch
diff --git a/docs/reference/camel/camel.types b/docs/reference/camel/camel.types
index c8f8144..eb3890f 100644
--- a/docs/reference/camel/camel.types
+++ b/docs/reference/camel/camel.types
@@ -20,6 +20,7 @@ camel_gpg_context_get_type
 camel_html_parser_get_type
 camel_imapx_folder_get_type
 camel_imapx_list_response_get_type
+camel_imapx_namespace_get_type
 camel_imapx_search_get_type
 camel_imapx_server_get_type
 camel_imapx_settings_get_type


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