From: Ossama Othman Date: Tue, 8 Oct 2013 18:11:12 +0000 (-0700) Subject: Effectively make connman_manager a singleton. X-Git-Tag: accepted/tizen/20131106.223055~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F74%2F10974%2F1;p=profile%2Fivi%2Fsettings-daemon.git 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 --- 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 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 clk( - new ivi::settings::clock(e)); + std::unique_ptr bt( + new ivi::settings::bluetooth(manager, e)); std::unique_ptr eth( - new ivi::settings::ethernet(e)); + new ivi::settings::ethernet(manager, e)); std::unique_ptr wifi( - new ivi::settings::wifi(e)); + new ivi::settings::wifi(manager, e)); + + std::unique_ptr 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 #include #include @@ -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 #include @@ -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();