Fix FSF address (Tobias Mueller, #470445)
[platform/upstream/evolution-data-server.git] / camel / camel-provider.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /* camel-provider.h :  provider definition  */
3
4 /*
5  *
6  * Authors:
7  *  Bertrand Guiheneuf <bertrand@helixcode.com>
8  *  Jeffrey Stedfast <fejj@ximian.com>
9  *
10  * Copyright 1999, 2000 Ximian, Inc. (www.ximian.com)
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of version 2 of the GNU Lesser General Public
14  * License as published by the Free Software Foundation.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
24  * USA
25  */
26
27
28 #ifndef CAMEL_PROVIDER_H
29 #define CAMEL_PROVIDER_H 1
30
31 #include <camel/camel-types.h>
32 #include <camel/camel-object.h>
33 #include <camel/camel-exception.h>
34 #include <camel/camel-url.h>
35
36 #define CAMEL_PROVIDER(obj) ((CamelProvider *)(obj))
37
38 G_BEGIN_DECLS
39
40 typedef enum {
41         CAMEL_PROVIDER_STORE,
42         CAMEL_PROVIDER_TRANSPORT,
43         CAMEL_NUM_PROVIDER_TYPES
44 } CamelProviderType;
45
46 extern char *camel_provider_type_name[CAMEL_NUM_PROVIDER_TYPES];
47
48 /* Provider flags:
49  *
50  * _IS_REMOTE   the provider works with remote data
51  * _IS_LOCAL    it can be used as a backend for local folder
52  *                tree folders. (*Not* just the opposite of _IS_REMOTE)
53  * _IS_SOURCE   mail arrives there, so it should be offered as an
54  *                option in the mail config dialog.
55  * _IS_STORAGE  mail is stored there. it will appear in the folder tree.
56  * _IS_EXTERNAL it appears in the folder tree but is not created by
57  *                the mail component.
58  * _HAS_LICENSE  the provider configuration first needs the license to
59  *                 be accepted.
60  */
61 #define CAMEL_PROVIDER_IS_REMOTE        (1 << 0)
62 #define CAMEL_PROVIDER_IS_LOCAL         (1 << 1)
63 #define CAMEL_PROVIDER_IS_EXTERNAL      (1 << 2)
64 #define CAMEL_PROVIDER_IS_SOURCE        (1 << 3)
65 #define CAMEL_PROVIDER_IS_STORAGE       (1 << 4)
66 #define CAMEL_PROVIDER_SUPPORTS_SSL     (1 << 5)
67 #define CAMEL_PROVIDER_HAS_LICENSE      (1 << 6)
68 #define CAMEL_PROVIDER_DISABLE_SENT_FOLDER (1 << 7)
69
70
71 /* Flags for url_flags. "ALLOW" means the config dialog will let the
72  * user configure it. "NEED" implies "ALLOW" but means the user must
73  * configure it. Service code can assume that any url part for which
74  * it has set the NEED flag will be set when the service is
75  * created. "HIDE" also implies "ALLOW", but the setting will be
76  * hidden/no widgets created for it.
77  */
78 #define CAMEL_URL_PART_USER      (1 << 0)
79 #define CAMEL_URL_PART_AUTH      (1 << 1)
80 #define CAMEL_URL_PART_PASSWORD  (1 << 2)
81 #define CAMEL_URL_PART_HOST      (1 << 3)
82 #define CAMEL_URL_PART_PORT      (1 << 4)
83 #define CAMEL_URL_PART_PATH      (1 << 5)
84 #define CAMEL_URL_PART_PATH_DIR  (1 << 6)
85
86 #define CAMEL_URL_PART_NEED            8
87 #define CAMEL_URL_PART_HIDDEN   (CAMEL_URL_PART_NEED + 8)
88
89 /* Use these macros to test a provider's url_flags */
90 #define CAMEL_PROVIDER_ALLOWS(prov, flags) (prov->url_flags & (flags | (flags << CAMEL_URL_PART_NEED) | (flags << CAMEL_URL_PART_HIDDEN)))
91 #define CAMEL_PROVIDER_NEEDS(prov, flags) (prov->url_flags & (flags << CAMEL_URL_PART_NEED))
92 #define CAMEL_PROVIDER_HIDDEN(prov, flags) (prov->url_flags & (flags << CAMEL_URL_PART_HIDDEN))
93
94 /* Providers use these macros to actually define their url_flags */
95 #define CAMEL_URL_ALLOW_USER     (CAMEL_URL_PART_USER)
96 #define CAMEL_URL_ALLOW_AUTH     (CAMEL_URL_PART_AUTH)
97 #define CAMEL_URL_ALLOW_PASSWORD (CAMEL_URL_PART_PASSWORD)
98 #define CAMEL_URL_ALLOW_HOST     (CAMEL_URL_PART_HOST)
99 #define CAMEL_URL_ALLOW_PORT     (CAMEL_URL_PART_PORT)
100 #define CAMEL_URL_ALLOW_PATH     (CAMEL_URL_PART_PATH)
101
102 #define CAMEL_URL_NEED_USER      (CAMEL_URL_PART_USER << CAMEL_URL_PART_NEED)
103 #define CAMEL_URL_NEED_AUTH      (CAMEL_URL_PART_AUTH << CAMEL_URL_PART_NEED)
104 #define CAMEL_URL_NEED_PASSWORD  (CAMEL_URL_PART_PASSWORD << CAMEL_URL_PART_NEED)
105 #define CAMEL_URL_NEED_HOST      (CAMEL_URL_PART_HOST << CAMEL_URL_PART_NEED)
106 #define CAMEL_URL_NEED_PORT      (CAMEL_URL_PART_PORT << CAMEL_URL_PART_NEED)
107 #define CAMEL_URL_NEED_PATH      (CAMEL_URL_PART_PATH << CAMEL_URL_PART_NEED)
108 #define CAMEL_URL_NEED_PATH_DIR  (CAMEL_URL_PART_PATH_DIR << CAMEL_URL_PART_NEED)
109
110 #define CAMEL_URL_HIDDEN_USER    (CAMEL_URL_PART_USER << CAMEL_URL_PART_HIDDEN)
111 #define CAMEL_URL_HIDDEN_AUTH    (CAMEL_URL_PART_AUTH << CAMEL_URL_PART_HIDDEN)
112 #define CAMEL_URL_HIDDEN_PASSWORD        (CAMEL_URL_PART_PASSWORD << CAMEL_URL_PART_HIDDEN)
113 #define CAMEL_URL_HIDDEN_HOST    (CAMEL_URL_PART_HOST << CAMEL_URL_PART_HIDDEN)
114 #define CAMEL_URL_HIDDEN_PORT    (CAMEL_URL_PART_PORT << CAMEL_URL_PART_HIDDEN)
115 #define CAMEL_URL_HIDDEN_PATH    (CAMEL_URL_PART_PATH << CAMEL_URL_PART_HIDDEN)
116
117 #define CAMEL_URL_FRAGMENT_IS_PATH  (1 << 30) /* url uses fragment for folder name path, not path */
118 #define CAMEL_URL_PATH_IS_ABSOLUTE (1 << 31)
119
120
121 #define CAMEL_PROVIDER_IS_STORE_AND_TRANSPORT(prov) (prov->object_types[CAMEL_PROVIDER_STORE] && prov->object_types[CAMEL_PROVIDER_TRANSPORT])
122
123 /* Generic extra config stuff */
124 typedef enum {
125         CAMEL_PROVIDER_CONF_END,
126         CAMEL_PROVIDER_CONF_SECTION_START,
127         CAMEL_PROVIDER_CONF_SECTION_END,
128         CAMEL_PROVIDER_CONF_CHECKBOX,
129         CAMEL_PROVIDER_CONF_CHECKSPIN,
130         CAMEL_PROVIDER_CONF_ENTRY,
131         CAMEL_PROVIDER_CONF_LABEL,
132         CAMEL_PROVIDER_CONF_HIDDEN
133 } CamelProviderConfType;
134
135 typedef struct {
136         CamelProviderConfType type;
137         char *name, *depname;
138         char *text, *value;
139 } CamelProviderConfEntry;
140
141 /* Some defaults */
142 #define CAMEL_PROVIDER_CONF_DEFAULT_USERNAME  { CAMEL_PROVIDER_CONF_LABEL, "username", NULL, N_("User_name:"), NULL }
143 #define CAMEL_PROVIDER_CONF_DEFAULT_HOSTNAME  { CAMEL_PROVIDER_CONF_LABEL, "hostname", NULL, N_("_Host:"), NULL }
144 #define CAMEL_PROVIDER_CONF_DEFAULT_PATH      { CAMEL_PROVIDER_CONF_ENTRY, "path", NULL, N_("_Path:"), "" }
145
146 typedef int (*CamelProviderAutoDetectFunc) (CamelURL *url, GHashTable **auto_detected, CamelException *ex);
147
148 typedef struct {
149         /* Provider name used in CamelURLs. */
150         char *protocol;
151         
152         /* Provider name as used by people. (May be the same as protocol) */
153         char *name;
154         
155         /* Description of the provider. A novice user should be able
156          * to read this description, and the information provided by
157          * an ISP, IS department, etc, and determine whether or not
158          * this provider is relevant to him, and if so, which
159          * information goes with it.
160          */
161         char *description;
162         
163         /* The category of message that this provider works with.
164          * (evolution-mail will only list a provider in the store/transport
165          * config dialogs if its domain is "mail".)
166          */
167         char *domain;
168         
169         /* Flags describing the provider, flags describing its URLs */
170         int flags, url_flags;
171
172         /* The ConfEntry and AutoDetect functions will probably be
173          * DEPRECATED in a future release */
174         
175         /* Extra configuration information */
176         CamelProviderConfEntry *extra_conf;
177
178         /* auto-detection function */
179         CamelProviderAutoDetectFunc auto_detect;
180
181         /* CamelType(s) of its store and/or transport. If both are
182          * set, then they are assumed to be linked together and the
183          * transport type can only be used in an account that also
184          * uses the store type (eg, Exchange or NNTP).
185          */
186         CamelType object_types[CAMEL_NUM_PROVIDER_TYPES];
187         
188         /* GList of CamelServiceAuthTypes the provider supports */
189         GList *authtypes;
190         
191         CamelObjectBag *service_cache[CAMEL_NUM_PROVIDER_TYPES];
192         
193         GHashFunc url_hash;
194         GCompareFunc url_equal;
195
196         /* gettext translation domain (NULL for providers in the
197          * evolution source tree).
198          */
199         char *translation_domain;
200
201         /* This string points to the provider's gconf key value
202          */
203         const char *license;
204         
205         /* This holds the license file name [ ascii text format ] containing
206          * the license agreement. This should be the absolute file path. This 
207          * is read only when the HAS_LICENSE flag is set
208          */
209         const char *license_file;
210
211         /* Private to the provider */   
212         void *priv;
213 } CamelProvider;
214
215 typedef struct _CamelProviderModule CamelProviderModule;
216
217 struct _CamelProviderModule {
218         char *path;
219         GSList *types;
220         guint loaded:1;
221 };
222
223 void camel_provider_init(void);
224
225 void camel_provider_load(const char *path, CamelException *ex);
226 void camel_provider_register(CamelProvider *provider);
227 GList *camel_provider_list(gboolean load);
228 CamelProvider *camel_provider_get(const char *url_string, CamelException *ex);
229
230 /* This is defined by each module, not by camel-provider.c. */
231 void camel_provider_module_init(void);
232
233
234 int camel_provider_auto_detect (CamelProvider *provider, CamelURL *url,
235                                 GHashTable **auto_detected, CamelException *ex);
236
237 G_END_DECLS
238
239 #endif /* CAMEL_PROVIDER_H */