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 1999, 2000 Ximian, Inc. (www.ximian.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 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 General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
27 #ifndef CAMEL_SESSION_H
28 #define CAMEL_SESSION_H 1
34 #endif /* __cplusplus }*/
36 #include <camel/camel-object.h>
37 #include <camel/camel-provider.h>
38 #include <camel/camel-junk-plugin.h>
40 #include <e-util/e-msgport.h>
42 #define CAMEL_SESSION_TYPE (camel_session_get_type ())
43 #define CAMEL_SESSION(obj) (CAMEL_CHECK_CAST((obj), CAMEL_SESSION_TYPE, CamelSession))
44 #define CAMEL_SESSION_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_SESSION_TYPE, CamelSessionClass))
45 #define CAMEL_IS_SESSION(o) (CAMEL_CHECK_TYPE((o), CAMEL_SESSION_TYPE))
48 typedef gboolean (*CamelTimeoutCallback) (gpointer data);
50 CAMEL_SESSION_ALERT_INFO,
51 CAMEL_SESSION_ALERT_WARNING,
52 CAMEL_SESSION_ALERT_ERROR
53 } CamelSessionAlertType;
57 CamelObject parent_object;
58 struct _CamelSessionPrivate *priv;
61 GHashTable *providers, *modules;
64 CamelJunkPlugin *junk_plugin;
69 typedef struct _CamelSessionThreadOps CamelSessionThreadOps;
70 typedef struct _CamelSessionThreadMsg CamelSessionThreadMsg;
74 CamelObjectClass parent_class;
76 void (*register_provider) (CamelSession *session,
77 CamelProvider *provider);
78 GList * (*list_providers) (CamelSession *session,
80 CamelProvider * (*get_provider) (CamelSession *session,
81 const char *url_string,
84 CamelService * (*get_service) (CamelSession *session,
85 const char *url_string,
86 CamelProviderType type,
88 char * (*get_storage_path) (CamelSession *session,
89 CamelService *service,
92 char * (*get_password) (CamelSession *session,
96 CamelService *service,
99 void (*forget_password) (CamelSession *session,
100 CamelService *service,
103 gboolean (*alert_user) (CamelSession *session,
104 CamelSessionAlertType type,
108 CamelFilterDriver * (*get_filter_driver) (CamelSession *session,
111 #ifdef ENABLE_THREADS
112 /* mechanism for creating and maintaining multiple threads of control */
113 void *(*thread_msg_new)(CamelSession *session, CamelSessionThreadOps *ops, unsigned int size);
114 void (*thread_msg_free)(CamelSession *session, CamelSessionThreadMsg *msg);
115 int (*thread_queue)(CamelSession *session, CamelSessionThreadMsg *msg, int flags);
116 void (*thread_wait)(CamelSession *session, int id);
117 void (*thread_status)(CamelSession *session, CamelSessionThreadMsg *msg, const char *text, int pc);
125 /* Standard Camel function */
126 CamelType camel_session_get_type (void);
129 void camel_session_construct (CamelSession *session,
130 const char *storage_path);
132 void camel_session_register_provider (CamelSession *session,
133 CamelProvider *provider);
134 GList * camel_session_list_providers (CamelSession *session,
137 CamelProvider * camel_session_get_provider (CamelSession *session,
138 const char *url_string,
141 CamelService * camel_session_get_service (CamelSession *session,
142 const char *url_string,
143 CamelProviderType type,
145 CamelService * camel_session_get_service_connected (CamelSession *session,
146 const char *url_string,
147 CamelProviderType type,
150 #define camel_session_get_store(session, url_string, ex) \
151 ((CamelStore *) camel_session_get_service_connected (session, url_string, CAMEL_PROVIDER_STORE, ex))
152 #define camel_session_get_transport(session, url_string, ex) \
153 ((CamelTransport *) camel_session_get_service_connected (session, url_string, CAMEL_PROVIDER_TRANSPORT, ex))
155 char * camel_session_get_storage_path (CamelSession *session,
156 CamelService *service,
159 char * camel_session_get_password (CamelSession *session,
163 CamelService *service,
166 void camel_session_forget_password (CamelSession *session,
167 CamelService *service,
170 gboolean camel_session_alert_user (CamelSession *session,
171 CamelSessionAlertType type,
175 gboolean camel_session_is_online (CamelSession *session);
176 void camel_session_set_online (CamelSession *session,
179 CamelFilterDriver *camel_session_get_filter_driver (CamelSession *session,
183 gboolean camel_session_check_junk (CamelSession *session);
184 void camel_session_set_check_junk (CamelSession *session, gboolean check_junk);
186 #ifdef ENABLE_THREADS
187 struct _CamelSessionThreadOps {
188 void (*receive)(CamelSession *session, struct _CamelSessionThreadMsg *m);
189 void (*free)(CamelSession *session, struct _CamelSessionThreadMsg *m);
192 struct _CamelSessionThreadMsg {
198 CamelSessionThreadOps *ops;
199 struct _CamelOperation *op;
200 CamelSession *session;
202 void *data; /* free for implementation to define, not used by camel, do not use in client code */
203 /* user fields follow */
206 void *camel_session_thread_msg_new(CamelSession *session, CamelSessionThreadOps *ops, unsigned int size);
207 void camel_session_thread_msg_free(CamelSession *session, CamelSessionThreadMsg *msg);
208 int camel_session_thread_queue(CamelSession *session, CamelSessionThreadMsg *msg, int flags);
209 void camel_session_thread_wait(CamelSession *session, int id);
215 #endif /* __cplusplus */
217 #endif /* CAMEL_SESSION_H */