aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Ancell <robert.ancell@canonical.com>2012-10-11 19:07:48 +1300
committerRobert Ancell <robert.ancell@canonical.com>2012-10-11 19:07:48 +1300
commitde247720b4c7261d96dd99edd42f5ea898ab09b5 (patch)
treeeaf1a04b1a61bda8908db6e064dc7b014b3884fa
parent8e5d7ea526a3d61e8b5ea95041893adbbca427b0 (diff)
downloadayatana-indicator-bluetooth-de247720b4c7261d96dd99edd42f5ea898ab09b5.tar.gz
ayatana-indicator-bluetooth-de247720b4c7261d96dd99edd42f5ea898ab09b5.tar.bz2
ayatana-indicator-bluetooth-de247720b4c7261d96dd99edd42f5ea898ab09b5.zip
Check device class
-rw-r--r--src/bluez.vala5
-rw-r--r--src/indicator-bluetooth.vala90
2 files changed, 83 insertions, 12 deletions
diff --git a/src/bluez.vala b/src/bluez.vala
index 976c1ce..c20acc7 100644
--- a/src/bluez.vala
+++ b/src/bluez.vala
@@ -102,6 +102,9 @@ public class BluezDevice : Object
private string _name = null;
public string name { get { return _name; } }
+ private uint32 _class = 0;
+ public uint32 class { get { return _class; } }
+
internal string path;
private BluezDeviceInterface proxy;
@@ -127,6 +130,8 @@ public class BluezDevice : Object
stderr.printf ("%s %s=%s\n", path, name, value.print (false));
if (name == "Name" && value.is_of_type (VariantType.STRING))
_name = value.get_string ();
+ if (name == "Class" && value.is_of_type (VariantType.UINT32))
+ _class = value.get_uint32 ();
}
private void input_property_changed_cb (string name, Variant value)
diff --git a/src/indicator-bluetooth.vala b/src/indicator-bluetooth.vala
index fd09738..e7ca190 100644
--- a/src/indicator-bluetooth.vala
+++ b/src/indicator-bluetooth.vala
@@ -74,18 +74,84 @@ public class BluetoothIndicator : AppIndicator.Indicator
menu.append (item);
item.submenu = new Gtk.Menu ();
- var i = new Gtk.MenuItem.with_label (_("Send files..."));
- i.visible = true;
- i.activate.connect (() => { Process.spawn_command_line_async ("bluetooth-sendto --device=DEVICE --name=NAME"); }); // FIXME
- item.submenu.append (i);
-
- //FIXME
- //var i = new Gtk.MenuItem.with_label (_("Keyboard Settings..."));
- //i.activate.connect (() => { Process.spawn_command_line_async ("gnome-control-center keyboard"); });
- //var i = new Gtk.MenuItem.with_label (_("Mouse and Touchpad Settings..."));
- //i.activate.connect (() => { Process.spawn_command_line_async ("gnome-control-center mouse"); });
- //var i = new Gtk.MenuItem.with_label (_("Sound Settings..."));
- //i.activate.connect (() => { Process.spawn_command_line_async ("gnome-control-center sound"); });
+
+ /* Scan class mask to determine what type of device it is */
+ var is_keyboard = false;
+ var is_pointer = false;
+ var is_audio = false;
+ switch ((device.class & 0x1f00) >> 8)
+ {
+ case 0x04:
+ switch ((device.class & 0xfc) >> 2)
+ {
+ case 0x0b:
+ case 0x0c:
+ case 0x0d:
+ /* (video devices) */
+ break;
+ default:
+ is_audio = true;
+ break;
+ }
+ break;
+ case 0x05:
+ switch ((device.class & 0xc0) >> 6)
+ {
+ case 0x00:
+ /* (joypads) */
+ break;
+ case 0x01:
+ is_keyboard = true;
+ break;
+ case 0x02:
+ is_pointer = true;
+ break;
+ }
+ break;
+ }
+
+ // FIXME: Check by looking at the UUIDs
+ var can_receive_files = true;
+ var can_browse_files = true;
+
+ if (can_receive_files)
+ {
+ var i = new Gtk.MenuItem.with_label (_("Send files..."));
+ i.visible = true;
+ i.activate.connect (() => { Process.spawn_command_line_async ("bluetooth-sendto --device=DEVICE --name=NAME"); }); // FIXME
+ item.submenu.append (i);
+ }
+ if (can_browse_files)
+ {
+ var i = new Gtk.MenuItem.with_label (_("Browse files..."));
+ i.visible = true;
+ i.activate.connect (() => { Process.spawn_command_line_async ("gnome-open obex://[%s]/"); }); // FIXME
+ item.submenu.append (i);
+ }
+
+ if (is_keyboard)
+ {
+ var i = new Gtk.MenuItem.with_label (_("Keyboard Settings..."));
+ i.visible = true;
+ i.activate.connect (() => { Process.spawn_command_line_async ("gnome-control-center keyboard"); });
+ item.submenu.append (i);
+ }
+
+ if (is_pointer)
+ {
+ var i = new Gtk.MenuItem.with_label (_("Mouse and Touchpad Settings..."));
+ i.visible = true;
+ i.activate.connect (() => { Process.spawn_command_line_async ("gnome-control-center mouse"); });
+ item.submenu.append (i);
+ }
+
+ if (is_audio)
+ {
+ var i = new Gtk.MenuItem.with_label (_("Sound Settings..."));
+ i.visible = true;
+ i.activate.connect (() => { Process.spawn_command_line_async ("gnome-control-center sound"); });
+ item.submenu.append (i);
+ }
}
var sep = new Gtk.SeparatorMenuItem ();