diff options
author | Dan Winship <danw@src.gnome.org> | 2000-05-30 03:32:29 +0800 |
---|---|---|
committer | Dan Winship <danw@src.gnome.org> | 2000-05-30 03:32:29 +0800 |
commit | 9f804702d5cfde8b82bb08eb931f408aeee2cbd7 (patch) | |
tree | c7e1e2bf02590719169f09e0b814d2931bd51b4a /camel/camel-service.c | |
parent | ccb665a0262b51c92ca5a54a074dda0dec91a573 (diff) | |
download | gsoc2013-evolution-9f804702d5cfde8b82bb08eb931f408aeee2cbd7.tar.gz gsoc2013-evolution-9f804702d5cfde8b82bb08eb931f408aeee2cbd7.tar.zst gsoc2013-evolution-9f804702d5cfde8b82bb08eb931f408aeee2cbd7.zip |
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
Diffstat (limited to 'camel/camel-service.c')
-rw-r--r-- | camel/camel-service.c | 28 |
1 files changed, 13 insertions, 15 deletions
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); |