1 //
2 // Copyright (C) 2013 The Android Open Source Project
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 #include "shill/ethernet/ethernet_eap_service.h"
18
19 #include <string>
20
21 #include <base/strings/stringprintf.h>
22
23 #include "shill/eap_credentials.h"
24 #include "shill/ethernet/ethernet_eap_provider.h"
25 #include "shill/manager.h"
26 #include "shill/technology.h"
27
28 using std::string;
29
30 namespace shill {
31
EthernetEapService(ControlInterface * control_interface,EventDispatcher * dispatcher,Metrics * metrics,Manager * manager)32 EthernetEapService::EthernetEapService(ControlInterface* control_interface,
33 EventDispatcher* dispatcher,
34 Metrics* metrics,
35 Manager* manager)
36 : Service(control_interface, dispatcher, metrics, manager,
37 Technology::kEthernetEap) {
38 SetEapCredentials(new EapCredentials());
39 set_friendly_name("Ethernet EAP Parameters");
40 }
41
~EthernetEapService()42 EthernetEapService::~EthernetEapService() {}
43
GetStorageIdentifier() const44 string EthernetEapService::GetStorageIdentifier() const {
45 return base::StringPrintf(
46 "%s_all", Technology::NameFromIdentifier(technology()).c_str());
47 }
48
GetDeviceRpcId(Error *) const49 string EthernetEapService::GetDeviceRpcId(Error* /*error*/) const {
50 return "/";
51 }
52
OnEapCredentialsChanged(Service::UpdateCredentialsReason reason)53 void EthernetEapService::OnEapCredentialsChanged(
54 Service::UpdateCredentialsReason reason) {
55 if (reason == Service::kReasonPropertyUpdate) {
56 // Although the has_ever_connected_ field is not used in the
57 // same manner as the other services, we still make this call
58 // to maintain consistent behavior by the EAP Credential Change
59 // call.
60 SetHasEverConnected(false);
61 }
62 manager()->ethernet_eap_provider()->OnCredentialsChanged();
63 }
64
Unload()65 bool EthernetEapService::Unload() {
66 Service::Unload();
67 manager()->ethernet_eap_provider()->OnCredentialsChanged();
68 return false;
69 }
70
71 } // namespace shill
72