Camel Hula provider - initial commits.
authorHarish Krishnaswamy <kharish@novell.com>
Mon, 14 Nov 2005 17:39:32 +0000 (17:39 +0000)
committerHarish Krishnaswamy <kharish@src.gnome.org>
Mon, 14 Nov 2005 17:39:32 +0000 (17:39 +0000)
2005-11-14  Harish Krishnaswamy  <kharish@novell.com>

* Makefile.am, camel-hula-provider.c, libcamelhula.urls :
Camel Hula provider - initial commits.

camel/providers/hula/ChangeLog [new file with mode: 0644]
camel/providers/hula/Makefile.am [new file with mode: 0644]
camel/providers/hula/camel-hula-provider.c [new file with mode: 0644]
camel/providers/hula/libcamelhula.urls [new file with mode: 0644]

diff --git a/camel/providers/hula/ChangeLog b/camel/providers/hula/ChangeLog
new file mode 100644 (file)
index 0000000..0d0d9a7
--- /dev/null
@@ -0,0 +1,5 @@
+2005-11-14  Harish Krishnaswamy  <kharish@novell.com>
+
+       * Makefile.am, camel-hula-provider.c, libcamelhula.urls :
+       Camel Hula provider - initial commits.
diff --git a/camel/providers/hula/Makefile.am b/camel/providers/hula/Makefile.am
new file mode 100644 (file)
index 0000000..a8270b3
--- /dev/null
@@ -0,0 +1,28 @@
+## Process this file with automake to produce Makefile.in\r
+\r
+camel_provider_LTLIBRARIES = libcamelhula.la\r
+camel_provider_DATA = libcamelhula.urls\r
+\r
+INCLUDES = -I.. \\r
+       -I$(top_srcdir)                         \\r
+       -I$(top_srcdir)/camel                   \\r
+       -I$(top_srcdir)/camel/providers/imap    \\r
+        -I$(top_srcdir)/libedataserver          \\r
+       $(CAMEL_CFLAGS)                         \\r
+       $(GNOME_INCLUDEDIR)                     \\r
+       -DCAMEL_EXPLICIT_TRANSLATION_DOMAIN=\"$(GETTEXT_PACKAGE)\"      \\r
+       -DG_LOG_DOMAIN=\"camel-hula-provider\"\r
+\r
+libcamelhula_la_SOURCES =                      \\r
+       camel-hula-provider.c           \r
+                       \r
+\r
+\r
+libcamelhula_la_LDFLAGS = -avoid-version -module $(NO_UNDEFINED)\r
+libcamelhula_la_LIBADD =                                            \\r
+       $(top_builddir)/libedataserver/libedataserver-1.2.la             \\r
+       $(top_builddir)/camel/libcamel-provider-1.2.la                   \\r
+       $(top_builddir)/camel/libcamel-1.2.la                            \\r
+       $(CAMEL_LIBS)\r
+\r
+EXTRA_DIST = libcamelhula.urls\r
diff --git a/camel/providers/hula/camel-hula-provider.c b/camel/providers/hula/camel-hula-provider.c
new file mode 100644 (file)
index 0000000..749ad3b
--- /dev/null
@@ -0,0 +1,181 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/* camel-groupwise-provider.c: GroupWise provider registration code */
+
+/*
+ *  Author: Harish Krishnaswamy (kharish@novell.com)
+ *
+ *  Copyright 2005 Novell, Inc. (www.novell.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
+ * License as published by the Free Software Foundation.
+ *
+ * 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string.h>
+#include <gmodule.h>
+#include "camel-provider.h"
+#include "camel-session.h"
+#include "camel-url.h"
+#include "camel-sasl.h"
+#include "camel-i18n.h"
+
+static void add_hash (guint *hash, char *s);
+static guint hula_url_hash (gconstpointer key);
+static gint check_equal (char *s1, char *s2);
+static gint hula_url_equal (gconstpointer a, gconstpointer b);
+
+
+CamelProviderConfEntry hula_conf_entries[] = {
+       /* override the labels/defaults of the standard settings */
+       { CAMEL_PROVIDER_CONF_SECTION_START, "mailcheck", NULL,
+         N_("Checking for New Mail") },
+       { CAMEL_PROVIDER_CONF_CHECKBOX, "check_all", NULL,
+         N_("C_heck for new messages in all folders"), "1" },
+       { CAMEL_PROVIDER_CONF_SECTION_END },
+       { CAMEL_PROVIDER_CONF_SECTION_START, "cmdsection", NULL,
+         N_("Connection to Server") },
+       { CAMEL_PROVIDER_CONF_CHECKBOX, "use_command", NULL,
+         N_("_Use custom command to connect to server"), "0" },
+       { CAMEL_PROVIDER_CONF_ENTRY, "command", "use_command",
+         N_("Command:"), "ssh -C -l %u %h exec /usr/sbin/imapd" },
+       { CAMEL_PROVIDER_CONF_SECTION_END },
+       { CAMEL_PROVIDER_CONF_SECTION_START, "folders", NULL,
+         N_("Folders") },
+       { CAMEL_PROVIDER_CONF_CHECKBOX, "use_lsub", NULL,
+         N_("_Show only subscribed folders"), "1" },
+       { CAMEL_PROVIDER_CONF_CHECKBOX, "override_namespace", NULL,
+         N_("O_verride server-supplied folder namespace"), "0" },
+       { CAMEL_PROVIDER_CONF_ENTRY, "namespace", "override_namespace",
+         N_("Namespace") },
+       { CAMEL_PROVIDER_CONF_SECTION_END },
+       
+       { CAMEL_PROVIDER_CONF_END }
+       /* revisit each options in other providers (incl. authdomain) for
+        * relevancy - harish*/
+};
+
+
+static CamelProvider hula_provider = {
+       "hula",
+       N_("Hula"),
+
+       N_("For accessing Hula servers"),
+
+       "mail",
+
+       CAMEL_PROVIDER_IS_REMOTE | CAMEL_PROVIDER_IS_SOURCE |
+       CAMEL_PROVIDER_IS_STORAGE | CAMEL_PROVIDER_SUPPORTS_SSL | CAMEL_PROVIDER_DISABLE_SENT_FOLDER,
+
+       CAMEL_URL_NEED_USER | CAMEL_URL_NEED_HOST | CAMEL_URL_ALLOW_AUTH,
+
+       hula_conf_entries,
+
+       /* ... */
+};
+
+CamelServiceAuthType camel_hula_password_authtype = {
+       N_("Password"),
+       
+       N_("This option will connect to the Hula server using a "
+          "plaintext password."),
+       
+       "",
+       TRUE
+};
+
+static int
+hula_auto_detect_cb (CamelURL *url, GHashTable **auto_detected,
+                        CamelException *ex)
+{
+       *auto_detected = g_hash_table_new (g_str_hash, g_str_equal);
+
+       g_hash_table_insert (*auto_detected, g_strdup ("caldav_host"),
+                            g_strdup (url->host));
+
+       return 0;
+}
+
+void
+camel_provider_module_init(void)
+{
+       CamelProvider *imap_provider = NULL;
+       CamelException ex = CAMEL_EXCEPTION_INITIALISER;
+
+       imap_provider =  camel_provider_get("imap://", &ex);
+
+       hula_provider.url_hash = hula_url_hash;
+       hula_provider.url_equal = hula_url_equal;
+       hula_provider.auto_detect = hula_auto_detect_cb;
+       hula_provider.authtypes = g_list_prepend (hula_provider.authtypes, &camel_hula_password_authtype);
+       hula_provider.translation_domain = GETTEXT_PACKAGE;
+       
+       hula_provider.object_types[CAMEL_PROVIDER_STORE] = imap_provider->object_types [CAMEL_PROVIDER_STORE];
+        
+       
+       camel_provider_register (&hula_provider);
+}
+
+
+static void
+add_hash (guint *hash, char *s)
+{
+       if (s)
+               *hash ^= g_str_hash(s);
+}
+
+static guint
+hula_url_hash (gconstpointer key)
+{
+       const CamelURL *u = (CamelURL *)key;
+       guint hash = 0;
+
+       add_hash (&hash, u->user);
+       add_hash (&hash, u->authmech);
+       add_hash (&hash, u->host);
+       hash ^= u->port;
+       
+       return hash;
+}
+
+static gint
+check_equal (char *s1, char *s2)
+{
+       if (s1 == NULL) {
+               if (s2 == NULL)
+                       return TRUE;
+               else
+                       return FALSE;
+       }
+       
+       if (s2 == NULL)
+               return FALSE;
+
+       return strcmp (s1, s2) == 0;
+}
+
+static gint
+hula_url_equal (gconstpointer a, gconstpointer b)
+{
+       const CamelURL *u1 = a, *u2 = b;
+       
+       return check_equal (u1->protocol, u2->protocol)
+               && check_equal (u1->user, u2->user)
+               && check_equal (u1->authmech, u2->authmech)
+               && check_equal (u1->host, u2->host)
+               && u1->port == u2->port;
+}
diff --git a/camel/providers/hula/libcamelhula.urls b/camel/providers/hula/libcamelhula.urls
new file mode 100644 (file)
index 0000000..5553f61
--- /dev/null
@@ -0,0 +1 @@
+hula