shill: Implement DeleteEntry Profile method
Implement the DeleteEntry DBus method call, which removes
a Profile entry as well as detaching any connected services
from the profile data. As a bonus change, modify Manager to
consolidate finding a Profile that is suitable for a Service
which does not have one.
BUG=chromium-os:25542
TEST=New unit tests
Change-Id: I6a954a41ab2d1b49f6432858e2263a63b5af21f1
Reviewed-on: https://gerrit.chromium.org/gerrit/14944
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Commit-Ready: Paul Stewart <pstew@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
diff --git a/profile.cc b/profile.cc
index 8ff5ff0..fba86df 100644
--- a/profile.cc
+++ b/profile.cc
@@ -149,6 +149,21 @@
return service->IsLoadableFrom(storage_.get());
}
+void Profile::DeleteEntry(const std::string &entry_name, Error *error) {
+ if (!storage_->ContainsGroup(entry_name)) {
+ Error::PopulateAndLog(error, Error::kNotFound,
+ base::StringPrintf("Entry %s does not exist in profile",
+ entry_name.c_str()));
+ return;
+ }
+ if (!manager_->HandleProfileEntryDeletion(this, entry_name)) {
+ // If HandleProfileEntryDeletion() returns succeeds, DeleteGroup()
+ // has already been called when AbandonService was called.
+ // Otherwise, we need to delete the group ourselves.
+ storage_->DeleteGroup(entry_name);
+ }
+}
+
bool Profile::IsValidIdentifierToken(const string &token) {
if (token.empty()) {
return false;