From 761a9fff03812af3c0beb26da1094c69fc3a0a72 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 31 Jul 2013 23:04:40 -0500 Subject: add a vapi/ directory off the top package directory --- vapi/config.vapi | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 vapi/config.vapi (limited to 'vapi') diff --git a/vapi/config.vapi b/vapi/config.vapi new file mode 100644 index 0000000..15c4c88 --- /dev/null +++ b/vapi/config.vapi @@ -0,0 +1,8 @@ +[CCode (cprefix = "", lower_case_cprefix = "", cheader_filename = "../config.h")] +namespace Config { + public const string GETTEXT_PACKAGE; + public const string GNOMELOCALEDIR; + public const string PKGDATADIR; + public const string PACKAGE_NAME; + public const string PACKAGE_VERSION; +} -- cgit v1.2.3 From 3cc732f558737acd0004efb013993515845e67d7 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 1 Aug 2013 01:34:47 -0500 Subject: add per-profile icons and initial menus w/settings section --- data/Makefile.am | 6 + data/com.canonical.indicator.bluetooth | 10 + src/Makefile.am | 34 +-- src/desktop.vala | 99 +++++++ src/gnome-bluetooth-1.0.vapi | 82 ------ src/indicator-bluetooth-service.vala | 415 ----------------------------- src/indicator-bluetooth.vala | 142 ---------- src/main.vala | 17 +- src/menu.vala | 53 ++++ src/phone.vala | 76 ++++++ src/service.vala | 470 +++++++++++++++++++++++++++++++++ vapi/gnome-bluetooth-1.0.vapi | 82 ++++++ 12 files changed, 803 insertions(+), 683 deletions(-) create mode 100644 data/com.canonical.indicator.bluetooth create mode 100644 src/desktop.vala delete mode 100644 src/gnome-bluetooth-1.0.vapi delete mode 100644 src/indicator-bluetooth-service.vala delete mode 100644 src/indicator-bluetooth.vala create mode 100644 src/menu.vala create mode 100644 src/phone.vala create mode 100644 src/service.vala create mode 100644 vapi/gnome-bluetooth-1.0.vapi (limited to 'vapi') diff --git a/data/Makefile.am b/data/Makefile.am index 6c491f1..d5f40aa 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -1,3 +1,9 @@ + +# the indicator bus file +indicatorsdir = $(prefix)/share/unity/indicators +dist_indicators_DATA = com.canonical.indicator.datetime + +# the dbus service file dbus_servicesdir = $(datadir)/dbus-1/services dbus_services_DATA = indicator-bluetooth.service diff --git a/data/com.canonical.indicator.bluetooth b/data/com.canonical.indicator.bluetooth new file mode 100644 index 0000000..746157a --- /dev/null +++ b/data/com.canonical.indicator.bluetooth @@ -0,0 +1,10 @@ +[Indicator Service] +Name=indicator-bluetooth +ObjectPath=/com/canonical/indicator/bluetooth +Position=70 + +[desktop] +ObjectPath=/com/canonical/indicator/bluetooth/desktop + +[phone] +ObjectPath=/com/canonical/indicator/bluetooth/phone diff --git a/src/Makefile.am b/src/Makefile.am index 2b92f9b..ed2c976 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,17 +1,18 @@ pkglibexec_PROGRAMS = indicator-bluetooth-service -indicatordir = ${libdir}/indicators3/7 -indicator_LTLIBRARIES = libbluetooth.la indicator_bluetooth_service_SOURCES = \ indicator3-0.4.vapi \ - gnome-bluetooth-1.0.vapi \ + desktop.vala \ main.vala \ - indicator-bluetooth-service.vala + menu.vala \ + phone.vala \ + service.vala indicator_bluetooth_service_VALAFLAGS = \ --ccode \ --vapidir=$(top_srcdir)/vapi/ \ --vapidir=./ \ + --pkg gnome-bluetooth-1.0 \ --pkg config \ --pkg posix \ --pkg glib-2.0 \ @@ -26,31 +27,6 @@ indicator_bluetooth_service_CFLAGS = \ indicator_bluetooth_service_LDADD = \ $(INDICATOR_BLUETOOTH_SERVICE_LIBS) -libbluetooth_la_SOURCES = \ - indicator3-0.4.vapi \ - indicator-bluetooth.vala \ - libido3-0.1.vapi - -libbluetooth_la_VALAFLAGS = \ - --ccode \ - --vapidir=$(top_srcdir)/vapi/ \ - --vapidir=./ \ - --pkg posix \ - --pkg glib-2.0 \ - --pkg gtk+-3.0 \ - --pkg Dbusmenu-0.4 \ - --pkg DbusmenuGtk3-0.4 - -libbluetooth_la_CFLAGS = \ - -DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \ - $(INDICATOR_BLUETOOTH_CFLAGS) - -libbluetooth_la_LIBADD = \ - $(INDICATOR_BLUETOOTH_LIBS) - -libbluetooth_la_LDFLAGS = \ - -module -avoid-version - CLEANFILES = \ $(patsubst %.vala,%.c,$(filter %.vala, $(SOURCES))) \ *_vala.stamp diff --git a/src/desktop.vala b/src/desktop.vala new file mode 100644 index 0000000..bd005f5 --- /dev/null +++ b/src/desktop.vala @@ -0,0 +1,99 @@ +/* + * Copyright 2013 Canonical Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authors: + * Charles Kerr + */ + +class DesktopMenu: BluetoothMenu +{ + private Settings settings; + + private Action[] actions; + + public override void add_actions_to_group (SimpleActionGroup group) + { + base.add_actions_to_group (group); + + for (var i=0; i { message("visible toggled"); }); + + this.actions = {}; + this.actions += new SimpleAction.stateful ("root-desktop", null, action_state_for_root()); + this.actions += create_settings_action (); + this.actions += create_wizard_action (); + + var section = new Menu (); + section.append (_("Set Up New Device…"), "indicator.desktop-wizard"); + section.append (_("Bluetooth Settings…"), "indicator.desktop-settings"); + this.menu.append_section (null, section); + } + + Action create_wizard_action () + { + var action = new SimpleAction ("desktop-wizard", null); + + action.activate.connect ((action, param) => { + try { + Process.spawn_command_line_async ("bluetooth-wizard"); + } catch (Error e) { + warning ("unable to launch settings: %s", e.message); + } + }); + + return action; + } + + Action create_settings_action () + { + var action = new SimpleAction ("desktop-settings", null); + + action.activate.connect ((action, param) => { + try { + Process.spawn_command_line_async ("gnome-control-center bluetooth"); + } catch (Error e) { + warning ("unable to launch settings: %s", e.message); + } + }); + + return action; + } + + protected Variant action_state_for_root () + { + var label = "Hello"; // FIXME + var a11y = "Hello"; // FIXME + var visible = true; // FIXME + + string icon_name = "bluetooth-active"; // FIXME: enabled, disabled, connected, etc. +//indicator-bluetooth-service.vala: bluetooth_service._icon_name = enabled ? "bluetooth-active" : "bluetooth-disabled"; + var icon = new ThemedIcon.with_default_fallbacks (icon_name); + + var builder = new VariantBuilder (new VariantType ("a{sv}")); + builder.add ("{sv}", "visible", new Variant ("b", visible)); + builder.add ("{sv}", "label", new Variant ("s", label)); + builder.add ("{sv}", "accessible-desc", new Variant ("s", a11y)); + builder.add ("{sv}", "icon", icon.serialize()); + return builder.end (); + } +} diff --git a/src/gnome-bluetooth-1.0.vapi b/src/gnome-bluetooth-1.0.vapi deleted file mode 100644 index 6d6aa09..0000000 --- a/src/gnome-bluetooth-1.0.vapi +++ /dev/null @@ -1,82 +0,0 @@ -[CCode (cprefix = "Bluetooth", lower_case_cprefix = "bluetooth_")] -namespace GnomeBluetooth -{ - -[CCode (cheader_filename = "bluetooth-client.h")] -public class Client : GLib.Object -{ - public Client (); - public Gtk.TreeModel model { get; } - public Gtk.TreeModel adapter_model { get; } - public Gtk.TreeModel device_model { get; } - [CCode (finish_function = "bluetooth_client_connect_service_finish")] - public async bool connect_service (string device, bool connect, GLib.Cancellable? cancellable = null) throws GLib.Error; -} - -[CCode (cheader_filename = "bluetooth-enums.h", cprefix = "BLUETOOTH_COLUMN_")] -public enum Column -{ - PROXY, - ADDRESS, - ALIAS, - NAME, - TYPE, - ICON, - DEFAULT, - PAIRED, - TRUSTED, - CONNECTED, - DISCOVERABLE, - DISCOVERING, - LEGACYPAIRING, - POWERED, - SERVICES, - UUIDS -} - -[CCode (cheader_filename = "bluetooth-enums.h", cprefix = "BLUETOOTH_TYPE_")] -public enum Type -{ - ANY, - PHONE, - MODEM, - COMPUTER, - NETWORK, - HEADSET, - HEADPHONES, - OTHER_AUDIO, - KEYBOARD, - MOUSE, - CAMERA, - PRINTER, - JOYPAD, - TABLET, - VIDEO -} - -[CCode (cheader_filename = "bluetooth-utils.h")] -public void browse_address (GLib.Object? object, string address, uint timestamp, GLib.AsyncReadyCallback? callback); - -[CCode (cheader_filename = "bluetooth-utils.h")] -public void send_to_address (string address, string alias); - -[CCode (cheader_filename = "bluetooth-killswitch.h", cprefix = "BLUETOOTH_KILLSWITCH_STATE_")] -public enum KillswitchState -{ - NO_ADAPTER, - SOFT_BLOCKED, - UNBLOCKED, - HARD_BLOCKED -} - -[CCode (cheader_filename = "bluetooth-killswitch.h")] -public class Killswitch : GLib.Object -{ - public Killswitch (); - public signal void state_changed (KillswitchState state); - public bool has_killswitches (); - public KillswitchState state { get; set; } - public unowned string state_to_string (); -} - -} diff --git a/src/indicator-bluetooth-service.vala b/src/indicator-bluetooth-service.vala deleted file mode 100644 index f65c538..0000000 --- a/src/indicator-bluetooth-service.vala +++ /dev/null @@ -1,415 +0,0 @@ -/* - * Copyright (C) 2012-2013 Canonical Ltd. - * Author: Robert Ancell - * - * This program is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, version 3 of the License. - * See http://www.gnu.org/copyleft/gpl.html the full text of the license. - */ - -public class BluetoothIndicator -{ - private Settings settings; - private DBusConnection bus; - private Indicator.Service indicator_service; - private Dbusmenu.Server menu_server; - private BluetoothService bluetooth_service; - private GnomeBluetooth.Client client; - private GnomeBluetooth.Killswitch killswitch; - private bool updating_killswitch = false; - private Dbusmenu.Menuitem enable_item; - private Dbusmenu.Menuitem visible_item; - private bool updating_visible = false; - private Dbusmenu.Menuitem devices_separator; - private List device_items; - private Dbusmenu.Menuitem menu; - - public BluetoothIndicator () throws Error - { - settings = new Settings ("com.canonical.indicator.bluetooth"); - settings.changed.connect ((key) => - { - if (key == "visible") - update_visible (); - }); - - bus = Bus.get_sync (BusType.SESSION); - - indicator_service = new Indicator.Service ("com.canonical.indicator.bluetooth"); - menu_server = new Dbusmenu.Server ("/com/canonical/indicator/bluetooth/menu"); - - bluetooth_service = new BluetoothService (); - bus.register_object ("/com/canonical/indicator/bluetooth/service", bluetooth_service); - - killswitch = new GnomeBluetooth.Killswitch (); - killswitch.state_changed.connect (killswitch_state_changed_cb); - - client = new GnomeBluetooth.Client (); - - menu = new Dbusmenu.Menuitem (); - menu_server.set_root (menu); - - enable_item = new Dbusmenu.Menuitem (); - enable_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Bluetooth")); - enable_item.property_set (Dbusmenu.MENUITEM_PROP_TYPE, "x-canonical-switch"); - enable_item.item_activated.connect (() => - { - if (updating_killswitch) - return; - if (killswitch.state == GnomeBluetooth.KillswitchState.UNBLOCKED) - killswitch.state = GnomeBluetooth.KillswitchState.SOFT_BLOCKED; - else - killswitch.state = GnomeBluetooth.KillswitchState.UNBLOCKED; - }); - menu.child_append (enable_item); - - visible_item = new Dbusmenu.Menuitem (); - visible_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Visible")); - visible_item.property_set (Dbusmenu.MENUITEM_PROP_TYPE, "x-canonical-switch"); - bool discoverable; - client.get ("default-adapter-discoverable", out discoverable); - visible_item.property_set_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE, discoverable ? Dbusmenu.MENUITEM_TOGGLE_STATE_CHECKED : Dbusmenu.MENUITEM_TOGGLE_STATE_UNCHECKED); - client.notify["default-adapter-discoverable"].connect (() => - { - updating_visible = true; - bool is_discoverable; - client.get ("default-adapter-discoverable", out is_discoverable); - visible_item.property_set_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE, is_discoverable ? Dbusmenu.MENUITEM_TOGGLE_STATE_CHECKED : Dbusmenu.MENUITEM_TOGGLE_STATE_UNCHECKED); - updating_visible = false; - }); - visible_item.item_activated.connect (() => - { - if (updating_visible) - return; - client.set ("default-adapter-discoverable", visible_item.property_get_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE) != Dbusmenu.MENUITEM_TOGGLE_STATE_CHECKED); - }); - menu.child_append (visible_item); - - devices_separator = new Dbusmenu.Menuitem (); - devices_separator.property_set (Dbusmenu.MENUITEM_PROP_TYPE, Dbusmenu.CLIENT_TYPES_SEPARATOR); - menu.child_append (devices_separator); - - device_items = new List (); - - client.model.row_inserted.connect (device_changed_cb); - client.model.row_changed.connect (device_changed_cb); - client.model.row_deleted.connect (device_removed_cb); - Gtk.TreeIter iter; - var have_iter = client.model.get_iter_first (out iter); - while (have_iter) - { - Gtk.TreeIter child_iter; - var have_child_iter = client.model.iter_children (out child_iter, iter); - while (have_child_iter) - { - device_changed_cb (null, child_iter); - have_child_iter = client.model.iter_next (ref child_iter); - } - have_iter = client.model.iter_next (ref iter); - } - - var sep = new Dbusmenu.Menuitem (); - sep.property_set (Dbusmenu.MENUITEM_PROP_TYPE, Dbusmenu.CLIENT_TYPES_SEPARATOR); - menu.child_append (sep); - - var item = new Dbusmenu.Menuitem (); - item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Set Up New Device…")); - item.item_activated.connect (() => { set_up_new_device (); }); - menu.child_append (item); - - item = new Dbusmenu.Menuitem (); - item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Bluetooth Settings…")); - item.item_activated.connect (() => { show_control_center ("bluetooth"); }); - menu.child_append (item); - - killswitch_state_changed_cb (killswitch.state); - - client.adapter_model.row_inserted.connect (update_visible); - client.adapter_model.row_deleted.connect (update_visible); - update_visible (); - } - - private BluetoothMenuItem? find_menu_item (string address) - { - foreach (var item in device_items) - if (item.address == address) - return item; - - return null; - } - - private void device_changed_cb (Gtk.TreePath? path, Gtk.TreeIter iter) - { - /* Ignore adapters */ - Gtk.TreeIter parent_iter; - if (!client.model.iter_parent (out parent_iter, iter)) - return; - - DBusProxy proxy; - string address; - string alias; - GnomeBluetooth.Type type; - string icon; - bool connected; - HashTable services; - string[] uuids; - client.model.get (iter, - GnomeBluetooth.Column.PROXY, out proxy, - GnomeBluetooth.Column.ADDRESS, out address, - GnomeBluetooth.Column.ALIAS, out alias, - GnomeBluetooth.Column.TYPE, out type, - GnomeBluetooth.Column.ICON, out icon, - GnomeBluetooth.Column.CONNECTED, out connected, - GnomeBluetooth.Column.SERVICES, out services, - GnomeBluetooth.Column.UUIDS, out uuids); - - /* Skip if haven't actually got any information yet */ - if (proxy == null) - return; - - /* Find or create menu item */ - var item = find_menu_item (address); - if (item == null) - { - item = new BluetoothMenuItem (client, address); - item.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, killswitch.state == GnomeBluetooth.KillswitchState.UNBLOCKED); - var last_item = devices_separator as Dbusmenu.Menuitem; - if (device_items != null) - last_item = device_items.last ().data; - device_items.append (item); - menu.child_add_position (item, last_item.get_position (menu) + 1); - } - - item.update (type, proxy, alias, icon, connected, services, uuids); - } - - private void update_visible () - { - bluetooth_service._visible = client.adapter_model.iter_n_children (null) > 0 && settings.get_boolean ("visible"); - var builder = new VariantBuilder (VariantType.ARRAY); - builder.add ("{sv}", "Visible", new Variant.boolean (bluetooth_service._visible)); - try - { - var properties = new Variant ("(sa{sv}as)", "com.canonical.indicator.bluetooth.service", builder, null); - bus.emit_signal (null, - "/com/canonical/indicator/bluetooth/service", - "org.freedesktop.DBus.Properties", - "PropertiesChanged", - properties); - } - catch (Error e) - { - warning ("Failed to emit signal: %s", e.message); - } - } - - private void device_removed_cb (Gtk.TreePath path) - { - Gtk.TreeIter iter; - if (!client.model.get_iter (out iter, path)) - return; - - string address; - client.model.get (iter, GnomeBluetooth.Column.ADDRESS, out address); - - var item = find_menu_item (address); - if (item == null) - return; - - device_items.remove (item); - menu.child_delete (item); - } - - private void killswitch_state_changed_cb (GnomeBluetooth.KillswitchState state) - { - updating_killswitch = true; - - var enabled = state == GnomeBluetooth.KillswitchState.UNBLOCKED; - - bluetooth_service._icon_name = enabled ? "bluetooth-active" : "bluetooth-disabled"; - bluetooth_service._accessible_description = enabled ? _("Bluetooth: On") : _("Bluetooth: Off"); - - var builder = new VariantBuilder (VariantType.ARRAY); - builder.add ("{sv}", "IconName", new Variant.string (bluetooth_service._icon_name)); - builder.add ("{sv}", "AccessibleDescription", new Variant.string (bluetooth_service._accessible_description)); - try - { - var properties = new Variant ("(sa{sv}as)", "com.canonical.indicator.bluetooth.service", builder, null); - bus.emit_signal (null, - "/com/canonical/indicator/bluetooth/service", - "org.freedesktop.DBus.Properties", - "PropertiesChanged", - properties); - } - catch (Error e) - { - warning ("Failed to emit signal: %s", e.message); - } - - enable_item.property_set_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE, enabled ? Dbusmenu.MENUITEM_TOGGLE_STATE_CHECKED : Dbusmenu.MENUITEM_TOGGLE_STATE_UNCHECKED); - - /* Disable devices when locked */ - visible_item.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, enabled); - devices_separator.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, enabled); - foreach (var item in device_items) - item.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, enabled && item.get_children () != null); - - updating_killswitch = false; - } -} - -private class BluetoothMenuItem : Dbusmenu.Menuitem -{ - private GnomeBluetooth.Client client; - public string address; - private Dbusmenu.Menuitem? connect_item = null; - private bool make_submenu = false; - - public BluetoothMenuItem (GnomeBluetooth.Client client, string address) - { - this.client = client; - this.address = address; - } - - public void update (GnomeBluetooth.Type type, DBusProxy proxy, string alias, string icon, bool connected, HashTable? services, string[] uuids) - { - property_set (Dbusmenu.MENUITEM_PROP_LABEL, alias); - property_set (Dbusmenu.MENUITEM_PROP_ICON_NAME, icon); - if (connect_item != null) - connect_item.property_set_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE, connected ? Dbusmenu.MENUITEM_TOGGLE_STATE_CHECKED : Dbusmenu.MENUITEM_TOGGLE_STATE_UNCHECKED); - - /* FIXME: Not sure if the GUI elements below can change over time */ - if (make_submenu) - return; - make_submenu = true; - - if (services != null) - { - connect_item = new Dbusmenu.Menuitem (); - connect_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Connection")); - connect_item.property_set (Dbusmenu.MENUITEM_PROP_TYPE, "x-canonical-switch"); - connect_item.property_set_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE, connected ? Dbusmenu.MENUITEM_TOGGLE_STATE_CHECKED : Dbusmenu.MENUITEM_TOGGLE_STATE_UNCHECKED); - connect_item.item_activated.connect (() => { connect_service (proxy.get_object_path (), connect_item.property_get_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE) != Dbusmenu.MENUITEM_TOGGLE_STATE_CHECKED); }); - child_append (connect_item); - } - - var can_send = false; - var can_browse = false; - if (uuids != null) - { - for (var i = 0; uuids[i] != null; i++) - { - if (uuids[i] == "OBEXObjectPush") - can_send = true; - if (uuids[i] == "OBEXFileTransfer") - can_browse = true; - } - } - - if (can_send) - { - var send_item = new Dbusmenu.Menuitem (); - send_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Send files…")); - send_item.item_activated.connect (() => { GnomeBluetooth.send_to_address (address, alias); }); - child_append (send_item); - } - - if (can_browse) - { - var browse_item = new Dbusmenu.Menuitem (); - browse_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Browse files…")); - browse_item.item_activated.connect (() => { GnomeBluetooth.browse_address (null, address, Gdk.CURRENT_TIME, null); }); - child_append (browse_item); - } - - switch (type) - { - case GnomeBluetooth.Type.KEYBOARD: - var keyboard_item = new Dbusmenu.Menuitem (); - keyboard_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Keyboard Settings…")); - keyboard_item.item_activated.connect (() => { show_control_center ("keyboard"); }); - child_append (keyboard_item); - break; - - case GnomeBluetooth.Type.MOUSE: - case GnomeBluetooth.Type.TABLET: - var mouse_item = new Dbusmenu.Menuitem (); - mouse_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Mouse and Touchpad Settings…")); - mouse_item.item_activated.connect (() => { show_control_center ("mouse"); }); - child_append (mouse_item); - break; - - case GnomeBluetooth.Type.HEADSET: - case GnomeBluetooth.Type.HEADPHONES: - case GnomeBluetooth.Type.OTHER_AUDIO: - var sound_item = new Dbusmenu.Menuitem (); - sound_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Sound Settings…")); - sound_item.item_activated.connect (() => { show_control_center ("sound"); }); - child_append (sound_item); - break; - } - - property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, get_children () != null); - } - - private void connect_service (string device, bool connect) - { - client.connect_service.begin (device, connect, null, (object, result) => - { - var connected = false; - try - { - connected = client.connect_service.end (result); - } - catch (Error e) - { - warning ("Failed to connect service: %s", e.message); - } - }); - } -} - -private void set_up_new_device () -{ - try - { - Process.spawn_command_line_async ("bluetooth-wizard"); - } - catch (GLib.SpawnError e) - { - warning ("Failed to open bluetooth-wizard: %s", e.message); - } -} - -private void show_control_center (string panel) -{ - try - { - Process.spawn_command_line_async ("gnome-control-center %s".printf (panel)); - } - catch (GLib.SpawnError e) - { - warning ("Failed to open control center: %s", e.message); - } -} - -[DBus (name = "com.canonical.indicator.bluetooth.service")] -private class BluetoothService : Object -{ - internal bool _visible = false; - public bool visible - { - get { return _visible; } - } - internal string _icon_name = "bluetooth-active"; - public string icon_name - { - get { return _icon_name; } - } - internal string _accessible_description = _("Bluetooth"); - public string accessible_description - { - get { return _accessible_description; } - } -} diff --git a/src/indicator-bluetooth.vala b/src/indicator-bluetooth.vala deleted file mode 100644 index bfbbc9f..0000000 --- a/src/indicator-bluetooth.vala +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (C) 2012-2013 Canonical Ltd. - * Author: Robert Ancell - * - * This program is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, version 3 of the License. - * See http://www.gnu.org/copyleft/gpl.html the full text of the license. - */ - -public class BluetoothIndicator : Indicator.Object -{ - private Indicator.ServiceManager service; - private Gtk.Image image; - private DbusmenuGtk.Menu menu; - private BluetoothService proxy; - private string accessible_description = _("Bluetooth: On"); - - construct - { - service = new Indicator.ServiceManager ("com.canonical.indicator.bluetooth"); - service.connection_change.connect (connection_change_cb); - menu = new DbusmenuGtk.Menu ("com.canonical.indicator.bluetooth", "/com/canonical/indicator/bluetooth/menu"); - image = Indicator.image_helper ("bluetooth-active"); - image.visible = true; - - var menu_client = menu.get_client (); - menu_client.add_type_handler_full ("x-canonical-switch", new_switch_cb); - - /* Hide until ready */ - set_visible (false); - } - - private bool new_switch_cb (Dbusmenu.Menuitem newitem, Dbusmenu.Menuitem parent, Dbusmenu.Client client) - { - var item = new Switch (newitem); - (client as DbusmenuGtk.Client).newitem_base (newitem, item, parent); - return true; - } - - public override unowned Gtk.Image get_image () - { - return image; - } - - public override unowned Gtk.Menu get_menu () - { - return menu; - } - - public override unowned string get_accessible_desc () - { - return accessible_description; - } - - private void connection_change_cb (bool connected) - { - if (!connected) - return; - - // FIXME: Set proxy to null on disconnect? - // FIXME: Use Cancellable to cancel existing connection - if (proxy == null) - { - Bus.get_proxy.begin (BusType.SESSION, - "com.canonical.indicator.bluetooth", - "/com/canonical/indicator/bluetooth/service", - DBusProxyFlags.NONE, null, (object, result) => - { - try - { - proxy = Bus.get_proxy.end (result); - proxy.g_properties_changed.connect (server_properties_changed_cb); - server_properties_changed_cb (); - } - catch (IOError e) - { - warning ("Failed to connect to bluetooth service: %s", e.message); - } - }); - } - } - - private void server_properties_changed_cb () - { - set_visible (proxy.visible); - Indicator.image_helper_update (image, proxy.icon_name); - accessible_description = proxy.accessible_description; - } -} - -public class Switch : Ido.SwitchMenuItem -{ - public Dbusmenu.Menuitem menuitem; - public new Gtk.Label label; - private bool updating_switch = false; - - public Switch (Dbusmenu.Menuitem menuitem) - { - this.menuitem = menuitem; - label = new Gtk.Label (""); - label.visible = true; - content_area.add (label); - - /* Be the first listener to the activate signal so we can stop it - * emitting when we change the state. Without this you get feedback loops */ - activate.connect (() => - { - if (updating_switch) - Signal.stop_emission_by_name (this, "activate"); - }); - - menuitem.property_changed.connect ((mi, prop, value) => { update (); }); - update (); - } - - private void update () - { - updating_switch = true; - label.label = menuitem.property_get (Dbusmenu.MENUITEM_PROP_LABEL); - active = menuitem.property_get_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE) == Dbusmenu.MENUITEM_TOGGLE_STATE_CHECKED; - updating_switch = false; - } -} - -[DBus (name = "com.canonical.indicator.bluetooth.service")] -public interface BluetoothService : DBusProxy -{ - public abstract bool visible { owned get; } - public abstract string icon_name { owned get; } - public abstract string accessible_description { owned get; } -} - -public static string get_version () -{ - return Indicator.VERSION; -} - -public static GLib.Type get_type () -{ - return typeof (BluetoothIndicator); -} diff --git a/src/main.vala b/src/main.vala index 79683b2..1df55c3 100644 --- a/src/main.vala +++ b/src/main.vala @@ -7,21 +7,8 @@ main (string[] args) Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.GNOMELOCALEDIR); Intl.textdomain (Config.GETTEXT_PACKAGE); - var loop = new MainLoop (); + var service = new BluetoothIndicator (); + service.run (); - BluetoothIndicator indicator; - try - { - indicator = new BluetoothIndicator (); - } - catch (Error e) - { - warning ("Failed to start bluetooth indicator service: %s", e.message); - return Posix.EXIT_FAILURE; - } - - loop.run (); return Posix.EXIT_SUCCESS; } - //var service = new IndicatorSound.Service (); - //return service.run (); diff --git a/src/menu.vala b/src/menu.vala new file mode 100644 index 0000000..a2c5449 --- /dev/null +++ b/src/menu.vala @@ -0,0 +1,53 @@ +/* + * Copyright 2013 Canonical Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authors: + * Charles Kerr + */ + +class BluetoothMenu: Object +{ + protected Menu root; + protected Menu menu; + + public virtual void add_actions_to_group (SimpleActionGroup group) + { + } + + public BluetoothMenu (string profile) + { + this.menu = new Menu (); + + var root_item = new MenuItem (null, "indicator.root-" + profile); + root_item.set_attribute ("x-canonical-type", "s", "com.canonical.indicator.root"); + root_item.set_submenu (this.menu); + + this.root = new Menu (); + this.root.append_item (root_item); + } + + public void export (DBusConnection connection, string object_path) + { + try + { + message ("exporting on %s", object_path); + connection.export_menu_model (object_path, this.root); + } + catch (Error e) + { + critical ("%s", e.message); + } + } +} diff --git a/src/phone.vala b/src/phone.vala new file mode 100644 index 0000000..2abcf11 --- /dev/null +++ b/src/phone.vala @@ -0,0 +1,76 @@ +/* + * Copyright 2013 Canonical Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authors: + * Charles Kerr + */ + +class PhoneMenu: BluetoothMenu +{ + private Action[] actions; + + public override void add_actions_to_group (SimpleActionGroup group) + { + base.add_actions_to_group (group); + + for (var i=0; i { + try { + Process.spawn_command_line_async ("system-settings bluetooth"); + } catch (Error e) { + warning ("unable to launch settings: %s", e.message); + } + }); + + return action; + } + + protected Variant action_state_for_root () + { + var label = "Hello World"; // FIXME + var a11y = "Hello World"; // FIXME + var visible = true; // FIXME + + string icon_name = "bluetooth"; // FIXME: enabled, disabled, connected, etc. + var icon = new ThemedIcon.with_default_fallbacks (icon_name); + + var builder = new VariantBuilder (new VariantType ("a{sv}")); + builder.add ("{sv}", "visible", new Variant ("b", visible)); + builder.add ("{sv}", "label", new Variant ("s", label)); + builder.add ("{sv}", "accessible-desc", new Variant ("s", a11y)); + builder.add ("{sv}", "icon", icon.serialize()); + return builder.end (); + } +} diff --git a/src/service.vala b/src/service.vala new file mode 100644 index 0000000..b6ae0f3 --- /dev/null +++ b/src/service.vala @@ -0,0 +1,470 @@ +/* + * Copyright (C) 2012-2013 Canonical Ltd. + * Author: Robert Ancell + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, version 3 of the License. + * See http://www.gnu.org/copyleft/gpl.html the full text of the license. + */ + +public class BluetoothIndicator +{ + private MainLoop loop; + private SimpleActionGroup actions; + private HashTable menus; + + private DBusConnection bus; + private Indicator.Service indicator_service; + private Dbusmenu.Server menu_server; + private BluetoothService bluetooth_service; + private GnomeBluetooth.Client client; + private GnomeBluetooth.Killswitch killswitch; + private bool updating_killswitch = false; + private Dbusmenu.Menuitem enable_item; + private Dbusmenu.Menuitem visible_item; + private bool updating_visible = false; + private Dbusmenu.Menuitem devices_separator; + private List device_items; + private Dbusmenu.Menuitem menu; + + public BluetoothIndicator () throws Error + { + var phone = new PhoneMenu (); + var desktop = new DesktopMenu (); + + this.menus = new HashTable (str_hash, str_equal); + this.menus.insert ("phone", phone); + this.menus.insert ("desktop", desktop); + + this.actions = new SimpleActionGroup (); + phone.add_actions_to_group (this.actions); + desktop.add_actions_to_group (this.actions); + } + + private void init_for_bus (DBusConnection bus) + { + this.bus = bus; + + indicator_service = new Indicator.Service ("com.canonical.indicator.bluetooth.old"); + menu_server = new Dbusmenu.Server ("/com/canonical/indicator/bluetooth/menu"); + + bluetooth_service = new BluetoothService (); + bus.register_object ("/com/canonical/indicator/bluetooth/service", bluetooth_service); + + killswitch = new GnomeBluetooth.Killswitch (); + killswitch.state_changed.connect (killswitch_state_changed_cb); + + client = new GnomeBluetooth.Client (); + + menu = new Dbusmenu.Menuitem (); + menu_server.set_root (menu); + + enable_item = new Dbusmenu.Menuitem (); + enable_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Bluetooth")); + enable_item.property_set (Dbusmenu.MENUITEM_PROP_TYPE, "x-canonical-switch"); + enable_item.item_activated.connect (() => + { + if (updating_killswitch) + return; + if (killswitch.state == GnomeBluetooth.KillswitchState.UNBLOCKED) + killswitch.state = GnomeBluetooth.KillswitchState.SOFT_BLOCKED; + else + killswitch.state = GnomeBluetooth.KillswitchState.UNBLOCKED; + }); + menu.child_append (enable_item); + + visible_item = new Dbusmenu.Menuitem (); + visible_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Visible")); + visible_item.property_set (Dbusmenu.MENUITEM_PROP_TYPE, "x-canonical-switch"); + bool discoverable; + client.get ("default-adapter-discoverable", out discoverable); + visible_item.property_set_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE, discoverable ? Dbusmenu.MENUITEM_TOGGLE_STATE_CHECKED : Dbusmenu.MENUITEM_TOGGLE_STATE_UNCHECKED); + client.notify["default-adapter-discoverable"].connect (() => + { + updating_visible = true; + bool is_discoverable; + client.get ("default-adapter-discoverable", out is_discoverable); + visible_item.property_set_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE, is_discoverable ? Dbusmenu.MENUITEM_TOGGLE_STATE_CHECKED : Dbusmenu.MENUITEM_TOGGLE_STATE_UNCHECKED); + updating_visible = false; + }); + visible_item.item_activated.connect (() => + { + if (updating_visible) + return; + client.set ("default-adapter-discoverable", visible_item.property_get_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE) != Dbusmenu.MENUITEM_TOGGLE_STATE_CHECKED); + }); + menu.child_append (visible_item); + + devices_separator = new Dbusmenu.Menuitem (); + devices_separator.property_set (Dbusmenu.MENUITEM_PROP_TYPE, Dbusmenu.CLIENT_TYPES_SEPARATOR); + menu.child_append (devices_separator); + + device_items = new List (); + + client.model.row_inserted.connect (device_changed_cb); + client.model.row_changed.connect (device_changed_cb); + client.model.row_deleted.connect (device_removed_cb); + Gtk.TreeIter iter; + var have_iter = client.model.get_iter_first (out iter); + while (have_iter) + { + Gtk.TreeIter child_iter; + var have_child_iter = client.model.iter_children (out child_iter, iter); + while (have_child_iter) + { + device_changed_cb (null, child_iter); + have_child_iter = client.model.iter_next (ref child_iter); + } + have_iter = client.model.iter_next (ref iter); + } + + var sep = new Dbusmenu.Menuitem (); + sep.property_set (Dbusmenu.MENUITEM_PROP_TYPE, Dbusmenu.CLIENT_TYPES_SEPARATOR); + menu.child_append (sep); + + var item = new Dbusmenu.Menuitem (); + item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Set Up New Device…")); + item.item_activated.connect (() => { set_up_new_device (); }); + menu.child_append (item); + + item = new Dbusmenu.Menuitem (); + item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Bluetooth Settings…")); + item.item_activated.connect (() => { show_control_center ("bluetooth"); }); + menu.child_append (item); + + killswitch_state_changed_cb (killswitch.state); + + client.adapter_model.row_inserted.connect (update_visible); + client.adapter_model.row_deleted.connect (update_visible); + update_visible (); + } + + public int run () + { + if (this.loop != null) + { + warning ("service is already running"); + return 1; + } + + Bus.own_name (BusType.SESSION, + "com.canonical.indicator.bluetooth", + BusNameOwnerFlags.NONE, + this.on_bus_acquired, + null, + this.on_name_lost); + + this.loop = new MainLoop (null, false); + this.loop.run (); + return 0; + } + + void on_bus_acquired (DBusConnection connection, string name) + { + stdout.printf ("bus acquired: %s\n", name); + + init_for_bus (connection); + + try + { + connection.export_action_group ("/com/canonical/indicator/bluetooth", this.actions); + } + catch (Error e) + { + critical ("%s", e.message); + } + + this.menus.@foreach ( (profile, menu) => menu.export (connection, @"/com/canonical/indicator/bluetooth/$profile")); + } + + void on_name_lost (DBusConnection connection, string name) + { + stdout.printf ("name lost: %s\n", name); + this.loop.quit (); + } + + + private BluetoothMenuItem? find_menu_item (string address) + { + foreach (var item in device_items) + if (item.address == address) + return item; + + return null; + } + + private void device_changed_cb (Gtk.TreePath? path, Gtk.TreeIter iter) + { + /* Ignore adapters */ + Gtk.TreeIter parent_iter; + if (!client.model.iter_parent (out parent_iter, iter)) + return; + + DBusProxy proxy; + string address; + string alias; + GnomeBluetooth.Type type; + string icon; + bool connected; + HashTable services; + string[] uuids; + client.model.get (iter, + GnomeBluetooth.Column.PROXY, out proxy, + GnomeBluetooth.Column.ADDRESS, out address, + GnomeBluetooth.Column.ALIAS, out alias, + GnomeBluetooth.Column.TYPE, out type, + GnomeBluetooth.Column.ICON, out icon, + GnomeBluetooth.Column.CONNECTED, out connected, + GnomeBluetooth.Column.SERVICES, out services, + GnomeBluetooth.Column.UUIDS, out uuids); + + /* Skip if haven't actually got any information yet */ + if (proxy == null) + return; + + /* Find or create menu item */ + var item = find_menu_item (address); + if (item == null) + { + item = new BluetoothMenuItem (client, address); + item.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, killswitch.state == GnomeBluetooth.KillswitchState.UNBLOCKED); + var last_item = devices_separator as Dbusmenu.Menuitem; + if (device_items != null) + last_item = device_items.last ().data; + device_items.append (item); + menu.child_add_position (item, last_item.get_position (menu) + 1); + } + + item.update (type, proxy, alias, icon, connected, services, uuids); + } + + private void update_visible () + { + bluetooth_service._visible = client.adapter_model.iter_n_children (null) > 0;// && settings.get_boolean ("visible"); + var builder = new VariantBuilder (VariantType.ARRAY); + builder.add ("{sv}", "Visible", new Variant.boolean (bluetooth_service._visible)); + try + { + var properties = new Variant ("(sa{sv}as)", "com.canonical.indicator.bluetooth.service", builder, null); + bus.emit_signal (null, + "/com/canonical/indicator/bluetooth/service", + "org.freedesktop.DBus.Properties", + "PropertiesChanged", + properties); + } + catch (Error e) + { + warning ("Failed to emit signal: %s", e.message); + } + } + + private void device_removed_cb (Gtk.TreePath path) + { + Gtk.TreeIter iter; + if (!client.model.get_iter (out iter, path)) + return; + + string address; + client.model.get (iter, GnomeBluetooth.Column.ADDRESS, out address); + + var item = find_menu_item (address); + if (item == null) + return; + + device_items.remove (item); + menu.child_delete (item); + } + + private void killswitch_state_changed_cb (GnomeBluetooth.KillswitchState state) + { + updating_killswitch = true; + + var enabled = state == GnomeBluetooth.KillswitchState.UNBLOCKED; + + bluetooth_service._icon_name = enabled ? "bluetooth-active" : "bluetooth-disabled"; + bluetooth_service._accessible_description = enabled ? _("Bluetooth: On") : _("Bluetooth: Off"); + + var builder = new VariantBuilder (VariantType.ARRAY); + builder.add ("{sv}", "IconName", new Variant.string (bluetooth_service._icon_name)); + builder.add ("{sv}", "AccessibleDescription", new Variant.string (bluetooth_service._accessible_description)); + try + { + var properties = new Variant ("(sa{sv}as)", "com.canonical.indicator.bluetooth.service", builder, null); + bus.emit_signal (null, + "/com/canonical/indicator/bluetooth/service", + "org.freedesktop.DBus.Properties", + "PropertiesChanged", + properties); + } + catch (Error e) + { + warning ("Failed to emit signal: %s", e.message); + } + + enable_item.property_set_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE, enabled ? Dbusmenu.MENUITEM_TOGGLE_STATE_CHECKED : Dbusmenu.MENUITEM_TOGGLE_STATE_UNCHECKED); + + /* Disable devices when locked */ + visible_item.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, enabled); + devices_separator.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, enabled); + foreach (var item in device_items) + item.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, enabled && item.get_children () != null); + + updating_killswitch = false; + } +} + +private class BluetoothMenuItem : Dbusmenu.Menuitem +{ + private GnomeBluetooth.Client client; + public string address; + private Dbusmenu.Menuitem? connect_item = null; + private bool make_submenu = false; + + public BluetoothMenuItem (GnomeBluetooth.Client client, string address) + { + this.client = client; + this.address = address; + } + + public void update (GnomeBluetooth.Type type, DBusProxy proxy, string alias, string icon, bool connected, HashTable? services, string[] uuids) + { + property_set (Dbusmenu.MENUITEM_PROP_LABEL, alias); + property_set (Dbusmenu.MENUITEM_PROP_ICON_NAME, icon); + if (connect_item != null) + connect_item.property_set_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE, connected ? Dbusmenu.MENUITEM_TOGGLE_STATE_CHECKED : Dbusmenu.MENUITEM_TOGGLE_STATE_UNCHECKED); + + /* FIXME: Not sure if the GUI elements below can change over time */ + if (make_submenu) + return; + make_submenu = true; + + if (services != null) + { + connect_item = new Dbusmenu.Menuitem (); + connect_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Connection")); + connect_item.property_set (Dbusmenu.MENUITEM_PROP_TYPE, "x-canonical-switch"); + connect_item.property_set_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE, connected ? Dbusmenu.MENUITEM_TOGGLE_STATE_CHECKED : Dbusmenu.MENUITEM_TOGGLE_STATE_UNCHECKED); + connect_item.item_activated.connect (() => { connect_service (proxy.get_object_path (), connect_item.property_get_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE) != Dbusmenu.MENUITEM_TOGGLE_STATE_CHECKED); }); + child_append (connect_item); + } + + var can_send = false; + var can_browse = false; + if (uuids != null) + { + for (var i = 0; uuids[i] != null; i++) + { + if (uuids[i] == "OBEXObjectPush") + can_send = true; + if (uuids[i] == "OBEXFileTransfer") + can_browse = true; + } + } + + if (can_send) + { + var send_item = new Dbusmenu.Menuitem (); + send_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Send files…")); + send_item.item_activated.connect (() => { GnomeBluetooth.send_to_address (address, alias); }); + child_append (send_item); + } + + if (can_browse) + { + var browse_item = new Dbusmenu.Menuitem (); + browse_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Browse files…")); + browse_item.item_activated.connect (() => { GnomeBluetooth.browse_address (null, address, Gdk.CURRENT_TIME, null); }); + child_append (browse_item); + } + + switch (type) + { + case GnomeBluetooth.Type.KEYBOARD: + var keyboard_item = new Dbusmenu.Menuitem (); + keyboard_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Keyboard Settings…")); + keyboard_item.item_activated.connect (() => { show_control_center ("keyboard"); }); + child_append (keyboard_item); + break; + + case GnomeBluetooth.Type.MOUSE: + case GnomeBluetooth.Type.TABLET: + var mouse_item = new Dbusmenu.Menuitem (); + mouse_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Mouse and Touchpad Settings…")); + mouse_item.item_activated.connect (() => { show_control_center ("mouse"); }); + child_append (mouse_item); + break; + + case GnomeBluetooth.Type.HEADSET: + case GnomeBluetooth.Type.HEADPHONES: + case GnomeBluetooth.Type.OTHER_AUDIO: + var sound_item = new Dbusmenu.Menuitem (); + sound_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Sound Settings…")); + sound_item.item_activated.connect (() => { show_control_center ("sound"); }); + child_append (sound_item); + break; + } + + property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, get_children () != null); + } + + private void connect_service (string device, bool connect) + { + client.connect_service.begin (device, connect, null, (object, result) => + { + var connected = false; + try + { + connected = client.connect_service.end (result); + } + catch (Error e) + { + warning ("Failed to connect service: %s", e.message); + } + }); + } +} + +private void set_up_new_device () +{ + try + { + Process.spawn_command_line_async ("bluetooth-wizard"); + } + catch (GLib.SpawnError e) + { + warning ("Failed to open bluetooth-wizard: %s", e.message); + } +} + +private void show_control_center (string panel) +{ + try + { + Process.spawn_command_line_async ("gnome-control-center %s".printf (panel)); + } + catch (GLib.SpawnError e) + { + warning ("Failed to open control center: %s", e.message); + } +} + +[DBus (name = "com.canonical.indicator.bluetooth.service")] +private class BluetoothService : Object +{ + internal bool _visible = false; + public bool visible + { + get { return _visible; } + } + internal string _icon_name = "bluetooth-active"; + public string icon_name + { + get { return _icon_name; } + } + internal string _accessible_description = _("Bluetooth"); + public string accessible_description + { + get { return _accessible_description; } + } +} diff --git a/vapi/gnome-bluetooth-1.0.vapi b/vapi/gnome-bluetooth-1.0.vapi new file mode 100644 index 0000000..6d6aa09 --- /dev/null +++ b/vapi/gnome-bluetooth-1.0.vapi @@ -0,0 +1,82 @@ +[CCode (cprefix = "Bluetooth", lower_case_cprefix = "bluetooth_")] +namespace GnomeBluetooth +{ + +[CCode (cheader_filename = "bluetooth-client.h")] +public class Client : GLib.Object +{ + public Client (); + public Gtk.TreeModel model { get; } + public Gtk.TreeModel adapter_model { get; } + public Gtk.TreeModel device_model { get; } + [CCode (finish_function = "bluetooth_client_connect_service_finish")] + public async bool connect_service (string device, bool connect, GLib.Cancellable? cancellable = null) throws GLib.Error; +} + +[CCode (cheader_filename = "bluetooth-enums.h", cprefix = "BLUETOOTH_COLUMN_")] +public enum Column +{ + PROXY, + ADDRESS, + ALIAS, + NAME, + TYPE, + ICON, + DEFAULT, + PAIRED, + TRUSTED, + CONNECTED, + DISCOVERABLE, + DISCOVERING, + LEGACYPAIRING, + POWERED, + SERVICES, + UUIDS +} + +[CCode (cheader_filename = "bluetooth-enums.h", cprefix = "BLUETOOTH_TYPE_")] +public enum Type +{ + ANY, + PHONE, + MODEM, + COMPUTER, + NETWORK, + HEADSET, + HEADPHONES, + OTHER_AUDIO, + KEYBOARD, + MOUSE, + CAMERA, + PRINTER, + JOYPAD, + TABLET, + VIDEO +} + +[CCode (cheader_filename = "bluetooth-utils.h")] +public void browse_address (GLib.Object? object, string address, uint timestamp, GLib.AsyncReadyCallback? callback); + +[CCode (cheader_filename = "bluetooth-utils.h")] +public void send_to_address (string address, string alias); + +[CCode (cheader_filename = "bluetooth-killswitch.h", cprefix = "BLUETOOTH_KILLSWITCH_STATE_")] +public enum KillswitchState +{ + NO_ADAPTER, + SOFT_BLOCKED, + UNBLOCKED, + HARD_BLOCKED +} + +[CCode (cheader_filename = "bluetooth-killswitch.h")] +public class Killswitch : GLib.Object +{ + public Killswitch (); + public signal void state_changed (KillswitchState state); + public bool has_killswitches (); + public KillswitchState state { get; set; } + public unowned string state_to_string (); +} + +} -- cgit v1.2.3 From cf894302767d5ec483b5f8002bb796a284895bbf Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 1 Aug 2013 18:21:05 -0500 Subject: add a bluetooth backend to track bluetooth being enabled, being hard/soft blocked, and its devices. --- Makefile.am | 6 +- configure.ac | 8 -- data/Makefile.am | 2 +- debian/control | 2 - src/Makefile.am | 5 + src/bluetooth.vala | 53 ++++++++++ src/bluez.vala | 97 +++++++++++++++++ src/desktop.vala | 121 +++++++++++++++------ src/killswitch.vala | 147 ++++++++++++++++++++++++++ src/libido3-0.1.vapi | 10 -- src/main.vala | 4 +- src/org-bluez.vala | 293 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/phone.vala | 2 +- src/service.vala | 21 ++-- vapi/rfkill.vapi | 44 ++++++++ 15 files changed, 748 insertions(+), 67 deletions(-) create mode 100644 src/bluetooth.vala create mode 100644 src/bluez.vala create mode 100644 src/killswitch.vala delete mode 100644 src/libido3-0.1.vapi create mode 100644 src/org-bluez.vala create mode 100644 vapi/rfkill.vapi (limited to 'vapi') diff --git a/Makefile.am b/Makefile.am index 4fa38ad..31ba5e2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,9 @@ SUBDIRS = data po src -EXTRA_DIST = autogen.sh NEWS +EXTRA_DIST = \ + autogen.sh \ + NEWS \ + vapi/rfkill.vapi \ + vapi/config.vapi DISTCHECK_CONFIGURE_FLAGS = --enable-localinstall diff --git a/configure.ac b/configure.ac index 3179a1e..15f09ef 100644 --- a/configure.ac +++ b/configure.ac @@ -21,14 +21,6 @@ PKG_CHECK_MODULES(INDICATOR_BLUETOOTH_SERVICE, [ dbusmenu-gtk3-0.4 ]) -PKG_CHECK_MODULES(INDICATOR_BLUETOOTH, [ - glib-2.0 - gtk+-3.0 - indicator3-0.4 - dbusmenu-gtk3-0.4 - libido3-0.1 -]) - dnl ############################## dnl # Custom Junk dnl ############################## diff --git a/data/Makefile.am b/data/Makefile.am index d5f40aa..fc726a7 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -1,7 +1,7 @@ # the indicator bus file indicatorsdir = $(prefix)/share/unity/indicators -dist_indicators_DATA = com.canonical.indicator.datetime +dist_indicators_DATA = com.canonical.indicator.bluetooth # the dbus service file dbus_servicesdir = $(datadir)/dbus-1/services diff --git a/debian/control b/debian/control index 07bc74d..a08015d 100644 --- a/debian/control +++ b/debian/control @@ -8,9 +8,7 @@ Build-Depends: debhelper (>= 9.0), gnome-common, libdbusmenu-gtk3-dev, libglib2.0-dev, - libgnome-bluetooth-dev, libgtk-3-dev, - libido3-0.1-dev, libindicator3-dev, valac (>=0.18), Standards-Version: 3.9.4 diff --git a/src/Makefile.am b/src/Makefile.am index ed2c976..720c981 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -2,10 +2,14 @@ pkglibexec_PROGRAMS = indicator-bluetooth-service indicator_bluetooth_service_SOURCES = \ indicator3-0.4.vapi \ + org-bluez.vala \ + bluetooth.vala \ + bluez.vala \ desktop.vala \ main.vala \ menu.vala \ phone.vala \ + killswitch.vala \ service.vala indicator_bluetooth_service_VALAFLAGS = \ @@ -14,6 +18,7 @@ indicator_bluetooth_service_VALAFLAGS = \ --vapidir=./ \ --pkg gnome-bluetooth-1.0 \ --pkg config \ + --pkg rfkill \ --pkg posix \ --pkg glib-2.0 \ --pkg gtk+-3.0 \ diff --git a/src/bluetooth.vala b/src/bluetooth.vala new file mode 100644 index 0000000..ad5ee09 --- /dev/null +++ b/src/bluetooth.vala @@ -0,0 +1,53 @@ +/* + * Copyright 2013 Canonical Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authors: + * Charles Kerr + */ + +public class Bluetooth: Object +{ + /*** + **** Properties + ***/ + + public bool discoverable { get; protected set; default = false; } + public virtual void try_set_discoverable (bool b) {} + + public bool powered { get; protected set; default = false; } + + public bool blocked { get; protected set; default = true; } + public virtual void try_set_blocked (bool b) { + kill_switch.try_set_blocked (b); + } + + /*** + **** Killswitch Implementation + ***/ + + protected KillSwitch kill_switch; + + public Bluetooth (KillSwitch kill_switch) + { + this.kill_switch = kill_switch; + + message ("changing blocked to %d", (int)!this.kill_switch.blocked); + blocked = this.kill_switch.blocked; + kill_switch.notify["blocked"].connect (() => { + message ("bluetooth changing blocked to %d", (int)kill_switch.blocked); + this.blocked = kill_switch.blocked; + }); + } +} diff --git a/src/bluez.vala b/src/bluez.vala new file mode 100644 index 0000000..178cc57 --- /dev/null +++ b/src/bluez.vala @@ -0,0 +1,97 @@ +/* + * Copyright 2013 Canonical Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authors: + * Charles Kerr + */ + +public class Bluez: Bluetooth +{ + private org.bluez.Manager manager; + private org.bluez.Adapter default_adapter; + + public Bluez (KillSwitch kill_switch) + { + string default_adapter_object_path = null; + + base (kill_switch); + + try + { + manager = Bus.get_proxy_sync (BusType.SYSTEM, "org.bluez", "/"); + + manager.default_adapter_changed.connect ((object_path) => on_default_adapter_changed (object_path)); + default_adapter_object_path = manager.default_adapter (); + } + catch (Error e) + { + critical ("%s", e.message); + } + + on_default_adapter_changed (default_adapter_object_path); + } + + private void on_default_adapter_changed (string? object_path) + { + if (object_path != null) try + { + message ("using default adapter at %s", object_path); + this.default_adapter = Bus.get_proxy_sync (BusType.SYSTEM, "org.bluez", object_path); + this.default_adapter.property_changed.connect(() => this.on_default_adapter_properties_changed()); + } + catch (Error e) + { + critical ("%s", e.message); + } + + this.on_default_adapter_properties_changed (); + } + + private void on_default_adapter_properties_changed () + { + bool is_discoverable = false; + bool is_powered = false; + + if (this.default_adapter != null) try + { + var properties = this.default_adapter.get_properties(); + + var v = properties.lookup("Discoverable"); + is_discoverable = (v != null) && v.get_boolean (); + + v = properties.lookup("Powered"); + is_powered = (v != null) && v.get_boolean (); + } + catch (Error e) + { + critical ("%s", e.message); + } + + this.powered = is_powered; + this.discoverable = is_discoverable; + } + + public override void try_set_discoverable (bool b) + { + if (discoverable != b) try + { + this.default_adapter.set_property ("Discoverable", new Variant.boolean(b)); + } + catch (Error e) + { + critical ("%s", e.message); + } + } +} diff --git a/src/desktop.vala b/src/desktop.vala index bd005f5..351770a 100644 --- a/src/desktop.vala +++ b/src/desktop.vala @@ -20,80 +20,133 @@ class DesktopMenu: BluetoothMenu { private Settings settings; + private Bluetooth bluetooth; - private Action[] actions; + private SimpleAction root_action; + private Action[] all_actions; public override void add_actions_to_group (SimpleActionGroup group) { base.add_actions_to_group (group); - for (var i=0; i { message("visible toggled"); }); - this.actions = {}; - this.actions += new SimpleAction.stateful ("root-desktop", null, action_state_for_root()); - this.actions += create_settings_action (); - this.actions += create_wizard_action (); + this.root_action = new SimpleAction.stateful ("root-desktop", null, action_state_for_root()); + + this.all_actions = {}; + this.all_actions += this.root_action; + this.all_actions += create_enabled_action (bluetooth); + this.all_actions += create_discoverable_action (bluetooth); + this.all_actions += create_settings_action (); + this.all_actions += create_wizard_action (); + + bluetooth.notify.connect (() => this.update_root_action_state()); + settings.changed["visible"].connect (()=> this.update_root_action_state()); + + Menu section; + MenuItem item; - var section = new Menu (); + section = new Menu (); + item = new MenuItem ("Bluetooth", "indicator.desktop-enabled"); + item.set_attribute ("x-canonical-type", "s", "com.canonical.indicator.switch"); + section.append_item (item); + item = new MenuItem ("Visible", "indicator.desktop-discoverable"); + item.set_attribute ("x-canonical-type", "s", "com.canonical.indicator.switch"); + section.append_item (item); + this.menu.append_section (null, section); + + section = new Menu (); section.append (_("Set Up New Device…"), "indicator.desktop-wizard"); section.append (_("Bluetooth Settings…"), "indicator.desktop-settings"); this.menu.append_section (null, section); } - Action create_wizard_action () + Action create_enabled_action (Bluetooth bluetooth) { - var action = new SimpleAction ("desktop-wizard", null); + var action = new SimpleAction.stateful ("desktop-enabled", null, !bluetooth.blocked); + action.activate.connect (() => action.set_state (!action.get_state().get_boolean())); + action.notify["state"].connect (() => bluetooth.try_set_blocked (!action.get_state().get_boolean())); + bluetooth.notify["blocked"].connect (() => action.set_state (!bluetooth.blocked)); + return action; + } - action.activate.connect ((action, param) => { - try { - Process.spawn_command_line_async ("bluetooth-wizard"); - } catch (Error e) { - warning ("unable to launch settings: %s", e.message); - } - }); + Action create_discoverable_action (Bluetooth bluetooth) + { + var action = new SimpleAction.stateful ("desktop-discoverable", null, bluetooth.discoverable); + action.set_enabled (bluetooth.powered); + action.activate.connect (() => action.set_state (!action.get_state().get_boolean())); + action.notify["state"].connect (() => bluetooth.try_set_discoverable (action.get_state().get_boolean())); + bluetooth.notify["discoverable"].connect (() => action.set_state (bluetooth.discoverable)); + bluetooth.notify["powered"].connect (() => action.set_enabled (bluetooth.powered)); + return action; + } + void spawn_command_line_async (string command) + { + try { + Process.spawn_command_line_async (command); + } catch (Error e) { + warning ("unable to launch '%s': %s", command, e.message); + } + } + + Action create_wizard_action () + { + var action = new SimpleAction ("desktop-wizard", null); + action.activate.connect (() => spawn_command_line_async ("bluetooth-wizard")); return action; } Action create_settings_action () { var action = new SimpleAction ("desktop-settings", null); - - action.activate.connect ((action, param) => { - try { - Process.spawn_command_line_async ("gnome-control-center bluetooth"); - } catch (Error e) { - warning ("unable to launch settings: %s", e.message); - } - }); - + action.activate.connect (() => spawn_command_line_async ("gnome-control-center bluetooth")); return action; } protected Variant action_state_for_root () { - var label = "Hello"; // FIXME - var a11y = "Hello"; // FIXME - var visible = true; // FIXME + bool blocked = bluetooth.blocked; + bool powered = bluetooth.powered; + + settings.changed["visible"].connect (()=> this.update_root_action_state()); + + bool visible = powered && settings.get_boolean("visible"); + + string a11y; + string icon_name; + if (powered && !blocked) + { + a11y = "Bluetooth (on)"; + icon_name = "bluetooth-active"; + } + else + { + a11y = "Bluetooth (off)"; + icon_name = "bluetooth-disabled"; + } - string icon_name = "bluetooth-active"; // FIXME: enabled, disabled, connected, etc. -//indicator-bluetooth-service.vala: bluetooth_service._icon_name = enabled ? "bluetooth-active" : "bluetooth-disabled"; var icon = new ThemedIcon.with_default_fallbacks (icon_name); var builder = new VariantBuilder (new VariantType ("a{sv}")); builder.add ("{sv}", "visible", new Variant ("b", visible)); - builder.add ("{sv}", "label", new Variant ("s", label)); builder.add ("{sv}", "accessible-desc", new Variant ("s", a11y)); builder.add ("{sv}", "icon", icon.serialize()); return builder.end (); } + + void update_root_action_state () + { + root_action.set_state (action_state_for_root ()); + } } diff --git a/src/killswitch.vala b/src/killswitch.vala new file mode 100644 index 0000000..92b1a3c --- /dev/null +++ b/src/killswitch.vala @@ -0,0 +1,147 @@ +/* + * Copyright 2013 Canonical Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Authors: + * Charles Kerr + */ + +/** + * Monitors whether or not bluetooth is blocked, + * either by software (e.g., a session configuration setting) + * or by hardware (e.g., user disabled it via a physical switch on her laptop) + */ +public class KillSwitch: Object +{ + public bool blocked { get; protected set; default = false; } + + public void try_set_blocked (bool blocked) + { + return_if_fail (this.blocked != blocked); + + // write a 'soft kill' event to fkill + var event = Linux.RfKillEvent() { + op = Linux.RfKillOp.CHANGE_ALL, + type = Linux.RfKillType.BLUETOOTH, + soft = (uint8)blocked + }; + + var bwritten = Posix.write (fd, &event, sizeof(Linux.RfKillEvent)); + if (bwritten == -1) + warning ("Could not write rfkill event: %s", strerror(errno)); + } + + /*** + **** Past this point, it's all RfKill implementation details... + ***/ + + private class Entry + { + public uint32 idx; + public Linux.RfKillType type; + public bool soft; + public bool hard; + } + + private HashTable entries; + private int fd; + private IOChannel channel; + private uint watch; + + private bool calculate_blocked () + { + foreach (Entry entry in entries.get_values()) + if (entry.soft || entry.hard) + return true; + + return false; + } + + ~KillSwitch () + { + Source.remove (watch); + Posix.close (fd); + } + + public KillSwitch () + { + entries = new HashTable(direct_hash, direct_equal); + + var path = "/dev/rfkill"; + fd = Posix.open (path, Posix.O_RDWR | Posix.O_NONBLOCK ); + message ("fd is %d", fd); + if (fd == -1) + { + warning (@"Can't open $path: $(strerror(errno)); KillSwitch disable"); + } + else + { + // read everything that's already there, then watch for more + while (read_event()); + channel = new IOChannel.unix_new (fd); + watch = channel.add_watch (IOCondition.IN, on_channel_event); + } + } + + private bool on_channel_event (IOChannel source, IOCondition condition) + { + read_event (); + return true; + } + + private bool read_event () + { + assert (fd != -1); + + var event = Linux.RfKillEvent(); + var n = sizeof (Linux.RfKillEvent); + var bytesread = Posix.read (fd, &event, n); + + if (bytesread == n) + { + process_event (event); + return true; + } + + return false; + } + + private void process_event (Linux.RfKillEvent event) + { + // we only want things that affect bluetooth + if ((event.type != Linux.RfKillType.ALL) && + (event.type != Linux.RfKillType.BLUETOOTH)) + return; + + switch (event.op) + { + case Linux.RfKillOp.CHANGE: + case Linux.RfKillOp.ADD: + Entry entry = new Entry (); + entry.idx = event.idx; + entry.type = event.type; + entry.soft = event.soft != 0; + entry.hard = event.hard != 0; + entries.insert (entry.idx, entry); + break; + + case Linux.RfKillOp.DEL: + entries.remove (event.idx); + break; + } + + // update the 'blocked' property + blocked = calculate_blocked (); + } +} diff --git a/src/libido3-0.1.vapi b/src/libido3-0.1.vapi deleted file mode 100644 index e6a8953..0000000 --- a/src/libido3-0.1.vapi +++ /dev/null @@ -1,10 +0,0 @@ -namespace Ido -{ - [CCode (cheader_filename = "libido/idoswitchmenuitem.h")] - public class SwitchMenuItem : Gtk.CheckMenuItem - { - [CCode (has_construct_function = false)] - public SwitchMenuItem (); - public Gtk.Container content_area { get; } - } -} diff --git a/src/main.vala b/src/main.vala index 1df55c3..7af617d 100644 --- a/src/main.vala +++ b/src/main.vala @@ -7,7 +7,9 @@ main (string[] args) Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.GNOMELOCALEDIR); Intl.textdomain (Config.GETTEXT_PACKAGE); - var service = new BluetoothIndicator (); + var bluetooth = new Bluez (new KillSwitch ()); + var service = new BluetoothIndicator (bluetooth); + service.run (); return Posix.EXIT_SUCCESS; diff --git a/src/org-bluez.vala b/src/org-bluez.vala new file mode 100644 index 0000000..49c8e4d --- /dev/null +++ b/src/org-bluez.vala @@ -0,0 +1,293 @@ +/* Generated by vala-dbus-binding-tool 0.4.0. Do not modify! */ +/* Generated with: vala-dbus-binding-tool --gdbus --directory=. */ +using GLib; + +namespace org { + + namespace bluez { + + [DBus (name = "org.bluez.Manager", timeout = 120000)] + public interface Manager : GLib.Object { + + [DBus (name = "GetProperties")] + public abstract GLib.HashTable get_properties() throws DBusError, IOError; + + [DBus (name = "DefaultAdapter")] + public abstract GLib.ObjectPath default_adapter() throws DBusError, IOError; + + [DBus (name = "FindAdapter")] + public abstract GLib.ObjectPath find_adapter(string pattern) throws DBusError, IOError; + + [DBus (name = "ListAdapters")] + public abstract GLib.ObjectPath[] list_adapters() throws DBusError, IOError; + + [DBus (name = "PropertyChanged")] + public signal void property_changed(string name, GLib.Variant value); + + [DBus (name = "AdapterAdded")] + public signal void adapter_added(GLib.ObjectPath adapter); + + [DBus (name = "AdapterRemoved")] + public signal void adapter_removed(GLib.ObjectPath adapter); + + [DBus (name = "DefaultAdapterChanged")] + public signal void default_adapter_changed(GLib.ObjectPath adapter); + } + + [DBus (name = "org.bluez.Manager", timeout = 120000)] + public interface ManagerSync : GLib.Object { + + [DBus (name = "GetProperties")] + public abstract GLib.HashTable get_properties() throws DBusError, IOError; + + [DBus (name = "DefaultAdapter")] + public abstract GLib.ObjectPath default_adapter() throws DBusError, IOError; + + [DBus (name = "FindAdapter")] + public abstract GLib.ObjectPath find_adapter(string pattern) throws DBusError, IOError; + + [DBus (name = "ListAdapters")] + public abstract GLib.ObjectPath[] list_adapters() throws DBusError, IOError; + + [DBus (name = "PropertyChanged")] + public signal void property_changed(string name, GLib.Variant value); + + [DBus (name = "AdapterAdded")] + public signal void adapter_added(GLib.ObjectPath adapter); + + [DBus (name = "AdapterRemoved")] + public signal void adapter_removed(GLib.ObjectPath adapter); + + [DBus (name = "DefaultAdapterChanged")] + public signal void default_adapter_changed(GLib.ObjectPath adapter); + } + + [DBus (name = "org.bluez.Adapter", timeout = 120000)] + public interface Adapter : GLib.Object { + + [DBus (name = "GetProperties")] + public abstract GLib.HashTable get_properties() throws DBusError, IOError; + + [DBus (name = "SetProperty")] + public abstract void set_property(string name, GLib.Variant value) throws DBusError, IOError; + + [DBus (name = "RequestSession")] + public abstract void request_session() throws DBusError, IOError; + + [DBus (name = "ReleaseSession")] + public abstract void release_session() throws DBusError, IOError; + + [DBus (name = "StartDiscovery")] + public abstract void start_discovery() throws DBusError, IOError; + + [DBus (name = "StopDiscovery")] + public abstract void stop_discovery() throws DBusError, IOError; + + [DBus (name = "ListDevices")] + public abstract GLib.ObjectPath[] list_devices() throws DBusError, IOError; + + [DBus (name = "CreateDevice")] + public abstract GLib.ObjectPath create_device(string address) throws DBusError, IOError; + + [DBus (name = "CreatePairedDevice")] + public abstract GLib.ObjectPath create_paired_device(string address, GLib.ObjectPath agent, string capability) throws DBusError, IOError; + + [DBus (name = "CancelDeviceCreation")] + public abstract void cancel_device_creation(string address) throws DBusError, IOError; + + [DBus (name = "RemoveDevice")] + public abstract void remove_device(GLib.ObjectPath device) throws DBusError, IOError; + + [DBus (name = "FindDevice")] + public abstract GLib.ObjectPath find_device(string address) throws DBusError, IOError; + + [DBus (name = "RegisterAgent")] + public abstract void register_agent(GLib.ObjectPath agent, string capability) throws DBusError, IOError; + + [DBus (name = "UnregisterAgent")] + public abstract void unregister_agent(GLib.ObjectPath agent) throws DBusError, IOError; + + [DBus (name = "PropertyChanged")] + public signal void property_changed(string name, GLib.Variant value); + + [DBus (name = "DeviceCreated")] + public signal void device_created(GLib.ObjectPath device); + + [DBus (name = "DeviceRemoved")] + public signal void device_removed(GLib.ObjectPath device); + + [DBus (name = "DeviceFound")] + public signal void device_found(string address, GLib.HashTable values); + + [DBus (name = "DeviceDisappeared")] + public signal void device_disappeared(string address); + } + + [DBus (name = "org.bluez.Adapter", timeout = 120000)] + public interface AdapterSync : GLib.Object { + + [DBus (name = "GetProperties")] + public abstract GLib.HashTable get_properties() throws DBusError, IOError; + + [DBus (name = "SetProperty")] + public abstract void set_property(string name, GLib.Variant value) throws DBusError, IOError; + + [DBus (name = "RequestSession")] + public abstract void request_session() throws DBusError, IOError; + + [DBus (name = "ReleaseSession")] + public abstract void release_session() throws DBusError, IOError; + + [DBus (name = "StartDiscovery")] + public abstract void start_discovery() throws DBusError, IOError; + + [DBus (name = "StopDiscovery")] + public abstract void stop_discovery() throws DBusError, IOError; + + [DBus (name = "ListDevices")] + public abstract GLib.ObjectPath[] list_devices() throws DBusError, IOError; + + [DBus (name = "CreateDevice")] + public abstract GLib.ObjectPath create_device(string address) throws DBusError, IOError; + + [DBus (name = "CreatePairedDevice")] + public abstract GLib.ObjectPath create_paired_device(string address, GLib.ObjectPath agent, string capability) throws DBusError, IOError; + + [DBus (name = "CancelDeviceCreation")] + public abstract void cancel_device_creation(string address) throws DBusError, IOError; + + [DBus (name = "RemoveDevice")] + public abstract void remove_device(GLib.ObjectPath device) throws DBusError, IOError; + + [DBus (name = "FindDevice")] + public abstract GLib.ObjectPath find_device(string address) throws DBusError, IOError; + + [DBus (name = "RegisterAgent")] + public abstract void register_agent(GLib.ObjectPath agent, string capability) throws DBusError, IOError; + + [DBus (name = "UnregisterAgent")] + public abstract void unregister_agent(GLib.ObjectPath agent) throws DBusError, IOError; + + [DBus (name = "PropertyChanged")] + public signal void property_changed(string name, GLib.Variant value); + + [DBus (name = "DeviceCreated")] + public signal void device_created(GLib.ObjectPath device); + + [DBus (name = "DeviceRemoved")] + public signal void device_removed(GLib.ObjectPath device); + + [DBus (name = "DeviceFound")] + public signal void device_found(string address, GLib.HashTable values); + + [DBus (name = "DeviceDisappeared")] + public signal void device_disappeared(string address); + } + + [DBus (name = "org.bluez.Agent", timeout = 120000)] + public interface Agent : GLib.Object { + + [DBus (name = "Authorize")] + public abstract void authorize(GLib.ObjectPath device, string uuid) throws DBusError, IOError; + + [DBus (name = "RequestPinCode")] + public abstract string request_pin_code(GLib.ObjectPath device) throws DBusError, IOError; + + [DBus (name = "DisplayPasskey")] + public abstract void display_passkey(GLib.ObjectPath device, uint passkey) throws DBusError, IOError; + + [DBus (name = "Release")] + public abstract void release() throws DBusError, IOError; + + [DBus (name = "Cancel")] + public abstract void cancel() throws DBusError, IOError; + + [DBus (name = "RequestConfirmation")] + public abstract void request_confirmation(GLib.ObjectPath device, uint passkey) throws DBusError, IOError; + + [DBus (name = "ConfirmModeChange")] + public abstract void confirm_mode_change(string mode) throws DBusError, IOError; + + [DBus (name = "RequestPasskey")] + public abstract uint request_passkey(GLib.ObjectPath device) throws DBusError, IOError; + } + + [DBus (name = "org.bluez.Agent", timeout = 120000)] + public interface AgentSync : GLib.Object { + + [DBus (name = "Authorize")] + public abstract void authorize(GLib.ObjectPath device, string uuid) throws DBusError, IOError; + + [DBus (name = "RequestPinCode")] + public abstract string request_pin_code(GLib.ObjectPath device) throws DBusError, IOError; + + [DBus (name = "DisplayPasskey")] + public abstract void display_passkey(GLib.ObjectPath device, uint passkey) throws DBusError, IOError; + + [DBus (name = "Release")] + public abstract void release() throws DBusError, IOError; + + [DBus (name = "Cancel")] + public abstract void cancel() throws DBusError, IOError; + + [DBus (name = "RequestConfirmation")] + public abstract void request_confirmation(GLib.ObjectPath device, uint passkey) throws DBusError, IOError; + + [DBus (name = "ConfirmModeChange")] + public abstract void confirm_mode_change(string mode) throws DBusError, IOError; + + [DBus (name = "RequestPasskey")] + public abstract uint request_passkey(GLib.ObjectPath device) throws DBusError, IOError; + } + + [DBus (name = "org.bluez.Device", timeout = 120000)] + public interface Device : GLib.Object { + + [DBus (name = "GetProperties")] + public abstract GLib.HashTable get_properties() throws DBusError, IOError; + + [DBus (name = "SetProperty")] + public abstract void set_property(string name, GLib.Variant value) throws DBusError, IOError; + + [DBus (name = "DiscoverServices")] + public abstract GLib.HashTable discover_services(string pattern) throws DBusError, IOError; + + [DBus (name = "CancelDiscovery")] + public abstract void cancel_discovery() throws DBusError, IOError; + + [DBus (name = "Disconnect")] + public abstract void disconnect() throws DBusError, IOError; + + [DBus (name = "PropertyChanged")] + public signal void property_changed(string name, GLib.Variant value); + + [DBus (name = "DisconnectRequested")] + public signal void disconnect_requested(); + } + + [DBus (name = "org.bluez.Device", timeout = 120000)] + public interface DeviceSync : GLib.Object { + + [DBus (name = "GetProperties")] + public abstract GLib.HashTable get_properties() throws DBusError, IOError; + + [DBus (name = "SetProperty")] + public abstract void set_property(string name, GLib.Variant value) throws DBusError, IOError; + + [DBus (name = "DiscoverServices")] + public abstract GLib.HashTable discover_services(string pattern) throws DBusError, IOError; + + [DBus (name = "CancelDiscovery")] + public abstract void cancel_discovery() throws DBusError, IOError; + + [DBus (name = "Disconnect")] + public abstract void disconnect() throws DBusError, IOError; + + [DBus (name = "PropertyChanged")] + public signal void property_changed(string name, GLib.Variant value); + + [DBus (name = "DisconnectRequested")] + public signal void disconnect_requested(); + } + } +} diff --git a/src/phone.vala b/src/phone.vala index 2abcf11..a2a9917 100644 --- a/src/phone.vala +++ b/src/phone.vala @@ -29,7 +29,7 @@ class PhoneMenu: BluetoothMenu group.insert (actions[i]); } - public PhoneMenu () + public PhoneMenu (Bluetooth bluetooth) { base ("phone"); diff --git a/src/service.vala b/src/service.vala index b6ae0f3..0f3d779 100644 --- a/src/service.vala +++ b/src/service.vala @@ -28,24 +28,27 @@ public class BluetoothIndicator private List device_items; private Dbusmenu.Menuitem menu; - public BluetoothIndicator () throws Error + public BluetoothIndicator (Bluetooth bluetooth) { - var phone = new PhoneMenu (); - var desktop = new DesktopMenu (); + var phone = new PhoneMenu (bluetooth); + var desktop = new DesktopMenu (bluetooth); - this.menus = new HashTable (str_hash, str_equal); - this.menus.insert ("phone", phone); - this.menus.insert ("desktop", desktop); + this.menus = new HashTable (str_hash, str_equal); + this.menus.insert ("phone", phone); + this.menus.insert ("desktop", desktop); - this.actions = new SimpleActionGroup (); - phone.add_actions_to_group (this.actions); - desktop.add_actions_to_group (this.actions); + this.actions = new SimpleActionGroup (); + phone.add_actions_to_group (this.actions); + desktop.add_actions_to_group (this.actions); } private void init_for_bus (DBusConnection bus) { this.bus = bus; + /// + /// + indicator_service = new Indicator.Service ("com.canonical.indicator.bluetooth.old"); menu_server = new Dbusmenu.Server ("/com/canonical/indicator/bluetooth/menu"); diff --git a/vapi/rfkill.vapi b/vapi/rfkill.vapi new file mode 100644 index 0000000..7bfd16d --- /dev/null +++ b/vapi/rfkill.vapi @@ -0,0 +1,44 @@ +// (C) Michael 'Mickey' Lauer +// LGPL2 +// scheduled for inclusion in linux.vapi + +namespace Linux +{ + /* + * RfKill + */ + [CCode (cname = "struct rfkill_event", cheader_filename = "linux/rfkill.h")] + public struct RfKillEvent { + public uint32 idx; + public RfKillType type; + public RfKillOp op; + public uint8 soft; + public uint8 hard; + } + + [CCode (cname = "guint8", cprefix = "RFKILL_OP_", cheader_filename = "linux/rfkill.h")] + public enum RfKillOp { + ADD, + DEL, + CHANGE, + CHANGE_ALL + } + + [CCode (cname = "guint8", cprefix = "RFKILL_STATE_", cheader_filename = "linux/rfkill.h")] + public enum RfKillState { + SOFT_BLOCKED, + UNBLOCKED, + HARD_BLOCKED + } + + [CCode (cname = "guint8", cprefix = "RFKILL_TYPE_", cheader_filename = "linux/rfkill.h")] + public enum RfKillType { + ALL, + WLAN, + BLUETOOTH, + UWB, + WIMAX, + WWAN + } + +} /* namespace Linux */ -- cgit v1.2.3 From dfd38e506145b8569611e5fb0eb8cb49eef1b7b2 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 1 Aug 2013 20:30:08 -0500 Subject: move indicator3-0.4.vapi to the vapi dir. it'll go away soon enough... --- Makefile.am | 6 +- src/Makefile.am | 4 +- src/indicator3-0.4.vapi | 145 ----------------------------------------------- vapi/indicator3-0.4.vapi | 145 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 151 insertions(+), 149 deletions(-) delete mode 100644 src/indicator3-0.4.vapi create mode 100644 vapi/indicator3-0.4.vapi (limited to 'vapi') diff --git a/Makefile.am b/Makefile.am index 31ba5e2..fe6146b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -3,7 +3,9 @@ SUBDIRS = data po src EXTRA_DIST = \ autogen.sh \ NEWS \ - vapi/rfkill.vapi \ - vapi/config.vapi + vapi/config.vapi \ + vapi/gnome-bluetooth-1.0.vapi \ + vapi/indicator3-0.4.vapi \ + vapi/rfkill.vapi DISTCHECK_CONFIGURE_FLAGS = --enable-localinstall diff --git a/src/Makefile.am b/src/Makefile.am index 720c981..f685a97 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,7 +1,6 @@ pkglibexec_PROGRAMS = indicator-bluetooth-service -indicator_bluetooth_service_SOURCES = \ - indicator3-0.4.vapi \ +indicator_bluetooth_service_SOURCES = \ org-bluez.vala \ bluetooth.vala \ bluez.vala \ @@ -16,6 +15,7 @@ indicator_bluetooth_service_VALAFLAGS = \ --ccode \ --vapidir=$(top_srcdir)/vapi/ \ --vapidir=./ \ + --pkg indicator3-0.4 \ --pkg gnome-bluetooth-1.0 \ --pkg config \ --pkg rfkill \ diff --git a/src/indicator3-0.4.vapi b/src/indicator3-0.4.vapi deleted file mode 100644 index 44204cd..0000000 --- a/src/indicator3-0.4.vapi +++ /dev/null @@ -1,145 +0,0 @@ -/* indicator-0.4.vapi generated by vapigen, do not modify. */ - -namespace Indicator { - [CCode (cheader_filename = "libindicator/indicator-desktop-shortcuts.h", type_check_function = "INDICATOR_IS_DESKTOP_SHORTCUTS", type_id = "indicator_desktop_shortcuts_get_type")] - public class DesktopShortcuts : GLib.Object { - [CCode (has_construct_function = false)] - public DesktopShortcuts (string file, string identity); - public unowned string get_nicks (); - public bool nick_exec (string nick); - public unowned string nick_get_name (string nick); - public string desktop_file { construct; } - [NoAccessorMethod] - public string identity { owned get; construct; } - } - [CCode (cheader_filename = "libindicator/indicator-object.h", type_check_function = "INDICATOR_IS_OBJECT", type_id = "indicator_object_get_type ()")] - public class Object : GLib.Object { - [CCode (has_construct_function = false)] - public Object (); - public bool check_environment (string env); - [NoWrapper] - public virtual void entry_activate (Indicator.ObjectEntry entry, uint timestamp); - [NoWrapper] - public virtual void entry_activate_window (Indicator.ObjectEntry entry, uint windowid, uint timestamp); - [NoWrapper] - public virtual void entry_being_removed (Indicator.ObjectEntry entry); - [NoWrapper] - public virtual void entry_close (Indicator.ObjectEntry entry, uint timestamp); - [NoWrapper] - public virtual void entry_was_added (Indicator.ObjectEntry entry); - [CCode (has_construct_function = false)] - public Object.from_file (string file); - [NoWrapper] - public virtual signal unowned string get_accessible_desc (); - public virtual GLib.List get_entries (); - public unowned string[] get_environment (); - [NoWrapper] - public virtual unowned Gtk.Image get_image (); - [NoWrapper] - public virtual unowned Gtk.Label get_label (); - public virtual uint get_location (Indicator.ObjectEntry entry); - [NoWrapper] - public virtual unowned Gtk.Menu get_menu (); - [NoWrapper] - public virtual unowned string get_name_hint (); - public virtual bool get_show_now (Indicator.ObjectEntry entry); - public void set_environment (string[] env); - public void set_visible (bool visible); - [NoAccessorMethod] - public bool indicator_object_default_visibility { get; set; } - public virtual signal void accessible_desc_update (Indicator.ObjectEntry entry); - public virtual signal void entry_added (Indicator.ObjectEntry entry); - public virtual signal void entry_moved (Indicator.ObjectEntry entry, uint old_pos, uint new_pos); - public virtual signal void entry_removed (Indicator.ObjectEntry entry); - public virtual signal void entry_scrolled (Indicator.ObjectEntry entry, uint delta, Indicator.ScrollDirection direction); - public virtual signal void menu_show (Indicator.ObjectEntry entry, uint timestamp); - public virtual signal void secondary_activate (Indicator.ObjectEntry entry, uint timestamp); - public virtual signal void show_now_changed (Indicator.ObjectEntry entry, bool show_now_state); - } - [CCode (cheader_filename = "libindicator/indicator-object.h")] - [Compact] - public class ObjectEntry { - public weak string accessible_desc; - public weak Gtk.Image image; - public weak Gtk.Label label; - public weak Gtk.Menu menu; - public weak string name_hint; - public weak Indicator.Object parent_object; - public static void activate (Indicator.Object io, Indicator.ObjectEntry entry, uint timestamp); - public static void activate_window (Indicator.Object io, Indicator.ObjectEntry entry, uint windowid, uint timestamp); - public static void close (Indicator.Object io, Indicator.ObjectEntry entry, uint timestamp); - } - [CCode (cheader_filename = "libindicator/indicator-service.h", type_check_function = "INDICATOR_IS_SERVICE", type_id = "indicator_service_get_type")] - public class Service : GLib.Object { - [CCode (has_construct_function = false)] - public Service (string name); - [CCode (cname = "indicator_service_new_version", has_construct_function = false)] - public Service.with_version (string name, uint version); - [NoAccessorMethod] - public string name { owned get; set; } - [NoAccessorMethod] - public uint version { get; set; } - public virtual signal void shutdown (); - } - [CCode (cheader_filename = "libindicator/indicator-service-manager.h", type_check_function = "INDICATOR_IS_SERVICE_MANAGER", type_id = "indicator_service_manager_get_type")] - public class ServiceManager : GLib.Object { - [CCode (has_construct_function = false)] - public ServiceManager (string dbus_name); - public bool connected (); - public void set_refresh (uint time_in_ms); - [CCode (cname = "indicator_service_manager_new_version", has_construct_function = false)] - public ServiceManager.with_version (string dbus_name, uint version); - [NoAccessorMethod] - public string name { owned get; set; } - [NoAccessorMethod] - public uint version { get; set; } - public virtual signal void connection_change (bool connected); - } - [CCode (cheader_filename = "libindicator/indicator-object.h", cprefix = "INDICATOR_OBJECT_SCROLL_", has_type_id = false)] - public enum ScrollDirection { - UP, - DOWN, - LEFT, - RIGHT - } - [CCode (cheader_filename = "libindicator/indicator.h", has_target = false)] - public delegate GLib.Type get_type_t (); - [CCode (cheader_filename = "libindicator/indicator.h", has_target = false)] - public delegate unowned string get_version_t (); - [CCode (cheader_filename = "libindicator/indicator.h")] - public const string GET_TYPE_S; - [CCode (cheader_filename = "libindicator/indicator.h")] - public const string GET_VERSION_S; - [CCode (cheader_filename = "libindicator/indicator-gobject.h")] - public const string OBJECT_DEFAULT_VISIBILITY; - [CCode (cheader_filename = "libindicator/indicator-gobject.h")] - public const string OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE; - [CCode (cheader_filename = "libindicator/indicator-gobject.h")] - public const string OBJECT_SIGNAL_ENTRY_ADDED; - [CCode (cheader_filename = "libindicator/indicator-gobject.h")] - public const string OBJECT_SIGNAL_ENTRY_MOVED; - [CCode (cheader_filename = "libindicator/indicator-gobject.h")] - public const string OBJECT_SIGNAL_ENTRY_REMOVED; - [CCode (cheader_filename = "libindicator/indicator-gobject.h")] - public const string OBJECT_SIGNAL_ENTRY_SCROLLED; - [CCode (cheader_filename = "libindicator/indicator-gobject.h")] - public const string OBJECT_SIGNAL_MENU_SHOW; - [CCode (cheader_filename = "libindicator/indicator-gobject.h")] - public const string OBJECT_SIGNAL_SECONDARY_ACTIVATE; - [CCode (cheader_filename = "libindicator/indicator-gobject.h")] - public const string OBJECT_SIGNAL_SHOW_NOW_CHANGED; - [CCode (cheader_filename = "libindicator/indicator-service-manager.h")] - public const string SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE; - [CCode (cheader_filename = "libindicator/indicator-service.h")] - public const string SERVICE_SIGNAL_SHUTDOWN; - [CCode (cheader_filename = "libindicator/indicator.h")] - public const int SET_VERSION; - [CCode (cheader_filename = "libindicator/indicator.h")] - public const string VERSION; - [CCode (cheader_filename = "libindicator/indicator.h", cname = "get_version")] - public static unowned string get_version (); - [CCode (cheader_filename = "libindicator/indicator-image-helper.h")] - public static unowned Gtk.Image image_helper (string name); - [CCode (cheader_filename = "libindicator/indicator-image-helper.h")] - public static void image_helper_update (Gtk.Image image, string name); -} \ No newline at end of file diff --git a/vapi/indicator3-0.4.vapi b/vapi/indicator3-0.4.vapi new file mode 100644 index 0000000..44204cd --- /dev/null +++ b/vapi/indicator3-0.4.vapi @@ -0,0 +1,145 @@ +/* indicator-0.4.vapi generated by vapigen, do not modify. */ + +namespace Indicator { + [CCode (cheader_filename = "libindicator/indicator-desktop-shortcuts.h", type_check_function = "INDICATOR_IS_DESKTOP_SHORTCUTS", type_id = "indicator_desktop_shortcuts_get_type")] + public class DesktopShortcuts : GLib.Object { + [CCode (has_construct_function = false)] + public DesktopShortcuts (string file, string identity); + public unowned string get_nicks (); + public bool nick_exec (string nick); + public unowned string nick_get_name (string nick); + public string desktop_file { construct; } + [NoAccessorMethod] + public string identity { owned get; construct; } + } + [CCode (cheader_filename = "libindicator/indicator-object.h", type_check_function = "INDICATOR_IS_OBJECT", type_id = "indicator_object_get_type ()")] + public class Object : GLib.Object { + [CCode (has_construct_function = false)] + public Object (); + public bool check_environment (string env); + [NoWrapper] + public virtual void entry_activate (Indicator.ObjectEntry entry, uint timestamp); + [NoWrapper] + public virtual void entry_activate_window (Indicator.ObjectEntry entry, uint windowid, uint timestamp); + [NoWrapper] + public virtual void entry_being_removed (Indicator.ObjectEntry entry); + [NoWrapper] + public virtual void entry_close (Indicator.ObjectEntry entry, uint timestamp); + [NoWrapper] + public virtual void entry_was_added (Indicator.ObjectEntry entry); + [CCode (has_construct_function = false)] + public Object.from_file (string file); + [NoWrapper] + public virtual signal unowned string get_accessible_desc (); + public virtual GLib.List get_entries (); + public unowned string[] get_environment (); + [NoWrapper] + public virtual unowned Gtk.Image get_image (); + [NoWrapper] + public virtual unowned Gtk.Label get_label (); + public virtual uint get_location (Indicator.ObjectEntry entry); + [NoWrapper] + public virtual unowned Gtk.Menu get_menu (); + [NoWrapper] + public virtual unowned string get_name_hint (); + public virtual bool get_show_now (Indicator.ObjectEntry entry); + public void set_environment (string[] env); + public void set_visible (bool visible); + [NoAccessorMethod] + public bool indicator_object_default_visibility { get; set; } + public virtual signal void accessible_desc_update (Indicator.ObjectEntry entry); + public virtual signal void entry_added (Indicator.ObjectEntry entry); + public virtual signal void entry_moved (Indicator.ObjectEntry entry, uint old_pos, uint new_pos); + public virtual signal void entry_removed (Indicator.ObjectEntry entry); + public virtual signal void entry_scrolled (Indicator.ObjectEntry entry, uint delta, Indicator.ScrollDirection direction); + public virtual signal void menu_show (Indicator.ObjectEntry entry, uint timestamp); + public virtual signal void secondary_activate (Indicator.ObjectEntry entry, uint timestamp); + public virtual signal void show_now_changed (Indicator.ObjectEntry entry, bool show_now_state); + } + [CCode (cheader_filename = "libindicator/indicator-object.h")] + [Compact] + public class ObjectEntry { + public weak string accessible_desc; + public weak Gtk.Image image; + public weak Gtk.Label label; + public weak Gtk.Menu menu; + public weak string name_hint; + public weak Indicator.Object parent_object; + public static void activate (Indicator.Object io, Indicator.ObjectEntry entry, uint timestamp); + public static void activate_window (Indicator.Object io, Indicator.ObjectEntry entry, uint windowid, uint timestamp); + public static void close (Indicator.Object io, Indicator.ObjectEntry entry, uint timestamp); + } + [CCode (cheader_filename = "libindicator/indicator-service.h", type_check_function = "INDICATOR_IS_SERVICE", type_id = "indicator_service_get_type")] + public class Service : GLib.Object { + [CCode (has_construct_function = false)] + public Service (string name); + [CCode (cname = "indicator_service_new_version", has_construct_function = false)] + public Service.with_version (string name, uint version); + [NoAccessorMethod] + public string name { owned get; set; } + [NoAccessorMethod] + public uint version { get; set; } + public virtual signal void shutdown (); + } + [CCode (cheader_filename = "libindicator/indicator-service-manager.h", type_check_function = "INDICATOR_IS_SERVICE_MANAGER", type_id = "indicator_service_manager_get_type")] + public class ServiceManager : GLib.Object { + [CCode (has_construct_function = false)] + public ServiceManager (string dbus_name); + public bool connected (); + public void set_refresh (uint time_in_ms); + [CCode (cname = "indicator_service_manager_new_version", has_construct_function = false)] + public ServiceManager.with_version (string dbus_name, uint version); + [NoAccessorMethod] + public string name { owned get; set; } + [NoAccessorMethod] + public uint version { get; set; } + public virtual signal void connection_change (bool connected); + } + [CCode (cheader_filename = "libindicator/indicator-object.h", cprefix = "INDICATOR_OBJECT_SCROLL_", has_type_id = false)] + public enum ScrollDirection { + UP, + DOWN, + LEFT, + RIGHT + } + [CCode (cheader_filename = "libindicator/indicator.h", has_target = false)] + public delegate GLib.Type get_type_t (); + [CCode (cheader_filename = "libindicator/indicator.h", has_target = false)] + public delegate unowned string get_version_t (); + [CCode (cheader_filename = "libindicator/indicator.h")] + public const string GET_TYPE_S; + [CCode (cheader_filename = "libindicator/indicator.h")] + public const string GET_VERSION_S; + [CCode (cheader_filename = "libindicator/indicator-gobject.h")] + public const string OBJECT_DEFAULT_VISIBILITY; + [CCode (cheader_filename = "libindicator/indicator-gobject.h")] + public const string OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE; + [CCode (cheader_filename = "libindicator/indicator-gobject.h")] + public const string OBJECT_SIGNAL_ENTRY_ADDED; + [CCode (cheader_filename = "libindicator/indicator-gobject.h")] + public const string OBJECT_SIGNAL_ENTRY_MOVED; + [CCode (cheader_filename = "libindicator/indicator-gobject.h")] + public const string OBJECT_SIGNAL_ENTRY_REMOVED; + [CCode (cheader_filename = "libindicator/indicator-gobject.h")] + public const string OBJECT_SIGNAL_ENTRY_SCROLLED; + [CCode (cheader_filename = "libindicator/indicator-gobject.h")] + public const string OBJECT_SIGNAL_MENU_SHOW; + [CCode (cheader_filename = "libindicator/indicator-gobject.h")] + public const string OBJECT_SIGNAL_SECONDARY_ACTIVATE; + [CCode (cheader_filename = "libindicator/indicator-gobject.h")] + public const string OBJECT_SIGNAL_SHOW_NOW_CHANGED; + [CCode (cheader_filename = "libindicator/indicator-service-manager.h")] + public const string SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE; + [CCode (cheader_filename = "libindicator/indicator-service.h")] + public const string SERVICE_SIGNAL_SHUTDOWN; + [CCode (cheader_filename = "libindicator/indicator.h")] + public const int SET_VERSION; + [CCode (cheader_filename = "libindicator/indicator.h")] + public const string VERSION; + [CCode (cheader_filename = "libindicator/indicator.h", cname = "get_version")] + public static unowned string get_version (); + [CCode (cheader_filename = "libindicator/indicator-image-helper.h")] + public static unowned Gtk.Image image_helper (string name); + [CCode (cheader_filename = "libindicator/indicator-image-helper.h")] + public static void image_helper_update (Gtk.Image image, string name); +} \ No newline at end of file -- cgit v1.2.3 From a0616908a817d6fad47c29ae703fc8a2ea379af6 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 9 Aug 2013 18:23:50 -0500 Subject: remove the libindicator vapi file; it's no longer used. --- Makefile.am | 1 - vapi/indicator3-0.4.vapi | 145 ----------------------------------------------- 2 files changed, 146 deletions(-) delete mode 100644 vapi/indicator3-0.4.vapi (limited to 'vapi') diff --git a/Makefile.am b/Makefile.am index fe6146b..ef681b3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5,7 +5,6 @@ EXTRA_DIST = \ NEWS \ vapi/config.vapi \ vapi/gnome-bluetooth-1.0.vapi \ - vapi/indicator3-0.4.vapi \ vapi/rfkill.vapi DISTCHECK_CONFIGURE_FLAGS = --enable-localinstall diff --git a/vapi/indicator3-0.4.vapi b/vapi/indicator3-0.4.vapi deleted file mode 100644 index 44204cd..0000000 --- a/vapi/indicator3-0.4.vapi +++ /dev/null @@ -1,145 +0,0 @@ -/* indicator-0.4.vapi generated by vapigen, do not modify. */ - -namespace Indicator { - [CCode (cheader_filename = "libindicator/indicator-desktop-shortcuts.h", type_check_function = "INDICATOR_IS_DESKTOP_SHORTCUTS", type_id = "indicator_desktop_shortcuts_get_type")] - public class DesktopShortcuts : GLib.Object { - [CCode (has_construct_function = false)] - public DesktopShortcuts (string file, string identity); - public unowned string get_nicks (); - public bool nick_exec (string nick); - public unowned string nick_get_name (string nick); - public string desktop_file { construct; } - [NoAccessorMethod] - public string identity { owned get; construct; } - } - [CCode (cheader_filename = "libindicator/indicator-object.h", type_check_function = "INDICATOR_IS_OBJECT", type_id = "indicator_object_get_type ()")] - public class Object : GLib.Object { - [CCode (has_construct_function = false)] - public Object (); - public bool check_environment (string env); - [NoWrapper] - public virtual void entry_activate (Indicator.ObjectEntry entry, uint timestamp); - [NoWrapper] - public virtual void entry_activate_window (Indicator.ObjectEntry entry, uint windowid, uint timestamp); - [NoWrapper] - public virtual void entry_being_removed (Indicator.ObjectEntry entry); - [NoWrapper] - public virtual void entry_close (Indicator.ObjectEntry entry, uint timestamp); - [NoWrapper] - public virtual void entry_was_added (Indicator.ObjectEntry entry); - [CCode (has_construct_function = false)] - public Object.from_file (string file); - [NoWrapper] - public virtual signal unowned string get_accessible_desc (); - public virtual GLib.List get_entries (); - public unowned string[] get_environment (); - [NoWrapper] - public virtual unowned Gtk.Image get_image (); - [NoWrapper] - public virtual unowned Gtk.Label get_label (); - public virtual uint get_location (Indicator.ObjectEntry entry); - [NoWrapper] - public virtual unowned Gtk.Menu get_menu (); - [NoWrapper] - public virtual unowned string get_name_hint (); - public virtual bool get_show_now (Indicator.ObjectEntry entry); - public void set_environment (string[] env); - public void set_visible (bool visible); - [NoAccessorMethod] - public bool indicator_object_default_visibility { get; set; } - public virtual signal void accessible_desc_update (Indicator.ObjectEntry entry); - public virtual signal void entry_added (Indicator.ObjectEntry entry); - public virtual signal void entry_moved (Indicator.ObjectEntry entry, uint old_pos, uint new_pos); - public virtual signal void entry_removed (Indicator.ObjectEntry entry); - public virtual signal void entry_scrolled (Indicator.ObjectEntry entry, uint delta, Indicator.ScrollDirection direction); - public virtual signal void menu_show (Indicator.ObjectEntry entry, uint timestamp); - public virtual signal void secondary_activate (Indicator.ObjectEntry entry, uint timestamp); - public virtual signal void show_now_changed (Indicator.ObjectEntry entry, bool show_now_state); - } - [CCode (cheader_filename = "libindicator/indicator-object.h")] - [Compact] - public class ObjectEntry { - public weak string accessible_desc; - public weak Gtk.Image image; - public weak Gtk.Label label; - public weak Gtk.Menu menu; - public weak string name_hint; - public weak Indicator.Object parent_object; - public static void activate (Indicator.Object io, Indicator.ObjectEntry entry, uint timestamp); - public static void activate_window (Indicator.Object io, Indicator.ObjectEntry entry, uint windowid, uint timestamp); - public static void close (Indicator.Object io, Indicator.ObjectEntry entry, uint timestamp); - } - [CCode (cheader_filename = "libindicator/indicator-service.h", type_check_function = "INDICATOR_IS_SERVICE", type_id = "indicator_service_get_type")] - public class Service : GLib.Object { - [CCode (has_construct_function = false)] - public Service (string name); - [CCode (cname = "indicator_service_new_version", has_construct_function = false)] - public Service.with_version (string name, uint version); - [NoAccessorMethod] - public string name { owned get; set; } - [NoAccessorMethod] - public uint version { get; set; } - public virtual signal void shutdown (); - } - [CCode (cheader_filename = "libindicator/indicator-service-manager.h", type_check_function = "INDICATOR_IS_SERVICE_MANAGER", type_id = "indicator_service_manager_get_type")] - public class ServiceManager : GLib.Object { - [CCode (has_construct_function = false)] - public ServiceManager (string dbus_name); - public bool connected (); - public void set_refresh (uint time_in_ms); - [CCode (cname = "indicator_service_manager_new_version", has_construct_function = false)] - public ServiceManager.with_version (string dbus_name, uint version); - [NoAccessorMethod] - public string name { owned get; set; } - [NoAccessorMethod] - public uint version { get; set; } - public virtual signal void connection_change (bool connected); - } - [CCode (cheader_filename = "libindicator/indicator-object.h", cprefix = "INDICATOR_OBJECT_SCROLL_", has_type_id = false)] - public enum ScrollDirection { - UP, - DOWN, - LEFT, - RIGHT - } - [CCode (cheader_filename = "libindicator/indicator.h", has_target = false)] - public delegate GLib.Type get_type_t (); - [CCode (cheader_filename = "libindicator/indicator.h", has_target = false)] - public delegate unowned string get_version_t (); - [CCode (cheader_filename = "libindicator/indicator.h")] - public const string GET_TYPE_S; - [CCode (cheader_filename = "libindicator/indicator.h")] - public const string GET_VERSION_S; - [CCode (cheader_filename = "libindicator/indicator-gobject.h")] - public const string OBJECT_DEFAULT_VISIBILITY; - [CCode (cheader_filename = "libindicator/indicator-gobject.h")] - public const string OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE; - [CCode (cheader_filename = "libindicator/indicator-gobject.h")] - public const string OBJECT_SIGNAL_ENTRY_ADDED; - [CCode (cheader_filename = "libindicator/indicator-gobject.h")] - public const string OBJECT_SIGNAL_ENTRY_MOVED; - [CCode (cheader_filename = "libindicator/indicator-gobject.h")] - public const string OBJECT_SIGNAL_ENTRY_REMOVED; - [CCode (cheader_filename = "libindicator/indicator-gobject.h")] - public const string OBJECT_SIGNAL_ENTRY_SCROLLED; - [CCode (cheader_filename = "libindicator/indicator-gobject.h")] - public const string OBJECT_SIGNAL_MENU_SHOW; - [CCode (cheader_filename = "libindicator/indicator-gobject.h")] - public const string OBJECT_SIGNAL_SECONDARY_ACTIVATE; - [CCode (cheader_filename = "libindicator/indicator-gobject.h")] - public const string OBJECT_SIGNAL_SHOW_NOW_CHANGED; - [CCode (cheader_filename = "libindicator/indicator-service-manager.h")] - public const string SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE; - [CCode (cheader_filename = "libindicator/indicator-service.h")] - public const string SERVICE_SIGNAL_SHUTDOWN; - [CCode (cheader_filename = "libindicator/indicator.h")] - public const int SET_VERSION; - [CCode (cheader_filename = "libindicator/indicator.h")] - public const string VERSION; - [CCode (cheader_filename = "libindicator/indicator.h", cname = "get_version")] - public static unowned string get_version (); - [CCode (cheader_filename = "libindicator/indicator-image-helper.h")] - public static unowned Gtk.Image image_helper (string name); - [CCode (cheader_filename = "libindicator/indicator-image-helper.h")] - public static void image_helper_update (Gtk.Image image, string name); -} \ No newline at end of file -- cgit v1.2.3