Fix crash when invalid parameter given
[platform/core/api/capability-manager.git] / src / dbus_signal.h
1 // Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by a apache 2.0 license that can be
3 // found in the LICENSE file.
4
5 #ifndef DBUS_SIGNAL_H_
6 #define DBUS_SIGNAL_H_
7
8 #include <glib.h>
9 #include <gio/gio.h>
10
11 #include <string>
12
13 #include "src/dbus.h"
14
15 namespace capmgr {
16
17 class DBusSignal {
18  public:
19     explicit DBusSignal(const std::string& signal_name);
20     ~DBusSignal();
21     void RegisterHandler(DBusCallback cb, void* user_data);
22     bool Subscribe();
23     const char* GetSignalName();
24     void Emit(GVariant* param);
25
26  private:
27     std::string signal_name_;
28     DBusCallback cb_;
29     void* user_data_;
30     GDBusProxy* proxy_;
31     GDBusConnection* conn_;
32 };
33
34 }  // namespace capmgr
35
36 #endif  // DBUS_SIGNAL_H_