[ekiga] Made registration events and message waiting information flow up the dependency graph using signals
- From: Julien Puydt <jpuydt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga] Made registration events and message waiting information flow up the dependency graph using signals
- Date: Fri, 8 Feb 2013 15:04:47 +0000 (UTC)
commit dd74fc3c7aea08fadff0386f0bed848f9ac75be7
Author: Julien Puydt <jpuydt free fr>
Date: Fri Feb 8 13:46:20 2013 +0100
Made registration events and message waiting information flow up the dependency graph using signals and not method calls in the opal code
lib/engine/components/opal/opal-bank.cpp | 24 ++++++++++++++++++
lib/engine/components/opal/opal-bank.h | 7 +++++
lib/engine/components/opal/sip-endpoint.cpp | 36 ++------------------------
lib/engine/components/opal/sip-endpoint.h | 15 ++++++-----
4 files changed, 42 insertions(+), 40 deletions(-)
---
diff --git a/lib/engine/components/opal/opal-bank.cpp b/lib/engine/components/opal/opal-bank.cpp
index 7782166..7596c44 100644
--- a/lib/engine/components/opal/opal-bank.cpp
+++ b/lib/engine/components/opal/opal-bank.cpp
@@ -94,6 +94,9 @@ Opal::Bank::Bank (Ekiga::ServiceCore& core):
g_slist_foreach (accounts, (GFunc) g_free, NULL);
g_slist_free (accounts);
+
+ sip_endpoint->registration_event.connect (boost::bind(&Opal::Bank::on_registration_event, this, _1, _2, _3));
+ sip_endpoint->mwi_event.connect (boost::bind(&Opal::Bank::on_mwi_event, this, _1, _2));
}
Opal::Bank::~Bank ()
@@ -364,3 +367,24 @@ Opal::Bank::unfetch (const std::string uri)
iter++)
(*iter)->unfetch (uri);
}
+
+void
+Opal::Bank::on_registration_event (std::string aor,
+ Opal::Account::RegistrationState state,
+ std::string msg)
+{
+ AccountPtr account = find_account (aor);
+
+ if (account)
+ account->handle_registration_event (state, msg);
+}
+
+void
+Opal::Bank::on_mwi_event (std::string aor,
+ std::string info)
+{
+ AccountPtr account = find_account (aor);
+
+ if (account)
+ account->handle_message_waiting_information (info);
+}
diff --git a/lib/engine/components/opal/opal-bank.h b/lib/engine/components/opal/opal-bank.h
index f2ad7d0..4678040 100644
--- a/lib/engine/components/opal/opal-bank.h
+++ b/lib/engine/components/opal/opal-bank.h
@@ -137,6 +137,13 @@ private:
void save () const;
+ void on_registration_event (std::string aor,
+ Opal::Account::RegistrationState state,
+ std::string msg);
+
+ void on_mwi_event (std::string aor,
+ std::string info);
+
};
/**
diff --git a/lib/engine/components/opal/sip-endpoint.cpp b/lib/engine/components/opal/sip-endpoint.cpp
index 017ffb6..44510e6 100644
--- a/lib/engine/components/opal/sip-endpoint.cpp
+++ b/lib/engine/components/opal/sip-endpoint.cpp
@@ -471,7 +471,7 @@ Opal::Sip::EndPoint::OnRegistrationStatus (const RegistrationStatus & status)
/* Successful registration or unregistration */
if (status.m_reason == SIP_PDU::Successful_OK) {
- Ekiga::Runtime::run_in_main (boost::bind (&Opal::Sip::EndPoint::registration_event_in_main, this, strm.str (), status.m_wasRegistering ? Account::Registered : Account::Unregistered, std::string ()));
+ Ekiga::Runtime::run_in_main (boost::bind (boost::ref(registration_event), strm.str(), status.m_wasRegistering ? Account::Registered : Account::Unregistered, std::string ()));
}
/* Registration or unregistration failure */
else {
@@ -703,7 +703,7 @@ Opal::Sip::EndPoint::OnRegistrationStatus (const RegistrationStatus & status)
* as a sip code has already been scheduled to be shown
*/
if (status.m_reason != SIP_PDU::Failure_RequestTerminated) {
- Ekiga::Runtime::run_in_main (boost::bind (&Opal::Sip::EndPoint::registration_event_in_main, this, strm.str (), status.m_wasRegistering ? Account::RegistrationFailed : Account::UnregistrationFailed, info));
+ Ekiga::Runtime::run_in_main (boost::bind (boost::ref (registration_event), strm.str (), status.m_wasRegistering ? Account::RegistrationFailed : Account::UnregistrationFailed, info));
}
}
}
@@ -720,7 +720,7 @@ Opal::Sip::EndPoint::OnMWIReceived (const PString & party,
mwi = "0/0";
/* Signal */
- Ekiga::Runtime::run_in_main (boost::bind (&Opal::Sip::EndPoint::mwi_received_in_main, this, party, mwi));
+ Ekiga::Runtime::run_in_main (boost::bind (boost::ref(mwi_event), party, mwi));
}
@@ -889,22 +889,6 @@ void Opal::Sip::EndPoint::on_transfer (std::string uri)
connection->TransferConnection (uri);
}
-
-void
-Opal::Sip::EndPoint::registration_event_in_main (const std::string aor,
- Opal::Account::RegistrationState state,
- const std::string msg)
-{
- boost::shared_ptr<Opal::Bank> bk = bank.lock ();
- if (bk) {
-
- AccountPtr account = bk->find_account (aor);
-
- if (account)
- account->handle_registration_event (state, msg);
- }
-}
-
void
Opal::Sip::EndPoint::push_message_in_main (const std::string uri,
const std::string name,
@@ -922,20 +906,6 @@ Opal::Sip::EndPoint::push_notice_in_main (const std::string uri,
}
void
-Opal::Sip::EndPoint::mwi_received_in_main (const std::string aor,
- const std::string info)
-{
- boost::shared_ptr<Opal::Bank> bk = bank.lock ();
- if (bk) {
-
- AccountPtr account = bk->find_account (aor);
-
- if (account)
- account->handle_message_waiting_information (info);
- }
-}
-
-void
Opal::Sip::EndPoint::update_bank (boost::shared_ptr<Opal::Bank> _bank)
{
bank = _bank;
diff --git a/lib/engine/components/opal/sip-endpoint.h b/lib/engine/components/opal/sip-endpoint.h
index 8adfa95..347c0d0 100644
--- a/lib/engine/components/opal/sip-endpoint.h
+++ b/lib/engine/components/opal/sip-endpoint.h
@@ -114,6 +114,14 @@ namespace Opal {
const std::string & get_forward_uri () const;
+ // a registration event occurred
+ // the parameters are the aor, the state and the message
+ boost::signal3<void, std::string, Opal::Account::RegistrationState, std::string> registration_event;
+
+ // a message waiting information was received
+ // the parameters are the aor and the info
+ boost::signal2<void, std::string, std::string> mwi_event;
+
/* AccountSubscriber */
bool subscribe (const Opal::Account & account, const PSafePtr<OpalPresentity> & presentity);
bool unsubscribe (const Opal::Account & account, const PSafePtr<OpalPresentity> & presentity);
@@ -167,10 +175,6 @@ namespace Opal {
bool visit_account (Ekiga::AccountPtr account);
void account_added (Ekiga::AccountPtr account);
- void registration_event_in_main (const std::string aor,
- Account::RegistrationState state,
- const std::string msg);
-
void push_message_in_main (const std::string uri,
const std::string name,
const std::string msg);
@@ -179,9 +183,6 @@ namespace Opal {
const std::string name,
const std::string msg);
- void mwi_received_in_main (const std::string aor,
- const std::string info);
-
PMutex aorMutex;
std::map<std::string, std::string> accounts;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]