diff options
-rw-r--r-- | src/libgdbus/dbus-system.c | 56 | ||||
-rw-r--r-- | src/libgdbus/dbus-system.h | 8 |
2 files changed, 63 insertions, 1 deletions
diff --git a/src/libgdbus/dbus-system.c b/src/libgdbus/dbus-system.c index f57f147..93b42db 100644 --- a/src/libgdbus/dbus-system.c +++ b/src/libgdbus/dbus-system.c @@ -1768,7 +1768,61 @@ int dbus_handle_emit_dbus_signal(const char *dest, ret = g_dbus_connection_emit_signal(dh->conn, dest, path, iface, name, param, &err); if (err) { - _E("%d %s\n", ret, err ? err->message : NULL); + _E("%d %s\n", ret, err ? err->message : "NULL"); + g_error_free(err); + } + + return ret; +} + +int dbus_handle_emit_dbus_signal_sync(const char *dest, + const char *path, + const char *iface, + const char *name, + GVariant *param) +{ + dbus_handle_s *dh = NULL; + GError *err = NULL; + gboolean ret = 0; + + dh = _dbus_handle_get_default_connection(); + if (!dh) { + _E("failed to get default connection, bustype:%d", (int)dbus_handle_get_default_bus_type()); + return -1; + } + + ret = g_dbus_connection_emit_signal(dh->conn, dest, path, iface, name, param, &err); + if (!ret) { + _E("%d %s\n", ret, err ? err->message : "NULL"); + g_error_free(err); + } + + ret = g_dbus_connection_flush_sync(dh->conn, NULL, &err); + if (!ret) { + _E("%d %s\n", ret, err ? err->message : "NULL"); + g_error_free(err); + } + + return ret; +} + +int dbus_handle_flush_sync(dbus_handle_h handle) +{ + dcl_dbus_handle(); + GError *err = NULL; + gboolean ret = 0; + + if (!dh) { + dh = _dbus_handle_get_default_connection(); + if (!dh) { + _E("failed to get default connection, bustype:%d", (int)dbus_handle_get_default_bus_type()); + return 0; + } + } + + ret = g_dbus_connection_flush_sync(dh->conn, NULL, &err); + if (!ret) { + _E("%d %s\n", ret, err ? err->message : "NULL"); g_error_free(err); } diff --git a/src/libgdbus/dbus-system.h b/src/libgdbus/dbus-system.h index 490419b..faf5e02 100644 --- a/src/libgdbus/dbus-system.h +++ b/src/libgdbus/dbus-system.h @@ -233,6 +233,14 @@ int dbus_handle_emit_dbus_signal (const char *dest, const char *name, GVariant *param); +int dbus_handle_emit_dbus_signal_sync(const char *dest, + const char *path, + const char *iface, + const char *name, + GVariant *param); + +int dbus_handle_flush_sync(dbus_handle_h handle); + enum ctx_quit_reason {CTX_QUIT_UNKNOWN, CTX_QUIT_NORMAL, CTX_QUIT_TIMEOUT}; typedef struct { |