• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include <brillo/brillo_export.h>
9 #include <brillo/glib/dbus.h>
10 
11 namespace brillo {
12 
13 // \precondition No functions in the dbus namespace can be called before
14 // ::g_type_init();
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