aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers
diff options
context:
space:
mode:
authorDan Winship <danw@helixcode.com>2000-04-07 04:10:05 +0800
committerDan Winship <danw@src.gnome.org>2000-04-07 04:10:05 +0800
commitf3f2afef4c3c60fa1ba472ef93e8e8516e7027bb (patch)
treea1bb7f65da6d7b02e755f7b4b088e8b2c20e0458 /camel/providers
parent1a6692a89d5e2ea02e777c010aa410b5ec5a48f3 (diff)
downloadgsoc2013-evolution-f3f2afef4c3c60fa1ba472ef93e8e8516e7027bb.tar
gsoc2013-evolution-f3f2afef4c3c60fa1ba472ef93e8e8516e7027bb.tar.gz
gsoc2013-evolution-f3f2afef4c3c60fa1ba472ef93e8e8516e7027bb.tar.bz2
gsoc2013-evolution-f3f2afef4c3c60fa1ba472ef93e8e8516e7027bb.tar.lz
gsoc2013-evolution-f3f2afef4c3c60fa1ba472ef93e8e8516e7027bb.tar.xz
gsoc2013-evolution-f3f2afef4c3c60fa1ba472ef93e8e8516e7027bb.tar.zst
gsoc2013-evolution-f3f2afef4c3c60fa1ba472ef93e8e8516e7027bb.zip
Reorganize the folder-fetching methods and implement a folder cache so
2000-04-06 Dan Winship <danw@helixcode.com> * camel-store.[ch]: Reorganize the folder-fetching methods and implement a folder cache so that multiple requests for the same folder will yield the same CamelFolder object (as long as it remains active). Includes some code to remove no-longer-active folders from the cache, but it doesn't get used since nothing is ever unref'ed in Camel right now... * providers/mbox/camel-mbox-store.c: * providers/pop3/camel-pop3-store.c: update for CamelStore changes. * camel-folder.[ch]: Remove the (unused) CamelException argument from camel_folder_get_name and camel_folder_get_full_name. (camel_folder_set_name): make this go away since changing a folder's name after it has been created could result in it conflicting with a separately-issued folder. svn path=/trunk/; revision=2314
Diffstat (limited to 'camel/providers')
-rw-r--r--camel/providers/mbox/camel-mbox-store.c26
-rw-r--r--camel/providers/pop3/camel-pop3-store.c31
2 files changed, 43 insertions, 14 deletions
diff --git a/camel/providers/mbox/camel-mbox-store.c b/camel/providers/mbox/camel-mbox-store.c
index 32d25becf1..0081aedb0e 100644
--- a/camel/providers/mbox/camel-mbox-store.c
+++ b/camel/providers/mbox/camel-mbox-store.c
@@ -35,8 +35,10 @@
#define CF_CLASS(so) CAMEL_FOLDER_CLASS (GTK_OBJECT(so)->klass)
#define CMBOXF_CLASS(so) CAMEL_MBOX_FOLDER_CLASS (GTK_OBJECT(so)->klass)
-static CamelFolder *_get_folder (CamelStore *store, const gchar *folder_name, CamelException *ex);
-
+static CamelFolder *get_folder (CamelStore *store, const char *folder_name,
+ CamelException *ex);
+static char *get_folder_name (CamelStore *store, const char *folder_name,
+ CamelException *ex);
static void
camel_mbox_store_class_init (CamelMboxStoreClass *camel_mbox_store_class)
@@ -44,7 +46,8 @@ camel_mbox_store_class_init (CamelMboxStoreClass *camel_mbox_store_class)
CamelStoreClass *camel_store_class = CAMEL_STORE_CLASS (camel_mbox_store_class);
/* virtual method overload */
- camel_store_class->get_folder = _get_folder;
+ camel_store_class->get_folder = get_folder;
+ camel_store_class->get_folder_name = get_folder_name;
}
@@ -53,8 +56,12 @@ static void
camel_mbox_store_init (gpointer object, gpointer klass)
{
CamelService *service = CAMEL_SERVICE (object);
+ CamelStore *store = CAMEL_STORE (object);
service->url_flags = CAMEL_SERVICE_URL_NEED_PATH;
+
+ /* mbox names are filenames, so they are case-sensitive. */
+ store->folders = g_hash_table_new (g_str_hash, g_str_equal);
}
@@ -97,15 +104,11 @@ camel_mbox_store_get_toplevel_dir (CamelMboxStore *store)
static CamelFolder *
-_get_folder (CamelStore *store, const gchar *folder_name, CamelException *ex)
+get_folder (CamelStore *store, const char *folder_name, CamelException *ex)
{
CamelMboxFolder *new_mbox_folder;
CamelFolder *new_folder;
- /* check if folder has already been created */
- /* call the standard routine for that when */
- /* it is done ... */
-
CAMEL_LOG_FULL_DEBUG ("Entering CamelMboxStore::get_folder\n");
new_mbox_folder = gtk_type_new (CAMEL_MBOX_FOLDER_TYPE);
new_folder = CAMEL_FOLDER (new_mbox_folder);
@@ -121,3 +124,10 @@ _get_folder (CamelStore *store, const gchar *folder_name, CamelException *ex)
return new_folder;
}
+
+static char *
+get_folder_name (CamelStore *store, const char *folder_name,
+ CamelException *ex)
+{
+ return g_strdup (folder_name);
+}
diff --git a/camel/providers/pop3/camel-pop3-store.c b/camel/providers/pop3/camel-pop3-store.c
index f14ed1dc55..b63cd30342 100644
--- a/camel/providers/pop3/camel-pop3-store.c
+++ b/camel/providers/pop3/camel-pop3-store.c
@@ -55,8 +55,11 @@ static gboolean pop3_disconnect (CamelService *service, CamelException *ex);
static GList *query_auth_types (CamelService *service);
static void free_auth_types (CamelService *service, GList *authtypes);
-static CamelFolder *get_folder (CamelStore *store, const gchar *folder_name,
+static CamelFolder *get_folder (CamelStore *store, const char *folder_name,
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 void
@@ -79,9 +82,9 @@ camel_pop3_store_class_init (CamelPop3StoreClass *camel_pop3_store_class)
camel_service_class->query_auth_types = query_auth_types;
camel_service_class->free_auth_types = free_auth_types;
- camel_store_class->get_root_folder = camel_pop3_folder_new;
- camel_store_class->get_default_folder = camel_pop3_folder_new;
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;
}
@@ -90,9 +93,11 @@ static void
camel_pop3_store_init (gpointer object, gpointer klass)
{
CamelService *service = CAMEL_SERVICE (object);
+ CamelStore *store = CAMEL_STORE (object);
service->url_flags = ( CAMEL_SERVICE_URL_NEED_USER |
CAMEL_SERVICE_URL_NEED_HOST );
+ store->folders = g_hash_table_new (g_str_hash, g_str_equal);
}
@@ -324,11 +329,18 @@ pop3_disconnect (CamelService *service, CamelException *ex)
return TRUE;
}
-static CamelFolder *get_folder (CamelStore *store, const gchar *folder_name,
- CamelException *ex)
+static CamelFolder *
+get_folder (CamelStore *store, const char *folder_name, CamelException *ex)
+{
+ return camel_pop3_folder_new (store, ex);
+}
+
+static char *
+get_folder_name (CamelStore *store, const char *folder_name,
+ CamelException *ex)
{
if (!strcasecmp (folder_name, "inbox"))
- return camel_pop3_folder_new (store, ex);
+ return g_strdup ("inbox");
else {
camel_exception_setv (ex, CAMEL_EXCEPTION_FOLDER_INVALID,
"No such folder `%s'.", folder_name);
@@ -336,6 +348,13 @@ static CamelFolder *get_folder (CamelStore *store, const gchar *folder_name,
}
}
+static char *
+get_root_folder_name (CamelStore *store, CamelException *ex)
+{
+ return g_strdup ("inbox");
+}
+
+
/**
* camel_pop3_command: Send a command to a POP3 server.
* @store: the POP3 store