Add optimized indexing capabilities for phone number values.
[platform/upstream/evolution-data-server.git] / camel / camel-session.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /* camel-session.h : Abstract class for an email session */
3
4 /*
5  *
6  * Author :
7  *  Bertrand Guiheneuf <bertrand@helixcode.com>
8  *
9  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
10  *
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.
14  *
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
18  * GNU Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
23  * USA
24  */
25
26 #if !defined (__CAMEL_H_INSIDE__) && !defined (CAMEL_COMPILATION)
27 #error "Only <camel/camel.h> can be included directly."
28 #endif
29
30 #ifndef CAMEL_SESSION_H
31 #define CAMEL_SESSION_H
32
33 #include <camel/camel-enums.h>
34 #include <camel/camel-filter-driver.h>
35 #include <camel/camel-junk-filter.h>
36 #include <camel/camel-msgport.h>
37 #include <camel/camel-provider.h>
38 #include <camel/camel-service.h>
39 #include <camel/camel-certdb.h>
40
41 /* Standard GObject macros */
42 #define CAMEL_TYPE_SESSION \
43         (camel_session_get_type ())
44 #define CAMEL_SESSION(obj) \
45         (G_TYPE_CHECK_INSTANCE_CAST \
46         ((obj), CAMEL_TYPE_SESSION, CamelSession))
47 #define CAMEL_SESSION_CLASS(cls) \
48         (G_TYPE_CHECK_CLASS_CAST \
49         ((cls), CAMEL_TYPE_SESSION, CamelSessionClass))
50 #define CAMEL_IS_SESSION(obj) \
51         (G_TYPE_CHECK_INSTANCE_TYPE \
52         ((obj), CAMEL_TYPE_SESSION))
53 #define CAMEL_IS_SESSION_CLASS(cls) \
54         (G_TYPE_CHECK_CLASS_TYPE \
55         ((cls), CAMEL_TYPE_SESSION))
56 #define CAMEL_SESSION_GET_CLASS(obj) \
57         (G_TYPE_INSTANCE_GET_CLASS \
58         ((obj), CAMEL_TYPE_SESSION, CamelSessionClass))
59
60 G_BEGIN_DECLS
61
62 typedef struct _CamelSession CamelSession;
63 typedef struct _CamelSessionClass CamelSessionClass;
64 typedef struct _CamelSessionPrivate CamelSessionPrivate;
65
66 enum {
67         CAMEL_SESSION_PASSWORD_REPROMPT = 1 << 0,
68         CAMEL_SESSION_PASSWORD_SECRET = 1 << 2,
69         CAMEL_SESSION_PASSWORD_STATIC = 1 << 3,
70         CAMEL_SESSION_PASSPHRASE = 1 << 4
71 };
72
73 struct _CamelSession {
74         CamelObject parent;
75         CamelSessionPrivate *priv;
76 };
77
78 /**
79  * CamelSessionCallback:
80  * @session: a #CamelSession
81  * @cancellable: a #CamelOperation cast as a #GCancellable
82  * @user_data: data passed to camel_session_submit_job()
83  * @error: return location for a #GError
84  *
85  * This is the callback signature for jobs submitted to the CamelSession
86  * via camel_session_submit_job().  The @error pointer is always non-%NULL,
87  * so it's safe to dereference to check if a #GError has been set.
88  *
89  * Since: 3.2
90  **/
91 typedef void    (*CamelSessionCallback)         (CamelSession *session,
92                                                  GCancellable *cancellable,
93                                                  gpointer user_data,
94                                                  GError **error);
95
96 struct _CamelSessionClass {
97         CamelObjectClass parent_class;
98
99         CamelService *  (*add_service)          (CamelSession *session,
100                                                  const gchar *uid,
101                                                  const gchar *protocol,
102                                                  CamelProviderType type,
103                                                  GError **error);
104         void            (*remove_service)       (CamelSession *session,
105                                                  CamelService *service);
106         gchar *         (*get_password)         (CamelSession *session,
107                                                  CamelService *service,
108                                                  const gchar *prompt,
109                                                  const gchar *item,
110                                                  guint32 flags,
111                                                  GError **error);
112         gboolean        (*forget_password)      (CamelSession *session,
113                                                  CamelService *service,
114                                                  const gchar *item,
115                                                  GError **error);
116         gint            (*alert_user)           (CamelSession *session,
117                                                  CamelSessionAlertType type,
118                                                  const gchar *prompt,
119                                                  GList *button_captions,
120                                                  GCancellable *cancellable);
121         CamelCertTrust  (*trust_prompt)         (CamelSession *session,
122                                                  const gchar *host,
123                                                  const gchar *certificate,
124                                                  guint32 certificate_errors,
125                                                  GList *issuers,
126                                                  GCancellable *cancellable);
127         CamelFilterDriver *
128                         (*get_filter_driver)    (CamelSession *session,
129                                                  const gchar *type,
130                                                  GError **error);
131         gboolean        (*lookup_addressbook)   (CamelSession *session,
132                                                  const gchar *name);
133         void            (*get_socks_proxy)      (CamelSession *session,
134                                                  const gchar *for_host,
135                                                  gchar **host_ret,
136                                                  gint *port_ret);
137
138         /* Synchronous I/O Methods */
139         gboolean        (*authenticate_sync)    (CamelSession *session,
140                                                  CamelService *service,
141                                                  const gchar *mechanism,
142                                                  GCancellable *cancellable,
143                                                  GError **error);
144         gboolean        (*forward_to_sync)      (CamelSession *session,
145                                                  CamelFolder *folder,
146                                                  CamelMimeMessage *message,
147                                                  const gchar *address,
148                                                  GCancellable *cancellable,
149                                                  GError **error);
150
151         /* Asynchronous I/O Methods (all have defaults) */
152         void            (*authenticate)         (CamelSession *session,
153                                                  CamelService *service,
154                                                  const gchar *mechanism,
155                                                  gint io_priority,
156                                                  GCancellable *cancellable,
157                                                  GAsyncReadyCallback callback,
158                                                  gpointer user_data);
159         gboolean        (*authenticate_finish)  (CamelSession *session,
160                                                  GAsyncResult *result,
161                                                  GError **error);
162         void            (*forward_to)           (CamelSession *session,
163                                                  CamelFolder *folder,
164                                                  CamelMimeMessage *message,
165                                                  const gchar *address,
166                                                  gint io_priority,
167                                                  GCancellable *cancellable,
168                                                  GAsyncReadyCallback callback,
169                                                  gpointer user_data);
170         gboolean        (*forward_to_finish)    (CamelSession *session,
171                                                  GAsyncResult *result,
172                                                  GError **error);
173
174         /* Signals */
175         void            (*job_started)          (CamelSession *session,
176                                                  GCancellable *cancellable);
177         void            (*job_finished)         (CamelSession *session,
178                                                  GCancellable *cancellable,
179                                                  const GError *error);
180 };
181
182 GType           camel_session_get_type          (void);
183 GMainContext *  camel_session_get_main_context  (CamelSession *session);
184 const gchar *   camel_session_get_user_data_dir (CamelSession *session);
185 const gchar *   camel_session_get_user_cache_dir
186                                                 (CamelSession *session);
187 void            camel_session_get_socks_proxy   (CamelSession *session,
188                                                  const gchar *for_host,
189                                                  gchar **host_ret,
190                                                  gint *port_ret);
191 CamelService *  camel_session_add_service       (CamelSession *session,
192                                                  const gchar *uid,
193                                                  const gchar *protocol,
194                                                  CamelProviderType type,
195                                                  GError **error);
196 void            camel_session_remove_service    (CamelSession *session,
197                                                  CamelService *service);
198 CamelService *  camel_session_ref_service       (CamelSession *session,
199                                                  const gchar *uid);
200 CamelService *  camel_session_ref_service_by_url
201                                                 (CamelSession *session,
202                                                  CamelURL *url,
203                                                  CamelProviderType type);
204 GList *         camel_session_list_services     (CamelSession *session);
205 void            camel_session_remove_services   (CamelSession *session);
206 gchar *         camel_session_get_password      (CamelSession *session,
207                                                  CamelService *service,
208                                                  const gchar *prompt,
209                                                  const gchar *item,
210                                                  guint32 flags,
211                                                  GError **error);
212 gboolean        camel_session_forget_password   (CamelSession *session,
213                                                  CamelService *service,
214                                                  const gchar *item,
215                                                  GError **error);
216 gint            camel_session_alert_user        (CamelSession *session,
217                                                  CamelSessionAlertType type,
218                                                  const gchar *prompt,
219                                                  GList *button_captions,
220                                                  GCancellable *cancellable);
221 CamelCertTrust  camel_session_trust_prompt      (CamelSession *session,
222                                                  const gchar *host,
223                                                  const gchar *certificate,
224                                                  guint32 certificate_errors,
225                                                  GList *issuers,
226                                                  GCancellable *cancellable);
227 gchar *         camel_session_build_password_prompt
228                                                 (const gchar *type,
229                                                  const gchar *user,
230                                                  const gchar *host);
231 gboolean        camel_session_get_online        (CamelSession *session);
232 void            camel_session_set_online        (CamelSession *session,
233                                                  gboolean online);
234 CamelFilterDriver *
235                 camel_session_get_filter_driver (CamelSession *session,
236                                                  const gchar *type,
237                                                  GError **error);
238 CamelJunkFilter *
239                 camel_session_get_junk_filter   (CamelSession *session);
240 void            camel_session_set_junk_filter   (CamelSession *session,
241                                                  CamelJunkFilter *junk_filter);
242 gboolean        camel_session_get_check_junk    (CamelSession *session);
243 void            camel_session_set_check_junk    (CamelSession *session,
244                                                  gboolean check_junk);
245 guint           camel_session_idle_add          (CamelSession *session,
246                                                  gint priority,
247                                                  GSourceFunc function,
248                                                  gpointer data,
249                                                  GDestroyNotify notify);
250 void            camel_session_submit_job        (CamelSession *session,
251                                                  CamelSessionCallback callback,
252                                                  gpointer user_data,
253                                                  GDestroyNotify notify);
254 gboolean        camel_session_get_network_available
255                                                 (CamelSession *session);
256 void            camel_session_set_network_available
257                                                 (CamelSession *session,
258                                                  gboolean network_available);
259 const GHashTable *
260                 camel_session_get_junk_headers  (CamelSession *session);
261 void            camel_session_set_junk_headers  (CamelSession *session,
262                                                  const gchar **headers,
263                                                  const gchar **values,
264                                                  gint len);
265 gboolean        camel_session_lookup_addressbook (CamelSession *session,
266                                                  const gchar *name);
267
268 gboolean        camel_session_authenticate_sync (CamelSession *session,
269                                                  CamelService *service,
270                                                  const gchar *mechanism,
271                                                  GCancellable *cancellable,
272                                                  GError **error);
273 void            camel_session_authenticate      (CamelSession *session,
274                                                  CamelService *service,
275                                                  const gchar *mechanism,
276                                                  gint io_priority,
277                                                  GCancellable *cancellable,
278                                                  GAsyncReadyCallback callback,
279                                                  gpointer user_data);
280 gboolean        camel_session_authenticate_finish
281                                                 (CamelSession *session,
282                                                  GAsyncResult *result,
283                                                  GError **error);
284 gboolean        camel_session_forward_to_sync   (CamelSession *session,
285                                                  CamelFolder *folder,
286                                                  CamelMimeMessage *message,
287                                                  const gchar *address,
288                                                  GCancellable *cancellable,
289                                                  GError **error);
290 void            camel_session_forward_to        (CamelSession *session,
291                                                  CamelFolder *folder,
292                                                  CamelMimeMessage *message,
293                                                  const gchar *address,
294                                                  gint io_priority,
295                                                  GCancellable *cancellable,
296                                                  GAsyncReadyCallback callback,
297                                                  gpointer user_data);
298 gboolean        camel_session_forward_to_finish (CamelSession *session,
299                                                  GAsyncResult *result,
300                                                  GError **error);
301
302 G_END_DECLS
303
304 #endif /* CAMEL_SESSION_H */