• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (C) 2015 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_DBUS_SHILL_DBUS_PROXY_H_
18 #define APMANAGER_DBUS_SHILL_DBUS_PROXY_H_
19 
20 #include <string>
21 
22 #include <base/macros.h>
23 #include <shill/dbus-proxies.h>
24 
25 #include "apmanager/shill_proxy_interface.h"
26 
27 namespace apmanager {
28 
29 class EventDispatcher;
30 
31 class ShillDBusProxy : public ShillProxyInterface {
32  public:
33   ShillDBusProxy(const scoped_refptr<dbus::Bus>& bus,
34                  const base::Closure& service_appeared_callback,
35                  const base::Closure& service_vanished_callback);
36   ~ShillDBusProxy() override;
37 
38   // Implementation of ShillProxyInterface.
39   bool ClaimInterface(const std::string& interface_name) override;
40   bool ReleaseInterface(const std::string& interface_name) override;
41 #if defined(__BRILLO__)
42   bool SetupApModeInterface(std::string* interface_name) override;
43   bool SetupStationModeInterface(std::string* interface_name) override;
44 #endif  // __BRILLO__
45 
46  private:
47   void OnServiceAvailable(bool service_available);
48   void OnServiceOwnerChanged(const std::string& old_owner,
49                              const std::string& new_owner);
50 
51   // DBus proxy for shill's manager interface.
52   std::unique_ptr<org::chromium::flimflam::ManagerProxy> manager_proxy_;
53   EventDispatcher* dispatcher_;
54   base::Closure service_appeared_callback_;
55   base::Closure service_vanished_callback_;
56   bool service_available_;
57 
58   base::WeakPtrFactory<ShillDBusProxy> weak_factory_{this};
59   DISALLOW_COPY_AND_ASSIGN(ShillDBusProxy);
60 };
61 
62 }  // namespace apmanager
63 
64 #endif  // APMANAGER_DBUS_SHILL_DBUS_PROXY_H_
65