diff options
Diffstat (limited to 'libempathy')
-rw-r--r-- | libempathy/empathy-irc-network-manager.c | 34 | ||||
-rw-r--r-- | libempathy/empathy-irc-network-manager.h | 2 | ||||
-rw-r--r-- | libempathy/empathy-irc-network.c | 16 | ||||
-rw-r--r-- | libempathy/empathy-irc-network.h | 4 |
4 files changed, 56 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); diff --git a/libempathy/empathy-irc-network.c b/libempathy/empathy-irc-network.c index 9b75f0e82..d5b0bdcb9 100644 --- a/libempathy/empathy-irc-network.c +++ b/libempathy/empathy-irc-network.c @@ -359,3 +359,19 @@ empathy_irc_network_set_server_position (EmpathyIrcNetwork *self, g_signal_emit (self, signals[MODIFIED], 0); } + +const gchar * +empathy_irc_network_get_name (EmpathyIrcNetwork *self) +{ + EmpathyIrcNetworkPriv *priv = GET_PRIV (self); + + return priv->name; +} + +const gchar * +empathy_irc_network_get_charset (EmpathyIrcNetwork *self) +{ + EmpathyIrcNetworkPriv *priv = GET_PRIV (self); + + return priv->charset; +} diff --git a/libempathy/empathy-irc-network.h b/libempathy/empathy-irc-network.h index b10b2769e..9d78f3c3f 100644 --- a/libempathy/empathy-irc-network.h +++ b/libempathy/empathy-irc-network.h @@ -75,6 +75,10 @@ void empathy_irc_network_remove_server (EmpathyIrcNetwork *network, void empathy_irc_network_set_server_position (EmpathyIrcNetwork *network, EmpathyIrcServer *server, gint pos); +const gchar * empathy_irc_network_get_name (EmpathyIrcNetwork *network); + +const gchar * empathy_irc_network_get_charset (EmpathyIrcNetwork *network); + G_END_DECLS #endif /* __EMPATHY_IRC_NETWORK_H__ */ |