aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-08-24 20:20:23 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-08-25 17:45:13 +0800
commit860c26554e90126287adcba3ae9dc536bdfbb622 (patch)
tree90774a7fed3fc9673ab9e5436b1f22fa65eb876d
parent1ceaa6d1ee7135f6a578eecb12686493fac88d6c (diff)
downloadgsoc2013-empathy-860c26554e90126287adcba3ae9dc536bdfbb622.tar
gsoc2013-empathy-860c26554e90126287adcba3ae9dc536bdfbb622.tar.gz
gsoc2013-empathy-860c26554e90126287adcba3ae9dc536bdfbb622.tar.bz2
gsoc2013-empathy-860c26554e90126287adcba3ae9dc536bdfbb622.tar.lz
gsoc2013-empathy-860c26554e90126287adcba3ae9dc536bdfbb622.tar.xz
gsoc2013-empathy-860c26554e90126287adcba3ae9dc536bdfbb622.tar.zst
gsoc2013-empathy-860c26554e90126287adcba3ae9dc536bdfbb622.zip
add empathy_irc_network_manager_dup_default()
-rw-r--r--libempathy/empathy-irc-network-manager.c34
-rw-r--r--libempathy/empathy-irc-network-manager.h2
2 files changed, 36 insertions, 0 deletions
diff --git a/libempathy/empathy-irc-network-manager.c b/libempathy/empathy-irc-network-manager.c
index 97d19a0eb..5e0530938 100644
--- a/libempathy/empathy-irc-network-manager.c
+++ b/libempathy/empathy-irc-network-manager.c
@@ -32,6 +32,7 @@
#include "empathy-debug.h"
#define IRC_NETWORKS_DTD_FILENAME "empathy-irc-networks.dtd"
+#define IRC_NETWORKS_FILENAME "irc-networks.xml"
#define SAVE_TIMER 4
#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyIrcNetworkManager)
@@ -781,3 +782,36 @@ empathy_irc_network_manager_find_network_by_address (
return network;
}
+
+EmpathyIrcNetworkManager *
+empathy_irc_network_manager_dup_default (void)
+{
+ static EmpathyIrcNetworkManager *default_mgr = NULL;
+ gchar *dir, *user_file_with_path, *global_file_with_path;
+
+ if (default_mgr != NULL)
+ return g_object_ref (default_mgr);
+
+ dir = g_build_filename (g_get_user_config_dir (), PACKAGE_NAME, NULL);
+ g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR);
+ user_file_with_path = g_build_filename (dir, IRC_NETWORKS_FILENAME, NULL);
+ g_free (dir);
+
+ global_file_with_path = g_build_filename (g_getenv ("EMPATHY_SRCDIR"),
+ "libempathy", IRC_NETWORKS_FILENAME, NULL);
+ if (!g_file_test (global_file_with_path, G_FILE_TEST_EXISTS))
+ {
+ g_free (global_file_with_path);
+ global_file_with_path = g_build_filename (DATADIR, "empathy",
+ IRC_NETWORKS_FILENAME, NULL);
+ }
+
+ default_mgr = empathy_irc_network_manager_new (
+ global_file_with_path, user_file_with_path);
+
+ g_object_add_weak_pointer (G_OBJECT (default_mgr), (gpointer *) &default_mgr);
+
+ g_free (global_file_with_path);
+ g_free (user_file_with_path);
+ return default_mgr;
+}
diff --git a/libempathy/empathy-irc-network-manager.h b/libempathy/empathy-irc-network-manager.h
index a050f4723..11c84836f 100644
--- a/libempathy/empathy-irc-network-manager.h
+++ b/libempathy/empathy-irc-network-manager.h
@@ -63,6 +63,8 @@ GType empathy_irc_network_manager_get_type (void);
EmpathyIrcNetworkManager * empathy_irc_network_manager_new (
const gchar *global_file, const gchar *user_file);
+EmpathyIrcNetworkManager * empathy_irc_network_manager_dup_default (void);
+
void empathy_irc_network_manager_add (EmpathyIrcNetworkManager *manager,
EmpathyIrcNetwork *network);