1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /* camel-groupwise-provider.c: GroupWise provider registration code */
5 * Authors: Jeffrey Stedfast <fejj@ximian.com>
6 * Sivaiah Nallagatla <snallagatla@novell.com>
7 * Rodrigo Moya <rodrigo@ximian.com>
9 * Copyright 2003 Novell, Inc. (www.novell.com)
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of version 2 of the GNU Lesser General Public
13 * License as published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this program; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 * Boston, MA 02110-1301, USA.
34 #include <glib/gi18n-lib.h>
37 #include "camel-provider.h"
38 #include "camel-sasl.h"
39 #include "camel-session.h"
40 #include "camel-url.h"
42 #include "camel-groupwise-store.h"
43 #include "camel-groupwise-transport.h"
45 static void add_hash (guint *hash, char *s);
46 static guint groupwise_url_hash (gconstpointer key);
47 static gint check_equal (char *s1, char *s2);
48 static gint groupwise_url_equal (gconstpointer a, gconstpointer b);
51 CamelProviderConfEntry groupwise_conf_entries[] = {
52 /* override the labels/defaults of the standard settings */
54 { CAMEL_PROVIDER_CONF_SECTION_START, "mailcheck", NULL,
55 N_("Checking for new mail") },
56 { CAMEL_PROVIDER_CONF_CHECKBOX, "check_all", NULL,
57 N_("C_heck for new messages in all folders"), "1" },
58 { CAMEL_PROVIDER_CONF_SECTION_END },
60 { CAMEL_PROVIDER_CONF_SECTION_START, "general", NULL, N_("Options") },
61 { CAMEL_PROVIDER_CONF_CHECKBOX, "filter", NULL,
62 N_("_Apply filters to new messages in Inbox on this server"), "0" },
63 { CAMEL_PROVIDER_CONF_CHECKBOX, "filter_junk", NULL,
64 N_("Check new messages for J_unk contents"), "0" },
65 { CAMEL_PROVIDER_CONF_CHECKBOX, "filter_junk_inbox", "filter_junk",
66 N_("Only check for Junk messages in the IN_BOX folder"), "0" },
67 { CAMEL_PROVIDER_CONF_CHECKBOX, "sync_offline", NULL,
68 N_("Automatically synchroni_ze account locally"), "0" },
69 { CAMEL_PROVIDER_CONF_SECTION_END },
71 /* extra GroupWise configuration settings */
72 {CAMEL_PROVIDER_CONF_SECTION_START, "soapport", NULL,
73 N_("SOAP Settings") },
75 { CAMEL_PROVIDER_CONF_ENTRY, "soap_port", NULL,
76 N_("Post Office Agent SOAP Port:"), "7191" },
78 { CAMEL_PROVIDER_CONF_HIDDEN, "auth-domain", NULL,
81 { CAMEL_PROVIDER_CONF_SECTION_END },
83 { CAMEL_PROVIDER_CONF_END }
87 static CamelProvider groupwise_provider = {
89 N_("Novell GroupWise"),
91 N_("For accessing Novell GroupWise servers"),
95 CAMEL_PROVIDER_IS_REMOTE | CAMEL_PROVIDER_IS_SOURCE |
96 CAMEL_PROVIDER_IS_STORAGE | CAMEL_PROVIDER_SUPPORTS_SSL | CAMEL_PROVIDER_DISABLE_SENT_FOLDER,
98 CAMEL_URL_NEED_USER | CAMEL_URL_NEED_HOST | CAMEL_URL_ALLOW_AUTH,
100 groupwise_conf_entries,
105 CamelServiceAuthType camel_groupwise_password_authtype = {
108 N_("This option will connect to the GroupWise server using a "
109 "plaintext password."),
116 groupwise_auto_detect_cb (CamelURL *url, GHashTable **auto_detected,
119 *auto_detected = g_hash_table_new (g_str_hash, g_str_equal);
121 g_hash_table_insert (*auto_detected, g_strdup ("poa"),
122 g_strdup (url->host));
128 camel_provider_module_init(void)
130 CamelProvider *imap_provider = NULL;
131 CamelException ex = CAMEL_EXCEPTION_INITIALISER;
132 gboolean use_imap = g_getenv ("USE_IMAP") != NULL;
135 imap_provider = camel_provider_get("imap://", &ex);
137 groupwise_provider.url_hash = groupwise_url_hash;
138 groupwise_provider.url_equal = groupwise_url_equal;
139 groupwise_provider.auto_detect = groupwise_auto_detect_cb;
140 groupwise_provider.authtypes = g_list_prepend (groupwise_provider.authtypes, &camel_groupwise_password_authtype);
141 groupwise_provider.translation_domain = GETTEXT_PACKAGE;
144 groupwise_provider.object_types[CAMEL_PROVIDER_STORE] = imap_provider->object_types [CAMEL_PROVIDER_STORE];
146 groupwise_provider.object_types[CAMEL_PROVIDER_STORE] = camel_groupwise_store_get_type();
147 groupwise_provider.object_types[CAMEL_PROVIDER_TRANSPORT] = camel_groupwise_transport_get_type();
150 camel_provider_register (&groupwise_provider);
155 add_hash (guint *hash, char *s)
158 *hash ^= g_str_hash(s);
162 groupwise_url_hash (gconstpointer key)
164 const CamelURL *u = (CamelURL *)key;
167 add_hash (&hash, u->user);
168 add_hash (&hash, u->authmech);
169 add_hash (&hash, u->host);
176 check_equal (char *s1, char *s2)
188 return strcmp (s1, s2) == 0;
192 groupwise_url_equal (gconstpointer a, gconstpointer b)
194 const CamelURL *u1 = a, *u2 = b;
196 return check_equal (u1->protocol, u2->protocol)
197 && check_equal (u1->user, u2->user)
198 && check_equal (u1->authmech, u2->authmech)
199 && check_equal (u1->host, u2->host)
200 && u1->port == u2->port;