[ekiga/ds-gsettings3] GSettings: Ported the accounts list to GSettings.



commit 90b7500eaab75efde5984686de497143557e8c39
Author: Damien Sandras <dsandras beip be>
Date:   Sat Oct 5 16:43:51 2013 +0200

    GSettings: Ported the accounts list to GSettings.

 lib/ekiga-settings.h                              |    4 +-
 lib/engine/components/local-roster/local-heap.cpp |    4 +-
 lib/engine/components/opal/opal-bank.cpp          |   35 +++++++++-----------
 lib/engine/components/opal/opal-bank.h            |    1 +
 lib/gmconf/gmconf-upgrade.c                       |   23 -------------
 5 files changed, 21 insertions(+), 46 deletions(-)
---
diff --git a/lib/ekiga-settings.h b/lib/ekiga-settings.h
index a637f9e..8455af9 100644
--- a/lib/ekiga-settings.h
+++ b/lib/ekiga-settings.h
@@ -47,13 +47,13 @@
 #include "config.h"
 
 #define USER_INTERFACE "org.gnome." PACKAGE_NAME ".general.user-interface"
-#define PROTOCOLS "org.gnome." PACKAGE_NAME ".protocols"
 
 #define SOUND_EVENTS_SCHEMA "org.gnome." PACKAGE_NAME ".general.sound-events"
 #define AUDIO_DEVICES_SCHEMA "org.gnome." PACKAGE_NAME ".devices.audio"
 #define VIDEO_DEVICES_SCHEMA "org.gnome." PACKAGE_NAME ".devices.video"
 #define VIDEO_DISPLAY_SCHEMA USER_INTERFACE ".video-display"
-#define SIP_SCHEMA PROTOCOLS ".sip"
+#define PROTOCOLS_SCHEMA "org.gnome." PACKAGE_NAME ".protocols"
+#define SIP_SCHEMA PROTOCOLS_SCHEMA ".sip"
 
 namespace Ekiga {
 
diff --git a/lib/engine/components/local-roster/local-heap.cpp 
b/lib/engine/components/local-roster/local-heap.cpp
index 4d3e8e2..1111a74 100644
--- a/lib/engine/components/local-roster/local-heap.cpp
+++ b/lib/engine/components/local-roster/local-heap.cpp
@@ -373,9 +373,9 @@ void
 Local::Heap::save () const
 {
   xmlChar *buffer = NULL;
-  int size = 0;
+  int doc_size = 0;
 
-  xmlDocDumpMemory (doc.get (), &buffer, &size);
+  xmlDocDumpMemory (doc.get (), &buffer, &doc_size);
 
   gm_conf_set_string (ROSTER_KEY, (const char *)buffer);
 
diff --git a/lib/engine/components/opal/opal-bank.cpp b/lib/engine/components/opal/opal-bank.cpp
index 74f3ca4..6549334 100644
--- a/lib/engine/components/opal/opal-bank.cpp
+++ b/lib/engine/components/opal/opal-bank.cpp
@@ -55,10 +55,11 @@ Opal::Bank::Bank (Ekiga::ServiceCore& core):
   audiooutput_core(core.get<Ekiga::AudioOutputCore> ("audiooutput-core")),
   opal_component(core.get<CallManager> ("opal-component"))
 {
-  GSList *accounts = gm_conf_get_string_list (PROTOCOLS_KEY "accounts_list");
-  GSList *accounts_iter = accounts;
+  gchar **accounts = NULL;
+  protocols_settings = g_settings_new (PROTOCOLS_SCHEMA);
 
-  while (accounts_iter) {
+  accounts = g_settings_get_strv (protocols_settings, "accounts-list");
+  for (int i = 0 ; accounts[i] != NULL ; i++) {
 
     boost::shared_ptr<Account> account
       = boost::shared_ptr<Account> (new Account (sip_endpoint,
@@ -66,17 +67,14 @@ Opal::Bank::Bank (Ekiga::ServiceCore& core):
                                                 personal_details,
                                                 audiooutput_core,
                                                 opal_component,
-                                                (char *)accounts_iter->data));
+                                                (char *)accounts[i]));
 
     add_account (account);
     Ekiga::BankImpl<Account>::add_connection (account, account->trigger_saving.connect (boost::bind 
(&Opal::Bank::save, this)));
     Ekiga::BankImpl<Account>::add_connection (account, account->presence_received.connect (boost::ref 
(presence_received)));
     Ekiga::BankImpl<Account>::add_connection (account, account->status_received.connect (boost::ref 
(status_received)));
-    accounts_iter = g_slist_next (accounts_iter);
   }
-
-  g_slist_foreach (accounts, (GFunc) g_free, NULL);
-  g_slist_free (accounts);
+  g_strfreev (accounts);
 
   sip_endpoint->registration_event.connect (boost::bind(&Opal::Bank::on_registration_event, this, _1, _2, 
_3));
   sip_endpoint->mwi_event.connect (boost::bind(&Opal::Bank::on_mwi_event, this, _1, _2));
@@ -94,6 +92,8 @@ Opal::Bank::~Bank ()
   // presence when killed, and that gives a crash if the call manager
   // is already gone!
   Ekiga::RefLister<Opal::Account>::remove_all_objects ();
+
+  g_clear_object (&protocols_settings);
 }
 
 bool
@@ -316,21 +316,18 @@ Opal::Bank::find_account (const std::string& aor)
 void
 Opal::Bank::save () const
 {
-  GSList *accounts = NULL;
+  int i = 0;
+  gchar** accounts = NULL;
 
+  accounts = (gchar**) g_malloc (sizeof (gchar*) * (size() + 1));
   for (const_iterator it = begin ();
        it != end ();
-       it++) {
-
-    std::string acct_str = (*it)->as_string ();
-    if ( !acct_str.empty ())
-      accounts = g_slist_append (accounts, g_strdup (acct_str.c_str ()));
-  }
-
-  gm_conf_set_string_list (PROTOCOLS_KEY "accounts_list", accounts);
+       it++)
+    accounts[i++] = g_strdup ((*it)->as_string ().c_str ());
+  accounts[i++] = NULL;
 
-  g_slist_foreach (accounts, (GFunc) g_free, NULL);
-  g_slist_free (accounts);
+  g_settings_set_strv (protocols_settings, "accounts-list", accounts);
+  g_strfreev (accounts);
 }
 
 void
diff --git a/lib/engine/components/opal/opal-bank.h b/lib/engine/components/opal/opal-bank.h
index 854e005..1ce6e3a 100644
--- a/lib/engine/components/opal/opal-bank.h
+++ b/lib/engine/components/opal/opal-bank.h
@@ -142,6 +142,7 @@ private:
 
     void update_sip_endpoint_aor_map ();
 
+    GSettings *protocols_settings;
   };
 
   /**
diff --git a/lib/gmconf/gmconf-upgrade.c b/lib/gmconf/gmconf-upgrade.c
index 27f563f..d292703 100644
--- a/lib/gmconf/gmconf-upgrade.c
+++ b/lib/gmconf/gmconf-upgrade.c
@@ -114,29 +114,6 @@ gmconf_upgrade_version ()
   }
   g_free (conf_url);
 
-  /* diamondcard is now set at sip.diamondcard.us */
-  GSList *accounts = gm_conf_get_string_list (PROTOCOLS_KEY "accounts_list");
-  GSList *accounts_iter = accounts;
-  GRegex* regex = g_regex_new ("eugw\\.ast\\.diamondcard\\.us",
-                              (GRegexCompileFlags)0,
-                              (GRegexMatchFlags)0,
-                              NULL);
-  gchar* replaced_acct = NULL;
-  while (accounts_iter) {
-
-    replaced_acct = g_regex_replace (regex, (gchar *) accounts_iter->data,
-                                    -1, 0, "sip.diamondcard.us",
-                                    (GRegexMatchFlags)0, NULL);
-    g_free (accounts_iter->data);
-    accounts_iter->data = replaced_acct;
-    accounts_iter = g_slist_next (accounts_iter);
-  }
-  g_regex_unref (regex);
-
-  gm_conf_set_string_list (PROTOCOLS_KEY "accounts_list", accounts);
-  g_slist_foreach (accounts, (GFunc) g_free, NULL);
-  g_slist_free (accounts);
-
   /* Video devices */
   gchar *plugin = NULL;
   gchar *device = NULL;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]