[ekiga/ds-opal-refactoring] OpalCall: Simplified signal handling.
- From: Damien Sandras <dsandras src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga/ds-opal-refactoring] OpalCall: Simplified signal handling.
- Date: Tue, 31 Mar 2015 16:14:30 +0000 (UTC)
commit f724b218bc46756abed48a32a36ca80831279e03
Author: Damien Sandras <dsandras seconix com>
Date: Sat Mar 28 16:19:43 2015 +0100
OpalCall: Simplified signal handling.
The Notifications have been moved from OpalCall to the CallCore, where
they belong.
Most signals are now simply relayed instead of having a dedicated
callback.
lib/engine/components/opal/opal-call.cpp | 84 +++---------------------------
lib/engine/components/opal/opal-call.h | 13 -----
lib/engine/engine.cpp | 4 +-
lib/engine/protocol/call-core.cpp | 21 ++++++--
lib/engine/protocol/call-core.h | 8 ++-
plugins/avahi/Makefile.am | 1 +
6 files changed, 33 insertions(+), 98 deletions(-)
---
diff --git a/lib/engine/components/opal/opal-call.cpp b/lib/engine/components/opal/opal-call.cpp
index 9c991de..d23f8b7 100644
--- a/lib/engine/components/opal/opal-call.cpp
+++ b/lib/engine/components/opal/opal-call.cpp
@@ -114,21 +114,9 @@ Opal::Call::Call (Opal::EndPoint& _manager,
Opal::Call::~Call ()
{
- remove_action ("hangup");
- remove_action ("reject");
- remove_action ("answer");
- remove_action ("transfer");
- remove_action ("hold");
- remove_action ("transmit-video");
+ Ekiga::Runtime::run_in_main (boost::ref (removed));
}
-void
-Opal::Call::set_engine_services (boost::shared_ptr<Ekiga::NotificationCore> _notification_core,
- boost::shared_ptr<Ekiga::CallCore> _call_core)
-{
- notification_core = _notification_core;
- call_core = _call_core;
-}
void
Opal::Call::hang_up ()
@@ -495,7 +483,7 @@ Opal::Call::OnEstablished (OpalConnection & connection)
remove_action ("reject");
parse_info (connection);
- Ekiga::Runtime::run_in_main (boost::bind (&Opal::Call::emit_established_in_main, this));
+ Ekiga::Runtime::run_in_main (boost::ref (established));
}
if (PIsDescendant(&connection, OpalRTPConnection)) {
@@ -637,9 +625,9 @@ Opal::Call::OnCleared ()
}
if (IsEstablished () || is_outgoing ())
- Ekiga::Runtime::run_in_main (boost::bind (&Opal::Call::emit_cleared_in_main, this, reason));
+ Ekiga::Runtime::run_in_main (boost::bind (boost::ref (cleared), reason));
else
- Ekiga::Runtime::run_in_main (boost::bind (&Opal::Call::emit_missed_in_main, this));
+ Ekiga::Runtime::run_in_main (boost::ref (missed));
}
@@ -670,7 +658,7 @@ Opal::Call::OnSetUp (OpalConnection & connection)
call_setup = true;
new CallSetup (*this, connection);
- Ekiga::Runtime::run_in_main (boost::bind (&Opal::Call::emit_setup_in_main, this));
+ Ekiga::Runtime::run_in_main (boost::ref (setup));
return true;
}
@@ -680,7 +668,7 @@ PBoolean
Opal::Call::OnAlerting (OpalConnection & connection)
{
if (!PIsDescendant(&connection, OpalPCSSConnection))
- Ekiga::Runtime::run_in_main (boost::bind (&Opal::Call::emit_ringing_in_main, this));
+ Ekiga::Runtime::run_in_main (boost::ref (ringing));
return OpalCall::OnAlerting (connection);
}
@@ -692,9 +680,9 @@ Opal::Call::OnHold (OpalConnection & /*connection*/,
bool on_hold)
{
if (on_hold)
- Ekiga::Runtime::run_in_main (boost::bind (&Opal::Call::emit_held_in_main, this));
+ Ekiga::Runtime::run_in_main (boost::ref (held));
else
- Ekiga::Runtime::run_in_main (boost::bind (&Opal::Call::emit_retrieved_in_main, this));
+ Ekiga::Runtime::run_in_main (boost::ref (retrieved));
}
@@ -755,59 +743,3 @@ Opal::Call::OnNoAnswerTimeout (PTimer &,
Clear (OpalConnection::EndedByNoAnswer);
}
}
-
-void
-Opal::Call::emit_established_in_main ()
-{
- established ();
-}
-
-void
-Opal::Call::emit_missed_in_main ()
-{
- boost::shared_ptr<Ekiga::CallCore> ccore = call_core.lock ();
- if (!ccore)
- return;
-
- std::stringstream msg;
-
- missed ();
- msg << _("Missed call from") << " " << get_remote_party_name ();
- boost::shared_ptr<Ekiga::Notification> notif (new Ekiga::Notification (Ekiga::Notification::Warning,
- _("Missed call"), msg.str (),
- _("Call"),
- boost::bind
(&Ekiga::CallCore::dial, ccore,
- get_remote_uri ())));
- notification_core->push_notification (notif);
-}
-
-void
-Opal::Call::emit_cleared_in_main (const std::string reason)
-{
- cleared (reason);
- removed ();
-}
-
-void
-Opal::Call::emit_setup_in_main ()
-{
- setup ();
-}
-
-void
-Opal::Call::emit_ringing_in_main ()
-{
- ringing ();
-}
-
-void
-Opal::Call::emit_held_in_main ()
-{
- held ();
-}
-
-void
-Opal::Call::emit_retrieved_in_main ()
-{
- retrieved ();
-}
diff --git a/lib/engine/components/opal/opal-call.h b/lib/engine/components/opal/opal-call.h
index 1e61ea0..48d112a 100644
--- a/lib/engine/components/opal/opal-call.h
+++ b/lib/engine/components/opal/opal-call.h
@@ -157,8 +157,6 @@ public:
*/
time_t get_start_time () const;
- void set_engine_services (boost::shared_ptr<Ekiga::NotificationCore> _notification_core,
- boost::shared_ptr<Ekiga::CallCore> _call_core);
public:
@@ -226,9 +224,6 @@ private:
/*
* Variables
*/
- boost::shared_ptr<Ekiga::NotificationCore> notification_core;
- boost::weak_ptr<Ekiga::CallCore> call_core;
-
std::string local_party_name;
std::string remote_party_name;
std::string remote_uri;
@@ -242,14 +237,6 @@ private:
private:
- void emit_established_in_main ();
- void emit_missed_in_main ();
- void emit_cleared_in_main (const std::string reason);
- void emit_setup_in_main ();
- void emit_ringing_in_main ();
- void emit_held_in_main ();
- void emit_retrieved_in_main ();
-
PTime start_time;
RTCPStatistics statistics;
bool auto_answer;
diff --git a/lib/engine/engine.cpp b/lib/engine/engine.cpp
index 5843b61..06ed4e8 100644
--- a/lib/engine/engine.cpp
+++ b/lib/engine/engine.cpp
@@ -97,14 +97,14 @@ engine_init (Ekiga::ServiceCore& core,
// FIRST we add a few things by hand
// (for speed and because that's less code)
- Ekiga::ServicePtr notification_core(new Ekiga::NotificationCore);
+ boost::shared_ptr<Ekiga::NotificationCore> notification_core(new Ekiga::NotificationCore);
core.add (notification_core);
boost::shared_ptr<Ekiga::FriendOrFoe> friend_or_foe (new Ekiga::FriendOrFoe);
boost::shared_ptr<Ekiga::FoeList> foe_list (new Ekiga::FoeList (friend_or_foe));
boost::shared_ptr<Ekiga::AccountCore> account_core (new Ekiga::AccountCore);
boost::shared_ptr<Ekiga::ContactCore> contact_core (new Ekiga::ContactCore);
- boost::shared_ptr<Ekiga::CallCore> call_core (new Ekiga::CallCore (friend_or_foe));
+ boost::shared_ptr<Ekiga::CallCore> call_core (new Ekiga::CallCore (friend_or_foe, notification_core));
boost::shared_ptr<Ekiga::ChatCore> chat_core (new Ekiga::ChatCore);
boost::shared_ptr<Ekiga::VideoOutputCore> videooutput_core (new Ekiga::VideoOutputCore);
boost::shared_ptr<Ekiga::VideoInputCore> videoinput_core (new Ekiga::VideoInputCore (core,
videooutput_core));
diff --git a/lib/engine/protocol/call-core.cpp b/lib/engine/protocol/call-core.cpp
index c89e3eb..d375049 100644
--- a/lib/engine/protocol/call-core.cpp
+++ b/lib/engine/protocol/call-core.cpp
@@ -36,6 +36,7 @@
#include "config.h"
#include <glib/gi18n.h>
+#include <sstream>
#include "call-core.h"
@@ -44,7 +45,8 @@
using namespace Ekiga;
-CallCore::CallCore (boost::shared_ptr<Ekiga::FriendOrFoe> iff_): iff(iff_)
+CallCore::CallCore (boost::shared_ptr<Ekiga::FriendOrFoe> _iff,
+ boost::shared_ptr<Ekiga::NotificationCore> _notification_core) : iff(_iff),
notification_core(_notification_core)
{
}
@@ -171,7 +173,7 @@ void CallCore::add_call (boost::shared_ptr<Call> call)
conns->add (call->ringing.connect (boost::bind (boost::ref (ringing_call), call)));
conns->add (call->setup.connect (boost::bind (boost::ref (setup_call), call)));
- conns->add (call->missed.connect (boost::bind (boost::ref (missed_call), call)));
+ conns->add (call->missed.connect (boost::bind (&CallCore::on_missed_call, this, call)));
conns->add (call->cleared.connect (boost::bind (boost::ref (cleared_call), call, _1)));
conns->add (call->established.connect (boost::bind (boost::ref (established_call), call)));
conns->add (call->held.connect (boost::bind (boost::ref (held_call), call)));
@@ -180,7 +182,7 @@ void CallCore::add_call (boost::shared_ptr<Call> call)
conns->add (call->stream_closed.connect (boost::bind (boost::ref (stream_closed), call, _1, _2, _3)));
conns->add (call->stream_paused.connect (boost::bind (boost::ref (stream_paused), call, _1, _2)));
conns->add (call->stream_resumed.connect (boost::bind (boost::ref (stream_resumed), call, _1, _2)));
- conns->add (call->removed.connect (boost::bind (&CallCore::on_call_removed, this, call)));
+ conns->add (call->removed.connect (boost::bind (&CallCore::remove_call, this, call)));
call_connections [call->get_id ()] = conns;
}
@@ -192,7 +194,16 @@ void CallCore::remove_call (boost::shared_ptr<Call> call)
}
-void CallCore::on_call_removed (boost::shared_ptr<Call> call)
+void CallCore::on_missed_call (boost::shared_ptr<Call> call)
{
- remove_call (call);
+ boost::shared_ptr<Ekiga::NotificationCore> _notification_core = notification_core.lock ();
+ if (_notification_core) {
+ std::stringstream msg;
+ msg << _("Missed call from") << " " << call->get_remote_party_name ();
+ boost::shared_ptr<Ekiga::Notification> notif (new Ekiga::Notification (Ekiga::Notification::Warning,
+ _("Missed call"), msg.str (),
+ _("Call"),
+ boost::bind
(&Ekiga::CallCore::dial, this, call->get_remote_uri ())));
+ _notification_core->push_notification (notif);
+ }
}
diff --git a/lib/engine/protocol/call-core.h b/lib/engine/protocol/call-core.h
index 9b6df8f..c19b906 100644
--- a/lib/engine/protocol/call-core.h
+++ b/lib/engine/protocol/call-core.h
@@ -46,6 +46,7 @@
#include "call.h"
#include "call-manager.h"
#include "contact-core.h"
+#include "notification-core.h"
#include <boost/smart_ptr.hpp>
#include <boost/signals2.hpp>
@@ -83,7 +84,8 @@ namespace Ekiga
/** The constructor
*/
- CallCore (boost::shared_ptr<Ekiga::FriendOrFoe> iff);
+ CallCore (boost::shared_ptr<Ekiga::FriendOrFoe> iff,
+ boost::shared_ptr<Ekiga::NotificationCore> notification_core);
~CallCore ();
@@ -194,9 +196,11 @@ namespace Ekiga
private:
- void on_call_removed (boost::shared_ptr<Call> call);
+ void on_missed_call (boost::shared_ptr<Call> call);
boost::shared_ptr<Ekiga::FriendOrFoe> iff;
+ boost::weak_ptr<Ekiga::NotificationCore> notification_core;
+
std::map<std::string, boost::shared_ptr<Ekiga::scoped_connections> > call_connections;
};
diff --git a/plugins/avahi/Makefile.am b/plugins/avahi/Makefile.am
index 1cd9cb8..455e023 100644
--- a/plugins/avahi/Makefile.am
+++ b/plugins/avahi/Makefile.am
@@ -8,6 +8,7 @@ AM_CXXFLAGS = \
-I$(top_srcdir)/lib/engine/account \
-I$(top_srcdir)/lib/engine/presence \
-I$(top_srcdir)/lib/engine/addressbook \
+ -I$(top_srcdir)/lib/engine/notification \
-I$(top_srcdir)/lib/engine/protocol
libgmavahi_la_SOURCES = \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]