nautilus-sendto r372 - in trunk: . src/plugins
- From: baptistem svn gnome org
- To: svn-commits-list gnome org
- Subject: nautilus-sendto r372 - in trunk: . src/plugins
- Date: Thu, 18 Dec 2008 14:05:31 +0000 (UTC)
Author: baptistem
Date: Thu Dec 18 14:05:31 2008
New Revision: 372
URL: http://svn.gnome.org/viewvc/nautilus-sendto?rev=372&view=rev
Log:
* src/plugins/bluetooth.c: Propose last used bluetooth device as
default device. Bug #546571.
Modified:
trunk/ChangeLog
trunk/src/plugins/bluetooth.c
Modified: trunk/src/plugins/bluetooth.c
==============================================================================
--- trunk/src/plugins/bluetooth.c (original)
+++ trunk/src/plugins/bluetooth.c Thu Dec 18 14:05:31 2008
@@ -27,9 +27,12 @@
#include <bluetooth-marshal.h>
#include <dbus/dbus-glib.h>
#include <glib/gi18n-lib.h>
+#include <gconf/gconf-client.h>
+
#include "../nautilus-sendto-plugin.h"
#define OBEX_FILETRANS_SVCLASS_ID_STR "0x1106"
+#define LAST_OBEX_DEVICE "/desktop/gnome/nautilus-sendto/last_obex_device"
static GtkTreeModel *model;
static int discovered;
@@ -127,6 +130,38 @@
return found;
}
+static char *
+get_device_name_from_address (char *bdaddr)
+{
+ const char *device_path;
+ DBusGProxy *device;
+ GHashTable *props;
+
+ if (dbus_g_proxy_call (object, "FindDevice", NULL,
+ G_TYPE_STRING, bdaddr, G_TYPE_INVALID,
+ DBUS_TYPE_G_OBJECT_PATH, &device_path, G_TYPE_INVALID) == FALSE) {
+ return bdaddr;
+ }
+
+ device = dbus_g_proxy_new_for_name (conn, "org.bluez",
+ device_path, "org.bluez.Device");
+
+ if (dbus_g_proxy_call (device, "GetProperties", NULL,
+ G_TYPE_INVALID, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
+ &props, G_TYPE_INVALID) != FALSE) {
+
+ GValue *value;
+ char *name;
+
+ value = g_hash_table_lookup (props, "Alias");
+ name = value ? g_value_get_string (value) : bdaddr;
+
+ return name;
+ } else {
+ return bdaddr;
+ }
+}
+
static void
add_phone_to_list (GtkListStore *store, const char *name, const char *bdaddr)
{
@@ -177,6 +212,24 @@
}
static void
+add_last_used_device_to_list (GtkListStore *store)
+{
+ char *bdaddr, *name;
+ GConfClient *gconfclient;
+
+ gconfclient = gconf_client_get_default ();
+ bdaddr = gconf_client_get_string (gconfclient, LAST_OBEX_DEVICE, NULL);
+ g_object_unref (gconfclient);
+
+ if (bdaddr != NULL && *bdaddr != '\0') {
+ name = get_device_name_from_address (bdaddr);
+ add_phone_to_list (store, name, bdaddr);
+ }
+
+ g_free (bdaddr);
+}
+
+static void
add_known_devices_to_list (GtkListStore *store)
{
GError *e = NULL;
@@ -250,6 +303,7 @@
gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0);
gtk_widget_set_sensitive (combobox, FALSE);
+ add_last_used_device_to_list (store);
add_known_devices_to_list (store);
start_device_scanning (store);
@@ -292,6 +346,21 @@
return ret;
}
+static void
+save_last_used_obex_device (const char *bdaddr)
+{
+ GConfClient *gconfclient;
+
+ gconfclient = gconf_client_get_default ();
+ gconf_client_set_string (gconfclient,
+ LAST_OBEX_DEVICE,
+ bdaddr,
+ NULL);
+
+ g_object_unref(gconfclient);
+}
+
+
static gboolean
send_files (NstPlugin *plugin, GtkWidget *contact_widget,
GList *file_list)
@@ -329,6 +398,8 @@
if (ret == FALSE) {
g_warning ("Couldn't send files via bluetooth: %s", err->message);
g_error_free (err);
+ } else {
+ save_last_used_obex_device (bdaddr);
}
return ret;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]