| 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/dbus/shill_service_client.h" | 5 #include "chromeos/dbus/shill_service_client.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 ShillClientHelper* helper = iter->second; | 64 ShillClientHelper* helper = iter->second; |
| 65 bus_->RemoveObjectProxy(shill::kFlimflamServiceName, | 65 bus_->RemoveObjectProxy(shill::kFlimflamServiceName, |
| 66 helper->object_proxy()->object_path(), | 66 helper->object_proxy()->object_path(), |
| 67 base::Bind(&base::DoNothing)); | 67 base::Bind(&base::DoNothing)); |
| 68 delete helper; | 68 delete helper; |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 | 71 |
| 72 virtual void AddPropertyChangedObserver( | 72 virtual void AddPropertyChangedObserver( |
| 73 const dbus::ObjectPath& service_path, | 73 const dbus::ObjectPath& service_path, |
| 74 ShillPropertyChangedObserver* observer) OVERRIDE { | 74 ShillPropertyChangedObserver* observer) override { |
| 75 GetHelper(service_path)->AddPropertyChangedObserver(observer); | 75 GetHelper(service_path)->AddPropertyChangedObserver(observer); |
| 76 } | 76 } |
| 77 | 77 |
| 78 virtual void RemovePropertyChangedObserver( | 78 virtual void RemovePropertyChangedObserver( |
| 79 const dbus::ObjectPath& service_path, | 79 const dbus::ObjectPath& service_path, |
| 80 ShillPropertyChangedObserver* observer) OVERRIDE { | 80 ShillPropertyChangedObserver* observer) override { |
| 81 GetHelper(service_path)->RemovePropertyChangedObserver(observer); | 81 GetHelper(service_path)->RemovePropertyChangedObserver(observer); |
| 82 } | 82 } |
| 83 | 83 |
| 84 virtual void GetProperties(const dbus::ObjectPath& service_path, | 84 virtual void GetProperties(const dbus::ObjectPath& service_path, |
| 85 const DictionaryValueCallback& callback) OVERRIDE { | 85 const DictionaryValueCallback& callback) override { |
| 86 dbus::MethodCall method_call(shill::kFlimflamServiceInterface, | 86 dbus::MethodCall method_call(shill::kFlimflamServiceInterface, |
| 87 shill::kGetPropertiesFunction); | 87 shill::kGetPropertiesFunction); |
| 88 GetHelper(service_path)->CallDictionaryValueMethodWithErrorCallback( | 88 GetHelper(service_path)->CallDictionaryValueMethodWithErrorCallback( |
| 89 &method_call, | 89 &method_call, |
| 90 base::Bind(callback, DBUS_METHOD_CALL_SUCCESS), | 90 base::Bind(callback, DBUS_METHOD_CALL_SUCCESS), |
| 91 base::Bind(&OnGetDictionaryError, "GetProperties", | 91 base::Bind(&OnGetDictionaryError, "GetProperties", |
| 92 service_path, callback)); | 92 service_path, callback)); |
| 93 } | 93 } |
| 94 | 94 |
| 95 virtual void SetProperty(const dbus::ObjectPath& service_path, | 95 virtual void SetProperty(const dbus::ObjectPath& service_path, |
| 96 const std::string& name, | 96 const std::string& name, |
| 97 const base::Value& value, | 97 const base::Value& value, |
| 98 const base::Closure& callback, | 98 const base::Closure& callback, |
| 99 const ErrorCallback& error_callback) OVERRIDE { | 99 const ErrorCallback& error_callback) override { |
| 100 dbus::MethodCall method_call(shill::kFlimflamServiceInterface, | 100 dbus::MethodCall method_call(shill::kFlimflamServiceInterface, |
| 101 shill::kSetPropertyFunction); | 101 shill::kSetPropertyFunction); |
| 102 dbus::MessageWriter writer(&method_call); | 102 dbus::MessageWriter writer(&method_call); |
| 103 writer.AppendString(name); | 103 writer.AppendString(name); |
| 104 ShillClientHelper::AppendValueDataAsVariant(&writer, value); | 104 ShillClientHelper::AppendValueDataAsVariant(&writer, value); |
| 105 GetHelper(service_path)->CallVoidMethodWithErrorCallback(&method_call, | 105 GetHelper(service_path)->CallVoidMethodWithErrorCallback(&method_call, |
| 106 callback, | 106 callback, |
| 107 error_callback); | 107 error_callback); |
| 108 } | 108 } |
| 109 | 109 |
| 110 virtual void SetProperties(const dbus::ObjectPath& service_path, | 110 virtual void SetProperties(const dbus::ObjectPath& service_path, |
| 111 const base::DictionaryValue& properties, | 111 const base::DictionaryValue& properties, |
| 112 const base::Closure& callback, | 112 const base::Closure& callback, |
| 113 const ErrorCallback& error_callback) OVERRIDE { | 113 const ErrorCallback& error_callback) override { |
| 114 dbus::MethodCall method_call(shill::kFlimflamServiceInterface, | 114 dbus::MethodCall method_call(shill::kFlimflamServiceInterface, |
| 115 shill::kSetPropertiesFunction); | 115 shill::kSetPropertiesFunction); |
| 116 dbus::MessageWriter writer(&method_call); | 116 dbus::MessageWriter writer(&method_call); |
| 117 ShillClientHelper::AppendServicePropertiesDictionary(&writer, properties); | 117 ShillClientHelper::AppendServicePropertiesDictionary(&writer, properties); |
| 118 GetHelper(service_path)->CallVoidMethodWithErrorCallback(&method_call, | 118 GetHelper(service_path)->CallVoidMethodWithErrorCallback(&method_call, |
| 119 callback, | 119 callback, |
| 120 error_callback); | 120 error_callback); |
| 121 } | 121 } |
| 122 | 122 |
| 123 virtual void ClearProperty(const dbus::ObjectPath& service_path, | 123 virtual void ClearProperty(const dbus::ObjectPath& service_path, |
| 124 const std::string& name, | 124 const std::string& name, |
| 125 const base::Closure& callback, | 125 const base::Closure& callback, |
| 126 const ErrorCallback& error_callback) OVERRIDE { | 126 const ErrorCallback& error_callback) override { |
| 127 dbus::MethodCall method_call(shill::kFlimflamServiceInterface, | 127 dbus::MethodCall method_call(shill::kFlimflamServiceInterface, |
| 128 shill::kClearPropertyFunction); | 128 shill::kClearPropertyFunction); |
| 129 dbus::MessageWriter writer(&method_call); | 129 dbus::MessageWriter writer(&method_call); |
| 130 writer.AppendString(name); | 130 writer.AppendString(name); |
| 131 GetHelper(service_path)->CallVoidMethodWithErrorCallback(&method_call, | 131 GetHelper(service_path)->CallVoidMethodWithErrorCallback(&method_call, |
| 132 callback, | 132 callback, |
| 133 error_callback); | 133 error_callback); |
| 134 } | 134 } |
| 135 | 135 |
| 136 | 136 |
| 137 virtual void ClearProperties(const dbus::ObjectPath& service_path, | 137 virtual void ClearProperties(const dbus::ObjectPath& service_path, |
| 138 const std::vector<std::string>& names, | 138 const std::vector<std::string>& names, |
| 139 const ListValueCallback& callback, | 139 const ListValueCallback& callback, |
| 140 const ErrorCallback& error_callback) OVERRIDE { | 140 const ErrorCallback& error_callback) override { |
| 141 dbus::MethodCall method_call(shill::kFlimflamServiceInterface, | 141 dbus::MethodCall method_call(shill::kFlimflamServiceInterface, |
| 142 shill::kClearPropertiesFunction); | 142 shill::kClearPropertiesFunction); |
| 143 dbus::MessageWriter writer(&method_call); | 143 dbus::MessageWriter writer(&method_call); |
| 144 writer.AppendArrayOfStrings(names); | 144 writer.AppendArrayOfStrings(names); |
| 145 GetHelper(service_path)->CallListValueMethodWithErrorCallback( | 145 GetHelper(service_path)->CallListValueMethodWithErrorCallback( |
| 146 &method_call, | 146 &method_call, |
| 147 callback, | 147 callback, |
| 148 error_callback); | 148 error_callback); |
| 149 } | 149 } |
| 150 | 150 |
| 151 virtual void Connect(const dbus::ObjectPath& service_path, | 151 virtual void Connect(const dbus::ObjectPath& service_path, |
| 152 const base::Closure& callback, | 152 const base::Closure& callback, |
| 153 const ErrorCallback& error_callback) OVERRIDE { | 153 const ErrorCallback& error_callback) override { |
| 154 dbus::MethodCall method_call(shill::kFlimflamServiceInterface, | 154 dbus::MethodCall method_call(shill::kFlimflamServiceInterface, |
| 155 shill::kConnectFunction); | 155 shill::kConnectFunction); |
| 156 GetHelper(service_path)->CallVoidMethodWithErrorCallback( | 156 GetHelper(service_path)->CallVoidMethodWithErrorCallback( |
| 157 &method_call, callback, error_callback); | 157 &method_call, callback, error_callback); |
| 158 } | 158 } |
| 159 | 159 |
| 160 virtual void Disconnect(const dbus::ObjectPath& service_path, | 160 virtual void Disconnect(const dbus::ObjectPath& service_path, |
| 161 const base::Closure& callback, | 161 const base::Closure& callback, |
| 162 const ErrorCallback& error_callback) OVERRIDE { | 162 const ErrorCallback& error_callback) override { |
| 163 dbus::MethodCall method_call(shill::kFlimflamServiceInterface, | 163 dbus::MethodCall method_call(shill::kFlimflamServiceInterface, |
| 164 shill::kDisconnectFunction); | 164 shill::kDisconnectFunction); |
| 165 GetHelper(service_path)->CallVoidMethodWithErrorCallback(&method_call, | 165 GetHelper(service_path)->CallVoidMethodWithErrorCallback(&method_call, |
| 166 callback, | 166 callback, |
| 167 error_callback); | 167 error_callback); |
| 168 } | 168 } |
| 169 | 169 |
| 170 virtual void Remove(const dbus::ObjectPath& service_path, | 170 virtual void Remove(const dbus::ObjectPath& service_path, |
| 171 const base::Closure& callback, | 171 const base::Closure& callback, |
| 172 const ErrorCallback& error_callback) OVERRIDE { | 172 const ErrorCallback& error_callback) override { |
| 173 dbus::MethodCall method_call(shill::kFlimflamServiceInterface, | 173 dbus::MethodCall method_call(shill::kFlimflamServiceInterface, |
| 174 shill::kRemoveServiceFunction); | 174 shill::kRemoveServiceFunction); |
| 175 GetHelper(service_path)->CallVoidMethodWithErrorCallback(&method_call, | 175 GetHelper(service_path)->CallVoidMethodWithErrorCallback(&method_call, |
| 176 callback, | 176 callback, |
| 177 error_callback); | 177 error_callback); |
| 178 } | 178 } |
| 179 | 179 |
| 180 virtual void ActivateCellularModem( | 180 virtual void ActivateCellularModem( |
| 181 const dbus::ObjectPath& service_path, | 181 const dbus::ObjectPath& service_path, |
| 182 const std::string& carrier, | 182 const std::string& carrier, |
| 183 const base::Closure& callback, | 183 const base::Closure& callback, |
| 184 const ErrorCallback& error_callback) OVERRIDE { | 184 const ErrorCallback& error_callback) override { |
| 185 dbus::MethodCall method_call(shill::kFlimflamServiceInterface, | 185 dbus::MethodCall method_call(shill::kFlimflamServiceInterface, |
| 186 shill::kActivateCellularModemFunction); | 186 shill::kActivateCellularModemFunction); |
| 187 dbus::MessageWriter writer(&method_call); | 187 dbus::MessageWriter writer(&method_call); |
| 188 writer.AppendString(carrier); | 188 writer.AppendString(carrier); |
| 189 GetHelper(service_path)->CallVoidMethodWithErrorCallback(&method_call, | 189 GetHelper(service_path)->CallVoidMethodWithErrorCallback(&method_call, |
| 190 callback, | 190 callback, |
| 191 error_callback); | 191 error_callback); |
| 192 } | 192 } |
| 193 | 193 |
| 194 virtual void CompleteCellularActivation( | 194 virtual void CompleteCellularActivation( |
| 195 const dbus::ObjectPath& service_path, | 195 const dbus::ObjectPath& service_path, |
| 196 const base::Closure& callback, | 196 const base::Closure& callback, |
| 197 const ErrorCallback& error_callback) OVERRIDE { | 197 const ErrorCallback& error_callback) override { |
| 198 dbus::MethodCall method_call(shill::kFlimflamServiceInterface, | 198 dbus::MethodCall method_call(shill::kFlimflamServiceInterface, |
| 199 shill::kCompleteCellularActivationFunction); | 199 shill::kCompleteCellularActivationFunction); |
| 200 dbus::MessageWriter writer(&method_call); | 200 dbus::MessageWriter writer(&method_call); |
| 201 GetHelper(service_path)->CallVoidMethodWithErrorCallback(&method_call, | 201 GetHelper(service_path)->CallVoidMethodWithErrorCallback(&method_call, |
| 202 callback, | 202 callback, |
| 203 error_callback); | 203 error_callback); |
| 204 } | 204 } |
| 205 | 205 |
| 206 virtual void GetLoadableProfileEntries( | 206 virtual void GetLoadableProfileEntries( |
| 207 const dbus::ObjectPath& service_path, | 207 const dbus::ObjectPath& service_path, |
| 208 const DictionaryValueCallback& callback) OVERRIDE { | 208 const DictionaryValueCallback& callback) override { |
| 209 dbus::MethodCall method_call(shill::kFlimflamServiceInterface, | 209 dbus::MethodCall method_call(shill::kFlimflamServiceInterface, |
| 210 shill::kGetLoadableProfileEntriesFunction); | 210 shill::kGetLoadableProfileEntriesFunction); |
| 211 GetHelper(service_path)->CallDictionaryValueMethodWithErrorCallback( | 211 GetHelper(service_path)->CallDictionaryValueMethodWithErrorCallback( |
| 212 &method_call, | 212 &method_call, |
| 213 base::Bind(callback, DBUS_METHOD_CALL_SUCCESS), | 213 base::Bind(callback, DBUS_METHOD_CALL_SUCCESS), |
| 214 base::Bind(&OnGetDictionaryError, "GetLoadableProfileEntries", | 214 base::Bind(&OnGetDictionaryError, "GetLoadableProfileEntries", |
| 215 service_path, callback)); | 215 service_path, callback)); |
| 216 } | 216 } |
| 217 | 217 |
| 218 virtual ShillServiceClient::TestInterface* GetTestInterface() OVERRIDE { | 218 virtual ShillServiceClient::TestInterface* GetTestInterface() override { |
| 219 return NULL; | 219 return NULL; |
| 220 } | 220 } |
| 221 | 221 |
| 222 protected: | 222 protected: |
| 223 virtual void Init(dbus::Bus* bus) OVERRIDE { | 223 virtual void Init(dbus::Bus* bus) override { |
| 224 bus_ = bus; | 224 bus_ = bus; |
| 225 } | 225 } |
| 226 | 226 |
| 227 private: | 227 private: |
| 228 typedef std::map<std::string, ShillClientHelper*> HelperMap; | 228 typedef std::map<std::string, ShillClientHelper*> HelperMap; |
| 229 | 229 |
| 230 // Returns the corresponding ShillClientHelper for the profile. | 230 // Returns the corresponding ShillClientHelper for the profile. |
| 231 ShillClientHelper* GetHelper(const dbus::ObjectPath& service_path) { | 231 ShillClientHelper* GetHelper(const dbus::ObjectPath& service_path) { |
| 232 HelperMap::iterator it = helpers_.find(service_path.value()); | 232 HelperMap::iterator it = helpers_.find(service_path.value()); |
| 233 if (it != helpers_.end()) | 233 if (it != helpers_.end()) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 ShillServiceClient::ShillServiceClient() {} | 280 ShillServiceClient::ShillServiceClient() {} |
| 281 | 281 |
| 282 ShillServiceClient::~ShillServiceClient() {} | 282 ShillServiceClient::~ShillServiceClient() {} |
| 283 | 283 |
| 284 // static | 284 // static |
| 285 ShillServiceClient* ShillServiceClient::Create() { | 285 ShillServiceClient* ShillServiceClient::Create() { |
| 286 return new ShillServiceClientImpl(); | 286 return new ShillServiceClientImpl(); |
| 287 } | 287 } |
| 288 | 288 |
| 289 } // namespace chromeos | 289 } // namespace chromeos |
| OLD | NEW |