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