aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2001-02-10 00:43:22 +0800
committerDan Winship <danw@src.gnome.org>2001-02-10 00:43:22 +0800
commit65eb577ecd2ce45f78f8df4da3386e2ac1f3c2c1 (patch)
tree1b71a69279b3130cab4dc333dd6a68d324ea4985 /camel/providers
parent154d1b95c85bc8888bae6b64a4f2ba040fe869b4 (diff)
downloadgsoc2013-evolution-65eb577ecd2ce45f78f8df4da3386e2ac1f3c2c1.tar
gsoc2013-evolution-65eb577ecd2ce45f78f8df4da3386e2ac1f3c2c1.tar.gz
gsoc2013-evolution-65eb577ecd2ce45f78f8df4da3386e2ac1f3c2c1.tar.bz2
gsoc2013-evolution-65eb577ecd2ce45f78f8df4da3386e2ac1f3c2c1.tar.lz
gsoc2013-evolution-65eb577ecd2ce45f78f8df4da3386e2ac1f3c2c1.tar.xz
gsoc2013-evolution-65eb577ecd2ce45f78f8df4da3386e2ac1f3c2c1.tar.zst
gsoc2013-evolution-65eb577ecd2ce45f78f8df4da3386e2ac1f3c2c1.zip
Rewrite a bunch. Replace the existing folder cache stuff with much simpler
* camel-store.c: Rewrite a bunch. Replace the existing folder cache stuff with much simpler code that still handles all the existing cases. Now the folder hash table is always created by the base class, using hash and compare functions provided by the class implementation. (If they are set to NULL, CamelStore won't cache folders.) lookup_folder, cache_folder, and uncache_folder are no longer class methods, and get_name is gone completely. (camel_store_get_inbox): Renamed from camel_store_get_default_folder, since that wasn't being used, and this is what we actually need. (camel_store_get_root_folder): Removed, since it's not needed for anything given get_folder_info. * camel-remote-store.c: * providers/local/camel-local-store.c: * providers/local/camel-mbox-store.c: * providers/local/camel-mh-store.c: * providers/local/camel-maildir-store.c: * providers/nntp/camel-nntp-store.c: * providers/pop3/camel-pop3-store.c: * providers/vee/camel-vee-store.c: Minor updates for CamelStore changes * providers/imap/camel-imap-store.c (camel_imap_store_class_init): Update for CamelStore changes. (hash_folder_name, compare_folder_name): treat INBOX case-insensitively, otherwise use g_str_hash and g_str_equal. * camel-service.c (camel_service_construct): Remove camel_service_new and create camel_service_construct (as a class method) in its place. * camel-session.c (camel_session_get_service): Use camel_object_new and camel_service_construct to replace camel_service_new. * providers/local/camel-local-store.c (construct): Append a '/' to the URL path if it doesn't end with one svn path=/trunk/; revision=8145
Diffstat (limited to 'camel/providers')
-rw-r--r--camel/providers/imap/camel-imap-store.c47
-rw-r--r--camel/providers/local/camel-local-store.c72
-rw-r--r--camel/providers/local/camel-maildir-store.c10
-rw-r--r--camel/providers/local/camel-mbox-store.c11
-rw-r--r--camel/providers/local/camel-mh-store.c10
-rw-r--r--camel/providers/nntp/camel-nntp-store.c7
-rw-r--r--camel/providers/pop3/camel-pop3-store.c26
-rw-r--r--camel/providers/vee/camel-vee-store.c9
8 files changed, 58 insertions, 134 deletions
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
index cd46d56226..f19d8feb31 100644
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@ -60,10 +60,9 @@ static CamelRemoteStoreClass *remote_store_class = NULL;
static gboolean imap_connect (CamelService *service, CamelException *ex);
static gboolean imap_disconnect (CamelService *service, gboolean clean, CamelException *ex);
static GList *query_auth_types (CamelService *service, gboolean connect, CamelException *ex);
+static guint hash_folder_name (gconstpointer key);
+static gint compare_folder_name (gconstpointer a, gconstpointer b);
static CamelFolder *get_folder (CamelStore *store, const char *folder_name, guint32 flags, CamelException *ex);
-static char *get_folder_name (CamelStore *store, const char *folder_name,
- CamelException *ex);
-static char *get_root_folder_name (CamelStore *store, CamelException *ex);
static CamelFolderInfo *get_folder_info (CamelStore *store, const char *top,
gboolean fast, gboolean recursive,
gboolean subscribed_only,
@@ -94,9 +93,9 @@ camel_imap_store_class_init (CamelImapStoreClass *camel_imap_store_class)
camel_service_class->connect = imap_connect;
camel_service_class->disconnect = imap_disconnect;
+ camel_store_class->hash_folder_name = hash_folder_name;
+ camel_store_class->compare_folder_name = compare_folder_name;
camel_store_class->get_folder = get_folder;
- camel_store_class->get_folder_name = get_folder_name;
- camel_store_class->get_root_folder_name = get_root_folder_name;
camel_store_class->get_folder_info = get_folder_info;
camel_store_class->free_folder_info = camel_store_free_folder_info_full;
@@ -603,6 +602,27 @@ imap_create (CamelImapStore *store, const char *folder_name,
return !camel_exception_is_set (ex);
}
+static guint
+hash_folder_name (gconstpointer key)
+{
+ if (g_strcasecmp (key, "INBOX") == 0)
+ return g_str_hash ("INBOX");
+ else
+ return g_str_hash (key);
+}
+
+static gint
+compare_folder_name (gconstpointer a, gconstpointer b)
+{
+ gconstpointer aname = a, bname = b;
+
+ if (g_strcasecmp (a, "INBOX") == 0)
+ aname = "INBOX";
+ if (g_strcasecmp (b, "INBOX") == 0)
+ bname = "INBOX";
+ return g_str_equal (aname, bname);
+}
+
static CamelFolder *
get_folder (CamelStore *store, const char *folder_name, guint32 flags,
CamelException *ex)
@@ -661,23 +681,6 @@ get_folder (CamelStore *store, const char *folder_name, guint32 flags,
return new_folder;
}
-static char *
-get_folder_name (CamelStore *store, const char *folder_name,
- CamelException *ex)
-{
- /* INBOX is case-insensitive */
- if (g_strcasecmp (folder_name, "INBOX") == 0)
- return g_strdup ("INBOX");
- else
- return g_strdup (folder_name);
-}
-
-static char *
-get_root_folder_name (CamelStore *store, CamelException *ex)
-{
- return g_strdup ("");
-}
-
static CamelFolderInfo *
parse_list_response_as_folder_info (CamelImapStore *imap_store,
const char *response)
diff --git a/camel/providers/local/camel-local-store.c b/camel/providers/local/camel-local-store.c
index 9af9df2744..b6ea31a98f 100644
--- a/camel/providers/local/camel-local-store.c
+++ b/camel/providers/local/camel-local-store.c
@@ -39,12 +39,11 @@
#define CLOCALS_CLASS(so) CAMEL_LOCAL_STORE_CLASS (CAMEL_OBJECT_GET_CLASS(so))
#define CF_CLASS(so) CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(so))
+static void construct (CamelService *service, CamelSession *session, CamelProvider *provider, CamelURL *url, CamelException *ex);
static CamelFolder *get_folder(CamelStore * store, const char *folder_name, guint32 flags, CamelException * ex);
static char *get_name(CamelService *service, gboolean brief);
-static char *get_root_folder_name (CamelStore *store, CamelException *ex);
-static char *get_default_folder_name (CamelStore *store, CamelException *ex);
+static CamelFolder *get_inbox (CamelStore *store, CamelException *ex);
static void rename_folder(CamelStore *store, const char *old_name, const char *new_name, CamelException *ex);
-static char *get_folder_name(CamelStore *store, const char *folder_name, CamelException *ex);
static CamelFolderInfo *get_folder_info (CamelStore *store, const char *top,
gboolean fast, gboolean recursive,
gboolean subscribed_only,
@@ -52,18 +51,21 @@ static CamelFolderInfo *get_folder_info (CamelStore *store, const char *top,
static void delete_folder(CamelStore *store, const char *folder_name, CamelException *ex);
static void rename_folder(CamelStore *store, const char *old, const char *new, CamelException *ex);
+static CamelStoreClass *parent_class = NULL;
+
static void
camel_local_store_class_init (CamelLocalStoreClass *camel_local_store_class)
{
CamelStoreClass *camel_store_class = CAMEL_STORE_CLASS (camel_local_store_class);
CamelServiceClass *camel_service_class = CAMEL_SERVICE_CLASS (camel_local_store_class);
+ parent_class = CAMEL_STORE_CLASS (camel_type_get_global_classfuncs (camel_store_get_type ()));
+
/* virtual method overload */
+ camel_service_class->construct = construct;
camel_service_class->get_name = get_name;
camel_store_class->get_folder = get_folder;
- camel_store_class->get_root_folder_name = get_root_folder_name;
- camel_store_class->get_default_folder_name = get_default_folder_name;
- camel_store_class->get_folder_name = get_folder_name;
+ camel_store_class->get_inbox = get_inbox;
camel_store_class->get_folder_info = get_folder_info;
camel_store_class->free_folder_info = camel_store_free_folder_info_full;
@@ -71,18 +73,6 @@ camel_local_store_class_init (CamelLocalStoreClass *camel_local_store_class)
camel_store_class->rename_folder = rename_folder;
}
-static void
-camel_local_store_init (gpointer object, gpointer klass)
-{
- CamelStore *store = CAMEL_STORE (object);
-
- /* local names are filenames, so they are case-sensitive. */
- if (store->folders)
- g_hash_table_destroy(store->folders);
-
- store->folders = g_hash_table_new (g_str_hash, g_str_equal);
-}
-
CamelType
camel_local_store_get_type (void)
{
@@ -94,13 +84,29 @@ camel_local_store_get_type (void)
sizeof (CamelLocalStoreClass),
(CamelObjectClassInitFunc) camel_local_store_class_init,
NULL,
- (CamelObjectInitFunc) camel_local_store_init,
+ NULL,
NULL);
}
return camel_local_store_type;
}
+static void
+construct (CamelService *service, CamelSession *session, CamelProvider *provider, CamelURL *url, CamelException *ex)
+{
+ int len;
+
+ CAMEL_SERVICE_CLASS (parent_class)->construct (service, session, provider, url, ex);
+ if (camel_exception_is_set (ex))
+ return;
+
+ len = strlen (service->url->path);
+ if (service->url->path[len - 1] != '/') {
+ service->url->path = g_realloc (service->url->path, len + 2);
+ strcpy (service->url->path + len, "/");
+ }
+}
+
const char *
camel_local_store_get_toplevel_dir (CamelLocalStore *store)
{
@@ -161,37 +167,15 @@ get_folder(CamelStore * store, const char *folder_name, guint32 flags, CamelExce
return NULL;
}
-static char *
-get_root_folder_name(CamelStore *store, CamelException *ex)
-{
- camel_exception_set(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("Local stores do not have a root folder"));
- return NULL;
-}
-
-static char *
-get_default_folder_name(CamelStore *store, CamelException *ex)
+static CamelFolder *
+get_inbox(CamelStore *store, CamelException *ex)
{
camel_exception_set(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("Local stores do not have a default folder"));
+ _("Local stores do not have an inbox"));
return NULL;
}
static char *
-get_folder_name (CamelStore *store, const char *folder_name, CamelException *ex)
-{
- /* For now, we don't allow hieararchy. FIXME. */
- if (strchr (folder_name + 1, '/')) {
- camel_exception_set (ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("Local folders may not be nested."));
- return NULL;
- }
-
- return *folder_name == '/' ? g_strdup (folder_name) :
- g_strdup_printf ("/%s", folder_name);
-}
-
-static char *
get_name (CamelService *service, gboolean brief)
{
if (brief)
diff --git a/camel/providers/local/camel-maildir-store.c b/camel/providers/local/camel-maildir-store.c
index f5bd353b6f..d419095ea0 100644
--- a/camel/providers/local/camel-maildir-store.c
+++ b/camel/providers/local/camel-maildir-store.c
@@ -56,14 +56,6 @@ static void camel_maildir_store_class_init(CamelObjectClass * camel_maildir_stor
camel_store_class->delete_folder = delete_folder;
}
-static void camel_maildir_store_init(CamelObject * object)
-{
- CamelStore *store = CAMEL_STORE(object);
-
- /* maildir names are filenames, so they are case-sensitive. */
- store->folders = g_hash_table_new(g_str_hash, g_str_equal);
-}
-
CamelType camel_maildir_store_get_type(void)
{
static CamelType camel_maildir_store_type = CAMEL_INVALID_TYPE;
@@ -74,7 +66,7 @@ CamelType camel_maildir_store_get_type(void)
sizeof(CamelMaildirStoreClass),
(CamelObjectClassInitFunc) camel_maildir_store_class_init,
NULL,
- (CamelObjectInitFunc) camel_maildir_store_init,
+ NULL,
NULL);
}
diff --git a/camel/providers/local/camel-mbox-store.c b/camel/providers/local/camel-mbox-store.c
index 8ae0891b31..c6ddc7ce0a 100644
--- a/camel/providers/local/camel-mbox-store.c
+++ b/camel/providers/local/camel-mbox-store.c
@@ -54,15 +54,6 @@ camel_mbox_store_class_init (CamelMboxStoreClass *camel_mbox_store_class)
camel_store_class->delete_folder = delete_folder;
}
-static void
-camel_mbox_store_init (gpointer object, gpointer klass)
-{
- CamelStore *store = CAMEL_STORE (object);
-
- /* mbox names are filenames, so they are case-sensitive. */
- store->folders = g_hash_table_new (g_str_hash, g_str_equal);
-}
-
CamelType
camel_mbox_store_get_type (void)
{
@@ -74,7 +65,7 @@ camel_mbox_store_get_type (void)
sizeof (CamelMboxStoreClass),
(CamelObjectClassInitFunc) camel_mbox_store_class_init,
NULL,
- (CamelObjectInitFunc) camel_mbox_store_init,
+ NULL,
NULL);
}
diff --git a/camel/providers/local/camel-mh-store.c b/camel/providers/local/camel-mh-store.c
index 3d637e4cad..a488a71c12 100644
--- a/camel/providers/local/camel-mh-store.c
+++ b/camel/providers/local/camel-mh-store.c
@@ -54,14 +54,6 @@ static void camel_mh_store_class_init(CamelObjectClass * camel_mh_store_class)
camel_store_class->delete_folder = delete_folder;
}
-static void camel_mh_store_init(CamelObject * object)
-{
- CamelStore *store = CAMEL_STORE(object);
-
- /* mh names are filenames, so they are case-sensitive. */
- store->folders = g_hash_table_new(g_str_hash, g_str_equal);
-}
-
CamelType camel_mh_store_get_type(void)
{
static CamelType camel_mh_store_type = CAMEL_INVALID_TYPE;
@@ -72,7 +64,7 @@ CamelType camel_mh_store_get_type(void)
sizeof(CamelMhStoreClass),
(CamelObjectClassInitFunc) camel_mh_store_class_init,
NULL,
- (CamelObjectInitFunc) camel_mh_store_init,
+ NULL,
NULL);
}
diff --git a/camel/providers/nntp/camel-nntp-store.c b/camel/providers/nntp/camel-nntp-store.c
index 8edf05e099..c1e8fb81e8 100644
--- a/camel/providers/nntp/camel-nntp-store.c
+++ b/camel/providers/nntp/camel-nntp-store.c
@@ -543,12 +543,6 @@ nntp_store_get_folder_info (CamelStore *store, const char *top,
}
}
-static char *
-nntp_store_get_root_folder_name (CamelStore *store, CamelException *ex)
-{
- return g_strdup ("");
-}
-
static gboolean
nntp_store_folder_subscribed (CamelStore *store, const char *folder_name)
{
@@ -601,7 +595,6 @@ camel_nntp_store_class_init (CamelNNTPStoreClass *camel_nntp_store_class)
camel_service_class->get_name = nntp_store_get_name;
camel_store_class->get_folder = nntp_store_get_folder;
- camel_store_class->get_root_folder_name = nntp_store_get_root_folder_name;
camel_store_class->get_folder_info = nntp_store_get_folder_info;
camel_store_class->free_folder_info = camel_store_free_folder_info_full;
diff --git a/camel/providers/pop3/camel-pop3-store.c b/camel/providers/pop3/camel-pop3-store.c
index f0338a8584..fac9cae931 100644
--- a/camel/providers/pop3/camel-pop3-store.c
+++ b/camel/providers/pop3/camel-pop3-store.c
@@ -76,9 +76,6 @@ static GList *query_auth_types (CamelService *service, gboolean connect, CamelEx
static CamelFolder *get_folder (CamelStore *store, const char *folder_name,
guint32 flags, CamelException *ex);
-static char *get_folder_name (CamelStore *store, const char *folder_name,
- CamelException *ex);
-static char *get_root_folder_name (CamelStore *store, CamelException *ex);
static int pop3_get_response (CamelPop3Store *store, char **ret, CamelException *ex);
@@ -90,9 +87,6 @@ camel_pop3_store_class_init (CamelPop3StoreClass *camel_pop3_store_class)
CAMEL_SERVICE_CLASS (camel_pop3_store_class);
CamelStoreClass *camel_store_class =
CAMEL_STORE_CLASS (camel_pop3_store_class);
- /*CamelRemoteStoreClass *camel_remote_store_class =
- * CAMEL_STORE_CLASS (camel_pop3_store_class);
- */
parent_class = CAMEL_REMOTE_STORE_CLASS(camel_type_get_global_classfuncs
(camel_remote_store_get_type ()));
@@ -103,8 +97,6 @@ camel_pop3_store_class_init (CamelPop3StoreClass *camel_pop3_store_class)
camel_service_class->disconnect = pop3_disconnect;
camel_store_class->get_folder = get_folder;
- camel_store_class->get_folder_name = get_folder_name;
- camel_store_class->get_root_folder_name = get_root_folder_name;
}
@@ -533,26 +525,12 @@ static CamelFolder *
get_folder (CamelStore *store, const char *folder_name,
guint32 flags, CamelException *ex)
{
- return camel_pop3_folder_new (store, ex);
-}
-
-static char *
-get_folder_name (CamelStore *store, const char *folder_name,
- CamelException *ex)
-{
- if (!g_strcasecmp (folder_name, "inbox"))
- return g_strdup ("inbox");
- else {
+ if (g_strcasecmp (folder_name, "inbox") != 0) {
camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID,
_("No such folder `%s'."), folder_name);
return NULL;
}
-}
-
-static char *
-get_root_folder_name (CamelStore *store, CamelException *ex)
-{
- return g_strdup ("inbox");
+ return camel_pop3_folder_new (store, ex);
}
diff --git a/camel/providers/vee/camel-vee-store.c b/camel/providers/vee/camel-vee-store.c
index 7acc127542..b39707e1a0 100644
--- a/camel/providers/vee/camel-vee-store.c
+++ b/camel/providers/vee/camel-vee-store.c
@@ -23,7 +23,6 @@
#include "camel-vee-folder.h"
static CamelFolder *vee_get_folder (CamelStore *store, const char *folder_name, guint32 flags, CamelException *ex);
-static char *vee_get_folder_name (CamelStore *store, const char *folder_name, CamelException *ex);
struct _CamelVeeStorePrivate {
};
@@ -63,7 +62,6 @@ camel_vee_store_class_init (CamelVeeStoreClass *klass)
/* virtual method overload */
store_class->get_folder = vee_get_folder;
- store_class->get_folder_name = vee_get_folder_name;
}
static void
@@ -93,10 +91,3 @@ vee_get_folder (CamelStore *store, const char *folder_name, guint32 flags, Camel
{
return camel_vee_folder_new (store, folder_name, ex);
}
-
-static char *
-vee_get_folder_name (CamelStore *store, const char *folder_name, CamelException *ex)
-{
- return g_strdup(folder_name);
-}
-