Extending test-client-custom-summary to try e_book_client_get_contacts_uids()
[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
40 /* Standard GObject macros */
41 #define CAMEL_TYPE_SESSION \
42         (camel_session_get_type ())
43 #define CAMEL_SESSION(obj) \
44         (G_TYPE_CHECK_INSTANCE_CAST \
45         ((obj), CAMEL_TYPE_SESSION, CamelSession))
46 #define CAMEL_SESSION_CLASS(cls) \
47         (G_TYPE_CHECK_CLASS_CAST \
48         ((cls), CAMEL_TYPE_SESSION, CamelSessionClass))
49 #define CAMEL_IS_SESSION(obj) \
50         (G_TYPE_CHECK_INSTANCE_TYPE \
51         ((obj), CAMEL_TYPE_SESSION))
52 #define CAMEL_IS_SESSION_CLASS(cls) \
53         (G_TYPE_CHECK_CLASS_TYPE \
54         ((cls), CAMEL_TYPE_SESSION))
55 #define CAMEL_SESSION_GET_CLASS(obj) \
56         (G_TYPE_INSTANCE_GET_CLASS \
57         ((obj), CAMEL_TYPE_SESSION, CamelSessionClass))
58
59 G_BEGIN_DECLS
60
61 typedef struct _CamelSession CamelSession;
62 typedef struct _CamelSessionClass CamelSessionClass;
63 typedef struct _CamelSessionPrivate CamelSessionPrivate;
64
65 enum {
66         CAMEL_SESSION_PASSWORD_REPROMPT = 1 << 0,
67         CAMEL_SESSION_PASSWORD_SECRET = 1 << 2,
68         CAMEL_SESSION_PASSWORD_STATIC = 1 << 3,
69         CAMEL_SESSION_PASSPHRASE = 1 << 4
70 };
71
72 struct _CamelSession {
73         CamelObject parent;
74         CamelSessionPrivate *priv;
75 };
76
77 /**
78  * CamelSessionCallback:
79  * @session: a #CamelSession
80  * @cancellable: a #CamelOperation cast as a #GCancellable
81  * @user_data: data passed to camel_session_submit_job()
82  * @error: return location for a #GError
83  *
84  * This is the callback signature for jobs submitted to the CamelSession
85  * via camel_session_submit_job().  The @error pointer is always non-%NULL,
86  * so it's safe to dereference to check if a #GError has been set.
87  *
88  * Since: 3.2
89  **/
90 typedef void    (*CamelSessionCallback)         (CamelSession *session,
91                                                  GCancellable *cancellable,
92                                                  gpointer user_data,
93                                                  GError **error);
94
95 struct _CamelSessionClass {
96         CamelObjectClass parent_class;
97
98         CamelService *  (*add_service)          (CamelSession *session,
99                                                  const gchar *uid,
100                                                  const gchar *protocol,
101                                                  CamelProviderType type,
102                                                  GError **error);
103         void            (*remove_service)       (CamelSession *session,
104                                                  CamelService *service);
105         gchar *         (*get_password)         (CamelSession *session,
106                                                  CamelService *service,
107                                                  const gchar *prompt,
108                                                  const gchar *item,
109                                                  guint32 flags,
110                                                  GError **error);
111         gboolean        (*forget_password)      (CamelSession *session,
112                                                  CamelService *service,
113                                                  const gchar *item,
114                                                  GError **error);
115         gint            (*alert_user)           (CamelSession *session,
116                                                  CamelSessionAlertType type,
117                                                  const gchar *prompt,
118                                                  GSList *button_captions);
119         CamelFilterDriver *
120                         (*get_filter_driver)    (CamelSession *session,
121                                                  const gchar *type,
122                                                  GError **error);
123         gboolean        (*lookup_addressbook)   (CamelSession *session,
124                                                  const gchar *name);
125         void            (*get_socks_proxy)      (CamelSession *session,
126                                                  const gchar *for_host,
127                                                  gchar **host_ret,
128                                                  gint *port_ret);
129
130         /* Synchronous I/O Methods */
131         gboolean        (*authenticate_sync)    (CamelSession *session,
132                                                  CamelService *service,
133                                                  const gchar *mechanism,
134                                                  GCancellable *cancellable,
135                                                  GError **error);
136         gboolean        (*forward_to_sync)      (CamelSession *session,
137                                                  CamelFolder *folder,
138                                                  CamelMimeMessage *message,
139                                                  const gchar *address,
140                                                  GCancellable *cancellable,
141                                                  GError **error);
142
143         /* Asynchronous I/O Methods (all have defaults) */
144         void            (*authenticate)         (CamelSession *session,
145                                                  CamelService *service,
146                                                  const gchar *mechanism,
147                                                  gint io_priority,
148                                                  GCancellable *cancellable,
149                                                  GAsyncReadyCallback callback,
150                                                  gpointer user_data);
151         gboolean        (*authenticate_finish)  (CamelSession *session,
152                                                  GAsyncResult *result,
153                                                  GError **error);
154         void            (*forward_to)           (CamelSession *session,
155                                                  CamelFolder *folder,
156                                                  CamelMimeMessage *message,
157                                                  const gchar *address,
158                                                  gint io_priority,
159                                                  GCancellable *cancellable,
160                                                  GAsyncReadyCallback callback,
161                                                  gpointer user_data);
162         gboolean        (*forward_to_finish)    (CamelSession *session,
163                                                  GAsyncResult *result,
164                                                  GError **error);
165
166         /* Signals */
167         void            (*job_started)          (CamelSession *session,
168                                                  GCancellable *cancellable);
169         void            (*job_finished)         (CamelSession *session,
170                                                  GCancellable *cancellable,
171                                                  const GError *error);
172 };
173
174 GType           camel_session_get_type          (void);
175 GMainContext *  camel_session_get_main_context  (CamelSession *session);
176 const gchar *   camel_session_get_user_data_dir (CamelSession *session);
177 const gchar *   camel_session_get_user_cache_dir
178                                                 (CamelSession *session);
179 void            camel_session_get_socks_proxy   (CamelSession *session,
180                                                  const gchar *for_host,
181                                                  gchar **host_ret,
182                                                  gint *port_ret);
183 CamelService *  camel_session_add_service       (CamelSession *session,
184                                                  const gchar *uid,
185                                                  const gchar *protocol,
186                                                  CamelProviderType type,
187                                                  GError **error);
188 void            camel_session_remove_service    (CamelSession *session,
189                                                  CamelService *service);
190 CamelService *  camel_session_ref_service       (CamelSession *session,
191                                                  const gchar *uid);
192 CamelService *  camel_session_ref_service_by_url
193                                                 (CamelSession *session,
194                                                  CamelURL *url,
195                                                  CamelProviderType type);
196 GList *         camel_session_list_services     (CamelSession *session);
197 void            camel_session_remove_services   (CamelSession *session);
198 gchar *         camel_session_get_password      (CamelSession *session,
199                                                  CamelService *service,
200                                                  const gchar *prompt,
201                                                  const gchar *item,
202                                                  guint32 flags,
203                                                  GError **error);
204 gboolean        camel_session_forget_password   (CamelSession *session,
205                                                  CamelService *service,
206                                                  const gchar *item,
207                                                  GError **error);
208 gint            camel_session_alert_user        (CamelSession *session,
209                                                  CamelSessionAlertType type,
210                                                  const gchar *prompt,
211                                                  GSList *button_captions);
212 gchar *         camel_session_build_password_prompt
213                                                 (const gchar *type,
214                                                  const gchar *user,
215                                                  const gchar *host);
216 gboolean        camel_session_get_online        (CamelSession *session);
217 void            camel_session_set_online        (CamelSession *session,
218                                                  gboolean online);
219 CamelFilterDriver *
220                 camel_session_get_filter_driver (CamelSession *session,
221                                                  const gchar *type,
222                                                  GError **error);
223 CamelJunkFilter *
224                 camel_session_get_junk_filter   (CamelSession *session);
225 void            camel_session_set_junk_filter   (CamelSession *session,
226                                                  CamelJunkFilter *junk_filter);
227 gboolean        camel_session_get_check_junk    (CamelSession *session);
228 void            camel_session_set_check_junk    (CamelSession *session,
229                                                  gboolean check_junk);
230 guint           camel_session_idle_add          (CamelSession *session,
231                                                  gint priority,
232                                                  GSourceFunc function,
233                                                  gpointer data,
234                                                  GDestroyNotify notify);
235 void            camel_session_submit_job        (CamelSession *session,
236                                                  CamelSessionCallback callback,
237                                                  gpointer user_data,
238                                                  GDestroyNotify notify);
239 gboolean        camel_session_get_network_available
240                                                 (CamelSession *session);
241 void            camel_session_set_network_available
242                                                 (CamelSession *session,
243                                                  gboolean network_available);
244 const GHashTable *
245                 camel_session_get_junk_headers  (CamelSession *session);
246 void            camel_session_set_junk_headers  (CamelSession *session,
247                                                  const gchar **headers,
248                                                  const gchar **values,
249                                                  gint len);
250 gboolean        camel_session_lookup_addressbook (CamelSession *session,
251                                                  const gchar *name);
252
253 gboolean        camel_session_authenticate_sync (CamelSession *session,
254                                                  CamelService *service,
255                                                  const gchar *mechanism,
256                                                  GCancellable *cancellable,
257                                                  GError **error);
258 void            camel_session_authenticate      (CamelSession *session,
259                                                  CamelService *service,
260                                                  const gchar *mechanism,
261                                                  gint io_priority,
262                                                  GCancellable *cancellable,
263                                                  GAsyncReadyCallback callback,
264                                                  gpointer user_data);
265 gboolean        camel_session_authenticate_finish
266                                                 (CamelSession *session,
267                                                  GAsyncResult *result,
268                                                  GError **error);
269 gboolean        camel_session_forward_to_sync   (CamelSession *session,
270                                                  CamelFolder *folder,
271                                                  CamelMimeMessage *message,
272                                                  const gchar *address,
273                                                  GCancellable *cancellable,
274                                                  GError **error);
275 void            camel_session_forward_to        (CamelSession *session,
276                                                  CamelFolder *folder,
277                                                  CamelMimeMessage *message,
278                                                  const gchar *address,
279                                                  gint io_priority,
280                                                  GCancellable *cancellable,
281                                                  GAsyncReadyCallback callback,
282                                                  gpointer user_data);
283 gboolean        camel_session_forward_to_finish (CamelSession *session,
284                                                  GAsyncResult *result,
285                                                  GError **error);
286
287 G_END_DECLS
288
289 #endif /* CAMEL_SESSION_H */