[ekiga] Opal: Added support for instance id unicity.



commit 84a96040a658c86c2ef2377c17286168d90460c1
Author: Damien Sandras <dsandras seconix com>
Date:   Sun Apr 19 14:27:10 2015 +0200

    Opal: Added support for instance id unicity.
    
    This is requested by RFC 5626. Basically, it allows a registrar to
    identify uniquely a UA and replace its current registrations if the UA
    is restarted.
    
    Ekiga now generates its instance id "key" on the first run.

 .../components/opal/process/sip-endpoint.cpp       |   17 +++++++++++++++++
 lib/engine/components/opal/process/sip-endpoint.h  |    4 ++++
 lib/engine/components/opal/sip-call-manager.cpp    |   14 ++++++++++++++
 org.gnome.ekiga.gschema.xml.in.in                  |    5 +++++
 4 files changed, 40 insertions(+), 0 deletions(-)
---
diff --git a/lib/engine/components/opal/process/sip-endpoint.cpp 
b/lib/engine/components/opal/process/sip-endpoint.cpp
index 2f0553a..0196fce 100644
--- a/lib/engine/components/opal/process/sip-endpoint.cpp
+++ b/lib/engine/components/opal/process/sip-endpoint.cpp
@@ -68,6 +68,7 @@ namespace Opal {
 
           SIPRegister::Params params;
           params.m_addressOfRecord = "sip:" + account.get_username () + "@" + account.get_host () + 
";transport=tcp";
+          params.m_instanceId = ep.GetInstanceID ();
           params.m_compatibility = SIPRegister::e_RFC5626;
           params.m_authID = account.get_authentication_username ();
           params.m_password = account.get_password ();
@@ -234,6 +235,21 @@ Opal::Sip::EndPoint::SetBusyForwardTarget (const PString & _party)
 
 
 void
+Opal::Sip::EndPoint::SetInstanceID (const PString & id)
+{
+  if (!id.empty ())
+    instanceID = PGloballyUniqueID (id);
+}
+
+
+PGloballyUniqueID &
+Opal::Sip::EndPoint::GetInstanceID ()
+{
+  return instanceID;
+}
+
+
+void
 Opal::Sip::EndPoint::OnRegistrationStatus (const RegistrationStatus & status)
 {
   std::string info;
@@ -283,6 +299,7 @@ Opal::Sip::EndPoint::OnRegistrationStatus (const RegistrationStatus & status)
         m_addressOfRecord.SetParamVar ("OPAL-proxy", proxy);
       }
       params.m_addressOfRecord = m_addressOfRecord;
+      params.m_instanceId = GetInstanceID ();
       params.m_compatibility = SIPRegister::e_RFC5626;
       params.m_authID = status.m_handler->GetAuthID ();
       params.m_password = status.m_handler->GetPassword ();
diff --git a/lib/engine/components/opal/process/sip-endpoint.h 
b/lib/engine/components/opal/process/sip-endpoint.h
index 7aae442..c7bef0c 100644
--- a/lib/engine/components/opal/process/sip-endpoint.h
+++ b/lib/engine/components/opal/process/sip-endpoint.h
@@ -97,6 +97,9 @@ namespace Opal {
 
       void SetBusyForwardTarget (const PString & party);
 
+      void SetInstanceID (const PString & id);
+
+      PGloballyUniqueID & GetInstanceID ();
 
     private:
       /* OPAL Methods */
@@ -122,6 +125,7 @@ namespace Opal {
       PString noAnswerForwardParty;
       PString unconditionalForwardParty;
       PString busyForwardParty;
+      PGloballyUniqueID instanceID;
     };
   };
 };
diff --git a/lib/engine/components/opal/sip-call-manager.cpp b/lib/engine/components/opal/sip-call-manager.cpp
index e812492..efbcec0 100644
--- a/lib/engine/components/opal/sip-call-manager.cpp
+++ b/lib/engine/components/opal/sip-call-manager.cpp
@@ -56,7 +56,15 @@ Opal::Sip::CallManager::CallManager (Ekiga::ServiceCore& _core,
   sip_settings = Ekiga::SettingsPtr (new Ekiga::Settings (SIP_SCHEMA, setup_cb));
   call_forwarding_settings = Ekiga::SettingsPtr (new Ekiga::Settings (CALL_FORWARDING_SCHEMA, setup_cb));
 
+  /* Initial setup */
   setup ("");
+
+  /* Generate a RFC 5626 compatible instance id if needed */
+  std::string instance_id = sip_settings->get_string ("instance-id");
+  if (instance_id.empty ()) {
+    instance_id = (const char*) PGloballyUniqueID ().AsString ();
+    sip_settings->set_string ("instance-id", instance_id);
+  }
 }
 
 
@@ -172,6 +180,12 @@ void Opal::Sip::CallManager::setup (const std::string & setting)
     return;
   }
 
+  if (setting.empty () || setting == "instance-id") {
+    std::string instance_id = sip_settings->get_string ("instance-id");
+    if (!instance_id.empty ())
+      sip_endpoint.SetInstanceID (instance_id);
+  }
+
   if (setting.empty () || setting == "listen-port")
     set_listen_port (sip_settings->get_int ("listen-port"));
 
diff --git a/org.gnome.ekiga.gschema.xml.in.in b/org.gnome.ekiga.gschema.xml.in.in
index 1f813dc..7503a41 100644
--- a/org.gnome.ekiga.gschema.xml.in.in
+++ b/org.gnome.ekiga.gschema.xml.in.in
@@ -434,6 +434,11 @@
       <_summary>Connection keepalive interval</_summary>
       <_description>Enter the number of seconds between keepalive messages sent by Ekiga to maintain the 
connection</_description>
     </key>
+    <key name="instance-id" type="s">
+      <default>''</default>
+      <_summary>Instance ID</_summary>
+      <_description>This is a Uniform Resource Name (URN) that uniquely identifies this specific UA 
instance. It will be generated on the first run.</_description>
+    </key>
   </schema>
   <schema gettext-domain="@GETTEXT_PACKAGE@" id="org gnome  PACKAGE_NAME@.protocols.h323" 
path="/org/gnome/@PACKAGE_NAME@/protocols/h323/">
     <key name="listen-port" type="i">


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