[evolution-data-server/openismus-work] Make the Camel provider modules relocatable



commit deec3a7073ea4f444c8773b57815434cba3d0174
Author: Tristan Van Berkom <tristanvb openismus com>
Date:   Mon Feb 25 19:28:04 2013 +0900

    Make the Camel provider modules relocatable
    
    This simply adds an environment variable allowing us to load the local
    provider from a relocated location in the case we run 'make check' without
    installing (this avoids some warnings and helps to isolate the test
    environment).

 camel/camel-provider.c |   11 ++++++++---
 camel/camel-provider.h |    8 ++++++++
 2 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/camel/camel-provider.c b/camel/camel-provider.c
index 6b74699..833cb62 100644
--- a/camel/camel-provider.c
+++ b/camel/camel-provider.c
@@ -172,6 +172,11 @@ camel_provider_init (void)
        gchar *p, *name, buf[80];
        CamelProviderModule *m;
        static gint loaded = 0;
+       const gchar *provider_dir;
+
+       provider_dir = g_getenv (EDS_CAMEL_PROVIDER_DIR);
+       if (!provider_dir)
+               provider_dir = CAMEL_PROVIDERDIR;
 
        g_once (&setup_once, provider_setup, NULL);
 
@@ -180,11 +185,11 @@ camel_provider_init (void)
 
        loaded = 1;
 
-       dir = g_dir_open (CAMEL_PROVIDERDIR, 0, NULL);
+       dir = g_dir_open (provider_dir, 0, NULL);
        if (!dir) {
                g_warning (
                        "Could not open camel provider directory (%s): %s",
-                       CAMEL_PROVIDERDIR, g_strerror (errno));
+                       provider_dir, g_strerror (errno));
                return;
        }
 
@@ -195,7 +200,7 @@ camel_provider_init (void)
                if (!p || strcmp (p, ".urls") != 0)
                        continue;
 
-               name = g_strdup_printf ("%s/%s", CAMEL_PROVIDERDIR, entry);
+               name = g_strdup_printf ("%s/%s", provider_dir, entry);
                fp = g_fopen (name, "r");
                if (!fp) {
                        g_warning (
diff --git a/camel/camel-provider.h b/camel/camel-provider.h
index 4924256..9bb49e0 100644
--- a/camel/camel-provider.h
+++ b/camel/camel-provider.h
@@ -38,6 +38,14 @@
 
 #define CAMEL_PROVIDER(obj) ((CamelProvider *)(obj))
 
+/**
+ * EDS_CAMEL_PROVIDER_DIR:
+ *
+ * This environment variable configures where the camel
+ * provider modules are loaded from.
+ */
+#define EDS_CAMEL_PROVIDER_DIR    "EDS_CAMEL_PROVIDER_DIR"
+
 G_BEGIN_DECLS
 
 extern gchar *camel_provider_type_name[CAMEL_NUM_PROVIDER_TYPES];


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]