diff options
-rw-r--r-- | camel/ChangeLog | 7 | ||||
-rw-r--r-- | camel/camel-service.c | 28 |
2 files changed, 20 insertions, 15 deletions
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 <danw@helixcode.com> + + * 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 <danw@helixcode.com> * 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 <config.h> #include "camel-service.h" +#include "camel-session.h" #include "camel-exception.h" #include <ctype.h> @@ -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); |