diff options
author | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2010-08-24 20:20:23 +0800 |
---|---|---|
committer | Guillaume Desmottes <guillaume.desmottes@collabora.co.uk> | 2010-08-25 17:45:13 +0800 |
commit | 860c26554e90126287adcba3ae9dc536bdfbb622 (patch) | |
tree | 90774a7fed3fc9673ab9e5436b1f22fa65eb876d /libempathy/empathy-irc-network-manager.c | |
parent | 1ceaa6d1ee7135f6a578eecb12686493fac88d6c (diff) | |
download | gsoc2013-empathy-860c26554e90126287adcba3ae9dc536bdfbb622.tar.gz gsoc2013-empathy-860c26554e90126287adcba3ae9dc536bdfbb622.tar.zst gsoc2013-empathy-860c26554e90126287adcba3ae9dc536bdfbb622.zip |
add empathy_irc_network_manager_dup_default()
Diffstat (limited to 'libempathy/empathy-irc-network-manager.c')
-rw-r--r-- | libempathy/empathy-irc-network-manager.c | 34 |
1 files changed, 34 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; +} |