summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberto Mardegan <mardy@users.sourceforge.net>2007-03-23 12:13:17 +0000
committerAlberto Mardegan <mardy@users.sourceforge.net>2007-03-23 12:13:17 +0000
commit048563a4ccc74272bcadbac0f239889abc18a66d (patch)
tree26577329ab90bb51c0c97d6216793c0729f05ab3
parent030f85c0b627724aebfb25d3c109bf16e882c022 (diff)
Get the manager files in a way analog to .profiles.
git-svn-id: https://mission-control.svn.sourceforge.net/svnroot/mission-control/trunk@18 d91c8aed-3f2b-0410-a83d-924a1c20a0ba
-rw-r--r--ChangeLog2
-rw-r--r--configure.ac10
-rw-r--r--libmissioncontrol/mc-manager.c71
3 files changed, 71 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 059ca5de..ce301327 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,7 +4,7 @@
Automatic update.
* configure.ac, libmissioncontrol/mc-profile.c,
- src/mcd-chan-handler.c:
+ libmissioncontrol/mc-manager.c, src/mcd-chan-handler.c:
Move to XDG compliant directory location for Telepathy data files.
2007-03-21 Alberto Mardegan <alberto.mardegan@nokia.com>
diff --git a/configure.ac b/configure.ac
index f5cd8991..1a5c5595 100644
--- a/configure.ac
+++ b/configure.ac
@@ -57,6 +57,16 @@ AC_SUBST(PROFILES_DIR)
AC_DEFINE_UNQUOTED(PROFILES_DIR,"$PROFILES_DIR", [Directory for storing profiles])
+AC_ARG_WITH(managers_dir, AS_HELP_STRING([--with-managers-dir=<path>],[Directory for storing managers]))
+if test -z "$with_managers_dir" ; then
+ MANAGERS_DIR="telepathy/managers"
+else
+ MANAGERS_DIR=$with_managers_dir
+fi
+AC_SUBST(MANAGERS_DIR)
+AC_DEFINE_UNQUOTED(MANAGERS_DIR,"$MANAGERS_DIR", [Directory for storing managers])
+
+
AC_ARG_WITH(accounts_dir, AS_HELP_STRING([--with-accounts-dir=<path>],[Directory for storing accounts]))
if test -z "$with_accounts_dir" ; then
ACCOUNTS_DIR="~/.mission-control/accounts"
diff --git a/libmissioncontrol/mc-manager.c b/libmissioncontrol/mc-manager.c
index 7d46c4c6..021bd8b7 100644
--- a/libmissioncontrol/mc-manager.c
+++ b/libmissioncontrol/mc-manager.c
@@ -32,8 +32,8 @@
#include "mc-manager.h"
#include "mc-manager-priv.h"
+#include <config.h>
-#define MANAGER_PATH "/usr/share/telepathy/managers"
#define MANAGER_SUFFIX ".manager"
#define MANAGER_SUFFIX_LEN 8
@@ -98,26 +98,75 @@ mc_manager_new (gchar *unique_name, gchar *bus_name, gchar *object_path,
return new;
}
-static const gchar *
-_mc_manager_path (void)
+static const gchar**
+_mc_manager_get_dirs ()
{
- const gchar *ret = NULL;
+ GSList *dir_list = NULL, *slist;
+ const gchar *dirname;
+ static gchar **manager_dirs = NULL;
+ guint n;
- if (ret == NULL)
+ if (manager_dirs) return (const gchar **)manager_dirs;
+
+ dirname = g_getenv ("MC_MANAGER_DIR");
+ if (dirname && g_file_test (dirname, G_FILE_TEST_IS_DIR))
+ dir_list = g_slist_prepend (dir_list, (gchar *)dirname);
+
+ if (MANAGERS_DIR[0] == '/')
+ {
+ if (g_file_test (MANAGERS_DIR, G_FILE_TEST_IS_DIR))
+ dir_list = g_slist_prepend (dir_list, MANAGERS_DIR);
+ }
+ else
{
- ret = g_getenv ("MC_MANAGER_DIR");
- if (ret == NULL)
- ret = MANAGER_PATH;
+ const gchar * const *dirs;
+ gchar *dir;
+
+ dir = g_build_filename (g_get_user_data_dir(), MANAGERS_DIR, NULL);
+ if (g_file_test (dir, G_FILE_TEST_IS_DIR))
+ dir_list = g_slist_prepend (dir_list, dir);
+ else g_free (dir);
+
+ dirs = g_get_system_data_dirs();
+ for (dirname = *dirs; dirname; dirs++, dirname = *dirs)
+ {
+ dir = g_build_filename (dirname, MANAGERS_DIR, NULL);
+ if (g_file_test (dir, G_FILE_TEST_IS_DIR))
+ dir_list = g_slist_prepend (dir_list, dir);
+ else g_free (dir);
+ }
}
- return ret;
+ /* build the string array */
+ n = g_slist_length (dir_list);
+ manager_dirs = g_new (gchar *, n + 1);
+ manager_dirs[n--] = NULL;
+ for (slist = dir_list; slist; slist = slist->next)
+ manager_dirs[n--] = slist->data;
+ g_slist_free (dir_list);
+ return (const gchar **)manager_dirs;
}
static gchar *
_mc_manager_filename (const gchar *unique_name)
{
- return g_strconcat (_mc_manager_path (), G_DIR_SEPARATOR_S,
- unique_name, MANAGER_SUFFIX, NULL);
+ const gchar **manager_dirs;
+ const gchar *dirname;
+ gchar *filename, *filepath = NULL;
+
+ manager_dirs = _mc_manager_get_dirs ();
+ if (!manager_dirs) return NULL;
+
+ filename = g_strconcat (unique_name, MANAGER_SUFFIX, NULL);
+ for (dirname = *manager_dirs; dirname; manager_dirs++, dirname = *manager_dirs)
+ {
+ filepath = g_build_filename (dirname, filename);
+ if (g_file_test (dirname, G_FILE_TEST_EXISTS)) break;
+ g_free (filepath);
+ filepath = NULL;
+ }
+ g_free (filename);
+ return filepath;
}
#define PREFIX_PROTOCOL "Protocol "