shill: Implement get/set of Profile property for Service
Create getter and setter. To set the "Profile" property on a
service we have to ask the manager to take care of finding the
profile by name, and then moving the service to the new profile.
BUG=chromium-os:22803
TEST=New unit test, manual (via list-services on a live system)
Change-Id: Idfb3f9f68764b926ddf06c0cc0285292aa85864d
Reviewed-on: https://gerrit.chromium.org/gerrit/13847
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Reviewed-by: Thieu Le <thieule@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
Commit-Ready: Paul Stewart <pstew@chromium.org>
diff --git a/manager.cc b/manager.cc
index 393c43a..5511376 100644
--- a/manager.cc
+++ b/manager.cc
@@ -321,6 +321,27 @@
from->AbandonService(to_move);
}
+void Manager::SetProfileForService(const ServiceRefPtr &to_set,
+ const string &profile_rpcid,
+ Error *error) {
+ for (vector<ProfileRefPtr>::iterator it = profiles_.begin();
+ it != profiles_.end();
+ ++it) {
+ if (profile_rpcid == (*it)->GetRpcIdentifier()) {
+ if (to_set->profile().get() == it->get()) {
+ Error::PopulateAndLog(error, Error::kInvalidArguments,
+ "Service is already connected to this profile");
+ } else if (!MoveServiceToProfile(to_set, *it)) {
+ Error::PopulateAndLog(error, Error::kInternalError,
+ "Unable to move service to profile");
+ }
+ return;
+ }
+ }
+ Error::PopulateAndLog(error, Error::kInvalidArguments,
+ "Unknown Profile requested for Service");
+}
+
void Manager::RegisterDevice(const DeviceRefPtr &to_manage) {
vector<DeviceRefPtr>::iterator it;
for (it = devices_.begin(); it != devices_.end(); ++it) {