aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-03-23 01:21:31 +0800
committerDan Winship <danw@src.gnome.org>2000-03-23 01:21:31 +0800
commit0f5f6d79199b16b0db1b7530c8835ad6a3bbe73c (patch)
treec0705435b394e1de37983bd78a88c51d9ea035c8 /camel
parent1fa17b36192eab987255accbe14b3fe184fa0948 (diff)
downloadgsoc2013-evolution-0f5f6d79199b16b0db1b7530c8835ad6a3bbe73c.tar.gz
gsoc2013-evolution-0f5f6d79199b16b0db1b7530c8835ad6a3bbe73c.tar.zst
gsoc2013-evolution-0f5f6d79199b16b0db1b7530c8835ad6a3bbe73c.zip
New function to scan the provider dir and return a list of all providers.
* camel-provider.c (camel_provider_scan): New function to scan the provider dir and return a list of all providers. svn path=/trunk/; revision=2145
Diffstat (limited to 'camel')
-rw-r--r--camel/Makefile.am5
-rw-r--r--camel/camel-provider.c45
-rw-r--r--camel/camel-provider.h9
3 files changed, 41 insertions, 18 deletions
diff --git a/camel/Makefile.am b/camel/Makefile.am
index 59fb9d1788..aaac035bee 100644
--- a/camel/Makefile.am
+++ b/camel/Makefile.am
@@ -3,13 +3,14 @@
SUBDIRS = providers
libcamelincludedir = $(includedir)/camel
-
+providerdir = $(libdir)/evolution/camel-providers/$(VERSION)
lib_LTLIBRARIES = libcamel.la
INCLUDES = -I.. -I$(srcdir)/.. -I$(includedir) \
-I$(top_srcdir)/intl \
- $(GTK_INCLUDEDIR)
+ $(GTK_INCLUDEDIR) \
+ -DCAMEL_PROVIDERDIR=\""$(providerdir)"\"
if ENABLE_THREADS
diff --git a/camel/camel-provider.c b/camel/camel-provider.c
index 8f5b66ddc6..b0e4017da5 100644
--- a/camel/camel-provider.c
+++ b/camel/camel-provider.c
@@ -48,9 +48,10 @@
#include "camel-provider.h"
#include "camel-log.h"
+#include <dirent.h>
+#include <string.h>
static GList *_provider_list = NULL;
-static gchar *_last_error;
static gint
_provider_name_cmp (gconstpointer a, gconstpointer b)
@@ -129,21 +130,39 @@ camel_provider_register_as_module (const gchar *module_path)
}
-
-
-
-/*
- be careful to this function, @a is expected to be
- a provider, @b a protocol name (const gchar *)
-*/
-static gint
-_provider_protocol_find (gconstpointer a, gconstpointer b)
+/**
+ * camel_provider_scan: Scan for available providers and return a list.
+ *
+ * Note that this function will cause all providers in the providerdir
+ * to be loaded into memory.
+ *
+ * Return value: the list of CamelProviders. The caller must free this
+ * list when it is done with it.
+ **/
+GList *
+camel_provider_scan (void)
{
- CamelProvider *provider_a = CAMEL_PROVIDER (a);
- const gchar *name_b = (const gchar *)b;
+ DIR *dir;
+ struct dirent *dent;
+ char *p, *name;
- return g_strcasecmp ( provider_a->name, name_b);
+ dir = opendir (CAMEL_PROVIDERDIR);
+ if (!dir)
+ return NULL;
+ while ((dent = readdir (dir))) {
+ p = strstr (dent->d_name, ".so");
+ if (!p || strcmp (p, ".so") != 0)
+ continue;
+
+ name = g_module_build_path (CAMEL_PROVIDERDIR, dent->d_name);
+ camel_provider_register_as_module (name);
+ g_free (name);
+ }
+ closedir (dir);
+
+ return g_list_copy (_provider_list);
}
+
/**
* camel_provider_get_for_protocol: get a registered provider for a protocol
diff --git a/camel/camel-provider.h b/camel/camel-provider.h
index 25a7235a86..5018cc6cd0 100644
--- a/camel/camel-provider.h
+++ b/camel/camel-provider.h
@@ -37,19 +37,21 @@ extern "C" {
#include <gtk/gtk.h>
#include <gmodule.h>
-#define CAMEL_PROVIDER(obj) (CamelProvider *)(obj)
+#define CAMEL_PROVIDER(obj) ((CamelProvider *)(obj))
typedef enum {
PROVIDER_STORE,
PROVIDER_TRANSPORT
} ProviderType;
+#define PROVIDER_REMOTE 0x01
typedef struct {
GtkType object_type; /* used to create instance of the provider */
ProviderType provider_type; /* is a store or a transport */
- gchar *protocol; /* name of the protocol ("imap"/"smtp"/"mh" ...) */
- gchar *name; /* name of the provider ("Raymond the imap provider") */
+ int flags; /* information about the provider */
+ gchar *protocol; /* name of the protocol ("IMAP"/"SMTP"/"MH" ...) */
+ gchar *name; /* name of the provider ("Raymond the IMAP provider") */
gchar *description; /* Useful when multiple providers are available for a same protocol */
GModule *gmodule;
@@ -58,6 +60,7 @@ typedef struct {
void camel_provider_register (CamelProvider *provider);
const CamelProvider *camel_provider_register_as_module (const gchar *module_path);
const CamelProvider *camel_provider_get_for_protocol (const gchar *protocol, ProviderType type);
+GList *camel_provider_scan (void);
#ifdef __cplusplus