new routine to free the data allocated by camel_service_query_auth_types.
[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 Helix Code, Inc. (http://www.helixcode.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 <gtk/gtk.h>
38 #include "camel-types.h"
39 #include "url-util.h"
40
41 #define CAMEL_SERVICE_TYPE     (camel_service_get_type ())
42 #define CAMEL_SERVICE(obj)     (GTK_CHECK_CAST((obj), CAMEL_SERVICE_TYPE, CamelService))
43 #define CAMEL_SERVICE_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), CAMEL_SERVICE_TYPE, CamelServiceClass))
44 #define CAMEL_IS_SERVICE(o)    (GTK_CHECK_TYPE((o), CAMEL_SERVICE_TYPE))
45
46
47
48 struct _CamelService {
49         GtkObject parent_object;
50
51         CamelSession *session;
52         gboolean connected;
53         Gurl *url;
54         int url_flags;
55
56 };
57
58
59
60 typedef struct {
61         GtkObjectClass parent_class;
62
63         gboolean  (*connect)           (CamelService *service, 
64                                         CamelException *ex);
65         gboolean  (*connect_with_url)  (CamelService *service, 
66                                         Gurl *url,
67                                         CamelException *ex);
68         gboolean  (*disconnect)        (CamelService *service, 
69                                         CamelException *ex);
70
71         gboolean  (*is_connected)      (CamelService *service);
72
73         GList *   (*query_auth_types)  (CamelService *service);
74         void      (*free_auth_types)   (CamelService *service,
75                                         GList *authtypes);
76
77 } CamelServiceClass;
78
79
80
81 /* flags for url_flags. (others can be added if needed) */
82 #define CAMEL_SERVICE_URL_NEED_USER     (1 << 1)
83 #define CAMEL_SERVICE_URL_NEED_AUTH     (1 << 2)
84 #define CAMEL_SERVICE_URL_NEED_HOST     (1 << 4)
85 #define CAMEL_SERVICE_URL_NEED_PATH     (1 << 6)
86
87
88 /* query_auth_types returns a GList of these */
89 typedef struct {
90         char *name, *description, *authproto;
91         gboolean need_password;
92 } CamelServiceAuthType;
93
94
95 /* public methods */
96 CamelService *      camel_service_new                (GtkType type, 
97                                                       CamelSession *session,
98                                                       Gurl *url, 
99                                                       CamelException *ex);
100
101 gboolean            camel_service_connect            (CamelService *service, 
102                                                       CamelException *ex);
103 gboolean            camel_service_connect_with_url   (CamelService *service, 
104                                                       char *url,
105                                                       CamelException *ex);
106 gboolean            camel_service_disconnect         (CamelService *service, 
107                                                       CamelException *ex);
108 gboolean            camel_service_is_connected       (CamelService *service);
109
110 char *              camel_service_get_url            (CamelService *service);
111 CamelSession *      camel_service_get_session        (CamelService *service);
112
113 GList *             camel_service_query_auth_types   (CamelService *service);
114 void                camel_service_free_auth_types    (CamelService *service,
115                                                       GList *authtypes);
116
117 /* Standard Gtk function */
118 GtkType camel_service_get_type (void);
119
120 #ifdef __cplusplus
121 }
122 #endif /* __cplusplus */
123
124 #endif /* CAMEL_SERVICE_H */
125