1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef LIBBRILLO_BRILLO_GLIB_ABSTRACT_DBUS_SERVICE_H_ 6 #define LIBBRILLO_BRILLO_GLIB_ABSTRACT_DBUS_SERVICE_H_ 7 8 // IMPORTANT: Do not use this in new code. Instead, use 9 // <brillo/daemons/dbus_daemon.h>. See https://goo.gl/EH3MmR for more details. 10 11 #include <brillo/brillo_export.h> 12 #include <brillo/glib/dbus.h> 13 14 namespace brillo { 15 16 namespace dbus { 17 class BRILLO_EXPORT AbstractDbusService { 18 public: ~AbstractDbusService()19 virtual ~AbstractDbusService() {} 20 21 // Setup the wrapped GObject and the GMainLoop 22 virtual bool Initialize() = 0; 23 virtual bool Reset() = 0; 24 25 // Registers the GObject as a service with the system DBus 26 // TODO(wad) make this testable by making BusConn and Proxy 27 // subclassing friendly. 28 virtual bool Register(const brillo::dbus::BusConnection& conn); 29 30 // Starts the run loop 31 virtual bool Run(); 32 33 // Stops the run loop 34 virtual bool Shutdown(); 35 36 // Used internally during registration to set the 37 // proper service information. 38 virtual const char* service_name() const = 0; 39 virtual const char* service_path() const = 0; 40 virtual const char* service_interface() const = 0; 41 virtual GObject* service_object() const = 0; 42 43 protected: 44 virtual GMainLoop* main_loop() = 0; 45 }; 46 47 } // namespace dbus 48 } // namespace brillo 49 50 #endif // LIBBRILLO_BRILLO_GLIB_ABSTRACT_DBUS_SERVICE_H_ 51