summaryrefslogtreecommitdiff
path: root/brillo/glib/abstract_dbus_service.h
blob: c40b6587ecdaac0b828b6803278f5a42788ef0bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef LIBBRILLO_BRILLO_GLIB_ABSTRACT_DBUS_SERVICE_H_
#define LIBBRILLO_BRILLO_GLIB_ABSTRACT_DBUS_SERVICE_H_

#include <brillo/brillo_export.h>
#include <brillo/glib/dbus.h>

namespace brillo {

// \precondition No functions in the dbus namespace can be called before
// ::g_type_init();

namespace dbus {
class BRILLO_EXPORT AbstractDbusService {
 public:
  virtual ~AbstractDbusService() {}

  // Setup the wrapped GObject and the GMainLoop
  virtual bool Initialize() = 0;
  virtual bool Reset() = 0;

  // Registers the GObject as a service with the system DBus
  // TODO(wad) make this testable by making BusConn and Proxy
  //           subclassing friendly.
  virtual bool Register(const brillo::dbus::BusConnection& conn);

  // Starts the run loop
  virtual bool Run();

  // Stops the run loop
  virtual bool Shutdown();

  // Used internally during registration to set the
  // proper service information.
  virtual const char* service_name() const = 0;
  virtual const char* service_path() const = 0;
  virtual const char* service_interface() const = 0;
  virtual GObject* service_object() const = 0;

 protected:
  virtual GMainLoop* main_loop() = 0;
};

}  // namespace dbus
}  // namespace brillo

#endif  // LIBBRILLO_BRILLO_GLIB_ABSTRACT_DBUS_SERVICE_H_