shill: make Connectable property of WiFiService reflect state
of security requirements and available credentials
BUG=chromium-os:23352
TEST=new unittests
Change-Id: I3d98512073d2280a40eee3fd462f592c43df00f3
Reviewed-on: https://gerrit.chromium.org/gerrit/12093
Tested-by: mukesh agrawal <quiche@chromium.org>
Reviewed-by: Gaurav Shah <gauravsh@chromium.org>
Commit-Ready: mukesh agrawal <quiche@chromium.org>
diff --git a/wifi_service.cc b/wifi_service.cc
index a8173a0..b1522cc 100644
--- a/wifi_service.cc
+++ b/wifi_service.cc
@@ -100,6 +100,7 @@
// Until we know better (at Profile load time), use the generic name.
storage_identifier_ = GetGenericStorageIdentifier();
+ UpdateConnectable();
}
WiFiService::~WiFiService() {
@@ -151,6 +152,8 @@
if (error->IsSuccess())
passphrase_ = passphrase;
+
+ UpdateConnectable();
}
bool WiFiService::IsLoadableFrom(StoreInterface *storage) const {
@@ -192,6 +195,9 @@
// Load properties specific to WiFi services.
storage->GetBool(id, kStorageHiddenSSID, &hidden_ssid_);
+
+ // TODO(quiche): Load Passphrase property, ensure that UpdateConnectable
+ // is called (maybe via SetPassphrase). (crosbug.com/23467)
return true;
}
@@ -204,6 +210,8 @@
// Save properties specific to WiFi services.
const string id = GetStorageIdentifier();
storage->SetBool(id, kStorageHiddenSSID, &hidden_ssid_);
+
+ // TODO(quiche): Save Passphrase property. (crosbug.com/23467)
return true;
}
@@ -281,6 +289,21 @@
return wifi_->GetRpcIdentifier();
}
+void WiFiService::UpdateConnectable() {
+ if (security_ == flimflam::kSecurityNone) {
+ DCHECK(passphrase_.empty());
+ set_connectable(true);
+ } else if (security_ == flimflam::kSecurityWep ||
+ security_ == flimflam::kSecurityWpa ||
+ security_ == flimflam::kSecurityPsk ||
+ security_ == flimflam::kSecurityRsn) {
+ set_connectable(!passphrase_.empty());
+ } else {
+ // TODO(quiche): Handle connectability for 802.1x. (crosbug.com/23466)
+ set_connectable(false);
+ }
+}
+
// static
void WiFiService::ValidateWEPPassphrase(const std::string &passphrase,
Error *error) {