[ekiga] Made the call manager handle the presentity subscriptions



commit fa3db37ab11eb80e81bc31efd849f8c71896e86c
Author: Julien Puydt <jpuydt free fr>
Date:   Fri Feb 8 15:40:19 2013 +0100

    Made the call manager handle the presentity subscriptions
    
    That means the bank and accounts don't need to wonder as much as
    before about H323 vs SIP -- and in particular, they don't use the H323
    endpoint anymore.

 lib/engine/components/opal/opal-account.cpp      |   64 +++++-----------------
 lib/engine/components/opal/opal-account.h        |   18 +-----
 lib/engine/components/opal/opal-bank.cpp         |   12 ----
 lib/engine/components/opal/opal-bank.h           |    3 -
 lib/engine/components/opal/opal-call-manager.cpp |   36 ++++++++++++
 lib/engine/components/opal/opal-call-manager.h   |    9 +++
 6 files changed, 62 insertions(+), 80 deletions(-)
---
diff --git a/lib/engine/components/opal/opal-account.cpp b/lib/engine/components/opal/opal-account.cpp
index dce5293..59727e3 100644
--- a/lib/engine/components/opal/opal-account.cpp
+++ b/lib/engine/components/opal/opal-account.cpp
@@ -57,29 +57,20 @@
 #include "platform.h"
 
 #include "sip-endpoint.h"
-#ifdef HAVE_H323
-#include "h323-endpoint.h"
-#endif
 
 Opal::Account::Account (boost::shared_ptr<Opal::Sip::EndPoint> _sip_endpoint,
-#ifdef HAVE_H323
-			boost::shared_ptr<Opal::H323::EndPoint> _h323_endpoint,
-#endif
 			boost::shared_ptr<Ekiga::PresenceCore> _presence_core,
 			boost::shared_ptr<Ekiga::NotificationCore> _notification_core,
 			boost::shared_ptr<Ekiga::PersonalDetails> _personal_details,
 			boost::shared_ptr<Ekiga::AudioOutputCore> _audiooutput_core,
-			boost::shared_ptr<CallManager> _opal_component,
+			boost::shared_ptr<CallManager> _call_manager,
 			const std::string & account):
   sip_endpoint(_sip_endpoint),
-#ifdef HAVE_H323
-  h323_endpoint(_h323_endpoint),
-#endif
   presence_core(_presence_core),
   notification_core(_notification_core),
   personal_details(_personal_details),
   audiooutput_core(_audiooutput_core),
-  opal_component(_opal_component)
+  call_manager(_call_manager)
 {
   state = Unregistered;
   status = _("Unregistered");
@@ -164,14 +155,11 @@ Opal::Account::Account (boost::shared_ptr<Opal::Sip::EndPoint> _sip_endpoint,
 
 
 Opal::Account::Account (boost::shared_ptr<Opal::Sip::EndPoint> _sip_endpoint,
-#ifdef HAVE_H323
-			boost::shared_ptr<Opal::H323::EndPoint> _h323_endpoint,
-#endif
 			boost::shared_ptr<Ekiga::PresenceCore> _presence_core,
 			boost::shared_ptr<Ekiga::NotificationCore> _notification_core,
 			boost::shared_ptr<Ekiga::PersonalDetails> _personal_details,
 			boost::shared_ptr<Ekiga::AudioOutputCore> _audiooutput_core,
-			boost::shared_ptr<CallManager> _opal_component,
+			boost::shared_ptr<CallManager> _call_manager,
 			Type t,
                         std::string _name,
                         std::string _host,
@@ -181,14 +169,11 @@ Opal::Account::Account (boost::shared_ptr<Opal::Sip::EndPoint> _sip_endpoint,
                         bool _enabled,
                         unsigned _timeout):
   sip_endpoint(_sip_endpoint),
-#ifdef HAVE_H323
-  h323_endpoint(_h323_endpoint),
-#endif
   presence_core(_presence_core),
   notification_core(_notification_core),
   personal_details(_personal_details),
   audiooutput_core(_audiooutput_core),
-  opal_component(_opal_component)
+  call_manager(_call_manager)
 {
   state = Unregistered;
   status = "";
@@ -331,14 +316,7 @@ void Opal::Account::enable ()
 
   state = Processing;
   status = _("Processing...");
-#ifdef HAVE_H323
-  if (type == Account::H323)
-    h323_endpoint->subscribe (*this, presentity);
-  else
-#endif
-    {
-      sip_endpoint->subscribe (*this, presentity);
-    }
+  call_manager->subscribe (*this, presentity);
 
   updated ();
   trigger_saving ();
@@ -357,13 +335,12 @@ void Opal::Account::disable ()
       Ekiga::Runtime::run_in_main (boost::bind (&Opal::Account::presence_status_in_main, this, *iter, "unknown", ""));
     }
   }
-#ifdef HAVE_H323
+
   if (type == Account::H323)
-    h323_endpoint->unsubscribe (*this, presentity);
-  else
-#endif
-    {
-      sip_endpoint->unsubscribe (*this, presentity);
+    call_manager->unsubscribe (*this, presentity);
+  else {
+
+      call_manager->unsubscribe (*this, presentity);
       sip_endpoint->Unsubscribe (SIPSubscribe::MessageSummary, get_aor ());
     }
 
@@ -459,11 +436,6 @@ Opal::Account::populate_menu (const std::string fullname,
 			      const std::string uri,
 			      Ekiga::MenuBuilder& builder)
 {
-  boost::shared_ptr<Opal::CallManager> call_manager = opal_component.lock ();
-
-  if (!call_manager)
-    return false;
-
   bool result = false;
   Ekiga::TemporaryMenuBuilder tmp_builder;
   std::string protocol;
@@ -762,7 +734,6 @@ Opal::Account::handle_registration_event (RegistrationState state_,
   case RegistrationFailed:
 
     state = state_;
-#ifdef HAVE_H323
     if (type == Account::H323) {
         std::stringstream msg;
         msg << _("Could not register to ") << get_name ();
@@ -772,25 +743,24 @@ Opal::Account::handle_registration_event (RegistrationState state_,
 	  ncore->push_notification (notif);
     }
     else {
-#endif
       switch (compat_mode) {
       case SIPRegister::e_FullyCompliant:
         // FullyCompliant did not work, try next compat mode
         compat_mode = SIPRegister::e_CannotRegisterMultipleContacts;
         PTRACE (4, "Register failed in FullyCompliant mode, retrying in CannotRegisterMultipleContacts mode");
-        sip_endpoint->subscribe (*this, presentity);
+        call_manager->subscribe (*this, presentity);
         break;
       case SIPRegister::e_CannotRegisterMultipleContacts:
         // CannotRegMC did not work, try next compat mode
         compat_mode = SIPRegister::e_CannotRegisterPrivateContacts;
         PTRACE (4, "Register failed in CannotRegisterMultipleContacts mode, retrying in CannotRegisterPrivateContacts mode");
-        sip_endpoint->subscribe (*this, presentity);
+        call_manager->subscribe (*this, presentity);
         break;
       case SIPRegister::e_CannotRegisterPrivateContacts:
         // CannotRegMC did not work, try next compat mode
         compat_mode = SIPRegister::e_HasApplicationLayerGateway;
         PTRACE (4, "Register failed in CannotRegisterMultipleContacts mode, retrying in HasApplicationLayerGateway mode");
-        sip_endpoint->subscribe (*this, presentity);
+        call_manager->subscribe (*this, presentity);
         break;
       case SIPRegister::e_HasApplicationLayerGateway:
         // HasAppLG did not work, stop registration with error
@@ -816,9 +786,7 @@ Opal::Account::handle_registration_event (RegistrationState state_,
         updated();
         break;
       }
-#ifdef HAVE_H323
     }
-#endif
     break;
 
   case Processing:
@@ -862,12 +830,8 @@ Opal::Account::get_type () const
 void
 Opal::Account::setup_presentity ()
 {
-  boost::shared_ptr<CallManager> manager = opal_component.lock ();
-  if (!manager)
-    return;
-
   PURL url = PString (get_aor ());
-  presentity = manager->AddPresentity (url);
+  presentity = call_manager->AddPresentity (url);
 
   if (presentity) {
 
diff --git a/lib/engine/components/opal/opal-account.h b/lib/engine/components/opal/opal-account.h
index dc00492..ff7884a 100644
--- a/lib/engine/components/opal/opal-account.h
+++ b/lib/engine/components/opal/opal-account.h
@@ -55,9 +55,6 @@ namespace Opal
   // forward declarations:
   class CallManager;
   namespace Sip { class EndPoint; };
-#ifdef HAVE_H323
-  namespace H323 { class EndPoint; };
-#endif
 
   /**
    * @addtogroup accounts
@@ -76,25 +73,19 @@ public:
     typedef enum { Processing, Registered, Unregistered, RegistrationFailed, UnregistrationFailed } RegistrationState;
 
     Account (boost::shared_ptr<Opal::Sip::EndPoint> _sip_endpoint,
-#ifdef HAVE_H323
-	     boost::shared_ptr<Opal::H323::EndPoint> _h323_endpoint,
-#endif
 	     boost::shared_ptr<Ekiga::PresenceCore> _presence_core,
 	     boost::shared_ptr<Ekiga::NotificationCore> _notification_core,
 	     boost::shared_ptr<Ekiga::PersonalDetails> _personal_details,
 	     boost::shared_ptr<Ekiga::AudioOutputCore> _audiooutput_core,
-	     boost::shared_ptr<CallManager> _opal_component,
+	     boost::shared_ptr<CallManager> _call_manager,
 	     const std::string & account);
 
     Account (boost::shared_ptr<Opal::Sip::EndPoint> _sip_endpoint,
-#ifdef HAVE_H323
-	     boost::shared_ptr<Opal::H323::EndPoint> _h323_endpoint,
-#endif
 	     boost::shared_ptr<Ekiga::PresenceCore> _presence_core,
 	     boost::shared_ptr<Ekiga::NotificationCore> _notification_core,
 	     boost::shared_ptr<Ekiga::PersonalDetails> _personal_details,
 	     boost::shared_ptr<Ekiga::AudioOutputCore> _audiooutput_core,
-	     boost::shared_ptr<CallManager> _opal_component,
+	     boost::shared_ptr<CallManager> _call_manager,
 	     Type t,
              std::string name,
              std::string host,
@@ -237,14 +228,11 @@ private:
 				  std::string status);
 
     boost::shared_ptr<Opal::Sip::EndPoint> sip_endpoint;
-#ifdef HAVE_H323
-    boost::shared_ptr<Opal::H323::EndPoint> h323_endpoint;
-#endif
     boost::weak_ptr<Ekiga::PresenceCore> presence_core;
     boost::weak_ptr<Ekiga::NotificationCore> notification_core;
     boost::weak_ptr<Ekiga::PersonalDetails> personal_details;
     boost::weak_ptr<Ekiga::AudioOutputCore> audiooutput_core;
-    boost::weak_ptr<CallManager> opal_component;
+    boost::shared_ptr<CallManager> call_manager;
   };
 
   typedef boost::shared_ptr<Account> AccountPtr;
diff --git a/lib/engine/components/opal/opal-bank.cpp b/lib/engine/components/opal/opal-bank.cpp
index 0b333c7..56fbef8 100644
--- a/lib/engine/components/opal/opal-bank.cpp
+++ b/lib/engine/components/opal/opal-bank.cpp
@@ -49,15 +49,9 @@
 
 #include "opal-bank.h"
 #include "sip-endpoint.h"
-#ifdef HAVE_H323
-#include "h323-endpoint.h"
-#endif
 
 Opal::Bank::Bank (Ekiga::ServiceCore& core):
   sip_endpoint(core.get<Opal::Sip::EndPoint> ("opal-sip-endpoint")),
-#ifdef HAVE_H323
-  h323_endpoint(core.get<Opal::H323::EndPoint> ("opal-h323-endpoint")),
-#endif
   presence_core(core.get<Ekiga::PresenceCore> ("presence-core")),
   notification_core(core.get<Ekiga::NotificationCore> ("notification-core")),
   personal_details(core.get<Ekiga::PersonalDetails> ("personal-details")),
@@ -75,9 +69,6 @@ Opal::Bank::Bank (Ekiga::ServiceCore& core):
 
     boost::shared_ptr<Account> account
       = boost::shared_ptr<Account> (new Account (sip_endpoint,
-#ifdef HAVE_H323
-						 h323_endpoint,
-#endif
 						 pcore,
 						 notification_core,
 						 personal_details,
@@ -283,9 +274,6 @@ void Opal::Bank::add (Account::Type acc_type,
     return;
   AccountPtr account
     = AccountPtr(new Opal::Account (sip_endpoint,
-#ifdef HAVE_H323
-				    h323_endpoint,
-#endif
 				    pcore,
 				    notification_core,
 				    personal_details,
diff --git a/lib/engine/components/opal/opal-bank.h b/lib/engine/components/opal/opal-bank.h
index 41810ed..61be537 100644
--- a/lib/engine/components/opal/opal-bank.h
+++ b/lib/engine/components/opal/opal-bank.h
@@ -109,9 +109,6 @@ public:
 
 private:
     boost::shared_ptr<Opal::Sip::EndPoint> sip_endpoint;
-#ifdef HAVE_H323
-    boost::shared_ptr<Opal::H323::EndPoint> h323_endpoint;
-#endif
     boost::weak_ptr<Ekiga::PresenceCore> presence_core;
     boost::shared_ptr<Ekiga::NotificationCore> notification_core;
     boost::shared_ptr<Ekiga::PersonalDetails> personal_details;
diff --git a/lib/engine/components/opal/opal-call-manager.cpp b/lib/engine/components/opal/opal-call-manager.cpp
index fcbf466..075a69d 100644
--- a/lib/engine/components/opal/opal-call-manager.cpp
+++ b/lib/engine/components/opal/opal-call-manager.cpp
@@ -914,6 +914,42 @@ CallManager::CreateVideoOutputDevice(const OpalConnection & connection,
   return device != NULL;
 }
 
+bool
+CallManager::subscribe (const Opal::Account& account,
+			const PSafePtr<OpalPresentity>& presentity)
+{
+  if (account.get_protocol_name () == "H323") {
+
+#ifdef HAVE_H323
+    return h323_endpoint->subscribe (account, presentity);
+#else
+    return false;
+#endif
+
+  } else {
+
+    return sip_endpoint->subscribe (account, presentity);
+  }
+}
+
+bool
+CallManager::unsubscribe (const Opal::Account& account,
+			  const PSafePtr<OpalPresentity>& presentity)
+{
+  if (account.get_protocol_name () == "H323") {
+
+#ifdef HAVE_H323
+    return h323_endpoint->unsubscribe (account, presentity);
+#else
+    return false;
+#endif
+
+  } else {
+
+    return sip_endpoint->unsubscribe (account, presentity);
+  }
+}
+
 void
 CallManager::set_sip_endpoint (boost::shared_ptr<Opal::Sip::EndPoint> _sip_endpoint)
 {
diff --git a/lib/engine/components/opal/opal-call-manager.h b/lib/engine/components/opal/opal-call-manager.h
index cfbeb90..9c4c5bb 100644
--- a/lib/engine/components/opal/opal-call-manager.h
+++ b/lib/engine/components/opal/opal-call-manager.h
@@ -62,6 +62,7 @@ class GMPCSSEndpoint;
 
 namespace Opal {
 
+  class Account;
   namespace Sip { class EndPoint; };
   namespace H323 { class EndPoint; };
 
@@ -115,7 +116,15 @@ public:
     void set_codecs (Ekiga::CodecList & codecs); 
     const Ekiga::CodecList & get_codecs () const;
 
+    /* presence subscription management */
+    bool subscribe (const Opal::Account& account,
+		    const PSafePtr<OpalPresentity>& presentity);
+
+    bool unsubscribe (const Opal::Account& account,
+		    const PSafePtr<OpalPresentity>& presentity);
+
     /* Extended stuff, OPAL CallManager specific */
+
     void set_forward_on_busy (bool enabled);
     bool get_forward_on_busy ();
 


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