1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /* camel-service.h : Abstract class for an email service */
5 * Authors: Bertrand Guiheneuf <bertrand@helixcode.com>
6 * Michael Zucchi <notzed@ximian.com>
8 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of version 2 of the GNU Lesser General Public
12 * License as published by the Free Software Foundation.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
25 #if !defined (__CAMEL_H_INSIDE__) && !defined (CAMEL_COMPILATION)
26 #error "Only <camel/camel.h> can be included directly."
29 #ifndef CAMEL_SERVICE_H
30 #define CAMEL_SERVICE_H
32 #include <camel/camel-enums.h>
33 #include <camel/camel-object.h>
34 #include <camel/camel-url.h>
35 #include <camel/camel-provider.h>
36 #include <camel/camel-operation.h>
37 #include <camel/camel-settings.h>
39 /* Standard GObject macros */
40 #define CAMEL_TYPE_SERVICE \
41 (camel_service_get_type ())
42 #define CAMEL_SERVICE(obj) \
43 (G_TYPE_CHECK_INSTANCE_CAST \
44 ((obj), CAMEL_TYPE_SERVICE, CamelService))
45 #define CAMEL_SERVICE_CLASS(cls) \
46 (G_TYPE_CHECK_CLASS_CAST \
47 ((cls), CAMEL_TYPE_SERVICE, CamelServiceClass))
48 #define CAMEL_IS_SERVICE(obj) \
49 (G_TYPE_CHECK_INSTANCE_TYPE \
50 ((obj), CAMEL_TYPE_SERVICE))
51 #define CAMEL_IS_SERVICE_CLASS(obj) \
52 (G_TYPE_CHECK_CLASS_TYPE \
53 ((cls), CAMEL_TYPE_SERVICE))
54 #define CAMEL_SERVICE_GET_CLASS(obj) \
55 (G_TYPE_INSTANCE_GET_CLASS \
56 ((obj), CAMEL_TYPE_SERVICE, CamelServiceClass))
59 * CAMEL_SERVICE_ERROR:
63 #define CAMEL_SERVICE_ERROR \
64 (camel_service_error_quark ())
70 typedef struct _CamelService CamelService;
71 typedef struct _CamelServiceClass CamelServiceClass;
72 typedef struct _CamelServicePrivate CamelServicePrivate;
80 CAMEL_SERVICE_ERROR_INVALID,
81 CAMEL_SERVICE_ERROR_URL_INVALID,
82 CAMEL_SERVICE_ERROR_UNAVAILABLE,
83 CAMEL_SERVICE_ERROR_CANT_AUTHENTICATE,
84 CAMEL_SERVICE_ERROR_NOT_CONNECTED
87 struct _CamelService {
89 CamelServicePrivate *priv;
92 struct _CamelServiceClass {
93 CamelObjectClass parent_class;
97 /* Non-Blocking Methods */
98 gchar * (*get_name) (CamelService *service,
101 /* Synchronous I/O Methods */
102 gboolean (*connect_sync) (CamelService *service,
103 GCancellable *cancellable,
105 gboolean (*disconnect_sync) (CamelService *service,
107 GCancellable *cancellable,
109 CamelAuthenticationResult
110 (*authenticate_sync) (CamelService *service,
111 const gchar *mechanism,
112 GCancellable *cancellable,
114 GList * (*query_auth_types_sync)
115 (CamelService *service,
116 GCancellable *cancellable,
119 /* Asynchronous I/O Methods (all have defaults) */
120 void (*connect) (CamelService *service,
122 GCancellable *cancellable,
123 GAsyncReadyCallback callback,
125 gboolean (*connect_finish) (CamelService *service,
126 GAsyncResult *result,
128 void (*disconnect) (CamelService *service,
131 GCancellable *cancellable,
132 GAsyncReadyCallback callback,
134 gboolean (*disconnect_finish) (CamelService *service,
135 GAsyncResult *result,
137 void (*authenticate) (CamelService *service,
138 const gchar *mechanism,
140 GCancellable *cancellable,
141 GAsyncReadyCallback callback,
143 CamelAuthenticationResult
144 (*authenticate_finish) (CamelService *service,
145 GAsyncResult *result,
147 void (*query_auth_types) (CamelService *service,
149 GCancellable *cancellable,
150 GAsyncReadyCallback callback,
152 GList * (*query_auth_types_finish)
153 (CamelService *service,
154 GAsyncResult *result,
158 /* query_auth_types returns a GList of these */
160 const gchar *name; /* user-friendly name */
161 const gchar *description;
162 const gchar *authproto;
164 gboolean need_password; /* needs a password to authenticate */
165 } CamelServiceAuthType;
167 GType camel_service_get_type (void);
168 GQuark camel_service_error_quark (void) G_GNUC_CONST;
169 void camel_service_migrate_files (CamelService *service);
170 CamelURL * camel_service_new_camel_url (CamelService *service);
171 CamelServiceConnectionStatus
172 camel_service_get_connection_status
173 (CamelService *service);
174 const gchar * camel_service_get_display_name (CamelService *service);
175 void camel_service_set_display_name (CamelService *service,
176 const gchar *display_name);
177 const gchar * camel_service_get_password (CamelService *service);
178 void camel_service_set_password (CamelService *service,
179 const gchar *password);
180 const gchar * camel_service_get_user_data_dir (CamelService *service);
181 const gchar * camel_service_get_user_cache_dir
182 (CamelService *service);
183 gchar * camel_service_get_name (CamelService *service,
185 CamelProvider * camel_service_get_provider (CamelService *service);
186 struct _CamelSession *
187 camel_service_get_session (CamelService *service);
188 CamelSettings * camel_service_ref_settings (CamelService *service);
189 void camel_service_set_settings (CamelService *service,
190 CamelSettings *settings);
191 const gchar * camel_service_get_uid (CamelService *service);
193 gboolean camel_service_connect_sync (CamelService *service,
194 GCancellable *cancellable,
196 void camel_service_connect (CamelService *service,
198 GCancellable *cancellable,
199 GAsyncReadyCallback callback,
201 gboolean camel_service_connect_finish (CamelService *service,
202 GAsyncResult *result,
204 gboolean camel_service_disconnect_sync (CamelService *service,
206 GCancellable *cancellable,
208 void camel_service_disconnect (CamelService *service,
211 GCancellable *cancellable,
212 GAsyncReadyCallback callback,
214 gboolean camel_service_disconnect_finish (CamelService *service,
215 GAsyncResult *result,
217 CamelAuthenticationResult
218 camel_service_authenticate_sync (CamelService *service,
219 const gchar *mechanism,
220 GCancellable *cancellable,
222 void camel_service_authenticate (CamelService *service,
223 const gchar *mechanism,
225 GCancellable *cancellable,
226 GAsyncReadyCallback callback,
228 CamelAuthenticationResult
229 camel_service_authenticate_finish
230 (CamelService *service,
231 GAsyncResult *result,
233 GList * camel_service_query_auth_types_sync
234 (CamelService *service,
235 GCancellable *cancellable,
237 void camel_service_query_auth_types (CamelService *service,
239 GCancellable *cancellable,
240 GAsyncReadyCallback callback,
242 GList * camel_service_query_auth_types_finish
243 (CamelService *service,
244 GAsyncResult *result,
249 #endif /* CAMEL_SERVICE_H */