return 0;
}
+int dbus_handle_method_sync_pairs(const char *dest,
+ const char *path,
+ const char *iface,
+ const char *method,
+ int num,
+ va_list args)
+{
+ GError *err = NULL;
+ GVariant * reply = NULL;
+ char *key, *value;
+ int ret = 0;
+ GVariant *var;
+ GVariantBuilder *builder;
+ dbus_handle_s *dh = NULL;
+
+ if (!dest || !path || !iface || !method) {
+ _E("wrong parameters dest(%s) path(%s) iface(%s) method(%s)", dest, path, iface, method);
+ return -1;
+ }
+
+ 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;
+ }
+
+ builder = g_variant_builder_new(G_VARIANT_TYPE("a{ss}"));
+
+ for (int i = 0 ; i < num ; i = i + 2) {
+ key = va_arg(args, char *);
+ value = va_arg(args, char *);
+ _I("key(%s), value(%s)", key, value);
+ g_variant_builder_add(builder, "{ss}", key, value);
+ }
+
+ var = g_variant_new("(a{ss})", builder);
+ g_variant_builder_unref(builder);
+
+ reply = g_dbus_connection_call_sync(dh->conn,
+ dest, path, iface, method,
+ var, NULL, G_DBUS_CALL_FLAGS_NONE, DBUS_REPLY_TIMEOUT, NULL, &err);
+ if (!reply || err) {
+ _E("failed to g_dbus_connection_call_sync");
+ return -1;
+ }
+
+ if (g_strcmp0("(i)", g_variant_get_type_string(reply)) == 0)
+ g_variant_get(reply, "(i)", &ret);
+ else
+ ret = -ENOMSG;
+
+ g_variant_unref(reply);
+
+ return ret;
+}
+
+int dbus_handle_method_async_pairs(const char *dest,
+ const char *path,
+ const char *iface,
+ const char *method,
+ int num,
+ va_list args)
+{
+ char *key, *value;
+ GVariant *var;
+ GVariantBuilder *builder;
+ dbus_handle_s *dh = NULL;
+
+ if (!dest || !path || !iface || !method) {
+ _E("wrong parameters dest(%s) path(%s) iface(%s) method(%s)", dest, path, iface, method);
+ return -1;
+ }
+
+ 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;
+ }
+
+ // dict
+ builder = g_variant_builder_new(G_VARIANT_TYPE("a{ss}"));
+
+ for (int i = 0 ; i < num ; i = i + 2) {
+ key = va_arg(args, char *);
+ value = va_arg(args, char *);
+ _I("key(%s), value(%s)", key, value);
+ g_variant_builder_add(builder, "{ss}", key, value);
+ }
+
+ var = g_variant_new("(a{ss})", builder);
+ g_variant_builder_unref(builder);
+
+ g_dbus_connection_call(dh->conn,
+ dest, path, iface, method,
+ var, NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ NULL,
+ NULL);
+
+ return 0;
+}
+
gint* dbus_handle_get_unix_fd_list(GDBusMethodInvocation *invocation, int *size)
{
GUnixFDList *fd_list = NULL;
return ret;
}
+int dbus_handle_method_async_pairs_with_reply(const char *dest,
+ const char *path,
+ const char *iface,
+ const char *method,
+ int num,
+ va_list args,
+ dbus_pending_cb cb,
+ int timeout_msec,
+ void *data)
+{
+ dbus_handle_s *dh = NULL;
+ pending_call_data *pdata = NULL;
+ GVariantBuilder *builder;
+ char *key, *value;
+ GVariant *param;
+ int ret = 0;
+
+ if (!dest || !path || !iface || !method) {
+ _E("wrong parameters dest(%s) path(%s) iface(%s) method(%s)", dest, path, iface, method);
+ return -1;
+ }
+
+ if (timeout_msec < -1) {
+ _E("wrong timeout %d", timeout_msec);
+ return -1;
+ }
+
+ dh = _dbus_handle_get_default_connection();
+ if (!dh) {
+ _E("failed to get default connection, bustype:%d", (int)dbus_handle_get_default_bus_type());
+ return -EPERM;
+ }
+
+ // dict
+ builder = g_variant_builder_new(G_VARIANT_TYPE("a{ss}"));
+
+ for (int i = 0 ; i < num ; i = i + 2) {
+ key = va_arg(args, char *);
+ value = va_arg(args, char *);
+ _I("key(%s), value(%s)", key, value);
+ g_variant_builder_add(builder, "{ss}", key, value);
+ }
+
+ param = g_variant_new("(a{ss})", builder);
+ g_variant_builder_unref(builder);
+
+ if (cb) {
+ pdata = (pending_call_data*)malloc(sizeof(pending_call_data));
+ if (!pdata) {
+ ret = -ENOMEM;
+ goto err;
+ }
+
+ pdata->func = cb;
+ pdata->data = data;
+ }
+ g_dbus_connection_call(dh->conn,
+ dest, path, iface, method,
+ param, NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ timeout_msec,
+ NULL,
+ (GAsyncReadyCallback)_cb_pending,
+ pdata);
+
+ return ret;
+err:
+ if (param)
+ g_variant_unref(param);
+ return ret;
+}
+
int dbus_connection_get_sender_pid(GDBusConnection *conn, const char * sender)
{
GError *err = NULL;