aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog4
-rw-r--r--camel/camel-service.c295
-rw-r--r--camel/camel-service.h6
3 files changed, 102 insertions, 203 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index f49ba73abe..ebc9d195e8 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,9 @@
2000-06-15 Dan Winship <danw@helixcode.com>
+ * camel-service.c: Remove camel_service_connect_with_url. (URLs
+ must be specified when the service is requested from the session,
+ so that there can only ever be one service for any URL.)
+
* camel-folder.c: (camel_folder_open, camel_folder_is_open,
camel_folder_get_mode): Kill. Folders are now always open, and
handle "closing" sorts of operations at sync or finalize time.
diff --git a/camel/camel-service.c b/camel/camel-service.c
index 52a7581e9f..1efcafcfe8 100644
--- a/camel/camel-service.c
+++ b/camel/camel-service.c
@@ -1,15 +1,15 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* camel-service.c : Abstract class for an email service */
-/*
+/*
*
- * Author :
+ * Author :
* Bertrand Guiheneuf <bertrand@helixcode.com>
*
* Copyright 1999, 2000 Helix Code, Inc. (http://www.helixcode.com)
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
@@ -36,16 +36,15 @@ static CamelObjectClass *parent_class = NULL;
/* Returns the class for a CamelService */
#define CSERV_CLASS(so) CAMEL_SERVICE_CLASS (GTK_OBJECT(so)->klass)
-static gboolean _connect(CamelService *service, CamelException *ex);
-static gboolean _connect_with_url (CamelService *service, CamelURL *url,
- CamelException *ex);
-static gboolean _disconnect(CamelService *service, CamelException *ex);
-static gboolean _is_connected (CamelService *service);
-static GList * _query_auth_types (CamelService *service, CamelException *ex);
-static void _free_auth_types (CamelService *service, GList *authtypes);
-static void _finalize (GtkObject *object);
-static gboolean _set_url (CamelService *service, CamelURL *url,
- CamelException *ex);
+static gboolean service_connect(CamelService *service, CamelException *ex);
+static gboolean service_disconnect(CamelService *service, CamelException *ex);
+static gboolean is_connected (CamelService *service);
+static GList * query_auth_types (CamelService *service, CamelException *ex);
+static void free_auth_types (CamelService *service, GList *authtypes);
+static void finalize (GtkObject *object);
+
+static gboolean check_url (CamelService *service, CamelException *ex);
+
static void
camel_service_class_init (CamelServiceClass *camel_service_class)
@@ -54,53 +53,45 @@ camel_service_class_init (CamelServiceClass *camel_service_class)
GTK_OBJECT_CLASS (camel_service_class);
parent_class = gtk_type_class (camel_object_get_type ());
-
+
/* virtual method definition */
- camel_service_class->connect = _connect;
- camel_service_class->connect_with_url = _connect_with_url;
- camel_service_class->disconnect = _disconnect;
- camel_service_class->is_connected = _is_connected;
- camel_service_class->query_auth_types = _query_auth_types;
- camel_service_class->free_auth_types = _free_auth_types;
+ camel_service_class->connect = service_connect;
+ camel_service_class->disconnect = service_disconnect;
+ camel_service_class->is_connected = is_connected;
+ camel_service_class->query_auth_types = query_auth_types;
+ camel_service_class->free_auth_types = free_auth_types;
/* virtual method overload */
- gtk_object_class->finalize = _finalize;
-}
-
-static void
-camel_service_init (void *o, void *k)
-{
-/* CamelService *service = o;*/
- return;
+ gtk_object_class->finalize = finalize;
}
GtkType
camel_service_get_type (void)
{
static GtkType camel_service_type = 0;
-
- if (!camel_service_type) {
- GtkTypeInfo camel_service_info =
+
+ if (!camel_service_type) {
+ GtkTypeInfo camel_service_info =
{
"CamelService",
sizeof (CamelService),
sizeof (CamelServiceClass),
(GtkClassInitFunc) camel_service_class_init,
- (GtkObjectInitFunc) camel_service_init,
+ (GtkObjectInitFunc) NULL,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
};
-
+
camel_service_type = gtk_type_unique (camel_object_get_type (),
&camel_service_info);
}
-
+
return camel_service_type;
}
-static void
-_finalize (GtkObject *object)
+static void
+finalize (GtkObject *object)
{
CamelService *camel_service = CAMEL_SERVICE (object);
@@ -113,6 +104,40 @@ _finalize (GtkObject *object)
}
+static gboolean
+check_url (CamelService *service, CamelException *ex)
+{
+ char *url_string;
+
+ if (service->url_flags & CAMEL_SERVICE_URL_NEED_USER &&
+ (service->url->user == NULL || service->url->user[0] == '\0')) {
+ url_string = camel_url_to_string (service->url, FALSE);
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID,
+ "URL '%s' needs a username component",
+ url_string);
+ g_free (url_string);
+ return FALSE;
+ } else if (service->url_flags & CAMEL_SERVICE_URL_NEED_HOST &&
+ (service->url->host == NULL || service->url->host[0] == '\0')) {
+ url_string = camel_url_to_string (service->url, FALSE);
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID,
+ "URL '%s' needs a host component",
+ url_string);
+ g_free (url_string);
+ return FALSE;
+ } else if (service->url_flags & CAMEL_SERVICE_URL_NEED_PATH &&
+ (service->url->path == NULL || service->url->path[0] == '\0')) {
+ url_string = camel_url_to_string (service->url, FALSE);
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID,
+ "URL '%s' needs a path component",
+ url_string);
+ g_free (url_string);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
/**
* camel_service_new: create a new CamelService or subtype
* @type: the GtkType of the class to create
@@ -134,40 +159,33 @@ camel_service_new (GtkType type, CamelSession *session, CamelURL *url,
g_return_val_if_fail (CAMEL_IS_SESSION (session), NULL);
service = CAMEL_SERVICE (gtk_object_new (type, NULL));
+ service->url = url;
+ if (!url->empty && !check_url (service, ex)) {
+ gtk_object_unref (GTK_OBJECT (service));
+ return NULL;
+ }
+
service->session = session;
gtk_object_ref (GTK_OBJECT (session));
- if (!_set_url (service, url, ex) && !url->empty)
- return NULL;
return service;
}
-/**
- * _connect : connect to a service
- * @service: object to connect
- * @ex: a CamelException
- *
- * connect to the service using the parameters
- * stored in the session it is initialized with
- *
- * Return value: whether or not the connection succeeded
- **/
+
static gboolean
-_connect (CamelService *service, CamelException *ex)
+service_connect (CamelService *service, CamelException *ex)
{
service->connected = TRUE;
return TRUE;
}
-
-
/**
- * camel_service_connect:connect to a service
+ * camel_service_connect:
* @service: CamelService object
* @ex: a CamelException
- *
- * connect to the service using the parameters
- * stored in the session it is initialized with
+ *
+ * Connect to the service using the parameters it was initialized
+ * with.
*
* Return value: whether or not the connection succeeded
**/
@@ -178,179 +196,63 @@ camel_service_connect (CamelService *service, CamelException *ex)
g_return_val_if_fail (service->session != NULL, FALSE);
g_return_val_if_fail (service->url != NULL, FALSE);
- return CSERV_CLASS(service)->connect(service, ex);
-}
-
-
-
-/**
- * _connect_with_url: connect to the specified address
- * @service: object to connect
- * @url: URL describing service to connect to
- * @ex: a CamelException
- *
- * Connect to the service, but do not use the session
- * default parameters to retrieve server's address
- *
- * Return value: whether or not the connection succeeded
- **/
-static gboolean
-_connect_with_url (CamelService *service, CamelURL *url, CamelException *ex)
-{
- if (!_set_url (service, url, ex))
- return FALSE;
-
- return CSERV_CLASS(service)->connect (service, ex);
+ return CSERV_CLASS (service)->connect (service, ex);
}
-/**
- * camel_service_connect_with_url: connect a service
- * @service: the service to connect
- * @url: URL describing the service to connect to
- * @ex: a CamelException
- *
- * Connect to a service, but do not use the session
- * default parameters to retrieve server's address
- *
- * Return value: whether or not the connection succeeded
- **/
-gboolean
-camel_service_connect_with_url (CamelService *service, char *url_string,
- CamelException *ex)
-{
- CamelURL *url;
- g_return_val_if_fail (CAMEL_IS_SERVICE (service), FALSE);
- g_return_val_if_fail (service->session != NULL, FALSE);
-
- url = camel_url_new (url_string, ex);
- if (!url)
- return FALSE;
- return CSERV_CLASS(service)->connect_with_url (service, url, ex);
-}
-
-
-
-/**
- * _disconnect : disconnect from a service
- * @service: object to disconnect
- * @ex: a CamelException
- *
- * disconnect from the service
- *
- * Return value: whether or not the disconnection succeeded without
- * errors. (Consult @ex if FALSE.)
- **/
static gboolean
-_disconnect (CamelService *service, CamelException *ex)
+service_disconnect (CamelService *service, CamelException *ex)
{
service->connected = FALSE;
return TRUE;
}
-
-
/**
- * camel_service_disconnect: disconnect from a service
+ * camel_service_disconnect:
* @service: CamelService object
* @ex: a CamelException
*
- * disconnect from the service
+ * Disconnect from the service.
*
* Return value: whether or not the disconnection succeeded without
- * errors. (Consult @ex if FALSE.)
+ * errors. (Consult @ex if %FALSE.)
**/
gboolean
camel_service_disconnect (CamelService *service, CamelException *ex)
{
- return CSERV_CLASS(service)->disconnect(service, ex);
+ return CSERV_CLASS (service)->disconnect (service, ex);
}
-
-/**
- * _is_connected: test if the service object is connected
- * @service: object to test
- *
- * Return value: whether or not the service is connected
- **/
static gboolean
-_is_connected (CamelService *service)
+is_connected (CamelService *service)
{
return service->connected;
}
/**
- * camel_service_is_connected: test if the service object is connected
+ * camel_service_is_connected:
* @service: object to test
- *
+ *
* Return value: whether or not the service is connected
**/
gboolean
camel_service_is_connected (CamelService *service)
{
- return CSERV_CLASS(service)->is_connected(service);
+ return CSERV_CLASS (service)->is_connected (service);
}
/**
- * _set_url: Validate a URL and set it as the default for a service
- * @service: the CamelService
- * @url_string: the URL
- * @ex: a CamelException
+ * camel_service_get_url:
+ * @service: a service
*
- * This converts the URL to a CamelURL, validates it for the service,
- * and sets it as the default URL for the service.
- *
- * Return value: success or failure
- **/
-static gboolean
-_set_url (CamelService *service, CamelURL *url, CamelException *ex)
-{
- char *url_string;
-
- if (service->url_flags & CAMEL_SERVICE_URL_NEED_USER &&
- (url->user == NULL || url->user[0] == '\0')) {
- url_string = camel_url_to_string (url, FALSE);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID,
- "URL '%s' needs a username component",
- url_string);
- g_free (url_string);
- return FALSE;
- } else if (service->url_flags & CAMEL_SERVICE_URL_NEED_HOST &&
- (url->host == NULL || url->host[0] == '\0')) {
- url_string = camel_url_to_string (url, FALSE);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID,
- "URL '%s' needs a host component",
- url_string);
- g_free (url_string);
- return FALSE;
- } else if (service->url_flags & CAMEL_SERVICE_URL_NEED_PATH &&
- (url->path == NULL || url->path[0] == '\0')) {
- url_string = camel_url_to_string (url, FALSE);
- camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID,
- "URL '%s' needs a path component",
- url_string);
- g_free (url_string);
- return FALSE;
- }
-
- if (service->url)
- camel_url_free (service->url);
- service->url = url;
- return TRUE;
-}
-
-/**
- * camel_service_get_url: get the url representing a service
- * @service: the service
- *
- * returns the URL representing a service. The returned URL must be
+ * Returns the URL representing a service. The returned URL must be
* freed when it is no longer needed. For security reasons, this
* routine does not return the password.
- *
+ *
* Return value: the url name
**/
char *
@@ -361,10 +263,10 @@ camel_service_get_url (CamelService *service)
/**
- * camel_service_get_session: return the session associated with a service
- * @service: the service
+ * camel_service_get_session:
+ * @service: a service
*
- * returns the CamelSession associated with the service.
+ * Returns the CamelSession associated with the service.
*
* Return value: the session
**/
@@ -376,14 +278,13 @@ camel_service_get_session (CamelService *service)
GList *
-_query_auth_types (CamelService *service, CamelException *ex)
+query_auth_types (CamelService *service, CamelException *ex)
{
return NULL;
}
/**
- * camel_service_query_auth_types: return a list of supported
- * authentication types.
+ * camel_service_query_auth_types:
* @service: a CamelService
* @ex: a CamelException
*
@@ -407,19 +308,19 @@ camel_service_query_auth_types (CamelService *service, CamelException *ex)
return CSERV_CLASS (service)->query_auth_types (service, ex);
}
+
static void
-_free_auth_types (CamelService *service, GList *authtypes)
+free_auth_types (CamelService *service, GList *authtypes)
{
;
}
/**
- * camel_service_free_auth_types: free a type list returned by
- * camel_service_query_auth_types.
+ * camel_service_free_auth_types:
* @service: the service
* @authtypes: the list of authtypes
*
- * This frees the data allocated by camel_service_query_auth_types.
+ * This frees the data allocated by camel_service_query_auth_types().
**/
void
camel_service_free_auth_types (CamelService *service, GList *authtypes)
@@ -432,7 +333,7 @@ camel_service_free_auth_types (CamelService *service, GList *authtypes)
/* URL utility routines */
/**
- * camel_service_gethost: get a hostent for a CamelService's host
+ * camel_service_gethost:
* @service: a CamelService
* @ex: a CamelException
*
diff --git a/camel/camel-service.h b/camel/camel-service.h
index 7ebd6aa0e8..179447661b 100644
--- a/camel/camel-service.h
+++ b/camel/camel-service.h
@@ -59,9 +59,6 @@ typedef struct {
gboolean (*connect) (CamelService *service,
CamelException *ex);
- gboolean (*connect_with_url) (CamelService *service,
- CamelURL *url,
- CamelException *ex);
gboolean (*disconnect) (CamelService *service,
CamelException *ex);
@@ -98,9 +95,6 @@ CamelService * camel_service_new (GtkType type,
gboolean camel_service_connect (CamelService *service,
CamelException *ex);
-gboolean camel_service_connect_with_url (CamelService *service,
- char *url,
- CamelException *ex);
gboolean camel_service_disconnect (CamelService *service,
CamelException *ex);
gboolean camel_service_is_connected (CamelService *service);