summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOssama Othman <ossama.othman@intel.com>2013-10-08 11:11:12 -0700
committerOssama Othman <ossama.othman@intel.com>2013-10-15 13:26:29 -0700
commitf9ba2cb1939b84ba099ddc7ee7961f1c04eaf837 (patch)
tree1d807e7b79d17d4f56c32f4c41cc3fc7c3a8cfa2
parent967168e40c76dac0b3f56b745e5898217b37a09b (diff)
downloadsettings-daemon-f9ba2cb1939b84ba099ddc7ee7961f1c04eaf837.tar.gz
settings-daemon-f9ba2cb1939b84ba099ddc7ee7961f1c04eaf837.tar.bz2
settings-daemon-f9ba2cb1939b84ba099ddc7ee7961f1c04eaf837.zip
Effectively make connman_manager a singleton.
Only one instance of connman_manager is needed since the corresponding connman Manager is really a global object. Change-Id: I5143c607c91663d5004024a427dc50142c7aa33a Signed-off-by: Ossama Othman <ossama.othman@intel.com>
-rw-r--r--plugins/connman/bluetooth.cpp5
-rw-r--r--plugins/connman/bluetooth.hpp2
-rw-r--r--plugins/connman/ethernet.cpp5
-rw-r--r--plugins/connman/ethernet.hpp2
-rw-r--r--plugins/connman/registration.cpp21
-rw-r--r--plugins/connman/technology.cpp5
-rw-r--r--plugins/connman/technology.hpp15
-rw-r--r--plugins/connman/wifi.cpp5
-rw-r--r--plugins/connman/wifi.hpp2
9 files changed, 35 insertions, 27 deletions
diff --git a/plugins/connman/bluetooth.cpp b/plugins/connman/bluetooth.cpp
index 8265b33..3509f86 100644
--- a/plugins/connman/bluetooth.cpp
+++ b/plugins/connman/bluetooth.cpp
@@ -36,8 +36,9 @@ namespace
// ----------------------------------------------------------------------
-ivi::settings::bluetooth::bluetooth(event_callback const & e)
- : technology_(technology_name, e)
+ivi::settings::bluetooth::bluetooth(connman_manager & manager,
+ event_callback const & e)
+ : technology_(technology_name, manager, e)
{
}
diff --git a/plugins/connman/bluetooth.hpp b/plugins/connman/bluetooth.hpp
index 78f4519..fad039f 100644
--- a/plugins/connman/bluetooth.hpp
+++ b/plugins/connman/bluetooth.hpp
@@ -55,7 +55,7 @@ namespace ivi
public:
/// Constructor.
- bluetooth(event_callback const & e);
+ bluetooth(connman_manager & manager, event_callback const & e);
/// Destructor.
virtual ~bluetooth();
diff --git a/plugins/connman/ethernet.cpp b/plugins/connman/ethernet.cpp
index 5a015b7..6719974 100644
--- a/plugins/connman/ethernet.cpp
+++ b/plugins/connman/ethernet.cpp
@@ -36,8 +36,9 @@ namespace
// ----------------------------------------------------------------------
-ivi::settings::ethernet::ethernet(event_callback const & e)
- : technology_(technology_name, e)
+ivi::settings::ethernet::ethernet(connman_manager & manager,
+ event_callback const & e)
+ : technology_(technology_name, manager, e)
{
}
diff --git a/plugins/connman/ethernet.hpp b/plugins/connman/ethernet.hpp
index 2bfa2fb..e9b3b77 100644
--- a/plugins/connman/ethernet.hpp
+++ b/plugins/connman/ethernet.hpp
@@ -55,7 +55,7 @@ namespace ivi
public:
/// Constructor.
- ethernet(event_callback const & e);
+ ethernet(connman_manager & manager, event_callback const & e);
/// Destructor.
virtual ~ethernet();
diff --git a/plugins/connman/registration.cpp b/plugins/connman/registration.cpp
index a072f25..adccd49 100644
--- a/plugins/connman/registration.cpp
+++ b/plugins/connman/registration.cpp
@@ -25,6 +25,7 @@
*/
#include "connman_api.hpp"
+#include "connman_manager.hpp"
#include "bluetooth.hpp"
#include "clock.hpp"
#include "ethernet.hpp"
@@ -48,23 +49,27 @@ extern "C" IVI_SETTINGS_CONNMAN_API bool
register_settings(ivi::settings::registrar & r,
ivi::settings::event_callback const & e)
{
- std::unique_ptr<ivi::settings::plugin> bt(
- new ivi::settings::bluetooth(e));
+ // Only one instance of connman_manager is needed since the
+ // corresponding connman Manager is really a global object.
+ static ivi::settings::connman_manager manager(e);
- std::unique_ptr<ivi::settings::plugin> clk(
- new ivi::settings::clock(e));
+ std::unique_ptr<ivi::settings::plugin> bt(
+ new ivi::settings::bluetooth(manager, e));
std::unique_ptr<ivi::settings::plugin> eth(
- new ivi::settings::ethernet(e));
+ new ivi::settings::ethernet(manager, e));
std::unique_ptr<ivi::settings::plugin> wifi(
- new ivi::settings::wifi(e));
+ new ivi::settings::wifi(manager, e));
+
+ std::unique_ptr<ivi::settings::plugin> clk(
+ new ivi::settings::clock(e));
return
r.register_setting(std::move(bt))
- && r.register_setting(std::move(clk))
&& r.register_setting(std::move(eth))
- && r.register_setting(std::move(wifi));
+ && r.register_setting(std::move(wifi))
+ && r.register_setting(std::move(clk));
}
// Local Variables:
diff --git a/plugins/connman/technology.cpp b/plugins/connman/technology.cpp
index 1ac890a..325b165 100644
--- a/plugins/connman/technology.cpp
+++ b/plugins/connman/technology.cpp
@@ -25,7 +25,9 @@
*/
#include "technology.hpp"
+#include "connman_manager.hpp"
#include "service.hpp"
+
#include <settingsd/response_callback.hpp>
#include <settingsd/glib_traits.hpp>
#include <settingsd/json_glib_traits.hpp>
@@ -36,12 +38,13 @@
ivi::settings::technology::technology(std::string tech,
+ connman_manager & manager,
event_callback const & e)
: connman_("net.connman.Technology", // Interface
("/net/connman/technology/"
+ tech).c_str(), // Object path
e)
- , manager_(e)
+ , manager_(manager)
, technology_(tech)
, event_callback_(e)
{
diff --git a/plugins/connman/technology.hpp b/plugins/connman/technology.hpp
index 44025bc..a7bf190 100644
--- a/plugins/connman/technology.hpp
+++ b/plugins/connman/technology.hpp
@@ -28,7 +28,8 @@
#define IVI_SETTINGS_CONNMAN_TECHNOLOGY_HPP
#include "connman.hpp"
-#include "connman_manager.hpp"
+
+#include <string>
#include <json-glib/json-glib.h>
@@ -38,6 +39,7 @@ namespace ivi
namespace settings
{
class response_callback;
+ class connman_manager;
/**
* @class technology
@@ -59,6 +61,7 @@ namespace ivi
* clients.
*/
technology(std::string tech,
+ connman_manager & manager,
event_callback const & e);
/// Handle requests common to all connman technologies.
@@ -120,14 +123,8 @@ namespace ivi
/// The proxy used to access the connman Technology D-Bus API.
connman connman_;
- /**
- * The proxy used to access the connman Manager D-Bus API.
- *
- * @todo There is no point in making this @c connman_manager
- * instance technology-specific since it is really a
- * connman global object.
- */
- connman_manager manager_;
+ /// The proxy used to access the connman Manager D-Bus API.
+ connman_manager & manager_;
/// Technology name, e.g. "bluetooth" or "wifi".
std::string const technology_;
diff --git a/plugins/connman/wifi.cpp b/plugins/connman/wifi.cpp
index 8cc4c03..31deafc 100644
--- a/plugins/connman/wifi.cpp
+++ b/plugins/connman/wifi.cpp
@@ -36,8 +36,9 @@ namespace
// ----------------------------------------------------------------------
-ivi::settings::wifi::wifi(event_callback const & e)
- : technology_(technology_name, e)
+ivi::settings::wifi::wifi(connman_manager & manager,
+ event_callback const & e)
+ : technology_(technology_name, manager, e)
{
}
diff --git a/plugins/connman/wifi.hpp b/plugins/connman/wifi.hpp
index 24cb5bd..6d75c93 100644
--- a/plugins/connman/wifi.hpp
+++ b/plugins/connman/wifi.hpp
@@ -57,7 +57,7 @@ namespace ivi
public:
/// Constructor.
- wifi(event_callback const & e);
+ wifi(connman_manager & manager, event_callback const & e);
/// Destructor.
virtual ~wifi();