Effectively make connman_manager a singleton. 74/10974/1
authorOssama Othman <ossama.othman@intel.com>
Tue, 8 Oct 2013 18:11:12 +0000 (11:11 -0700)
committerOssama Othman <ossama.othman@intel.com>
Tue, 15 Oct 2013 20:26:29 +0000 (13:26 -0700)
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>
plugins/connman/bluetooth.cpp
plugins/connman/bluetooth.hpp
plugins/connman/ethernet.cpp
plugins/connman/ethernet.hpp
plugins/connman/registration.cpp
plugins/connman/technology.cpp
plugins/connman/technology.hpp
plugins/connman/wifi.cpp
plugins/connman/wifi.hpp

index 8265b33..3509f86 100644 (file)
@@ -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)
 {
 }
 
index 78f4519..fad039f 100644 (file)
@@ -55,7 +55,7 @@ namespace ivi
     public:
 
       /// Constructor.
-      bluetooth(event_callback const & e);
+      bluetooth(connman_manager & manager, event_callback const & e);
 
       /// Destructor.
       virtual ~bluetooth();
index 5a015b7..6719974 100644 (file)
@@ -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)
 {
 }
 
index 2bfa2fb..e9b3b77 100644 (file)
@@ -55,7 +55,7 @@ namespace ivi
     public:
 
       /// Constructor.
-      ethernet(event_callback const & e);
+      ethernet(connman_manager & manager, event_callback const & e);
 
       /// Destructor.
       virtual ~ethernet();
index a072f25..adccd49 100644 (file)
@@ -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:
index 1ac890a..325b165 100644 (file)
@@ -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>
 
 
 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)
 {
index 44025bc..a7bf190 100644 (file)
@@ -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_;
index 8cc4c03..31deafc 100644 (file)
@@ -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)
 {
 }
 
index 24cb5bd..6d75c93 100644 (file)
@@ -57,7 +57,7 @@ namespace ivi
     public:
 
       /// Constructor.
-      wifi(event_callback const & e);
+      wifi(connman_manager & manager, event_callback const & e);
 
       /// Destructor.
       virtual ~wifi();