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_DBUS_CONTROL_H_ 18 #define APMANAGER_DBUS_DBUS_CONTROL_H_ 19 20 #include <base/macros.h> 21 #include <brillo/dbus/exported_object_manager.h> 22 #include <dbus/bus.h> 23 24 #include "apmanager/control_interface.h" 25 #include "apmanager/manager.h" 26 27 namespace apmanager { 28 29 // D-Bus control interface for IPC through D-Bus. 30 class DBusControl : public ControlInterface { 31 public: 32 DBusControl(); 33 ~DBusControl() override; 34 35 // Inheritted from ControlInterface. 36 void Init() override; 37 void Shutdown() override; 38 std::unique_ptr<ConfigAdaptorInterface> CreateConfigAdaptor( 39 Config* config, int service_identifier) override; 40 std::unique_ptr<DeviceAdaptorInterface> CreateDeviceAdaptor( 41 Device* device) override; 42 std::unique_ptr<ManagerAdaptorInterface> CreateManagerAdaptor( 43 Manager* manager) override; 44 std::unique_ptr<ServiceAdaptorInterface> CreateServiceAdaptor( 45 Service* device) override; 46 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: 54 // Invoked when D-Bus objects for both ObjectManager and Manager 55 // are registered to the bus. 56 void OnObjectRegistrationCompleted(bool registration_success); 57 58 // 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_; 63 std::unique_ptr<brillo::dbus_utils::ExportedObjectManager> object_manager_; 64 std::unique_ptr<Manager> manager_; 65 66 DISALLOW_COPY_AND_ASSIGN(DBusControl); 67 }; 68 69 } // namespace apmanager 70 71 #endif // APMANAGER_DBUS_DBUS_CONTROL_H_ 72