1 /*
2  * e-mail-session.h
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
11  * for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program; if not, see <http://www.gnu.org/licenses/>.
15  *
16  *
17  * Authors:
18  *		Jeffrey Stedfast <fejj@ximian.com>
19  *
20  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
21  *
22  */
23 
24 #if !defined (__LIBEMAIL_ENGINE_H_INSIDE__) && !defined (LIBEMAIL_ENGINE_COMPILATION)
25 #error "Only <libemail-engine/libemail-engine.h> should be included directly."
26 #endif
27 
28 #ifndef E_MAIL_SESSION_H
29 #define E_MAIL_SESSION_H
30 
31 #include <camel/camel.h>
32 #include <libedataserver/libedataserver.h>
33 #include <libemail-engine/e-mail-engine-enums.h>
34 #include <libemail-engine/e-mail-junk-filter.h>
35 #include <libemail-engine/em-vfolder-context.h>
36 #include <libemail-engine/mail-folder-cache.h>
37 
38 /* Standard GObject macros */
39 #define E_TYPE_MAIL_SESSION \
40 	(e_mail_session_get_type ())
41 #define E_MAIL_SESSION(obj) \
42 	(G_TYPE_CHECK_INSTANCE_CAST \
43 	((obj), E_TYPE_MAIL_SESSION, EMailSession))
44 #define E_MAIL_SESSION_CLASS(cls) \
45 	(G_TYPE_CHECK_CLASS_CAST \
46 	((cls), E_TYPE_MAIL_SESSION, EMailSessionClass))
47 #define E_IS_MAIL_SESSION(obj) \
48 	(G_TYPE_CHECK_INSTANCE_TYPE \
49 	((obj), E_TYPE_MAIL_SESSION))
50 #define E_IS_MAIL_SESSION_CLASS(cls) \
51 	(G_TYPE_CHECK_CLASS_TYPE \
52 	((cls), E_TYPE_MAIL_SESSION))
53 #define E_MAIL_SESSION_GET_CLASS(obj) \
54 	(G_TYPE_INSTANCE_GET_CLASS \
55 	((obj), E_TYPE_MAIL_SESSION, EMailSessionClass))
56 
57 /* Built-in CamelServices */
58 #define E_MAIL_SESSION_LOCAL_UID   "local"	/* "On This Computer" */
59 #define E_MAIL_SESSION_VFOLDER_UID "vfolder"	/* "Search Folders" */
60 
61 G_BEGIN_DECLS
62 
63 typedef struct _EMailSession EMailSession;
64 typedef struct _EMailSessionClass EMailSessionClass;
65 typedef struct _EMailSessionPrivate EMailSessionPrivate;
66 
67 struct _EMailSession {
68 	CamelSession parent;
69 	EMailSessionPrivate *priv;
70 };
71 
72 struct _EMailSessionClass {
73 	CamelSessionClass parent_class;
74 
75 	EMVFolderContext *
76 			(*create_vfolder_context)
77 						(EMailSession *session);
78 	void		(*flush_outbox)		(EMailSession *session);
79 	void		(*refresh_service)	(EMailSession *session,
80 						 CamelService *service);
81 	void		(*store_added)		(EMailSession *session,
82 						 CamelStore *store);
83 	void		(*store_removed)	(EMailSession *session,
84 						 CamelStore *store);
85 	void		(*allow_auth_prompt)	(EMailSession *session,
86 						 ESource *source);
87 	gchar *		(*get_recipient_certificate)
88 						(EMailSession *session,
89 						 guint flags, /* bit-or of CamelRecipientCertificateFlags */
90 						 const gchar *email_address);
91 	void		(*archive_folder_changed)
92 						(EMailSession *session,
93 						 const gchar *service_uid,
94 						 const gchar *old_folder_uri,
95 						 const gchar *new_folder_uri);
96 	void		(*connect_store)	(EMailSession *session,
97 						 CamelStore *store);
98 
99 	/* Padding for future expansion */
100 	gpointer reserved[8];
101 };
102 
103 GType		e_mail_session_get_type		(void);
104 EMailSession *	e_mail_session_new		(ESourceRegistry *registry);
105 ESourceRegistry *
106 		e_mail_session_get_registry	(EMailSession *session);
107 MailFolderCache *
108 		e_mail_session_get_folder_cache	(EMailSession *session);
109 CamelStore *	e_mail_session_get_local_store	(EMailSession *session);
110 CamelStore *	e_mail_session_get_vfolder_store
111 						(EMailSession *session);
112 CamelFolder *	e_mail_session_get_local_folder	(EMailSession *session,
113 						 EMailLocalFolder type);
114 const gchar *	e_mail_session_get_local_folder_uri
115 						(EMailSession *session,
116 						 EMailLocalFolder type);
117 GList *		e_mail_session_get_available_junk_filters
118 						(EMailSession *session);
119 EMailJunkFilter *
120 		e_mail_session_get_junk_filter_by_name
121 						(EMailSession *session,
122 						 const gchar *filter_name);
123 CamelFolder *	e_mail_session_get_inbox_sync	(EMailSession *session,
124 						 const gchar *service_uid,
125 						 GCancellable *cancellable,
126 						 GError **error);
127 void		e_mail_session_get_inbox	(EMailSession *session,
128 						 const gchar *service_uid,
129 						 gint io_priority,
130 						 GCancellable *cancellable,
131 						 GAsyncReadyCallback callback,
132 						 gpointer user_data);
133 CamelFolder *	e_mail_session_get_inbox_finish	(EMailSession *session,
134 						 GAsyncResult *result,
135 						 GError **error);
136 CamelFolder *	e_mail_session_get_trash_sync	(EMailSession *session,
137 						 const gchar *service_uid,
138 						 GCancellable *cancellable,
139 						 GError **error);
140 void		e_mail_session_get_trash	(EMailSession *session,
141 						 const gchar *service_uid,
142 						 gint io_priority,
143 						 GCancellable *cancellable,
144 						 GAsyncReadyCallback callback,
145 						 gpointer user_data);
146 CamelFolder *	e_mail_session_get_trash_finish	(EMailSession *session,
147 						 GAsyncResult *result,
148 						 GError **error);
149 CamelFolder *	e_mail_session_uri_to_folder_sync
150 						(EMailSession *session,
151 						 const gchar *folder_uri,
152 						 CamelStoreGetFolderFlags flags,
153 						 GCancellable *cancellable,
154 						 GError **error);
155 void		e_mail_session_uri_to_folder	(EMailSession *session,
156 						 const gchar *folder_uri,
157 						 CamelStoreGetFolderFlags flags,
158 						 gint io_priority,
159 						 GCancellable *cancellable,
160 						 GAsyncReadyCallback callback,
161 						 gpointer user_data);
162 CamelFolder *	e_mail_session_uri_to_folder_finish
163 						(EMailSession *session,
164 						 GAsyncResult *result,
165 						 GError **error);
166 EMVFolderContext *
167 		e_mail_session_create_vfolder_context
168 						(EMailSession *session);
169 
170 void		e_mail_session_flush_outbox	(EMailSession *session);
171 void		e_mail_session_schedule_outbox_flush
172 						(EMailSession *session,
173 						 gint delay_minutes);
174 void		e_mail_session_cancel_scheduled_outbox_flush
175 						(EMailSession *session);
176 gboolean	e_mail_session_mark_service_used_sync
177 						(EMailSession *session,
178 						 CamelService *service,
179 						 GCancellable *cancellable);
180 void		e_mail_session_unmark_service_used
181 						(EMailSession *session,
182 						 CamelService *service);
183 void		e_mail_session_emit_allow_auth_prompt
184 						(EMailSession *session,
185 						 ESource *source);
186 gboolean	e_mail_session_is_archive_folder
187 						(EMailSession *session,
188 						 const gchar *folder_uri);
189 void		e_mail_session_emit_connect_store
190 						(EMailSession *session,
191 						 CamelStore *store);
192 
193 /* Useful GBinding transform functions */
194 gboolean	e_binding_transform_service_to_source
195 						(GBinding *binding,
196 						 const GValue *source_value,
197 						 GValue *target_value,
198 						 gpointer session);
199 gboolean	e_binding_transform_source_to_service
200 						(GBinding *binding,
201 						 const GValue *source_value,
202 						 GValue *target_value,
203 						 gpointer session);
204 
205 /*** Legacy API ***/
206 
207 void		mail_session_flush_filter_log	(EMailSession *session);
208 const gchar *	mail_session_get_data_dir	(void);
209 const gchar *	mail_session_get_cache_dir	(void);
210 const gchar *	mail_session_get_config_dir	(void);
211 
212 G_END_DECLS
213 
214 #endif /* E_MAIL_SESSION_H */
215