[ekiga] Action: Be a bit more restrictive about access to Actor/Action methods.
- From: Damien Sandras <dsandras src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ekiga] Action: Be a bit more restrictive about access to Actor/Action methods.
- Date: Tue, 6 Jan 2015 17:26:47 +0000 (UTC)
commit 4289b897f4874466ee5b6b692c9ca067bc3b2bcc
Author: Damien Sandras <dsandras seconix com>
Date: Tue Jan 6 18:21:21 2015 +0100
Action: Be a bit more restrictive about access to Actor/Action methods.
The idea behind this change is that only Actors can change supported
Actions. An external object is not supposed to add/remove/enable/disable
Actions of a given Actor. Only the Actor itself (ie the class
implementing an Actor is supposed doing it).
lib/engine/action/action-provider.cpp | 7 ++++
lib/engine/action/action-provider.h | 3 ++
lib/engine/action/action.h | 15 ++++-----
lib/engine/action/actor.h | 36 +++++++++++-----------
lib/engine/components/opal/opal-call-manager.cpp | 3 +-
5 files changed, 36 insertions(+), 28 deletions(-)
---
diff --git a/lib/engine/action/action-provider.cpp b/lib/engine/action/action-provider.cpp
index 9a2ecaa..0099ecb 100644
--- a/lib/engine/action/action-provider.cpp
+++ b/lib/engine/action/action-provider.cpp
@@ -40,6 +40,13 @@
using namespace Ekiga;
void
+ActionProvider::add_action (Actor & actor,
+ ActionPtr action)
+{
+ actor.add_action (action);
+}
+
+void
URIActionProviderStore::pull_actions (Actor & actor,
const std::string & name,
const std::string & uri)
diff --git a/lib/engine/action/action-provider.h b/lib/engine/action/action-provider.h
index 648f903..a7280e4 100644
--- a/lib/engine/action/action-provider.h
+++ b/lib/engine/action/action-provider.h
@@ -58,6 +58,9 @@ namespace Ekiga {
{
public:
virtual void pull_actions (Actor & /*actor*/) {};
+ protected:
+ virtual void add_action (Actor & actor,
+ ActionPtr action);
};
typedef boost::shared_ptr< ActionProvider > ActionProviderPtr;
diff --git a/lib/engine/action/action.h b/lib/engine/action/action.h
index 019002a..ce17aa4 100644
--- a/lib/engine/action/action.h
+++ b/lib/engine/action/action.h
@@ -134,7 +134,7 @@ namespace Ekiga {
bool is_enabled () const;
- protected:
+ private:
/** Enable the Action.
* This will enable the action. Only enabled actions are usable
@@ -150,25 +150,22 @@ namespace Ekiga {
void disable ();
-
- std::string name;
- std::string description;
- boost::function0<void> callback;
- bool action_enabled;
-
/** Those signals are emitted when the Action is enabled/disabled.
*/
boost::signals2::signal<void(void)> enabled;
boost::signals2::signal<void(void)> disabled;
- private:
-
/** This signal is emitted when the Action is activated. This triggers
* the signal execution.
*/
boost::signals2::signal<void(void)> activated;
+ std::string name;
+ std::string description;
+ boost::function0<void> callback;
+ bool action_enabled;
+
Ekiga::scoped_connections conns;
};
diff --git a/lib/engine/action/actor.h b/lib/engine/action/actor.h
index c3303ca..e8d4387 100644
--- a/lib/engine/action/actor.h
+++ b/lib/engine/action/actor.h
@@ -60,12 +60,29 @@ namespace Ekiga {
*/
class Actor : public std::list< ActionPtr >
{
- friend class Action;
+ friend class ActionProvider;
public:
typedef std::list < ActionPtr >::const_iterator const_iterator;
typedef std::list < ActionPtr >::iterator iterator;
+ /**
+ * Those signals are emitted when an Action is enabled/disabled
+ * in the ActionMap.
+ */
+ boost::signals2::signal<void(const std::string &)> action_enabled;
+ boost::signals2::signal<void(const std::string &)> action_disabled;
+
+
+ /**
+ * Those signals are emitted when an Action is added/removed
+ * to/from the ActionMap.
+ */
+ boost::signals2::signal<void(const std::string &)> action_added;
+ boost::signals2::signal<void(const std::string &)> action_removed;
+
+
+ protected:
/** Add an action to the given Actor.
*
* Actions that are not "added" using this method will not be usable
@@ -114,23 +131,6 @@ namespace Ekiga {
*/
virtual ActionPtr get_action (const std::string & name);
-
- /**
- * Those signals are emitted when an Action is enabled/disabled
- * in the ActionMap.
- */
- boost::signals2::signal<void(const std::string &)> action_enabled;
- boost::signals2::signal<void(const std::string &)> action_disabled;
-
-
- /**
- * Those signals are emitted when an Action is added/removed
- * to/from the ActionMap.
- */
- boost::signals2::signal<void(const std::string &)> action_added;
- boost::signals2::signal<void(const std::string &)> action_removed;
-
-
private:
/**
diff --git a/lib/engine/components/opal/opal-call-manager.cpp
b/lib/engine/components/opal/opal-call-manager.cpp
index 6f6ade1..d0f93f7 100644
--- a/lib/engine/components/opal/opal-call-manager.cpp
+++ b/lib/engine/components/opal/opal-call-manager.cpp
@@ -235,7 +235,8 @@ void CallManager::pull_actions (Ekiga::Actor & actor,
{
if (is_supported_uri (uri)) {
- actor.add_action (Ekiga::ActionPtr (new Ekiga::Action ("call", _("Call"), boost::bind
(&CallManager::dial, this, uri))));
+ add_action (actor,
+ Ekiga::ActionPtr (new Ekiga::Action ("call", _("Call"), boost::bind (&CallManager::dial,
this, uri))));
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]