Make Enable/Disable work using new callbacks for async support.

Use new-style callbacks to implement the Manager EnableTechnology
and DisableTechnology operations asynchronously. This allows
devices to be enabled and disabled from the UI ,and for the UI
to display available networks once the device is enabled.

Removed the behavior whereby setting the Device.Powered property
had the side effect of enabling or disabling the device. To
replace this, I added new Device.Enable and Device.Disable calls
for enabling and disabling individual devices.

Also separated the in-memory value of the Powered property from
the persisted value. Whenever a client requests that a device
be enabled or disabled, the desired power state is immediately
saved in the profile, but the in-memory value isn't updated until
the operation completes. On startup, shill now automatically
starts any devices for which the persistent Powered property
is set, and does not start devices for which it is not set.

BUG=chromium-os:23319,chromium-os:27814
TEST=Manual testing on device + unit tests passing.

Change-Id: Id676be3fc662cfd5efb730c67687edfd16b2dc6b
Reviewed-on: https://gerrit.chromium.org/gerrit/18123
Commit-Ready: Eric Shienbrood <ers@chromium.org>
Reviewed-by: Eric Shienbrood <ers@chromium.org>
Tested-by: Eric Shienbrood <ers@chromium.org>
diff --git a/modem_gsm_network_proxy.h b/modem_gsm_network_proxy.h
index 4b0dc50..f714585 100644
--- a/modem_gsm_network_proxy.h
+++ b/modem_gsm_network_proxy.h
@@ -15,32 +15,50 @@
 class ModemGSMNetworkProxy : public ModemGSMNetworkProxyInterface {
  public:
   // Constructs a ModemManager.Modem.Gsm.Network DBus object proxy at |path|
-  // owned by |service|. Caught signals will be dispatched to |delegate|.
-  ModemGSMNetworkProxy(ModemGSMNetworkProxyDelegate *delegate,
-                       DBus::Connection *connection,
+  // owned by |service|.
+  ModemGSMNetworkProxy(DBus::Connection *connection,
                        const std::string &path,
                        const std::string &service);
   virtual ~ModemGSMNetworkProxy();
 
   // Inherited from ModemGSMNetworkProxyInterface.
-  virtual void GetRegistrationInfo(AsyncCallHandler *call_handler, int timeout);
-  virtual uint32 GetSignalQuality();
+  virtual void GetRegistrationInfo(Error *error,
+                                   const RegistrationInfoCallback &callback,
+                                   int timeout);
+  virtual void GetSignalQuality(Error *error,
+                                const SignalQualityCallback &callback,
+                                int timeout);
   virtual void Register(const std::string &network_id,
-                        AsyncCallHandler *call_handler, int timeout);
-  virtual void Scan(AsyncCallHandler *call_handler, int timeout);
+                        Error *error, const ResultCallback &callback,
+                        int timeout);
+  virtual void Scan(Error *error, const ScanResultsCallback &callback,
+                    int timeout);
   virtual uint32 AccessTechnology();
 
+  virtual void set_signal_quality_callback(
+      const SignalQualitySignalCallback &callback);
+  virtual void set_network_mode_callback(
+      const NetworkModeSignalCallback &callback);
+  virtual void set_registration_info_callback(
+      const RegistrationInfoSignalCallback &callback);
+
  private:
   class Proxy
       : public org::freedesktop::ModemManager::Modem::Gsm::Network_proxy,
         public DBus::ObjectProxy {
    public:
-    Proxy(ModemGSMNetworkProxyDelegate *delegate,
-          DBus::Connection *connection,
+    Proxy(DBus::Connection *connection,
           const std::string &path,
           const std::string &service);
     virtual ~Proxy();
 
+    virtual void set_signal_quality_callback(
+        const SignalQualitySignalCallback &callback);
+    virtual void set_network_mode_callback(
+        const NetworkModeSignalCallback &callback);
+    virtual void set_registration_info_callback(
+        const RegistrationInfoSignalCallback &callback);
+
    private:
     // Signal callbacks inherited from ModemManager::Modem::Gsm::Network_proxy.
     virtual void SignalQuality(const uint32 &quality);
@@ -54,10 +72,15 @@
     virtual void GetRegistrationInfoCallback(const GSMRegistrationInfo &info,
                                              const DBus::Error &dberror,
                                              void *data);
+    virtual void GetSignalQualityCallback(const uint32 &quality,
+                                          const DBus::Error &dberror,
+                                          void *data);
     virtual void ScanCallback(const GSMScanResults &results,
                               const DBus::Error &dberror, void *data);
 
-    ModemGSMNetworkProxyDelegate *delegate_;
+    SignalQualitySignalCallback signal_quality_callback_;
+    RegistrationInfoSignalCallback registration_info_callback_;
+    NetworkModeSignalCallback network_mode_callback_;
 
     DISALLOW_COPY_AND_ASSIGN(Proxy);
   };