OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium 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 #include "chromeos/network/network_state.h" | 5 #include "chromeos/network/network_state.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "third_party/cros_system_api/dbus/service_constants.h" | 8 #include "third_party/cros_system_api/dbus/service_constants.h" |
9 | 9 |
10 namespace chromeos { | 10 namespace chromeos { |
(...skipping 24 matching lines...) Expand all Loading... |
35 } else if (key == flimflam::kSecurityProperty) { | 35 } else if (key == flimflam::kSecurityProperty) { |
36 return GetStringValue(key, value, &security_); | 36 return GetStringValue(key, value, &security_); |
37 } else if (key == flimflam::kNetworkTechnologyProperty) { | 37 } else if (key == flimflam::kNetworkTechnologyProperty) { |
38 return GetStringValue(key, value, &technology_); | 38 return GetStringValue(key, value, &technology_); |
39 } else if (key == flimflam::kDeviceProperty) { | 39 } else if (key == flimflam::kDeviceProperty) { |
40 return GetStringValue(key, value, &device_path_); | 40 return GetStringValue(key, value, &device_path_); |
41 } else if (key == flimflam::kGuidProperty) { | 41 } else if (key == flimflam::kGuidProperty) { |
42 return GetStringValue(key, value, &guid_); | 42 return GetStringValue(key, value, &guid_); |
43 } else if (key == shill::kActivateOverNonCellularNetworkProperty) { | 43 } else if (key == shill::kActivateOverNonCellularNetworkProperty) { |
44 return GetBooleanValue(key, value, &activate_over_non_cellular_networks_); | 44 return GetBooleanValue(key, value, &activate_over_non_cellular_networks_); |
| 45 } else if (key == shill::kOutOfCreditsProperty) { |
| 46 return GetBooleanValue(key, value, &cellular_out_of_credits_); |
45 } | 47 } |
46 return false; | 48 return false; |
47 } | 49 } |
48 | 50 |
49 void NetworkState::GetProperties(base::DictionaryValue* dictionary) const { | 51 void NetworkState::GetProperties(base::DictionaryValue* dictionary) const { |
50 // Keep care that these properties are the same as in |PropertyChanged|. | 52 // Keep care that these properties are the same as in |PropertyChanged|. |
51 dictionary->SetStringWithoutPathExpansion(flimflam::kNameProperty, name()); | 53 dictionary->SetStringWithoutPathExpansion(flimflam::kNameProperty, name()); |
52 dictionary->SetStringWithoutPathExpansion(flimflam::kTypeProperty, type()); | 54 dictionary->SetStringWithoutPathExpansion(flimflam::kTypeProperty, type()); |
53 dictionary->SetIntegerWithoutPathExpansion(flimflam::kSignalStrengthProperty, | 55 dictionary->SetIntegerWithoutPathExpansion(flimflam::kSignalStrengthProperty, |
54 signal_strength()); | 56 signal_strength()); |
55 dictionary->SetStringWithoutPathExpansion(flimflam::kStateProperty, | 57 dictionary->SetStringWithoutPathExpansion(flimflam::kStateProperty, |
56 connection_state()); | 58 connection_state()); |
57 dictionary->SetStringWithoutPathExpansion(flimflam::kErrorProperty, | 59 dictionary->SetStringWithoutPathExpansion(flimflam::kErrorProperty, |
58 error()); | 60 error()); |
59 dictionary->SetStringWithoutPathExpansion(flimflam::kActivationStateProperty, | 61 dictionary->SetStringWithoutPathExpansion(flimflam::kActivationStateProperty, |
60 activation_state()); | 62 activation_state()); |
61 dictionary->SetStringWithoutPathExpansion(flimflam::kRoamingStateProperty, | 63 dictionary->SetStringWithoutPathExpansion(flimflam::kRoamingStateProperty, |
62 roaming()); | 64 roaming()); |
63 dictionary->SetStringWithoutPathExpansion(flimflam::kSecurityProperty, | 65 dictionary->SetStringWithoutPathExpansion(flimflam::kSecurityProperty, |
64 security()); | 66 security()); |
65 dictionary->SetStringWithoutPathExpansion( | 67 dictionary->SetStringWithoutPathExpansion( |
66 flimflam::kNetworkTechnologyProperty, | 68 flimflam::kNetworkTechnologyProperty, |
67 technology()); | 69 technology()); |
68 dictionary->SetStringWithoutPathExpansion(flimflam::kDeviceProperty, | 70 dictionary->SetStringWithoutPathExpansion(flimflam::kDeviceProperty, |
69 device_path()); | 71 device_path()); |
70 dictionary->SetStringWithoutPathExpansion(flimflam::kGuidProperty, guid()); | 72 dictionary->SetStringWithoutPathExpansion(flimflam::kGuidProperty, guid()); |
71 dictionary->SetBooleanWithoutPathExpansion( | 73 dictionary->SetBooleanWithoutPathExpansion( |
72 shill::kActivateOverNonCellularNetworkProperty, | 74 shill::kActivateOverNonCellularNetworkProperty, |
73 activate_over_non_cellular_networks()); | 75 activate_over_non_cellular_networks()); |
| 76 dictionary->SetBooleanWithoutPathExpansion(shill::kOutOfCreditsProperty, |
| 77 cellular_out_of_credits()); |
74 } | 78 } |
75 | 79 |
76 bool NetworkState::IsConnectedState() const { | 80 bool NetworkState::IsConnectedState() const { |
77 return StateIsConnected(connection_state_); | 81 return StateIsConnected(connection_state_); |
78 } | 82 } |
79 | 83 |
80 bool NetworkState::IsConnectingState() const { | 84 bool NetworkState::IsConnectingState() const { |
81 return StateIsConnecting(connection_state_); | 85 return StateIsConnecting(connection_state_); |
82 } | 86 } |
83 | 87 |
84 // static | 88 // static |
85 bool NetworkState::StateIsConnected(const std::string& connection_state) { | 89 bool NetworkState::StateIsConnected(const std::string& connection_state) { |
86 return (connection_state == flimflam::kStateReady || | 90 return (connection_state == flimflam::kStateReady || |
87 connection_state == flimflam::kStateOnline || | 91 connection_state == flimflam::kStateOnline || |
88 connection_state == flimflam::kStatePortal); | 92 connection_state == flimflam::kStatePortal); |
89 } | 93 } |
90 | 94 |
91 // static | 95 // static |
92 bool NetworkState::StateIsConnecting(const std::string& connection_state) { | 96 bool NetworkState::StateIsConnecting(const std::string& connection_state) { |
93 return (connection_state == flimflam::kStateAssociation || | 97 return (connection_state == flimflam::kStateAssociation || |
94 connection_state == flimflam::kStateConfiguration || | 98 connection_state == flimflam::kStateConfiguration || |
95 connection_state == flimflam::kStateCarrier); | 99 connection_state == flimflam::kStateCarrier); |
96 } | 100 } |
97 | 101 |
98 } // namespace chromeos | 102 } // namespace chromeos |
OLD | NEW |