~ubuntu-branches/ubuntu/natty/evolution-data-server/natty

« back to all changes in this revision

Viewing changes to .pc/199-git-backport-2.32.1-to-b08a6a1.patch/camel/providers/imap/camel-imap-provider.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2011-02-07 14:11:56 UTC
  • mfrom: (1.1.84 upstream)
  • Revision ID: james.westby@ubuntu.com-20110207141156-jakojbbkzee62447
Tags: 2.32.2-0ubuntu1
* New upstream release
* debian/patches/01_various_linking_issues.patch:
* debian/patches/02_fix_sources_migration.patch:
* debian/patches/199-git-backport-2.32.1-b08a6a1_to_2d0f4a3.patch:
* debian/patches/199-git-backport-2.32.1-to-b08a6a1.patch:
* debian/patches/199-git-skip-empty-cache-files-ee21a86.patch:
  - Fixed upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
 
/* camel-imap-provider.c: imap provider registration code */
3
 
 
4
 
/*
5
 
 *  Authors: Jeffrey Stedfast <fejj@ximian.com>
6
 
 *
7
 
 *  Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
8
 
 *
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.
12
 
 *
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.
17
 
 *
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.
22
 
 *
23
 
 */
24
 
 
25
 
#include <config.h>
26
 
 
27
 
#include <string.h>
28
 
#include <camel/camel.h>
29
 
#include <glib/gi18n-lib.h>
30
 
 
31
 
#include "camel-imap-store.h"
32
 
 
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);
37
 
 
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 },
46
 
#ifndef G_OS_WIN32
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 },
54
 
#endif
55
 
        { CAMEL_PROVIDER_CONF_SECTION_START, "folders", NULL,
56
 
          N_("Folders") },
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",
62
 
          N_("Names_pace:") },
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 }
75
 
};
76
 
 
77
 
static CamelProvider imap_provider = {
78
 
        "imap",
79
 
        N_("IMAP"),
80
 
 
81
 
        N_("For reading and storing mail on IMAP servers."),
82
 
 
83
 
        "mail",
84
 
 
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,
88
 
 
89
 
        CAMEL_URL_NEED_USER | CAMEL_URL_NEED_HOST | CAMEL_URL_ALLOW_AUTH,
90
 
 
91
 
        imap_conf_entries,
92
 
 
93
 
        /* ... */
94
 
};
95
 
 
96
 
CamelServiceAuthType camel_imap_password_authtype = {
97
 
        N_("Password"),
98
 
 
99
 
        N_("This option will connect to the IMAP server using a "
100
 
           "plaintext password."),
101
 
 
102
 
        "",
103
 
        TRUE
104
 
};
105
 
 
106
 
void
107
 
camel_provider_module_init(void)
108
 
{
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;
115
 
 
116
 
        camel_provider_register(&imap_provider);
117
 
}
118
 
 
119
 
static void
120
 
add_hash (guint *hash, gchar *s)
121
 
{
122
 
        if (s)
123
 
                *hash ^= g_str_hash(s);
124
 
}
125
 
 
126
 
static guint
127
 
imap_url_hash (gconstpointer key)
128
 
{
129
 
        const CamelURL *u = (CamelURL *)key;
130
 
        guint hash = 0;
131
 
 
132
 
        add_hash (&hash, u->user);
133
 
        add_hash (&hash, u->host);
134
 
        hash ^= u->port;
135
 
 
136
 
        return hash;
137
 
}
138
 
 
139
 
static gint
140
 
check_equal (gchar *s1, gchar *s2)
141
 
{
142
 
        if (s1 == NULL) {
143
 
                if (s2 == NULL)
144
 
                        return TRUE;
145
 
                else
146
 
                        return FALSE;
147
 
        }
148
 
 
149
 
        if (s2 == NULL)
150
 
                return FALSE;
151
 
 
152
 
        return strcmp (s1, s2) == 0;
153
 
}
154
 
 
155
 
static gint
156
 
imap_url_equal (gconstpointer a, gconstpointer b)
157
 
{
158
 
        const CamelURL *u1 = a, *u2 = b;
159
 
 
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;
164
 
}