aboutsummaryrefslogtreecommitdiff
path: root/src/bluetooth.vala
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2013-08-03 10:48:02 -0500
committerCharles Kerr <charles.kerr@canonical.com>2013-08-03 10:48:02 -0500
commit9837ce82575d089b52269ff600820d565be3fd22 (patch)
treee0a958673815a3befc35f5dbc9e31f8aa785f76c /src/bluetooth.vala
parentd73ae6424c53b2b8760b81d24a71cae6a3169a59 (diff)
downloadayatana-indicator-bluetooth-9837ce82575d089b52269ff600820d565be3fd22.tar.gz
ayatana-indicator-bluetooth-9837ce82575d089b52269ff600820d565be3fd22.tar.bz2
ayatana-indicator-bluetooth-9837ce82575d089b52269ff600820d565be3fd22.zip
initial support for individual devices in Bluetooth class
Diffstat (limited to 'src/bluetooth.vala')
-rw-r--r--src/bluetooth.vala138
1 files changed, 138 insertions, 0 deletions
diff --git a/src/bluetooth.vala b/src/bluetooth.vala
index b6d0e55..1952d1c 100644
--- a/src/bluetooth.vala
+++ b/src/bluetooth.vala
@@ -36,6 +36,144 @@ public class Bluetooth: Object
killswitch.try_set_blocked (b);
}
+ public class Device: Object {
+ public string name { get; construct; }
+ public bool supports_browsing { get; construct; }
+ public bool supports_file_transfer { get; construct; }
+ public Device (string name,
+ bool supports_browsing,
+ bool supports_file_transfer) {
+ Object (name: name,
+ supports_browsing: supports_browsing,
+ supports_file_transfer: supports_file_transfer);
+ }
+ }
+
+ private static uint16 get_uuid16_from_uuid (string uuid)
+ {
+ uint16 uuid16;
+
+ string[] tokens = uuid.split ("-", 1);
+ if (tokens.length > 0)
+ uuid16 = (uint16) uint64.parse ("0x"+tokens[0]);
+ else
+ uuid16 = 0;
+
+ return uuid16;
+ }
+
+ protected static bool uuid_supports_file_transfer (string uuid)
+ {
+ return get_uuid16_from_uuid (uuid) == 0x1105; // OBEXObjectPush
+ }
+
+ protected static bool uuid_supports_browsing (string uuid)
+ {
+ return get_uuid16_from_uuid (uuid) == 0x1106; // OBEXFileTransfer
+ }
+
+ public enum DeviceType
+ {
+ COMPUTER,
+ PHONE,
+ MODEM,
+ NETWORK,
+ HEADSET,
+ HEADPHONES,
+ VIDEO,
+ OTHER_AUDIO,
+ JOYPAD,
+ KEYPAD,
+ KEYBOARD,
+ TABLET,
+ MOUSE,
+ PRINTER,
+ CAMERA
+ }
+
+ protected static DeviceType class_to_device_type (uint32 c)
+ {
+ switch ((c & 0x1f00) >> 8)
+ {
+ case 0x01:
+ return DeviceType.COMPUTER;
+
+ case 0x02:
+ switch ((c & 0xfc) >> 2)
+ {
+ case 0x01:
+ case 0x02:
+ case 0x03:
+ case 0x05:
+ return DeviceType.PHONE;
+
+ case 0x04:
+ return DeviceType.MODEM;
+ }
+ break;
+
+ case 0x03:
+ return DeviceType.NETWORK;
+
+ case 0x04:
+ switch ((c & 0xfc) >> 2)
+ {
+ case 0x01:
+ case 0x02:
+ return DeviceType.HEADSET;
+
+ case 0x06:
+ return DeviceType.HEADPHONES;
+
+ case 0x0b: // vcr
+ case 0x0c: // video camera
+ case 0x0d: // camcorder
+ return DeviceType.VIDEO;
+
+ default:
+ return DeviceType.OTHER_AUDIO;
+ }
+ //break;
+
+ case 0x05:
+ switch ((c & 0xc0) >> 6)
+ {
+ case 0x00:
+ switch ((c & 0x1e) >> 2)
+ {
+ case 0x01:
+ case 0x02:
+ return DeviceType.JOYPAD;
+ }
+ break;
+
+ case 0x01:
+ return DeviceType.KEYBOARD;
+
+ case 0x02:
+ switch ((c & 0x1e) >> 2)
+ {
+ case 0x05:
+ return DeviceType.TABLET;
+
+ default:
+ return DeviceType.MOUSE;
+ }
+ }
+ break;
+
+ case 0x06:
+ if ((c & 0x80) != 0)
+ return DeviceType.PRINTER;
+ if ((c & 0x20) != 0)
+ return DeviceType.CAMERA;
+ break;
+ }
+
+ return 0;
+ }
+
+
/***
**** Killswitch Implementation
***/