| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef SRC_SERVICE_H_ |
| 6 #define SRC_SERVICE_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <string> |
| 10 |
| 11 #include <base/basictypes.h> // NOLINT |
| 12 #include <dbus-c++/dbus.h> // NOLINT |
| 13 |
| 14 #include "src/data_plan.h" |
| 15 #include "src/flimflam_service_client_glue.h" |
| 16 |
| 17 namespace cashew { |
| 18 |
| 19 class Device; |
| 20 |
| 21 // map of key, value pairs representing service properties received via D-Bus |
| 22 typedef std::map<std::string, DBus::Variant> PropertyMap; |
| 23 |
| 24 // represents a cellular service and monitors Flimflam state for that service |
| 25 class Service : public org::chromium::flimflam::Service_proxy, |
| 26 public DBus::IntrospectableProxy, |
| 27 public DBus::ObjectProxy { |
| 28 public: |
| 29 Service(DBus::Connection& connection, const DBus::Path& path); // NOLINT |
| 30 virtual ~Service(); |
| 31 |
| 32 // get D-Bus path for this service |
| 33 virtual const DBus::Path& GetPath() const; |
| 34 |
| 35 // valid state values for this service |
| 36 typedef enum { |
| 37 kStateUnknown = 0, |
| 38 kStateIdle, |
| 39 kStateCarrier, |
| 40 kStateAssociation, |
| 41 kStateConfiguration, |
| 42 kStateReady, |
| 43 kStateDisconnect, |
| 44 kStateFailure, |
| 45 kStateActivationFailure, |
| 46 } State; |
| 47 |
| 48 // get state for this service |
| 49 virtual State GetState() const; |
| 50 |
| 51 // valid type values for this service |
| 52 typedef enum { |
| 53 kTypeUnknown = 0, |
| 54 kTypeEthernet, |
| 55 kTypeWifi, |
| 56 kTypeWimax, |
| 57 kTypeBluetooth, |
| 58 kTypeCellular, |
| 59 } Type; |
| 60 |
| 61 // get type for this service |
| 62 // NOTE: for now, should always be kTypeCellular |
| 63 virtual Type GetType() const; |
| 64 |
| 65 // get Device object for this service |
| 66 // this can return NULL if we don't yet have Device info |
| 67 virtual Device* GetDevice() const; |
| 68 |
| 69 // get data plan info, formatted for D-Bus |
| 70 virtual DBusDataPlanList GetDBusDataPlans() const; |
| 71 |
| 72 // Flimflam Service D-Bus Proxy methods |
| 73 |
| 74 // receive incoming PropertyChanged D-Bus signal from Flimflam service |
| 75 virtual void PropertyChanged(const std::string& property_name, |
| 76 const DBus::Variant& new_value); |
| 77 |
| 78 private: |
| 79 // D-Bus connection, owned by our creator |
| 80 // shared with Device obj that we create |
| 81 DBus::Connection& connection_; |
| 82 |
| 83 // D-Bus path for Flimflam service that we represent |
| 84 // this is our unique identifier |
| 85 const DBus::Path path_; |
| 86 |
| 87 // Service connection state |
| 88 State state_; |
| 89 |
| 90 // Service type |
| 91 Type type_; |
| 92 |
| 93 // Device corresponding to our service |
| 94 Device *device_; |
| 95 |
| 96 // cached data plan info |
| 97 DataPlanList data_plans_; |
| 98 |
| 99 // TODO(vlaviano): reference to back end carrier plugin |
| 100 // TODO(vlaviano): refresh data plan info from carrier plugin |
| 101 |
| 102 // convert state string to State enum value |
| 103 State StateFromString(const std::string& state) const; |
| 104 |
| 105 // convert type string to Type enum value |
| 106 Type TypeFromString(const std::string& type) const; |
| 107 |
| 108 // we've received updated Device info from Flimflam |
| 109 void OnDeviceUpdate(const DBus::Path& device_path); |
| 110 |
| 111 // we've received updated State info from Flimflam |
| 112 void OnStateUpdate(const std::string& state); |
| 113 |
| 114 // we've received updated Type info from Flimflam |
| 115 void OnTypeUpdate(const std::string& type); |
| 116 |
| 117 // get service properties from Flimflam |
| 118 void GetServiceProperties(); |
| 119 |
| 120 // clear data_plans_ list and delete data plan objects |
| 121 void DeleteDataPlans(); |
| 122 |
| 123 // create a hardcoded data plan and add it to data_plans_ list |
| 124 // for debugging |
| 125 void AddHardcodedDataPlan(); |
| 126 |
| 127 DISALLOW_COPY_AND_ASSIGN(Service); |
| 128 }; |
| 129 |
| 130 } // namespace cashew |
| 131 |
| 132 #endif // SRC_SERVICE_H_ |
| OLD | NEW |