| 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 #ifndef SRC_SERVICE_H_ | 5 #ifndef SRC_SERVICE_H_ |
| 6 #define SRC_SERVICE_H_ | 6 #define SRC_SERVICE_H_ |
| 7 | 7 |
| 8 #include <glib.h> | 8 #include <glib.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 kTypeWifi, | 63 kTypeWifi, |
| 64 kTypeWimax, | 64 kTypeWimax, |
| 65 kTypeBluetooth, | 65 kTypeBluetooth, |
| 66 kTypeCellular, | 66 kTypeCellular, |
| 67 } Type; | 67 } Type; |
| 68 | 68 |
| 69 // get type for this service | 69 // get type for this service |
| 70 // NOTE: for now, should always be kTypeCellular | 70 // NOTE: for now, should always be kTypeCellular |
| 71 virtual Type GetType() const; | 71 virtual Type GetType() const; |
| 72 | 72 |
| 73 // convert type string to Type enum value |
| 74 static Type TypeFromString(const std::string& type); |
| 75 |
| 73 // get Device object for this service | 76 // get Device object for this service |
| 74 // this can return NULL if we don't yet have Device info | 77 // this can return NULL if we don't yet have Device info |
| 75 virtual Device* GetDevice() const; | 78 virtual Device* GetDevice() const; |
| 76 | 79 |
| 77 // get data plan info, formatted for D-Bus | 80 // get data plan info, formatted for D-Bus |
| 78 virtual DBusDataPlanList GetDBusDataPlans() const; | 81 virtual DBusDataPlanList GetDBusDataPlans() const; |
| 79 | 82 |
| 83 // do we think that we're the default service at this time? |
| 84 virtual bool IsDefaultService() const; |
| 85 |
| 80 // Flimflam Service D-Bus Proxy methods | 86 // Flimflam Service D-Bus Proxy methods |
| 81 | 87 |
| 82 // receive incoming PropertyChanged D-Bus signal from Flimflam service | 88 // receive incoming PropertyChanged D-Bus signal from Flimflam service |
| 83 virtual void PropertyChanged(const std::string& property_name, | 89 virtual void PropertyChanged(const std::string& property_name, |
| 84 const DBus::Variant& new_value); | 90 const DBus::Variant& new_value); |
| 85 | 91 |
| 86 // Device methods | 92 // Device methods |
| 87 | 93 |
| 88 // we've received updated Cellular.Carrier info from our child Device | 94 // we've received updated Cellular.Carrier info from our child Device |
| 89 virtual void OnCarrierUpdate(const std::string& carrier); | 95 virtual void OnCarrierUpdate(const std::string& carrier); |
| 90 | 96 |
| 91 // DataPlanProviderDelegate methods | 97 // DataPlanProviderDelegate methods |
| 92 | 98 |
| 93 // a request to our carrier usage API proxy has completed | 99 // a request to our carrier usage API proxy has completed |
| 94 virtual void OnRequestComplete(const DataPlanProvider *provider, | 100 virtual void OnRequestComplete(const DataPlanProvider *provider, |
| 95 bool successful, | 101 bool successful, |
| 96 const Value *parsed_usage_update); | 102 const Value *parsed_usage_update); |
| 97 | 103 |
| 104 // Service Manager methods |
| 105 |
| 106 // we've received an update from our parent about whether or not we're the |
| 107 // default service |
| 108 virtual void OnDefaultServiceUpdate(bool is_default_service); |
| 109 |
| 110 // we've received an update from our parent that Flimflam has come online |
| 111 virtual void OnFlimflamOnline(); |
| 112 |
| 113 // we've received an update from our parent that Flimflam has gone offline |
| 114 virtual void OnFlimflamOffline(); |
| 115 |
| 98 private: | 116 private: |
| 99 // back pointer to our parent ServiceManager | 117 // back pointer to our parent ServiceManager |
| 100 ServiceManager * const parent_; | 118 ServiceManager * const parent_; |
| 101 | 119 |
| 102 // D-Bus connection, owned by our creator | 120 // D-Bus connection, owned by our creator |
| 103 // shared with Device obj that we create | 121 // shared with Device obj that we create |
| 104 DBus::Connection& connection_; | 122 DBus::Connection& connection_; |
| 105 | 123 |
| 106 // D-Bus path for Flimflam service that we represent | 124 // D-Bus path for Flimflam service that we represent |
| 107 // this is our unique identifier | 125 // this is our unique identifier |
| (...skipping 20 matching lines...) Expand all Loading... |
| 128 | 146 |
| 129 // do we have an outstanding usage API request | 147 // do we have an outstanding usage API request |
| 130 bool request_in_progress_; | 148 bool request_in_progress_; |
| 131 | 149 |
| 132 // periodic update timeout | 150 // periodic update timeout |
| 133 GSource *update_timeout_source_; | 151 GSource *update_timeout_source_; |
| 134 | 152 |
| 135 // carrier policy | 153 // carrier policy |
| 136 Policy *policy_; | 154 Policy *policy_; |
| 137 | 155 |
| 156 // do we think that we're the default service? |
| 157 bool is_default_service_; |
| 158 |
| 138 // convert state string to State enum value | 159 // convert state string to State enum value |
| 139 State StateFromString(const std::string& state) const; | 160 State StateFromString(const std::string& state) const; |
| 140 | 161 |
| 141 // convert type string to Type enum value | |
| 142 Type TypeFromString(const std::string& type) const; | |
| 143 | |
| 144 // we've received updated Device info from Flimflam | 162 // we've received updated Device info from Flimflam |
| 145 void OnDeviceUpdate(const DBus::Path& device_path); | 163 void OnDeviceUpdate(const DBus::Path& device_path); |
| 146 | 164 |
| 147 // we've received updated State info from Flimflam | 165 // we've received updated State info from Flimflam |
| 148 void OnStateUpdate(const std::string& state); | 166 void OnStateUpdate(const std::string& state); |
| 149 | 167 |
| 150 // we've received updated Type info from Flimflam | 168 // we've received updated Type info from Flimflam |
| 151 void OnTypeUpdate(const std::string& type); | 169 void OnTypeUpdate(const std::string& type); |
| 152 | 170 |
| 153 // we've received updated Cellular.UsageUrl info from Flimflam | 171 // we've received updated Cellular.UsageUrl info from Flimflam |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 // this also destroys the update timer and cancels pending requests | 207 // this also destroys the update timer and cancels pending requests |
| 190 // NOTE: this does not delete usage url (it's considered service state) | 208 // NOTE: this does not delete usage url (it's considered service state) |
| 191 void DeleteCarrierState(); | 209 void DeleteCarrierState(); |
| 192 | 210 |
| 193 // does |status| contain a valid usage API status result string? | 211 // does |status| contain a valid usage API status result string? |
| 194 bool IsValidCrosUsageStatus(const std::string& status) const; | 212 bool IsValidCrosUsageStatus(const std::string& status) const; |
| 195 | 213 |
| 196 // usage API request returned an error result | 214 // usage API request returned an error result |
| 197 void OnCrosUsageErrorResult(const std::string& status); | 215 void OnCrosUsageErrorResult(const std::string& status); |
| 198 | 216 |
| 217 // do we think that we're connected at this time? |
| 218 bool IsConnected() const; |
| 219 |
| 220 // we've just become connected |
| 221 void OnConnected(); |
| 222 |
| 223 // we've just become disconnected |
| 224 // NOTE: this means we've entered a state other than kStateReady, not |
| 225 // that we're necessarily in kStateDisconnect |
| 226 void OnDisconnected(); |
| 227 |
| 228 // are we currently sending periodic usage API requests? |
| 229 bool IsSendingUsageRequests() const; |
| 230 |
| 231 // based on our best current knowledge and our policy, should we be |
| 232 // sending periodic usage API requests? |
| 233 bool ShouldSendUsageRequests() const; |
| 234 |
| 235 // stop sending periodic usage API requests |
| 236 void StopSendingUsageRequests(); |
| 237 |
| 238 // start sending periodic usage API requests |
| 239 void StartSendingUsageRequests(); |
| 240 |
| 241 // something has changed, so reevaluate whether or not we should be sending |
| 242 // periodic usage API requests and adjust our behavior if necessary |
| 243 void ReconsiderSendingUsageRequests(); |
| 244 |
| 199 DISALLOW_COPY_AND_ASSIGN(Service); | 245 DISALLOW_COPY_AND_ASSIGN(Service); |
| 200 }; | 246 }; |
| 201 | 247 |
| 202 } // namespace cashew | 248 } // namespace cashew |
| 203 | 249 |
| 204 #endif // SRC_SERVICE_H_ | 250 #endif // SRC_SERVICE_H_ |
| OLD | NEW |