[gnome-bluetooth] applet: Make sendto function work as expected
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-bluetooth] applet: Make sendto function work as expected
- Date: Sat, 30 Oct 2010 02:42:04 +0000 (UTC)
commit 6043a76d08dabd96e9d008c93fedcdb44edf0d8f
Author: Bastien Nocera <hadess hadess net>
Date: Sat Oct 30 03:40:13 2010 +0100
applet: Make sendto function work as expected
We weren't handling alias being NULL. Fix coding style in browse.
applet/bluetooth-applet.c | 79 ++++++++++++++++++++++++++++-----------------
1 files changed, 49 insertions(+), 30 deletions(-)
---
diff --git a/applet/bluetooth-applet.c b/applet/bluetooth-applet.c
index db216fe..faf140c 100644
--- a/applet/bluetooth-applet.c
+++ b/applet/bluetooth-applet.c
@@ -190,22 +190,23 @@ void bluetooth_applet_browse_address (BluetoothApplet *applet,
GAsyncReadyCallback callback,
gpointer user_data)
{
- GFile *file;
- char *uri;
- MountClosure *closure;
- g_return_if_fail (BLUETOOTH_IS_APPLET (applet));
- g_return_if_fail (address != NULL);
-
- uri = g_strdup_printf ("obex://[%s]/", address);
- file = g_file_new_for_uri (uri);
-
- closure = g_new (MountClosure, 1);
- closure->result = g_simple_async_result_new (G_OBJECT (applet), callback, user_data, bluetooth_applet_browse_address);
- closure->timestamp = timestamp;
- g_file_mount_enclosing_volume(file, G_MOUNT_MOUNT_NONE, NULL, NULL, mount_ready_cb, closure);
-
- g_free (uri);
- g_object_unref (file);
+ GFile *file;
+ char *uri;
+ MountClosure *closure;
+
+ g_return_if_fail (BLUETOOTH_IS_APPLET (applet));
+ g_return_if_fail (address != NULL);
+
+ uri = g_strdup_printf ("obex://[%s]/", address);
+ file = g_file_new_for_uri (uri);
+
+ closure = g_new (MountClosure, 1);
+ closure->result = g_simple_async_result_new (G_OBJECT (applet), callback, user_data, bluetooth_applet_browse_address);
+ closure->timestamp = timestamp;
+ g_file_mount_enclosing_volume(file, G_MOUNT_MOUNT_NONE, NULL, NULL, mount_ready_cb, closure);
+
+ g_free (uri);
+ g_object_unref (file);
}
/**
@@ -220,20 +221,38 @@ void bluetooth_applet_send_to_address (BluetoothApplet *applet,
const char *address,
const char *alias)
{
- char *command;
- char *quoted_address;
- char *quoted_alias;
- g_return_if_fail (address != NULL);
- g_return_if_fail (alias != NULL);
- g_return_if_fail (BLUETOOTH_IS_APPLET (applet));
-
- quoted_address = g_shell_quote (address);
- quoted_alias = g_shell_quote (alias);
- command = g_strdup_printf ("bluetooth-sendto --device=%s --name=%s", quoted_address, quoted_alias);
- g_spawn_command_line_async (command, NULL);
- g_free (command);
- g_free (quoted_address);
- g_free (quoted_alias);
+ GPtrArray *a;
+ GError *err = NULL;
+ guint i;
+
+ g_return_if_fail (BLUETOOTH_IS_APPLET (applet));
+
+ a = g_ptr_array_new ();
+ g_ptr_array_add (a, "bluetooth-sendto");
+ if (address != NULL) {
+ char *s;
+
+ s = g_strdup_printf ("--device=\"%s\"", address);
+ g_ptr_array_add (a, s);
+ }
+ if (address != NULL && alias != NULL) {
+ char *s;
+
+ s = g_strdup_printf ("--name=\"%s\"", alias);
+ g_ptr_array_add (a, s);
+ }
+ g_ptr_array_add (a, NULL);
+
+ 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);
+ }
+
+ for (i = 1; a->pdata[i] != NULL; i++)
+ g_free (a->pdata[i]);
+
+ g_ptr_array_free (a, TRUE);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]