aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-provider.c
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2004-12-03 11:36:57 +0800
committerMichael Zucci <zucchi@src.gnome.org>2004-12-03 11:36:57 +0800
commitc83477345fa5dceb62b85efd0a76a54f94a78858 (patch)
treeaaea668a8d4f768b96174ad81aca864983addd0c /camel/camel-provider.c
parent300ec3f74d9f2ea59503ad267c927723ea59fd3e (diff)
downloadgsoc2013-evolution-c83477345fa5dceb62b85efd0a76a54f94a78858.tar.gz
gsoc2013-evolution-c83477345fa5dceb62b85efd0a76a54f94a78858.tar.zst
gsoc2013-evolution-c83477345fa5dceb62b85efd0a76a54f94a78858.zip
have our own so we don't need to link with glib.
* camel-lock-helper.c (g_strerror): have our own so we don't need to link with glib. * providers/*/Makefile.am: Do not install ANY provider header files. No providers are subclassable. No providers are directly linkable. * camel.pc.in: create package config file. * tests/lib/folders.c (test_folder_message_ops): updated counts for delete also marking unread. * tests/lib/camel-test.c (camel_test_provider_init): new api for initialising test system 'in-build'. * camel-provider.c: remove the assertions, init if we need to,k use pthread_once stuff to serialise it. * tests/folder/test3.c (main): remove gtk stuff (???). * tests/*: Fix all the makefiles. Made make-check work 'in-build'. * tests/lib/folders.c (test_folder_counts): update for api changes. (test_message_info): similar. * providers/Makefile.am: removed groupwise from the build, this can't go in here anymore, not in its current state. * camel-net-utils.c (camel_gethostbyaddr_r) (camel_gethostbyname_r): the old e_gethost* calls from e-host-utils.c. 2004-11-15 Not Zed <NotZed@Ximian.com> * providers/imap/camel-imap-utils.c (imap_path_to_physical): copied from e-path.c. (imap_path_find_folders): copied from e-path.c. * camel.h: remove the provider stuff from the header. * camel-provider.c: globalise provider_init variable, and asserton it in all functions that rely on it. * camel-service.c: removed getaddrinfo/etc. * camel-net-utils.[ch]: separate out camel_getaddrinfo etc. * Makefile.am: split camel into 2 libraries, libcamel and libcamel-store. * camel-multipart-signed.c (camel_multipart_signed_sign) (camel_multipart_signed_verify, prepare_sign): remove old deprecated api. * camel-multipart-encrypted.c (camel_multipart_encrypted_encrypt) (camel_multipart_encrypted_decrypt): remove old deprecated api. svn path=/trunk/; revision=28046
Diffstat (limited to 'camel/camel-provider.c')
-rw-r--r--camel/camel-provider.c50
1 files changed, 34 insertions, 16 deletions
diff --git a/camel/camel-provider.c b/camel/camel-provider.c
index 889188f672..c3a9546bbd 100644
--- a/camel/camel-provider.c
+++ b/camel/camel-provider.c
@@ -41,7 +41,7 @@
#include "camel-exception.h"
#include "camel-string-utils.h"
#include "camel-vee-store.h"
-#include "e-util/e-msgport.h"
+#include "libedataserver/e-msgport.h"
#include "camel-i18n.h"
/* table of CamelProviderModule's */
@@ -68,6 +68,21 @@ static CamelProvider vee_provider = {
/* ... */
};
+static pthread_once_t setup_once = PTHREAD_ONCE_INIT;
+
+static void
+provider_setup(void)
+{
+ provider_lock = e_mutex_new(E_MUTEX_REC);
+ module_table = g_hash_table_new(camel_strcase_hash, camel_strcase_equal);
+ provider_table = g_hash_table_new(camel_strcase_hash, camel_strcase_equal);
+
+ vee_provider.object_types[CAMEL_PROVIDER_STORE] = camel_vee_store_get_type ();
+ vee_provider.url_hash = camel_url_hash;
+ vee_provider.url_equal = camel_url_equal;
+ camel_provider_register(&vee_provider);
+}
+
/**
* camel_provider_init:
*
@@ -78,6 +93,9 @@ static CamelProvider vee_provider = {
* A .urls file has the same initial prefix as the shared library it
* correspond to, and consists of a series of lines containing the URL
* protocols that that library handles.
+ *
+ * TODO: This should be pathed?
+ * TODO: This should be plugin-d?
**/
void
camel_provider_init (void)
@@ -86,26 +104,19 @@ camel_provider_init (void)
struct dirent *d;
char *p, *name, buf[80];
CamelProviderModule *m;
- static int init = 0;
+ static int loaded = 0;
- if (init)
- return;
+ pthread_once(&setup_once, provider_setup);
- init = 1;
-
- provider_lock = e_mutex_new(E_MUTEX_REC);
- module_table = g_hash_table_new(camel_strcase_hash, camel_strcase_equal);
- provider_table = g_hash_table_new(camel_strcase_hash, camel_strcase_equal);
+ if (loaded)
+ return;
- vee_provider.object_types[CAMEL_PROVIDER_STORE] = camel_vee_store_get_type ();
- vee_provider.url_hash = camel_url_hash;
- vee_provider.url_equal = camel_url_equal;
- camel_provider_register(&vee_provider);
+ loaded = 1;
dir = opendir (CAMEL_PROVIDERDIR);
if (!dir) {
- g_error ("Could not open camel provider directory (%s): %s",
- CAMEL_PROVIDERDIR, g_strerror (errno));
+ g_warning("Could not open camel provider directory (%s): %s",
+ CAMEL_PROVIDERDIR, g_strerror (errno));
return;
}
@@ -167,6 +178,8 @@ camel_provider_load(const char *path, CamelException *ex)
GModule *module;
CamelProvider *(*camel_provider_module_init) (void);
+ pthread_once(&setup_once, provider_setup);
+
if (!g_module_supported ()) {
camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
_("Could not load %s: Module loading "
@@ -210,6 +223,8 @@ camel_provider_register(CamelProvider *provider)
g_return_if_fail (provider != NULL);
+ g_assert(provider_table);
+
LOCK();
if (g_hash_table_lookup(provider_table, provider->protocol) != NULL) {
@@ -284,6 +299,8 @@ camel_provider_list(gboolean load)
{
GList *list = NULL;
+ g_assert(provider_table);
+
LOCK();
if (load) {
@@ -329,6 +346,7 @@ camel_provider_get(const char *url_string, CamelException *ex)
size_t len;
g_return_val_if_fail(url_string != NULL, NULL);
+ g_assert(provider_table);
len = strcspn(url_string, ":");
protocol = g_alloca(len+1);
@@ -388,7 +406,7 @@ camel_provider_auto_detect (CamelProvider *provider, CamelURL *url,
GHashTable **auto_detected, CamelException *ex)
{
g_return_val_if_fail (provider != NULL, -1);
-
+
if (provider->auto_detect) {
return provider->auto_detect (url, auto_detected, ex);
} else {