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.h b/modem_gsm_card_proxy.h
index 944403a..b6196d1 100644
--- a/modem_gsm_card_proxy.h
+++ b/modem_gsm_card_proxy.h
@@ -16,28 +16,35 @@
 
 class ModemGSMCardProxy : public ModemGSMCardProxyInterface {
  public:
-  // Constructs a ModemManager.Modem.Gsm.Card DBus object proxy at |path| owned
-  // by |service|. Callbacks will be dispatched to |delegate|.
-  ModemGSMCardProxy(ModemGSMCardProxyDelegate *delegate,
-                    DBus::Connection *connection,
+  // Constructs a ModemManager.Modem.Gsm.Card DBus
+  // object proxy at |path| owned by |service|.
+  ModemGSMCardProxy(DBus::Connection *connection,
                     const std::string &path,
                     const std::string &service);
   virtual ~ModemGSMCardProxy();
 
   // Inherited from ModemGSMCardProxyInterface.
-  virtual void GetIMEI(AsyncCallHandler *call_handler, int timeout);
-  virtual void GetIMSI(AsyncCallHandler *call_handler, int timeout);
-  virtual void GetSPN(AsyncCallHandler *call_handler, int timeout);
-  virtual void GetMSISDN(AsyncCallHandler *call_handler, int timeout);
+  virtual void GetIMEI(Error *error, const GSMIdentifierCallback &callback,
+                       int timeout);
+  virtual void GetIMSI(Error *error, const GSMIdentifierCallback &callback,
+                       int timeout);
+  virtual void GetSPN(Error *error, const GSMIdentifierCallback &callback,
+                      int timeout);
+  virtual void GetMSISDN(Error *error, const GSMIdentifierCallback &callback,
+                         int timeout);
   virtual void EnablePIN(const std::string &pin, bool enabled,
-                         AsyncCallHandler *call_handler, int timeout);
+                         Error *error, const ResultCallback &callback,
+                         int timeout);
   virtual void SendPIN(const std::string &pin,
-                       AsyncCallHandler *call_handler, int timeout);
+                       Error *error, const ResultCallback &callback,
+                       int timeout);
   virtual void SendPUK(const std::string &puk, const std::string &pin,
-                       AsyncCallHandler *call_handler, int timeout);
+                       Error *error, const ResultCallback &callback,
+                       int timeout);
   virtual void ChangePIN(const std::string &old_pin,
                          const std::string &new_pin,
-                         AsyncCallHandler *call_handler, int timeout);
+                         Error *error, const ResultCallback &callback,
+                         int timeout);
   virtual uint32 EnabledFacilityLocks();
 
  private:
@@ -45,8 +52,7 @@
       : public org::freedesktop::ModemManager::Modem::Gsm::Card_proxy,
         public DBus::ObjectProxy {
    public:
-    Proxy(ModemGSMCardProxyDelegate *delegate,
-          DBus::Connection *connection,
+    Proxy(DBus::Connection *connection,
           const std::string &path,
           const std::string &service);
     virtual ~Proxy();
@@ -62,14 +68,16 @@
                                  const DBus::Error &dberror, void *data);
     virtual void GetSpnCallback(const std::string &spn,
                                  const DBus::Error &dberror, void *data);
-    virtual void GetMsIsdnCallback(const std::string &misisdn,
+    virtual void GetMsIsdnCallback(const std::string &msisdn,
                                  const DBus::Error &dberror, void *data);
     virtual void EnablePinCallback(const DBus::Error &dberror, void *data);
     virtual void SendPinCallback(const DBus::Error &dberror, void *data);
     virtual void SendPukCallback(const DBus::Error &dberror, void *data);
     virtual void ChangePinCallback(const DBus::Error &dberror, void *data);
 
-    ModemGSMCardProxyDelegate *delegate_;
+    virtual void GetIdCallback(const std::string &id,
+                               const DBus::Error &dberror, void *data);
+    virtual void PinCallback(const DBus::Error &dberror, void *data);
 
     DISALLOW_COPY_AND_ASSIGN(Proxy);
   };