Implement {Available|Connected|Enabled}Technolgies and DefaultTechnology

This is Part 1 of a series of changes required for the Manager to generate
the right set of DBus events allowing shill to properly tell Chrome about
connectivity.

Some other side-effects in the change (needed to implement the above):
- Emit these manager properties over DBus everytime we re-sort the Service
  vector.
- Add a technology data member to Device, this allows easy enumeration of
  technologies.
- Add interface for getting a handle to the selected service on a device.
- Map connected state to online instead of ready state. This is needed for
  so that Chrome doesn't wait for the portal detection code to switch the
  state from ready->online.
- Default set the ethernet service as connectable.

BUG=chromium-os:14887
TEST=1) manual test to verify shill properly configures the ethernet
     device and Chrome correctly detects that.
     2) new unit tests

Change-Id: Ib10f2f0836f8d4aacaad1491f58ed9b3b5d37e7d
Reviewed-on: https://gerrit.chromium.org/gerrit/12019
Tested-by: Gaurav Shah <gauravsh@chromium.org>
Reviewed-by: mukesh agrawal <quiche@chromium.org>
diff --git a/device.h b/device.h
index bc8dd9d..299b0c6 100644
--- a/device.h
+++ b/device.h
@@ -41,7 +41,8 @@
          Manager *manager,
          const std::string &link_name,
          const std::string &address,
-         int interface_index);
+         int interface_index,
+         Technology::Identifier technology);
   virtual ~Device();
 
   virtual void Start();
@@ -51,6 +52,9 @@
   // to Start()), or destroyed (if its refcount falls to zero).
   virtual void Stop();
 
+
+  // TODO(gauravsh): We do not really need this since technology() can be used
+  //                 to get a device's technology for direct comparison.
   // Base method always returns false.
   virtual bool TechnologyIs(const Technology::Identifier type) const;
 
@@ -70,6 +74,11 @@
                          const std::string &new_pin,
                          Error *error);
 
+  // Returns true if the selected service on the device (if any) is connected.
+  // Returns false if there is no selected service, or if the selected service
+  // is not connected.
+  bool IsConnected() const;
+
   std::string GetRpcIdentifier();
   std::string GetStorageIdentifier();
 
@@ -78,6 +87,7 @@
   int interface_index() const { return interface_index_; }
   const ConnectionRefPtr &connection() const { return connection_; }
   bool powered() const { return powered_; }
+  virtual Technology::Identifier technology() const { return technology_; }
 
   const std::string &FriendlyName() const;
 
@@ -112,6 +122,8 @@
   FRIEND_TEST(DeviceTest, SelectedService);
   FRIEND_TEST(DeviceTest, Stop);
   FRIEND_TEST(ManagerTest, DeviceRegistrationAndStart);
+  FRIEND_TEST(ManagerTest, ConnectedTechnologies);
+  FRIEND_TEST(ManagerTest, DefaultTechnology);
   FRIEND_TEST(WiFiMainTest, Connect);
 
   // If there's an IP configuration in |ipconfig_|, releases the IP address and
@@ -188,6 +200,7 @@
   IPConfigRefPtr ipconfig_;
   ConnectionRefPtr connection_;
   scoped_ptr<DeviceAdaptorInterface> adaptor_;
+  Technology::Identifier technology_;
 
   // Maintain a reference to the connected / connecting service
   ServiceRefPtr selected_service_;