static CamelService * get_service (CamelSession *session, const char *url_string, CamelProviderType type, CamelException *ex) { CamelURL *url; CamelProvider *provider; CamelService *service; CamelException internal_ex; url = camel_url_new (url_string, ex); if (!url) return NULL; /* We need to look up the provider so we can then lookup the service in the provider's cache */ provider = camel_provider_get(url->protocol, ex); if (provider && !provider->object_types[type]) { camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID, _("No provider available for protocol `%s'"), url->protocol); provider = NULL; } if (!provider) { camel_url_free (url); return NULL; } /* If the provider doesn't use paths but the URL contains one, * ignore it. */ if (url->path && !CAMEL_PROVIDER_ALLOWS (provider, CAMEL_URL_PART_PATH)) camel_url_set_path (url, NULL); /* Now look up the service in the provider's cache */ // service = camel_object_bag_reserve(provider->service_cache[type], url); // if (service == NULL) { service = (CamelService *)camel_object_new (provider->object_types[type]); camel_exception_init (&internal_ex); camel_service_construct (service, session, provider, url, &internal_ex); if (camel_exception_is_set (&internal_ex)) { camel_exception_xfer (ex, &internal_ex); camel_object_unref (service); service = NULL; // camel_object_bag_abort(provider->service_cache[type], url); } else { // camel_object_bag_add(provider->service_cache[type], url, service); } // } camel_url_free (url); return service; }
static gboolean groupwise_connect_sync (CamelService *service, GCancellable *cancellable, GError **error) { CamelGroupwiseStore *store = CAMEL_GROUPWISE_STORE (service); CamelGroupwiseStorePrivate *priv = store->priv; CamelGroupwiseStoreNamespace *ns; CamelSession *session = service->session; d("in groupwise store connect\n"); if (service->status == CAMEL_SERVICE_DISCONNECTED) return FALSE; if (!priv) { store->priv = g_new0 (CamelGroupwiseStorePrivate, 1); priv = store->priv; camel_service_construct (service, service->session, service->provider, service->url, error); } camel_service_lock (service, CAMEL_SERVICE_REC_CONNECT_LOCK); if (priv->cnc) { camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK); return TRUE; } if (!check_for_connection (service, cancellable, error) || !groupwise_auth_loop (service, cancellable, error)) { camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK); camel_service_disconnect_sync (service, TRUE, NULL); return FALSE; } service->status = CAMEL_SERVICE_CONNECTED; camel_offline_store_set_online_sync ( CAMEL_OFFLINE_STORE (store), TRUE, cancellable, NULL); if (!e_gw_connection_get_version (priv->cnc)) { camel_session_alert_user (session, CAMEL_SESSION_ALERT_WARNING, _("Some features may not work correctly with your current server version"), FALSE); } ns = camel_groupwise_store_summary_namespace_new (store->summary, priv->storage_path, '/'); camel_groupwise_store_summary_namespace_set (store->summary, ns); if (camel_store_summary_count ((CamelStoreSummary *)store->summary) == 0) { /*Settting the refresh stamp to the current time*/ store->refresh_stamp = time (NULL); } camel_store_summary_save ((CamelStoreSummary *) store->summary); camel_service_unlock (service, CAMEL_SERVICE_REC_CONNECT_LOCK); if (E_IS_GW_CONNECTION (priv->cnc)) { return TRUE; } return FALSE; }