[ekiga/ds-gsettings] Opal: Ported SIP GmConf keys to GSettings.



commit ba4c18742b09160d5a6099b63d257f93624f04be
Author: Damien Sandras <dsandras beip be>
Date:   Sun Sep 29 18:12:35 2013 +0200

    Opal: Ported SIP GmConf keys to GSettings.

 lib/ekiga-settings.h                              |    2 +
 lib/engine/components/opal/opal-gmconf-bridge.cpp |   33 -----------------
 lib/engine/components/opal/opal-main.cpp          |    2 +
 lib/engine/components/opal/sip-endpoint.cpp       |   41 +++++++++++++++++++++
 lib/engine/components/opal/sip-endpoint.h         |    7 ++++
 5 files changed, 52 insertions(+), 33 deletions(-)
---
diff --git a/lib/ekiga-settings.h b/lib/ekiga-settings.h
index fba4634..628b100 100644
--- a/lib/ekiga-settings.h
+++ b/lib/ekiga-settings.h
@@ -43,11 +43,13 @@
 #include <gio/gio.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"
 
 namespace Ekiga {
 
diff --git a/lib/engine/components/opal/opal-gmconf-bridge.cpp 
b/lib/engine/components/opal/opal-gmconf-bridge.cpp
index 9c09f7a..62d5541 100644
--- a/lib/engine/components/opal/opal-gmconf-bridge.cpp
+++ b/lib/engine/components/opal/opal-gmconf-bridge.cpp
@@ -251,39 +251,6 @@ ConfBridge::on_property_changed (std::string key,
   }
 
   //
-  // SIP related keys
-  // 
-  else if (key.find (SIP_KEY) != string::npos) {
-
-    boost::shared_ptr<Opal::Sip::EndPoint> sip_manager = boost::dynamic_pointer_cast<Opal::Sip::EndPoint> 
(manager.get_protocol_manager ("sip"));
-    if (sip_manager) {
-
-      if (key == SIP_KEY "outbound_proxy_host") {
-
-        gchar* str = gm_conf_entry_get_string (entry);
-        if (str != NULL)
-          sip_manager->set_outbound_proxy (str);
-        g_free (str);
-      }
-      else if (key == SIP_KEY "dtmf_mode") {
-
-        sip_manager->set_dtmf_mode (gm_conf_entry_get_int (entry));
-      }
-      else if (key == SIP_KEY "forward_host") {
-
-        gchar* str = gm_conf_entry_get_string (entry);
-        if (str != NULL)
-          sip_manager->set_forward_uri (str);
-        g_free (str);
-      }
-      else if (key == SIP_KEY "binding_timeout") {
-
-        sip_manager->set_nat_binding_delay (gm_conf_entry_get_int (entry));
-      }
-    }
-  }
-
-  //
   // H.323 keys
   //
 #ifdef HAVE_H323
diff --git a/lib/engine/components/opal/opal-main.cpp b/lib/engine/components/opal/opal-main.cpp
index 4365977..e145e75 100644
--- a/lib/engine/components/opal/opal-main.cpp
+++ b/lib/engine/components/opal/opal-main.cpp
@@ -112,6 +112,8 @@ struct OPALSpark: public Ekiga::Spark
       core.add (call_manager);
 
       boost::shared_ptr<Sip::EndPoint> sip_manager (new Sip::EndPoint (*call_manager, core), null_deleter 
());
+      sip_manager->setup ();
+      std::cout << "FIXME: why are we doing this only for the SIP endpoint and not for the H.323 endpoint?" 
<< std::endl << std::flush;
       call_manager->set_sip_endpoint (sip_manager);
       core.add (sip_manager);
 
diff --git a/lib/engine/components/opal/sip-endpoint.cpp b/lib/engine/components/opal/sip-endpoint.cpp
index 01c55ab..3ed0574 100644
--- a/lib/engine/components/opal/sip-endpoint.cpp
+++ b/lib/engine/components/opal/sip-endpoint.cpp
@@ -148,6 +148,9 @@ Opal::Sip::EndPoint::EndPoint (Opal::CallManager & _manager,
 
   /* NAT Binding */
   SetNATBindingRefreshMethod (SIPEndPoint::Options);
+
+  settings = new Ekiga::Settings (SIP_SCHEMA);
+  settings->changed.connect (boost::bind (&EndPoint::setup, this, _1));
 }
 
 
@@ -155,6 +158,44 @@ Opal::Sip::EndPoint::~EndPoint ()
 {
 }
 
+void
+Opal::Sip::EndPoint::setup (std::string setting)
+{
+  //keys.push_back (SIP_KEY "forward_host"); 
+  //keys.push_back (SIP_KEY "outbound_proxy_host");
+  //keys.push_back (SIP_KEY "dtmf_mode");
+  ///keys.push_back (SIP_KEY "binding_timeout");
+  GSettings *s = settings->get_g_settings ();
+  if (setting.empty () || setting == "binding-timeout")  {
+    PTRACE(4, "Sip::EndPoint\tSet NAT binding delay to " << g_settings_get_int (s, "binding-timeout"));
+    set_nat_binding_delay (g_settings_get_int (s, "binding-timeout"));
+  }
+  if (setting.empty () || setting == "outbound-proxy-host")  {
+
+    gchar* str = g_settings_get_string (s, "outbound-proxy-host");
+    if (str != NULL && strcmp (str, "")) {
+      PTRACE(4, "Sip::EndPoint\tSet outbound proxy to " << str);
+      set_outbound_proxy (str);
+    }
+    g_free (str);
+  }
+  if (setting.empty () || setting == "dtmf-mode")  {
+
+    PTRACE(4, "Sip::EndPoint\tSet DTMF mode to " << g_settings_get_int (s, "dtmf-mode"));
+    set_dtmf_mode (g_settings_get_int (s, "dtmf-mode"));
+  }
+  if (setting.empty () || setting == "forward-host")  {
+
+    gchar* str = g_settings_get_string (s, "forward-host");
+    if (str != NULL && strcmp (str, "") && strcasecmp (str, "sip:")) {
+      PTRACE(4, "Sip::EndPoint\tSet forward host to " << str);
+      set_forward_uri (str);
+    }
+    g_free (str);
+  }
+}
+
+
 bool
 Opal::Sip::EndPoint::populate_menu (const std::string& fullname,
                                    const std::string& uri,
diff --git a/lib/engine/components/opal/sip-endpoint.h b/lib/engine/components/opal/sip-endpoint.h
index d4d6553..17c5af3 100644
--- a/lib/engine/components/opal/sip-endpoint.h
+++ b/lib/engine/components/opal/sip-endpoint.h
@@ -53,6 +53,8 @@
 
 #include "opal-call-manager.h"
 
+#include "ekiga-settings.h"
+
 namespace Opal {
 
   namespace Sip {
@@ -73,6 +75,9 @@ namespace Opal {
 
       ~EndPoint ();
 
+      /* Set up endpoint: all options or a specific setting */
+      void setup (std::string setting = "");
+      
       /* Service */
       const std::string get_name () const
       { return "opal-sip-endpoint"; }
@@ -197,6 +202,8 @@ namespace Opal {
       unsigned listen_port;
 
       boost::shared_ptr<SIP::Dialect> dialect;
+
+      Ekiga::Settings* settings;
     };
   };
 };


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