summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChanwoo Choi <cw00.choi@samsung.com>2018-03-20 16:59:34 +0900
committerChanwoo Choi <cw00.choi@samsung.com>2018-04-05 18:50:49 +0900
commitf770e15a4e52ac4c7b4b6aedcf977a7a32ee1fbd (patch)
tree76d4734314bfc40d8b001995d3d14a9ba83a588f
parentfedc0928b15f6ac1917d9be4186078e1730feb26 (diff)
downloadpass-f770e15a4e52ac4c7b4b6aedcf977a7a32ee1fbd.tar.gz
pass-f770e15a4e52ac4c7b4b6aedcf977a7a32ee1fbd.tar.bz2
pass-f770e15a4e52ac4c7b4b6aedcf977a7a32ee1fbd.zip
core: gdbus: Add new gdbus function to send broadcast signal
Add new following new function in order to send broadcast signal through d-bus interface: - int pass_gdbus_send_broadcast_signal(char *path, char *interface, char *method, GVariant *arg) Change-Id: I4e08a984f234fb4557e94f446e2d0aea86afc768 Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
-rw-r--r--include/pass/gdbus-util.h4
-rw-r--r--src/core/gdbus-util.c39
2 files changed, 43 insertions, 0 deletions
diff --git a/include/pass/gdbus-util.h b/include/pass/gdbus-util.h
index 306e859..f6be0b9 100644
--- a/include/pass/gdbus-util.h
+++ b/include/pass/gdbus-util.h
@@ -19,6 +19,7 @@
#ifndef __GDBUS_UTIL_H__
#define __GDBUS_UTIL_H__
+#include <glib.h>
#include <gio/gio.h>
#include <stdbool.h>
@@ -51,6 +52,9 @@ int pass_gdbus_connect_signal(gpointer instance, int num_signals,
struct pass_gdbus_signal_info *signal_infos);
void pass_gdbus_disconnect_signal(gpointer instance, int num_signals,
struct pass_gdbus_signal_info *signal_infos);
+int pass_gdbus_send_broadcast_signal(char *path, char *interface,
+ char *method, GVariant *arg);
+
SystemPassCore *pass_gdbus_get_instance_core(void);
void pass_gdbus_put_instance_core(SystemPassCore **instance);
SystemPassPmqos *pass_gdbus_get_instance_pmqos(void);
diff --git a/src/core/gdbus-util.c b/src/core/gdbus-util.c
index 42d21b8..6a672db 100644
--- a/src/core/gdbus-util.c
+++ b/src/core/gdbus-util.c
@@ -188,6 +188,45 @@ void pass_gdbus_disconnect_signal(gpointer instance, int num_signals,
}
}
+int pass_gdbus_send_broadcast_signal(char *path, char *interface, char *method,
+ GVariant *arg)
+{
+ GDBusMessage *message = NULL;
+ GError *err = NULL;
+ int ret;
+
+ if (!path || !interface || !method || !arg) {
+ _E("invalid parameter\n");
+ return -EINVAL;
+ }
+
+ if (!g_dbus_sys_conn) {
+ _E("cannot get the dbus connection to system message bus\n");
+ return -ENOSYS;
+ }
+
+ /* Make the dbus message to send broadcast signal */
+ message = g_dbus_message_new_signal(path, interface, method);
+ if (!message) {
+ _E("failed to allocate new %s.%s signal", interface, method);
+ return -EPERM;
+ }
+ g_dbus_message_set_body(message, arg);
+
+ /* Send broadcast signal */
+ ret = g_dbus_connection_send_message(g_dbus_sys_conn, message,
+ G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, &err);
+ if (!ret) {
+ _E("failed to broadcast [%s][%d]", method, arg);
+ g_object_unref(message);
+ return -ECOMM;
+ }
+
+ g_object_unref(message);
+
+ return 0;
+}
+
static void put_instance(gpointer *instance)
{
g_object_unref(*instance);