diff --git a/Makefile.tools b/Makefile.tools
index 6be310e..f53760d 100644
--- a/Makefile.tools
+++ b/Makefile.tools
client_bluetoothctl_SOURCES = $(gdbus_sources) client/main.c \
client/display.h client/display.c \
- client/agent.h client/agent.c
+ client/agent.h client/agent.c \
+ monitor/uuid.h monitor/uuid.c
client_bluetoothctl_LDADD = @GLIB_LIBS@ @DBUS_LIBS@ -lreadline
endif
diff --git a/client/main.c b/client/main.c
index ea83942..b716d95 100644
--- a/client/main.c
+++ b/client/main.c
#include <glib.h>
#include <gdbus.h>
+#include "monitor/uuid.h"
#include "agent.h"
#include "display.h"
print_iter("\t", name, &iter);
}
+static void print_uuids(GDBusProxy *proxy)
+{
+ DBusMessageIter iter, value;
+
+ if (g_dbus_proxy_get_property(proxy, "UUIDs", &iter) == FALSE)
+ return;
+
+ dbus_message_iter_recurse(&iter, &value);
+
+ while (dbus_message_iter_get_arg_type(&value) == DBUS_TYPE_STRING) {
+ const char *uuid, *text;
+
+ dbus_message_iter_get_basic(&value, &uuid);
+
+ text = uuidstr_to_str(uuid);
+ if (text) {
+ char str[26];
+ unsigned int n;
+
+ str[sizeof(str) - 1] = '\0';
+
+ n = snprintf(str, sizeof(str), "%s", text);
+ if (n > sizeof(str) - 1) {
+ str[sizeof(str) - 2] = '.';
+ str[sizeof(str) - 3] = '.';
+ if (str[sizeof(str) - 4] == ' ')
+ str[sizeof(str) - 4] = '.';
+
+ n = sizeof(str) - 1;
+ }
+
+ rl_printf("\tUUID: %s%*c(%s)\n",
+ str, 26 - n, ' ', uuid);
+ } else
+ rl_printf("\tUUID: %*c(%s)\n", 26, ' ', uuid);
+
+ dbus_message_iter_next(&value);
+ }
+}
+
static gboolean device_is_child(GDBusProxy *device, GDBusProxy *master)
{
DBusMessageIter iter;
static void cmd_show(const char *arg)
{
GDBusProxy *proxy;
- DBusMessageIter iter, value;
+ DBusMessageIter iter;
const char *address;
if (!arg || !strlen(arg)) {
print_property(proxy, "Powered");
print_property(proxy, "Discoverable");
print_property(proxy, "Pairable");
-
- if (g_dbus_proxy_get_property(proxy, "UUIDs", &iter) == FALSE)
- goto done;
-
- dbus_message_iter_recurse(&iter, &value);
-
- while (dbus_message_iter_get_arg_type(&value) == DBUS_TYPE_STRING) {
- const char *str;
- dbus_message_iter_get_basic(&value, &str);
- rl_printf("\tUUID: %s\n", str);
- dbus_message_iter_next(&value);
- }
-
-done:
+ print_uuids(proxy);
print_property(proxy, "Discovering");
}
static void cmd_info(const char *arg)
{
GDBusProxy *proxy;
- DBusMessageIter iter, value;
+ DBusMessageIter iter;
const char *address;
if (!arg || !strlen(arg)) {
print_property(proxy, "Blocked");
print_property(proxy, "Connected");
print_property(proxy, "LegacyPairing");
-
- if (g_dbus_proxy_get_property(proxy, "UUIDs", &iter) == FALSE)
- goto done;
-
- dbus_message_iter_recurse(&iter, &value);
-
- while (dbus_message_iter_get_arg_type(&value) == DBUS_TYPE_STRING) {
- const char *str;
- dbus_message_iter_get_basic(&value, &str);
- rl_printf("\tUUID: %s\n", str);
- dbus_message_iter_next(&value);
- }
-
-done:
+ print_uuids(proxy);
print_property(proxy, "VendorSource");
print_property(proxy, "Vendor");
print_property(proxy, "Product");