Chris Masone | 52cd19b | 2011-06-29 17:23:04 -0700 | [diff] [blame^] | 1 | // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "shill/profile.h" |
| 6 | |
| 7 | #include <string> |
| 8 | |
| 9 | #include <base/logging.h> |
| 10 | #include <base/stl_util-inl.h> |
| 11 | |
| 12 | #include "shill/adaptor_interfaces.h" |
| 13 | #include "shill/control_interface.h" |
| 14 | #include "shill/dbus_adaptor.h" |
| 15 | #include "shill/error.h" |
| 16 | #include "shill/property_accessor.h" |
| 17 | #include "shill/shill_event.h" |
| 18 | |
| 19 | using std::string; |
| 20 | |
| 21 | namespace shill { |
| 22 | Profile::Profile(ControlInterface *control_interface) |
| 23 | : adaptor_(control_interface->CreateProfileAdaptor(this)) { |
| 24 | } |
| 25 | |
| 26 | Profile::~Profile() {} |
| 27 | |
| 28 | bool Profile::SetBoolProperty(const string& name, bool value, Error *error) { |
| 29 | VLOG(2) << "Setting " << name << " as a bool."; |
| 30 | bool set = (ContainsKey(bool_properties_, name) && |
| 31 | bool_properties_[name]->Set(value)); |
| 32 | if (!set && error) |
| 33 | error->Populate(Error::kInvalidArguments, name + " is not a R/W bool."); |
| 34 | return set; |
| 35 | } |
| 36 | |
| 37 | bool Profile::SetStringProperty(const string& name, |
| 38 | const string& value, |
| 39 | Error *error) { |
| 40 | VLOG(2) << "Setting " << name << " as a string."; |
| 41 | bool set = (ContainsKey(string_properties_, name) && |
| 42 | string_properties_[name]->Set(value)); |
| 43 | if (!set && error) |
| 44 | error->Populate(Error::kInvalidArguments, name + " is not a R/W string."); |
| 45 | return set; |
| 46 | } |
| 47 | |
| 48 | } // namespace shill |