diff options
author | Peter Williams <peterw@src.gnome.org> | 2000-08-30 05:28:46 +0800 |
---|---|---|
committer | Peter Williams <peterw@src.gnome.org> | 2000-08-30 05:28:46 +0800 |
commit | da570c66609a9baea34d4899c4ca7e1f8329d471 (patch) | |
tree | 78f82074f39463fc8db0cfb92728d57fe9c2ac84 /camel/camel-service.c | |
parent | ba2eaa68b17882b0fec2eac160f674d29598795f (diff) | |
download | gsoc2013-evolution-da570c66609a9baea34d4899c4ca7e1f8329d471.tar gsoc2013-evolution-da570c66609a9baea34d4899c4ca7e1f8329d471.tar.gz gsoc2013-evolution-da570c66609a9baea34d4899c4ca7e1f8329d471.tar.bz2 gsoc2013-evolution-da570c66609a9baea34d4899c4ca7e1f8329d471.tar.lz gsoc2013-evolution-da570c66609a9baea34d4899c4ca7e1f8329d471.tar.xz gsoc2013-evolution-da570c66609a9baea34d4899c4ca7e1f8329d471.tar.zst gsoc2013-evolution-da570c66609a9baea34d4899c4ca7e1f8329d471.zip |
CamelRemoteStore: a new generic store for stores that connect to servers. Prepare for the ability to cancel operations (much better exception handling). Clean up IMAP like nobody's business
svn path=/trunk/; revision=5103
Diffstat (limited to 'camel/camel-service.c')
-rw-r--r-- | camel/camel-service.c | 79 |
1 files changed, 48 insertions, 31 deletions
diff --git a/camel/camel-service.c b/camel/camel-service.c index 6554bad5cb..9df7837bf7 100644 --- a/camel/camel-service.c +++ b/camel/camel-service.c @@ -151,8 +151,8 @@ check_url (CamelService *service, CamelException *ex) * Return value: the CamelService, or NULL. **/ CamelService * -camel_service_new (CamelType type, CamelSession *session, CamelURL *url, - CamelException *ex) +camel_service_new (CamelType type, CamelSession *session, CamelProvider *provider, + CamelURL *url, CamelException *ex) { CamelService *service; @@ -171,6 +171,9 @@ camel_service_new (CamelType type, CamelSession *session, CamelURL *url, service->session = session; camel_object_ref (CAMEL_OBJECT (session)); + service->provider = provider; + /* don't ref -- providers are not CamelObjects */ + service->connected = FALSE; if (!url->empty) { @@ -205,22 +208,24 @@ service_connect (CamelService *service, CamelException *ex) * * Return value: whether or not the connection succeeded **/ -/** - *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); - * - * if (service->connect_level > 0) { - * service->connect_level++; - * return TRUE; - * } - * - * return CSERV_CLASS (service)->connect (service, 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); + + if (service->connected) { + /* But we're still connected, so no exception + * and return true. + */ + g_warning ("camel_service_connect: trying to connect to an already connected service"); + return TRUE; + } + + return CSERV_CLASS (service)->connect (service, ex); +} static gboolean service_disconnect (CamelService *service, CamelException *ex) @@ -244,19 +249,18 @@ service_disconnect (CamelService *service, CamelException *ex) * Return value: whether or not the disconnection succeeded without * errors. (Consult @ex if %FALSE.) **/ -/** - *gboolean - *camel_service_disconnect (CamelService *service, CamelException *ex) - *{ - * if (service->connect_level < 1) { - * camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_NOT_CONNECTED, - * "Trying to disconnect from a service that isn't connected"); - * return FALSE; - * } - * - * return CSERV_CLASS (service)->disconnect (service, ex); - *} - **/ + +gboolean +camel_service_disconnect (CamelService *service, CamelException *ex) +{ + if (!service->connected) { + camel_exception_set (ex, CAMEL_EXCEPTION_SERVICE_NOT_CONNECTED, + "Trying to disconnect from a service that isn't connected"); + return FALSE; + } + + return CSERV_CLASS (service)->disconnect (service, ex); +} /** *static gboolean @@ -341,6 +345,19 @@ camel_service_get_session (CamelService *service) return service->session; } +/** + * camel_service_get_provider: + * @service: a service + * + * Returns the CamelProvider associated with the service. + * + * Return value: the provider + **/ +CamelProvider * +camel_service_get_provider (CamelService *service) +{ + return service->provider; +} GList * query_auth_types_func (CamelService *service, CamelException *ex) |