1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
/* camel-imap-provider.c: imap provider registration code */
5
* Authors: Jeffrey Stedfast <fejj@ximian.com>
7
* Copyright (C) 1999-2008 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.
28
#include <camel/camel.h>
29
#include <glib/gi18n-lib.h>
31
#include "camel-imap-store.h"
33
static void add_hash (guint *hash, gchar *s);
34
static guint imap_url_hash (gconstpointer key);
35
static gint check_equal (gchar *s1, gchar *s2);
36
static gint imap_url_equal (gconstpointer a, gconstpointer b);
38
static CamelProviderConfEntry imap_conf_entries[] = {
39
{ CAMEL_PROVIDER_CONF_SECTION_START, "mailcheck", NULL,
40
N_("Checking for New Mail") },
41
{ CAMEL_PROVIDER_CONF_CHECKBOX, "check_all", NULL,
42
N_("C_heck for new messages in all folders"), "1" },
43
{ CAMEL_PROVIDER_CONF_CHECKBOX, "check_lsub", NULL,
44
N_("Ch_eck for new messages in subscribed folders"), "0" },
45
{ CAMEL_PROVIDER_CONF_SECTION_END },
47
{ CAMEL_PROVIDER_CONF_SECTION_START, "cmdsection", NULL,
48
N_("Connection to Server") },
49
{ CAMEL_PROVIDER_CONF_CHECKBOX, "use_command", NULL,
50
N_("_Use custom command to connect to server"), "0" },
51
{ CAMEL_PROVIDER_CONF_ENTRY, "command", "use_command",
52
N_("Co_mmand:"), "ssh -C -l %u %h exec /usr/sbin/imapd" },
53
{ CAMEL_PROVIDER_CONF_SECTION_END },
55
{ CAMEL_PROVIDER_CONF_SECTION_START, "folders", NULL,
57
{ CAMEL_PROVIDER_CONF_CHECKBOX, "use_lsub", NULL,
58
N_("_Show only subscribed folders"), "1" },
59
{ CAMEL_PROVIDER_CONF_CHECKBOX, "override_namespace", NULL,
60
N_("O_verride server-supplied folder namespace"), "0" },
61
{ CAMEL_PROVIDER_CONF_ENTRY, "namespace", "override_namespace",
63
{ CAMEL_PROVIDER_CONF_SECTION_END },
64
{ CAMEL_PROVIDER_CONF_SECTION_START, "general", NULL, N_("Options") },
65
{ CAMEL_PROVIDER_CONF_CHECKBOX, "filter", NULL,
66
N_("_Apply filters to new messages in INBOX on this server"), "0" },
67
{ CAMEL_PROVIDER_CONF_CHECKBOX, "filter_junk", NULL,
68
N_("Check new messages for Jun_k contents"), "0" },
69
{ CAMEL_PROVIDER_CONF_CHECKBOX, "filter_junk_inbox", "filter_junk",
70
N_("Only check for Junk messages in the IN_BOX folder"), "0" },
71
{ CAMEL_PROVIDER_CONF_CHECKBOX, "sync_offline", NULL,
72
N_("Automatically synchroni_ze remote mail locally"), "0" },
73
{ CAMEL_PROVIDER_CONF_SECTION_END },
74
{ CAMEL_PROVIDER_CONF_END }
77
static CamelProvider imap_provider = {
81
N_("For reading and storing mail on IMAP servers."),
85
CAMEL_PROVIDER_IS_REMOTE | CAMEL_PROVIDER_IS_SOURCE |
86
CAMEL_PROVIDER_IS_STORAGE | CAMEL_PROVIDER_SUPPORTS_SSL |
87
CAMEL_PROVIDER_ALLOW_REAL_TRASH_FOLDER | CAMEL_PROVIDER_ALLOW_REAL_JUNK_FOLDER,
89
CAMEL_URL_NEED_USER | CAMEL_URL_NEED_HOST | CAMEL_URL_ALLOW_AUTH,
96
CamelServiceAuthType camel_imap_password_authtype = {
99
N_("This option will connect to the IMAP server using a "
100
"plaintext password."),
107
camel_provider_module_init(void)
109
imap_provider.object_types[CAMEL_PROVIDER_STORE] = camel_imap_store_get_type ();
110
imap_provider.url_hash = imap_url_hash;
111
imap_provider.url_equal = imap_url_equal;
112
imap_provider.authtypes = camel_sasl_authtype_list (FALSE);
113
imap_provider.authtypes = g_list_prepend (imap_provider.authtypes, &camel_imap_password_authtype);
114
imap_provider.translation_domain = GETTEXT_PACKAGE;
116
camel_provider_register(&imap_provider);
120
add_hash (guint *hash, gchar *s)
123
*hash ^= g_str_hash(s);
127
imap_url_hash (gconstpointer key)
129
const CamelURL *u = (CamelURL *)key;
132
add_hash (&hash, u->user);
133
add_hash (&hash, u->host);
140
check_equal (gchar *s1, gchar *s2)
152
return strcmp (s1, s2) == 0;
156
imap_url_equal (gconstpointer a, gconstpointer b)
158
const CamelURL *u1 = a, *u2 = b;
160
return check_equal (u1->protocol, u2->protocol)
161
&& check_equal (u1->user, u2->user)
162
&& check_equal (u1->host, u2->host)
163
&& u1->port == u2->port;