Change "gboolean connected" to "CamelServiceConnectionStatus status",
[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  *
6  * Author : 
7  *  Bertrand Guiheneuf <bertrand@helixcode.com>
8  *
9  * Copyright 1999, 2000 Ximian, Inc. (www.ximian.com)
10  *
11  * This program is free software; you can redistribute it and/or 
12  * modify it under the terms of the GNU General Public License as 
13  * published by the Free Software Foundation; either version 2 of the
14  * License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
24  * USA
25  */
26
27
28 #ifndef CAMEL_SERVICE_H
29 #define CAMEL_SERVICE_H 1
30
31
32 #ifdef __cplusplus
33 extern "C" {
34 #pragma }
35 #endif /* __cplusplus }*/
36
37 #include <netdb.h>
38 #include <camel/camel-object.h>
39 #include <camel/camel-url.h>
40 #include <camel/camel-provider.h>
41 #include <camel/camel-operation.h>
42
43 #define CAMEL_SERVICE_TYPE     (camel_service_get_type ())
44 #define CAMEL_SERVICE(obj)     (CAMEL_CHECK_CAST((obj), CAMEL_SERVICE_TYPE, CamelService))
45 #define CAMEL_SERVICE_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_SERVICE_TYPE, CamelServiceClass))
46 #define CAMEL_IS_SERVICE(o)    (CAMEL_CHECK_TYPE((o), CAMEL_SERVICE_TYPE))
47
48
49 typedef enum {
50         CAMEL_SERVICE_DISCONNECTED,
51         CAMEL_SERVICE_CONNECTING,
52         CAMEL_SERVICE_CONNECTED,
53         CAMEL_SERVICE_DISCONNECTING
54 } CamelServiceConnectionStatus;
55
56 struct _CamelService {
57         CamelObject parent_object;
58         struct _CamelServicePrivate *priv;
59
60         CamelSession *session;
61         CamelProvider *provider;
62         CamelServiceConnectionStatus status;
63         CamelOperation *connect_op;
64         CamelURL *url;
65 };
66
67
68 typedef struct {
69         CamelObjectClass parent_class;
70
71         void      (*construct)         (CamelService *service,
72                                         CamelSession *session,
73                                         CamelProvider *provider,
74                                         CamelURL *url,
75                                         CamelException *ex);
76
77         gboolean  (*connect)           (CamelService *service, 
78                                         CamelException *ex);
79         gboolean  (*disconnect)        (CamelService *service,
80                                         gboolean clean,
81                                         CamelException *ex);
82         void      (*cancel_connect)    (CamelService *service);
83
84         GList *   (*query_auth_types)  (CamelService *service,
85                                         CamelException *ex);
86
87         char *    (*get_name)          (CamelService *service,
88                                         gboolean brief);
89         char *    (*get_path)          (CamelService *service);
90
91 } CamelServiceClass;
92
93
94 /* query_auth_types returns a GList of these */
95 typedef struct {
96         char *name;               /* user-friendly name */
97         char *description;
98         char *authproto;
99         
100         gboolean need_password;   /* needs a password to authenticate */
101 } CamelServiceAuthType;
102
103
104 /* public methods */
105 void                camel_service_construct          (CamelService *service,
106                                                       CamelSession *session,
107                                                       CamelProvider *provider,
108                                                       CamelURL *url, 
109                                                       CamelException *ex);
110 gboolean            camel_service_connect            (CamelService *service, 
111                                                       CamelException *ex);
112 gboolean            camel_service_disconnect         (CamelService *service,
113                                                       gboolean clean,
114                                                       CamelException *ex);
115 void                camel_service_cancel_connect     (CamelService *service);
116 char *              camel_service_get_url            (CamelService *service);
117 char *              camel_service_get_name           (CamelService *service,
118                                                       gboolean brief);
119 char *              camel_service_get_path           (CamelService *service);
120 CamelSession *      camel_service_get_session        (CamelService *service);
121 CamelProvider *     camel_service_get_provider       (CamelService *service);
122 GList *             camel_service_query_auth_types   (CamelService *service,
123                                                       CamelException *ex);
124
125 /* convenience functions */
126 struct hostent *    camel_service_gethost            (CamelService *service,
127                                                       CamelException *ex);
128
129 /* cancellable dns lookup */
130 struct hostent *    camel_get_host_byname            (const char *name, CamelException *ex);
131 void                camel_free_host                  (struct hostent *h);
132
133 /* Standard Camel function */
134 CamelType camel_service_get_type (void);
135
136 #ifdef __cplusplus
137 }
138 #endif /* __cplusplus */
139
140 #endif /* CAMEL_SERVICE_H */
141