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 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
27 #ifndef CAMEL_SESSION_H
28 #define CAMEL_SESSION_H 1
30 #include <camel/camel-object.h>
31 #include <camel/camel-provider.h>
32 #include <camel/camel-junk-plugin.h>
34 #include <libedataserver/e-msgport.h>
36 #define CAMEL_SESSION_TYPE (camel_session_get_type ())
37 #define CAMEL_SESSION(obj) (CAMEL_CHECK_CAST((obj), CAMEL_SESSION_TYPE, CamelSession))
38 #define CAMEL_SESSION_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_SESSION_TYPE, CamelSessionClass))
39 #define CAMEL_IS_SESSION(o) (CAMEL_CHECK_TYPE((o), CAMEL_SESSION_TYPE))
43 typedef gboolean (*CamelTimeoutCallback) (gpointer data);
45 CAMEL_SESSION_ALERT_INFO,
46 CAMEL_SESSION_ALERT_WARNING,
47 CAMEL_SESSION_ALERT_ERROR
48 } CamelSessionAlertType;
51 CAMEL_SESSION_PASSWORD_REPROMPT = 1 << 0,
52 CAMEL_SESSION_PASSWORD_SECRET = 1 << 2,
53 CAMEL_SESSION_PASSWORD_STATIC = 1 << 3,
54 CAMEL_SESSION_PASSPHRASE = 1 << 4,
59 CamelObject parent_object;
60 struct _CamelSessionPrivate *priv;
63 CamelJunkPlugin *junk_plugin;
67 guint network_state:1;
70 typedef struct _CamelSessionThreadOps CamelSessionThreadOps;
71 typedef struct _CamelSessionThreadMsg CamelSessionThreadMsg;
74 CamelObjectClass parent_class;
76 CamelService * (*get_service) (CamelSession *session,
77 const char *url_string,
78 CamelProviderType type,
80 char * (*get_storage_path) (CamelSession *session,
81 CamelService *service,
84 char * (*get_password) (CamelSession *session,
85 CamelService *service,
91 void (*forget_password) (CamelSession *session,
92 CamelService *service,
96 gboolean (*alert_user) (CamelSession *session,
97 CamelSessionAlertType type,
101 CamelFilterDriver * (*get_filter_driver) (CamelSession *session,
105 /* mechanism for creating and maintaining multiple threads of control */
106 void *(*thread_msg_new)(CamelSession *session, CamelSessionThreadOps *ops, unsigned int size);
107 void (*thread_msg_free)(CamelSession *session, CamelSessionThreadMsg *msg);
108 int (*thread_queue)(CamelSession *session, CamelSessionThreadMsg *msg, int flags);
109 void (*thread_wait)(CamelSession *session, int id);
110 void (*thread_status)(CamelSession *session, CamelSessionThreadMsg *msg, const char *text, int pc);
116 /* Standard Camel function */
117 CamelType camel_session_get_type (void);
120 void camel_session_construct (CamelSession *session,
121 const char *storage_path);
123 CamelService * camel_session_get_service (CamelSession *session,
124 const char *url_string,
125 CamelProviderType type,
127 CamelService * camel_session_get_service_connected (CamelSession *session,
128 const char *url_string,
129 CamelProviderType type,
132 #define camel_session_get_store(session, url_string, ex) \
133 ((CamelStore *) camel_session_get_service_connected (session, url_string, CAMEL_PROVIDER_STORE, ex))
134 #define camel_session_get_transport(session, url_string, ex) \
135 ((CamelTransport *) camel_session_get_service_connected (session, url_string, CAMEL_PROVIDER_TRANSPORT, ex))
137 char * camel_session_get_storage_path (CamelSession *session,
138 CamelService *service,
141 char * camel_session_get_password (CamelSession *session,
142 CamelService *service,
148 void camel_session_forget_password (CamelSession *session,
149 CamelService *service,
153 gboolean camel_session_alert_user (CamelSession *session,
154 CamelSessionAlertType type,
158 gboolean camel_session_is_online (CamelSession *session);
159 void camel_session_set_online (CamelSession *session,
162 CamelFilterDriver *camel_session_get_filter_driver (CamelSession *session,
166 gboolean camel_session_check_junk (CamelSession *session);
167 void camel_session_set_check_junk (CamelSession *session,
168 gboolean check_junk);
170 struct _CamelSessionThreadOps {
171 void (*receive)(CamelSession *session, struct _CamelSessionThreadMsg *m);
172 void (*free)(CamelSession *session, struct _CamelSessionThreadMsg *m);
175 struct _CamelSessionThreadMsg {
181 CamelSessionThreadOps *ops;
182 struct _CamelOperation *op;
183 CamelSession *session;
185 void *data; /* free for implementation to define, not used by camel, do not use in client code */
186 /* user fields follow */
189 void *camel_session_thread_msg_new(CamelSession *session, CamelSessionThreadOps *ops, unsigned int size);
190 void camel_session_thread_msg_free(CamelSession *session, CamelSessionThreadMsg *msg);
191 int camel_session_thread_queue(CamelSession *session, CamelSessionThreadMsg *msg, int flags);
192 void camel_session_thread_wait(CamelSession *session, int id);
193 gboolean camel_session_get_network_state (CamelSession *session);
194 void camel_session_set_network_state (CamelSession *session, gboolean network_state);
198 #endif /* CAMEL_SESSION_H */