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>
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))
61 typedef struct _CamelSession CamelSession;
62 typedef struct _CamelSessionClass CamelSessionClass;
63 typedef struct _CamelSessionPrivate CamelSessionPrivate;
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
72 struct _CamelSession {
74 CamelSessionPrivate *priv;
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
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.
90 typedef void (*CamelSessionCallback) (CamelSession *session,
91 GCancellable *cancellable,
95 struct _CamelSessionClass {
96 CamelObjectClass parent_class;
98 CamelService * (*add_service) (CamelSession *session,
100 const gchar *protocol,
101 CamelProviderType type,
103 void (*remove_service) (CamelSession *session,
104 CamelService *service);
105 gchar * (*get_password) (CamelSession *session,
106 CamelService *service,
111 gboolean (*forget_password) (CamelSession *session,
112 CamelService *service,
115 gint (*alert_user) (CamelSession *session,
116 CamelSessionAlertType type,
118 GSList *button_captions);
120 (*get_filter_driver) (CamelSession *session,
123 gboolean (*lookup_addressbook) (CamelSession *session,
125 void (*get_socks_proxy) (CamelSession *session,
126 const gchar *for_host,
130 /* Synchronous I/O Methods */
131 gboolean (*authenticate_sync) (CamelSession *session,
132 CamelService *service,
133 const gchar *mechanism,
134 GCancellable *cancellable,
136 gboolean (*forward_to_sync) (CamelSession *session,
138 CamelMimeMessage *message,
139 const gchar *address,
140 GCancellable *cancellable,
143 /* Asynchronous I/O Methods (all have defaults) */
144 void (*authenticate) (CamelSession *session,
145 CamelService *service,
146 const gchar *mechanism,
148 GCancellable *cancellable,
149 GAsyncReadyCallback callback,
151 gboolean (*authenticate_finish) (CamelSession *session,
152 GAsyncResult *result,
154 void (*forward_to) (CamelSession *session,
156 CamelMimeMessage *message,
157 const gchar *address,
159 GCancellable *cancellable,
160 GAsyncReadyCallback callback,
162 gboolean (*forward_to_finish) (CamelSession *session,
163 GAsyncResult *result,
167 void (*job_started) (CamelSession *session,
168 GCancellable *cancellable);
169 void (*job_finished) (CamelSession *session,
170 GCancellable *cancellable,
171 const GError *error);
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,
183 CamelService * camel_session_add_service (CamelSession *session,
185 const gchar *protocol,
186 CamelProviderType type,
188 void camel_session_remove_service (CamelSession *session,
189 CamelService *service);
190 CamelService * camel_session_ref_service (CamelSession *session,
192 CamelService * camel_session_ref_service_by_url
193 (CamelSession *session,
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,
204 gboolean camel_session_forget_password (CamelSession *session,
205 CamelService *service,
208 gint camel_session_alert_user (CamelSession *session,
209 CamelSessionAlertType type,
211 GSList *button_captions);
212 gchar * camel_session_build_password_prompt
216 gboolean camel_session_get_online (CamelSession *session);
217 void camel_session_set_online (CamelSession *session,
220 camel_session_get_filter_driver (CamelSession *session,
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,
232 GSourceFunc function,
234 GDestroyNotify notify);
235 void camel_session_submit_job (CamelSession *session,
236 CamelSessionCallback callback,
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);
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,
250 gboolean camel_session_lookup_addressbook (CamelSession *session,
253 gboolean camel_session_authenticate_sync (CamelSession *session,
254 CamelService *service,
255 const gchar *mechanism,
256 GCancellable *cancellable,
258 void camel_session_authenticate (CamelSession *session,
259 CamelService *service,
260 const gchar *mechanism,
262 GCancellable *cancellable,
263 GAsyncReadyCallback callback,
265 gboolean camel_session_authenticate_finish
266 (CamelSession *session,
267 GAsyncResult *result,
269 gboolean camel_session_forward_to_sync (CamelSession *session,
271 CamelMimeMessage *message,
272 const gchar *address,
273 GCancellable *cancellable,
275 void camel_session_forward_to (CamelSession *session,
277 CamelMimeMessage *message,
278 const gchar *address,
280 GCancellable *cancellable,
281 GAsyncReadyCallback callback,
283 gboolean camel_session_forward_to_finish (CamelSession *session,
284 GAsyncResult *result,
289 #endif /* CAMEL_SESSION_H */