summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Kümmel <syntheticpp@gmx.net>2015-09-08 18:11:22 +0200
committerPeter Kümmel <syntheticpp@gmx.net>2015-09-08 18:24:36 +0200
commitda4e1004a998416991536172b51f74b89d0b2b00 (patch)
treea9e23b073ff160bf9d61c97e9b3c250db14a4eb9
parentbe13fc774cfab83b25273b83610b5b8d58fe6955 (diff)
downloadbluez-tools-da4e1004a998416991536172b51f74b89d0b2b00.tar.gz
dbus needs a tuple of variants
-rw-r--r--src/lib/agent-helper.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/src/lib/agent-helper.c b/src/lib/agent-helper.c
index 053ee31..a4d1a04 100644
--- a/src/lib/agent-helper.c
+++ b/src/lib/agent-helper.c
@@ -241,6 +241,7 @@ static void _bt_agent_method_call_func(GDBusConnection *connection, const gchar
Device *device_obj = device_new(g_variant_get_string(g_variant_get_child_value(parameters, 0), NULL));
const gchar *pin = _find_device_pin(device_get_dbus_object_path(device_obj));
guint32 ret = 0;
+ gboolean invoke = FALSE;
if (_interactive)
g_print("Device: %s (%s)\n", device_get_alias(device_obj, &error), device_get_address(device_obj, &error));
@@ -259,8 +260,7 @@ static void _bt_agent_method_call_func(GDBusConnection *connection, const gchar
if (_interactive)
g_print("Passkey found\n");
sscanf(pin, "%u", &ret);
- g_dbus_method_invocation_return_value(invocation, g_variant_new_uint32(ret));
- return;
+ invoke = TRUE;
}
else if (_interactive)
{
@@ -268,11 +268,19 @@ static void _bt_agent_method_call_func(GDBusConnection *connection, const gchar
errno = 0;
if (scanf("%u", &ret) == EOF && errno)
g_warning("%s\n", strerror(errno));
- g_dbus_method_invocation_return_value(invocation, g_variant_new_uint32(ret));
- return;
+ invoke = TRUE;
}
- g_dbus_method_invocation_return_dbus_error(invocation, "org.bluez.Error.Rejected", "No passkey inputted");
+ if (invoke)
+ {
+ GVariant* vars[1];
+ vars[0] = g_variant_new_uint32(ret);
+ g_dbus_method_invocation_return_value(invocation, g_variant_new_tuple(vars, 1));
+ }
+ else
+ {
+ g_dbus_method_invocation_return_dbus_error(invocation, "org.bluez.Error.Rejected", "No passkey inputted");
+ }
}
else if (g_strcmp0(method_name, "RequestPinCode") == 0)
{
@@ -280,6 +288,7 @@ static void _bt_agent_method_call_func(GDBusConnection *connection, const gchar
Device *device_obj = device_new(g_variant_get_string(g_variant_get_child_value(parameters, 0), NULL));
const gchar *pin = _find_device_pin(device_get_dbus_object_path(device_obj));
const gchar ret[16];
+ gboolean invoke = FALSE;
if (_interactive)
g_print("Device: %s (%s)\n", device_get_alias(device_obj, &error), device_get_address(device_obj, &error));
@@ -298,8 +307,7 @@ static void _bt_agent_method_call_func(GDBusConnection *connection, const gchar
if (_interactive)
g_print("Passkey found\n");
sscanf(pin, "%s", &ret);
- g_dbus_method_invocation_return_value(invocation, g_variant_new_string(ret));
- return;
+ invoke = TRUE;
}
else if (_interactive)
{
@@ -307,13 +315,19 @@ static void _bt_agent_method_call_func(GDBusConnection *connection, const gchar
errno = 0;
if (scanf("%s", &ret) == EOF && errno)
g_warning("%s\n", strerror(errno));
+ invoke = TRUE;
+ }
+
+ if (invoke)
+ {
GVariant* vars[1];
vars[0] = g_variant_new_string(ret);
g_dbus_method_invocation_return_value(invocation, g_variant_new_tuple(vars, 1));
- return;
}
-
- g_dbus_method_invocation_return_dbus_error(invocation, "org.bluez.Error.Rejected", "No passkey inputted");
+ else
+ {
+ g_dbus_method_invocation_return_dbus_error(invocation, "org.bluez.Error.Rejected", "No passkey inputted");
+ }
}
}