[telepathy-mission-control/master] McdMaster: allow plugin location to be overridden in the environment

Simon McVittie simon.mcvittie at collabora.co.uk
Mon May 18 08:47:04 PDT 2009


---
 src/mcd-master.c |   21 ++++++++++++++++++---
 1 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/mcd-master.c b/src/mcd-master.c
index 2c8c740..9d8aa01 100644
--- a/src/mcd-master.c
+++ b/src/mcd-master.c
@@ -281,18 +281,33 @@ mcd_master_unload_plugins (McdMaster *master)
     priv->plugins = NULL;
 }
 
+static const gchar *
+mcd_master_get_plugin_dir (void)
+{
+    const gchar *dir = g_getenv ("MC_FILTER_PLUGIN_DIR");
+
+    if (dir == NULL)
+        dir = MCD_DEFAULT_FILTER_PLUGIN_DIR;
+
+    return dir;
+}
+
 static void
 mcd_master_load_plugins (McdMaster *master)
 {
     McdMasterPrivate *priv = MCD_MASTER_PRIV (master);
+    const gchar *plugin_dir;
     GDir *dir = NULL;
     GError *error = NULL;
     const gchar *name;
 
-    dir = g_dir_open (MCD_DEFAULT_FILTER_PLUGIN_DIR, 0, &error);
+    plugin_dir = mcd_master_get_plugin_dir ();
+
+    dir = g_dir_open (plugin_dir, 0, &error);
     if (!dir)
     {
-        DEBUG ("Could not open plugin directory: %s", error->message);
+        DEBUG ("Could not open plugin directory %s: %s", plugin_dir,
+               error->message);
 	g_error_free (error);
 	return;
     }
@@ -305,7 +320,7 @@ mcd_master_load_plugins (McdMaster *master)
 
 	if (name[0] == '.' || !g_str_has_suffix (name, ".so")) continue;
 
-	path = g_build_filename (MCD_DEFAULT_FILTER_PLUGIN_DIR, name, NULL);
+	path = g_build_filename (plugin_dir, name, NULL);
 	module = g_module_open (path, 0);
 	g_free (path);
 	if (module)
-- 
1.5.6.5




More information about the telepathy-commits mailing list