blob: 0a5a50b3a5ac253fce2a374e3ca7d4c2f84d2bc0 [file] [log] [blame]
Vitaly Bukacad20f02015-10-16 17:27:15 -07001// 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 Buka3ef4fff2015-07-31 01:12:07 -070014
15#ifndef BUFFET_AP_MANAGER_CLIENT_H_
16#define BUFFET_AP_MANAGER_CLIENT_H_
17
18#include <memory>
19#include <string>
20
Alex Vakulenko297114c2015-10-12 13:45:43 -070021#include <apmanager/dbus-proxies.h>
Vitaly Buka3ef4fff2015-07-31 01:12:07 -070022#include <base/callback.h>
23#include <base/memory/ref_counted.h>
24
Vitaly Buka3ef4fff2015-07-31 01:12:07 -070025namespace buffet {
26
27// Manages soft AP for wifi bootstrapping.
28// Once created can handle multiple Start/Stop requests.
29class 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 Vakulenkode94eb52015-12-08 17:11:20 -080042 void OnManagerAdded(
43 org::chromium::apmanager::ManagerProxyInterface* manager_proxy);
44 void OnServiceAdded(
45 org::chromium::apmanager::ServiceProxyInterface* service_proxy);
Vitaly Buka3ef4fff2015-07-31 01:12:07 -070046
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 Vakulenkode94eb52015-12-08 17:11:20 -080056 org::chromium::apmanager::ManagerProxyInterface* manager_proxy_{nullptr};
Vitaly Buka3ef4fff2015-07-31 01:12:07 -070057
58 dbus::ObjectPath service_path_;
Alex Vakulenkode94eb52015-12-08 17:11:20 -080059 org::chromium::apmanager::ServiceProxyInterface* service_proxy_{nullptr};
Vitaly Buka3ef4fff2015-07-31 01:12:07 -070060
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_