| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // TODO(vlaviano): update accessor style (GetFoo/SetFoo -> foo) | 5 // TODO(vlaviano): update accessor style (GetFoo/SetFoo -> foo) |
| 6 | 6 |
| 7 #ifndef SRC_SERVICE_H_ | 7 #ifndef SRC_SERVICE_H_ |
| 8 #define SRC_SERVICE_H_ | 8 #define SRC_SERVICE_H_ |
| 9 | 9 |
| 10 #include <glib.h> | 10 #include <glib.h> |
| 11 | 11 |
| 12 #include <map> | 12 #include <map> |
| 13 #include <string> | 13 #include <string> |
| 14 | 14 |
| 15 #include <base/basictypes.h> // NOLINT | 15 #include <base/basictypes.h> // NOLINT |
| 16 #include <dbus-c++/dbus.h> // NOLINT | 16 #include <dbus-c++/dbus.h> // NOLINT |
| 17 | 17 |
| 18 #include "src/data_plan.h" | 18 #include "src/data_plan.h" |
| 19 #include "src/data_plan_provider.h" | 19 #include "src/data_plan_provider.h" |
| 20 #include "src/flimflam_service_client_glue.h" | 20 #include "src/flimflam_service_client_glue.h" |
| 21 #include "src/property_changed_handler.h" |
| 21 | 22 |
| 22 namespace cashew { | 23 namespace cashew { |
| 23 | 24 |
| 24 class Device; | 25 class Device; |
| 25 class Policy; | 26 class Policy; |
| 26 class ServiceManager; | 27 class ServiceManager; |
| 27 | 28 |
| 28 // map of key, value pairs representing service properties received via D-Bus | 29 // map of key, value pairs representing service properties received via D-Bus |
| 29 typedef std::map<std::string, DBus::Variant> PropertyMap; | 30 typedef std::map<std::string, DBus::Variant> PropertyMap; |
| 30 | 31 |
| 31 // represents a cellular service and monitors Flimflam state for that service | 32 // represents a cellular service and monitors Flimflam state for that service |
| 32 class Service : public org::chromium::flimflam::Service_proxy, | 33 class Service : public org::chromium::flimflam::Service_proxy, |
| 33 public DBus::IntrospectableProxy, | 34 public DBus::IntrospectableProxy, |
| 34 public DBus::ObjectProxy, | 35 public DBus::ObjectProxy, |
| 35 public DataPlanProviderDelegate { | 36 public DataPlanProviderDelegate, |
| 37 public PropertyChangedDelegate { |
| 36 public: | 38 public: |
| 37 Service(ServiceManager * const parent, | 39 Service(ServiceManager * const parent, |
| 38 DBus::Connection& connection, // NOLINT | 40 DBus::Connection& connection, // NOLINT |
| 39 const DBus::Path& path); | 41 const DBus::Path& path); |
| 40 virtual ~Service(); | 42 virtual ~Service(); |
| 41 | 43 |
| 42 // get D-Bus path for this service | 44 // get D-Bus path for this service |
| 43 virtual const DBus::Path& GetPath() const; | 45 virtual const DBus::Path& GetPath() const; |
| 44 | 46 |
| 45 // valid state values for this service | 47 // valid state values for this service |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 kConnectivityStateRestricted, | 93 kConnectivityStateRestricted, |
| 92 kConnectivityStateUnrestricted, | 94 kConnectivityStateUnrestricted, |
| 93 kConnectivityStateNone, | 95 kConnectivityStateNone, |
| 94 } ConnectivityState; | 96 } ConnectivityState; |
| 95 | 97 |
| 96 // get connectivity state for this service | 98 // get connectivity state for this service |
| 97 virtual ConnectivityState GetConnectivityState() const; | 99 virtual ConnectivityState GetConnectivityState() const; |
| 98 | 100 |
| 99 // Flimflam Service D-Bus Proxy methods | 101 // Flimflam Service D-Bus Proxy methods |
| 100 | 102 |
| 101 // receive incoming PropertyChanged D-Bus signal from Flimflam service | 103 // receive incoming PropertyChanged D-Bus signal from Flimflam service and |
| 104 // schedule deferred processing |
| 102 virtual void PropertyChanged(const std::string& property_name, | 105 virtual void PropertyChanged(const std::string& property_name, |
| 103 const DBus::Variant& new_value); | 106 const DBus::Variant& new_value); |
| 104 | 107 |
| 108 // PropertyChangedDelegate methods |
| 109 |
| 110 virtual void OnPropertyChanged(const PropertyChangedHandler *handler, |
| 111 const std::string& property_name, |
| 112 const DBus::Variant& new_value); |
| 113 |
| 105 // Device methods | 114 // Device methods |
| 106 | 115 |
| 107 // we've received updated Cellular.Carrier info from our child Device | 116 // we've received updated Cellular.Carrier info from our child Device |
| 108 virtual void OnCarrierUpdate(const std::string& carrier); | 117 virtual void OnCarrierUpdate(const std::string& carrier); |
| 109 | 118 |
| 110 // we've received updated byte counter info from our child Device | 119 // we've received updated byte counter info from our child Device |
| 111 virtual void OnByteCounterUpdate(uint64 rx_bytes, uint64 tx_bytes); | 120 virtual void OnByteCounterUpdate(uint64 rx_bytes, uint64 tx_bytes); |
| 112 | 121 |
| 113 // DataPlanProviderDelegate methods | 122 // DataPlanProviderDelegate methods |
| 114 | 123 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 | 201 |
| 193 // are we in the process of retrying our GetProperties call? | 202 // are we in the process of retrying our GetProperties call? |
| 194 // this flag exists to distinguish between our initial g_idle_add call | 203 // this flag exists to distinguish between our initial g_idle_add call |
| 195 // and our subsequent timer calls | 204 // and our subsequent timer calls |
| 196 bool retrying_get_properties_; | 205 bool retrying_get_properties_; |
| 197 | 206 |
| 198 // Service connectivity state | 207 // Service connectivity state |
| 199 // finer-grained connectivity info applicable when |state_| == kStateReady | 208 // finer-grained connectivity info applicable when |state_| == kStateReady |
| 200 ConnectivityState connectivity_state_; | 209 ConnectivityState connectivity_state_; |
| 201 | 210 |
| 211 // Handler for deferred processing of D-Bus PropertyChanged signals. |
| 212 // See comments in service_manager.h |
| 213 PropertyChangedHandler property_changed_handler_; |
| 214 |
| 202 // convert connectivity state string to ConnectivityState enum value | 215 // convert connectivity state string to ConnectivityState enum value |
| 203 static ConnectivityState ConnectivityStateFromString( | 216 static ConnectivityState ConnectivityStateFromString( |
| 204 const std::string& connectivity_state); | 217 const std::string& connectivity_state); |
| 205 | 218 |
| 206 // convert state string to State enum value | 219 // convert state string to State enum value |
| 207 static State StateFromString(const std::string& state); | 220 static State StateFromString(const std::string& state); |
| 208 | 221 |
| 209 // we've received updated Device info from Flimflam | 222 // we've received updated Device info from Flimflam |
| 210 void OnDeviceUpdate(const DBus::Path& device_path); | 223 void OnDeviceUpdate(const DBus::Path& device_path); |
| 211 | 224 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 | 312 |
| 300 // consult policy to determine if we should send an unsolicited update | 313 // consult policy to determine if we should send an unsolicited update |
| 301 void MaybeEmitDataPlansUpdate(); | 314 void MaybeEmitDataPlansUpdate(); |
| 302 | 315 |
| 303 DISALLOW_COPY_AND_ASSIGN(Service); | 316 DISALLOW_COPY_AND_ASSIGN(Service); |
| 304 }; | 317 }; |
| 305 | 318 |
| 306 } // namespace cashew | 319 } // namespace cashew |
| 307 | 320 |
| 308 #endif // SRC_SERVICE_H_ | 321 #endif // SRC_SERVICE_H_ |
| OLD | NEW |