From 8aee6ecfcc5494f7ad83c5761e04e5b52e08d73c Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Thu, 8 Jun 2017 21:34:23 +0200 Subject: [PATCH] mconnectctl: print capabilities --- src/mconnectctl/main.vala | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/mconnectctl/main.vala b/src/mconnectctl/main.vala index 5946179..371d392 100644 --- a/src/mconnectctl/main.vala +++ b/src/mconnectctl/main.vala @@ -40,6 +40,8 @@ namespace Mconnect { public abstract bool is_paired { owned get;} public abstract bool allowed { owned get;} public abstract bool is_active { owned get;} + public abstract string[] outgoing_capabilities { owned get;} + public abstract string[] incoming_capabilities { owned get;} } public class Client { @@ -186,6 +188,14 @@ namespace Mconnect { }); } + private void print_sorted_caps(string[] caps, string format) { + qsort_with_data(caps, sizeof(string), + (a, b) => GLib.strcmp(a, b)); + foreach (var cap in caps) { + stdout.printf(format, cap); + } + } + private int cmd_show_device(string[] args) { return checked_dbus_call(() => { var dp = get_device(new ObjectPath(args[0])); @@ -205,6 +215,10 @@ namespace Mconnect { dp.allowed.to_string(), dp.is_paired.to_string(), dp.is_active.to_string()); + stdout.printf(" Capabilities (out):\n"); + print_sorted_caps(dp.outgoing_capabilities, " %s\n"); + stdout.printf(" Capabilities (in):\n"); + print_sorted_caps(dp.incoming_capabilities, " %s\n"); return 0; }); }