1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /* camel-session.h : Abstract class for an email session */
7 * Bertrand Guiheneuf <bertrand@helixcode.com>
9 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
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.
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.
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
26 #if !defined (__CAMEL_H_INSIDE__) && !defined (CAMEL_COMPILATION)
27 #error "Only <camel/camel.h> can be included directly."
30 #ifndef CAMEL_SESSION_H
31 #define CAMEL_SESSION_H
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>
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))
62 typedef struct _CamelSession CamelSession;
63 typedef struct _CamelSessionClass CamelSessionClass;
64 typedef struct _CamelSessionPrivate CamelSessionPrivate;
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
73 struct _CamelSession {
75 CamelSessionPrivate *priv;
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
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.
91 typedef void (*CamelSessionCallback) (CamelSession *session,
92 GCancellable *cancellable,
96 struct _CamelSessionClass {
97 CamelObjectClass parent_class;
99 CamelService * (*add_service) (CamelSession *session,
101 const gchar *protocol,
102 CamelProviderType type,
104 void (*remove_service) (CamelSession *session,
105 CamelService *service);
106 gchar * (*get_password) (CamelSession *session,
107 CamelService *service,
112 gboolean (*forget_password) (CamelSession *session,
113 CamelService *service,
116 gint (*alert_user) (CamelSession *session,
117 CamelSessionAlertType type,
119 GList *button_captions,
120 GCancellable *cancellable);
121 CamelCertTrust (*trust_prompt) (CamelSession *session,
123 const gchar *certificate,
124 guint32 certificate_errors,
126 GCancellable *cancellable);
128 (*get_filter_driver) (CamelSession *session,
131 gboolean (*lookup_addressbook) (CamelSession *session,
133 void (*get_socks_proxy) (CamelSession *session,
134 const gchar *for_host,
138 /* Synchronous I/O Methods */
139 gboolean (*authenticate_sync) (CamelSession *session,
140 CamelService *service,
141 const gchar *mechanism,
142 GCancellable *cancellable,
144 gboolean (*forward_to_sync) (CamelSession *session,
146 CamelMimeMessage *message,
147 const gchar *address,
148 GCancellable *cancellable,
151 /* Asynchronous I/O Methods (all have defaults) */
152 void (*authenticate) (CamelSession *session,
153 CamelService *service,
154 const gchar *mechanism,
156 GCancellable *cancellable,
157 GAsyncReadyCallback callback,
159 gboolean (*authenticate_finish) (CamelSession *session,
160 GAsyncResult *result,
162 void (*forward_to) (CamelSession *session,
164 CamelMimeMessage *message,
165 const gchar *address,
167 GCancellable *cancellable,
168 GAsyncReadyCallback callback,
170 gboolean (*forward_to_finish) (CamelSession *session,
171 GAsyncResult *result,
175 void (*job_started) (CamelSession *session,
176 GCancellable *cancellable);
177 void (*job_finished) (CamelSession *session,
178 GCancellable *cancellable,
179 const GError *error);
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,
191 CamelService * camel_session_add_service (CamelSession *session,
193 const gchar *protocol,
194 CamelProviderType type,
196 void camel_session_remove_service (CamelSession *session,
197 CamelService *service);
198 CamelService * camel_session_ref_service (CamelSession *session,
200 CamelService * camel_session_ref_service_by_url
201 (CamelSession *session,
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,
212 gboolean camel_session_forget_password (CamelSession *session,
213 CamelService *service,
216 gint camel_session_alert_user (CamelSession *session,
217 CamelSessionAlertType type,
219 GList *button_captions,
220 GCancellable *cancellable);
221 CamelCertTrust camel_session_trust_prompt (CamelSession *session,
223 const gchar *certificate,
224 guint32 certificate_errors,
226 GCancellable *cancellable);
227 gchar * camel_session_build_password_prompt
231 gboolean camel_session_get_online (CamelSession *session);
232 void camel_session_set_online (CamelSession *session,
235 camel_session_get_filter_driver (CamelSession *session,
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,
247 GSourceFunc function,
249 GDestroyNotify notify);
250 void camel_session_submit_job (CamelSession *session,
251 CamelSessionCallback callback,
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);
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,
265 gboolean camel_session_lookup_addressbook (CamelSession *session,
268 gboolean camel_session_authenticate_sync (CamelSession *session,
269 CamelService *service,
270 const gchar *mechanism,
271 GCancellable *cancellable,
273 void camel_session_authenticate (CamelSession *session,
274 CamelService *service,
275 const gchar *mechanism,
277 GCancellable *cancellable,
278 GAsyncReadyCallback callback,
280 gboolean camel_session_authenticate_finish
281 (CamelSession *session,
282 GAsyncResult *result,
284 gboolean camel_session_forward_to_sync (CamelSession *session,
286 CamelMimeMessage *message,
287 const gchar *address,
288 GCancellable *cancellable,
290 void camel_session_forward_to (CamelSession *session,
292 CamelMimeMessage *message,
293 const gchar *address,
295 GCancellable *cancellable,
296 GAsyncReadyCallback callback,
298 gboolean camel_session_forward_to_finish (CamelSession *session,
299 GAsyncResult *result,
304 #endif /* CAMEL_SESSION_H */