Lock down Camel headers.
[platform/upstream/evolution-data-server.git] / camel / camel-service.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /* camel-service.h : Abstract class for an email service */
3 /*
4  *
5  * Authors: Bertrand Guiheneuf <bertrand@helixcode.com>
6  *          Michael Zucchi <notzed@ximian.com>
7  *
8  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
9  *
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.
13  *
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.
18  *
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
22  * USA
23  */
24
25 #if !defined (__CAMEL_H_INSIDE__) && !defined (CAMEL_COMPILATION)
26 #error "Only <camel/camel.h> can be included directly."
27 #endif
28
29 #ifndef CAMEL_SERVICE_H
30 #define CAMEL_SERVICE_H
31
32 #include <camel/camel-object.h>
33 #include <camel/camel-url.h>
34 #include <camel/camel-provider.h>
35 #include <camel/camel-operation.h>
36
37 #define CAMEL_SERVICE_TYPE     (camel_service_get_type ())
38 #define CAMEL_SERVICE(obj)     (CAMEL_CHECK_CAST((obj), CAMEL_SERVICE_TYPE, CamelService))
39 #define CAMEL_SERVICE_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_SERVICE_TYPE, CamelServiceClass))
40 #define CAMEL_IS_SERVICE(o)    (CAMEL_CHECK_TYPE((o), CAMEL_SERVICE_TYPE))
41
42 G_BEGIN_DECLS
43
44 enum {
45         CAMEL_SERVICE_ARG_FIRST  = CAMEL_ARG_FIRST + 100,
46         CAMEL_SERVICE_ARG_USERNAME,
47         CAMEL_SERVICE_ARG_AUTH,
48         CAMEL_SERVICE_ARG_HOSTNAME,
49         CAMEL_SERVICE_ARG_PORT,
50         CAMEL_SERVICE_ARG_PATH
51 };
52
53 #define CAMEL_SERVICE_USERNAME     (CAMEL_SERVICE_ARG_USERNAME | CAMEL_ARG_STR)
54 #define CAMEL_SERVICE_AUTH         (CAMEL_SERVICE_ARG_AUTH | CAMEL_ARG_STR)
55 #define CAMEL_SERVICE_HOSTNAME     (CAMEL_SERVICE_ARG_HOSTNAME | CAMEL_ARG_STR)
56 #define CAMEL_SERVICE_PORT         (CAMEL_SERVICE_ARG_PORT | CAMEL_ARG_INT)
57 #define CAMEL_SERVICE_PATH         (CAMEL_SERVICE_ARG_PATH | CAMEL_ARG_STR)
58
59 typedef enum {
60         CAMEL_SERVICE_DISCONNECTED,
61         CAMEL_SERVICE_CONNECTING,
62         CAMEL_SERVICE_CONNECTED,
63         CAMEL_SERVICE_DISCONNECTING
64 } CamelServiceConnectionStatus;
65
66 struct _CamelService {
67         CamelObject parent_object;
68         struct _CamelServicePrivate *priv;
69
70         CamelSession *session;
71         CamelProvider *provider;
72         CamelServiceConnectionStatus status;
73         CamelOperation *connect_op;
74         CamelURL *url;
75 };
76
77 typedef struct {
78         CamelObjectClass parent_class;
79
80         void      (*construct)         (CamelService *service,
81                                         CamelSession *session,
82                                         CamelProvider *provider,
83                                         CamelURL *url,
84                                         CamelException *ex);
85
86         gboolean  (*connect)           (CamelService *service,
87                                         CamelException *ex);
88         gboolean  (*disconnect)        (CamelService *service,
89                                         gboolean clean,
90                                         CamelException *ex);
91         void      (*cancel_connect)    (CamelService *service);
92
93         GList *   (*query_auth_types)  (CamelService *service,
94                                         CamelException *ex);
95
96         gchar *    (*get_name)          (CamelService *service,
97                                         gboolean brief);
98         gchar *    (*get_path)          (CamelService *service);
99
100 } CamelServiceClass;
101
102 /* query_auth_types returns a GList of these */
103 typedef struct {
104         const gchar *name;               /* user-friendly name */
105         const gchar *description;
106         const gchar *authproto;
107
108         gboolean need_password;   /* needs a password to authenticate */
109 } CamelServiceAuthType;
110
111 /* public methods */
112 void                camel_service_construct          (CamelService *service,
113                                                       CamelSession *session,
114                                                       CamelProvider *provider,
115                                                       CamelURL *url,
116                                                       CamelException *ex);
117 gboolean            camel_service_connect            (CamelService *service,
118                                                       CamelException *ex);
119 gboolean            camel_service_disconnect         (CamelService *service,
120                                                       gboolean clean,
121                                                       CamelException *ex);
122 void                camel_service_cancel_connect     (CamelService *service);
123 gchar *              camel_service_get_url            (CamelService *service);
124 gchar *              camel_service_get_name           (CamelService *service,
125                                                       gboolean brief);
126 gchar *              camel_service_get_path           (CamelService *service);
127 CamelSession *      camel_service_get_session        (CamelService *service);
128 CamelProvider *     camel_service_get_provider       (CamelService *service);
129 GList *             camel_service_query_auth_types   (CamelService *service,
130                                                       CamelException *ex);
131
132 /* Standard Camel function */
133 CamelType camel_service_get_type (void);
134
135 G_END_DECLS
136
137 #endif /* CAMEL_SERVICE_H */