Darin Petkov | e7c6ad3 | 2012-06-29 10:22:09 +0200 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Chris Masone | 52cd19b | 2011-06-29 17:23:04 -0700 | [diff] [blame] | 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 | |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 7 | #include <set> |
Chris Masone | 52cd19b | 2011-06-29 17:23:04 -0700 | [diff] [blame] | 8 | #include <string> |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 9 | #include <vector> |
Chris Masone | 52cd19b | 2011-06-29 17:23:04 -0700 | [diff] [blame] | 10 | |
Chris Masone | b9c0059 | 2011-10-06 13:10:39 -0700 | [diff] [blame] | 11 | #include <base/file_path.h> |
Paul Stewart | e73d05c | 2012-03-29 16:26:05 -0700 | [diff] [blame] | 12 | #include <base/file_util.h> |
Eric Shienbrood | 3e20a23 | 2012-02-16 11:35:56 -0500 | [diff] [blame] | 13 | #include <base/stl_util.h> |
Darin Petkov | a476682 | 2011-07-07 10:42:22 -0700 | [diff] [blame] | 14 | #include <base/string_util.h> |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 15 | #include <base/stringprintf.h> |
Chris Masone | 88cbd5f | 2011-07-03 14:30:04 -0700 | [diff] [blame] | 16 | #include <chromeos/dbus/service_constants.h> |
Chris Masone | 52cd19b | 2011-06-29 17:23:04 -0700 | [diff] [blame] | 17 | |
| 18 | #include "shill/adaptor_interfaces.h" |
| 19 | #include "shill/control_interface.h" |
Chris Masone | b9c0059 | 2011-10-06 13:10:39 -0700 | [diff] [blame] | 20 | #include "shill/key_file_store.h" |
Christopher Wiley | b691efd | 2012-08-09 13:51:51 -0700 | [diff] [blame] | 21 | #include "shill/logging.h" |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 22 | #include "shill/manager.h" |
Chris Masone | 52cd19b | 2011-06-29 17:23:04 -0700 | [diff] [blame] | 23 | #include "shill/property_accessor.h" |
Chris Masone | 7aa5f90 | 2011-07-11 11:13:35 -0700 | [diff] [blame] | 24 | #include "shill/service.h" |
Chris Masone | 9d77993 | 2011-08-25 16:33:41 -0700 | [diff] [blame] | 25 | #include "shill/store_interface.h" |
Chris Masone | 52cd19b | 2011-06-29 17:23:04 -0700 | [diff] [blame] | 26 | |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 27 | using std::set; |
Chris Masone | 52cd19b | 2011-06-29 17:23:04 -0700 | [diff] [blame] | 28 | using std::string; |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 29 | using std::vector; |
Chris Masone | 52cd19b | 2011-06-29 17:23:04 -0700 | [diff] [blame] | 30 | |
| 31 | namespace shill { |
Darin Petkov | a476682 | 2011-07-07 10:42:22 -0700 | [diff] [blame] | 32 | |
Darin Petkov | a476682 | 2011-07-07 10:42:22 -0700 | [diff] [blame] | 33 | Profile::Profile(ControlInterface *control_interface, |
Chris Masone | 7df0c67 | 2011-07-15 10:24:54 -0700 | [diff] [blame] | 34 | Manager *manager, |
| 35 | const Identifier &name, |
Chris Masone | 2ae797d | 2011-08-23 20:41:00 -0700 | [diff] [blame] | 36 | const string &user_storage_format, |
Chris Masone | 7df0c67 | 2011-07-15 10:24:54 -0700 | [diff] [blame] | 37 | bool connect_to_rpc) |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 38 | : manager_(manager), |
Chris Masone | 7df0c67 | 2011-07-15 10:24:54 -0700 | [diff] [blame] | 39 | name_(name), |
Chris Masone | 2ae797d | 2011-08-23 20:41:00 -0700 | [diff] [blame] | 40 | storage_format_(user_storage_format) { |
Chris Masone | 7df0c67 | 2011-07-15 10:24:54 -0700 | [diff] [blame] | 41 | if (connect_to_rpc) |
| 42 | adaptor_.reset(control_interface->CreateProfileAdaptor(this)); |
| 43 | |
Chris Masone | 88cbd5f | 2011-07-03 14:30:04 -0700 | [diff] [blame] | 44 | // flimflam::kCheckPortalListProperty: Registered in DefaultProfile |
| 45 | // flimflam::kCountryProperty: Registered in DefaultProfile |
Chris Masone | 7df0c67 | 2011-07-15 10:24:54 -0700 | [diff] [blame] | 46 | store_.RegisterConstString(flimflam::kNameProperty, &name_.identifier); |
Chris Masone | 88cbd5f | 2011-07-03 14:30:04 -0700 | [diff] [blame] | 47 | |
| 48 | // flimflam::kOfflineModeProperty: Registered in DefaultProfile |
| 49 | // flimflam::kPortalURLProperty: Registered in DefaultProfile |
| 50 | |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 51 | HelpRegisterDerivedStrings(flimflam::kServicesProperty, |
| 52 | &Profile::EnumerateAvailableServices, |
| 53 | NULL); |
Chris Masone | 7df0c67 | 2011-07-15 10:24:54 -0700 | [diff] [blame] | 54 | HelpRegisterDerivedStrings(flimflam::kEntriesProperty, |
| 55 | &Profile::EnumerateEntries, |
| 56 | NULL); |
Chris Masone | 52cd19b | 2011-06-29 17:23:04 -0700 | [diff] [blame] | 57 | } |
| 58 | |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 59 | Profile::~Profile() {} |
Chris Masone | 52cd19b | 2011-06-29 17:23:04 -0700 | [diff] [blame] | 60 | |
Paul Stewart | 5dc40aa | 2011-10-28 19:43:43 -0700 | [diff] [blame] | 61 | bool Profile::InitStorage(GLib *glib, InitStorageOption storage_option, |
| 62 | Error *error) { |
Chris Masone | b9c0059 | 2011-10-06 13:10:39 -0700 | [diff] [blame] | 63 | FilePath final_path; |
| 64 | if (!GetStoragePath(&final_path)) { |
Paul Stewart | be00517 | 2011-11-02 18:10:29 -0700 | [diff] [blame] | 65 | Error::PopulateAndLog(error, Error::kInvalidArguments, |
Chris Masone | b9c0059 | 2011-10-06 13:10:39 -0700 | [diff] [blame] | 66 | base::StringPrintf("Could not set up profile storage for %s:%s", |
Paul Stewart | be00517 | 2011-11-02 18:10:29 -0700 | [diff] [blame] | 67 | name_.user.c_str(), name_.identifier.c_str())); |
Chris Masone | b9c0059 | 2011-10-06 13:10:39 -0700 | [diff] [blame] | 68 | return false; |
| 69 | } |
| 70 | scoped_ptr<KeyFileStore> storage(new KeyFileStore(glib)); |
| 71 | storage->set_path(final_path); |
Paul Stewart | 5dc40aa | 2011-10-28 19:43:43 -0700 | [diff] [blame] | 72 | bool already_exists = storage->IsNonEmpty(); |
| 73 | if (!already_exists && storage_option != kCreateNew && |
| 74 | storage_option != kCreateOrOpenExisting) { |
Paul Stewart | be00517 | 2011-11-02 18:10:29 -0700 | [diff] [blame] | 75 | Error::PopulateAndLog(error, Error::kNotFound, |
Paul Stewart | 5dc40aa | 2011-10-28 19:43:43 -0700 | [diff] [blame] | 76 | base::StringPrintf("Profile storage for %s:%s does not already exist", |
Paul Stewart | be00517 | 2011-11-02 18:10:29 -0700 | [diff] [blame] | 77 | name_.user.c_str(), name_.identifier.c_str())); |
Paul Stewart | 5dc40aa | 2011-10-28 19:43:43 -0700 | [diff] [blame] | 78 | return false; |
| 79 | } else if (already_exists && storage_option != kOpenExisting && |
| 80 | storage_option != kCreateOrOpenExisting) { |
Paul Stewart | be00517 | 2011-11-02 18:10:29 -0700 | [diff] [blame] | 81 | Error::PopulateAndLog(error, Error::kAlreadyExists, |
Paul Stewart | 5dc40aa | 2011-10-28 19:43:43 -0700 | [diff] [blame] | 82 | base::StringPrintf("Profile storage for %s:%s already exists", |
Paul Stewart | be00517 | 2011-11-02 18:10:29 -0700 | [diff] [blame] | 83 | name_.user.c_str(), name_.identifier.c_str())); |
Paul Stewart | 5dc40aa | 2011-10-28 19:43:43 -0700 | [diff] [blame] | 84 | return false; |
| 85 | } |
Chris Masone | b9c0059 | 2011-10-06 13:10:39 -0700 | [diff] [blame] | 86 | if (!storage->Open()) { |
Paul Stewart | be00517 | 2011-11-02 18:10:29 -0700 | [diff] [blame] | 87 | Error::PopulateAndLog(error, Error::kInternalError, |
Chris Masone | b9c0059 | 2011-10-06 13:10:39 -0700 | [diff] [blame] | 88 | base::StringPrintf("Could not open profile storage for %s:%s", |
Paul Stewart | be00517 | 2011-11-02 18:10:29 -0700 | [diff] [blame] | 89 | name_.user.c_str(), name_.identifier.c_str())); |
Paul Stewart | 2ebc16d | 2012-08-23 10:38:39 -0700 | [diff] [blame] | 90 | if (already_exists) { |
| 91 | // The profile contents is corrupt, or we do not have access to |
| 92 | // this file. Move this file out of the way so a future open attempt |
| 93 | // will succeed, assuming the failure reason was the former. |
| 94 | storage->MarkAsCorrupted(); |
| 95 | } |
Chris Masone | b9c0059 | 2011-10-06 13:10:39 -0700 | [diff] [blame] | 96 | return false; |
| 97 | } |
Paul Stewart | 5dc40aa | 2011-10-28 19:43:43 -0700 | [diff] [blame] | 98 | if (!already_exists) { |
| 99 | // Add a descriptive header to the profile so even if nothing is stored |
| 100 | // to it, it still has some content. Completely empty keyfiles are not |
| 101 | // valid for reading. |
| 102 | storage->SetHeader( |
| 103 | base::StringPrintf("Profile %s:%s", name_.user.c_str(), |
| 104 | name_.identifier.c_str())); |
| 105 | } |
Chris Masone | b9c0059 | 2011-10-06 13:10:39 -0700 | [diff] [blame] | 106 | set_storage(storage.release()); |
Paul Stewart | 3c50401 | 2013-01-17 17:49:58 -0800 | [diff] [blame^] | 107 | manager_->OnProfileStorageInitialized(storage_.get()); |
Chris Masone | b9c0059 | 2011-10-06 13:10:39 -0700 | [diff] [blame] | 108 | return true; |
| 109 | } |
| 110 | |
Paul Stewart | e73d05c | 2012-03-29 16:26:05 -0700 | [diff] [blame] | 111 | bool Profile::RemoveStorage(GLib *glib, Error *error) { |
| 112 | FilePath path; |
| 113 | |
| 114 | CHECK(!storage_.get()); |
| 115 | |
| 116 | if (!GetStoragePath(&path)) { |
| 117 | Error::PopulateAndLog( |
| 118 | error, Error::kInvalidArguments, |
| 119 | base::StringPrintf("Could get the storage path for %s:%s", |
| 120 | name_.user.c_str(), name_.identifier.c_str())); |
| 121 | return false; |
| 122 | } |
| 123 | |
| 124 | if (!file_util::Delete(path, false)) { |
| 125 | Error::PopulateAndLog( |
| 126 | error, Error::kOperationFailed, |
| 127 | base::StringPrintf("Could not remove path %s", path.value().c_str())); |
| 128 | return false; |
| 129 | } |
| 130 | |
| 131 | return true; |
| 132 | } |
| 133 | |
Chris Masone | 7df0c67 | 2011-07-15 10:24:54 -0700 | [diff] [blame] | 134 | string Profile::GetFriendlyName() { |
| 135 | return (name_.user.empty() ? "" : name_.user + "/") + name_.identifier; |
| 136 | } |
| 137 | |
| 138 | string Profile::GetRpcIdentifier() { |
Paul Stewart | 19c871d | 2011-12-15 16:10:13 -0800 | [diff] [blame] | 139 | if (!adaptor_.get()) { |
| 140 | // NB: This condition happens in unit tests. |
| 141 | return string(); |
| 142 | } |
Chris Masone | 7df0c67 | 2011-07-15 10:24:54 -0700 | [diff] [blame] | 143 | return adaptor_->GetRpcIdentifier(); |
| 144 | } |
| 145 | |
Chris Masone | b9c0059 | 2011-10-06 13:10:39 -0700 | [diff] [blame] | 146 | void Profile::set_storage(StoreInterface *storage) { |
| 147 | storage_.reset(storage); |
| 148 | } |
| 149 | |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 150 | bool Profile::AdoptService(const ServiceRefPtr &service) { |
Paul Stewart | 451aa7f | 2012-04-11 19:07:58 -0700 | [diff] [blame] | 151 | if (service->profile() == this) { |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 152 | return false; |
Paul Stewart | 451aa7f | 2012-04-11 19:07:58 -0700 | [diff] [blame] | 153 | } |
Philipp Neubeck | 7917360 | 2012-11-13 21:10:09 +0100 | [diff] [blame] | 154 | service->SetProfile(this); |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 155 | return service->Save(storage_.get()) && storage_->Flush(); |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 156 | } |
| 157 | |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 158 | bool Profile::AbandonService(const ServiceRefPtr &service) { |
| 159 | if (service->profile() == this) |
Philipp Neubeck | 7917360 | 2012-11-13 21:10:09 +0100 | [diff] [blame] | 160 | service->SetProfile(NULL); |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 161 | return storage_->DeleteGroup(service->GetStorageIdentifier()) && |
| 162 | storage_->Flush(); |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 163 | } |
| 164 | |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 165 | bool Profile::UpdateService(const ServiceRefPtr &service) { |
| 166 | return service->Save(storage_.get()) && storage_->Flush(); |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 167 | } |
| 168 | |
Paul Stewart | 2c575d2 | 2012-12-07 12:28:57 -0800 | [diff] [blame] | 169 | bool Profile::LoadService(const ServiceRefPtr &service) { |
Paul Stewart | bba6a5b | 2011-11-02 18:45:59 -0700 | [diff] [blame] | 170 | if (!ContainsService(service)) |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 171 | return false; |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 172 | return service->Load(storage_.get()); |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 173 | } |
| 174 | |
Paul Stewart | 2c575d2 | 2012-12-07 12:28:57 -0800 | [diff] [blame] | 175 | bool Profile::ConfigureService(const ServiceRefPtr &service) { |
| 176 | if (!LoadService(service)) |
| 177 | return false; |
| 178 | service->SetProfile(this); |
| 179 | return true; |
| 180 | } |
| 181 | |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 182 | bool Profile::ConfigureDevice(const DeviceRefPtr &device) { |
| 183 | return device->Load(storage_.get()); |
| 184 | } |
| 185 | |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 186 | bool Profile::ContainsService(const ServiceConstRefPtr &service) { |
Paul Stewart | bba6a5b | 2011-11-02 18:45:59 -0700 | [diff] [blame] | 187 | return service->IsLoadableFrom(storage_.get()); |
Chris Masone | 7aa5f90 | 2011-07-11 11:13:35 -0700 | [diff] [blame] | 188 | } |
| 189 | |
Paul Stewart | 7522551 | 2012-01-26 22:51:33 -0800 | [diff] [blame] | 190 | void Profile::DeleteEntry(const std::string &entry_name, Error *error) { |
| 191 | if (!storage_->ContainsGroup(entry_name)) { |
| 192 | Error::PopulateAndLog(error, Error::kNotFound, |
| 193 | base::StringPrintf("Entry %s does not exist in profile", |
| 194 | entry_name.c_str())); |
| 195 | return; |
| 196 | } |
| 197 | if (!manager_->HandleProfileEntryDeletion(this, entry_name)) { |
| 198 | // If HandleProfileEntryDeletion() returns succeeds, DeleteGroup() |
| 199 | // has already been called when AbandonService was called. |
| 200 | // Otherwise, we need to delete the group ourselves. |
| 201 | storage_->DeleteGroup(entry_name); |
| 202 | } |
Paul Stewart | 0756db9 | 2012-01-27 08:34:47 -0800 | [diff] [blame] | 203 | Save(); |
| 204 | } |
| 205 | |
| 206 | ServiceRefPtr Profile::GetServiceFromEntry(const std::string &entry_name, |
| 207 | Error *error) { |
| 208 | return manager_->GetServiceWithStorageIdentifier(this, entry_name, error); |
Paul Stewart | 7522551 | 2012-01-26 22:51:33 -0800 | [diff] [blame] | 209 | } |
| 210 | |
Paul Stewart | a41e38d | 2011-11-11 07:47:29 -0800 | [diff] [blame] | 211 | bool Profile::IsValidIdentifierToken(const string &token) { |
Darin Petkov | a476682 | 2011-07-07 10:42:22 -0700 | [diff] [blame] | 212 | if (token.empty()) { |
| 213 | return false; |
| 214 | } |
| 215 | for (string::const_iterator it = token.begin(); it != token.end(); ++it) { |
| 216 | if (!IsAsciiAlpha(*it) && !IsAsciiDigit(*it)) { |
| 217 | return false; |
| 218 | } |
| 219 | } |
| 220 | return true; |
| 221 | } |
| 222 | |
| 223 | bool Profile::ParseIdentifier(const string &raw, Identifier *parsed) { |
| 224 | if (raw.empty()) { |
| 225 | return false; |
| 226 | } |
| 227 | if (raw[0] == '~') { |
| 228 | // Format: "~user/identifier". |
| 229 | size_t slash = raw.find('/'); |
| 230 | if (slash == string::npos) { |
| 231 | return false; |
| 232 | } |
| 233 | string user(raw.begin() + 1, raw.begin() + slash); |
| 234 | string identifier(raw.begin() + slash + 1, raw.end()); |
| 235 | if (!IsValidIdentifierToken(user) || !IsValidIdentifierToken(identifier)) { |
| 236 | return false; |
| 237 | } |
| 238 | parsed->user = user; |
| 239 | parsed->identifier = identifier; |
| 240 | return true; |
| 241 | } |
| 242 | |
| 243 | // Format: "identifier". |
| 244 | if (!IsValidIdentifierToken(raw)) { |
| 245 | return false; |
| 246 | } |
| 247 | parsed->user = ""; |
| 248 | parsed->identifier = raw; |
| 249 | return true; |
| 250 | } |
| 251 | |
Paul Stewart | 5dc40aa | 2011-10-28 19:43:43 -0700 | [diff] [blame] | 252 | bool Profile::MatchesIdentifier(const Identifier &name) const { |
| 253 | return name.user == name_.user && name.identifier == name_.identifier; |
| 254 | } |
| 255 | |
Chris Masone | b9c0059 | 2011-10-06 13:10:39 -0700 | [diff] [blame] | 256 | bool Profile::Save() { |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 257 | return storage_->Flush(); |
Chris Masone | 9d77993 | 2011-08-25 16:33:41 -0700 | [diff] [blame] | 258 | } |
| 259 | |
Chris Masone | 2ae797d | 2011-08-23 20:41:00 -0700 | [diff] [blame] | 260 | bool Profile::GetStoragePath(FilePath *path) { |
| 261 | if (name_.user.empty()) { |
| 262 | LOG(ERROR) << "Non-default profiles cannot be stored globally."; |
| 263 | return false; |
| 264 | } |
| 265 | FilePath dir(base::StringPrintf(storage_format_.c_str(), name_.user.c_str())); |
Darin Petkov | a476682 | 2011-07-07 10:42:22 -0700 | [diff] [blame] | 266 | // TODO(petkov): Validate the directory permissions, etc. |
| 267 | *path = dir.Append(base::StringPrintf("%s.profile", |
Chris Masone | 2ae797d | 2011-08-23 20:41:00 -0700 | [diff] [blame] | 268 | name_.identifier.c_str())); |
Darin Petkov | a476682 | 2011-07-07 10:42:22 -0700 | [diff] [blame] | 269 | return true; |
| 270 | } |
| 271 | |
Gaurav Shah | 1b7a616 | 2011-11-09 11:41:01 -0800 | [diff] [blame] | 272 | vector<string> Profile::EnumerateAvailableServices(Error *error) { |
Paul Stewart | 1b25314 | 2012-01-26 14:05:52 -0800 | [diff] [blame] | 273 | // We should return the Manager's service list if this is the active profile. |
| 274 | if (manager_->IsActiveProfile(this)) { |
| 275 | return manager_->EnumerateAvailableServices(error); |
| 276 | } else { |
| 277 | return vector<string>(); |
| 278 | } |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 279 | } |
| 280 | |
Gaurav Shah | 1b7a616 | 2011-11-09 11:41:01 -0800 | [diff] [blame] | 281 | vector<string> Profile::EnumerateEntries(Error */*error*/) { |
Chris Masone | 6515aab | 2011-10-12 16:19:09 -0700 | [diff] [blame] | 282 | set<string> groups(storage_->GetGroups()); |
Paul Stewart | 1b25314 | 2012-01-26 14:05:52 -0800 | [diff] [blame] | 283 | vector<string> service_groups; |
| 284 | |
| 285 | // Filter this list down to only entries that correspond |
| 286 | // to a technology. (wifi_*, etc) |
| 287 | for (set<string>::iterator it = groups.begin(); |
| 288 | it != groups.end(); ++it) { |
| 289 | if (Technology::IdentifierFromStorageGroup(*it) != Technology::kUnknown) |
| 290 | service_groups.push_back(*it); |
| 291 | } |
| 292 | |
| 293 | return service_groups; |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 294 | } |
| 295 | |
Darin Petkov | e7c6ad3 | 2012-06-29 10:22:09 +0200 | [diff] [blame] | 296 | bool Profile::UpdateDevice(const DeviceRefPtr &device) { |
| 297 | return false; |
| 298 | } |
| 299 | |
mukesh agrawal | ffa3d04 | 2011-10-06 15:26:10 -0700 | [diff] [blame] | 300 | void Profile::HelpRegisterDerivedStrings( |
| 301 | const string &name, |
Gaurav Shah | 1b7a616 | 2011-11-09 11:41:01 -0800 | [diff] [blame] | 302 | Strings(Profile::*get)(Error *), |
mukesh agrawal | ffa3d04 | 2011-10-06 15:26:10 -0700 | [diff] [blame] | 303 | void(Profile::*set)(const Strings&, Error *)) { |
Chris Masone | 6791a43 | 2011-07-12 13:23:19 -0700 | [diff] [blame] | 304 | store_.RegisterDerivedStrings( |
| 305 | name, |
| 306 | StringsAccessor(new CustomAccessor<Profile, Strings>(this, get, set))); |
| 307 | } |
| 308 | |
Chris Masone | 52cd19b | 2011-06-29 17:23:04 -0700 | [diff] [blame] | 309 | } // namespace shill |