Vitaly Buka | cad20f0 | 2015-10-16 17:27:15 -0700 | [diff] [blame] | 1 | // Copyright 2015 The Android Open Source Project |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
Vitaly Buka | 3ef4fff | 2015-07-31 01:12:07 -0700 | [diff] [blame] | 14 | |
| 15 | #ifndef BUFFET_AP_MANAGER_CLIENT_H_ |
| 16 | #define BUFFET_AP_MANAGER_CLIENT_H_ |
| 17 | |
| 18 | #include <memory> |
| 19 | #include <string> |
| 20 | |
Alex Vakulenko | 297114c | 2015-10-12 13:45:43 -0700 | [diff] [blame] | 21 | #include <apmanager/dbus-proxies.h> |
Vitaly Buka | 3ef4fff | 2015-07-31 01:12:07 -0700 | [diff] [blame] | 22 | #include <base/callback.h> |
| 23 | #include <base/memory/ref_counted.h> |
| 24 | |
Vitaly Buka | 3ef4fff | 2015-07-31 01:12:07 -0700 | [diff] [blame] | 25 | namespace buffet { |
| 26 | |
| 27 | // Manages soft AP for wifi bootstrapping. |
| 28 | // Once created can handle multiple Start/Stop requests. |
| 29 | class ApManagerClient final { |
| 30 | public: |
| 31 | explicit ApManagerClient(const scoped_refptr<dbus::Bus>& bus); |
| 32 | ~ApManagerClient(); |
| 33 | |
| 34 | void Start(const std::string& ssid); |
| 35 | void Stop(); |
| 36 | |
| 37 | std::string GetSsid() const { return ssid_; } |
| 38 | |
| 39 | private: |
| 40 | void RemoveService(const dbus::ObjectPath& object_path); |
| 41 | |
Alex Vakulenko | de94eb5 | 2015-12-08 17:11:20 -0800 | [diff] [blame] | 42 | void OnManagerAdded( |
| 43 | org::chromium::apmanager::ManagerProxyInterface* manager_proxy); |
| 44 | void OnServiceAdded( |
| 45 | org::chromium::apmanager::ServiceProxyInterface* service_proxy); |
Vitaly Buka | 3ef4fff | 2015-07-31 01:12:07 -0700 | [diff] [blame] | 46 | |
| 47 | void OnSsidSet(bool success); |
| 48 | |
| 49 | void OnServiceRemoved(const dbus::ObjectPath& object_path); |
| 50 | void OnManagerRemoved(const dbus::ObjectPath& object_path); |
| 51 | |
| 52 | scoped_refptr<dbus::Bus> bus_; |
| 53 | |
| 54 | std::unique_ptr<org::chromium::apmanager::ObjectManagerProxy> |
| 55 | object_manager_proxy_; |
Alex Vakulenko | de94eb5 | 2015-12-08 17:11:20 -0800 | [diff] [blame] | 56 | org::chromium::apmanager::ManagerProxyInterface* manager_proxy_{nullptr}; |
Vitaly Buka | 3ef4fff | 2015-07-31 01:12:07 -0700 | [diff] [blame] | 57 | |
| 58 | dbus::ObjectPath service_path_; |
Alex Vakulenko | de94eb5 | 2015-12-08 17:11:20 -0800 | [diff] [blame] | 59 | org::chromium::apmanager::ServiceProxyInterface* service_proxy_{nullptr}; |
Vitaly Buka | 3ef4fff | 2015-07-31 01:12:07 -0700 | [diff] [blame] | 60 | |
| 61 | std::string ssid_; |
| 62 | |
| 63 | base::WeakPtrFactory<ApManagerClient> weak_ptr_factory_{this}; |
| 64 | }; |
| 65 | |
| 66 | } // namespace buffet |
| 67 | |
| 68 | #endif // BUFFET_AP_MANAGER_CLIENT_H_ |