summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.ci/gbt.suppr4
-rw-r--r--lib/bluetooth-settings-widget.c6
-rw-r--r--lib/bluetooth-utils.c32
-rw-r--r--lib/bluetooth-utils.h5
4 files changed, 28 insertions, 19 deletions
diff --git a/.ci/gbt.suppr b/.ci/gbt.suppr
index 925ff5d5..adac0c3d 100644
--- a/.ci/gbt.suppr
+++ b/.ci/gbt.suppr
@@ -49,3 +49,7 @@ drop = yes
[suppress_function]
symbol_name = bluetooth_client_dump_device
drop = yes
+
+[suppress_function]
+name = bluetooth_send_to_address
+change_kind = function-subtype-change
diff --git a/lib/bluetooth-settings-widget.c b/lib/bluetooth-settings-widget.c
index 72c017bf..909f399b 100644
--- a/lib/bluetooth-settings-widget.c
+++ b/lib/bluetooth-settings-widget.c
@@ -1210,7 +1210,11 @@ static void
send_callback (GtkButton *button,
BluetoothSettingsWidget *self)
{
- bluetooth_send_to_address (self->selected_bdaddr, self->selected_name);
+ g_autoptr(GError) error = NULL;
+
+ if (!bluetooth_send_to_address (self->selected_bdaddr, self->selected_name, &error))
+ g_warning ("Failed to call bluetooth-sendto: %s",
+ error ? error->message : "unknown error");
}
/* Visibility/Discoverable */
diff --git a/lib/bluetooth-utils.c b/lib/bluetooth-utils.c
index 87d550e8..78c561db 100644
--- a/lib/bluetooth-utils.c
+++ b/lib/bluetooth-utils.c
@@ -425,31 +425,31 @@ bluetooth_uuid_to_string (const char *uuid)
* bluetooth_send_to_address:
* @address: Remote device to use
* @alias: Remote device's name
+ * @error: a #GError
*
- * Start a GUI application for transfering files over Bluetooth.
+ * Start a GUI application for transferring files over Bluetooth.
+ *
+ * Return value: %TRUE on success, %FALSE on error.
**/
-void
-bluetooth_send_to_address (const char *address,
- const char *alias)
+gboolean
+bluetooth_send_to_address (const char *address,
+ const char *alias,
+ GError **error)
{
GPtrArray *a;
- GError *err = NULL;
+ g_auto(GStrv) args = NULL;
- a = g_ptr_array_new_with_free_func ((GDestroyNotify) g_free);
+ g_return_val_if_fail (address != NULL, FALSE);
+ g_return_val_if_fail (bluetooth_verify_address (address), FALSE);
+ a = g_ptr_array_new ();
g_ptr_array_add (a, g_strdup ("bluetooth-sendto"));
- if (address != NULL)
- g_ptr_array_add (a, g_strdup_printf ("--device=%s", address));
- if (address != NULL && alias != NULL)
+ g_ptr_array_add (a, g_strdup_printf ("--device=%s", address));
+ if (alias != NULL)
g_ptr_array_add (a, g_strdup_printf ("--name=%s", alias));
g_ptr_array_add (a, NULL);
+ args = (GStrv) g_ptr_array_free (a, FALSE);
- if (g_spawn_async(NULL, (char **) a->pdata, NULL,
- G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, &err) == FALSE) {
- g_printerr("Couldn't execute command: %s\n", err->message);
- g_error_free (err);
- }
-
- g_ptr_array_free (a, TRUE);
+ return g_spawn_async (NULL, args, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, error);
}
diff --git a/lib/bluetooth-utils.h b/lib/bluetooth-utils.h
index b4a4932f..efe091bf 100644
--- a/lib/bluetooth-utils.h
+++ b/lib/bluetooth-utils.h
@@ -33,5 +33,6 @@ const gchar *bluetooth_type_to_string (guint type);
gboolean bluetooth_verify_address (const char *bdaddr);
const char *bluetooth_uuid_to_string (const char *uuid);
-void bluetooth_send_to_address (const char *address,
- const char *alias);
+gboolean bluetooth_send_to_address (const char *address,
+ const char *alias,
+ GError **error);