[empathy: 1/26] add empathy_irc_network_manager_dup_default()
- From: Guillaume Desmottes <gdesmott src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy: 1/26] add empathy_irc_network_manager_dup_default()
- Date: Thu, 26 Aug 2010 12:03:27 +0000 (UTC)
commit 860c26554e90126287adcba3ae9dc536bdfbb622
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date: Tue Aug 24 14:20:23 2010 +0200
add empathy_irc_network_manager_dup_default()
libempathy/empathy-irc-network-manager.c | 34 ++++++++++++++++++++++++++++++
libempathy/empathy-irc-network-manager.h | 2 +
2 files changed, 36 insertions(+), 0 deletions(-)
---
diff --git a/libempathy/empathy-irc-network-manager.c b/libempathy/empathy-irc-network-manager.c
index 97d19a0..5e05309 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 a050f47..11c8483 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]