aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-02-22 02:38:58 +0800
committerDan Winship <danw@src.gnome.org>2000-02-22 02:38:58 +0800
commitd3d2adb98ce84c89f5e2c648329764d55d8ec412 (patch)
treedf745b058ae76662cef56e168c7afae7a912b045
parenta81eaf4588c2ed0d126e8294e83c0e914e5fb91c (diff)
downloadgsoc2013-evolution-d3d2adb98ce84c89f5e2c648329764d55d8ec412.tar.gz
gsoc2013-evolution-d3d2adb98ce84c89f5e2c648329764d55d8ec412.tar.zst
gsoc2013-evolution-d3d2adb98ce84c89f5e2c648329764d55d8ec412.zip
add CamelExceptions to several functions. Use camel_session_new to
* camel-session.h: * camel-session.c: add CamelExceptions to several functions. Use camel_session_new to initialize the session and URL fields of created CamelStores as appropriate. * camel-store.h: * camel-store.c * camel-service.h: * camel-service.c: Move the session and url (and associated functions) from CamelStore to CamelService. Add url_flags to CamelService so subclasses can specify which URL components are mandatory for them. Add camel_session_new for camel_session_get_store* to use. * providers/mbox/camel-mbox-folder.c: * providers/mbox/camel-mbox-store.c: * providers/mbox/camel-mbox-store.h: Update for above changes. svn path=/trunk/; revision=1888
-rw-r--r--camel/ChangeLog18
-rw-r--r--camel/camel-exception-list.def6
-rw-r--r--camel/camel-service.c163
-rw-r--r--camel/camel-service.h17
-rw-r--r--camel/camel-session.c113
-rw-r--r--camel/camel-session.h8
-rw-r--r--camel/camel-store.c82
-rw-r--r--camel/camel-store.h8
-rw-r--r--camel/providers/mbox/camel-mbox-folder.c4
-rw-r--r--camel/providers/mbox/camel-mbox-store.c55
-rw-r--r--camel/providers/mbox/camel-mbox-store.h5
11 files changed, 266 insertions, 213 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 6043cffb4c..c8ec75d11f 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,23 @@
2000-02-21 Dan Winship <danw@helixcode.com>
+ * camel-session.h:
+ * camel-session.c: add CamelExceptions to several functions. Use
+ camel_session_new to initialize the session and URL fields of
+ created CamelStores as appropriate.
+
+ * camel-store.h:
+ * camel-store.c
+ * camel-service.h:
+ * camel-service.c: Move the session and url (and associated
+ functions) from CamelStore to CamelService. Add url_flags to
+ CamelService so subclasses can specify which URL components
+ are mandatory for them. Add camel_session_new for
+ camel_session_get_store* to use.
+
+ * providers/mbox/camel-mbox-folder.c:
+ * providers/mbox/camel-mbox-store.c:
+ * providers/mbox/camel-mbox-store.h: Update for above changes.
+
* camel-exception-list.def: Once camel is being used for real,
exceptions won't be renumberable. So renumber them now to make
more room to add exceptions to the various categories later, and
diff --git a/camel/camel-exception-list.def b/camel/camel-exception-list.def
index 8e14625c1b..c157d9544c 100644
--- a/camel/camel-exception-list.def
+++ b/camel/camel-exception-list.def
@@ -23,3 +23,9 @@ CAMEL_EXCEPTION_FOLDER_INVALID_UID,
/* CamelStoreException */
CAMEL_EXCEPTION_STORE_NULL = 200,
+CAMEL_EXCEPTION_STORE_INVALID,
+
+/* CamelServiceException */
+CAMEL_EXCEPTION_SERVICE_NULL = 300,
+CAMEL_EXCEPTION_SERVICE_INVALID,
+CAMEL_EXCEPTION_SERVICE_URL_INVALID
diff --git a/camel/camel-service.c b/camel/camel-service.c
index 0b4d2bf853..0bd2b42d01 100644
--- a/camel/camel-service.c
+++ b/camel/camel-service.c
@@ -26,6 +26,7 @@
#include <config.h>
#include "camel-service.h"
#include "camel-log.h"
+#include "camel-exception.h"
static GtkObjectClass *parent_class=NULL;
@@ -38,6 +39,8 @@ static gboolean _connect_with_url (CamelService *service, Gurl *url,
static gboolean _disconnect(CamelService *service, CamelException *ex);
static gboolean _is_connected (CamelService *service);
static void _finalize (GtkObject *object);
+static gboolean _set_url (CamelService *service, Gurl *url,
+ CamelException *ex);
static void
camel_service_class_init (CamelServiceClass *camel_service_class)
@@ -92,27 +95,67 @@ _finalize (GtkObject *object)
if (camel_service->url)
g_url_free (camel_service->url);
+ if (camel_service->session)
+ gtk_object_unref (GTK_OBJECT (camel_service->session));
GTK_OBJECT_CLASS (parent_class)->finalize (object);
CAMEL_LOG_FULL_DEBUG ("Leaving CamelService::finalize\n");
}
+/**
+ * camel_service_new: create a new CamelService or subtype
+ * @type: the GtkType of the class to create
+ * @session: the session for the service
+ * @url: the default URL for the service (may be NULL)
+ * @ex: a CamelException
+ *
+ * Creates a new CamelService (or one of its subtypes), initialized
+ * with the given parameters.
+ *
+ * Return value: the CamelService, or NULL.
+ **/
+CamelService *
+camel_service_new (GtkType type, CamelSession *session, Gurl *url,
+ CamelException *ex)
+{
+ CamelService *service;
+
+ g_assert(session);
+
+ service = CAMEL_SERVICE (gtk_object_new (type, NULL));
+ service->session = session;
+ gtk_object_ref (GTK_OBJECT (session));
+ if (url) {
+ if (!_set_url (service, url, ex))
+ return NULL;
+ }
+
+ return service;
+}
/**
* _connect : connect to a service
+ * @service: object to connect
+ * @ex: a CamelException
*
* connect to the service using the parameters
* stored in the session it is initialized with
- * WARNING: session not implemented for the moment
*
- * @service: object to connect
+ * Return value: whether or not the connection succeeded
**/
static gboolean
_connect (CamelService *service, CamelException *ex)
{
-#warning need to get default URL from somewhere
- return CSERV_CLASS(service)->connect_with_url(service, NULL, 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;
}
@@ -120,11 +163,12 @@ _connect (CamelService *service, CamelException *ex)
/**
* camel_service_connect:connect to a service
* @service: CamelService object
+ * @ex: a CamelException
*
* connect to the service using the parameters
* stored in the session it is initialized with
- * WARNING: session not implemented for the moment
- *
+ *
+ * Return value: whether or not the connection succeeded
**/
gboolean
camel_service_connect (CamelService *service, CamelException *ex)
@@ -136,30 +180,36 @@ camel_service_connect (CamelService *service, CamelException *ex)
/**
* _connect_with_url: connect to the specified address
- *
+ * @service: object to connect
+ * @url: URL describing service to connect to
+ * @ex: a CamelException
+ *
* Connect to the service, but do not use the session
* default parameters to retrieve server's address
*
- * @service: object to connect
- * @url: URL describing service to connect to
+ * Return value: whether or not the connection succeeded
**/
static gboolean
_connect_with_url (CamelService *service, Gurl *url, CamelException *ex)
{
- service->connected = TRUE;
- service->url = url;
+ g_assert (service->session);
- return TRUE;
+ if (!_set_url (service, url, ex))
+ return FALSE;
+
+ return CSERV_CLASS(service)->connect (service, ex);
}
/**
* camel_service_connect_with_url: connect a service
* @service: the service to connect
* @url: URL describing the service to connect to
+ * @ex: a CamelException
*
* Connect to a service, but do not use the session
* default parameters to retrieve server's address
- *
+ *
+ * Return value: whether or not the connection succeeded
**/
gboolean
camel_service_connect_with_url (CamelService *service, char *url,
@@ -173,19 +223,18 @@ camel_service_connect_with_url (CamelService *service, char *url,
/**
* _disconnect : disconnect from a service
+ * @service: object to disconnect
+ * @ex: a CamelException
*
* disconnect from the service
*
- * @service: object to disconnect
+ * Return value: whether or not the disconnection succeeded without
+ * errors. (Consult @ex if FALSE.)
**/
static gboolean
_disconnect (CamelService *service, CamelException *ex)
{
service->connected = FALSE;
- if (service->url) {
- g_url_free(service->url);
- service->url = NULL;
- }
return TRUE;
}
@@ -195,6 +244,12 @@ _disconnect (CamelService *service, CamelException *ex)
/**
* camel_service_disconnect: disconnect from a service
* @service: CamelService object
+ * @ex: a CamelException
+ *
+ * disconnect from the service
+ *
+ * Return value: whether or not the disconnection succeeded without
+ * errors. (Consult @ex if FALSE.)
**/
gboolean
camel_service_disconnect (CamelService *service, CamelException *ex)
@@ -208,7 +263,7 @@ camel_service_disconnect (CamelService *service, CamelException *ex)
* _is_connected: test if the service object is connected
* @service: object to test
*
- * Return value:
+ * Return value: whether or not the service is connected
**/
static gboolean
_is_connected (CamelService *service)
@@ -221,7 +276,7 @@ _is_connected (CamelService *service)
* camel_service_is_connected: test if the service object is connected
* @service: object to test
*
- * Return value:
+ * Return value: whether or not the service is connected
**/
gboolean
camel_service_is_connected (CamelService *service)
@@ -231,18 +286,80 @@ camel_service_is_connected (CamelService *service)
/**
+ * _set_url: Validate a URL and set it as the default for a service
+ * @service: the CamelService
+ * @url_string: the URL
+ * @ex: a CamelException
+ *
+ * This converts the URL to a Gurl, validates it for the service,
+ * and sets it as the default URL for the service.
+ *
+ * Return value: success or failure
+ **/
+static gboolean
+_set_url (CamelService *service, Gurl *url, CamelException *ex)
+{
+ char *url_string;
+
+ if (service->url_flags & CAMEL_SERVICE_URL_NEED_USER &&
+ (url->user == NULL || url->user[0] == '\0')) {
+ url_string = g_url_to_string (url, FALSE);
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID,
+ "URL '%s' needs a username component",
+ url_string);
+ g_free (url_string);
+ return FALSE;
+ } else if (service->url_flags & CAMEL_SERVICE_URL_NEED_HOST &&
+ (url->host == NULL || url->host[0] == '\0')) {
+ url_string = g_url_to_string (url, FALSE);
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID,
+ "URL '%s' needs a host component",
+ url_string);
+ g_free (url_string);
+ return FALSE;
+ } else if (service->url_flags & CAMEL_SERVICE_URL_NEED_PATH &&
+ (url->path == NULL || url->path[0] == '\0')) {
+ url_string = g_url_to_string (url, FALSE);
+ camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID,
+ "URL '%s' needs a path component",
+ url_string);
+ g_free (url_string);
+ return FALSE;
+ }
+
+ if (service->url)
+ g_url_free (service->url);
+ service->url = url;
+ return TRUE;
+}
+
+/**
* camel_service_get_url: get the url representing a service
* @service: the service
*
- * returns the URL representing a service. For security reasons
- * This routine does not return the password.
+ * returns the URL representing a service. The returned URL must be
+ * freed when it is no longer needed. For security reasons, this
+ * routine does not return the password.
*
* Return value: the url name
**/
-gchar *
+char *
camel_service_get_url (CamelService *service)
{
return g_url_to_string(service->url, FALSE);
}
+/**
+ * camel_service_get_session: return the session associated with a service
+ * @service: the service
+ *
+ * returns the CamelSession associated with the service.
+ *
+ * Return value: the session
+ **/
+CamelSession *
+camel_service_get_session (CamelService *service)
+{
+ return service->session;
+}
diff --git a/camel/camel-service.h b/camel/camel-service.h
index fbcbd78d4d..b6d7b70c94 100644
--- a/camel/camel-service.h
+++ b/camel/camel-service.h
@@ -48,8 +48,10 @@ extern "C" {
struct _CamelService {
GtkObject parent_object;
+ CamelSession *session;
gboolean connected;
Gurl *url;
+ int url_flags;
};
@@ -69,13 +71,24 @@ typedef struct {
+/* flags for url_flags. (others can be added if needed) */
+#define CAMEL_SERVICE_URL_NEED_USER (1 << 1)
+#define CAMEL_SERVICE_URL_NEED_HOST (1 << 4)
+#define CAMEL_SERVICE_URL_NEED_PATH (1 << 6)
+
+
/* public methods */
+CamelService *camel_service_new (GtkType type, CamelSession *session,
+ Gurl *url, CamelException *ex);
+
gboolean camel_service_connect (CamelService *service, CamelException *ex);
-gboolean camel_service_connect_with_url (CamelService *service, gchar *url,
+gboolean camel_service_connect_with_url (CamelService *service, char *url,
CamelException *ex);
+gboolean camel_service_disconnect (CamelService *service, CamelException *ex);
gboolean camel_service_is_connected (CamelService *service);
-gchar *camel_service_get_url (CamelService *service);
+char *camel_service_get_url (CamelService *service);
+CamelSession *camel_service_get_session (CamelService *service);
/* Standard Gtk function */
GtkType camel_service_get_type (void);
diff --git a/camel/camel-session.c b/camel/camel-session.c
index ddc74e0be0..cf5db3c57f 100644
--- a/camel/camel-session.c
+++ b/camel/camel-session.c
@@ -26,6 +26,7 @@
#include <config.h>
#include "camel-session.h"
#include "camel-store.h"
+#include "camel-exception.h"
#include "string-utils.h"
#include "url-util.h"
#include "hash-table-utils.h"
@@ -124,94 +125,118 @@ camel_session_set_provider (CamelSession *session, CamelProvider *provider)
* camel_session_get_store_from_provider: create a folder instance for a given provider
* @session: session object the folder will be initialized with
* @provider: provider folder to instantiate
- *
+ * @ex: a CamelException
*
*
* Return value: the newly instantiated store
**/
CamelStore *
-camel_session_get_store_from_provider (CamelSession *session, CamelProvider *provider)
+camel_session_get_store_from_provider (CamelSession *session,
+ CamelProvider *provider,
+ CamelException *ex)
{
- CamelStore *store;
-
g_assert(session);
g_assert(provider);
- store = CAMEL_STORE (gtk_object_new (provider->object_type, NULL));
-#warning set the url to a useful value.
- camel_store_init(store, session, NULL, NULL);
- return store;
+ return CAMEL_STORE (camel_service_new (provider->object_type,
+ session, NULL, ex));
}
+/**
+ * get_store_for_protocol_with_url: private helper routine
+ * @session: CamelSession object
+ * @protocol: protocol name
+ * @url: a URL, or NULL
+ * @ex: a CamelException
+ *
+ * Used by camel_session_get_store_for_protocol and
+ * camel_session_get_store.
+ *
+ * Return value: initialized store associated with this protocol, or NULL if no provider was found.
+ **/
+static CamelStore *
+get_store_for_protocol_with_url (CamelSession *session, const char *protocol,
+ Gurl *url, CamelException *ex)
+{
+ const CamelProvider *provider = NULL;
+
+ /* See if there is a provider assiciated with this
+ * protocol in this session.
+ */
+ provider = CAMEL_PROVIDER (g_hash_table_lookup (session->store_provider_list, protocol));
+ if (!provider) {
+ /* No provider was found in this session. See
+ * if there is a registered provider for this
+ * protocol.
+ */
+ provider = camel_provider_get_for_protocol (protocol, PROVIDER_STORE);
+ }
+ if (!provider)
+ return NULL;
+
+ return CAMEL_STORE (camel_service_new (provider->object_type,
+ session, url, ex));
+}
+
/**
* camel_session_get_store_for_protocol: get the store associated to a protocol
* @session: CamelSession object
* @protocol: protocol name
+ * @ex: a CamelException
*
- * Return a CamelStore object associated to a given
+ * Return a CamelStore object associated with a given
* store protocol. If a provider has been set for this
* protocol in the session @session using
* camel_session_set_provider (), then a store
- * obtained from this provider is return.
- * Otherwise, if one or more provider corresponding
- * to this protocol has been registered (See
+ * obtained from this provider is returned.
+ * Otherwise, if one or more providers corresponding
+ * to this protocol have been registered (See
* camel_provider_register_as_module), the last registered
* one is used.
*
- * Return value: store associated to this protocol or NULL if no provider was found.
+ * Return value: store associated with this protocol, or NULL if no provider was found.
**/
CamelStore *
-camel_session_get_store_for_protocol (CamelSession *session, const gchar *protocol)
+camel_session_get_store_for_protocol (CamelSession *session,
+ const char *protocol,
+ CamelException *ex)
{
- const CamelProvider *provider = NULL;
- CamelStore *new_store;
-
- /* look if there is a provider assiciated to this
- protocol in this session */
- provider = CAMEL_PROVIDER (g_hash_table_lookup (session->store_provider_list, protocol));
- if (!provider)
- /* no provider was found in this session, look
- if there is a registered provider for this
- protocol */
- provider = camel_provider_get_for_protocol (protocol, PROVIDER_STORE);
-
- if (!provider) return NULL;
-
- new_store = (CamelStore *)gtk_type_new (provider->object_type);
- return new_store;
+ return get_store_for_protocol_with_url (session, protocol, NULL, ex);
}
-
/**
* camel_session_get_store: get a store object for an URL
* @session: session object
- * @url_string: url
+ * @url_string: url
+ * @ex: a CamelException
*
* return a store corresponding to an URL.
*
* Return value: the store, or NULL if no provider correponds to the protocol
**/
CamelStore *
-camel_session_get_store (CamelSession *session, const gchar *url_string)
+camel_session_get_store (CamelSession *session, const char *url_string,
+ CamelException *ex)
{
- Gurl *url = NULL;
- CamelStore *new_store = NULL;
+ Gurl *url;
+ CamelStore *store;
url = g_url_new (url_string);
- g_return_val_if_fail (url, NULL);
-
- if (url->protocol) {
- new_store = camel_session_get_store_for_protocol (session, url->protocol);
- if (new_store)
- camel_store_init (new_store, session, url_string, NULL);
+ if (url == NULL || url->protocol == NULL) {
+ camel_exception_setv(ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID,
+ "Could not determine protocol for "
+ "URL '%s'", url_string);
+ return NULL;
}
- g_url_free (url);
- return new_store;
-
+ store = get_store_for_protocol_with_url (session, url->protocol,
+ url, ex);
+ if (store == NULL)
+ g_url_free (url);
+ return store;
}
diff --git a/camel/camel-session.h b/camel/camel-session.h
index 1dc234fb7f..0b65326323 100644
--- a/camel/camel-session.h
+++ b/camel/camel-session.h
@@ -73,8 +73,12 @@ GtkType camel_session_get_type (void);
CamelSession *camel_session_new (void);
void camel_session_set_provider (CamelSession *session, CamelProvider *provider);
-CamelStore *camel_session_get_store_for_protocol (CamelSession *session, const gchar *protocol);
-CamelStore *camel_session_get_store (CamelSession *session, const gchar *url_string);
+CamelStore *camel_session_get_store_for_protocol (CamelSession *session,
+ const gchar *protocol,
+ CamelException *ex);
+CamelStore *camel_session_get_store (CamelSession *session,
+ const char *url_string,
+ CamelException *ex);
#ifdef __cplusplus
diff --git a/camel/camel-store.c b/camel/camel-store.c
index 1938fcbd3f..dee1ef295c 100644
--- a/camel/camel-store.c
+++ b/camel/camel-store.c
@@ -36,29 +36,21 @@ static CamelServiceClass *parent_class = NULL;
static void _set_separator(CamelStore *store, gchar sep, CamelException *ex);
static CamelFolder *_get_root_folder(CamelStore *store, CamelException *ex);
static CamelFolder *_get_default_folder(CamelStore *store, CamelException *ex);
-static void _init(CamelStore *store, CamelSession *session, const gchar *url_name, CamelException *ex);
static CamelFolder *_get_folder (CamelStore *store, const gchar *folder_name, CamelException *ex);
static gchar _get_separator (CamelStore *store, CamelException *ex);
-static void _finalize (GtkObject *object);
-
static void
camel_store_class_init (CamelStoreClass *camel_store_class)
{
- GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (camel_store_class);
parent_class = gtk_type_class (camel_service_get_type ());
/* virtual method definition */
- camel_store_class->init = _init;
camel_store_class->set_separator = _set_separator;
camel_store_class->get_separator = _get_separator;
camel_store_class->get_folder = _get_folder;
camel_store_class->get_root_folder = _get_root_folder;
camel_store_class->get_default_folder = _get_default_folder;
-
- /* virtual method overload */
- gtk_object_class->finalize = _finalize;
}
@@ -94,65 +86,6 @@ camel_store_get_type (void)
-
-/**
- * camel_store_init: call store's init method
- * @store: the store to initialize
- * @session: session which instantiates the store
- * @url_name: URL defining the store
- *
- * This routine is called by the session object from which this
- * store is created. It must not be called directly.
- *
- **/
-void
-camel_store_init (CamelStore *store, CamelSession *session, const gchar *url_name, CamelException *ex)
-{
- g_assert(store);
- CS_CLASS(store)->init (store, session, url_name, ex);
-}
-
-
-/**
- * init: method called by a session object to initialize a store object
- * @store: the store to initialize
- * @session: session which instantiates the store
- * @url_name: URL defining the store
- *
- * This routine is called by the session object from which this
- * store is created. Be careful, @url_name is used as a private field
- * of the store object.
- *
- **/
-static void
-_init (CamelStore *store, CamelSession *session, const gchar *url_name, CamelException *ex)
-{
-
-#warning re-enable assertion here.
- g_assert(session);
- g_assert(url_name);
-
- store->session = session;
- gtk_object_ref (GTK_OBJECT (session));
- /*store->url_name = url_name;*/
-}
-
-
-static void
-_finalize (GtkObject *object)
-{
- CamelStore *camel_store = CAMEL_STORE (object);
- CAMEL_LOG_FULL_DEBUG ("Entering CamelStore::finalize\n");
-
- /* if (camel_store->url_name) g_free (camel_store->url_name); */
- if (camel_store->session) gtk_object_unref (GTK_OBJECT (camel_store->session));
-
- GTK_OBJECT_CLASS (parent_class)->finalize (object);
- CAMEL_LOG_FULL_DEBUG ("Leaving CamelStore::finalize\n");
-}
-
-
-
/**
* camel_store_set_separator: set the character which separates this folder path from the folders names in a lower level of hierarchy.
*
@@ -259,18 +192,3 @@ _get_default_folder (CamelStore *store, CamelException *ex)
{
return NULL;
}
-
-
-CamelSession *
-camel_store_get_session (CamelStore *store, CamelException *ex)
-{
- if (!store) {
- camel_exception_set (ex,
- CAMEL_EXCEPTION_STORE_NULL,
- "Store is NULL");
- return NULL;
- }
-
- return store->session;
-}
-
diff --git a/camel/camel-store.h b/camel/camel-store.h
index 588e467d53..d9ffb74b74 100644
--- a/camel/camel-store.h
+++ b/camel/camel-store.h
@@ -48,8 +48,6 @@ struct _CamelStore
{
CamelService parent_object;
- CamelSession *session;
- /* gchar *url_name; */
gchar separator;
};
@@ -58,10 +56,6 @@ struct _CamelStore
typedef struct {
CamelServiceClass parent_class;
- void (*init) (CamelStore *store,
- CamelSession *session,
- const gchar *url_name,
- CamelException *ex);
void (*set_separator) (CamelStore *store, gchar sep,
CamelException *ex);
gchar (*get_separator) (CamelStore *store,
@@ -82,10 +76,8 @@ typedef struct {
/* Standard Gtk function */
GtkType camel_store_get_type (void);
-void camel_store_init (CamelStore *store, CamelSession *session, const gchar *url_name, CamelException *ex);
CamelFolder * camel_store_get_folder (CamelStore *store, const gchar *folder_name, CamelException *ex);
gchar camel_store_get_separator (CamelStore *store, CamelException *ex);
-CamelSession * camel_store_get_session (CamelStore *store, CamelException *ex);
#ifdef __cplusplus
}
diff --git a/camel/providers/mbox/camel-mbox-folder.c b/camel/providers/mbox/camel-mbox-folder.c
index fb5c5a9299..ad899090dc 100644
--- a/camel/providers/mbox/camel-mbox-folder.c
+++ b/camel/providers/mbox/camel-mbox-folder.c
@@ -362,7 +362,7 @@ _set_name (CamelFolder *folder, const gchar *name, CamelException *ex)
g_free (mbox_folder->index_file_path);
separator = camel_store_get_separator (folder->parent_store, ex);
- root_dir_path = camel_mbox_store_get_toplevel_dir (CAMEL_MBOX_STORE(folder->parent_store), ex);
+ root_dir_path = camel_mbox_store_get_toplevel_dir (CAMEL_MBOX_STORE(folder->parent_store));
CAMEL_LOG_FULL_DEBUG ("CamelMboxFolder::set_name full_name is %s\n", folder->full_name);
CAMEL_LOG_FULL_DEBUG ("CamelMboxFolder::set_name root_dir_path is %s\n", root_dir_path);
@@ -1112,7 +1112,7 @@ _get_message_by_uid (CamelFolder *folder, const gchar *uid, CamelException *ex)
}
- message = camel_mime_message_new_with_session (camel_store_get_session (parent_store, ex));
+ message = camel_mime_message_new_with_session (camel_service_get_session (CAMEL_SERVICE (parent_store)));
camel_data_wrapper_construct_from_stream (CAMEL_DATA_WRAPPER (message), message_stream);
diff --git a/camel/providers/mbox/camel-mbox-store.c b/camel/providers/mbox/camel-mbox-store.c
index 12923b1b5a..9c5e889aa7 100644
--- a/camel/providers/mbox/camel-mbox-store.c
+++ b/camel/providers/mbox/camel-mbox-store.c
@@ -23,16 +23,14 @@
#include "camel-mbox-store.h"
#include "camel-mbox-folder.h"
+#include "camel-exception.h"
#include "url-util.h"
-static CamelStoreClass *parent_class=NULL;
-
/* Returns the class for a CamelMboxStore */
#define CMBOXS_CLASS(so) CAMEL_MBOX_STORE_CLASS (GTK_OBJECT(so)->klass)
#define CF_CLASS(so) CAMEL_FOLDER_CLASS (GTK_OBJECT(so)->klass)
#define CMBOXF_CLASS(so) CAMEL_MBOX_FOLDER_CLASS (GTK_OBJECT(so)->klass)
-static void _init (CamelStore *store, CamelSession *session, const gchar *url_name, CamelException *ex);
static CamelFolder *_get_folder (CamelStore *store, const gchar *folder_name, CamelException *ex);
@@ -40,12 +38,8 @@ static void
camel_mbox_store_class_init (CamelMboxStoreClass *camel_mbox_store_class)
{
CamelStoreClass *camel_store_class = CAMEL_STORE_CLASS (camel_mbox_store_class);
-
- parent_class = gtk_type_class (camel_store_get_type ());
- /* virtual method definition */
/* virtual method overload */
- camel_store_class->init = _init;
camel_store_class->get_folder = _get_folder;
}
@@ -55,8 +49,10 @@ static void
camel_mbox_store_init (gpointer object, gpointer klass)
{
CamelStore *store = CAMEL_STORE (object);
-
+ CamelService *service = CAMEL_SERVICE (object);
+
store->separator = '/';
+ service->url_flags = CAMEL_SERVICE_URL_NEED_PATH;
}
@@ -87,50 +83,17 @@ camel_mbox_store_get_type (void)
}
-
-
-/* These evil public functions are here for test only */
-void
-camel_mbox_store_set_toplevel_dir (CamelMboxStore *store, const gchar *toplevel, CamelException *ex)
-{
- store->toplevel_dir = g_strdup (toplevel);
- CAMEL_STORE(store)->separator = '/';
-}
-
-
const gchar *
-camel_mbox_store_get_toplevel_dir (CamelMboxStore *store, CamelException *ex)
+camel_mbox_store_get_toplevel_dir (CamelMboxStore *store)
{
- return store->toplevel_dir;
-}
-
+ Gurl *url = CAMEL_SERVICE (store)->url;
-
-static void
-_init (CamelStore *store, CamelSession *session, const gchar *url_name, CamelException *ex)
-{
- CamelMboxStore *mbox_store = CAMEL_MBOX_STORE (store);
- Gurl *store_url;
-
- g_assert (url_name);
- /* call parent implementation */
- parent_class->init (store, session, url_name, ex);
-
-
- /* find the path in the URL*/
- store_url = g_url_new (url_name);
-
- g_return_if_fail (store_url);
- g_return_if_fail (store_url->path);
-
- mbox_store->toplevel_dir = g_strdup (store_url->path);
- g_url_free (store_url);
-
-
-
+ g_assert(url != NULL);
+ return url->path;
}
+
static CamelFolder *
_get_folder (CamelStore *store, const gchar *folder_name, CamelException *ex)
{
diff --git a/camel/providers/mbox/camel-mbox-store.h b/camel/providers/mbox/camel-mbox-store.h
index a5aea965e2..e33688066f 100644
--- a/camel/providers/mbox/camel-mbox-store.h
+++ b/camel/providers/mbox/camel-mbox-store.h
@@ -43,7 +43,6 @@ extern "C" {
typedef struct {
CamelStore parent_object;
- gchar *toplevel_dir;
} CamelMboxStore;
@@ -51,7 +50,6 @@ typedef struct {
typedef struct {
CamelStoreClass parent_class;
-
} CamelMboxStoreClass;
@@ -60,8 +58,7 @@ typedef struct {
/* Standard Gtk function */
GtkType camel_mbox_store_get_type (void);
-void camel_mbox_store_set_toplevel_dir (CamelMboxStore *store, const gchar *toplevel, CamelException *ex);
-const gchar *camel_mbox_store_get_toplevel_dir (CamelMboxStore *store, CamelException *ex);
+const gchar *camel_mbox_store_get_toplevel_dir (CamelMboxStore *store);
#ifdef __cplusplus
}