Skip to contentSkip to conversation

client: Display address if calling 'disconnect' without arguments

PATCH Superseded Mateusz Lemusisk 2 participants 2 messages Jun 4, 2015 – Jun 5, 2015 Bluetooth drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 client: Display address if calling 'disconnect' without arguments

Before:

[PHILIPS BTM2180]# disconnect
Attempting to disconnect from
Successful disconnected

After:

[PHILIPS BTM2180]# disconnect
Attempting to disconnect from XX:XX:XX:XX:XX:XX
Successful disconnected

---
 client/main.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
client/main.c +13 -1
index 41e95b2..88ae5ed 100644
@@ -1422,7 +1422,19 @@ static void cmd_disconn(const char *arg)
 		return;
 	}
 
-	rl_printf("Attempting to disconnect from %s\n", arg);
+	if (strlen(arg) == 0) {
+		const char *default_address;
+		DBusMessageIter iter;
+
+		if (g_dbus_proxy_get_property(proxy, "Address", &iter) == FALSE)
+			default_address = "";
+		else
+			dbus_message_iter_get_basic(&iter, &default_address);
+
+		rl_printf("Attempting to disconnect from %s\n", default_address);
+	} else {
+		rl_printf("Attempting to disconnect from %s\n", arg);
+	}
 }
 
 static void cmd_list_attributes(const char *arg)
Signature · 1 line
2.4.2
#1 lore raw

Hi Mateusz,

Quoted 29 lines · Mateusz Lemusisk

Before:

[PHILIPS BTM2180]# disconnect
Attempting to disconnect from
Successful disconnected

After:

[PHILIPS BTM2180]# disconnect
Attempting to disconnect from XX:XX:XX:XX:XX:XX
Successful disconnected

---
 client/main.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
client/main.c +4 -1
index 41e95b2..88ae5ed 100644
@@ -1422,7 +1422,19 @@ static void cmd_disconn(const char *arg)
                return;
        }
 
-       rl_printf("Attempting to disconnect from %s\n", arg);
+       if (strlen(arg) == 0) {
+               const char *default_address;
+               DBusMessageIter iter;
+

client/main.c static void cmd_disconn(const char *arg) · line 1438

Quoted 10 lines
client/main.c +9 -0
+               if (g_dbus_proxy_get_property(proxy, "Address", &iter) == FALSE)
+                       default_address = "";
+               else
+                       dbus_message_iter_get_basic(&iter, &default_address);
+
+               rl_printf("Attempting to disconnect from %s\n", default_address);
+       } else {
+               rl_printf("Attempting to disconnect from %s\n", arg);
+       }
 }

Please check the columns limit is 80:
WARNING:LONG_LINE: line over 80 characters
#19: FILE: client/main.c:1434:
+ rl_printf("Attempting to disconnect from %s\n", default_address);

Also there is no need to add braces to single line if/else statements and perhaps you could move rl_printf line out of them and make it common so in case you have an arg you just assign it to address variable, in fact it might be possible to use arg directly.

Quoted 8 lines
client/main.c +0 -1
 static void cmd_list_attributes(const char *arg)
--

2.4.2

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 1 line
Luiz Augusto von Dentz