blob: c12dbfaabc947cb991f456048978a6864ec36d64 [file] [log] [blame]
Peter Qiua522e002015-10-13 13:21:58 -07001//
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
Peter Qiu58083962015-11-05 14:29:50 -080017#ifndef APMANAGER_DBUS_DBUS_CONTROL_H_
18#define APMANAGER_DBUS_DBUS_CONTROL_H_
Peter Qiua522e002015-10-13 13:21:58 -070019
20#include <base/macros.h>
Peter Qiu0d70fa72015-11-12 10:31:40 -080021#include <brillo/dbus/exported_object_manager.h>
Peter Qiua522e002015-10-13 13:21:58 -070022#include <dbus/bus.h>
23
24#include "apmanager/control_interface.h"
Peter Qiu0d70fa72015-11-12 10:31:40 -080025#include "apmanager/manager.h"
Peter Qiua522e002015-10-13 13:21:58 -070026
27namespace apmanager {
28
29// D-Bus control interface for IPC through D-Bus.
30class DBusControl : public ControlInterface {
31 public:
Peter Qiu0d70fa72015-11-12 10:31:40 -080032 DBusControl();
Peter Qiua522e002015-10-13 13:21:58 -070033 ~DBusControl() override;
34
35 // Inheritted from ControlInterface.
Peter Qiu0d70fa72015-11-12 10:31:40 -080036 void Init() override;
37 void Shutdown() override;
Peter Qiu00029782015-11-17 13:45:57 -080038 std::unique_ptr<ConfigAdaptorInterface> CreateConfigAdaptor(
39 Config* config, int service_identifier) override;
Peter Qiuf9335402015-11-16 12:09:16 -080040 std::unique_ptr<DeviceAdaptorInterface> CreateDeviceAdaptor(
41 Device* device) override;
Peter Qiu685dd4a2015-11-21 17:47:49 -080042 std::unique_ptr<ManagerAdaptorInterface> CreateManagerAdaptor(
43 Manager* manager) override;
Peter Qiu0e92d1e2015-11-20 10:11:36 -080044 std::unique_ptr<ServiceAdaptorInterface> CreateServiceAdaptor(
45 Service* device) override;
Peter Qiua522e002015-10-13 13:21:58 -070046 std::unique_ptr<FirewallProxyInterface> CreateFirewallProxy(
47 const base::Closure& service_appeared_callback,
48 const base::Closure& service_vanished_callback) override;
49 std::unique_ptr<ShillProxyInterface> CreateShillProxy(
50 const base::Closure& service_appeared_callback,
51 const base::Closure& service_vanished_callback) override;
52
53 private:
Peter Qiu0d70fa72015-11-12 10:31:40 -080054 // Invoked when D-Bus objects for both ObjectManager and Manager
55 // are registered to the bus.
56 void OnObjectRegistrationCompleted(bool registration_success);
57
Peter Qiua522e002015-10-13 13:21:58 -070058 // NOTE: No dedicated bus is needed for the proxies, since the proxies
59 // being created here doesn't listen for any broadcast signals.
60 // Use a dedicated bus for the proxies if this condition is not true
61 // anymore.
62 scoped_refptr<dbus::Bus> bus_;
Peter Qiu0d70fa72015-11-12 10:31:40 -080063 std::unique_ptr<brillo::dbus_utils::ExportedObjectManager> object_manager_;
64 std::unique_ptr<Manager> manager_;
65
Peter Qiua522e002015-10-13 13:21:58 -070066 DISALLOW_COPY_AND_ASSIGN(DBusControl);
67};
68
69} // namespace apmanager
70
Peter Qiu58083962015-11-05 14:29:50 -080071#endif // APMANAGER_DBUS_DBUS_CONTROL_H_