[ekiga/gnome-2-26] Worked on unthreading the endpoints (not 100% there yet, though)
- From: Eugen Dedu <ededu src gnome org>
- To: svn-commits-list gnome org
- Subject: [ekiga/gnome-2-26] Worked on unthreading the endpoints (not 100% there yet, though)
- Date: Mon, 27 Apr 2009 12:28:59 -0400 (EDT)
commit 993d1897085d396afbad5bfb5425cd88e1724dae
Author: Julien Puydt <jpuydt src gnome org>
Date: Tue Mar 31 19:37:26 2009 +0000
Worked on unthreading the endpoints (not 100% there yet, though)
svn path=/trunk/; revision=7838
---
lib/engine/components/opal/h323-endpoint.cpp | 156 +++++++-----
lib/engine/components/opal/h323-endpoint.h | 4 +
lib/engine/components/opal/sip-endpoint.cpp | 353 +++++++++++++++-----------
lib/engine/components/opal/sip-endpoint.h | 69 ++++--
4 files changed, 344 insertions(+), 238 deletions(-)
diff --git a/lib/engine/components/opal/h323-endpoint.cpp b/lib/engine/components/opal/h323-endpoint.cpp
index ba46f3b..40452e4 100644
--- a/lib/engine/components/opal/h323-endpoint.cpp
+++ b/lib/engine/components/opal/h323-endpoint.cpp
@@ -43,14 +43,6 @@
#include "opal-call.h"
#include "account-core.h"
-static void
-registration_event_in_main (sigc::slot2<void, Ekiga::AccountCore::RegistrationState, std::string> slot,
- Ekiga::AccountCore::RegistrationState state,
- const std::string msg)
-{
- slot (state, msg);
-}
-
namespace Opal {
namespace H323 {
@@ -59,23 +51,23 @@ namespace Opal {
{
PCLASSINFO(subscriber, PThread);
- public:
+ public:
subscriber (const Opal::Account & _account,
- Opal::H323::EndPoint& _manager)
+ Opal::H323::EndPoint& _manager)
: PThread (1000, AutoDeleteThread),
- account (_account),
- manager (_manager)
+ account (_account),
+ manager (_manager)
{
this->Resume ();
};
- void Main ()
- {
- manager.Register (account);
- };
+ void Main ()
+ {
+ manager.Register (account);
+ };
- private:
+ private:
const Opal::Account & account;
Opal::H323::EndPoint& manager;
};
@@ -85,9 +77,9 @@ namespace Opal {
/* The class */
Opal::H323::EndPoint::EndPoint (Opal::CallManager & _manager, Ekiga::ServiceCore & _core, unsigned _listen_port)
- : H323EndPoint (_manager),
- manager (_manager),
- core (_core)
+ : H323EndPoint (_manager),
+ manager (_manager),
+ core (_core)
{
protocol_name = "h323";
uri_prefix = "h323:";
@@ -108,34 +100,37 @@ Opal::H323::EndPoint::~EndPoint ()
{
}
-bool Opal::H323::EndPoint::populate_menu (Ekiga::ContactPtr contact,
- std::string uri,
- Ekiga::MenuBuilder &builder)
+bool
+Opal::H323::EndPoint::populate_menu (Ekiga::ContactPtr contact,
+ std::string uri,
+ Ekiga::MenuBuilder &builder)
{
return menu_builder_add_actions (contact->get_name (), uri, builder);
}
-bool Opal::H323::EndPoint::populate_menu (Ekiga::PresentityPtr presentity,
- const std::string uri,
- Ekiga::MenuBuilder& builder)
+bool
+Opal::H323::EndPoint::populate_menu (Ekiga::PresentityPtr presentity,
+ const std::string uri,
+ Ekiga::MenuBuilder& builder)
{
return menu_builder_add_actions (presentity->get_name (), uri, builder);
}
-bool Opal::H323::EndPoint::menu_builder_add_actions (const std::string & /*fullname*/,
- const std::string& uri,
- Ekiga::MenuBuilder & builder)
+bool
+Opal::H323::EndPoint::menu_builder_add_actions (const std::string & /*fullname*/,
+ const std::string& uri,
+ Ekiga::MenuBuilder & builder)
{
bool populated = false;
if (uri.find ("h323:") == 0) {
-
+
if (0 == GetConnectionCount ())
builder.add_action ("call", _("Call"),
sigc::bind (sigc::mem_fun (this, &Opal::H323::EndPoint::on_dial), uri));
- else
+ else
builder.add_action ("transfer", _("Transfer"),
sigc::bind (sigc::mem_fun (this, &Opal::H323::EndPoint::on_transfer), uri));
populated = true;
@@ -145,7 +140,8 @@ bool Opal::H323::EndPoint::menu_builder_add_actions (const std::string & /*fulln
}
-bool Opal::H323::EndPoint::dial (const std::string & uri)
+bool
+Opal::H323::EndPoint::dial (const std::string& uri)
{
if (uri.find ("h323:") == 0) {
@@ -159,15 +155,17 @@ bool Opal::H323::EndPoint::dial (const std::string & uri)
}
-const std::string & Opal::H323::EndPoint::get_protocol_name () const
+const std::string&
+Opal::H323::EndPoint::get_protocol_name () const
{
return protocol_name;
}
-void Opal::H323::EndPoint::set_dtmf_mode (unsigned mode)
+void
+Opal::H323::EndPoint::set_dtmf_mode (unsigned mode)
{
- switch (mode)
+ switch (mode)
{
case 0:
SetSendUserInputMode (OpalConnection::SendUserInputAsString);
@@ -187,7 +185,8 @@ void Opal::H323::EndPoint::set_dtmf_mode (unsigned mode)
}
-unsigned Opal::H323::EndPoint::get_dtmf_mode () const
+unsigned
+Opal::H323::EndPoint::get_dtmf_mode () const
{
if (GetSendUserInputMode () == OpalConnection::SendUserInputAsString)
return 0;
@@ -205,7 +204,8 @@ unsigned Opal::H323::EndPoint::get_dtmf_mode () const
}
-bool Opal::H323::EndPoint::set_listen_port (unsigned port)
+bool
+Opal::H323::EndPoint::set_listen_port (unsigned port)
{
listen_iface.protocol = "tcp";
listen_iface.voip_protocol = "h323";
@@ -228,25 +228,29 @@ bool Opal::H323::EndPoint::set_listen_port (unsigned port)
}
-const Ekiga::CallProtocolManager::Interface & Opal::H323::EndPoint::get_listen_interface () const
+const Ekiga::CallProtocolManager::Interface&
+Opal::H323::EndPoint::get_listen_interface () const
{
return listen_iface;
}
-void Opal::H323::EndPoint::set_forward_uri (const std::string & uri)
+void
+Opal::H323::EndPoint::set_forward_uri (const std::string& uri)
{
forward_uri = uri;
}
-const std::string & Opal::H323::EndPoint::get_forward_uri () const
+const std::string&
+Opal::H323::EndPoint::get_forward_uri () const
{
return forward_uri;
}
-bool Opal::H323::EndPoint::subscribe (const Opal::Account & account)
+bool
+Opal::H323::EndPoint::subscribe (const Opal::Account & account)
{
if (account.get_protocol_name () != "H323" || account.is_active ())
return false;
@@ -257,7 +261,8 @@ bool Opal::H323::EndPoint::subscribe (const Opal::Account & account)
}
-bool Opal::H323::EndPoint::unsubscribe (const Opal::Account & account)
+bool
+Opal::H323::EndPoint::unsubscribe (const Opal::Account & account)
{
if (account.get_protocol_name () != "H323" || !account.is_active ())
return false;
@@ -268,7 +273,8 @@ bool Opal::H323::EndPoint::unsubscribe (const Opal::Account & account)
}
-void Opal::H323::EndPoint::Register (const Opal::Account & account)
+void
+Opal::H323::EndPoint::Register (const Opal::Account& account)
{
PString gatekeeperID;
std::string info;
@@ -325,17 +331,17 @@ void Opal::H323::EndPoint::Register (const Opal::Account & account)
info = _("Failed");
/* Signal */
- Ekiga::Runtime::run_in_main (sigc::bind (sigc::ptr_fun(registration_event_in_main),
- account.registration_event.make_slot (),
- Ekiga::AccountCore::RegistrationFailed,
- info));
+ Ekiga::Runtime::run_in_main (sigc::bind (sigc::mem_fun (this, &Opal::H323::EndPoint::registration_event_in_main),
+ account,
+ Ekiga::AccountCore::RegistrationFailed,
+ info));
}
else {
- Ekiga::Runtime::run_in_main (sigc::bind (sigc::ptr_fun(registration_event_in_main),
- account.registration_event.make_slot (),
- Ekiga::AccountCore::Registered,
- std::string ()));
+ Ekiga::Runtime::run_in_main (sigc::bind (sigc::mem_fun (this, &Opal::H323::EndPoint::registration_event_in_main),
+ account,
+ Ekiga::AccountCore::Registered,
+ std::string ()));
}
}
else if (unregister && IsRegisteredWithGatekeeper (account.get_host ())) {
@@ -344,19 +350,20 @@ void Opal::H323::EndPoint::Register (const Opal::Account & account)
RemoveAliasName (account.get_username ());
/* Signal */
- Ekiga::Runtime::run_in_main (sigc::bind (sigc::ptr_fun(registration_event_in_main),
- account.registration_event.make_slot (),
- Ekiga::AccountCore::Unregistered,
- std::string ()));
+ Ekiga::Runtime::run_in_main (sigc::bind (sigc::mem_fun (this, &Opal::H323::EndPoint::registration_event_in_main),
+ account,
+ Ekiga::AccountCore::Unregistered,
+ std::string ()));
}
}
-bool Opal::H323::EndPoint::UseGatekeeper (const PString & address,
- const PString & domain,
- const PString & iface)
+bool
+Opal::H323::EndPoint::UseGatekeeper (const PString & address,
+ const PString & domain,
+ const PString & iface)
{
- bool result =
+ bool result =
H323EndPoint::UseGatekeeper (address, domain, iface);
PWaitAndSignal m(gk_name_mutex);
@@ -367,7 +374,8 @@ bool Opal::H323::EndPoint::UseGatekeeper (const PString & address,
}
-bool Opal::H323::EndPoint::RemoveGatekeeper (const PString & address)
+bool
+Opal::H323::EndPoint::RemoveGatekeeper (const PString & address)
{
if (IsRegisteredWithGatekeeper (address))
return H323EndPoint::RemoveGatekeeper (0);
@@ -376,7 +384,8 @@ bool Opal::H323::EndPoint::RemoveGatekeeper (const PString & address)
}
-bool Opal::H323::EndPoint::IsRegisteredWithGatekeeper (const PString & address)
+bool
+Opal::H323::EndPoint::IsRegisteredWithGatekeeper (const PString & address)
{
PWaitAndSignal m(gk_name_mutex);
@@ -384,15 +393,16 @@ bool Opal::H323::EndPoint::IsRegisteredWithGatekeeper (const PString & address)
}
-bool Opal::H323::EndPoint::OnIncomingConnection (OpalConnection & connection,
- G_GNUC_UNUSED unsigned options,
- G_GNUC_UNUSED OpalConnection::StringOptions *stroptions)
+bool
+Opal::H323::EndPoint::OnIncomingConnection (OpalConnection & connection,
+ G_GNUC_UNUSED unsigned options,
+ G_GNUC_UNUSED OpalConnection::StringOptions *stroptions)
{
PTRACE (3, "EndPoint\tIncoming connection");
if (!forward_uri.empty () && manager.get_unconditional_forward ())
connection.ForwardCall (forward_uri);
- else if (manager.GetCallCount () > 1) {
+ else if (manager.GetCallCount () > 1) {
if (!forward_uri.empty () && manager.get_forward_on_busy ())
connection.ForwardCall (forward_uri);
@@ -405,7 +415,7 @@ bool Opal::H323::EndPoint::OnIncomingConnection (OpalConnection & connection,
Opal::Call *call = dynamic_cast<Opal::Call *> (&connection.GetCall ());
if (call) {
- if (!forward_uri.empty () && manager.get_forward_on_no_answer ())
+ if (!forward_uri.empty () && manager.get_forward_on_no_answer ())
call->set_no_answer_forward (manager.get_reject_delay (), forward_uri);
else
call->set_reject_delay (manager.get_reject_delay ());
@@ -418,16 +428,26 @@ bool Opal::H323::EndPoint::OnIncomingConnection (OpalConnection & connection,
}
-void Opal::H323::EndPoint::on_dial (std::string uri)
+void
+Opal::H323::EndPoint::on_dial (std::string uri)
{
manager.dial (uri);
}
-void Opal::H323::EndPoint::on_transfer (std::string uri)
+void
+Opal::H323::EndPoint::on_transfer (std::string uri)
{
/* FIXME : we don't handle several calls here */
for (PSafePtr<OpalConnection> connection(connectionsActive, PSafeReference); connection != NULL; ++connection)
if (!PIsDescendant(&(*connection), OpalPCSSConnection))
connection->TransferConnection (uri);
}
+
+void
+Opal::H323::EndPoint::registration_event_in_main (Opal::Account& account,
+ Ekiga::AccountCore::RegistrationState state,
+ const std::string msg)
+{
+ account.registration_event.emit (state, msg);
+}
diff --git a/lib/engine/components/opal/h323-endpoint.h b/lib/engine/components/opal/h323-endpoint.h
index 994b61c..0ac4a60 100644
--- a/lib/engine/components/opal/h323-endpoint.h
+++ b/lib/engine/components/opal/h323-endpoint.h
@@ -124,6 +124,10 @@ namespace Opal {
void on_transfer (std::string uri);
+ void registration_event_in_main (Opal::Account& account,
+ Ekiga::AccountCore::RegistrationState state,
+ const std::string msg);
+
CallManager & manager;
Ekiga::ServiceCore & core;
diff --git a/lib/engine/components/opal/sip-endpoint.cpp b/lib/engine/components/opal/sip-endpoint.cpp
index 2d99191..ede2505 100644
--- a/lib/engine/components/opal/sip-endpoint.cpp
+++ b/lib/engine/components/opal/sip-endpoint.cpp
@@ -53,42 +53,6 @@
#include "personal-details.h"
#include "opal-account.h"
-static void
-registration_event_in_main (sigc::slot2<void, Ekiga::AccountCore::RegistrationState, std::string> slot,
- Ekiga::AccountCore::RegistrationState state,
- const std::string msg)
-{
- slot (state, msg);
-}
-
-static void
-presence_status_in_main (Ekiga::PresenceFetcher* fetcher,
- std::string uri,
- std::string presence,
- std::string status)
-{
- fetcher->presence_received.emit (uri, presence);
- fetcher->status_received.emit (uri, status);
-}
-
-static void
-push_message_in_main (SIP::Dialect* dialect,
- const std::string uri,
- const std::string name,
- const std::string msg)
-{
- dialect->push_message (uri, name, msg);
-}
-
-static void
-push_notice_in_main (SIP::Dialect* dialect,
- const std::string uri,
- const std::string name,
- const std::string msg)
-{
- dialect->push_notice (uri, name, msg);
-}
-
namespace Opal {
namespace Sip {
@@ -97,22 +61,27 @@ namespace Opal {
{
PCLASSINFO(subscriber, PThread);
- public:
+ public:
subscriber (const Opal::Account & _account,
Opal::Sip::EndPoint & _manager)
: PThread (1000, AutoDeleteThread),
- account (_account),
- manager (_manager)
+ account (_account),
+ manager (_manager)
{
this->Resume ();
};
void Main ()
- {
- manager.Register (account);
- };
+ {
+ manager.Register (account.get_username (),
+ account.get_host (),
+ account.get_authentication_username (),
+ account.get_password (),
+ account.is_enabled (),
+ account.get_timeout ());
+ };
- private:
+ private:
const Opal::Account & account;
Opal::Sip::EndPoint & manager;
};
@@ -125,9 +94,9 @@ namespace Opal {
Opal::Sip::EndPoint::EndPoint (Opal::CallManager & _manager,
Ekiga::ServiceCore & _core,
unsigned _listen_port)
-: SIPEndPoint (_manager),
- manager (_manager),
- core (_core)
+ : SIPEndPoint (_manager),
+ manager (_manager),
+ core (_core)
{
gmref_ptr<Ekiga::ChatCore> chat_core = core.get ("chat-core");
@@ -142,9 +111,8 @@ Opal::Sip::EndPoint::EndPoint (Opal::CallManager & _manager,
uri_prefix = "sip:";
listen_port = (_listen_port > 0 ? _listen_port : 5060);
- dialect = new SIP::Dialect (core, sigc::mem_fun (this, &Opal::Sip::EndPoint::send_message));
- dialect->reference (); // take a reference in the main thread
- chat_core->add_dialect (gmref_ptr<SIP::Dialect>(dialect));
+ dialect = gmref_ptr<SIP::Dialect>(new SIP::Dialect (core, sigc::mem_fun (this, &Opal::Sip::EndPoint::send_message)));
+ chat_core->add_dialect (dialect);
/* Timeouts */
SetAckTimeout (PTimeInterval (0, 32));
@@ -172,29 +140,31 @@ Opal::Sip::EndPoint::EndPoint (Opal::CallManager & _manager,
Opal::Sip::EndPoint::~EndPoint ()
{
bank->unreference (); // leave a reference in the main thread
- dialect->unreference (); // leave a reference in the main thread
}
-bool Opal::Sip::EndPoint::populate_menu (Ekiga::ContactPtr contact,
- const std::string uri,
- Ekiga::MenuBuilder &builder)
+bool
+Opal::Sip::EndPoint::populate_menu (Ekiga::ContactPtr contact,
+ const std::string uri,
+ Ekiga::MenuBuilder &builder)
{
return menu_builder_add_actions (contact->get_name (), uri, builder);
}
-bool Opal::Sip::EndPoint::populate_menu (Ekiga::PresentityPtr presentity,
- const std::string uri,
- Ekiga::MenuBuilder& builder)
+bool
+Opal::Sip::EndPoint::populate_menu (Ekiga::PresentityPtr presentity,
+ const std::string uri,
+ Ekiga::MenuBuilder& builder)
{
return menu_builder_add_actions (presentity->get_name (), uri, builder);
}
-bool Opal::Sip::EndPoint::menu_builder_add_actions (const std::string& fullname,
- const std::string& uri,
- Ekiga::MenuBuilder & builder)
+bool
+Opal::Sip::EndPoint::menu_builder_add_actions (const std::string& fullname,
+ const std::string& uri,
+ Ekiga::MenuBuilder & builder)
{
bool populated = false;
@@ -289,7 +259,8 @@ bool Opal::Sip::EndPoint::menu_builder_add_actions (const std::string& fullname,
}
-void Opal::Sip::EndPoint::fetch (const std::string _uri)
+void
+Opal::Sip::EndPoint::fetch (const std::string _uri)
{
std::string::size_type loc = _uri.find ("@", 0);
std::string domain;
@@ -315,7 +286,8 @@ void Opal::Sip::EndPoint::fetch (const std::string _uri)
}
-void Opal::Sip::EndPoint::unfetch (const std::string uri)
+void
+Opal::Sip::EndPoint::unfetch (const std::string uri)
{
if (std::find (subscribed_uris.begin (), subscribed_uris.end (), uri) != subscribed_uris.end ()) {
@@ -326,7 +298,8 @@ void Opal::Sip::EndPoint::unfetch (const std::string uri)
}
-void Opal::Sip::EndPoint::publish (const Ekiga::PersonalDetails & details)
+void
+Opal::Sip::EndPoint::publish (const Ekiga::PersonalDetails & details)
{
std::string hostname = (const char *) PIPSocket::GetHostName ();
std::string presence = ((Ekiga::PersonalDetails &) (details)).get_presence ();
@@ -375,8 +348,9 @@ void Opal::Sip::EndPoint::publish (const Ekiga::PersonalDetails & details)
}
-bool Opal::Sip::EndPoint::send_message (const std::string & _uri,
- const std::string & _message)
+bool
+Opal::Sip::EndPoint::send_message (const std::string & _uri,
+ const std::string & _message)
{
if (!_uri.empty () && (_uri.find ("sip:") == 0 || _uri.find (':') == string::npos) && !_message.empty ()) {
@@ -389,7 +363,8 @@ bool Opal::Sip::EndPoint::send_message (const std::string & _uri,
}
-bool Opal::Sip::EndPoint::dial (const std::string & uri)
+bool
+Opal::Sip::EndPoint::dial (const std::string & uri)
{
std::stringstream ustr;
@@ -410,13 +385,15 @@ bool Opal::Sip::EndPoint::dial (const std::string & uri)
}
-const std::string & Opal::Sip::EndPoint::get_protocol_name () const
+const std::string&
+Opal::Sip::EndPoint::get_protocol_name () const
{
return protocol_name;
}
-void Opal::Sip::EndPoint::set_dtmf_mode (unsigned mode)
+void
+Opal::Sip::EndPoint::set_dtmf_mode (unsigned mode)
{
switch (mode) {
@@ -435,7 +412,8 @@ void Opal::Sip::EndPoint::set_dtmf_mode (unsigned mode)
}
-unsigned Opal::Sip::EndPoint::get_dtmf_mode () const
+unsigned
+Opal::Sip::EndPoint::get_dtmf_mode () const
{
// SIP Info
if (GetSendUserInputMode () == OpalConnection::SendUserInputAsTone)
@@ -449,7 +427,8 @@ unsigned Opal::Sip::EndPoint::get_dtmf_mode () const
}
-bool Opal::Sip::EndPoint::set_listen_port (unsigned port)
+bool
+Opal::Sip::EndPoint::set_listen_port (unsigned port)
{
unsigned udp_min, udp_max;
@@ -490,52 +469,60 @@ bool Opal::Sip::EndPoint::set_listen_port (unsigned port)
}
-const Ekiga::CallProtocolManager::Interface & Opal::Sip::EndPoint::get_listen_interface () const
+const Ekiga::CallProtocolManager::Interface&
+Opal::Sip::EndPoint::get_listen_interface () const
{
return listen_iface;
}
-void Opal::Sip::EndPoint::set_forward_uri (const std::string & uri)
+void
+Opal::Sip::EndPoint::set_forward_uri (const std::string & uri)
{
forward_uri = uri;
}
-const std::string & Opal::Sip::EndPoint::get_forward_uri () const
+const std::string&
+Opal::Sip::EndPoint::get_forward_uri () const
{
return forward_uri;
}
-void Opal::Sip::EndPoint::set_outbound_proxy (const std::string & uri)
+void
+Opal::Sip::EndPoint::set_outbound_proxy (const std::string & uri)
{
outbound_proxy = uri;
SetProxy (SIPURL (outbound_proxy));
}
-const std::string & Opal::Sip::EndPoint::get_outbound_proxy () const
+const std::string&
+Opal::Sip::EndPoint::get_outbound_proxy () const
{
return outbound_proxy;
}
-void Opal::Sip::EndPoint::set_nat_binding_delay (unsigned delay)
+void
+Opal::Sip::EndPoint::set_nat_binding_delay (unsigned delay)
{
if (delay > 0)
SetNATBindingTimeout (PTimeInterval (0, delay));
}
-unsigned Opal::Sip::EndPoint::get_nat_binding_delay ()
+unsigned
+Opal::Sip::EndPoint::get_nat_binding_delay ()
{
return GetNATBindingTimeout ().GetSeconds ();
}
-std::string Opal::Sip::EndPoint::get_aor_domain (const std::string & aor)
+std::string
+Opal::Sip::EndPoint::get_aor_domain (const std::string & aor)
{
std::string domain;
std::string::size_type loc = aor.find ("@", 0);
@@ -547,7 +534,8 @@ std::string Opal::Sip::EndPoint::get_aor_domain (const std::string & aor)
}
-bool Opal::Sip::EndPoint::subscribe (const Opal::Account & account)
+bool
+Opal::Sip::EndPoint::subscribe (const Opal::Account & account)
{
if (account.get_protocol_name () != "SIP")
return false;
@@ -557,7 +545,8 @@ bool Opal::Sip::EndPoint::subscribe (const Opal::Account & account)
}
-bool Opal::Sip::EndPoint::unsubscribe (const Opal::Account & account)
+bool
+Opal::Sip::EndPoint::unsubscribe (const Opal::Account & account)
{
if (account.get_protocol_name () != "SIP")
return false;
@@ -567,45 +556,52 @@ bool Opal::Sip::EndPoint::unsubscribe (const Opal::Account & account)
}
-void Opal::Sip::EndPoint::Register (const Opal::Account & account)
+void
+Opal::Sip::EndPoint::Register (const std::string username,
+ const std::string host_,
+ const std::string auth_username,
+ const std::string password,
+ bool is_enabled,
+ unsigned timeout)
{
PString _aor;
std::stringstream aor;
- std::string host = account.get_host ();
+ std::string host(host_);
std::string::size_type loc = host.find (":", 0);
if (loc != std::string::npos)
host = host.substr (0, loc);
- if (account.get_username ().find ("@") == std::string::npos)
- aor << account.get_username () << "@" << host;
+ if (username.find ("@") == std::string::npos)
+ aor << username << "@" << host;
else
- aor << account.get_username ();
+ aor << username;
SIPRegister::Params params;
params.m_addressOfRecord = aor.str ();
- params.m_registrarAddress = account.get_host ();
- params.m_authID = account.get_authentication_username ();
- params.m_password = account.get_password ();
- params.m_expire = (account.is_enabled () ? account.get_timeout () : 0);
+ params.m_registrarAddress = host;
+ params.m_authID = auth_username;
+ params.m_password = password;
+ params.m_expire = is_enabled ? timeout : 0;
params.m_minRetryTime = 0;
params.m_maxRetryTime = 0;
// Update the list of active domains
std::string domain = Opal::Sip::EndPoint::get_aor_domain (aor.str ());
bool found = (std::find (active_domains.begin (), active_domains.end (), domain) != active_domains.end ());
- if (account.is_enabled () && !found)
+ if (is_enabled && !found)
active_domains.push_back (domain);
- else if (!account.is_enabled () && found)
+ else if (!is_enabled && found)
active_domains.remove (domain);
// Register the given aor to the give registrar
if (!SIPEndPoint::Register (params, _aor))
- OnRegistrationFailed (aor.str (), SIP_PDU::MaxStatusCode, account.is_enabled ());
+ OnRegistrationFailed (aor.str (), SIP_PDU::MaxStatusCode, is_enabled);
}
-void Opal::Sip::EndPoint::OnRegistered (const PString & _aor,
- bool was_registering)
+void
+Opal::Sip::EndPoint::OnRegistered (const PString & _aor,
+ bool was_registering)
{
std::string aor = (const char *) _aor;
std::string::size_type found;
@@ -676,18 +672,18 @@ void Opal::Sip::EndPoint::OnRegistered (const PString & _aor,
Subscribe (SIPSubscribe::MessageSummary, 3600, aor);
/* Signal */
- Opal::Account *account = bank->find_account (strm.str ());
- if (account)
- Ekiga::Runtime::run_in_main (sigc::bind (sigc::ptr_fun(registration_event_in_main),
- account->registration_event.make_slot (),
- was_registering ? Ekiga::AccountCore::Registered : Ekiga::AccountCore::Unregistered,
- std::string ()));
+ Ekiga::Runtime::run_in_main (sigc::bind (sigc::mem_fun (this,
+ &Opal::Sip::EndPoint::registration_event_in_main),
+ strm.str (),
+ was_registering ? Ekiga::AccountCore::Registered : Ekiga::AccountCore::Unregistered,
+ std::string ()));
}
-void Opal::Sip::EndPoint::OnRegistrationFailed (const PString & _aor,
- SIP_PDU::StatusCodes r,
- bool wasRegistering)
+void
+Opal::Sip::EndPoint::OnRegistrationFailed (const PString & _aor,
+ SIP_PDU::StatusCodes r,
+ bool wasRegistering)
{
std::stringstream strm;
std::string info;
@@ -914,17 +910,19 @@ void Opal::Sip::EndPoint::OnRegistrationFailed (const PString & _aor,
*/
if (r != SIP_PDU::Failure_RequestTerminated) {
/* Signal */
- Opal::Account *account = bank->find_account (strm.str ());
- if (account)
- Ekiga::Runtime::run_in_main (sigc::bind (sigc::ptr_fun(registration_event_in_main),
- account->registration_event.make_slot (),
- wasRegistering ? Ekiga::AccountCore::RegistrationFailed : Ekiga::AccountCore::UnregistrationFailed,
- info));
+ Ekiga::Runtime::run_in_main (sigc::bind (sigc::mem_fun (this,
+ &Opal::Sip::EndPoint::registration_event_in_main),
+ strm.str (),
+ wasRegistering ? Ekiga::AccountCore::RegistrationFailed : Ekiga::AccountCore::UnregistrationFailed,
+ info));
}
}
-void Opal::Sip::EndPoint::OnMWIReceived (const PString & party, OpalManager::MessageWaitingType /*type*/, const PString & info)
+void
+Opal::Sip::EndPoint::OnMWIReceived (const PString & party,
+ OpalManager::MessageWaitingType /*type*/,
+ const PString & info)
{
std::string mwi = info;
std::transform (mwi.begin(), mwi.end(), mwi.begin(), ::tolower);
@@ -932,15 +930,14 @@ void Opal::Sip::EndPoint::OnMWIReceived (const PString & party, OpalManager::Mes
mwi = "0/0";
/* Signal */
- Opal::Account *account = bank->find_account (party);
- if (account)
- Ekiga::Runtime::run_in_main (sigc::bind (account->mwi_event.make_slot (), info));
+ Ekiga::Runtime::run_in_main (sigc::bind (sigc::mem_fun (this, &Opal::Sip::EndPoint::mwi_received_in_main), party, info));
}
-bool Opal::Sip::EndPoint::OnIncomingConnection (OpalConnection &connection,
- unsigned options,
- OpalConnection::StringOptions * stroptions)
+bool
+Opal::Sip::EndPoint::OnIncomingConnection (OpalConnection &connection,
+ unsigned options,
+ OpalConnection::StringOptions * stroptions)
{
PTRACE (3, "Opal::Sip::EndPoint\tIncoming connection");
@@ -972,8 +969,9 @@ bool Opal::Sip::EndPoint::OnIncomingConnection (OpalConnection &connection,
}
-bool Opal::Sip::EndPoint::OnReceivedMESSAGE (OpalTransport & transport,
- SIP_PDU & pdu)
+bool
+Opal::Sip::EndPoint::OnReceivedMESSAGE (OpalTransport & transport,
+ SIP_PDU & pdu)
{
PString *last = NULL;
PString *val = NULL;
@@ -999,28 +997,31 @@ bool Opal::Sip::EndPoint::OnReceivedMESSAGE (OpalTransport & transport,
std::string message_uri = (const char *) uri.AsString ();
std::string _message = (const char *) pdu.GetEntityBody ();
- Ekiga::Runtime::run_in_main (sigc::bind (sigc::ptr_fun (push_message_in_main), dialect, message_uri, display_name, _message));
+ Ekiga::Runtime::run_in_main (sigc::bind (sigc::mem_fun (this, &Opal::Sip::EndPoint::push_message_in_main), message_uri, display_name, _message));
}
return SIPEndPoint::OnReceivedMESSAGE (transport, pdu);
}
-void Opal::Sip::EndPoint::OnMessageFailed (const SIPURL & messageUrl,
- SIP_PDU::StatusCodes /*reason*/)
+void
+Opal::Sip::EndPoint::OnMessageFailed (const SIPURL & messageUrl,
+ SIP_PDU::StatusCodes /*reason*/)
{
SIPURL to = messageUrl;
to.Sanitise (SIPURL::ToURI);
std::string uri = (const char *) to.AsString ();
std::string display_name = (const char *) to.GetDisplayName ();
- Ekiga::Runtime::run_in_main (sigc::bind (sigc::ptr_fun (push_notice_in_main),
- dialect, uri, display_name,
- _("Could not send message")));
+ Ekiga::Runtime::run_in_main (sigc::bind (sigc::mem_fun (this, &Opal::Sip::EndPoint::push_notice_in_main),
+ uri, display_name,
+ _("Could not send message")));
}
-SIPURL Opal::Sip::EndPoint::GetRegisteredPartyName (const SIPURL & host, const OpalTransport & transport)
+SIPURL
+Opal::Sip::EndPoint::GetRegisteredPartyName (const SIPURL & host,
+ const OpalTransport & transport)
{
PString local_address;
PIPSocket::Address address;
@@ -1029,7 +1030,7 @@ SIPURL Opal::Sip::EndPoint::GetRegisteredPartyName (const SIPURL & host, const O
SIPURL registration_address;
/* If we are registered to an account corresponding to host, use it.
- */
+ */
PSafePtr<SIPHandler> info = activeSIPHandlers.FindSIPHandlerByDomain(host.GetHostName (), SIP_PDU::Method_REGISTER, PSafeReadOnly);
if (info != NULL) {
@@ -1044,6 +1045,9 @@ SIPURL Opal::Sip::EndPoint::GetRegisteredPartyName (const SIPURL & host, const O
*/
if (host.GetHostAddress ().GetIpAndPort (address, port) && !manager.IsLocalAddress (address)) {
+ /* FIXME: this is the only place where we use the bank in a thread
+ * can't we just return GetDefaultDisplayName () ?
+ */
Opal::Account *account = bank->find_account ("Ekiga.net");
if (account)
@@ -1111,7 +1115,7 @@ Opal::Sip::EndPoint::OnPresenceInfoReceived (const PString & user,
if (presence != "unknown" && (old_presence != presence || old_status != status)) {
presence_infos[_uri].presence = presence;
presence_infos[_uri].status = status;
- Ekiga::Runtime::run_in_main (sigc::bind (sigc::ptr_fun (presence_status_in_main), this, _uri, presence_infos[_uri].presence, presence_infos[_uri].status));
+ Ekiga::Runtime::run_in_main (sigc::bind (sigc::mem_fun (this, &Opal::Sip::EndPoint::presence_status_in_main), _uri, presence_infos[_uri].presence, presence_infos[_uri].status));
}
}
@@ -1127,36 +1131,36 @@ Opal::Sip::EndPoint::OnDialogInfoReceived (const SIPDialogNotification & info)
PString remote_display_name = info.m_remote.m_display.IsEmpty () ? remote_uri : info.m_remote.m_display;
switch (info.m_state) {
- case SIPDialogNotification::Proceeding:
- case SIPDialogNotification::Early:
- if (!remote_display_name.IsEmpty ())
- _status = g_strdup_printf (_("Incoming call from %s"), (const char *) remote_display_name);
- else
- _status = g_strdup_printf (_("Incoming call"));
- status = _status;
- presence = "ringing";
- break;
- case SIPDialogNotification::Confirmed:
- if (!remote_display_name.IsEmpty ())
- _status = g_strdup_printf (_("In a call with %s"), (const char *) remote_display_name);
- else
- _status = g_strdup_printf (_("In a call"));
- presence = "inacall";
- status = _status;
- break;
- default:
- case SIPDialogNotification::Trying:
- case SIPDialogNotification::Terminated:
- break;
+ case SIPDialogNotification::Proceeding:
+ case SIPDialogNotification::Early:
+ if (!remote_display_name.IsEmpty ())
+ _status = g_strdup_printf (_("Incoming call from %s"), (const char *) remote_display_name);
+ else
+ _status = g_strdup_printf (_("Incoming call"));
+ status = _status;
+ presence = "ringing";
+ break;
+ case SIPDialogNotification::Confirmed:
+ if (!remote_display_name.IsEmpty ())
+ _status = g_strdup_printf (_("In a call with %s"), (const char *) remote_display_name);
+ else
+ _status = g_strdup_printf (_("In a call"));
+ presence = "inacall";
+ status = _status;
+ break;
+ default:
+ case SIPDialogNotification::Trying:
+ case SIPDialogNotification::Terminated:
+ break;
}
dialog_infos[uri].presence = presence;
dialog_infos[uri].status = status;
if (_status)
- Ekiga::Runtime::run_in_main (sigc::bind (sigc::ptr_fun (presence_status_in_main), this, uri, dialog_infos[uri].presence, dialog_infos[uri].status));
+ Ekiga::Runtime::run_in_main (sigc::bind (sigc::mem_fun (this, &Opal::Sip::EndPoint::presence_status_in_main), uri, dialog_infos[uri].presence, dialog_infos[uri].status));
else
- Ekiga::Runtime::run_in_main (sigc::bind (sigc::ptr_fun (presence_status_in_main), this, uri, presence_infos[uri].presence, presence_infos[uri].status));
+ Ekiga::Runtime::run_in_main (sigc::bind (sigc::mem_fun (this, &Opal::Sip::EndPoint::presence_status_in_main), uri, presence_infos[uri].presence, presence_infos[uri].status));
}
@@ -1180,3 +1184,54 @@ void Opal::Sip::EndPoint::on_transfer (std::string uri)
if (!PIsDescendant(&(*connection), OpalPCSSConnection))
connection->TransferConnection (uri);
}
+
+void
+Opal::Sip::EndPoint::registration_event_in_main (const std::string aor,
+ Ekiga::AccountCore::RegistrationState state,
+ const std::string msg)
+{
+ Opal::Account* account = bank->find_account (aor);
+
+ if (account != 0) {
+
+ account->registration_event.emit (state, msg);
+ }
+}
+
+
+void
+Opal::Sip::EndPoint::presence_status_in_main (std::string uri,
+ std::string presence,
+ std::string status)
+{
+ presence_received.emit (uri, presence);
+ status_received.emit (uri, status);
+}
+
+void
+Opal::Sip::EndPoint::push_message_in_main (const std::string uri,
+ const std::string name,
+ const std::string msg)
+{
+ dialect->push_message (uri, name, msg);
+}
+
+void
+Opal::Sip::EndPoint::push_notice_in_main (const std::string uri,
+ const std::string name,
+ const std::string msg)
+{
+ dialect->push_notice (uri, name, msg);
+}
+
+void
+Opal::Sip::EndPoint::mwi_received_in_main (const std::string aor,
+ const std::string info)
+{
+ Opal::Account* account = bank->find_account (aor);
+
+ if (account) {
+
+ account->mwi_event.emit (info);
+ }
+}
diff --git a/lib/engine/components/opal/sip-endpoint.h b/lib/engine/components/opal/sip-endpoint.h
index 2e4adb4..39f808b 100644
--- a/lib/engine/components/opal/sip-endpoint.h
+++ b/lib/engine/components/opal/sip-endpoint.h
@@ -60,17 +60,17 @@ namespace Opal {
namespace Sip {
- class EndPoint : public SIPEndPoint,
- public Ekiga::CallProtocolManager,
- public Ekiga::PresenceFetcher,
- public Ekiga::PresencePublisher,
- public Ekiga::PresentityDecorator,
- public Ekiga::AccountSubscriberImpl<Opal::Account>,
- public Ekiga::ContactDecorator
+ class EndPoint : public SIPEndPoint,
+ public Ekiga::CallProtocolManager,
+ public Ekiga::PresenceFetcher,
+ public Ekiga::PresencePublisher,
+ public Ekiga::PresentityDecorator,
+ public Ekiga::AccountSubscriberImpl<Opal::Account>,
+ public Ekiga::ContactDecorator
{
PCLASSINFO(EndPoint, SIPEndPoint);
- public:
+ public:
typedef std::list<std::string> domain_list;
typedef std::list<std::string>::iterator domain_list_iterator;
@@ -79,9 +79,11 @@ namespace Opal {
std::string status;
bool requested;
} uri_info;
- typedef std::map<std::string, uri_info> uri_info_map;
+ typedef std::map<std::string, uri_info> uri_info_map;
- EndPoint (CallManager &ep, Ekiga::ServiceCore & core, unsigned listen_port);
+ EndPoint (CallManager& ep,
+ Ekiga::ServiceCore& core,
+ unsigned listen_port);
~EndPoint ();
@@ -109,12 +111,12 @@ namespace Opal {
/* Chat subsystem */
- bool send_message (const std::string & uri,
+ bool send_message (const std::string & uri,
const std::string & message);
/* CallProtocolManager */
- bool dial (const std::string & uri);
+ bool dial (const std::string & uri);
const std::string & get_protocol_name () const;
@@ -122,7 +124,7 @@ namespace Opal {
unsigned get_dtmf_mode () const;
bool set_listen_port (unsigned port);
- const Ekiga::CallProtocolManager::Interface & get_listen_interface () const;
+ const Ekiga::CallProtocolManager::Interface& get_listen_interface () const;
/* SIP EndPoint */
@@ -135,18 +137,23 @@ namespace Opal {
void set_forward_uri (const std::string & uri);
const std::string & get_forward_uri () const;
-
+
/* AccountSubscriber */
bool subscribe (const Opal::Account & account);
bool unsubscribe (const Opal::Account & account);
-
+
/* Helper */
static std::string get_aor_domain (const std::string & aor);
/* OPAL Methods */
- void Register (const Opal::Account & account);
+ void Register (const std::string username,
+ const std::string host,
+ const std::string auth_username,
+ const std::string password,
+ bool is_enabled,
+ unsigned timeout);
void OnRegistered (const PString & aor,
bool wasRegistering);
@@ -155,8 +162,8 @@ namespace Opal {
SIP_PDU::StatusCodes reason,
bool wasRegistering);
- void OnMWIReceived (const PString & party,
- OpalManager::MessageWaitingType type,
+ void OnMWIReceived (const PString & party,
+ OpalManager::MessageWaitingType type,
const PString & info);
bool OnIncomingConnection (OpalConnection &connection,
@@ -175,16 +182,36 @@ namespace Opal {
void OnMessageFailed (const SIPURL & messageUrl,
SIP_PDU::StatusCodes reason);
- SIPURL GetRegisteredPartyName (const SIPURL & host, const OpalTransport & transport);
+ SIPURL GetRegisteredPartyName (const SIPURL & host,
+ const OpalTransport & transport);
/* Callbacks */
- private:
+ private:
void on_dial (std::string uri);
void on_message (std::string uri,
std::string name);
void on_transfer (std::string uri);
+ void registration_event_in_main (const std::string aor,
+ Ekiga::AccountCore::RegistrationState state,
+ const std::string msg);
+
+ void presence_status_in_main (std::string uri,
+ std::string presence,
+ std::string status);
+
+ void push_message_in_main (const std::string uri,
+ const std::string name,
+ const std::string msg);
+
+ void push_notice_in_main (const std::string uri,
+ const std::string name,
+ const std::string msg);
+
+ void mwi_received_in_main (const std::string aor,
+ const std::string info);
+
PMutex msgDataMutex;
msgDict msgData;
@@ -205,7 +232,7 @@ namespace Opal {
unsigned listen_port;
- SIP::Dialect* dialect;
+ gmref_ptr<SIP::Dialect> dialect;
domain_list active_domains; // List of active domains
uri_info_map presence_infos; // List of uri presences
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]