1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /* camel-groupwise-provider.c: GroupWise provider registration code */
5 * Author: Harish Krishnaswamy (kharish@novell.com)
7 * Copyright 2005 Novell, Inc. (www.novell.com)
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of version 2 of the GNU Lesser General Public
11 * License as published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this program; if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
32 #include <glib/gi18n-lib.h>
35 #include "camel-provider.h"
36 #include "camel-sasl.h"
37 #include "camel-session.h"
38 #include "camel-url.h"
40 static void add_hash (guint *hash, char *s);
41 static guint hula_url_hash (gconstpointer key);
42 static gint check_equal (char *s1, char *s2);
43 static gint hula_url_equal (gconstpointer a, gconstpointer b);
46 static CamelProviderConfEntry hula_conf_entries[] = {
47 /* override the labels/defaults of the standard settings */
48 { CAMEL_PROVIDER_CONF_SECTION_START, "mailcheck", NULL,
49 N_("Checking for New Mail") },
50 { CAMEL_PROVIDER_CONF_CHECKBOX, "check_all", NULL,
51 N_("C_heck for new messages in all folders"), "1" },
52 { CAMEL_PROVIDER_CONF_SECTION_END },
53 { CAMEL_PROVIDER_CONF_SECTION_START, "cmdsection", NULL,
54 N_("Connection to Server") },
55 { CAMEL_PROVIDER_CONF_CHECKBOX, "use_command", NULL,
56 N_("_Use custom command to connect to server"), "0" },
57 { CAMEL_PROVIDER_CONF_ENTRY, "command", "use_command",
58 N_("Command:"), "ssh -C -l %u %h exec /usr/sbin/imapd" },
59 { CAMEL_PROVIDER_CONF_SECTION_END },
60 { CAMEL_PROVIDER_CONF_SECTION_START, "folders", NULL,
62 { CAMEL_PROVIDER_CONF_CHECKBOX, "use_lsub", NULL,
63 N_("_Show only subscribed folders"), "1" },
64 { CAMEL_PROVIDER_CONF_CHECKBOX, "override_namespace", NULL,
65 N_("O_verride server-supplied folder namespace"), "0" },
66 { CAMEL_PROVIDER_CONF_ENTRY, "namespace", "override_namespace",
68 { CAMEL_PROVIDER_CONF_SECTION_END },
70 { CAMEL_PROVIDER_CONF_END }
71 /* revisit each options in other providers (incl. authdomain) for
72 * relevancy - harish*/
76 static CamelProvider hula_provider = {
80 N_("For accessing Hula servers"),
84 CAMEL_PROVIDER_IS_REMOTE | CAMEL_PROVIDER_IS_SOURCE |
85 CAMEL_PROVIDER_IS_STORAGE | CAMEL_PROVIDER_SUPPORTS_SSL | CAMEL_PROVIDER_DISABLE_SENT_FOLDER,
87 CAMEL_URL_NEED_USER | CAMEL_URL_NEED_HOST | CAMEL_URL_ALLOW_AUTH,
94 static CamelServiceAuthType camel_hula_password_authtype = {
97 N_("This option will connect to the Hula server using a "
98 "plaintext password."),
105 hula_auto_detect_cb (CamelURL *url, GHashTable **auto_detected,
108 *auto_detected = g_hash_table_new (g_str_hash, g_str_equal);
110 g_hash_table_insert (*auto_detected, g_strdup ("caldav_host"),
111 g_strdup (url->host));
117 camel_provider_module_init(void)
119 CamelProvider *imap_provider = NULL;
120 CamelException ex = CAMEL_EXCEPTION_INITIALISER;
122 imap_provider = camel_provider_get("imap://", &ex);
124 hula_provider.url_hash = hula_url_hash;
125 hula_provider.url_equal = hula_url_equal;
126 hula_provider.auto_detect = hula_auto_detect_cb;
127 hula_provider.authtypes = g_list_prepend (hula_provider.authtypes, &camel_hula_password_authtype);
128 hula_provider.translation_domain = GETTEXT_PACKAGE;
130 hula_provider.object_types[CAMEL_PROVIDER_STORE] = imap_provider->object_types [CAMEL_PROVIDER_STORE];
133 camel_provider_register (&hula_provider);
138 add_hash (guint *hash, char *s)
141 *hash ^= g_str_hash(s);
145 hula_url_hash (gconstpointer key)
147 const CamelURL *u = (CamelURL *)key;
150 add_hash (&hash, u->user);
151 add_hash (&hash, u->authmech);
152 add_hash (&hash, u->host);
159 check_equal (char *s1, char *s2)
171 return strcmp (s1, s2) == 0;
175 hula_url_equal (gconstpointer a, gconstpointer b)
177 const CamelURL *u1 = a, *u2 = b;
179 return check_equal (u1->protocol, u2->protocol)
180 && check_equal (u1->user, u2->user)
181 && check_equal (u1->authmech, u2->authmech)
182 && check_equal (u1->host, u2->host)
183 && u1->port == u2->port;