| 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 #include "src/device.h" | 5 #include "src/device.h" |
| 6 | 6 |
| 7 #include <glog/logging.h> | 7 #include <glog/logging.h> |
| 8 | 8 |
| 9 #include "src/service.h" | 9 #include "src/service.h" |
| 10 | 10 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 } | 51 } |
| 52 | 52 |
| 53 const std::string& Device::GetCarrier() const { | 53 const std::string& Device::GetCarrier() const { |
| 54 return carrier_; | 54 return carrier_; |
| 55 } | 55 } |
| 56 | 56 |
| 57 // Flimflam Device D-Bus Proxy methods | 57 // Flimflam Device D-Bus Proxy methods |
| 58 void Device::PropertyChanged(const std::string& property_name, | 58 void Device::PropertyChanged(const std::string& property_name, |
| 59 const DBus::Variant& new_value) { | 59 const DBus::Variant& new_value) { |
| 60 DLOG(INFO) << path_ << ": PropertyChanged: property_name = " << property_name; | 60 DLOG(INFO) << path_ << ": PropertyChanged: property_name = " << property_name; |
| 61 if (property_name.compare(kFlimflamDeviceCarrierProperty) == 0) { | 61 if (property_name == kFlimflamDeviceCarrierProperty) { |
| 62 OnCarrierUpdate(new_value.reader().get_string()); | 62 OnCarrierUpdate(new_value.reader().get_string()); |
| 63 } else if (property_name.compare(kFlimflamDeviceTypeProperty) == 0) { | 63 } else if (property_name == kFlimflamDeviceTypeProperty) { |
| 64 OnTypeUpdate(new_value.reader().get_string()); | 64 OnTypeUpdate(new_value.reader().get_string()); |
| 65 } else { | 65 } else { |
| 66 // we don't care about this property | 66 // we don't care about this property |
| 67 } | 67 } |
| 68 } | 68 } |
| 69 | 69 |
| 70 // Private methods | 70 // Private methods |
| 71 | 71 |
| 72 Device::Type Device::TypeFromString(const std::string& type) const { | 72 Device::Type Device::TypeFromString(const std::string& type) const { |
| 73 if (type.compare(kFlimflamDeviceTypeEthernet) == 0) { | 73 if (type == kFlimflamDeviceTypeEthernet) { |
| 74 return kTypeEthernet; | 74 return kTypeEthernet; |
| 75 } | 75 } |
| 76 if (type.compare(kFlimflamDeviceTypeWifi) == 0) { | 76 if (type == kFlimflamDeviceTypeWifi) { |
| 77 return kTypeWifi; | 77 return kTypeWifi; |
| 78 } | 78 } |
| 79 if (type.compare(kFlimflamDeviceTypeWimax) == 0) { | 79 if (type == kFlimflamDeviceTypeWimax) { |
| 80 return kTypeWimax; | 80 return kTypeWimax; |
| 81 } | 81 } |
| 82 if (type.compare(kFlimflamDeviceTypeBluetooth) == 0) { | 82 if (type == kFlimflamDeviceTypeBluetooth) { |
| 83 return kTypeBluetooth; | 83 return kTypeBluetooth; |
| 84 } | 84 } |
| 85 if (type.compare(kFlimflamDeviceTypeGPS) == 0) { | 85 if (type == kFlimflamDeviceTypeGPS) { |
| 86 return kTypeGPS; | 86 return kTypeGPS; |
| 87 } | 87 } |
| 88 if (type.compare(kFlimflamDeviceTypeCellular) == 0) { | 88 if (type == kFlimflamDeviceTypeCellular) { |
| 89 return kTypeCellular; | 89 return kTypeCellular; |
| 90 } | 90 } |
| 91 if (type.compare(kFlimflamDeviceTypeVendor) == 0) { | 91 if (type == kFlimflamDeviceTypeVendor) { |
| 92 return kTypeVendor; | 92 return kTypeVendor; |
| 93 } | 93 } |
| 94 return kTypeUnknown; | 94 return kTypeUnknown; |
| 95 } | 95 } |
| 96 | 96 |
| 97 void Device::OnCarrierUpdate(const std::string& carrier) { | 97 void Device::OnCarrierUpdate(const std::string& carrier) { |
| 98 DLOG(INFO) << path_ << ": OnCarrierUpdate: carrier = " << carrier; | 98 DLOG(INFO) << path_ << ": OnCarrierUpdate: carrier = " << carrier; |
| 99 // only propagate this to parent Service if there's been a change | 99 // only propagate this to parent Service if there's been a change |
| 100 // we expect to see only one such change (from "Unknown") | 100 // we expect to see only one such change (from "Unknown") |
| 101 if (carrier_.compare(carrier)) { | 101 if (carrier_ != carrier) { |
| 102 if (carrier_.compare(kCarrierUnknown)) { | 102 if (carrier_ != kCarrierUnknown) { |
| 103 LOG(WARNING) << path_ << ": OnCarrierUpdate: carrier change from " | 103 LOG(WARNING) << path_ << ": OnCarrierUpdate: carrier change from " |
| 104 << carrier_ << " to " << carrier << "!"; | 104 << carrier_ << " to " << carrier << "!"; |
| 105 } | 105 } |
| 106 carrier_ = carrier; | 106 carrier_ = carrier; |
| 107 parent_->OnCarrierUpdate(carrier); | 107 parent_->OnCarrierUpdate(carrier); |
| 108 } | 108 } |
| 109 } | 109 } |
| 110 | 110 |
| 111 void Device::OnTypeUpdate(const std::string& type) { | 111 void Device::OnTypeUpdate(const std::string& type) { |
| 112 DLOG(INFO) << path_ << ": OnTypeUpdate: type = " << type; | 112 DLOG(INFO) << path_ << ": OnTypeUpdate: type = " << type; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 if (it != properties.end()) { | 156 if (it != properties.end()) { |
| 157 const DBus::Variant& value = static_cast<DBus::Variant>(it->second); | 157 const DBus::Variant& value = static_cast<DBus::Variant>(it->second); |
| 158 OnCarrierUpdate(value.reader().get_string()); | 158 OnCarrierUpdate(value.reader().get_string()); |
| 159 } else { | 159 } else { |
| 160 DLOG(WARNING) << path_ | 160 DLOG(WARNING) << path_ |
| 161 << ": GetDeviceProperties: no Cellular.Carrier property"; | 161 << ": GetDeviceProperties: no Cellular.Carrier property"; |
| 162 } | 162 } |
| 163 } | 163 } |
| 164 | 164 |
| 165 } // namespace cashew | 165 } // namespace cashew |
| OLD | NEW |