From: Chanwoo Choi Date: Tue, 20 Mar 2018 07:59:34 +0000 (+0900) Subject: core: gdbus: Add new gdbus function to send broadcast signal X-Git-Tag: submit/tizen/20180409.024353~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f770e15a4e52ac4c7b4b6aedcf977a7a32ee1fbd;p=platform%2Fcore%2Fsystem%2Fpass.git 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 --- 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 #include #include @@ -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);