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_card_proxy_interface.h b/modem_gsm_card_proxy_interface.h
index a047c02..1285a3c 100644
--- a/modem_gsm_card_proxy_interface.h
+++ b/modem_gsm_card_proxy_interface.h
@@ -7,62 +7,47 @@
 
 #include <string>
 
+#include "shill/callbacks.h"
+
 namespace shill {
 
-class AsyncCallHandler;
 class Error;
+typedef base::Callback<void(const std::string &,
+                            const Error &)> GSMIdentifierCallback;
 
 // These are the methods that a ModemManager.Modem.Gsm.Card 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.
 class ModemGSMCardProxyInterface {
  public:
   virtual ~ModemGSMCardProxyInterface() {}
 
-  virtual void GetIMEI(AsyncCallHandler *call_handler, int timeout) = 0;
-  virtual void GetIMSI(AsyncCallHandler *call_handler, int timeout) = 0;
-  virtual void GetSPN(AsyncCallHandler *call_handler, int timeout) = 0;
-  virtual void GetMSISDN(AsyncCallHandler *call_handler, int timeout) = 0;
-
+  virtual void GetIMEI(Error *error, const GSMIdentifierCallback &callback,
+                       int timeout) = 0;
+  virtual void GetIMSI(Error *error, const GSMIdentifierCallback &callback,
+                       int timeout) = 0;
+  virtual void GetSPN(Error *error, const GSMIdentifierCallback &callback,
+                      int timeout) = 0;
+  virtual void GetMSISDN(Error *error, const GSMIdentifierCallback &callback,
+                         int timeout) = 0;
   virtual void EnablePIN(const std::string &pin, bool enabled,
-                         AsyncCallHandler *call_handler, int timeout) = 0;
+                         Error *error, const ResultCallback &callback,
+                         int timeout) = 0;
   virtual void SendPIN(const std::string &pin,
-                       AsyncCallHandler *call_handler, int timeout) = 0;
+                       Error *error, const ResultCallback &callback,
+                       int timeout) = 0;
   virtual void SendPUK(const std::string &puk, const std::string &pin,
-                       AsyncCallHandler *call_handler, int timeout) = 0;
+                       Error *error, const ResultCallback &callback,
+                       int timeout) = 0;
   virtual void ChangePIN(const std::string &old_pin,
                          const std::string &new_pin,
-                         AsyncCallHandler *call_handler, int timeout) = 0;
+                         Error *error, const ResultCallback &callback,
+                         int timeout) = 0;
 
   // Properties.
   virtual uint32 EnabledFacilityLocks() = 0;
 };
 
-// ModemManager.Modem.Gsm.Card callback delegate to be associated with the
-// proxy.
-class ModemGSMCardProxyDelegate {
- public:
-  virtual ~ModemGSMCardProxyDelegate() {}
-
-  virtual void OnGetIMEICallback(const std::string &imei,
-                                 const Error &e,
-                                 AsyncCallHandler *call_handler) = 0;
-  virtual void OnGetIMSICallback(const std::string &imsi,
-                                 const Error &e,
-                                 AsyncCallHandler *call_handler) = 0;
-  virtual void OnGetSPNCallback(const std::string &spn,
-                                const Error &e,
-                                AsyncCallHandler *call_handler) = 0;
-  virtual void OnGetMSISDNCallback(const std::string &misisdn,
-                                   const Error &e,
-                                   AsyncCallHandler *call_handler) = 0;
-  // Callback used for all four PIN operations: EnablePIN, SendPIN,
-  // SendPUK, and ChangePIN.
-  virtual void OnPINOperationCallback(const Error &e,
-                                      AsyncCallHandler *call_handler) = 0;
-};
-
 }  // namespace shill
 
 #endif  // SHILL_MODEM_GSM_CARD_PROXY_INTERFACE_