summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Orlenko <zxteam@gmail.com>2010-07-14 16:54:51 +1100
committerAlexander Orlenko <zxteam@gmail.com>2010-07-14 16:54:51 +1100
commit981f309514b9bf83b7adac94b7e5949264ad533b (patch)
tree6a792a9480104ada67a38687d28e6c9302846c62
parent4983869a78233a6bd04e4327db904569dd5cf613 (diff)
downloadbluez-tools-981f309514b9bf83b7adac94b7e5949264ad533b.tar.gz
Fixed summary && description messages
Added checking of interface existence to audio/input/network/serial tools
-rw-r--r--src/Makefile.am2
-rw-r--r--src/bt-adapter.c10
-rw-r--r--src/bt-agent.c6
-rw-r--r--src/bt-audio.c15
-rw-r--r--src/bt-device.c35
-rw-r--r--src/bt-monitor.c6
-rw-r--r--src/bt-network.c32
-rw-r--r--src/bt-serial.c15
8 files changed, 75 insertions, 46 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 297f674..c295af2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -45,4 +45,4 @@ bt_network_SOURCES = $(lib_sources) bt-network.c
bt_serial_SOURCES = $(lib_sources) bt-serial.c
#CLEANFILES = Makefile.in lib/marshallers.c lib/marshallers.h
-
+CLEANFILES = $(top_srcdir)/.version
diff --git a/src/bt-adapter.c b/src/bt-adapter.c
index 64d642a..907554a 100644
--- a/src/bt-adapter.c
+++ b/src/bt-adapter.c
@@ -41,6 +41,8 @@ static void adapter_device_found(Adapter *adapter, const gchar *address, GHashTa
if (g_hash_table_size(found_devices) == 0) g_print("\n");
+ // TODO: Translate class of adapter ?
+
g_print("[%s]\n", address);
g_print(" Name: %s\n", g_value_get_string(g_hash_table_lookup(values, "Name")));
g_print(" Alias: %s\n", g_value_get_string(g_hash_table_lookup(values, "Alias")));
@@ -80,10 +82,10 @@ static gchar *set_value_arg = NULL;
static GOptionEntry entries[] = {
{"list", 'l', 0, G_OPTION_ARG_NONE, &list_arg, "List all available adapters", NULL},
- {"adapter", 'a', 0, G_OPTION_ARG_STRING, &adapter_arg, "Adapter name or MAC", "adapter#id"},
+ {"adapter", 'a', 0, G_OPTION_ARG_STRING, &adapter_arg, "Adapter name or MAC", "<name|mac>"},
{"info", 'i', 0, G_OPTION_ARG_NONE, &info_arg, "Show adapter info", NULL},
{"discover", 'd', 0, G_OPTION_ARG_NONE, &discover_arg, "Discover remote devices", NULL},
- {"set", 0, 0, G_OPTION_ARG_NONE, &set_arg, "Set property", NULL},
+ {"set", 0, 0, G_OPTION_ARG_NONE, &set_arg, "Set adapter property", NULL},
{NULL}
};
@@ -96,7 +98,7 @@ int main(int argc, char *argv[])
context = g_option_context_new("- a bluetooth adapter manager");
g_option_context_add_main_entries(context, entries, NULL);
- g_option_context_set_summary(context, "adapter summary");
+ g_option_context_set_summary(context, "Version "PACKAGE_VERSION);
g_option_context_set_description(context,
"Set Options:\n"
" --set <property> <value>\n"
@@ -107,7 +109,7 @@ int main(int argc, char *argv[])
" Pairable\n"
" PairableTimeout\n"
" Powered\n\n"
- "adapter desc"
+ "Report bugs to <"PACKAGE_BUGREPORT">."
);
if (!g_option_context_parse(context, &argc, &argv, &error)) {
diff --git a/src/bt-agent.c b/src/bt-agent.c
index 1d23d93..e8656b6 100644
--- a/src/bt-agent.c
+++ b/src/bt-agent.c
@@ -33,7 +33,7 @@
static gchar *adapter_arg = NULL;
static GOptionEntry entries[] = {
- {"adapter", 'a', 0, G_OPTION_ARG_STRING, &adapter_arg, "Adapter name or MAC", "adapter#id"},
+ {"adapter", 'a', 0, G_OPTION_ARG_STRING, &adapter_arg, "Adapter name or MAC", "<name|mac>"},
{NULL}
};
@@ -46,8 +46,8 @@ int main(int argc, char *argv[])
context = g_option_context_new(" - a bluetooth agent");
g_option_context_add_main_entries(context, entries, NULL);
- g_option_context_set_summary(context, "agent summary");
- g_option_context_set_description(context, "agent desc");
+ g_option_context_set_summary(context, "Version "PACKAGE_VERSION);
+ g_option_context_set_description(context, "Report bugs to <"PACKAGE_BUGREPORT">.");
if (!g_option_context_parse(context, &argc, &argv, &error)) {
g_print("%s: %s\n", g_get_prgname(), error->message);
diff --git a/src/bt-audio.c b/src/bt-audio.c
index 67fc49f..8e0b1e1 100644
--- a/src/bt-audio.c
+++ b/src/bt-audio.c
@@ -51,9 +51,9 @@ static gchar *connect_arg = NULL;
static gchar *disconnect_arg = NULL;
static GOptionEntry entries[] = {
- {"adapter", 'a', 0, G_OPTION_ARG_STRING, &adapter_arg, "Adapter name or MAC", "adapter#id"},
- {"connect", 'c', 0, G_OPTION_ARG_STRING, &connect_arg, "Connect to an audio device", "device#id"},
- {"disconnect", 'd', 0, G_OPTION_ARG_STRING, &disconnect_arg, "Disconnect from an audio device", "device#id"},
+ {"adapter", 'a', 0, G_OPTION_ARG_STRING, &adapter_arg, "Adapter name or MAC", "<name|mac>"},
+ {"connect", 'c', 0, G_OPTION_ARG_STRING, &connect_arg, "Connect to an audio device", "<name|mac>"},
+ {"disconnect", 'd', 0, G_OPTION_ARG_STRING, &disconnect_arg, "Disconnect from an audio device", "<name|mac>"},
{NULL}
};
@@ -66,8 +66,8 @@ int main(int argc, char *argv[])
context = g_option_context_new("- a bluetooth generic audio manager");
g_option_context_add_main_entries(context, entries, NULL);
- g_option_context_set_summary(context, "audio summary");
- g_option_context_set_description(context, "audio desc");
+ g_option_context_set_summary(context, "Version "PACKAGE_VERSION);
+ g_option_context_set_description(context, "Report bugs to <"PACKAGE_BUGREPORT">.");
if (!g_option_context_parse(context, &argc, &argv, &error)) {
g_print("%s: %s\n", g_get_prgname(), error->message);
@@ -91,7 +91,10 @@ int main(int argc, char *argv[])
Device *device = find_device(adapter, connect_arg != NULL ? connect_arg : disconnect_arg, &error);
exit_if_error(error);
- // TODO: Test to AUDIO service
+ if (!intf_is_supported(device_get_dbus_object_path(device), AUDIO_INTF)) {
+ g_printerr("Audio service is not supported by this device\n");
+ exit(EXIT_FAILURE);
+ }
GMainLoop *mainloop = g_main_loop_new(NULL, FALSE);
diff --git a/src/bt-device.c b/src/bt-device.c
index afddc77..b20e502 100644
--- a/src/bt-device.c
+++ b/src/bt-device.c
@@ -170,13 +170,13 @@ static gchar *set_property_arg = NULL;
static gchar *set_value_arg = NULL;
static GOptionEntry entries[] = {
- {"adapter", 'a', 0, G_OPTION_ARG_STRING, &adapter_arg, "Adapter name or MAC", "adapter#id"},
+ {"adapter", 'a', 0, G_OPTION_ARG_STRING, &adapter_arg, "Adapter name or MAC", "<name|mac>"},
{"list", 'l', 0, G_OPTION_ARG_NONE, &list_arg, "List added devices", NULL},
- {"connect", 'c', 0, G_OPTION_ARG_STRING, &connect_arg, "Connect to a device", "device#id"},
- {"remove", 'r', 0, G_OPTION_ARG_STRING, &remove_arg, "Remove device", "device#id"},
- {"info", 'i', 0, G_OPTION_ARG_STRING, &info_arg, "Get info about device", "device#id"},
- {"services", 's', 0, G_OPTION_ARG_STRING, &services_arg, "Discover device services", "device#id"},
- {"set", 0, 0, G_OPTION_ARG_NONE, &set_arg, "Set property", NULL},
+ {"connect", 'c', 0, G_OPTION_ARG_STRING, &connect_arg, "Connect to a device", "<mac>"},
+ {"remove", 'r', 0, G_OPTION_ARG_STRING, &remove_arg, "Remove device", "<name|mac>"},
+ {"info", 'i', 0, G_OPTION_ARG_STRING, &info_arg, "Get info about device", "<name|mac>"},
+ {"services", 's', 0, G_OPTION_ARG_STRING, &services_arg, "Discover device services", "<name|mac>"},
+ {"set", 0, 0, G_OPTION_ARG_NONE, &set_arg, "Set device property", NULL},
{NULL}
};
@@ -189,15 +189,15 @@ int main(int argc, char *argv[])
context = g_option_context_new("- a bluetooth device manager");
g_option_context_add_main_entries(context, entries, NULL);
- g_option_context_set_summary(context, "device summary");
+ g_option_context_set_summary(context, "Version "PACKAGE_VERSION);
g_option_context_set_description(context,
"Set Options:\n"
- " --set <device#id> <property> <value>\n"
+ " --set <name|mac> <property> <value>\n"
" Where `property` is one of:\n"
" Alias\n"
" Trusted\n"
" Blocked\n\n"
- "device desc"
+ "Report bugs to <"PACKAGE_BUGREPORT">."
);
if (!g_option_context_parse(context, &argc, &argv, &error)) {
@@ -266,11 +266,12 @@ int main(int argc, char *argv[])
Device *device = find_device(adapter, info_arg, &error);
exit_if_error(error);
+ // TODO: Translate class of device ?
+
g_print("[%s]\n", device_get_address(device));
g_print(" Name: %s\n", device_get_name(device));
g_print(" Alias: %s [rw]\n", device_get_alias(device));
g_print(" Address: %s\n", device_get_address(device));
- // TODO: Add class to type conv
g_print(" Class: %x\n", device_get_class(device));
g_print(" Paired: %d\n", device_get_paired(device));
g_print(" Trusted: %d [rw]\n", device_get_trusted(device));
@@ -296,14 +297,16 @@ int main(int argc, char *argv[])
GHashTableIter iter;
gpointer key, value;
+ // TOOD: Add verbose option
+
g_hash_table_iter_init(&iter, device_services);
while (g_hash_table_iter_next(&iter, &key, &value)) {
- //GMarkupParser xml_parser = {xml_start_element, xml_end_element, NULL, NULL, NULL};
- //GMarkupParseContext *xml_parse_context = g_markup_parse_context_new(&xml_parser, 0, NULL, NULL);
- //g_markup_parse_context_parse(xml_parse_context, value, strlen(value), &error);
- //exit_if_error(error);
- //g_markup_parse_context_free(xml_parse_context);
- g_print("%s", value);
+ GMarkupParser xml_parser = {xml_start_element, xml_end_element, NULL, NULL, NULL};
+ GMarkupParseContext *xml_parse_context = g_markup_parse_context_new(&xml_parser, 0, NULL, NULL);
+ g_markup_parse_context_parse(xml_parse_context, value, strlen(value), &error);
+ exit_if_error(error);
+ g_markup_parse_context_free(xml_parse_context);
+ //g_print("%s", value);
}
g_print("Done\n");
diff --git a/src/bt-monitor.c b/src/bt-monitor.c
index 83dc5a6..67853fc 100644
--- a/src/bt-monitor.c
+++ b/src/bt-monitor.c
@@ -254,7 +254,7 @@ static void release_device(Device *device)
}
static GOptionEntry entries[] = {
- {"adapter", 'a', 0, G_OPTION_ARG_STRING, &adapter_arg, "Adapter name or MAC", "adapter#id"},
+ {"adapter", 'a', 0, G_OPTION_ARG_STRING, &adapter_arg, "Adapter name or MAC", "<name|mac>"},
{NULL}
};
@@ -267,8 +267,8 @@ int main(int argc, char *argv[])
context = g_option_context_new("- a bluetooth monitor");
g_option_context_add_main_entries(context, entries, NULL);
- g_option_context_set_summary(context, "monitor summary");
- g_option_context_set_description(context, "monitor desc");
+ g_option_context_set_summary(context, "Version "PACKAGE_VERSION);
+ g_option_context_set_description(context, "Report bugs to <"PACKAGE_BUGREPORT">.");
if (!g_option_context_parse(context, &argc, &argv, &error)) {
g_print("%s: %s\n", g_get_prgname(), error->message);
diff --git a/src/bt-network.c b/src/bt-network.c
index ec6918f..8368a91 100644
--- a/src/bt-network.c
+++ b/src/bt-network.c
@@ -54,9 +54,9 @@ static gchar *service_property_arg = NULL;
static gchar *service_value_arg = NULL;
static GOptionEntry entries[] = {
- {"adapter", 'a', 0, G_OPTION_ARG_STRING, &adapter_arg, "Adapter name or MAC", "adapter#id"},
+ {"adapter", 'a', 0, G_OPTION_ARG_STRING, &adapter_arg, "Adapter name or MAC", "<name|mac>"},
{"connect", 'c', 0, G_OPTION_ARG_NONE, &connect_arg, "Connect to a network device", NULL},
- {"disconnect", 'd', 0, G_OPTION_ARG_STRING, &disconnect_arg, "Disconnect from a network device", "device#id"},
+ {"disconnect", 'd', 0, G_OPTION_ARG_STRING, &disconnect_arg, "Disconnect from a network device", "<name|mac>"},
{"service", 's', 0, G_OPTION_ARG_NONE, &service_arg, "Manage GN/PANU/NAP services", NULL},
{NULL}
};
@@ -70,10 +70,10 @@ int main(int argc, char *argv[])
context = g_option_context_new("- a bluetooth network manager");
g_option_context_add_main_entries(context, entries, NULL);
- g_option_context_set_summary(context, "network summary");
+ g_option_context_set_summary(context, "Version "PACKAGE_VERSION);
g_option_context_set_description(context,
"Connect Options:\n"
- " -c, --connect <device#id> <pattern>\n"
+ " -c, --connect <name|mac> <pattern>\n"
" Where `pattern` is:\n"
" UUID 128 bit string\n"
" Profile short name: gn, panu or nap\n"
@@ -84,7 +84,7 @@ int main(int argc, char *argv[])
" Name\n"
" Enabled\n"
" By default - show status\n\n"
- "network desc"
+ "Report bugs to <"PACKAGE_BUGREPORT">."
);
if (!g_option_context_parse(context, &argc, &argv, &error)) {
@@ -123,7 +123,10 @@ int main(int argc, char *argv[])
Device *device = find_device(adapter, connect_device_arg != NULL ? connect_device_arg : disconnect_arg, &error);
exit_if_error(error);
- // TODO: Test to NETWORK service
+ if (!intf_is_supported(device_get_dbus_object_path(device), NETWORK_INTF)) {
+ g_printerr("Network service is not supported by this device\n");
+ exit(EXIT_FAILURE);
+ }
GMainLoop *mainloop = g_main_loop_new(NULL, FALSE);
@@ -140,7 +143,7 @@ int main(int argc, char *argv[])
g_free(intf);
}
g_print("Interface: %s\n", network_get_interface(network));
- g_print("UUID: %s\n", network_get_uuid(network));
+ g_print("UUID: %s (%s)\n", get_uuid_name(network_get_uuid(network)), network_get_uuid(network));
} else if (disconnect_arg) {
if (network_get_connected(network) == FALSE) {
g_print("Network service is already disconnected\n");
@@ -185,6 +188,11 @@ int main(int argc, char *argv[])
}
if (g_ascii_strcasecmp(service_name_arg, "GN") == 0) {
+ if (!intf_is_supported(adapter_get_dbus_object_path(adapter), NETWORK_HUB_INTF)) {
+ g_printerr("GN service is not supported by this adapter\n");
+ exit(EXIT_FAILURE);
+ }
+
NetworkHub *hub = g_object_new(NETWORK_HUB_TYPE, "DBusObjectPath", adapter_get_dbus_object_path(adapter), NULL);
if (service_property_arg == NULL) {
@@ -210,6 +218,11 @@ int main(int argc, char *argv[])
g_object_unref(hub);
} else if (g_ascii_strcasecmp(service_name_arg, "PANU") == 0) {
+ if (!intf_is_supported(adapter_get_dbus_object_path(adapter), NETWORK_PEER_INTF)) {
+ g_printerr("PANU service is not supported by this adapter\n");
+ exit(EXIT_FAILURE);
+ }
+
NetworkPeer *peer = g_object_new(NETWORK_PEER_TYPE, "DBusObjectPath", adapter_get_dbus_object_path(adapter), NULL);
if (service_property_arg == NULL) {
@@ -235,6 +248,11 @@ int main(int argc, char *argv[])
g_object_unref(peer);
} else if (g_ascii_strcasecmp(service_name_arg, "NAP") == 0) {
+ if (!intf_is_supported(adapter_get_dbus_object_path(adapter), NETWORK_ROUTER_INTF)) {
+ g_printerr("NAP service is not supported by this adapter\n");
+ exit(EXIT_FAILURE);
+ }
+
NetworkRouter *router = g_object_new(NETWORK_ROUTER_TYPE, "DBusObjectPath", adapter_get_dbus_object_path(adapter), NULL);
if (service_property_arg == NULL) {
diff --git a/src/bt-serial.c b/src/bt-serial.c
index 8abc246..7007cbe 100644
--- a/src/bt-serial.c
+++ b/src/bt-serial.c
@@ -39,7 +39,7 @@ static gchar *disconnect_device_arg = NULL;
static gchar *disconnect_tty_device_arg = NULL;
static GOptionEntry entries[] = {
- {"adapter", 'a', 0, G_OPTION_ARG_STRING, &adapter_arg, "Adapter name or MAC", "adapter#id"},
+ {"adapter", 'a', 0, G_OPTION_ARG_STRING, &adapter_arg, "Adapter name or MAC", "<name|mac>"},
{"connect", 'c', 0, G_OPTION_ARG_NONE, &connect_arg, "Connect to a serial device", NULL},
{"disconnect", 'd', 0, G_OPTION_ARG_NONE, &disconnect_arg, "Disconnect from a serial device", NULL},
{NULL}
@@ -54,19 +54,19 @@ int main(int argc, char *argv[])
context = g_option_context_new(" - a bluetooth serial manager");
g_option_context_add_main_entries(context, entries, NULL);
- g_option_context_set_summary(context, "serial summary");
+ g_option_context_set_summary(context, "Version "PACKAGE_VERSION);
g_option_context_set_description(context,
"Connect Options:\n"
- " -c, --connect <device#id> <pattern>\n"
+ " -c, --connect <name|mac> <pattern>\n"
" Where `pattern` is:\n"
" UUID 128 bit string\n"
" Profile short name, e.g: spp, dun\n"
" RFCOMM channel, 1-30\n\n"
"Disconnect Options:\n"
- " -d, --disconnect <device#id> <tty_device>\n"
+ " -d, --disconnect <name|mac> <tty_device>\n"
" Where `tty_device` is:\n"
" RFCOMM TTY device that has been connected\n\n"
- "serial desc"
+ "Report bugs to <"PACKAGE_BUGREPORT">."
);
if (!g_option_context_parse(context, &argc, &argv, &error)) {
@@ -107,7 +107,10 @@ int main(int argc, char *argv[])
Device *device = find_device(adapter, connect_device_arg != NULL ? connect_device_arg : disconnect_device_arg, &error);
exit_if_error(error);
- // TODO: Test to Serial service
+ if (!intf_is_supported(device_get_dbus_object_path(device), SERIAL_INTF)) {
+ g_printerr("Serial service is not supported by this device\n");
+ exit(EXIT_FAILURE);
+ }
Serial *serial = g_object_new(SERIAL_TYPE, "DBusObjectPath", device_get_dbus_object_path(device), NULL);