1 //
2 // Copyright (C) 2014 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 #ifndef APMANAGER_SHILL_MANAGER_H_
18 #define APMANAGER_SHILL_MANAGER_H_
19 
20 #include <set>
21 #include <string>
22 
23 #include <base/macros.h>
24 #include <base/memory/weak_ptr.h>
25 
26 #include "apmanager/shill_proxy_interface.h"
27 
28 namespace apmanager {
29 
30 class ControlInterface;
31 
32 class ShillManager {
33  public:
34   ShillManager();
35   virtual ~ShillManager();
36 
37   void Init(ControlInterface* control_interface);
38 
39   // Claim the given interface |interface_name| from shill.
40   virtual void ClaimInterface(const std::string& interface_name);
41   // Release the given interface |interface_name| to shill.
42   virtual void ReleaseInterface(const std::string& interface_name);
43 #if defined(__BRILLO__)
44   // Setup an AP mode interface.
45   virtual bool SetupApModeInterface(std::string* interface_name);
46   // Setup a station mode interface.
47   virtual bool SetupStationModeInterface(std::string* interface_name);
48 #endif  // __BRILLO__
49 
50  private:
51   void OnShillServiceAppeared();
52   void OnShillServiceVanished();
53 
54   std::unique_ptr<ShillProxyInterface> shill_proxy_;
55   // List of interfaces apmanager have claimed.
56   std::set<std::string> claimed_interfaces_;
57 
58   base::WeakPtrFactory<ShillManager> weak_factory_{this};
59   DISALLOW_COPY_AND_ASSIGN(ShillManager);
60 };
61 
62 }  // namespace apmanager
63 
64 #endif  // APMANAGER_SHILL_MANAGER_H_
65