[ekiga/ds-opal-refactoring] Opal: Use references to objects when possible.
- From: Damien Sandras <dsandras src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga/ds-opal-refactoring] Opal: Use references to objects when possible.
- Date: Sat, 21 Mar 2015 17:50:24 +0000 (UTC)
commit 4a18ec26a57859ae7b0474d254bb41eb8f3ff2fc
Author: Damien Sandras <dsandras seconix com>
Date: Sat Mar 21 18:26:24 2015 +0100
Opal: Use references to objects when possible.
Use the SIP::EndPoint and H323::EndPoint directly in the
SIP::CallManager and H323::CallManager.
lib/engine/components/opal/h323-call-manager.cpp | 171 +++++++++-----------
lib/engine/components/opal/h323-call-manager.h | 6 +-
lib/engine/components/opal/opal-call-manager.h | 1 +
lib/engine/components/opal/opal-main.cpp | 11 +-
.../components/opal/process/h323-endpoint.cpp | 9 +-
lib/engine/components/opal/process/h323-endpoint.h | 7 +-
.../components/opal/process/opal-endpoint.cpp | 16 +-
lib/engine/components/opal/process/opal-endpoint.h | 24 ++-
.../components/opal/process/opal-process.cpp | 12 +-
lib/engine/components/opal/process/opal-process.h | 4 +-
.../components/opal/process/sip-endpoint.cpp | 35 ++---
lib/engine/components/opal/process/sip-endpoint.h | 11 +--
lib/engine/components/opal/sip-call-manager.cpp | 100 +++++-------
lib/engine/components/opal/sip-call-manager.h | 5 +-
14 files changed, 181 insertions(+), 231 deletions(-)
---
diff --git a/lib/engine/components/opal/h323-call-manager.cpp
b/lib/engine/components/opal/h323-call-manager.cpp
index 47cf2ef..1dc8844 100644
--- a/lib/engine/components/opal/h323-call-manager.cpp
+++ b/lib/engine/components/opal/h323-call-manager.cpp
@@ -46,7 +46,10 @@
/* The engine class */
Opal::H323::CallManager::CallManager (Ekiga::ServiceCore& _core,
- Opal::EndPoint& _endpoint) : Opal::CallManager (_core, _endpoint),
protocol_name ("h323")
+ Opal::EndPoint& _endpoint,
+ Opal::H323::EndPoint& _h323_endpoint)
+ : Opal::CallManager (_core, _endpoint),
+ h323_endpoint (_h323_endpoint), protocol_name ("h323")
{
/* Setup things */
Ekiga::SettingsCallback setup_cb = boost::bind (&Opal::H323::CallManager::setup, this, _1);
@@ -81,11 +84,7 @@ bool Opal::H323::CallManager::dial (const std::string & uri)
if (!is_supported_uri (uri))
return false;
- boost::shared_ptr<Opal::H323::EndPoint> h323_endpoint = endpoint.get_h323_endpoint ();
- if (h323_endpoint)
- return h323_endpoint->SetUpCall (uri);
-
- return false;
+ return h323_endpoint.SetUpCall (uri);
}
@@ -106,11 +105,7 @@ const Ekiga::CallManager::InterfaceList Opal::H323::CallManager::get_interfaces
{
Ekiga::CallManager::InterfaceList ilist;
- boost::shared_ptr<Opal::H323::EndPoint> h323_endpoint = endpoint.get_h323_endpoint ();
- if (!h323_endpoint)
- return ilist;
-
- OpalListenerList listeners = h323_endpoint->GetListeners ();
+ OpalListenerList listeners = h323_endpoint.GetListeners ();
for (int i = 0 ; i < listeners.GetSize () ; i++) {
Ekiga::CallManager::Interface iface;
PIPSocket::Address address;
@@ -133,59 +128,49 @@ const Ekiga::CallManager::InterfaceList Opal::H323::CallManager::get_interfaces
bool
Opal::H323::CallManager::set_listen_port (unsigned port)
{
- boost::shared_ptr<Opal::H323::EndPoint> h323_endpoint = endpoint.get_h323_endpoint ();
- if (h323_endpoint)
- return h323_endpoint->StartListener (port);
-
- return false;
+ return h323_endpoint.StartListener (port);
}
void
Opal::H323::CallManager::set_dtmf_mode (unsigned mode)
{
- boost::shared_ptr<Opal::H323::EndPoint> h323_endpoint = endpoint.get_h323_endpoint ();
- if (h323_endpoint) {
- switch (mode)
- {
- case 0:
- h323_endpoint->SetSendUserInputMode (OpalConnection::SendUserInputAsString);
- PTRACE (4, "Opal::H323::CallManager\tSet DTMF Mode to String");
- break;
- case 1:
- h323_endpoint->SetSendUserInputMode (OpalConnection::SendUserInputAsTone);
- PTRACE (4, "Opal::H323::CallManager\tSet DTMF Mode to Tone");
- break;
- case 3:
- h323_endpoint->SetSendUserInputMode (OpalConnection::SendUserInputAsQ931);
- PTRACE (4, "Opal::H323::CallManager\tSet DTMF Mode to Q931");
- break;
- default:
- h323_endpoint->SetSendUserInputMode (OpalConnection::SendUserInputAsInlineRFC2833);
- PTRACE (4, "Opal::H323::CallManager\tSet DTMF Mode to RFC2833");
- break;
- }
- }
+ switch (mode)
+ {
+ case 0:
+ h323_endpoint.SetSendUserInputMode (OpalConnection::SendUserInputAsString);
+ PTRACE (4, "Opal::H323::CallManager\tSet DTMF Mode to String");
+ break;
+ case 1:
+ h323_endpoint.SetSendUserInputMode (OpalConnection::SendUserInputAsTone);
+ PTRACE (4, "Opal::H323::CallManager\tSet DTMF Mode to Tone");
+ break;
+ case 3:
+ h323_endpoint.SetSendUserInputMode (OpalConnection::SendUserInputAsQ931);
+ PTRACE (4, "Opal::H323::CallManager\tSet DTMF Mode to Q931");
+ break;
+ default:
+ h323_endpoint.SetSendUserInputMode (OpalConnection::SendUserInputAsInlineRFC2833);
+ PTRACE (4, "Opal::H323::CallManager\tSet DTMF Mode to RFC2833");
+ break;
+ }
}
unsigned
Opal::H323::CallManager::get_dtmf_mode () const
{
- boost::shared_ptr<Opal::H323::EndPoint> h323_endpoint = endpoint.get_h323_endpoint ();
- if (h323_endpoint) {
- if (h323_endpoint->GetSendUserInputMode () == OpalConnection::SendUserInputAsString)
- return 0;
+ if (h323_endpoint.GetSendUserInputMode () == OpalConnection::SendUserInputAsString)
+ return 0;
- if (h323_endpoint->GetSendUserInputMode () == OpalConnection::SendUserInputAsTone)
- return 1;
+ if (h323_endpoint.GetSendUserInputMode () == OpalConnection::SendUserInputAsTone)
+ return 1;
- if (h323_endpoint->GetSendUserInputMode () == OpalConnection::SendUserInputAsInlineRFC2833)
- return 2;
+ if (h323_endpoint.GetSendUserInputMode () == OpalConnection::SendUserInputAsInlineRFC2833)
+ return 2;
- if (h323_endpoint->GetSendUserInputMode () == OpalConnection::SendUserInputAsQ931)
- return 2;
- }
+ if (h323_endpoint.GetSendUserInputMode () == OpalConnection::SendUserInputAsQ931)
+ return 2;
g_return_val_if_reached (1);
}
@@ -193,61 +178,55 @@ Opal::H323::CallManager::get_dtmf_mode () const
void Opal::H323::CallManager::setup (const std::string & setting)
{
- std::cout << "In Opal::H323::EndPoint::setup " << std::endl;
- boost::shared_ptr<Opal::H323::EndPoint> h323_endpoint = endpoint.get_h323_endpoint ();
- if (h323_endpoint) {
-
- if (setting.empty () || setting == "listen-port") {
+ if (setting.empty () || setting == "listen-port") {
- set_listen_port (h323_settings->get_int ("listen-port"));
- }
- if (setting.empty () || setting == "maximum-video-tx-bitrate") {
-
- int maximum_video_tx_bitrate = video_codecs_settings->get_int ("maximum-video-tx-bitrate");
- // maximum_video_tx_bitrate is the max video bitrate specified by the user
- // add to it 10% (approx.) accounting for audio,
- // and multiply it by 10 as needed by SetInitialBandwidth
- h323_endpoint->set_initial_bandwidth (maximum_video_tx_bitrate * 11);
- }
- if (setting.empty () || setting == "enable-h245-tunneling") {
+ set_listen_port (h323_settings->get_int ("listen-port"));
+ }
+ if (setting.empty () || setting == "maximum-video-tx-bitrate") {
- h323_endpoint->DisableH245Tunneling (!h323_settings->get_bool ("enable-h245-tunneling"));
- PTRACE (4, "Opal::H323::EndPoint\tH.245 Tunneling: " << h323_settings->get_bool
("enable-h245-tunneling"));
- }
- if (setting.empty () || setting == "enable-early-h245") {
+ int maximum_video_tx_bitrate = video_codecs_settings->get_int ("maximum-video-tx-bitrate");
+ // maximum_video_tx_bitrate is the max video bitrate specified by the user
+ // add to it 10% (approx.) accounting for audio,
+ // and multiply it by 10 as needed by SetInitialBandwidth
+ h323_endpoint.set_initial_bandwidth (maximum_video_tx_bitrate * 11);
+ }
+ if (setting.empty () || setting == "enable-h245-tunneling") {
- h323_endpoint->DisableH245inSetup (!h323_settings->get_bool ("enable-early-h245"));
- PTRACE (4, "Opal::H323::EndPoint\tEarly H.245: " << h323_settings->get_bool ("enable-early-h245"));
- }
- if (setting.empty () || setting == "enable-fast-connect") {
+ h323_endpoint.DisableH245Tunneling (!h323_settings->get_bool ("enable-h245-tunneling"));
+ PTRACE (4, "Opal::H323::EndPoint\tH.245 Tunneling: " << h323_settings->get_bool
("enable-h245-tunneling"));
+ }
+ if (setting.empty () || setting == "enable-early-h245") {
- h323_endpoint->DisableFastStart (!h323_settings->get_bool ("enable-fast-connect"));
- PTRACE (4, "Opal::H323::EndPoint\tFast Connect: " << h323_settings->get_bool ("enable-fast-connect"));
- }
- if (setting.empty () || setting == "dtmf-mode") {
+ h323_endpoint.DisableH245inSetup (!h323_settings->get_bool ("enable-early-h245"));
+ PTRACE (4, "Opal::H323::EndPoint\tEarly H.245: " << h323_settings->get_bool ("enable-early-h245"));
+ }
+ if (setting.empty () || setting == "enable-fast-connect") {
- set_dtmf_mode (h323_settings->get_enum ("dtmf-mode"));
- }
- if (setting.empty () || setting == "forward-host") {
+ h323_endpoint.DisableFastStart (!h323_settings->get_bool ("enable-fast-connect"));
+ PTRACE (4, "Opal::H323::EndPoint\tFast Connect: " << h323_settings->get_bool ("enable-fast-connect"));
+ }
+ if (setting.empty () || setting == "dtmf-mode") {
- h323_endpoint->set_forward_uri (h323_settings->get_string ("forward-host"));
- }
- if (setting.empty () || setting == "video-role") {
-
- /*
- CallManager::VideoOptions options;
- endpoint.get_video_options (options);
- options.extended_video_roles = h323_settings->get_enum ("video-role");
- endpoint.set_video_options (options);
- */
- std::cout << "FIXME" << std::endl;
- }
- if (setting.empty () || setting == "enable-h239") {
+ set_dtmf_mode (h323_settings->get_enum ("dtmf-mode"));
+ }
+ if (setting.empty () || setting == "forward-host") {
- h323_endpoint->SetDefaultH239Control(h323_settings->get_bool ("enable-h239"));
- PTRACE (4, "Opal::H323::EndPoint\tH.239 Control: " << h323_settings->get_bool ("enable-h239"));
- }
+ h323_endpoint.set_forward_uri (h323_settings->get_string ("forward-host"));
+ }
+ if (setting.empty () || setting == "video-role") {
+
+ /*
+ CallManager::VideoOptions options;
+ endpoint.get_video_options (options);
+ options.extended_video_roles = h323_settings->get_enum ("video-role");
+ endpoint.set_video_options (options);
+ */
+ std::cout << "FIXME" << std::endl;
+ }
+ if (setting.empty () || setting == "enable-h239") {
+ h323_endpoint.SetDefaultH239Control(h323_settings->get_bool ("enable-h239"));
+ PTRACE (4, "Opal::H323::EndPoint\tH.239 Control: " << h323_settings->get_bool ("enable-h239"));
}
// We do not call the parent setup () method as it is also handled
diff --git a/lib/engine/components/opal/h323-call-manager.h b/lib/engine/components/opal/h323-call-manager.h
index 9252e35..42fcbd0 100644
--- a/lib/engine/components/opal/h323-call-manager.h
+++ b/lib/engine/components/opal/h323-call-manager.h
@@ -41,6 +41,7 @@
#include "opal-call-manager.h"
#include "opal-endpoint.h"
+#include "h323-endpoint.h"
#include "ekiga-settings.h"
@@ -58,7 +59,8 @@ namespace Opal {
{
public:
CallManager (Ekiga::ServiceCore& core,
- Opal::EndPoint& endpoint);
+ Opal::EndPoint& endpoint,
+ Opal::H323::EndPoint& h323_endpoint);
~CallManager ();
/* URIActionProvider Methods */
@@ -87,6 +89,8 @@ namespace Opal {
Ekiga::SettingsPtr h323_settings;
Ekiga::SettingsPtr video_codecs_settings;
+ Opal::H323::EndPoint& h323_endpoint;
+
std::string protocol_name;
};
};
diff --git a/lib/engine/components/opal/opal-call-manager.h b/lib/engine/components/opal/opal-call-manager.h
index e664d3b..70ed303 100644
--- a/lib/engine/components/opal/opal-call-manager.h
+++ b/lib/engine/components/opal/opal-call-manager.h
@@ -40,6 +40,7 @@
#include "call-manager.h"
#include "opal-endpoint.h"
+#include "opal-call.h"
#include "ekiga-settings.h"
diff --git a/lib/engine/components/opal/opal-main.cpp b/lib/engine/components/opal/opal-main.cpp
index 981b86f..3c48fde 100644
--- a/lib/engine/components/opal/opal-main.cpp
+++ b/lib/engine/components/opal/opal-main.cpp
@@ -89,13 +89,16 @@ struct OPALSpark: public Ekiga::Spark
hook_ekiga_plugins_to_opal (core);
// We create our various CallManagers: SIP, H.323
- boost::shared_ptr<Opal::Sip::CallManager> sip_call_manager (new Opal::Sip::CallManager (core,
GnomeMeeting::Process ()->get_endpoint ()));
+ Opal::EndPoint& endpoint = GnomeMeeting::Process ()->GetEndPoint ();
+ Opal::Sip::EndPoint& sip_endpoint = endpoint.GetSipEndPoint ();
+ boost::shared_ptr<Opal::Sip::CallManager> sip_call_manager (new Opal::Sip::CallManager (core,
endpoint, sip_endpoint));
contact_core->push_back (Ekiga::URIActionProviderPtr (sip_call_manager));
presence_core->push_back (Ekiga::URIActionProviderPtr (sip_call_manager));
call_core->add_manager (sip_call_manager);
#ifdef HAVE_H323
- boost::shared_ptr<Opal::H323::CallManager> h323_call_manager (new Opal::H323::CallManager (core,
GnomeMeeting::Process ()->get_endpoint ()));
+ Opal::H323::EndPoint& h323_endpoint = endpoint.GetH323EndPoint ();
+ boost::shared_ptr<Opal::H323::CallManager> h323_call_manager (new Opal::H323::CallManager (core,
endpoint, h323_endpoint));
contact_core->push_back (Ekiga::URIActionProviderPtr (h323_call_manager));
presence_core->push_back (Ekiga::URIActionProviderPtr (h323_call_manager));
call_core->add_manager (h323_call_manager);
@@ -104,9 +107,9 @@ struct OPALSpark: public Ekiga::Spark
std::cout << "FIXME HERE" << std::endl;
boost::shared_ptr<Opal::Bank> bank = boost::shared_ptr<Opal::Bank> (new Opal::Bank (core,
#ifdef HAVE_H323
-
GnomeMeeting::Process ()->get_endpoint ().get_h323_endpoint ().get (),
+ &h323_endpoint,
#endif
-
GnomeMeeting::Process ()->get_endpoint ().get_sip_endpoint ().get ()));
+ &sip_endpoint));
account_core->add_bank (bank);
presence_core->add_cluster (bank);
diff --git a/lib/engine/components/opal/process/h323-endpoint.cpp
b/lib/engine/components/opal/process/h323-endpoint.cpp
index 9b9c576..f18c995 100644
--- a/lib/engine/components/opal/process/h323-endpoint.cpp
+++ b/lib/engine/components/opal/process/h323-endpoint.cpp
@@ -140,13 +140,12 @@ namespace Opal {
/* The class */
Opal::H323::EndPoint::EndPoint (Opal::EndPoint & _endpoint,
const Ekiga::ServiceCore& _core): H323EndPoint (_endpoint),
- endpoint (_endpoint),
- core (_core)
+ core (_core)
{
uri_prefix = "h323:";
/* Ready to take calls */
- endpoint.AddRouteEntry("h323:.* = pc:*");
- endpoint.AddRouteEntry("pc:.* = h323:<da>");
+ GetManager ().AddRouteEntry("h323:.* = pc:*");
+ GetManager ().AddRouteEntry("pc:.* = h323:<da>");
std::cout << "FIXME" << std::endl;
// manager.ready.connect (boost::bind (&EndPoint::setup, this, ""));
@@ -161,7 +160,7 @@ bool
Opal::H323::EndPoint::SetUpCall (const std::string& uri)
{
PString token;
- endpoint.SetUpCall("pc:*", uri, token, (void*) uri.c_str());
+ GetManager ().SetUpCall("pc:*", uri, token, (void*) uri.c_str());
return true;
}
diff --git a/lib/engine/components/opal/process/h323-endpoint.h
b/lib/engine/components/opal/process/h323-endpoint.h
index dc5af5b..fd43c94 100644
--- a/lib/engine/components/opal/process/h323-endpoint.h
+++ b/lib/engine/components/opal/process/h323-endpoint.h
@@ -53,6 +53,8 @@
namespace Opal {
+ class EndPoint;
+
namespace H323 {
class EndPoint : public H323EndPoint
@@ -79,7 +81,6 @@ namespace Opal {
void set_forward_uri (const std::string & uri);
const std::string & get_forward_uri () const;
-
/* Enable / Disable accounts. The account given as argument
* will be updated to reflect the current account state once
* the operation has been successful.
@@ -100,10 +101,6 @@ namespace Opal {
unsigned options,
OpalConnection::StringOptions *str_options);
- // this object is really managed by opal,
- // so the way it is handled here is correct
- Opal::EndPoint &endpoint;
-
PMutex gk_name_mutex;
PString gk_name;
diff --git a/lib/engine/components/opal/process/opal-endpoint.cpp
b/lib/engine/components/opal/process/opal-endpoint.cpp
index dc49d20..7de5fe4 100644
--- a/lib/engine/components/opal/process/opal-endpoint.cpp
+++ b/lib/engine/components/opal/process/opal-endpoint.cpp
@@ -161,15 +161,15 @@ Opal::EndPoint::EndPoint (Ekiga::ServiceCore& core)
PInterfaceMonitor::GetInstance().SetRefreshInterval (15000);
- // Create endpoints / CallProtocolManagers
+ // Create endpoints
+ // Their destruction is controlled by Opal
pcssEP = new GMPCSSEndpoint (*this, core);
pcssEP->SetSoundChannelPlayDevice("EKIGA");
pcssEP->SetSoundChannelRecordDevice("EKIGA");
- sip_endpoint = boost::shared_ptr<Sip::EndPoint> (new Sip::EndPoint (*this, core), null_deleter ());
-
+ sip_endpoint = new Sip::EndPoint (*this, core);
#ifdef HAVE_H323
- h323_endpoint= boost::shared_ptr<H323::EndPoint>(new H323::EndPoint (*this, core), null_deleter ());
+ h323_endpoint= new H323::EndPoint (*this, core);
#endif
}
@@ -433,16 +433,16 @@ void Opal::EndPoint::set_stun_enabled (bool enabled)
}
-boost::shared_ptr<Opal::Sip::EndPoint> Opal::EndPoint::get_sip_endpoint ()
+Opal::Sip::EndPoint& Opal::EndPoint::GetSipEndPoint ()
{
- return sip_endpoint;
+ return *sip_endpoint;
}
#ifdef HAVE_H323
-boost::shared_ptr<Opal::H323::EndPoint> Opal::EndPoint::get_h323_endpoint ()
+Opal::H323::EndPoint& Opal::EndPoint::GetH323EndPoint ()
{
- return h323_endpoint;
+ return *h323_endpoint;
}
#endif
diff --git a/lib/engine/components/opal/process/opal-endpoint.h
b/lib/engine/components/opal/process/opal-endpoint.h
index 65fbc2a..e8530f9 100644
--- a/lib/engine/components/opal/process/opal-endpoint.h
+++ b/lib/engine/components/opal/process/opal-endpoint.h
@@ -43,10 +43,12 @@
#include <ptlib.h>
+#ifdef HAVE_H323
#include <h323/h323.h>
-#include <sip/sip.h>
+#include "h323-endpoint.h"
+#endif
-#include "menu-builder.h"
+#include <sip/sip.h>
#include "opal-call.h"
@@ -62,8 +64,14 @@ namespace Opal {
class Account;
class CallManager;
- namespace Sip { class EndPoint; };
- namespace H323 { class EndPoint; };
+ namespace SIP {
+ class EndPoint;
+ }
+#ifdef HAVE_H323
+ namespace H323 {
+ class EndPoint;
+ }
+#endif
/* This is the OPAL endpoint. We do not want it to directly
* use the CallCore, CallManager's and other engine implementations.
@@ -116,9 +124,9 @@ public:
void set_stun_server (const std::string & server);
void set_stun_enabled (bool);
- boost::shared_ptr<Sip::EndPoint> get_sip_endpoint ();
+ Sip::EndPoint& GetSipEndPoint ();
#ifdef HAVE_H323
- boost::shared_ptr<H323::EndPoint> get_h323_endpoint ();
+ H323::EndPoint& GetH323EndPoint ();
#endif
@@ -192,9 +200,9 @@ private:
bool stun_enabled;
bool auto_answer;
- boost::shared_ptr<Sip::EndPoint> sip_endpoint;
+ Sip::EndPoint *sip_endpoint;
#ifdef HAVE_H323
- boost::shared_ptr<H323::EndPoint> h323_endpoint;
+ H323::EndPoint *h323_endpoint;
#endif
};
};
diff --git a/lib/engine/components/opal/process/opal-process.cpp
b/lib/engine/components/opal/process/opal-process.cpp
index 7f5df86..7a00e48 100644
--- a/lib/engine/components/opal/process/opal-process.cpp
+++ b/lib/engine/components/opal/process/opal-process.cpp
@@ -47,11 +47,9 @@
GnomeMeeting *GnomeMeeting::GM = 0;
/* The main GnomeMeeting Class */
-GnomeMeeting::GnomeMeeting ()
- : PProcess("", "", MAJOR_VERSION, MINOR_VERSION, BUILD_TYPE, BUILD_NUMBER)
+GnomeMeeting::GnomeMeeting () : PProcess("", "", MAJOR_VERSION, MINOR_VERSION, BUILD_TYPE, BUILD_NUMBER)
{
GM = this;
- endpoint = NULL;
}
GnomeMeeting::~GnomeMeeting ()
@@ -78,8 +76,6 @@ GnomeMeeting::~GnomeMeeting ()
std::cout << "bank use count" << bank.use_count () << std::endl << std::flush;
*/
- if (endpoint)
- delete endpoint;
std::cout << "PPROCESS END END" << std::endl << std::flush;
}
@@ -103,7 +99,7 @@ void GnomeMeeting::Start (Ekiga::ServiceCore& core)
Opal::EndPoint&
-GnomeMeeting::get_endpoint ()
+GnomeMeeting::GetEndPoint ()
{
return *endpoint;
}
@@ -111,9 +107,9 @@ GnomeMeeting::get_endpoint ()
void GnomeMeeting::on_ready (
#ifdef HAVE_H323
- Opal::H323::EndPoint* h323_endpoint,
+ Opal::H323::EndPoint* /*h323_endpoint*/,
#endif
- Opal::Sip::EndPoint* sip_endpoint)
+ Opal::Sip::EndPoint* /*sip_endpoint*/)
{
/*
presence_core = boost::weak_ptr<Ekiga::PresenceCore> (core.get<Ekiga::PresenceCore> ("presence-core"));
diff --git a/lib/engine/components/opal/process/opal-process.h
b/lib/engine/components/opal/process/opal-process.h
index b7040ae..1fdec20 100644
--- a/lib/engine/components/opal/process/opal-process.h
+++ b/lib/engine/components/opal/process/opal-process.h
@@ -74,7 +74,7 @@ class GnomeMeeting : public PProcess
static GnomeMeeting *Process ();
- Opal::EndPoint& get_endpoint ();
+ Opal::EndPoint& GetEndPoint ();
private:
@@ -85,7 +85,7 @@ class GnomeMeeting : public PProcess
Opal::Sip::EndPoint* sip_endpoint);
static GnomeMeeting *GM;
- Opal::EndPoint *endpoint;
+ Opal::EndPoint* endpoint;
boost::shared_ptr<Opal::Bank> bank;
boost::weak_ptr<Ekiga::CallCore> call_core;
diff --git a/lib/engine/components/opal/process/sip-endpoint.cpp
b/lib/engine/components/opal/process/sip-endpoint.cpp
index 4c1267c..3884822 100644
--- a/lib/engine/components/opal/process/sip-endpoint.cpp
+++ b/lib/engine/components/opal/process/sip-endpoint.cpp
@@ -108,7 +108,6 @@ namespace Opal {
/* The class */
Opal::Sip::EndPoint::EndPoint (Opal::EndPoint & _endpoint,
const Ekiga::ServiceCore& _core): SIPEndPoint (_endpoint),
- endpoint (_endpoint),
core (_core)
{
boost::shared_ptr<Ekiga::ChatCore> chat_core = core.get<Ekiga::ChatCore> ("chat-core");
@@ -116,9 +115,6 @@ Opal::Sip::EndPoint::EndPoint (Opal::EndPoint & _endpoint,
uri_prefix = "sip:";
- // dialect = boost::shared_ptr<SIP::Dialect>(new SIP::Dialect (presence_core, boost::bind
(&Opal::Sip::EndPoint::send_message, this, _1, _2)));
-// chat_core->add_dialect (dialect);
-
/* Timeouts */
SetAckTimeout (PTimeInterval (0, 32));
SetPduCleanUpTimeout (PTimeInterval (0, 1));
@@ -131,8 +127,8 @@ Opal::Sip::EndPoint::EndPoint (Opal::EndPoint & _endpoint,
SetUserAgent ("Ekiga/" PACKAGE_VERSION);
/* Ready to take calls */
- endpoint.AddRouteEntry("sip:.* = pc:*");
- endpoint.AddRouteEntry("pc:.* = sip:<da>");
+ GetManager ().AddRouteEntry("sip:.* = pc:*");
+ GetManager ().AddRouteEntry("pc:.* = sip:<da>");
/* NAT Binding */
PTimeInterval timeout;
@@ -192,7 +188,7 @@ Opal::Sip::EndPoint::SetUpCall (const std::string & uri)
}
PString token;
- endpoint.SetUpCall ("pc:*", ustr.str(), token, (void*) ustr.str().c_str());
+ GetManager ().SetUpCall ("pc:*", ustr.str(), token, (void*) ustr.str().c_str());
return true;
}
@@ -201,10 +197,10 @@ Opal::Sip::EndPoint::SetUpCall (const std::string & uri)
bool
Opal::Sip::EndPoint::StartListener (unsigned port)
{
- unsigned udp_min = endpoint.GetUDPPortBase ();
- unsigned udp_max = endpoint.GetUDPPortMax ();
- unsigned tcp_min = endpoint.GetTCPPortBase ();
- unsigned tcp_max = endpoint.GetTCPPortMax ();
+ unsigned udp_min = GetManager ().GetUDPPortBase ();
+ unsigned udp_max = GetManager ().GetUDPPortMax ();
+ unsigned tcp_min = GetManager ().GetTCPPortBase ();
+ unsigned tcp_max = GetManager ().GetTCPPortMax ();
const std::string protocols[] = { "udp", "tcp", "" };
const unsigned ports[][2] = { { udp_min, udp_max }, { tcp_min, tcp_max } };
@@ -329,6 +325,9 @@ Opal::Sip::EndPoint::OnRegistrationStatus (const RegistrationStatus & status)
std::string info;
boost::shared_ptr<Opal::Bank> bank = core.get<Opal::Bank> ("opal-account-store");
+ if (!bank)
+ return;
+
Opal::AccountPtr account = bank->find_account (status.m_addressofRecord);
if (!account)
return;
@@ -351,7 +350,7 @@ Opal::Sip::EndPoint::OnRegistrationStatus (const RegistrationStatus & status)
if (status.m_reason == SIP_PDU::Successful_OK) {
account->handle_registration_event (status.m_wasRegistering?Account::Registered:Account::Unregistered,
std::string (),
- endpoint.AddPresentity (PURL (status.m_addressofRecord)));
+ GetManager ().AddPresentity (PURL (status.m_addressofRecord)));
}
/* Registration or unregistration failure */
else {
@@ -701,8 +700,6 @@ Opal::Sip::EndPoint::OnReceivedMESSAGE (SIP_PDU & pdu)
Ekiga::Message msg = {time, display_name, payload };
g_free (time);
- Ekiga::Runtime::run_in_main (boost::bind (&Opal::Sip::EndPoint::push_message_in_main, this, message_uri,
msg));
-
return SIPEndPoint::OnReceivedMESSAGE (pdu);
}
@@ -735,8 +732,6 @@ Opal::Sip::EndPoint::OnMESSAGECompleted (const SIPMessage::Params & params,
gchar* time = g_time_val_to_iso8601 (¤t);
Ekiga::Message msg = {time, "" /* it's a notice */, payload };
g_free (time);
-
- Ekiga::Runtime::run_in_main (boost::bind (&Opal::Sip::EndPoint::push_message_in_main, this, uri, msg));
}
@@ -778,11 +773,3 @@ Opal::Sip::EndPoint::OnDialogInfoReceived (const SIPDialogNotification & info)
break;
}
}
-
-
-void
-Opal::Sip::EndPoint::push_message_in_main (const std::string uri,
- const Ekiga::Message msg)
-{
- dialect->push_message (uri, msg);
-}
diff --git a/lib/engine/components/opal/process/sip-endpoint.h
b/lib/engine/components/opal/process/sip-endpoint.h
index 7e06e60..9aa4968 100644
--- a/lib/engine/components/opal/process/sip-endpoint.h
+++ b/lib/engine/components/opal/process/sip-endpoint.h
@@ -51,7 +51,7 @@
#include "services.h"
#include "opal-call-manager.h"
-
+#include "opal-endpoint.h"
namespace Opal {
@@ -124,21 +124,12 @@ namespace Opal {
/* Callbacks */
private:
- void push_message_in_main (const std::string uri,
- const Ekiga::Message msg);
-
- // this object is really managed by opal,
- // so the way it is handled here is correct
- Opal::EndPoint & endpoint;
-
std::map<std::string, PString> publications;
std::string uri_prefix;
std::string forward_uri;
std::string outbound_proxy;
- boost::shared_ptr<SIP::Dialect> dialect;
-
const Ekiga::ServiceCore & core;
};
};
diff --git a/lib/engine/components/opal/sip-call-manager.cpp b/lib/engine/components/opal/sip-call-manager.cpp
index 648a13e..981e965 100644
--- a/lib/engine/components/opal/sip-call-manager.cpp
+++ b/lib/engine/components/opal/sip-call-manager.cpp
@@ -46,7 +46,10 @@
/* The engine class */
Opal::Sip::CallManager::CallManager (Ekiga::ServiceCore& _core,
- Opal::EndPoint& _endpoint) : Opal::CallManager (_core, _endpoint),
protocol_name ("sip")
+ Opal::EndPoint& _endpoint,
+ Opal::Sip::EndPoint& _sip_endpoint)
+ : Opal::CallManager (_core, _endpoint),
+ sip_endpoint (_sip_endpoint), protocol_name ("sip")
{
/* Setup things */
Ekiga::SettingsCallback setup_cb = boost::bind (&Opal::Sip::CallManager::setup, this, _1);
@@ -80,11 +83,7 @@ bool Opal::Sip::CallManager::dial (const std::string & uri)
if (!is_supported_uri (uri))
return false;
- boost::shared_ptr<Opal::Sip::EndPoint> sip_endpoint = endpoint.get_sip_endpoint ();
- if (sip_endpoint)
- return sip_endpoint->SetUpCall (uri);
-
- return false;
+ return sip_endpoint.SetUpCall (uri);
}
@@ -105,11 +104,7 @@ const Ekiga::CallManager::InterfaceList Opal::Sip::CallManager::get_interfaces (
{
Ekiga::CallManager::InterfaceList ilist;
- boost::shared_ptr<Opal::Sip::EndPoint> sip_endpoint = endpoint.get_sip_endpoint ();
- if (!sip_endpoint)
- return ilist;
-
- OpalListenerList listeners = sip_endpoint->GetListeners ();
+ OpalListenerList listeners = sip_endpoint.GetListeners ();
for (int i = 0 ; i < listeners.GetSize () ; i++) {
Ekiga::CallManager::Interface iface;
PIPSocket::Address address;
@@ -132,31 +127,24 @@ const Ekiga::CallManager::InterfaceList Opal::Sip::CallManager::get_interfaces (
bool
Opal::Sip::CallManager::set_listen_port (unsigned port)
{
- boost::shared_ptr<Opal::Sip::EndPoint> sip_endpoint = endpoint.get_sip_endpoint ();
- if (sip_endpoint)
- return sip_endpoint->StartListener (port);
-
- return false;
+ return sip_endpoint.StartListener (port);
}
void
Opal::Sip::CallManager::set_dtmf_mode (unsigned mode)
{
- boost::shared_ptr<Opal::Sip::EndPoint> sip_endpoint = endpoint.get_sip_endpoint ();
- if (sip_endpoint) {
- switch (mode) {
-
- case 0: // RFC2833
- PTRACE (4, "Opal::Sip::CallManager\tSet DTMF Mode to RFC2833");
- sip_endpoint->SetSendUserInputMode (OpalConnection::SendUserInputAsInlineRFC2833);
- break;
- case 1: // SIP Info
- default:
- PTRACE (4, "Opal::Sip::CallManager\tSet DTMF Mode to SIP INFO");
- sip_endpoint->SetSendUserInputMode (OpalConnection::SendUserInputAsTone);
- break;
- }
+ switch (mode) {
+
+ case 0: // RFC2833
+ PTRACE (4, "Opal::Sip::CallManager\tSet DTMF Mode to RFC2833");
+ sip_endpoint.SetSendUserInputMode (OpalConnection::SendUserInputAsInlineRFC2833);
+ break;
+ case 1: // SIP Info
+ default:
+ PTRACE (4, "Opal::Sip::CallManager\tSet DTMF Mode to SIP INFO");
+ sip_endpoint.SetSendUserInputMode (OpalConnection::SendUserInputAsTone);
+ break;
}
}
@@ -164,16 +152,13 @@ Opal::Sip::CallManager::set_dtmf_mode (unsigned mode)
unsigned
Opal::Sip::CallManager::get_dtmf_mode () const
{
- boost::shared_ptr<Opal::Sip::EndPoint> sip_endpoint = endpoint.get_sip_endpoint ();
- if (sip_endpoint) {
- // RFC2833
- if (sip_endpoint->GetSendUserInputMode () == OpalConnection::SendUserInputAsInlineRFC2833)
- return 0;
-
- // SIP Info
- if (sip_endpoint->GetSendUserInputMode () == OpalConnection::SendUserInputAsTone)
- return 1;
- }
+ // RFC2833
+ if (sip_endpoint.GetSendUserInputMode () == OpalConnection::SendUserInputAsInlineRFC2833)
+ return 0;
+
+ // SIP Info
+ if (sip_endpoint.GetSendUserInputMode () == OpalConnection::SendUserInputAsTone)
+ return 1;
g_return_val_if_reached (1);
}
@@ -181,25 +166,22 @@ Opal::Sip::CallManager::get_dtmf_mode () const
void Opal::Sip::CallManager::setup (const std::string & setting)
{
- boost::shared_ptr<Opal::Sip::EndPoint> sip_endpoint = endpoint.get_sip_endpoint ();
- if (sip_endpoint) {
- if (setting.empty () || setting == "listen-port") {
- set_listen_port (sip_settings->get_int ("listen-port"));
- }
- if (setting.empty () || setting == "binding-timeout") {
- sip_endpoint->set_nat_binding_delay (sip_settings->get_int ("binding-timeout"));
- }
- if (setting.empty () || setting == "outbound-proxy-host") {
- sip_endpoint->set_outbound_proxy (sip_settings->get_string ("outbound-proxy-host"));
- }
-
- if (setting.empty () || setting == "dtmf-mode") {
- set_dtmf_mode (sip_settings->get_enum ("dtmf-mode"));
- }
-
- if (setting.empty () || setting == "forward-host") {
- sip_endpoint->set_forward_uri (sip_settings->get_string ("forward-host"));
- }
+ if (setting.empty () || setting == "listen-port") {
+ set_listen_port (sip_settings->get_int ("listen-port"));
+ }
+ if (setting.empty () || setting == "binding-timeout") {
+ sip_endpoint.set_nat_binding_delay (sip_settings->get_int ("binding-timeout"));
+ }
+ if (setting.empty () || setting == "outbound-proxy-host") {
+ sip_endpoint.set_outbound_proxy (sip_settings->get_string ("outbound-proxy-host"));
+ }
+
+ if (setting.empty () || setting == "dtmf-mode") {
+ set_dtmf_mode (sip_settings->get_enum ("dtmf-mode"));
+ }
+
+ if (setting.empty () || setting == "forward-host") {
+ sip_endpoint.set_forward_uri (sip_settings->get_string ("forward-host"));
}
Opal::CallManager::setup (setting);
diff --git a/lib/engine/components/opal/sip-call-manager.h b/lib/engine/components/opal/sip-call-manager.h
index 517bbec..31b4a9c 100644
--- a/lib/engine/components/opal/sip-call-manager.h
+++ b/lib/engine/components/opal/sip-call-manager.h
@@ -41,6 +41,7 @@
#include "opal-call-manager.h"
#include "opal-endpoint.h"
+#include "sip-endpoint.h"
#include "ekiga-settings.h"
@@ -58,7 +59,8 @@ namespace Opal {
{
public:
CallManager (Ekiga::ServiceCore& core,
- Opal::EndPoint& endpoint);
+ Opal::EndPoint& endpoint,
+ Opal::Sip::EndPoint& sip_endpoint);
~CallManager ();
/* URIActionProvider Methods */
@@ -85,6 +87,7 @@ namespace Opal {
void setup (const std::string & setting = "");
Ekiga::SettingsPtr sip_settings;
+ Opal::Sip::EndPoint& sip_endpoint;
std::string protocol_name;
};
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]