#ifndef __GDBUS_UTIL_H__
#define __GDBUS_UTIL_H__
+#include <glib.h>
#include <gio/gio.h>
#include <stdbool.h>
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);
}
}
+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);