From 9f804702d5cfde8b82bb08eb931f408aeee2cbd7 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Mon, 29 May 2000 19:32:29 +0000 Subject: Fix up some glib precondition stuff. Try to set the URL in * camel-service.c (camel_service_new): Fix up some glib precondition stuff. Try to set the URL in camel_service_new before checking whether or not it's "empty" so that you can successfully set "sendmail:" as a URL. svn path=/trunk/; revision=3266 --- camel/ChangeLog | 7 +++++++ camel/camel-service.c | 28 +++++++++++++--------------- 2 files changed, 20 insertions(+), 15 deletions(-) (limited to 'camel') diff --git a/camel/ChangeLog b/camel/ChangeLog index 504676950c..7e8bd613c9 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,10 @@ +2000-05-29 Dan Winship + + * camel-service.c (camel_service_new): Fix up some glib + precondition stuff. Try to set the URL in camel_service_new before + checking whether or not it's "empty" so that you can successfully + set "sendmail:" as a URL. + 2000-05-28 Dan Winship * camel-provider.h: Add a domain field to CamelProvider, to say diff --git a/camel/camel-service.c b/camel/camel-service.c index ae3867643f..885c166a05 100644 --- a/camel/camel-service.c +++ b/camel/camel-service.c @@ -25,6 +25,7 @@ */ #include #include "camel-service.h" +#include "camel-session.h" #include "camel-exception.h" #include @@ -124,15 +125,13 @@ camel_service_new (GtkType type, CamelSession *session, CamelURL *url, { CamelService *service; - g_assert(session); + g_return_val_if_fail (CAMEL_IS_SESSION (session), NULL); service = CAMEL_SERVICE (gtk_object_new (type, NULL)); service->session = session; gtk_object_ref (GTK_OBJECT (session)); - if (!url->empty) { - if (!_set_url (service, url, ex)) - return NULL; - } + if (!_set_url (service, url, ex) && !url->empty) + return NULL; return service; } @@ -150,13 +149,6 @@ camel_service_new (GtkType type, CamelSession *session, CamelURL *url, static gboolean _connect (CamelService *service, CamelException *ex) { - g_assert (service->session); - /* XXX it's possible that this should be an exception - * rather than an assertion... I'm not sure how the code - * is supposed to be used. - */ - g_assert (service->url); - service->connected = TRUE; return TRUE; } @@ -176,6 +168,10 @@ _connect (CamelService *service, CamelException *ex) gboolean camel_service_connect (CamelService *service, CamelException *ex) { + g_return_val_if_fail (CAMEL_IS_SERVICE (service), FALSE); + 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); } @@ -195,8 +191,6 @@ camel_service_connect (CamelService *service, CamelException *ex) static gboolean _connect_with_url (CamelService *service, CamelURL *url, CamelException *ex) { - g_assert (service->session); - if (!_set_url (service, url, ex)) return FALSE; @@ -218,8 +212,12 @@ gboolean camel_service_connect_with_url (CamelService *service, char *url_string, CamelException *ex) { - CamelURL *url = camel_url_new (url_string, 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); -- cgit v1.2.3