1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /* camelService.c : Abstract class for an email service */
6 * Copyright (C) 1999 Bertrand Guiheneuf <Bertrand.Guiheneuf@inria.fr> .
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
24 #include "camel-service.h"
26 static GtkObjectClass *parent_class=NULL;
28 /* Returns the class for a CamelService */
29 #define CSERV_CLASS(so) CAMEL_SERVICE_CLASS (GTK_OBJECT(so)->klass)
31 static void _connect(CamelService *service);
32 static void _connect_to_with_login_passwd(CamelService *service, GString *host, GString *login, GString *passwd);
33 static void _connect_to_with_login_passwd_port(CamelService *service, GString *host, GString *login, GString *passwd, guint port);
34 static gboolean _is_connected(CamelService *service);
35 static void _set_connected(CamelService *service, gboolean state);
36 static GString *_get_url(CamelService *service);
39 camel_service_class_init (CamelServiceClass *camel_service_class)
41 parent_class = gtk_type_class (gtk_object_get_type ());
43 /* virtual method definition */
44 camel_service_class->connect = _connect;
45 camel_service_class->connect_to_with_login_passwd = _connect_to_with_login_passwd;
46 camel_service_class->connect_to_with_login_passwd_port = _connect_to_with_login_passwd_port;
47 camel_service_class->is_connected = _is_connected;
48 camel_service_class->set_connected = _set_connected;
49 camel_service_class->get_url = _get_url;
51 /* virtual method overload */
61 camel_service_get_type (void)
63 static GtkType camel_service_type = 0;
65 if (!camel_service_type) {
66 GtkTypeInfo camel_service_info =
69 sizeof (CamelService),
70 sizeof (CamelServiceClass),
71 (GtkClassInitFunc) camel_service_class_init,
72 (GtkObjectInitFunc) NULL,
73 /* reserved_1 */ NULL,
74 /* reserved_2 */ NULL,
75 (GtkClassInitFunc) NULL,
78 camel_service_type = gtk_type_unique (gtk_object_get_type (), &camel_service_info);
81 return camel_service_type;
89 * _connect : connect to a service
91 * connect to the service using the parameters
92 * stored in the session it is initialized with
93 * WARNING: session not implemented for the moment
95 * @service: object to connect
98 _connect(CamelService *service)
100 CSERV_CLASS(service)->set_connected(service, TRUE);
105 * camel_service_connect : connect to a service
107 * connect to the service using the parameters
108 * stored in the session it is initialized with
109 * WARNING: session not implemented for the moment
111 * @service: object to connect to
114 camel_service_connect(CamelService *service)
116 CSERV_CLASS(service)->connect(service);
122 * _connect_to: connect to the specified address
124 * Connect to the service, but do not use the session
125 * default parameters to retrieve server's address
127 * @service: object to connect
128 * @host: host to connect to
129 * @login: user name used to log in
130 * @passwd: password used to log in
133 _connect_to_with_login_passwd(CamelService *service, GString *host, GString *login, GString *passwd)
135 CSERV_CLASS(service)->set_connected(service, TRUE);
139 * camel_service_connect_to_with_login_passwd: connect a service
140 * @service: the service to connect
141 * @host: host to connect to
142 * @login: login to connect with
143 * @passwd: password to connect with
145 * Connect to a service, but do not use the session
146 * default parameters to retrieve server's address
150 camel_service_connect_to_with_login_passwd(CamelService *service, GString *host, GString *login, GString *passwd)
152 CSERV_CLASS(service)->connect_to_with_login_passwd (service, host, login, passwd);
158 * _connect_to:login:password : connect to the specified address
160 * Connect to the service, but do not use the session
161 * default parameters to retrieve server's address
163 * @service: object to connect
164 * @host: host to connect to
165 * @login: user name used to log in
166 * @passwd: password used to log in
167 * @port: port to connect to
171 _connect_to_with_login_passwd_port(CamelService *service, GString *host, GString *login, GString *passwd, guint port)
173 CSERV_CLASS(service)->set_connected(service, TRUE);
178 * camel_service_connect_to_with_login_passwd_port: connect a service
179 * @service: the service to connect
180 * @host: host to connect to
181 * @login: login to connect with
182 * @passwd: password to connect with
183 * @port: port to connect to
185 * Connect to a service, but do not use the session
186 * default parameters to retrieve server's address
190 camel_service_connect_to_with_login_passwd_port(CamelService *service, GString *host, GString *login, GString *passwd, guint port)
192 CSERV_CLASS(service)->connect_to_with_login_passwd_port (service, host, login, passwd, port);
199 * _is_connected: test if the service object is connected
202 * @service: object to test
206 _is_connected(CamelService *service)
208 return service->connected;
213 * camel_service_is_connected: test if a service object is connected
215 * @service: the service
219 * Return value: TRUE is the service is connected
222 camel_service_is_connected(CamelService *service)
224 return CSERV_CLASS(service)->is_connected(service);
229 * _set_connected: set the connected state
231 * This routine has to be called by providers to set the
232 * connection state, mainly when the service is disconnected
233 * wheras the close() method has not been called.
235 * @service: object to set the state of
236 * @state: connected/disconnected
240 _set_connected(CamelService *service, gboolean state)
242 service->connected = state;
248 * _get_url: get url representing a service
249 * @service: the service
251 * This method merely returns the "url" field. Subclasses
252 * may provide more active implementations.
257 _get_url(CamelService *service)
263 * camel_service_get_url: get the url representing a service
264 * @service: the service
266 * returns the URL representing a service. For security reasons
267 * This routine may not always return the password.
269 * Return value: the url name
272 camel_service_get_url(CamelService *service)
274 return CSERV_CLASS(service)->get_url(service);