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_cdma_proxy_interface.h b/modem_cdma_proxy_interface.h
index 3329b7b..921a499 100644
--- a/modem_cdma_proxy_interface.h
+++ b/modem_cdma_proxy_interface.h
@@ -9,45 +9,48 @@
 
 #include <base/basictypes.h>
 
+#include "shill/callbacks.h"
 #include "shill/dbus_properties.h"
 
 namespace shill {
 
-class AsyncCallHandler;
 class Error;
 
+typedef base::Callback<void(uint32)> SignalQualitySignalCallback;
+typedef base::Callback<void(uint32, uint32)> RegistrationStateSignalCallback;
+
+typedef base::Callback<void(uint32, const Error &)> ActivationResultCallback;
+typedef base::Callback<void(uint32, const Error &)> SignalQualityCallback;
+typedef base::Callback<void(uint32, uint32,
+                            const Error &)> RegistrationStateCallback;
+
 // These are the methods that a ModemManager.Modem.CDMA proxy must support.
 // The interface is provided so that it can be mocked in tests.
-// All calls are made asynchronously. Call completion is signalled through
-// the corresponding 'OnXXXCallback' method in the ProxyDelegate interface.
+// All calls are made asynchronously. Call completion is signalled via
+// the callbacks passed to the methods.
 class ModemCDMAProxyInterface {
  public:
   virtual ~ModemCDMAProxyInterface() {}
 
-  virtual void Activate(const std::string &carrier,
-                        AsyncCallHandler *call_handler, int timeout) = 0;
-  virtual void GetRegistrationState(uint32 *cdma_1x_state,
-                                    uint32 *evdo_state) = 0;
-  virtual uint32 GetSignalQuality() = 0;
+  virtual void Activate(const std::string &carrier, Error *error,
+                        const ActivationResultCallback &callback,
+                        int timeout) = 0;
+  virtual void GetRegistrationState(Error *error,
+                                    const RegistrationStateCallback &callback,
+                                    int timeout) = 0;
+  virtual void GetSignalQuality(Error *error,
+                                const SignalQualityCallback &callback,
+                                int timeout) = 0;
 
   // Properties.
   virtual const std::string MEID() = 0;
-};
 
-// ModemManager.Modem.CDMA signal delegate to be associated with the proxy.
-class ModemCDMAProxyDelegate {
- public:
-  virtual ~ModemCDMAProxyDelegate() {}
-
-  virtual void OnCDMAActivationStateChanged(
-      uint32 activation_state,
-      uint32 activation_error,
-      const DBusPropertiesMap &status_changes) = 0;
-  virtual void OnCDMARegistrationStateChanged(uint32 state_1x,
-                                              uint32 state_evdo) = 0;
-  virtual void OnCDMASignalQualityChanged(uint32 strength) = 0;
-  virtual void OnActivateCallback(uint32 status, const Error &error,
-                                  AsyncCallHandler *call_handler) = 0;
+  virtual void set_activation_state_callback(
+      const ActivationStateSignalCallback &callback) = 0;
+  virtual void set_signal_quality_callback(
+      const SignalQualitySignalCallback &callback) = 0;
+  virtual void set_registration_state_callback(
+      const RegistrationStateSignalCallback &callback) = 0;
 };
 
 }  // namespace shill