2011-09-28 13:16:26 +00:00
|
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2022-08-03 04:03:40 +00:00
|
|
|
|
/* exported Indicator */
|
2022-08-06 00:43:29 +00:00
|
|
|
|
const {Atk, Clutter, Gio, GLib, GObject, NM, Polkit, St} = imports.gi;
|
2011-01-25 21:08:12 +00:00
|
|
|
|
|
|
|
|
|
const Main = imports.ui.main;
|
|
|
|
|
const PopupMenu = imports.ui.popupMenu;
|
|
|
|
|
const MessageTray = imports.ui.messageTray;
|
|
|
|
|
const ModemManager = imports.misc.modemManager;
|
|
|
|
|
const Util = imports.misc.util;
|
|
|
|
|
|
2022-08-06 03:01:20 +00:00
|
|
|
|
const {Spinner} = imports.ui.animation;
|
2022-08-03 04:03:40 +00:00
|
|
|
|
const {QuickMenuToggle, SystemIndicator} = imports.ui.quickSettings;
|
|
|
|
|
|
2022-07-23 23:11:32 +00:00
|
|
|
|
const {loadInterfaceXML} = imports.misc.fileUtils;
|
|
|
|
|
const {registerDestroyableType} = imports.misc.signalTracker;
|
2018-09-06 00:55:20 +00:00
|
|
|
|
|
2022-02-10 23:09:54 +00:00
|
|
|
|
Gio._promisify(Gio.DBusConnection.prototype, 'call');
|
|
|
|
|
Gio._promisify(NM.Client, 'new_async');
|
|
|
|
|
Gio._promisify(NM.Client.prototype, 'check_connectivity_async');
|
2022-08-06 03:01:20 +00:00
|
|
|
|
Gio._promisify(NM.DeviceWifi.prototype, 'request_scan_async');
|
2019-12-19 19:50:37 +00:00
|
|
|
|
|
2022-08-06 03:01:20 +00:00
|
|
|
|
const WIFI_SCAN_FREQUENCY = 15;
|
2022-08-06 00:43:29 +00:00
|
|
|
|
const MAX_VISIBLE_NETWORKS = 8;
|
2016-05-13 17:42:04 +00:00
|
|
|
|
|
2011-01-25 21:08:12 +00:00
|
|
|
|
// small optimization, to avoid using [] all the time
|
2017-10-31 10:38:20 +00:00
|
|
|
|
const NM80211Mode = NM['80211Mode'];
|
2011-01-25 21:08:12 +00:00
|
|
|
|
|
2017-07-18 17:47:27 +00:00
|
|
|
|
var PortalHelperResult = {
|
2014-02-17 17:06:35 +00:00
|
|
|
|
CANCELLED: 0,
|
|
|
|
|
COMPLETED: 1,
|
2019-08-20 21:43:54 +00:00
|
|
|
|
RECHECK: 2,
|
2014-02-17 17:06:35 +00:00
|
|
|
|
};
|
|
|
|
|
|
2018-09-06 00:55:20 +00:00
|
|
|
|
const PortalHelperIface = loadInterfaceXML('org.gnome.Shell.PortalHelper');
|
2022-06-23 12:53:29 +00:00
|
|
|
|
const PortalHelperInfo = Gio.DBusInterfaceInfo.new_for_xml(PortalHelperIface);
|
2014-02-17 17:06:35 +00:00
|
|
|
|
|
2011-01-25 21:08:12 +00:00
|
|
|
|
function signalToIcon(value) {
|
2020-09-03 22:45:38 +00:00
|
|
|
|
if (value < 20)
|
|
|
|
|
return 'none';
|
|
|
|
|
else if (value < 40)
|
2011-01-25 21:08:12 +00:00
|
|
|
|
return 'weak';
|
2020-09-03 22:45:38 +00:00
|
|
|
|
else if (value < 50)
|
|
|
|
|
return 'ok';
|
|
|
|
|
else if (value < 80)
|
|
|
|
|
return 'good';
|
|
|
|
|
else
|
|
|
|
|
return 'excellent';
|
2011-01-25 21:08:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-08-03 18:05:53 +00:00
|
|
|
|
function ssidToLabel(ssid) {
|
2017-10-31 10:38:20 +00:00
|
|
|
|
let label = NM.utils_ssid_to_utf8(ssid.get_data());
|
2011-08-03 18:05:53 +00:00
|
|
|
|
if (!label)
|
|
|
|
|
label = _("<unknown>");
|
|
|
|
|
return label;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-31 18:40:36 +00:00
|
|
|
|
function launchSettingsPanel(panel, ...args) {
|
|
|
|
|
const param = new GLib.Variant('(sav)',
|
|
|
|
|
[panel, args.map(s => new GLib.Variant('s', s))]);
|
|
|
|
|
const platformData = {
|
|
|
|
|
'desktop-startup-id': new GLib.Variant('s',
|
2022-02-07 14:14:06 +00:00
|
|
|
|
`_TIME${global.get_current_time()}`),
|
2020-07-31 18:40:36 +00:00
|
|
|
|
};
|
|
|
|
|
try {
|
|
|
|
|
Gio.DBus.session.call(
|
2022-02-11 16:14:00 +00:00
|
|
|
|
'org.gnome.Settings',
|
|
|
|
|
'/org/gnome/Settings',
|
2020-07-31 18:40:36 +00:00
|
|
|
|
'org.freedesktop.Application',
|
|
|
|
|
'ActivateAction',
|
|
|
|
|
new GLib.Variant('(sava{sv})',
|
|
|
|
|
['launch-panel', [param], platformData]),
|
|
|
|
|
null,
|
|
|
|
|
Gio.DBusCallFlags.NONE,
|
|
|
|
|
-1,
|
|
|
|
|
null);
|
|
|
|
|
} catch (e) {
|
2022-02-07 14:14:06 +00:00
|
|
|
|
log(`Failed to launch Settings panel: ${e.message}`);
|
2020-07-31 18:40:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-03 14:05:20 +00:00
|
|
|
|
class ItemSorter {
|
|
|
|
|
[Symbol.iterator] = this.items;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Maintains a list of sorted items. By default, items are
|
|
|
|
|
* assumed to be objects with a name property.
|
|
|
|
|
*
|
2022-08-03 06:12:28 +00:00
|
|
|
|
* Optionally items can have a secondary sort order by
|
|
|
|
|
* recency. If used, items must by objects with a timestamp
|
|
|
|
|
* property that can be used in substraction, and "bigger"
|
|
|
|
|
* must mean "more recent". Number and Date both qualify.
|
|
|
|
|
*
|
2022-08-03 14:05:20 +00:00
|
|
|
|
* @param {object=} options - property object with options
|
|
|
|
|
* @param {Function} options.sortFunc - a custom sort function
|
2022-08-03 06:12:28 +00:00
|
|
|
|
* @param {bool} options.trackMru - whether to track MRU order as well
|
2022-08-03 14:05:20 +00:00
|
|
|
|
**/
|
|
|
|
|
constructor(options = {}) {
|
2022-08-03 06:12:28 +00:00
|
|
|
|
const {sortFunc, trackMru} = {
|
2022-08-03 14:05:20 +00:00
|
|
|
|
sortFunc: this._sortByName.bind(this),
|
2022-08-03 06:12:28 +00:00
|
|
|
|
trackMru: false,
|
2022-08-03 14:05:20 +00:00
|
|
|
|
...options,
|
|
|
|
|
};
|
|
|
|
|
|
2022-08-03 06:12:28 +00:00
|
|
|
|
this._trackMru = trackMru;
|
2022-08-03 14:05:20 +00:00
|
|
|
|
this._sortFunc = sortFunc;
|
2022-08-03 06:12:28 +00:00
|
|
|
|
this._sortFuncMru = this._sortByMru.bind(this);
|
2022-08-03 14:05:20 +00:00
|
|
|
|
|
|
|
|
|
this._itemsOrder = [];
|
2022-08-03 06:12:28 +00:00
|
|
|
|
this._itemsMruOrder = [];
|
2022-08-03 14:05:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*items() {
|
|
|
|
|
yield* this._itemsOrder;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-03 06:12:28 +00:00
|
|
|
|
*itemsByMru() {
|
|
|
|
|
console.assert(this._trackMru, 'itemsByMru: MRU tracking is disabled');
|
|
|
|
|
yield* this._itemsMruOrder;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-03 14:05:20 +00:00
|
|
|
|
_sortByName(one, two) {
|
|
|
|
|
return GLib.utf8_collate(one.name, two.name);
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-03 06:12:28 +00:00
|
|
|
|
_sortByMru(one, two) {
|
|
|
|
|
return two.timestamp - one.timestamp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_upsert(array, item, sortFunc) {
|
|
|
|
|
this._delete(array, item);
|
|
|
|
|
return Util.insertSorted(array, item, sortFunc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_delete(array, item) {
|
|
|
|
|
const pos = array.indexOf(item);
|
|
|
|
|
if (pos >= 0)
|
|
|
|
|
array.splice(pos, 1);
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-03 14:05:20 +00:00
|
|
|
|
/**
|
|
|
|
|
* Insert or update item.
|
|
|
|
|
*
|
|
|
|
|
* @param {any} item - the item to upsert
|
|
|
|
|
* @returns {number} - the sorted position of item
|
|
|
|
|
*/
|
|
|
|
|
upsert(item) {
|
2022-08-03 06:12:28 +00:00
|
|
|
|
if (this._trackMru)
|
|
|
|
|
this._upsert(this._itemsMruOrder, item, this._sortFuncMru);
|
|
|
|
|
|
|
|
|
|
return this._upsert(this._itemsOrder, item, this._sortFunc);
|
2022-08-03 14:05:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param {any} item - item to remove
|
|
|
|
|
*/
|
|
|
|
|
delete(item) {
|
2022-08-03 06:12:28 +00:00
|
|
|
|
if (this._trackMru)
|
|
|
|
|
this._delete(this._itemsMruOrder, item);
|
|
|
|
|
this._delete(this._itemsOrder, item);
|
2022-08-03 14:05:20 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-02 11:41:13 +00:00
|
|
|
|
const NMMenuItem = GObject.registerClass({
|
2022-08-02 10:34:18 +00:00
|
|
|
|
Properties: {
|
|
|
|
|
'radio-mode': GObject.ParamSpec.boolean('radio-mode', '', '',
|
|
|
|
|
GObject.ParamFlags.READWRITE,
|
|
|
|
|
false),
|
|
|
|
|
'is-active': GObject.ParamSpec.boolean('is-active', '', '',
|
|
|
|
|
GObject.ParamFlags.READABLE,
|
|
|
|
|
false),
|
|
|
|
|
'name': GObject.ParamSpec.string('name', '', '',
|
|
|
|
|
GObject.ParamFlags.READWRITE,
|
|
|
|
|
''),
|
|
|
|
|
'icon-name': GObject.ParamSpec.string('icon-name', '', '',
|
|
|
|
|
GObject.ParamFlags.READWRITE,
|
|
|
|
|
''),
|
|
|
|
|
},
|
2022-08-02 11:41:13 +00:00
|
|
|
|
}, class NMMenuItem extends PopupMenu.PopupBaseMenuItem {
|
|
|
|
|
get state() {
|
|
|
|
|
return this._activeConnection?.state ??
|
|
|
|
|
NM.ActiveConnectionState.DEACTIVATED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get is_active() {
|
|
|
|
|
return this.state <= NM.ActiveConnectionState.ACTIVATED;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-03 06:12:28 +00:00
|
|
|
|
get timestamp() {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-02 11:41:13 +00:00
|
|
|
|
activate() {
|
|
|
|
|
super.activate(Clutter.get_current_event());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_activeConnectionStateChanged() {
|
|
|
|
|
this.notify('is-active');
|
|
|
|
|
this.notify('icon-name');
|
|
|
|
|
|
|
|
|
|
this._sync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_setActiveConnection(activeConnection) {
|
|
|
|
|
this._activeConnection?.disconnectObject(this);
|
|
|
|
|
|
|
|
|
|
this._activeConnection = activeConnection;
|
|
|
|
|
|
|
|
|
|
this._activeConnection?.connectObject(
|
|
|
|
|
'notify::state', () => this._activeConnectionStateChanged(),
|
|
|
|
|
this);
|
|
|
|
|
this._activeConnectionStateChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_sync() {
|
|
|
|
|
// Overridden by subclasses
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2022-08-02 12:04:46 +00:00
|
|
|
|
/**
|
|
|
|
|
* Item that contains a section, and can be collapsed
|
|
|
|
|
* into a submenu
|
|
|
|
|
*/
|
|
|
|
|
const NMSectionItem = GObject.registerClass({
|
|
|
|
|
Properties: {
|
|
|
|
|
'use-submenu': GObject.ParamSpec.boolean('use-submenu', '', '',
|
|
|
|
|
GObject.ParamFlags.READWRITE,
|
|
|
|
|
false),
|
|
|
|
|
},
|
|
|
|
|
}, class NMSectionItem extends NMMenuItem {
|
|
|
|
|
constructor() {
|
|
|
|
|
super({
|
|
|
|
|
activate: false,
|
|
|
|
|
can_focus: false,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this._useSubmenu = false;
|
|
|
|
|
|
|
|
|
|
// Turn into an empty container with no padding
|
|
|
|
|
this.styleClass = '';
|
|
|
|
|
this.setOrnament(PopupMenu.Ornament.HIDDEN);
|
|
|
|
|
|
|
|
|
|
// Add intermediate section; we need this for submenu support
|
|
|
|
|
this._mainSection = new PopupMenu.PopupMenuSection();
|
|
|
|
|
this.add_child(this._mainSection.actor);
|
|
|
|
|
|
|
|
|
|
this._submenuItem = new PopupMenu.PopupSubMenuMenuItem('', true);
|
|
|
|
|
this._mainSection.addMenuItem(this._submenuItem);
|
|
|
|
|
this._submenuItem.hide();
|
|
|
|
|
|
|
|
|
|
this.section = new PopupMenu.PopupMenuSection();
|
|
|
|
|
this._mainSection.addMenuItem(this.section);
|
|
|
|
|
|
|
|
|
|
// Represents the item as a whole when shown
|
|
|
|
|
this.bind_property('name',
|
|
|
|
|
this._submenuItem.label, 'text',
|
|
|
|
|
GObject.BindingFlags.DEFAULT);
|
|
|
|
|
this.bind_property('icon-name',
|
|
|
|
|
this._submenuItem.icon, 'icon-name',
|
|
|
|
|
GObject.BindingFlags.DEFAULT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_setParent(parent) {
|
|
|
|
|
super._setParent(parent);
|
|
|
|
|
this._mainSection._setParent(parent);
|
|
|
|
|
|
|
|
|
|
parent?.connect('menu-closed',
|
|
|
|
|
() => this._mainSection.emit('menu-closed'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get use_submenu() {
|
|
|
|
|
return this._useSubmenu;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set use_submenu(useSubmenu) {
|
|
|
|
|
if (this._useSubmenu === useSubmenu)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
this._useSubmenu = useSubmenu;
|
|
|
|
|
this._submenuItem.visible = useSubmenu;
|
|
|
|
|
|
|
|
|
|
if (useSubmenu) {
|
|
|
|
|
this._mainSection.box.remove_child(this.section.actor);
|
|
|
|
|
this._submenuItem.menu.box.add_child(this.section.actor);
|
|
|
|
|
} else {
|
|
|
|
|
this._submenuItem.menu.box.remove_child(this.section.actor);
|
|
|
|
|
this._mainSection.box.add_child(this.section.actor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2022-08-02 11:41:13 +00:00
|
|
|
|
const NMConnectionItem = GObject.registerClass(
|
|
|
|
|
class NMConnectionItem extends NMMenuItem {
|
2017-10-31 01:19:44 +00:00
|
|
|
|
constructor(section, connection) {
|
2022-07-04 22:30:44 +00:00
|
|
|
|
super();
|
|
|
|
|
|
2013-06-12 00:13:37 +00:00
|
|
|
|
this._section = section;
|
|
|
|
|
this._connection = connection;
|
|
|
|
|
this._activeConnection = null;
|
2011-03-25 15:27:56 +00:00
|
|
|
|
|
2022-08-02 21:18:22 +00:00
|
|
|
|
this._icon = new St.Icon({
|
|
|
|
|
style_class: 'popup-menu-icon',
|
|
|
|
|
x_align: Clutter.ActorAlign.END,
|
|
|
|
|
visible: !this.radio_mode,
|
|
|
|
|
});
|
|
|
|
|
this.add_child(this._icon);
|
|
|
|
|
|
2022-08-02 10:34:18 +00:00
|
|
|
|
this._label = new St.Label({
|
|
|
|
|
y_expand: true,
|
|
|
|
|
y_align: Clutter.ActorAlign.CENTER,
|
|
|
|
|
});
|
|
|
|
|
this.add_child(this._label);
|
|
|
|
|
this.label_actor = this._label;
|
|
|
|
|
|
2022-08-02 21:18:22 +00:00
|
|
|
|
this.bind_property('icon-name',
|
|
|
|
|
this._icon, 'icon-name',
|
|
|
|
|
GObject.BindingFlags.DEFAULT);
|
|
|
|
|
this.bind_property('radio-mode',
|
|
|
|
|
this._icon, 'visible',
|
|
|
|
|
GObject.BindingFlags.INVERT_BOOLEAN);
|
|
|
|
|
|
2022-08-02 10:34:18 +00:00
|
|
|
|
this.connectObject(
|
|
|
|
|
'notify::radio-mode', () => this._sync(),
|
2022-08-02 21:18:22 +00:00
|
|
|
|
'notify::name', () => this._sync(),
|
2022-08-02 10:34:18 +00:00
|
|
|
|
this);
|
2014-02-08 14:02:05 +00:00
|
|
|
|
this._sync();
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2014-02-08 14:02:05 +00:00
|
|
|
|
|
2022-08-02 10:34:18 +00:00
|
|
|
|
get name() {
|
|
|
|
|
return this._connection.get_id();
|
|
|
|
|
}
|
2013-04-29 19:11:14 +00:00
|
|
|
|
|
2022-08-03 06:12:28 +00:00
|
|
|
|
get timestamp() {
|
|
|
|
|
return this._connection.get_setting_connection()?.get_timestamp() ?? 0;
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
|
updateForConnection(connection) {
|
2014-02-08 13:32:23 +00:00
|
|
|
|
// connection should always be the same object
|
|
|
|
|
// (and object path) as this._connection, but
|
|
|
|
|
// this can be false if NetworkManager was restarted
|
|
|
|
|
// and picked up connections in a different order
|
|
|
|
|
// Just to be safe, we set it here again
|
|
|
|
|
|
|
|
|
|
this._connection = connection;
|
2022-08-02 10:34:18 +00:00
|
|
|
|
this.notify('name');
|
2014-02-08 13:32:23 +00:00
|
|
|
|
this._sync();
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2014-02-08 13:32:23 +00:00
|
|
|
|
|
2022-08-02 10:34:18 +00:00
|
|
|
|
_updateOrnament() {
|
|
|
|
|
this.setOrnament(this.radio_mode && this.is_active
|
|
|
|
|
? PopupMenu.Ornament.DOT : PopupMenu.Ornament.NONE);
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2011-01-25 21:08:12 +00:00
|
|
|
|
|
2022-08-02 21:18:22 +00:00
|
|
|
|
_getRegularLabel() {
|
|
|
|
|
return this.is_active
|
|
|
|
|
// Translators: %s is a device name like "MyPhone"
|
|
|
|
|
? _('Disconnect %s').format(this.name)
|
|
|
|
|
// Translators: %s is a device name like "MyPhone"
|
|
|
|
|
: _('Connect to %s').format(this.name);
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
|
_sync() {
|
2022-08-02 10:34:18 +00:00
|
|
|
|
if (this.radioMode) {
|
2022-08-06 10:55:39 +00:00
|
|
|
|
this._label.text = this.name;
|
2022-08-02 10:34:18 +00:00
|
|
|
|
this.accessible_role = Atk.Role.CHECK_MENU_ITEM;
|
|
|
|
|
} else {
|
2022-08-02 21:18:22 +00:00
|
|
|
|
this._label.text = this._getRegularLabel();
|
2022-08-02 10:34:18 +00:00
|
|
|
|
this.accessible_role = Atk.Role.MENU_ITEM;
|
|
|
|
|
}
|
|
|
|
|
this._updateOrnament();
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2011-01-25 21:08:12 +00:00
|
|
|
|
|
2022-08-02 10:34:18 +00:00
|
|
|
|
activate() {
|
2022-08-02 11:41:13 +00:00
|
|
|
|
super.activate();
|
2011-01-25 21:08:12 +00:00
|
|
|
|
|
2022-08-02 10:34:18 +00:00
|
|
|
|
if (this.radio_mode && this._activeConnection != null)
|
|
|
|
|
return; // only activate in radio mode
|
2013-06-12 00:13:37 +00:00
|
|
|
|
|
2014-02-08 14:02:05 +00:00
|
|
|
|
if (this._activeConnection == null)
|
|
|
|
|
this._section.activateConnection(this._connection);
|
2022-08-02 10:34:18 +00:00
|
|
|
|
else
|
|
|
|
|
this._section.deactivateConnection(this._activeConnection);
|
2014-02-08 14:02:05 +00:00
|
|
|
|
|
|
|
|
|
this._sync();
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2011-01-25 21:08:12 +00:00
|
|
|
|
|
2022-08-02 11:41:13 +00:00
|
|
|
|
setActiveConnection(connection) {
|
|
|
|
|
this._setActiveConnection(connection);
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2022-08-02 10:34:18 +00:00
|
|
|
|
});
|
2013-06-12 00:13:37 +00:00
|
|
|
|
|
2022-08-06 10:55:39 +00:00
|
|
|
|
const NMDeviceConnectionItem = GObject.registerClass({
|
|
|
|
|
Properties: {
|
|
|
|
|
'device-name': GObject.ParamSpec.string('device-name', '', '',
|
|
|
|
|
GObject.ParamFlags.READWRITE,
|
|
|
|
|
''),
|
|
|
|
|
},
|
|
|
|
|
}, class NMDeviceConnectionItem extends NMConnectionItem {
|
|
|
|
|
constructor(section, connection) {
|
|
|
|
|
super(section, connection);
|
|
|
|
|
|
|
|
|
|
this.connectObject(
|
|
|
|
|
'notify::radio-mode', () => this.notify('name'),
|
|
|
|
|
'notify::device-name', () => this.notify('name'),
|
|
|
|
|
this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get name() {
|
|
|
|
|
return this.radioMode
|
|
|
|
|
? this._connection.get_id()
|
|
|
|
|
: this.deviceName;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2022-08-02 23:23:29 +00:00
|
|
|
|
const NMDeviceItem = GObject.registerClass({
|
|
|
|
|
Properties: {
|
|
|
|
|
'single-device-mode': GObject.ParamSpec.boolean('single-device-mode', '', '',
|
|
|
|
|
GObject.ParamFlags.READWRITE,
|
|
|
|
|
false),
|
|
|
|
|
},
|
|
|
|
|
}, class NMDeviceItem extends NMSectionItem {
|
2022-08-02 13:36:38 +00:00
|
|
|
|
constructor(client, device) {
|
2022-07-04 22:30:44 +00:00
|
|
|
|
super();
|
|
|
|
|
|
2022-08-02 13:36:38 +00:00
|
|
|
|
if (this.constructor === NMDeviceItem)
|
2022-02-07 14:14:06 +00:00
|
|
|
|
throw new TypeError(`Cannot instantiate abstract type ${this.constructor.name}`);
|
2011-01-25 21:08:12 +00:00
|
|
|
|
|
2013-04-26 23:28:48 +00:00
|
|
|
|
this._client = client;
|
2022-08-02 13:36:38 +00:00
|
|
|
|
this._device = device;
|
|
|
|
|
this._deviceName = '';
|
2013-04-26 23:28:48 +00:00
|
|
|
|
|
2014-01-14 22:49:47 +00:00
|
|
|
|
this._connectionItems = new Map();
|
2022-08-03 16:12:31 +00:00
|
|
|
|
this._itemSorter = new ItemSorter({trackMru: true});
|
2013-04-26 23:28:48 +00:00
|
|
|
|
|
2022-08-02 20:44:38 +00:00
|
|
|
|
// Item shown in the 0-connections case
|
|
|
|
|
this._autoConnectItem =
|
|
|
|
|
this.section.addAction(_('Connect'), () => this._autoConnect(), '');
|
2013-04-26 23:28:48 +00:00
|
|
|
|
|
2022-08-02 20:44:38 +00:00
|
|
|
|
// Represents the device as a whole when shown
|
|
|
|
|
this.bind_property('name',
|
|
|
|
|
this._autoConnectItem.label, 'text',
|
|
|
|
|
GObject.BindingFlags.SYNC_CREATE);
|
|
|
|
|
this.bind_property('icon-name',
|
|
|
|
|
this._autoConnectItem._icon, 'icon-name',
|
|
|
|
|
GObject.BindingFlags.SYNC_CREATE);
|
2013-04-26 23:28:48 +00:00
|
|
|
|
|
2022-08-02 20:44:38 +00:00
|
|
|
|
this._deactivateItem =
|
|
|
|
|
this.section.addAction(_('Turn Off'), () => this.deactivateConnection());
|
2022-08-02 13:36:38 +00:00
|
|
|
|
|
|
|
|
|
this._client.connectObject(
|
2022-08-02 20:44:38 +00:00
|
|
|
|
'notify::connectivity', () => this.notify('icon-name'),
|
|
|
|
|
'notify::primary-connection', () => this.notify('icon-name'),
|
2022-08-02 13:36:38 +00:00
|
|
|
|
this);
|
|
|
|
|
|
|
|
|
|
this._device.connectObject(
|
2022-08-01 15:28:54 +00:00
|
|
|
|
'notify::available-connections', () => this._syncConnections(),
|
2022-08-02 13:36:38 +00:00
|
|
|
|
'notify::active-connection', () => this._activeConnectionChanged(),
|
|
|
|
|
this);
|
2013-06-12 00:13:37 +00:00
|
|
|
|
|
2022-08-02 23:23:29 +00:00
|
|
|
|
this.connect('notify::single-device-mode', () => this._sync());
|
|
|
|
|
|
2022-08-01 15:28:54 +00:00
|
|
|
|
this._syncConnections();
|
2022-08-02 20:44:38 +00:00
|
|
|
|
this._activeConnectionChanged();
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2013-06-12 00:13:37 +00:00
|
|
|
|
|
2022-08-03 16:12:31 +00:00
|
|
|
|
get timestamp() {
|
|
|
|
|
const [item] = this._itemSorter.itemsByMru();
|
|
|
|
|
return item?.timestamp ?? 0;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-02 13:36:38 +00:00
|
|
|
|
_canReachInternet() {
|
|
|
|
|
if (this._client.primary_connection !== this._device.active_connection)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
return this._client.connectivity === NM.ConnectivityState.FULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_autoConnect() {
|
|
|
|
|
let connection = new NM.SimpleConnection();
|
|
|
|
|
this._client.add_and_activate_connection_async(connection, this._device, null, null, null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_activeConnectionChanged() {
|
2022-08-02 20:44:38 +00:00
|
|
|
|
const oldItem = this._connectionItems.get(
|
2022-08-01 15:28:54 +00:00
|
|
|
|
this._activeConnection?.connection);
|
2022-08-02 20:44:38 +00:00
|
|
|
|
oldItem?.setActiveConnection(null);
|
2022-08-02 13:36:38 +00:00
|
|
|
|
|
2022-08-02 20:44:38 +00:00
|
|
|
|
this._setActiveConnection(this._device.active_connection);
|
|
|
|
|
|
|
|
|
|
const newItem = this._connectionItems.get(
|
2022-08-01 15:28:54 +00:00
|
|
|
|
this._activeConnection?.connection);
|
2022-08-02 20:44:38 +00:00
|
|
|
|
newItem?.setActiveConnection(this._activeConnection);
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2014-03-15 11:40:13 +00:00
|
|
|
|
|
2022-08-01 15:28:54 +00:00
|
|
|
|
_syncConnections() {
|
|
|
|
|
const available = this._device.get_available_connections();
|
|
|
|
|
const removed = [...this._connectionItems.keys()]
|
|
|
|
|
.filter(conn => !available.includes(conn));
|
|
|
|
|
|
|
|
|
|
for (const conn of removed)
|
|
|
|
|
this._removeConnection(conn);
|
|
|
|
|
|
|
|
|
|
for (const conn of available)
|
|
|
|
|
this._addConnection(conn);
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2013-06-12 00:13:37 +00:00
|
|
|
|
|
2022-08-03 04:44:36 +00:00
|
|
|
|
_getActivatableItem() {
|
|
|
|
|
const [lastUsed] = this._itemSorter.itemsByMru();
|
|
|
|
|
if (lastUsed?.timestamp > 0)
|
|
|
|
|
return lastUsed;
|
|
|
|
|
|
|
|
|
|
const [firstItem] = this._itemSorter;
|
|
|
|
|
if (firstItem)
|
|
|
|
|
return firstItem;
|
|
|
|
|
|
|
|
|
|
console.assert(this._autoConnectItem.visible,
|
|
|
|
|
`${this}'s autoConnect item should be visible when otherwise empty`);
|
|
|
|
|
return this._autoConnectItem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
activate() {
|
|
|
|
|
super.activate();
|
|
|
|
|
|
|
|
|
|
if (this._activeConnection)
|
|
|
|
|
this.deactivateConnection();
|
|
|
|
|
else
|
|
|
|
|
this._getActivatableItem()?.activate();
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-02 13:36:38 +00:00
|
|
|
|
activateConnection(connection) {
|
|
|
|
|
this._client.activate_connection_async(connection, this._device, null, null, null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
deactivateConnection(_activeConnection) {
|
|
|
|
|
this._device.disconnect(null);
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2012-08-29 14:22:24 +00:00
|
|
|
|
|
2022-08-01 15:28:54 +00:00
|
|
|
|
_onConnectionChanged(connection) {
|
|
|
|
|
const item = this._connectionItems.get(connection);
|
2022-08-06 14:15:07 +00:00
|
|
|
|
item.updateForConnection(connection);
|
2022-08-01 15:28:54 +00:00
|
|
|
|
}
|
2017-02-13 13:52:23 +00:00
|
|
|
|
|
2022-08-01 15:28:54 +00:00
|
|
|
|
_resortItem(item) {
|
2022-08-03 14:05:20 +00:00
|
|
|
|
const pos = this._itemSorter.upsert(item);
|
2022-08-02 20:44:38 +00:00
|
|
|
|
this.section.moveMenuItem(item, pos);
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2017-02-13 13:52:23 +00:00
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
|
_addConnection(connection) {
|
2022-08-01 15:28:54 +00:00
|
|
|
|
if (this._connectionItems.has(connection))
|
2013-06-12 00:13:37 +00:00
|
|
|
|
return;
|
2012-08-29 14:22:24 +00:00
|
|
|
|
|
2022-08-01 15:28:54 +00:00
|
|
|
|
connection.connectObject(
|
|
|
|
|
'changed', this._onConnectionChanged.bind(this),
|
|
|
|
|
this);
|
|
|
|
|
|
|
|
|
|
const item = new NMDeviceConnectionItem(this, connection);
|
|
|
|
|
|
2022-08-02 20:44:38 +00:00
|
|
|
|
this.bind_property('radio-mode',
|
|
|
|
|
item, 'radio-mode',
|
|
|
|
|
GObject.BindingFlags.SYNC_CREATE);
|
|
|
|
|
this.bind_property('name',
|
|
|
|
|
item, 'device-name',
|
|
|
|
|
GObject.BindingFlags.SYNC_CREATE);
|
|
|
|
|
this.bind_property('icon-name',
|
|
|
|
|
item, 'icon-name',
|
|
|
|
|
GObject.BindingFlags.SYNC_CREATE);
|
2022-08-01 15:28:54 +00:00
|
|
|
|
item.connectObject(
|
|
|
|
|
'notify::name', () => this._resortItem(item),
|
|
|
|
|
this);
|
2013-06-12 00:13:37 +00:00
|
|
|
|
|
2022-08-03 14:05:20 +00:00
|
|
|
|
const pos = this._itemSorter.upsert(item);
|
2022-08-02 20:44:38 +00:00
|
|
|
|
this.section.addMenuItem(item, pos);
|
2022-08-01 15:28:54 +00:00
|
|
|
|
this._connectionItems.set(connection, item);
|
2013-04-29 19:11:14 +00:00
|
|
|
|
this._sync();
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2012-08-29 14:22:24 +00:00
|
|
|
|
|
2022-08-01 15:28:54 +00:00
|
|
|
|
_removeConnection(connection) {
|
|
|
|
|
const item = this._connectionItems.get(connection);
|
|
|
|
|
if (!item)
|
2014-03-08 18:54:09 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2022-08-03 14:05:20 +00:00
|
|
|
|
this._itemSorter.delete(item);
|
2022-08-01 15:28:54 +00:00
|
|
|
|
this._connectionItems.delete(connection);
|
2022-08-03 14:05:20 +00:00
|
|
|
|
item.destroy();
|
2012-08-29 14:22:24 +00:00
|
|
|
|
|
2013-04-29 19:11:14 +00:00
|
|
|
|
this._sync();
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2012-12-04 13:49:34 +00:00
|
|
|
|
|
2022-08-02 22:54:20 +00:00
|
|
|
|
setDeviceName(name) {
|
|
|
|
|
this._deviceName = name;
|
2022-08-02 20:44:38 +00:00
|
|
|
|
this.notify('name');
|
2022-08-02 13:36:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
|
_sync() {
|
2022-08-02 20:44:38 +00:00
|
|
|
|
const nItems = this._connectionItems.size;
|
|
|
|
|
this.radio_mode = nItems > 1;
|
2022-08-02 23:23:29 +00:00
|
|
|
|
this.useSubmenu = this.radioMode && !this.singleDeviceMode;
|
2022-08-07 20:09:23 +00:00
|
|
|
|
this._autoConnectItem.visible = nItems === 0;
|
2022-08-02 10:34:18 +00:00
|
|
|
|
this._deactivateItem.visible = this.radioMode && this.isActive;
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2022-08-02 20:44:38 +00:00
|
|
|
|
});
|
2014-01-23 19:25:06 +00:00
|
|
|
|
|
2022-08-02 20:44:38 +00:00
|
|
|
|
const NMWiredDeviceItem = GObject.registerClass(
|
|
|
|
|
class NMWiredDeviceItem extends NMDeviceItem {
|
|
|
|
|
get icon_name() {
|
|
|
|
|
switch (this.state) {
|
|
|
|
|
case NM.ActiveConnectionState.ACTIVATING:
|
|
|
|
|
return 'network-wired-acquiring-symbolic';
|
|
|
|
|
case NM.ActiveConnectionState.ACTIVATED:
|
|
|
|
|
return this._canReachInternet()
|
|
|
|
|
? 'network-wired-symbolic'
|
|
|
|
|
: 'network-wired-no-route-symbolic';
|
|
|
|
|
default:
|
|
|
|
|
return 'network-wired-disconnected-symbolic';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get name() {
|
|
|
|
|
return this._deviceName;
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
|
_hasCarrier() {
|
2017-10-31 10:38:20 +00:00
|
|
|
|
if (this._device instanceof NM.DeviceEthernet)
|
2014-01-28 22:41:13 +00:00
|
|
|
|
return this._device.carrier;
|
|
|
|
|
else
|
|
|
|
|
return true;
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2014-01-23 19:25:06 +00:00
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
|
_sync() {
|
2022-08-02 20:44:38 +00:00
|
|
|
|
this.visible = this._hasCarrier();
|
2017-10-31 01:19:44 +00:00
|
|
|
|
super._sync();
|
|
|
|
|
}
|
2022-08-02 20:44:38 +00:00
|
|
|
|
});
|
2014-01-23 19:25:06 +00:00
|
|
|
|
|
2022-08-02 20:44:38 +00:00
|
|
|
|
const NMModemDeviceItem = GObject.registerClass(
|
|
|
|
|
class NMModemDeviceItem extends NMDeviceItem {
|
2017-10-31 01:19:44 +00:00
|
|
|
|
constructor(client, device) {
|
|
|
|
|
super(client, device);
|
2013-10-02 17:39:58 +00:00
|
|
|
|
|
2013-06-12 00:13:37 +00:00
|
|
|
|
this._mobileDevice = null;
|
|
|
|
|
|
|
|
|
|
let capabilities = device.current_capabilities;
|
|
|
|
|
if (device.udi.indexOf('/org/freedesktop/ModemManager1/Modem') == 0)
|
|
|
|
|
this._mobileDevice = new ModemManager.BroadbandModem(device.udi, capabilities);
|
2017-10-31 10:38:20 +00:00
|
|
|
|
else if (capabilities & NM.DeviceModemCapabilities.GSM_UMTS)
|
2013-06-12 00:13:37 +00:00
|
|
|
|
this._mobileDevice = new ModemManager.ModemGsm(device.udi);
|
2017-10-31 10:38:20 +00:00
|
|
|
|
else if (capabilities & NM.DeviceModemCapabilities.CDMA_EVDO)
|
2013-06-12 00:13:37 +00:00
|
|
|
|
this._mobileDevice = new ModemManager.ModemCdma(device.udi);
|
2017-10-31 10:38:20 +00:00
|
|
|
|
else if (capabilities & NM.DeviceModemCapabilities.LTE)
|
2013-06-12 00:13:37 +00:00
|
|
|
|
this._mobileDevice = new ModemManager.ModemGsm(device.udi);
|
|
|
|
|
|
2021-08-15 22:36:59 +00:00
|
|
|
|
this._mobileDevice?.connectObject(
|
|
|
|
|
'notify::operator-name', this._sync.bind(this),
|
2022-08-02 20:44:38 +00:00
|
|
|
|
'notify::signal-quality', () => this.notify('icon-name'), this);
|
2021-06-07 15:49:57 +00:00
|
|
|
|
|
2021-08-15 22:36:59 +00:00
|
|
|
|
Main.sessionMode.connectObject('updated',
|
|
|
|
|
this._sessionUpdated.bind(this), this);
|
2021-06-07 15:49:57 +00:00
|
|
|
|
this._sessionUpdated();
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-02 20:44:38 +00:00
|
|
|
|
get icon_name() {
|
|
|
|
|
switch (this.state) {
|
|
|
|
|
case NM.ActiveConnectionState.ACTIVATING:
|
|
|
|
|
return 'network-cellular-acquiring-symbolic';
|
|
|
|
|
case NM.ActiveConnectionState.ACTIVATED: {
|
|
|
|
|
const qualityString = signalToIcon(this._mobileDevice.signal_quality);
|
|
|
|
|
return `network-cellular-signal-${qualityString}-symbolic`;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
return this._activeConnection
|
|
|
|
|
? 'network-cellular-signal-none-symbolic'
|
|
|
|
|
: 'network-cellular-disabled-symbolic';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get name() {
|
|
|
|
|
return this._mobileDevice?.operator_name || this._deviceName;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-03 03:35:25 +00:00
|
|
|
|
get wwanPanelSupported() {
|
2021-08-10 09:52:30 +00:00
|
|
|
|
// Currently, wwan panel doesn't support CDMA_EVDO modems
|
|
|
|
|
const supportedCaps =
|
|
|
|
|
NM.DeviceModemCapabilities.GSM_UMTS |
|
|
|
|
|
NM.DeviceModemCapabilities.LTE;
|
|
|
|
|
return this._device.current_capabilities & supportedCaps;
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
|
_autoConnect() {
|
2022-08-03 03:35:25 +00:00
|
|
|
|
if (this.wwanPanelSupported)
|
2021-08-10 09:52:30 +00:00
|
|
|
|
launchSettingsPanel('wwan', 'show-device', this._device.udi);
|
|
|
|
|
else
|
|
|
|
|
launchSettingsPanel('network', 'connect-3g', this._device.get_path());
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2013-04-29 19:11:14 +00:00
|
|
|
|
|
2021-06-07 15:49:57 +00:00
|
|
|
|
_sessionUpdated() {
|
|
|
|
|
this._autoConnectItem.sensitive = Main.sessionMode.hasWindows;
|
|
|
|
|
}
|
2022-08-02 20:44:38 +00:00
|
|
|
|
});
|
2021-06-07 15:49:57 +00:00
|
|
|
|
|
2022-08-02 20:44:38 +00:00
|
|
|
|
const NMBluetoothDeviceItem = GObject.registerClass(
|
|
|
|
|
class NMBluetoothDeviceItem extends NMDeviceItem {
|
2017-10-31 01:19:44 +00:00
|
|
|
|
constructor(client, device) {
|
|
|
|
|
super(client, device);
|
2013-10-02 17:39:58 +00:00
|
|
|
|
|
2022-08-02 20:44:38 +00:00
|
|
|
|
this._device.bind_property('name',
|
|
|
|
|
this, 'name',
|
|
|
|
|
GObject.BindingFlags.SYNC_CREATE);
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-02 20:44:38 +00:00
|
|
|
|
get icon_name() {
|
|
|
|
|
switch (this.state) {
|
|
|
|
|
case NM.ActiveConnectionState.ACTIVATING:
|
|
|
|
|
return 'network-cellular-acquiring-symbolic';
|
|
|
|
|
case NM.ActiveConnectionState.ACTIVATED:
|
|
|
|
|
return 'network-cellular-connected-symbolic';
|
|
|
|
|
default:
|
|
|
|
|
return this._activeConnection
|
|
|
|
|
? 'network-cellular-signal-none-symbolic'
|
|
|
|
|
: 'network-cellular-disabled-symbolic';
|
|
|
|
|
}
|
2022-02-21 12:39:17 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-02 20:44:38 +00:00
|
|
|
|
get name() {
|
|
|
|
|
return this._device.name;
|
2013-04-29 19:11:14 +00:00
|
|
|
|
}
|
2022-08-02 20:44:38 +00:00
|
|
|
|
});
|
2013-06-12 04:03:36 +00:00
|
|
|
|
|
2022-07-23 23:11:32 +00:00
|
|
|
|
const WirelessNetwork = GObject.registerClass({
|
|
|
|
|
Properties: {
|
|
|
|
|
'name': GObject.ParamSpec.string(
|
|
|
|
|
'name', '', '',
|
|
|
|
|
GObject.ParamFlags.READABLE,
|
|
|
|
|
''),
|
|
|
|
|
'icon-name': GObject.ParamSpec.string(
|
|
|
|
|
'icon-name', '', '',
|
|
|
|
|
GObject.ParamFlags.READABLE,
|
|
|
|
|
''),
|
|
|
|
|
'secure': GObject.ParamSpec.boolean(
|
|
|
|
|
'secure', '', '',
|
|
|
|
|
GObject.ParamFlags.READABLE,
|
|
|
|
|
false),
|
|
|
|
|
'is-active': GObject.ParamSpec.boolean(
|
|
|
|
|
'is-active', '', '',
|
|
|
|
|
GObject.ParamFlags.READABLE,
|
|
|
|
|
false),
|
|
|
|
|
},
|
|
|
|
|
Signals: {
|
|
|
|
|
'destroy': {},
|
|
|
|
|
},
|
|
|
|
|
}, class WirelessNetwork extends GObject.Object {
|
|
|
|
|
static _securityTypes =
|
|
|
|
|
Object.values(NM.UtilsSecurityType).sort((a, b) => b - a);
|
|
|
|
|
|
|
|
|
|
_init(device) {
|
|
|
|
|
super._init();
|
|
|
|
|
|
|
|
|
|
this._device = device;
|
|
|
|
|
|
|
|
|
|
this._device.connectObject(
|
|
|
|
|
'notify::active-access-point', () => this.notify('is-active'),
|
|
|
|
|
this);
|
|
|
|
|
|
|
|
|
|
this._accessPoints = new Set();
|
|
|
|
|
this._connections = [];
|
|
|
|
|
this._name = '';
|
|
|
|
|
this._ssid = null;
|
|
|
|
|
this._bestAp = null;
|
|
|
|
|
this._mode = 0;
|
|
|
|
|
this._securityType = NM.UtilsSecurityType.NONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get _strength() {
|
|
|
|
|
return this._bestAp?.strength ?? 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get name() {
|
|
|
|
|
return this._name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get icon_name() {
|
|
|
|
|
if (this._mode === NM80211Mode.ADHOC)
|
|
|
|
|
return 'network-workgroup-symbolic';
|
|
|
|
|
|
|
|
|
|
if (!this._bestAp)
|
|
|
|
|
return '';
|
|
|
|
|
|
|
|
|
|
return `network-wireless-signal-${signalToIcon(this._bestAp.strength)}-symbolic`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get secure() {
|
|
|
|
|
return this._securityType !== NM.UtilsSecurityType.NONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get is_active() {
|
|
|
|
|
return this._accessPoints.has(this._device.activeAccessPoint);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
hasAccessPoint(ap) {
|
|
|
|
|
return this._accessPoints.has(ap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
hasAccessPoints() {
|
|
|
|
|
return this._accessPoints.size > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
checkAccessPoint(ap) {
|
|
|
|
|
if (!ap.get_ssid())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
const secType = this._getApSecurityType(ap);
|
|
|
|
|
if (secType === NM.UtilsSecurityType.INVALID)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (this._accessPoints.size === 0)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
return this._ssid.equal(ap.ssid) &&
|
|
|
|
|
this._mode === ap.mode &&
|
|
|
|
|
this._securityType === secType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param {NM.AccessPoint} ap - an access point
|
|
|
|
|
* @returns {bool} - whether the access point was added
|
|
|
|
|
*/
|
|
|
|
|
addAccessPoint(ap) {
|
|
|
|
|
if (!this.checkAccessPoint(ap))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (this._accessPoints.size === 0) {
|
|
|
|
|
this._ssid = ap.get_ssid();
|
|
|
|
|
this._mode = ap.mode;
|
|
|
|
|
this._securityType = this._getApSecurityType(ap);
|
|
|
|
|
this._name = NM.utils_ssid_to_utf8(this._ssid.get_data()) || '<unknown>';
|
|
|
|
|
|
|
|
|
|
this.notify('name');
|
|
|
|
|
this.notify('secure');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const wasActive = this.is_active;
|
|
|
|
|
this._accessPoints.add(ap);
|
|
|
|
|
|
|
|
|
|
ap.connectObject(
|
2022-08-09 10:55:16 +00:00
|
|
|
|
'notify::strength', () => {
|
|
|
|
|
this.notify('icon-name');
|
|
|
|
|
this._updateBestAp();
|
|
|
|
|
}, this);
|
2022-07-23 23:11:32 +00:00
|
|
|
|
this._updateBestAp();
|
|
|
|
|
|
|
|
|
|
if (wasActive !== this.is_active)
|
|
|
|
|
this.notify('is-active');
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param {NM.AccessPoint} ap - an access point
|
|
|
|
|
* @returns {bool} - whether the access point was removed
|
|
|
|
|
*/
|
|
|
|
|
removeAccessPoint(ap) {
|
|
|
|
|
const wasActive = this.is_active;
|
|
|
|
|
if (!this._accessPoints.delete(ap))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
this._updateBestAp();
|
|
|
|
|
|
|
|
|
|
if (wasActive !== this.is_active)
|
|
|
|
|
this.notify('is-active');
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param {WirelessNetwork} other - network to compare with
|
|
|
|
|
* @returns {number} - the sort order
|
|
|
|
|
*/
|
|
|
|
|
compare(other) {
|
|
|
|
|
// place known connections first
|
|
|
|
|
const cmpConnections = other.hasConnections() - this.hasConnections();
|
|
|
|
|
if (cmpConnections !== 0)
|
|
|
|
|
return cmpConnections;
|
|
|
|
|
|
|
|
|
|
const cmpAps = other.hasAccessPoints() - this.hasAccessPoints();
|
|
|
|
|
if (cmpAps !== 0)
|
|
|
|
|
return cmpAps;
|
|
|
|
|
|
|
|
|
|
// place stronger connections first
|
|
|
|
|
const cmpStrength = other._strength - this._strength;
|
|
|
|
|
if (cmpStrength !== 0)
|
|
|
|
|
return cmpStrength;
|
|
|
|
|
|
|
|
|
|
// place secure connections first
|
|
|
|
|
const cmpSec = other.secure - this.secure;
|
|
|
|
|
if (cmpSec !== 0)
|
|
|
|
|
return cmpSec;
|
|
|
|
|
|
|
|
|
|
// sort alphabetically
|
|
|
|
|
return GLib.utf8_collate(this._name, other._name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
hasConnections() {
|
|
|
|
|
return this._connections.length > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
checkConnections(connections) {
|
|
|
|
|
const aps = [...this._accessPoints];
|
|
|
|
|
this._connections = connections.filter(
|
|
|
|
|
c => aps.some(ap => ap.connection_valid(c)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
canAutoconnect() {
|
|
|
|
|
const canAutoconnect =
|
|
|
|
|
this._securityTypes !== NM.UtilsSecurityType.WPA_ENTERPRISE &&
|
|
|
|
|
this._securityTypes !== NM.UtilsSecurityType.WPA2_ENTERPRISE;
|
|
|
|
|
return canAutoconnect;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
activate() {
|
|
|
|
|
const [ap] = this._accessPoints;
|
|
|
|
|
let [conn] = this._connections;
|
|
|
|
|
if (conn) {
|
|
|
|
|
this._device.client.activate_connection_async(conn, this._device, null, null, null);
|
|
|
|
|
} else if (!this.canAutoconnect()) {
|
|
|
|
|
launchSettingsPanel('wifi', 'connect-8021x-wifi',
|
|
|
|
|
this._getDeviceDBusPath(), ap.get_path());
|
|
|
|
|
} else {
|
|
|
|
|
conn = new NM.SimpleConnection();
|
|
|
|
|
this._device.client.add_and_activate_connection_async(
|
|
|
|
|
conn, this._device, ap.get_path(), null, null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
destroy() {
|
|
|
|
|
this.emit('destroy');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_getDeviceDBusPath() {
|
|
|
|
|
// nm_object_get_path() is shadowed by nm_device_get_path()
|
|
|
|
|
return NM.Object.prototype.get_path.call(this._device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_getApSecurityType(ap) {
|
|
|
|
|
const {wirelessCapabilities: caps} = this._device;
|
|
|
|
|
const {flags, wpaFlags, rsnFlags} = ap;
|
|
|
|
|
const haveAp = true;
|
|
|
|
|
const adHoc = ap.mode === NM80211Mode.ADHOC;
|
|
|
|
|
const bestType = WirelessNetwork._securityTypes
|
|
|
|
|
.find(t => NM.utils_security_valid(t, caps, haveAp, adHoc, flags, wpaFlags, rsnFlags));
|
|
|
|
|
return bestType ?? NM.UtilsSecurityType.INVALID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_updateBestAp() {
|
|
|
|
|
const [bestAp] =
|
|
|
|
|
[...this._accessPoints].sort((a, b) => b.strength - a.strength);
|
|
|
|
|
|
|
|
|
|
if (this._bestAp === bestAp)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
this._bestAp = bestAp;
|
|
|
|
|
this.notify('icon-name');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
registerDestroyableType(WirelessNetwork);
|
|
|
|
|
|
2022-08-06 00:43:29 +00:00
|
|
|
|
const NMWirelessNetworkItem = GObject.registerClass(
|
|
|
|
|
class NMWirelessNetworkItem extends PopupMenu.PopupBaseMenuItem {
|
2019-05-22 16:27:15 +00:00
|
|
|
|
_init(network) {
|
2022-08-06 00:43:29 +00:00
|
|
|
|
super._init({style_class: 'nm-network-item'});
|
|
|
|
|
|
2013-06-12 04:03:36 +00:00
|
|
|
|
this._network = network;
|
|
|
|
|
|
2022-08-06 00:43:29 +00:00
|
|
|
|
const icons = new St.BoxLayout();
|
|
|
|
|
this.add_child(icons);
|
2019-05-22 16:27:15 +00:00
|
|
|
|
|
2022-08-06 00:43:29 +00:00
|
|
|
|
this._signalIcon = new St.Icon({style_class: 'popup-menu-icon'});
|
|
|
|
|
icons.add_child(this._signalIcon);
|
2013-06-12 04:03:36 +00:00
|
|
|
|
|
2022-08-06 00:43:29 +00:00
|
|
|
|
this._secureIcon = new St.Icon({
|
|
|
|
|
style_class: 'wireless-secure-icon',
|
|
|
|
|
y_align: Clutter.ActorAlign.END,
|
2019-10-21 18:44:00 +00:00
|
|
|
|
});
|
2022-08-06 00:43:29 +00:00
|
|
|
|
icons.add_actor(this._secureIcon);
|
2013-06-12 04:03:36 +00:00
|
|
|
|
|
2022-08-06 00:43:29 +00:00
|
|
|
|
this._label = new St.Label();
|
2019-05-22 16:27:15 +00:00
|
|
|
|
this.label_actor = this._label;
|
2019-10-21 18:44:00 +00:00
|
|
|
|
this.add_child(this._label);
|
2013-08-19 14:31:31 +00:00
|
|
|
|
|
2020-03-29 21:51:13 +00:00
|
|
|
|
this._selectedIcon = new St.Icon({
|
2022-08-06 00:43:29 +00:00
|
|
|
|
style_class: 'popup-menu-icon',
|
2020-03-29 21:51:13 +00:00
|
|
|
|
icon_name: 'object-select-symbolic',
|
|
|
|
|
});
|
2019-05-22 16:27:15 +00:00
|
|
|
|
this.add(this._selectedIcon);
|
2013-06-12 04:03:36 +00:00
|
|
|
|
|
2022-07-23 23:11:32 +00:00
|
|
|
|
this._network.bind_property('icon-name',
|
|
|
|
|
this._signalIcon, 'icon-name',
|
|
|
|
|
GObject.BindingFlags.SYNC_CREATE);
|
|
|
|
|
this._network.bind_property('name',
|
|
|
|
|
this._label, 'text',
|
|
|
|
|
GObject.BindingFlags.SYNC_CREATE);
|
|
|
|
|
this._network.bind_property('is-active',
|
|
|
|
|
this._selectedIcon, 'visible',
|
|
|
|
|
GObject.BindingFlags.SYNC_CREATE);
|
|
|
|
|
this._network.bind_property_full('secure',
|
|
|
|
|
this._secureIcon, 'icon-name',
|
|
|
|
|
GObject.BindingFlags.SYNC_CREATE,
|
|
|
|
|
(bind, source) => [true, source ? 'network-wireless-encrypted-symbolic' : ''],
|
|
|
|
|
null);
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2013-06-12 04:03:36 +00:00
|
|
|
|
|
2022-07-23 23:11:32 +00:00
|
|
|
|
get network() {
|
|
|
|
|
return this._network;
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2019-05-23 20:45:44 +00:00
|
|
|
|
});
|
2013-06-12 04:03:36 +00:00
|
|
|
|
|
2022-08-02 23:23:29 +00:00
|
|
|
|
const NMWirelessDeviceItem = GObject.registerClass({
|
|
|
|
|
Properties: {
|
2022-08-05 10:30:12 +00:00
|
|
|
|
'is-hotspot': GObject.ParamSpec.boolean('is-hotspot', '', '',
|
|
|
|
|
GObject.ParamFlags.READABLE,
|
|
|
|
|
false),
|
2022-08-02 23:23:29 +00:00
|
|
|
|
'single-device-mode': GObject.ParamSpec.boolean('single-device-mode', '', '',
|
|
|
|
|
GObject.ParamFlags.READWRITE,
|
|
|
|
|
false),
|
|
|
|
|
},
|
|
|
|
|
}, class NMWirelessDeviceItem extends NMSectionItem {
|
2017-10-31 01:19:44 +00:00
|
|
|
|
constructor(client, device) {
|
2022-07-04 22:30:44 +00:00
|
|
|
|
super();
|
|
|
|
|
|
2013-06-12 04:03:36 +00:00
|
|
|
|
this._client = client;
|
|
|
|
|
this._device = device;
|
|
|
|
|
|
2022-08-02 22:54:20 +00:00
|
|
|
|
this._deviceName = '';
|
2013-06-12 04:03:36 +00:00
|
|
|
|
|
2022-08-06 00:43:29 +00:00
|
|
|
|
this._networkItems = new Map();
|
|
|
|
|
this._itemSorter = new ItemSorter({
|
|
|
|
|
sortFunc: (one, two) => one.network.compare(two.network),
|
|
|
|
|
});
|
2013-06-12 04:03:36 +00:00
|
|
|
|
|
2021-08-15 22:36:59 +00:00
|
|
|
|
this._client.connectObject(
|
2022-08-06 00:43:29 +00:00
|
|
|
|
'notify::wireless-enabled', () => this.notify('icon-name'),
|
2022-08-02 20:44:38 +00:00
|
|
|
|
'notify::connectivity', () => this.notify('icon-name'),
|
|
|
|
|
'notify::primary-connection', () => this.notify('icon-name'),
|
2022-08-05 11:21:26 +00:00
|
|
|
|
this);
|
2021-08-15 22:36:59 +00:00
|
|
|
|
|
|
|
|
|
this._device.connectObject(
|
|
|
|
|
'notify::active-access-point', this._activeApChanged.bind(this),
|
2022-08-02 20:44:38 +00:00
|
|
|
|
'notify::active-connection', () => this._activeConnectionChanged(),
|
2022-08-06 00:43:29 +00:00
|
|
|
|
'notify::available-connections', () => this._availableConnectionsChanged(),
|
2022-08-05 10:30:12 +00:00
|
|
|
|
'state-changed', () => this.notify('is-hotspot'),
|
2022-08-06 00:43:29 +00:00
|
|
|
|
'access-point-added', (d, ap) => {
|
|
|
|
|
this._addAccessPoint(ap);
|
|
|
|
|
this._updateItemsVisibility();
|
|
|
|
|
},
|
|
|
|
|
'access-point-removed', (d, ap) => {
|
|
|
|
|
this._removeAccessPoint(ap);
|
|
|
|
|
this._updateItemsVisibility();
|
|
|
|
|
}, this);
|
2013-06-12 04:03:36 +00:00
|
|
|
|
|
2022-08-02 23:23:29 +00:00
|
|
|
|
this.bind_property('single-device-mode',
|
|
|
|
|
this, 'use-submenu',
|
|
|
|
|
GObject.BindingFlags.INVERT_BOOLEAN);
|
|
|
|
|
|
2022-08-06 00:43:29 +00:00
|
|
|
|
Main.sessionMode.connectObject('updated',
|
|
|
|
|
() => this._updateItemsVisibility(),
|
|
|
|
|
this);
|
|
|
|
|
|
|
|
|
|
for (const ap of this._device.get_access_points())
|
|
|
|
|
this._addAccessPoint(ap);
|
2022-08-02 20:44:38 +00:00
|
|
|
|
|
2022-08-04 22:32:24 +00:00
|
|
|
|
this._activeApChanged();
|
2022-08-02 20:44:38 +00:00
|
|
|
|
this._activeConnectionChanged();
|
2022-08-06 00:43:29 +00:00
|
|
|
|
this._availableConnectionsChanged();
|
|
|
|
|
this._updateItemsVisibility();
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-02 20:44:38 +00:00
|
|
|
|
get icon_name() {
|
|
|
|
|
if (!this._device.client.wireless_enabled)
|
|
|
|
|
return 'network-wireless-disabled-symbolic';
|
2014-03-15 11:40:13 +00:00
|
|
|
|
|
2022-08-02 20:44:38 +00:00
|
|
|
|
switch (this.state) {
|
|
|
|
|
case NM.ActiveConnectionState.ACTIVATING:
|
|
|
|
|
return 'network-wireless-acquiring-symbolic';
|
2021-08-15 22:36:59 +00:00
|
|
|
|
|
2022-08-02 20:44:38 +00:00
|
|
|
|
case NM.ActiveConnectionState.ACTIVATED: {
|
2022-08-05 10:30:12 +00:00
|
|
|
|
if (this.is_hotspot)
|
2022-08-02 20:44:38 +00:00
|
|
|
|
return 'network-wireless-hotspot-symbolic';
|
|
|
|
|
|
|
|
|
|
if (!this._canReachInternet())
|
|
|
|
|
return 'network-wireless-no-route-symbolic';
|
|
|
|
|
|
|
|
|
|
if (!this._activeAccessPoint) {
|
|
|
|
|
if (this._device.mode !== NM80211Mode.ADHOC)
|
|
|
|
|
console.info('An active wireless connection, in infrastructure mode, involves no access point?');
|
|
|
|
|
|
|
|
|
|
return 'network-wireless-connected-symbolic';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const {strength} = this._activeAccessPoint;
|
|
|
|
|
return `network-wireless-signal-${signalToIcon(strength)}-symbolic`;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
return 'network-wireless-signal-none-symbolic';
|
2014-02-24 16:25:38 +00:00
|
|
|
|
}
|
2022-08-02 20:44:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get name() {
|
2022-08-05 10:30:12 +00:00
|
|
|
|
if (this.is_hotspot)
|
2022-08-02 20:44:38 +00:00
|
|
|
|
/* Translators: %s is a network identifier */
|
|
|
|
|
return _('%s Hotspot').format(this._deviceName);
|
|
|
|
|
|
|
|
|
|
const {ssid} = this._activeAccessPoint ?? {};
|
|
|
|
|
if (ssid)
|
|
|
|
|
return ssidToLabel(ssid);
|
2013-06-12 04:03:36 +00:00
|
|
|
|
|
2022-08-02 20:44:38 +00:00
|
|
|
|
return this._deviceName;
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2013-06-12 04:03:36 +00:00
|
|
|
|
|
2022-08-05 10:30:12 +00:00
|
|
|
|
get is_hotspot() {
|
|
|
|
|
if (!this._device.active_connection)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
const {connection} = this._device.active_connection;
|
|
|
|
|
if (!connection)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
let ip4config = connection.get_setting_ip4_config();
|
|
|
|
|
if (!ip4config)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return ip4config.get_method() === NM.SETTING_IP4_CONFIG_METHOD_SHARED;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-05 11:40:45 +00:00
|
|
|
|
activate() {
|
|
|
|
|
if (!this.is_hotspot)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
const {activeConnection} = this._device;
|
|
|
|
|
this._client.deactivate_connection_async(activeConnection, null, null);
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
|
_activeApChanged() {
|
2021-08-15 22:36:59 +00:00
|
|
|
|
this._activeAccessPoint?.disconnectObject(this);
|
2013-06-12 04:03:36 +00:00
|
|
|
|
this._activeAccessPoint = this._device.active_access_point;
|
2022-08-04 22:39:47 +00:00
|
|
|
|
this._activeAccessPoint?.connectObject(
|
2022-08-02 20:44:38 +00:00
|
|
|
|
'notify::strength', () => this.notify('icon-name'),
|
|
|
|
|
'notify::ssid', () => this.notify('name'),
|
2022-08-04 22:39:47 +00:00
|
|
|
|
this);
|
2013-06-12 04:03:36 +00:00
|
|
|
|
|
2022-08-02 20:44:38 +00:00
|
|
|
|
this.notify('icon-name');
|
|
|
|
|
this.notify('name');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_activeConnectionChanged() {
|
|
|
|
|
this._setActiveConnection(this._device.active_connection);
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2013-06-12 04:03:36 +00:00
|
|
|
|
|
2022-08-06 00:43:29 +00:00
|
|
|
|
_availableConnectionsChanged() {
|
|
|
|
|
const connections = this._device.get_available_connections();
|
|
|
|
|
for (const net of this._networkItems.keys())
|
|
|
|
|
net.checkConnections(connections);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_addAccessPoint(ap) {
|
|
|
|
|
if (ap.get_ssid() == null) {
|
|
|
|
|
// This access point is not visible yet
|
|
|
|
|
// Wait for it to get a ssid
|
|
|
|
|
ap.connectObject('notify::ssid', () => {
|
|
|
|
|
if (!ap.ssid)
|
|
|
|
|
return;
|
|
|
|
|
ap.disconnectObject(this);
|
|
|
|
|
this._addAccessPoint(ap);
|
|
|
|
|
}, this);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let network = [...this._networkItems.keys()]
|
|
|
|
|
.find(n => n.checkAccessPoint(ap));
|
|
|
|
|
|
|
|
|
|
if (!network) {
|
|
|
|
|
network = new WirelessNetwork(this._device);
|
|
|
|
|
|
|
|
|
|
const item = new NMWirelessNetworkItem(network);
|
|
|
|
|
item.connect('activate', () => network.activate());
|
|
|
|
|
|
|
|
|
|
network.connectObject(
|
|
|
|
|
'notify::icon-name', () => this._resortItem(item),
|
|
|
|
|
'notify::is-active', () => this._resortItem(item),
|
|
|
|
|
this);
|
|
|
|
|
|
|
|
|
|
const pos = this._itemSorter.upsert(item);
|
|
|
|
|
this.section.addMenuItem(item, pos);
|
|
|
|
|
this._networkItems.set(network, item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
network.addAccessPoint(ap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_removeAccessPoint(ap) {
|
|
|
|
|
const network = [...this._networkItems.keys()]
|
|
|
|
|
.find(n => n.removeAccessPoint(ap));
|
|
|
|
|
|
|
|
|
|
if (!network || network.hasAccessPoints())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
const item = this._networkItems.get(network);
|
|
|
|
|
this._itemSorter.delete(item);
|
|
|
|
|
this._networkItems.delete(network);
|
|
|
|
|
|
|
|
|
|
item?.destroy();
|
|
|
|
|
network.destroy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_resortItem(item) {
|
|
|
|
|
const pos = this._itemSorter.upsert(item);
|
|
|
|
|
this.section.moveMenuItem(item, pos);
|
|
|
|
|
|
|
|
|
|
this._updateItemsVisibility();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_updateItemsVisibility() {
|
|
|
|
|
const {hasWindows} = Main.sessionMode;
|
|
|
|
|
|
|
|
|
|
let nVisible = 0;
|
|
|
|
|
for (const item of this._itemSorter) {
|
|
|
|
|
const {network: net} = item;
|
|
|
|
|
item.visible =
|
|
|
|
|
(hasWindows || net.hasConnections() || net.canAutoconnect()) &&
|
2022-12-21 08:13:31 +00:00
|
|
|
|
nVisible < MAX_VISIBLE_NETWORKS;
|
|
|
|
|
if (item.visible)
|
|
|
|
|
nVisible++;
|
2022-08-06 00:43:29 +00:00
|
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2013-06-12 04:03:36 +00:00
|
|
|
|
|
2022-08-02 22:54:20 +00:00
|
|
|
|
setDeviceName(name) {
|
|
|
|
|
this._deviceName = name;
|
2022-08-02 20:44:38 +00:00
|
|
|
|
this.notify('name');
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2013-06-12 04:03:36 +00:00
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
|
_canReachInternet() {
|
2022-08-07 20:09:23 +00:00
|
|
|
|
if (this._client.primary_connection !== this._device.active_connection)
|
2014-02-03 23:04:43 +00:00
|
|
|
|
return true;
|
|
|
|
|
|
2022-08-07 20:09:23 +00:00
|
|
|
|
return this._client.connectivity === NM.ConnectivityState.FULL;
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2022-08-02 20:44:38 +00:00
|
|
|
|
});
|
2013-06-12 04:03:36 +00:00
|
|
|
|
|
status/network: Decouple NMVpnSection from NMConnectionSection
The NMConnectionSection class is used - surprise - to manage a
list of related connections. And while the presentation of VPN
items is slightly different from connections associated with
devices (switches vs. ornaments), it makes perfect sense for
the VPN section to share the nitty-gritty with the base class.
But…
Right now it is perfectly fine for NMConnectionSection to be
used both as a child element in a device section, and as toplevel
item of the VPN section. Any nesting of sections is entirely
transparent to the user, and all connection sections appear as
submenu items in the toplevel menu.
That won't work for quick settings.
There's no PopoverMenuSection that allows invisible grouping, so
adding items dynamically would either need to happen at the end,
or require some tricky cross-component code to impose a particular
order.
And last but not least, quick toggles are very much unsuited for
a potentially large number of items. The whole point is to provide
quick direct access to system features, not to compete with menus
over the number of items they can hold.
That is, we need to get from the current state where each device
appears as a toplevel item, to a state where we have one quick
toggle for each device type plus one for VPN.
The decoupled VPN section still behaves largely as it did as a
subclass, with the notable difference that it no longer uses
a submenu item, so all VPN connections now appear at the toplevel.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2407>
2022-08-01 17:08:18 +00:00
|
|
|
|
const NMVpnConnectionItem = GObject.registerClass({
|
|
|
|
|
Signals: {
|
|
|
|
|
'activation-failed': {},
|
|
|
|
|
},
|
|
|
|
|
}, class NMVpnConnectionItem extends NMConnectionItem {
|
2022-08-02 10:34:18 +00:00
|
|
|
|
constructor(section, connection) {
|
|
|
|
|
super(section, connection);
|
|
|
|
|
|
|
|
|
|
this._label.x_expand = true;
|
2022-08-15 15:40:52 +00:00
|
|
|
|
this.accessible_role = Atk.Role.CHECK_MENU_ITEM;
|
|
|
|
|
this._icon.hide();
|
2022-08-02 10:34:18 +00:00
|
|
|
|
|
|
|
|
|
this._switch = new PopupMenu.Switch(this.is_active);
|
|
|
|
|
this.add_child(this._switch);
|
|
|
|
|
|
|
|
|
|
this.bind_property('is-active',
|
|
|
|
|
this._switch, 'state',
|
|
|
|
|
GObject.BindingFlags.SYNC_CREATE);
|
2022-08-15 15:40:52 +00:00
|
|
|
|
this.bind_property('name',
|
|
|
|
|
this._label, 'text',
|
|
|
|
|
GObject.BindingFlags.SYNC_CREATE);
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2014-02-08 14:02:05 +00:00
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
|
_sync() {
|
2022-08-15 15:40:52 +00:00
|
|
|
|
if (this.is_active)
|
2022-08-02 10:34:18 +00:00
|
|
|
|
this.add_accessible_state(Atk.StateType.CHECKED);
|
|
|
|
|
else
|
|
|
|
|
this.remove_accessible_state(Atk.StateType.CHECKED);
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2014-02-08 14:02:05 +00:00
|
|
|
|
|
2022-08-02 11:41:13 +00:00
|
|
|
|
_activeConnectionStateChanged() {
|
2022-08-02 09:46:28 +00:00
|
|
|
|
const state = this._activeConnection?.get_state();
|
|
|
|
|
const reason = this._activeConnection?.get_state_reason();
|
|
|
|
|
|
|
|
|
|
if (state === NM.ActiveConnectionState.DEACTIVATED &&
|
|
|
|
|
reason !== NM.ActiveConnectionStateReason.NO_SECRETS &&
|
|
|
|
|
reason !== NM.ActiveConnectionStateReason.USER_DISCONNECTED)
|
2022-07-31 23:21:50 +00:00
|
|
|
|
this.emit('activation-failed');
|
2012-08-29 14:22:24 +00:00
|
|
|
|
|
2022-08-02 11:41:13 +00:00
|
|
|
|
super._activeConnectionStateChanged();
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2013-04-26 23:21:02 +00:00
|
|
|
|
|
2022-08-02 10:34:18 +00:00
|
|
|
|
get icon_name() {
|
|
|
|
|
switch (this.state) {
|
|
|
|
|
case NM.ActiveConnectionState.ACTIVATING:
|
|
|
|
|
return 'network-vpn-acquiring-symbolic';
|
|
|
|
|
case NM.ActiveConnectionState.ACTIVATED:
|
|
|
|
|
return 'network-vpn-symbolic';
|
|
|
|
|
default:
|
|
|
|
|
return 'network-vpn-disabled-symbolic';
|
2013-04-29 19:20:45 +00:00
|
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2022-08-06 10:55:39 +00:00
|
|
|
|
|
|
|
|
|
set icon_name(_ignored) {
|
|
|
|
|
}
|
2022-08-02 10:34:18 +00:00
|
|
|
|
});
|
2013-04-26 23:21:02 +00:00
|
|
|
|
|
2022-08-03 04:03:40 +00:00
|
|
|
|
const NMToggle = GObject.registerClass({
|
2022-08-03 00:14:52 +00:00
|
|
|
|
Signals: {
|
|
|
|
|
'activation-failed': {},
|
|
|
|
|
},
|
2022-08-03 04:03:40 +00:00
|
|
|
|
}, class NMToggle extends QuickMenuToggle {
|
2022-08-01 17:41:26 +00:00
|
|
|
|
constructor() {
|
status/network: Decouple NMVpnSection from NMConnectionSection
The NMConnectionSection class is used - surprise - to manage a
list of related connections. And while the presentation of VPN
items is slightly different from connections associated with
devices (switches vs. ornaments), it makes perfect sense for
the VPN section to share the nitty-gritty with the base class.
But…
Right now it is perfectly fine for NMConnectionSection to be
used both as a child element in a device section, and as toplevel
item of the VPN section. Any nesting of sections is entirely
transparent to the user, and all connection sections appear as
submenu items in the toplevel menu.
That won't work for quick settings.
There's no PopoverMenuSection that allows invisible grouping, so
adding items dynamically would either need to happen at the end,
or require some tricky cross-component code to impose a particular
order.
And last but not least, quick toggles are very much unsuited for
a potentially large number of items. The whole point is to provide
quick direct access to system features, not to compete with menus
over the number of items they can hold.
That is, we need to get from the current state where each device
appears as a toplevel item, to a state where we have one quick
toggle for each device type plus one for VPN.
The decoupled VPN section still behaves largely as it did as a
subclass, with the notable difference that it no longer uses
a submenu item, so all VPN connections now appear at the toplevel.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2407>
2022-08-01 17:08:18 +00:00
|
|
|
|
super();
|
|
|
|
|
|
|
|
|
|
this._items = new Map();
|
2022-08-03 16:28:46 +00:00
|
|
|
|
this._itemSorter = new ItemSorter({trackMru: true});
|
status/network: Decouple NMVpnSection from NMConnectionSection
The NMConnectionSection class is used - surprise - to manage a
list of related connections. And while the presentation of VPN
items is slightly different from connections associated with
devices (switches vs. ornaments), it makes perfect sense for
the VPN section to share the nitty-gritty with the base class.
But…
Right now it is perfectly fine for NMConnectionSection to be
used both as a child element in a device section, and as toplevel
item of the VPN section. Any nesting of sections is entirely
transparent to the user, and all connection sections appear as
submenu items in the toplevel menu.
That won't work for quick settings.
There's no PopoverMenuSection that allows invisible grouping, so
adding items dynamically would either need to happen at the end,
or require some tricky cross-component code to impose a particular
order.
And last but not least, quick toggles are very much unsuited for
a potentially large number of items. The whole point is to provide
quick direct access to system features, not to compete with menus
over the number of items they can hold.
That is, we need to get from the current state where each device
appears as a toplevel item, to a state where we have one quick
toggle for each device type plus one for VPN.
The decoupled VPN section still behaves largely as it did as a
subclass, with the notable difference that it no longer uses
a submenu item, so all VPN connections now appear at the toplevel.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2407>
2022-08-01 17:08:18 +00:00
|
|
|
|
|
2022-08-01 17:54:31 +00:00
|
|
|
|
this._itemsSection = new PopupMenu.PopupMenuSection();
|
2022-08-03 00:14:52 +00:00
|
|
|
|
this.menu.addMenuItem(this._itemsSection);
|
status/network: Decouple NMVpnSection from NMConnectionSection
The NMConnectionSection class is used - surprise - to manage a
list of related connections. And while the presentation of VPN
items is slightly different from connections associated with
devices (switches vs. ornaments), it makes perfect sense for
the VPN section to share the nitty-gritty with the base class.
But…
Right now it is perfectly fine for NMConnectionSection to be
used both as a child element in a device section, and as toplevel
item of the VPN section. Any nesting of sections is entirely
transparent to the user, and all connection sections appear as
submenu items in the toplevel menu.
That won't work for quick settings.
There's no PopoverMenuSection that allows invisible grouping, so
adding items dynamically would either need to happen at the end,
or require some tricky cross-component code to impose a particular
order.
And last but not least, quick toggles are very much unsuited for
a potentially large number of items. The whole point is to provide
quick direct access to system features, not to compete with menus
over the number of items they can hold.
That is, we need to get from the current state where each device
appears as a toplevel item, to a state where we have one quick
toggle for each device type plus one for VPN.
The decoupled VPN section still behaves largely as it did as a
subclass, with the notable difference that it no longer uses
a submenu item, so all VPN connections now appear at the toplevel.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2407>
2022-08-01 17:08:18 +00:00
|
|
|
|
|
2022-08-03 00:14:52 +00:00
|
|
|
|
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
|
2022-08-03 00:58:21 +00:00
|
|
|
|
|
|
|
|
|
this._itemBinding = new GObject.BindingGroup();
|
|
|
|
|
this._itemBinding.bind('icon-name',
|
|
|
|
|
this, 'icon-name', GObject.BindingFlags.DEFAULT);
|
2023-02-04 18:00:28 +00:00
|
|
|
|
this._itemBinding.bind_property_full('source',
|
|
|
|
|
this, 'title', GObject.BindingFlags.DEFAULT,
|
|
|
|
|
() => [true, this._getDefaultName()],
|
|
|
|
|
null);
|
2022-08-03 05:09:08 +00:00
|
|
|
|
this._itemBinding.bind_full('name',
|
2023-02-04 17:57:20 +00:00
|
|
|
|
this, 'subtitle', GObject.BindingFlags.DEFAULT,
|
|
|
|
|
(bind, source) => [true, this._transformSubtitle(source)],
|
2022-08-03 05:09:08 +00:00
|
|
|
|
null);
|
2022-08-03 04:03:40 +00:00
|
|
|
|
|
|
|
|
|
this.connect('clicked', () => this.activate());
|
2022-08-01 17:41:26 +00:00
|
|
|
|
}
|
2014-02-17 14:04:40 +00:00
|
|
|
|
|
2022-08-01 17:41:26 +00:00
|
|
|
|
setClient(client) {
|
|
|
|
|
if (this._client === client)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
this._client?.disconnectObject(this);
|
|
|
|
|
this._client = client;
|
2022-08-06 23:58:02 +00:00
|
|
|
|
this._client?.connectObject(
|
|
|
|
|
'notify::networking-enabled', () => this._sync(),
|
|
|
|
|
this);
|
2022-08-01 16:06:08 +00:00
|
|
|
|
|
2022-08-01 17:41:26 +00:00
|
|
|
|
this._items.forEach(item => item.destroy());
|
|
|
|
|
this._items.clear();
|
|
|
|
|
|
|
|
|
|
if (this._client)
|
|
|
|
|
this._loadInitialItems();
|
2022-08-01 17:54:31 +00:00
|
|
|
|
this._sync();
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-03 04:44:36 +00:00
|
|
|
|
activate() {
|
|
|
|
|
const activeItems = [...this._getActiveItems()];
|
|
|
|
|
|
|
|
|
|
if (activeItems.length > 0)
|
|
|
|
|
activeItems.forEach(i => i.activate());
|
|
|
|
|
else
|
|
|
|
|
this._itemBinding.source?.activate();
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-01 17:54:31 +00:00
|
|
|
|
_loadInitialItems() {
|
|
|
|
|
throw new GObject.NotImplementedError();
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-03 05:09:08 +00:00
|
|
|
|
// transform function for property binding:
|
|
|
|
|
// Ignore the provided label if there are multiple active
|
2023-02-04 15:25:01 +00:00
|
|
|
|
// items, and replace it with something like "2 connected"
|
2023-02-04 17:57:20 +00:00
|
|
|
|
_transformSubtitle(source) {
|
2022-08-03 05:09:08 +00:00
|
|
|
|
const nActive = this.checked
|
|
|
|
|
? [...this._getActiveItems()].length
|
|
|
|
|
: 0;
|
|
|
|
|
if (nActive > 1)
|
2023-02-04 15:25:01 +00:00
|
|
|
|
return ngettext('%d connected', '%d connected', nActive).format(nActive);
|
2022-08-03 05:09:08 +00:00
|
|
|
|
return source;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-03 16:28:46 +00:00
|
|
|
|
_updateItemsVisibility() {
|
|
|
|
|
[...this._itemSorter.itemsByMru()].forEach(
|
|
|
|
|
(item, i) => (item.visible = i < MAX_VISIBLE_NETWORKS));
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-03 05:09:08 +00:00
|
|
|
|
_itemActiveChanged() {
|
|
|
|
|
// force an update in case we changed
|
|
|
|
|
// from or to multiple active items
|
|
|
|
|
this._itemBinding.source?.notify('name');
|
|
|
|
|
this._sync();
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-03 01:40:40 +00:00
|
|
|
|
_updateChecked() {
|
|
|
|
|
const [firstActive] = this._getActiveItems();
|
|
|
|
|
this.checked = !!firstActive;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-01 17:54:31 +00:00
|
|
|
|
_resortItem(item) {
|
|
|
|
|
const pos = this._itemSorter.upsert(item);
|
|
|
|
|
this._itemsSection.moveMenuItem(item, pos);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_addItem(key, item) {
|
|
|
|
|
console.assert(!this._items.has(key),
|
|
|
|
|
`${this} already has an item for ${key}`);
|
|
|
|
|
|
|
|
|
|
item.connectObject(
|
2022-08-03 05:09:08 +00:00
|
|
|
|
'notify::is-active', () => this._itemActiveChanged(),
|
2022-08-01 17:54:31 +00:00
|
|
|
|
'notify::name', () => this._resortItem(item),
|
|
|
|
|
'destroy', () => this._removeItem(key),
|
|
|
|
|
this);
|
|
|
|
|
|
|
|
|
|
this._items.set(key, item);
|
|
|
|
|
const pos = this._itemSorter.upsert(item);
|
|
|
|
|
this._itemsSection.addMenuItem(item, pos);
|
|
|
|
|
this._sync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_removeItem(key) {
|
|
|
|
|
const item = this._items.get(key);
|
|
|
|
|
if (!item)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
this._itemSorter.delete(item);
|
|
|
|
|
this._items.delete(key);
|
|
|
|
|
|
|
|
|
|
item.destroy();
|
|
|
|
|
this._sync();
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-03 00:58:21 +00:00
|
|
|
|
*_getActiveItems() {
|
|
|
|
|
for (const item of this._itemSorter) {
|
|
|
|
|
if (item.is_active)
|
|
|
|
|
yield item;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_getPrimaryItem() {
|
|
|
|
|
// prefer active items
|
|
|
|
|
const [firstActive] = this._getActiveItems();
|
|
|
|
|
if (firstActive)
|
|
|
|
|
return firstActive;
|
|
|
|
|
|
|
|
|
|
// otherwise prefer the most-recently used
|
|
|
|
|
const [lastUsed] = this._itemSorter.itemsByMru();
|
|
|
|
|
if (lastUsed?.timestamp > 0)
|
|
|
|
|
return lastUsed;
|
|
|
|
|
|
|
|
|
|
// as a last resort, return the top-most visible item
|
|
|
|
|
for (const item of this._itemSorter) {
|
|
|
|
|
if (item.visible)
|
|
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.assert(!this.visible,
|
|
|
|
|
`${this} should not be visible when empty`);
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-01 17:54:31 +00:00
|
|
|
|
_sync() {
|
2022-08-06 23:58:02 +00:00
|
|
|
|
this.visible =
|
|
|
|
|
this._client?.networking_enabled && this._items.size > 0;
|
2022-08-03 16:28:46 +00:00
|
|
|
|
this._updateItemsVisibility();
|
2022-08-03 01:40:40 +00:00
|
|
|
|
this._updateChecked();
|
2022-08-03 00:58:21 +00:00
|
|
|
|
this._itemBinding.source = this._getPrimaryItem();
|
2022-08-01 17:54:31 +00:00
|
|
|
|
}
|
2022-08-03 00:14:52 +00:00
|
|
|
|
});
|
2022-08-01 17:54:31 +00:00
|
|
|
|
|
2022-08-03 04:03:40 +00:00
|
|
|
|
const NMVpnToggle = GObject.registerClass(
|
|
|
|
|
class NMVpnToggle extends NMToggle {
|
2022-08-01 17:54:31 +00:00
|
|
|
|
constructor() {
|
|
|
|
|
super();
|
|
|
|
|
|
2022-08-03 04:03:40 +00:00
|
|
|
|
this.menu.setHeader('network-vpn-symbolic', _('VPN'));
|
2022-08-03 00:14:52 +00:00
|
|
|
|
this.menu.addSettingsAction(_('VPN Settings'),
|
2022-08-01 17:54:31 +00:00
|
|
|
|
'gnome-network-panel.desktop');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setClient(client) {
|
|
|
|
|
super.setClient(client);
|
|
|
|
|
|
|
|
|
|
this._client?.connectObject(
|
|
|
|
|
'connection-added', (c, conn) => this._addConnection(conn),
|
|
|
|
|
'connection-removed', (c, conn) => this._removeConnection(conn),
|
|
|
|
|
'notify::active-connections', () => this._syncActiveConnections(),
|
|
|
|
|
this);
|
2022-08-01 16:06:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-03 05:09:08 +00:00
|
|
|
|
_getDefaultName() {
|
|
|
|
|
return _('VPN');
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-01 16:06:08 +00:00
|
|
|
|
_loadInitialItems() {
|
|
|
|
|
const connections = this._client.get_connections();
|
|
|
|
|
for (const conn of connections)
|
status/network: Decouple NMVpnSection from NMConnectionSection
The NMConnectionSection class is used - surprise - to manage a
list of related connections. And while the presentation of VPN
items is slightly different from connections associated with
devices (switches vs. ornaments), it makes perfect sense for
the VPN section to share the nitty-gritty with the base class.
But…
Right now it is perfectly fine for NMConnectionSection to be
used both as a child element in a device section, and as toplevel
item of the VPN section. Any nesting of sections is entirely
transparent to the user, and all connection sections appear as
submenu items in the toplevel menu.
That won't work for quick settings.
There's no PopoverMenuSection that allows invisible grouping, so
adding items dynamically would either need to happen at the end,
or require some tricky cross-component code to impose a particular
order.
And last but not least, quick toggles are very much unsuited for
a potentially large number of items. The whole point is to provide
quick direct access to system features, not to compete with menus
over the number of items they can hold.
That is, we need to get from the current state where each device
appears as a toplevel item, to a state where we have one quick
toggle for each device type plus one for VPN.
The decoupled VPN section still behaves largely as it did as a
subclass, with the notable difference that it no longer uses
a submenu item, so all VPN connections now appear at the toplevel.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2407>
2022-08-01 17:08:18 +00:00
|
|
|
|
this._addConnection(conn);
|
2022-08-01 16:06:08 +00:00
|
|
|
|
|
|
|
|
|
this._syncActiveConnections();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_syncActiveConnections() {
|
|
|
|
|
const activeConnections =
|
|
|
|
|
this._client.get_active_connections().filter(
|
|
|
|
|
c => this._shouldHandleConnection(c.connection));
|
|
|
|
|
|
status/network: Decouple NMVpnSection from NMConnectionSection
The NMConnectionSection class is used - surprise - to manage a
list of related connections. And while the presentation of VPN
items is slightly different from connections associated with
devices (switches vs. ornaments), it makes perfect sense for
the VPN section to share the nitty-gritty with the base class.
But…
Right now it is perfectly fine for NMConnectionSection to be
used both as a child element in a device section, and as toplevel
item of the VPN section. Any nesting of sections is entirely
transparent to the user, and all connection sections appear as
submenu items in the toplevel menu.
That won't work for quick settings.
There's no PopoverMenuSection that allows invisible grouping, so
adding items dynamically would either need to happen at the end,
or require some tricky cross-component code to impose a particular
order.
And last but not least, quick toggles are very much unsuited for
a potentially large number of items. The whole point is to provide
quick direct access to system features, not to compete with menus
over the number of items they can hold.
That is, we need to get from the current state where each device
appears as a toplevel item, to a state where we have one quick
toggle for each device type plus one for VPN.
The decoupled VPN section still behaves largely as it did as a
subclass, with the notable difference that it no longer uses
a submenu item, so all VPN connections now appear at the toplevel.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2407>
2022-08-01 17:08:18 +00:00
|
|
|
|
for (const item of this._items.values())
|
2022-08-01 16:06:08 +00:00
|
|
|
|
item.setActiveConnection(null);
|
|
|
|
|
|
|
|
|
|
for (const a of activeConnections)
|
status/network: Decouple NMVpnSection from NMConnectionSection
The NMConnectionSection class is used - surprise - to manage a
list of related connections. And while the presentation of VPN
items is slightly different from connections associated with
devices (switches vs. ornaments), it makes perfect sense for
the VPN section to share the nitty-gritty with the base class.
But…
Right now it is perfectly fine for NMConnectionSection to be
used both as a child element in a device section, and as toplevel
item of the VPN section. Any nesting of sections is entirely
transparent to the user, and all connection sections appear as
submenu items in the toplevel menu.
That won't work for quick settings.
There's no PopoverMenuSection that allows invisible grouping, so
adding items dynamically would either need to happen at the end,
or require some tricky cross-component code to impose a particular
order.
And last but not least, quick toggles are very much unsuited for
a potentially large number of items. The whole point is to provide
quick direct access to system features, not to compete with menus
over the number of items they can hold.
That is, we need to get from the current state where each device
appears as a toplevel item, to a state where we have one quick
toggle for each device type plus one for VPN.
The decoupled VPN section still behaves largely as it did as a
subclass, with the notable difference that it no longer uses
a submenu item, so all VPN connections now appear at the toplevel.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2407>
2022-08-01 17:08:18 +00:00
|
|
|
|
this._items.get(a.connection)?.setActiveConnection(a);
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2017-12-21 15:51:28 +00:00
|
|
|
|
|
2022-08-01 16:06:08 +00:00
|
|
|
|
_shouldHandleConnection(connection) {
|
|
|
|
|
const setting = connection.get_setting_connection();
|
|
|
|
|
if (!setting)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
// Ignore slave connection
|
|
|
|
|
if (setting.get_master())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
const handledTypes = [
|
|
|
|
|
NM.SETTING_VPN_SETTING_NAME,
|
|
|
|
|
NM.SETTING_WIREGUARD_SETTING_NAME,
|
|
|
|
|
];
|
|
|
|
|
return handledTypes.includes(setting.type);
|
|
|
|
|
}
|
|
|
|
|
|
status/network: Decouple NMVpnSection from NMConnectionSection
The NMConnectionSection class is used - surprise - to manage a
list of related connections. And while the presentation of VPN
items is slightly different from connections associated with
devices (switches vs. ornaments), it makes perfect sense for
the VPN section to share the nitty-gritty with the base class.
But…
Right now it is perfectly fine for NMConnectionSection to be
used both as a child element in a device section, and as toplevel
item of the VPN section. Any nesting of sections is entirely
transparent to the user, and all connection sections appear as
submenu items in the toplevel menu.
That won't work for quick settings.
There's no PopoverMenuSection that allows invisible grouping, so
adding items dynamically would either need to happen at the end,
or require some tricky cross-component code to impose a particular
order.
And last but not least, quick toggles are very much unsuited for
a potentially large number of items. The whole point is to provide
quick direct access to system features, not to compete with menus
over the number of items they can hold.
That is, we need to get from the current state where each device
appears as a toplevel item, to a state where we have one quick
toggle for each device type plus one for VPN.
The decoupled VPN section still behaves largely as it did as a
subclass, with the notable difference that it no longer uses
a submenu item, so all VPN connections now appear at the toplevel.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2407>
2022-08-01 17:08:18 +00:00
|
|
|
|
_onConnectionChanged(connection) {
|
|
|
|
|
const item = this._items.get(connection);
|
|
|
|
|
item.updateForConnection(connection);
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-01 16:06:08 +00:00
|
|
|
|
_addConnection(connection) {
|
status/network: Decouple NMVpnSection from NMConnectionSection
The NMConnectionSection class is used - surprise - to manage a
list of related connections. And while the presentation of VPN
items is slightly different from connections associated with
devices (switches vs. ornaments), it makes perfect sense for
the VPN section to share the nitty-gritty with the base class.
But…
Right now it is perfectly fine for NMConnectionSection to be
used both as a child element in a device section, and as toplevel
item of the VPN section. Any nesting of sections is entirely
transparent to the user, and all connection sections appear as
submenu items in the toplevel menu.
That won't work for quick settings.
There's no PopoverMenuSection that allows invisible grouping, so
adding items dynamically would either need to happen at the end,
or require some tricky cross-component code to impose a particular
order.
And last but not least, quick toggles are very much unsuited for
a potentially large number of items. The whole point is to provide
quick direct access to system features, not to compete with menus
over the number of items they can hold.
That is, we need to get from the current state where each device
appears as a toplevel item, to a state where we have one quick
toggle for each device type plus one for VPN.
The decoupled VPN section still behaves largely as it did as a
subclass, with the notable difference that it no longer uses
a submenu item, so all VPN connections now appear at the toplevel.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2407>
2022-08-01 17:08:18 +00:00
|
|
|
|
if (this._items.has(connection))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!this._shouldHandleConnection(connection))
|
|
|
|
|
return;
|
2022-08-01 16:06:08 +00:00
|
|
|
|
|
|
|
|
|
connection.connectObject(
|
status/network: Decouple NMVpnSection from NMConnectionSection
The NMConnectionSection class is used - surprise - to manage a
list of related connections. And while the presentation of VPN
items is slightly different from connections associated with
devices (switches vs. ornaments), it makes perfect sense for
the VPN section to share the nitty-gritty with the base class.
But…
Right now it is perfectly fine for NMConnectionSection to be
used both as a child element in a device section, and as toplevel
item of the VPN section. Any nesting of sections is entirely
transparent to the user, and all connection sections appear as
submenu items in the toplevel menu.
That won't work for quick settings.
There's no PopoverMenuSection that allows invisible grouping, so
adding items dynamically would either need to happen at the end,
or require some tricky cross-component code to impose a particular
order.
And last but not least, quick toggles are very much unsuited for
a potentially large number of items. The whole point is to provide
quick direct access to system features, not to compete with menus
over the number of items they can hold.
That is, we need to get from the current state where each device
appears as a toplevel item, to a state where we have one quick
toggle for each device type plus one for VPN.
The decoupled VPN section still behaves largely as it did as a
subclass, with the notable difference that it no longer uses
a submenu item, so all VPN connections now appear at the toplevel.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2407>
2022-08-01 17:08:18 +00:00
|
|
|
|
'changed', this._onConnectionChanged.bind(this),
|
2022-08-01 16:06:08 +00:00
|
|
|
|
this);
|
|
|
|
|
|
status/network: Decouple NMVpnSection from NMConnectionSection
The NMConnectionSection class is used - surprise - to manage a
list of related connections. And while the presentation of VPN
items is slightly different from connections associated with
devices (switches vs. ornaments), it makes perfect sense for
the VPN section to share the nitty-gritty with the base class.
But…
Right now it is perfectly fine for NMConnectionSection to be
used both as a child element in a device section, and as toplevel
item of the VPN section. Any nesting of sections is entirely
transparent to the user, and all connection sections appear as
submenu items in the toplevel menu.
That won't work for quick settings.
There's no PopoverMenuSection that allows invisible grouping, so
adding items dynamically would either need to happen at the end,
or require some tricky cross-component code to impose a particular
order.
And last but not least, quick toggles are very much unsuited for
a potentially large number of items. The whole point is to provide
quick direct access to system features, not to compete with menus
over the number of items they can hold.
That is, we need to get from the current state where each device
appears as a toplevel item, to a state where we have one quick
toggle for each device type plus one for VPN.
The decoupled VPN section still behaves largely as it did as a
subclass, with the notable difference that it no longer uses
a submenu item, so all VPN connections now appear at the toplevel.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2407>
2022-08-01 17:08:18 +00:00
|
|
|
|
const item = new NMVpnConnectionItem(this, connection);
|
|
|
|
|
item.connectObject(
|
|
|
|
|
'activation-failed', () => this.emit('activation-failed'),
|
|
|
|
|
this);
|
2022-08-01 17:54:31 +00:00
|
|
|
|
this._addItem(connection, item);
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
status/network: Decouple NMVpnSection from NMConnectionSection
The NMConnectionSection class is used - surprise - to manage a
list of related connections. And while the presentation of VPN
items is slightly different from connections associated with
devices (switches vs. ornaments), it makes perfect sense for
the VPN section to share the nitty-gritty with the base class.
But…
Right now it is perfectly fine for NMConnectionSection to be
used both as a child element in a device section, and as toplevel
item of the VPN section. Any nesting of sections is entirely
transparent to the user, and all connection sections appear as
submenu items in the toplevel menu.
That won't work for quick settings.
There's no PopoverMenuSection that allows invisible grouping, so
adding items dynamically would either need to happen at the end,
or require some tricky cross-component code to impose a particular
order.
And last but not least, quick toggles are very much unsuited for
a potentially large number of items. The whole point is to provide
quick direct access to system features, not to compete with menus
over the number of items they can hold.
That is, we need to get from the current state where each device
appears as a toplevel item, to a state where we have one quick
toggle for each device type plus one for VPN.
The decoupled VPN section still behaves largely as it did as a
subclass, with the notable difference that it no longer uses
a submenu item, so all VPN connections now appear at the toplevel.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2407>
2022-08-01 17:08:18 +00:00
|
|
|
|
_removeConnection(connection) {
|
2022-08-01 17:54:31 +00:00
|
|
|
|
this._removeItem(connection);
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2014-03-04 13:02:00 +00:00
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
|
activateConnection(connection) {
|
2017-10-31 10:38:20 +00:00
|
|
|
|
this._client.activate_connection_async(connection, null, null, null, null);
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2013-04-26 23:21:02 +00:00
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
|
deactivateConnection(activeConnection) {
|
2017-10-31 10:38:20 +00:00
|
|
|
|
this._client.deactivate_connection(activeConnection, null);
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2022-08-03 00:14:52 +00:00
|
|
|
|
});
|
2012-08-29 14:22:24 +00:00
|
|
|
|
|
2022-08-03 04:03:40 +00:00
|
|
|
|
const NMDeviceToggle = GObject.registerClass(
|
|
|
|
|
class NMDeviceToggle extends NMToggle {
|
2022-08-01 14:19:43 +00:00
|
|
|
|
constructor(deviceType) {
|
2017-10-31 01:19:44 +00:00
|
|
|
|
super();
|
2016-05-13 17:42:04 +00:00
|
|
|
|
|
2022-08-01 14:59:28 +00:00
|
|
|
|
this._deviceType = deviceType;
|
|
|
|
|
this._nmDevices = new Set();
|
2022-11-04 18:53:57 +00:00
|
|
|
|
this._deviceNames = new Map();
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2016-05-13 17:42:04 +00:00
|
|
|
|
|
2022-08-01 14:59:28 +00:00
|
|
|
|
setClient(client) {
|
|
|
|
|
this._nmDevices.clear();
|
|
|
|
|
|
2022-08-01 17:54:31 +00:00
|
|
|
|
super.setClient(client);
|
|
|
|
|
|
2022-08-01 14:59:28 +00:00
|
|
|
|
this._client?.connectObject(
|
|
|
|
|
'device-added', (c, dev) => {
|
|
|
|
|
this._addDevice(dev);
|
|
|
|
|
this._syncDeviceNames();
|
|
|
|
|
},
|
|
|
|
|
'device-removed', (c, dev) => {
|
|
|
|
|
this._removeDevice(dev);
|
|
|
|
|
this._syncDeviceNames();
|
|
|
|
|
}, this);
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-03 05:09:08 +00:00
|
|
|
|
_getDefaultName() {
|
|
|
|
|
const [dev] = this._nmDevices;
|
|
|
|
|
const [name] = NM.Device.disambiguate_names([dev]);
|
|
|
|
|
return name;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-01 14:59:28 +00:00
|
|
|
|
_loadInitialItems() {
|
|
|
|
|
const devices = this._client.get_devices();
|
|
|
|
|
for (const dev of devices)
|
|
|
|
|
this._addDevice(dev);
|
|
|
|
|
this._syncDeviceNames();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_shouldShowDevice(device) {
|
|
|
|
|
switch (device.state) {
|
|
|
|
|
case NM.DeviceState.DISCONNECTED:
|
|
|
|
|
case NM.DeviceState.ACTIVATED:
|
|
|
|
|
case NM.DeviceState.DEACTIVATING:
|
|
|
|
|
case NM.DeviceState.PREPARE:
|
|
|
|
|
case NM.DeviceState.CONFIG:
|
|
|
|
|
case NM.DeviceState.IP_CONFIG:
|
|
|
|
|
case NM.DeviceState.IP_CHECK:
|
|
|
|
|
case NM.DeviceState.SECONDARIES:
|
|
|
|
|
case NM.DeviceState.NEED_AUTH:
|
|
|
|
|
case NM.DeviceState.FAILED:
|
|
|
|
|
return true;
|
|
|
|
|
case NM.DeviceState.UNMANAGED:
|
|
|
|
|
case NM.DeviceState.UNAVAILABLE:
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_syncDeviceNames() {
|
|
|
|
|
const devices = [...this._nmDevices];
|
|
|
|
|
const names = NM.Device.disambiguate_names(devices);
|
2022-11-04 18:53:57 +00:00
|
|
|
|
this._deviceNames.clear();
|
2022-08-01 14:59:28 +00:00
|
|
|
|
devices.forEach(
|
2022-11-04 18:53:57 +00:00
|
|
|
|
(dev, i) => {
|
|
|
|
|
this._deviceNames.set(dev, names[i]);
|
|
|
|
|
this._items.get(dev)?.setDeviceName(names[i]);
|
|
|
|
|
});
|
2022-08-01 14:59:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_syncDeviceItem(device) {
|
|
|
|
|
if (this._shouldShowDevice(device))
|
|
|
|
|
this._ensureDeviceItem(device);
|
|
|
|
|
else
|
|
|
|
|
this._removeDeviceItem(device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_deviceStateChanged(device, newState, oldState, reason) {
|
|
|
|
|
if (newState === oldState) {
|
|
|
|
|
console.info(`${device} emitted state-changed without actually changing state`);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Emit a notification if activation fails, but don't do it
|
|
|
|
|
if the reason is no secrets, as that indicates the user
|
|
|
|
|
cancelled the agent dialog */
|
|
|
|
|
if (newState === NM.DeviceState.FAILED &&
|
|
|
|
|
reason !== NM.DeviceStateReason.NO_SECRETS)
|
|
|
|
|
this.emit('activation-failed');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_createDeviceMenuItem(_device) {
|
|
|
|
|
throw new GObject.NotImplementedError();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_ensureDeviceItem(device) {
|
|
|
|
|
if (this._items.has(device))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
const item = this._createDeviceMenuItem(device);
|
2022-11-04 18:53:57 +00:00
|
|
|
|
item.setDeviceName(this._deviceNames.get(device) ?? '');
|
2022-08-01 17:54:31 +00:00
|
|
|
|
this._addItem(device, item);
|
2022-08-01 14:59:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_removeDeviceItem(device) {
|
2022-08-01 17:54:31 +00:00
|
|
|
|
this._removeItem(device);
|
2022-08-01 14:59:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_addDevice(device) {
|
|
|
|
|
if (this._nmDevices.has(device))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (device.get_device_type() !== this._deviceType)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
device.connectObject(
|
|
|
|
|
'state-changed', this._deviceStateChanged.bind(this),
|
|
|
|
|
'notify::interface', () => this._syncDeviceNames(),
|
|
|
|
|
'notify::state', () => this._syncDeviceItem(device),
|
|
|
|
|
this);
|
|
|
|
|
|
|
|
|
|
this._nmDevices.add(device);
|
|
|
|
|
this._syncDeviceItem(device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_removeDevice(device) {
|
|
|
|
|
if (!this._nmDevices.delete(device))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
device.disconnectObject(this);
|
|
|
|
|
this._removeDeviceItem(device);
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
|
_sync() {
|
2022-08-01 17:54:31 +00:00
|
|
|
|
super._sync();
|
|
|
|
|
|
2022-08-02 23:23:29 +00:00
|
|
|
|
const nItems = this._items.size;
|
|
|
|
|
this._items.forEach(item => (item.singleDeviceMode = nItems === 1));
|
2016-05-13 17:42:04 +00:00
|
|
|
|
}
|
2022-08-03 00:14:52 +00:00
|
|
|
|
});
|
2011-01-25 21:08:12 +00:00
|
|
|
|
|
2022-08-03 04:03:40 +00:00
|
|
|
|
const NMWirelessToggle = GObject.registerClass(
|
|
|
|
|
class NMWirelessToggle extends NMDeviceToggle {
|
2022-08-03 03:27:44 +00:00
|
|
|
|
constructor() {
|
|
|
|
|
super(NM.DeviceType.WIFI);
|
2022-08-03 03:35:25 +00:00
|
|
|
|
|
2022-08-05 11:40:45 +00:00
|
|
|
|
this._itemBinding.bind('is-hotspot',
|
|
|
|
|
this, 'menu-enabled',
|
|
|
|
|
GObject.BindingFlags.INVERT_BOOLEAN);
|
|
|
|
|
|
2022-08-06 03:01:20 +00:00
|
|
|
|
this._scanningSpinner = new Spinner(16);
|
|
|
|
|
|
|
|
|
|
this.menu.connectObject('open-state-changed', (m, isOpen) => {
|
|
|
|
|
if (isOpen)
|
|
|
|
|
this._startScanning();
|
|
|
|
|
else
|
|
|
|
|
this._stopScanning();
|
|
|
|
|
});
|
|
|
|
|
|
2022-08-03 04:03:40 +00:00
|
|
|
|
this.menu.setHeader('network-wireless-symbolic', _('Wi–Fi'));
|
2022-08-06 03:01:20 +00:00
|
|
|
|
this.menu.addHeaderSuffix(this._scanningSpinner);
|
2022-08-03 00:14:52 +00:00
|
|
|
|
this.menu.addSettingsAction(_('All Networks'),
|
2022-08-03 03:35:25 +00:00
|
|
|
|
'gnome-wifi-panel.desktop');
|
2022-08-03 03:27:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-03 21:24:53 +00:00
|
|
|
|
setClient(client) {
|
|
|
|
|
super.setClient(client);
|
|
|
|
|
|
|
|
|
|
this._client?.bind_property('wireless-enabled',
|
|
|
|
|
this, 'checked',
|
|
|
|
|
GObject.BindingFlags.SYNC_CREATE);
|
2022-08-03 21:24:53 +00:00
|
|
|
|
this._client?.bind_property('wireless-hardware-enabled',
|
|
|
|
|
this, 'reactive',
|
|
|
|
|
GObject.BindingFlags.SYNC_CREATE);
|
2022-08-03 21:24:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
activate() {
|
2022-08-05 11:40:45 +00:00
|
|
|
|
const primaryItem = this._itemBinding.source;
|
|
|
|
|
if (primaryItem?.is_hotspot)
|
|
|
|
|
primaryItem.activate();
|
|
|
|
|
else
|
|
|
|
|
this._client.wireless_enabled = !this._client.wireless_enabled;
|
2022-08-03 21:24:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-06 03:01:20 +00:00
|
|
|
|
async _scanDevice(device) {
|
|
|
|
|
const {lastScan} = device;
|
|
|
|
|
await device.request_scan_async(null);
|
|
|
|
|
|
|
|
|
|
// Wait for the lastScan property to update, which
|
|
|
|
|
// indicates the end of the scan
|
|
|
|
|
return new Promise(resolve => {
|
|
|
|
|
GLib.timeout_add(GLib.PRIORITY_DEFAULT, 1500, () => {
|
|
|
|
|
if (device.lastScan === lastScan)
|
|
|
|
|
return GLib.SOURCE_CONTINUE;
|
|
|
|
|
|
|
|
|
|
resolve();
|
|
|
|
|
return GLib.SOURCE_REMOVE;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async _scanDevices() {
|
|
|
|
|
if (!this._client.wireless_enabled)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
this._scanningSpinner.play();
|
|
|
|
|
|
|
|
|
|
const devices = [...this._items.keys()];
|
|
|
|
|
await Promise.all(
|
|
|
|
|
devices.map(d => this._scanDevice(d)));
|
|
|
|
|
|
|
|
|
|
this._scanningSpinner.stop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_startScanning() {
|
|
|
|
|
this._scanTimeoutId = GLib.timeout_add_seconds(
|
|
|
|
|
GLib.PRIORITY_DEFAULT, WIFI_SCAN_FREQUENCY, () => {
|
|
|
|
|
this._scanDevices().catch(logError);
|
|
|
|
|
return GLib.SOURCE_CONTINUE;
|
|
|
|
|
});
|
|
|
|
|
this._scanDevices().catch(logError);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_stopScanning() {
|
|
|
|
|
if (this._scanTimeoutId)
|
|
|
|
|
GLib.source_remove(this._scanTimeoutId);
|
|
|
|
|
delete this._scanTimeoutId;
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-01 14:59:28 +00:00
|
|
|
|
_createDeviceMenuItem(device) {
|
|
|
|
|
return new NMWirelessDeviceItem(this._client, device);
|
|
|
|
|
}
|
2022-08-03 21:24:53 +00:00
|
|
|
|
|
|
|
|
|
_updateChecked() {
|
|
|
|
|
// handled via a property binding
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-05 11:40:45 +00:00
|
|
|
|
_getPrimaryItem() {
|
|
|
|
|
const hotspot = [...this._items.values()].find(i => i.is_hotspot);
|
|
|
|
|
if (hotspot)
|
|
|
|
|
return hotspot;
|
|
|
|
|
|
|
|
|
|
return super._getPrimaryItem();
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-03 21:24:53 +00:00
|
|
|
|
_shouldShowDevice(device) {
|
|
|
|
|
// don't disappear if wireless-enabled is false
|
|
|
|
|
if (device.state === NM.DeviceState.UNAVAILABLE)
|
|
|
|
|
return true;
|
|
|
|
|
return super._shouldShowDevice(device);
|
|
|
|
|
}
|
2022-08-03 00:14:52 +00:00
|
|
|
|
});
|
2022-08-03 03:27:44 +00:00
|
|
|
|
|
2022-08-03 04:03:40 +00:00
|
|
|
|
const NMWiredToggle = GObject.registerClass(
|
|
|
|
|
class NMWiredToggle extends NMDeviceToggle {
|
2022-08-03 03:27:44 +00:00
|
|
|
|
constructor() {
|
|
|
|
|
super(NM.DeviceType.ETHERNET);
|
2022-08-03 03:35:25 +00:00
|
|
|
|
|
2022-08-03 04:03:40 +00:00
|
|
|
|
this.menu.setHeader('network-wired-symbolic', _('Wired Connections'));
|
2022-08-03 00:14:52 +00:00
|
|
|
|
this.menu.addSettingsAction(_('Wired Settings'),
|
2022-08-03 03:35:25 +00:00
|
|
|
|
'gnome-network-panel.desktop');
|
2022-08-03 03:27:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-01 14:59:28 +00:00
|
|
|
|
_createDeviceMenuItem(device) {
|
|
|
|
|
return new NMWiredDeviceItem(this._client, device);
|
|
|
|
|
}
|
2022-08-03 00:14:52 +00:00
|
|
|
|
});
|
2022-08-03 03:27:44 +00:00
|
|
|
|
|
2022-08-03 04:03:40 +00:00
|
|
|
|
const NMBluetoothToggle = GObject.registerClass(
|
|
|
|
|
class NMBluetoothToggle extends NMDeviceToggle {
|
2022-08-03 03:27:44 +00:00
|
|
|
|
constructor() {
|
|
|
|
|
super(NM.DeviceType.BT);
|
2022-08-03 03:35:25 +00:00
|
|
|
|
|
2022-08-03 04:03:40 +00:00
|
|
|
|
this.menu.setHeader('network-cellular-symbolic', _('Bluetooth Tethers'));
|
2022-08-03 00:14:52 +00:00
|
|
|
|
this.menu.addSettingsAction(_('Bluetooth Settings'),
|
2022-08-03 03:35:25 +00:00
|
|
|
|
'gnome-network-panel.desktop');
|
2022-08-03 03:27:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-04 23:31:58 +00:00
|
|
|
|
_getDefaultName() {
|
|
|
|
|
// Translators: "Tether" from "Bluetooth Tether"
|
|
|
|
|
return _('Tether');
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-01 14:59:28 +00:00
|
|
|
|
_createDeviceMenuItem(device) {
|
|
|
|
|
return new NMBluetoothDeviceItem(this._client, device);
|
|
|
|
|
}
|
2022-08-03 00:14:52 +00:00
|
|
|
|
});
|
2022-08-03 03:27:44 +00:00
|
|
|
|
|
2022-08-03 04:03:40 +00:00
|
|
|
|
const NMModemToggle = GObject.registerClass(
|
|
|
|
|
class NMModemToggle extends NMDeviceToggle {
|
2022-08-03 03:27:44 +00:00
|
|
|
|
constructor() {
|
|
|
|
|
super(NM.DeviceType.MODEM);
|
2022-08-03 03:35:25 +00:00
|
|
|
|
|
2022-08-03 04:03:40 +00:00
|
|
|
|
this.menu.setHeader('network-cellular-symbolic', _('Mobile Connections'));
|
|
|
|
|
|
2022-08-03 03:35:25 +00:00
|
|
|
|
const settingsLabel = _('Mobile Broadband Settings');
|
2022-08-03 00:14:52 +00:00
|
|
|
|
this._wwanSettings = this.menu.addSettingsAction(settingsLabel,
|
2022-08-03 03:35:25 +00:00
|
|
|
|
'gnome-wwan-panel.desktop');
|
2022-08-03 00:14:52 +00:00
|
|
|
|
this._legacySettings = this.menu.addSettingsAction(settingsLabel,
|
2022-08-03 03:35:25 +00:00
|
|
|
|
'gnome-network-panel.desktop');
|
2022-08-03 03:27:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-04 23:34:11 +00:00
|
|
|
|
_getDefaultName() {
|
|
|
|
|
// Translators: "Mobile" from "Mobile Broadband"
|
|
|
|
|
return _('Mobile');
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-01 14:59:28 +00:00
|
|
|
|
_createDeviceMenuItem(device) {
|
|
|
|
|
return new NMModemDeviceItem(this._client, device);
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-03 03:35:25 +00:00
|
|
|
|
_sync() {
|
|
|
|
|
super._sync();
|
|
|
|
|
|
|
|
|
|
const useWwanPanel =
|
|
|
|
|
[...this._items.values()].some(i => i.wwanPanelSupported);
|
|
|
|
|
this._wwanSettings.visible = useWwanPanel;
|
|
|
|
|
this._legacySettings.visible = !useWwanPanel;
|
|
|
|
|
}
|
2022-08-03 00:14:52 +00:00
|
|
|
|
});
|
2022-08-03 03:27:44 +00:00
|
|
|
|
|
2022-08-03 04:03:40 +00:00
|
|
|
|
var Indicator = GObject.registerClass(
|
|
|
|
|
class Indicator extends SystemIndicator {
|
2019-07-16 09:24:13 +00:00
|
|
|
|
_init() {
|
|
|
|
|
super._init();
|
2012-06-19 17:50:37 +00:00
|
|
|
|
|
2022-08-01 17:41:26 +00:00
|
|
|
|
this._connectivityQueue = new Set();
|
|
|
|
|
|
|
|
|
|
this._mainConnection = null;
|
|
|
|
|
|
|
|
|
|
this._notification = null;
|
|
|
|
|
|
2022-08-03 04:03:40 +00:00
|
|
|
|
this._wiredToggle = new NMWiredToggle();
|
|
|
|
|
this._wirelessToggle = new NMWirelessToggle();
|
|
|
|
|
this._modemToggle = new NMModemToggle();
|
|
|
|
|
this._btToggle = new NMBluetoothToggle();
|
|
|
|
|
this._vpnToggle = new NMVpnToggle();
|
|
|
|
|
|
|
|
|
|
this._deviceToggles = new Map([
|
|
|
|
|
[NM.DeviceType.ETHERNET, this._wiredToggle],
|
|
|
|
|
[NM.DeviceType.WIFI, this._wirelessToggle],
|
|
|
|
|
[NM.DeviceType.MODEM, this._modemToggle],
|
|
|
|
|
[NM.DeviceType.BT, this._btToggle],
|
2022-08-03 03:27:44 +00:00
|
|
|
|
]);
|
2022-08-03 04:03:40 +00:00
|
|
|
|
this.quickSettingsItems.push(...this._deviceToggles.values());
|
|
|
|
|
this.quickSettingsItems.push(this._vpnToggle);
|
2022-08-01 17:11:59 +00:00
|
|
|
|
|
2022-08-03 04:03:40 +00:00
|
|
|
|
this.quickSettingsItems.forEach(toggle => {
|
|
|
|
|
toggle.connectObject(
|
2022-08-01 14:59:28 +00:00
|
|
|
|
'activation-failed', () => this._onActivationFailed(),
|
2022-08-01 15:28:54 +00:00
|
|
|
|
this);
|
2022-08-01 17:11:59 +00:00
|
|
|
|
});
|
2011-01-25 21:08:12 +00:00
|
|
|
|
|
2022-08-03 02:11:15 +00:00
|
|
|
|
this._primaryIndicator = this._addIndicator();
|
|
|
|
|
this._vpnIndicator = this._addIndicator();
|
|
|
|
|
|
2022-08-03 02:33:48 +00:00
|
|
|
|
this._primaryIndicatorBinding = new GObject.BindingGroup();
|
|
|
|
|
this._primaryIndicatorBinding.bind('icon-name',
|
|
|
|
|
this._primaryIndicator, 'icon-name',
|
|
|
|
|
GObject.BindingFlags.DEFAULT);
|
|
|
|
|
|
2022-08-03 04:03:40 +00:00
|
|
|
|
this._vpnToggle.bind_property('checked',
|
2022-08-03 02:11:15 +00:00
|
|
|
|
this._vpnIndicator, 'visible',
|
|
|
|
|
GObject.BindingFlags.SYNC_CREATE);
|
2022-08-03 04:03:40 +00:00
|
|
|
|
this._vpnToggle.bind_property('icon-name',
|
2022-08-03 02:11:15 +00:00
|
|
|
|
this._vpnIndicator, 'icon-name',
|
|
|
|
|
GObject.BindingFlags.SYNC_CREATE);
|
|
|
|
|
|
2022-08-01 17:41:26 +00:00
|
|
|
|
this._getClient().catch(logError);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async _getClient() {
|
|
|
|
|
this._client = await NM.Client.new_async(null);
|
|
|
|
|
|
2022-08-03 04:03:40 +00:00
|
|
|
|
this.quickSettingsItems.forEach(
|
|
|
|
|
toggle => toggle.setClient(this._client));
|
2022-08-01 17:41:26 +00:00
|
|
|
|
|
2022-07-31 23:41:01 +00:00
|
|
|
|
this._client.bind_property('nm-running',
|
|
|
|
|
this, 'visible',
|
|
|
|
|
GObject.BindingFlags.SYNC_CREATE);
|
|
|
|
|
|
2022-07-31 23:47:22 +00:00
|
|
|
|
this._client.connectObject(
|
|
|
|
|
'notify::primary-connection', () => this._syncMainConnection(),
|
|
|
|
|
'notify::activating-connection', () => this._syncMainConnection(),
|
|
|
|
|
'notify::connectivity', () => this._syncConnectivity(),
|
|
|
|
|
this);
|
2022-08-01 14:59:28 +00:00
|
|
|
|
this._syncMainConnection();
|
2017-12-02 00:27:35 +00:00
|
|
|
|
|
2021-06-07 22:17:48 +00:00
|
|
|
|
try {
|
|
|
|
|
this._configPermission = await Polkit.Permission.new(
|
|
|
|
|
'org.freedesktop.NetworkManager.network-control', null, null);
|
2022-08-07 00:10:22 +00:00
|
|
|
|
|
2022-08-03 04:03:40 +00:00
|
|
|
|
this.quickSettingsItems.forEach(toggle => {
|
2022-08-07 00:10:22 +00:00
|
|
|
|
this._configPermission.bind_property('allowed',
|
2022-08-03 04:03:40 +00:00
|
|
|
|
toggle, 'reactive',
|
2022-08-07 00:10:22 +00:00
|
|
|
|
GObject.BindingFlags.SYNC_CREATE);
|
|
|
|
|
});
|
2021-06-07 22:17:48 +00:00
|
|
|
|
} catch (e) {
|
2022-02-07 14:14:06 +00:00
|
|
|
|
log(`No permission to control network connections: ${e}`);
|
2021-06-07 22:17:48 +00:00
|
|
|
|
this._configPermission = null;
|
|
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2011-01-25 21:08:12 +00:00
|
|
|
|
|
2022-07-31 23:30:12 +00:00
|
|
|
|
_onActivationFailed() {
|
|
|
|
|
this._notification?.destroy();
|
2011-08-22 16:21:31 +00:00
|
|
|
|
|
2022-07-31 23:30:12 +00:00
|
|
|
|
const source = new MessageTray.Source(
|
|
|
|
|
_('Network Manager'), 'network-error-symbolic');
|
|
|
|
|
source.policy =
|
|
|
|
|
new MessageTray.NotificationApplicationPolicy('gnome-network-panel');
|
2011-08-22 16:21:31 +00:00
|
|
|
|
|
2022-07-31 23:30:12 +00:00
|
|
|
|
this._notification = new MessageTray.Notification(source,
|
|
|
|
|
_('Connection failed'),
|
|
|
|
|
_('Activation of network connection failed'));
|
|
|
|
|
this._notification.setUrgency(MessageTray.Urgency.HIGH);
|
2013-08-27 18:58:50 +00:00
|
|
|
|
this._notification.setTransient(true);
|
2022-07-31 23:30:12 +00:00
|
|
|
|
this._notification.connect('destroy',
|
|
|
|
|
() => (this._notification = null));
|
2011-08-22 16:21:31 +00:00
|
|
|
|
|
2022-07-31 23:30:12 +00:00
|
|
|
|
Main.messageTray.add(source);
|
|
|
|
|
source.showNotification(this._notification);
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2012-08-29 14:22:24 +00:00
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
|
_syncMainConnection() {
|
2021-08-15 22:36:59 +00:00
|
|
|
|
this._mainConnection?.disconnectObject(this);
|
2011-01-25 21:08:12 +00:00
|
|
|
|
|
2022-08-03 02:33:48 +00:00
|
|
|
|
this._mainConnection =
|
|
|
|
|
this._client.get_primary_connection() ||
|
|
|
|
|
this._client.get_activating_connection();
|
2013-04-29 19:20:45 +00:00
|
|
|
|
|
|
|
|
|
if (this._mainConnection) {
|
2021-08-15 22:36:59 +00:00
|
|
|
|
this._mainConnection.connectObject('notify::state',
|
|
|
|
|
this._mainConnectionStateChanged.bind(this), this);
|
2013-08-23 20:21:30 +00:00
|
|
|
|
this._mainConnectionStateChanged();
|
2013-04-29 19:20:45 +00:00
|
|
|
|
}
|
2013-08-16 23:32:54 +00:00
|
|
|
|
|
|
|
|
|
this._updateIcon();
|
2014-02-17 17:06:35 +00:00
|
|
|
|
this._syncConnectivity();
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2011-01-25 21:08:12 +00:00
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
|
_mainConnectionStateChanged() {
|
2022-08-07 20:09:23 +00:00
|
|
|
|
if (this._mainConnection.state === NM.ActiveConnectionState.ACTIVATED)
|
|
|
|
|
this._notification?.destroy();
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2011-09-04 19:17:33 +00:00
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
|
_flushConnectivityQueue() {
|
2022-07-31 23:17:53 +00:00
|
|
|
|
for (let item of this._connectivityQueue)
|
|
|
|
|
this._portalHelperProxy?.CloseAsync(item);
|
|
|
|
|
this._connectivityQueue.clear();
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2014-02-17 17:06:35 +00:00
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
|
_closeConnectivityCheck(path) {
|
2022-07-31 23:17:53 +00:00
|
|
|
|
if (this._connectivityQueue.delete(path))
|
|
|
|
|
this._portalHelperProxy?.CloseAsync(path);
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2014-02-17 17:06:35 +00:00
|
|
|
|
|
2022-11-11 14:35:12 +00:00
|
|
|
|
async _portalHelperDone(parameters) {
|
2014-02-17 17:06:35 +00:00
|
|
|
|
let [path, result] = parameters;
|
|
|
|
|
|
|
|
|
|
if (result == PortalHelperResult.CANCELLED) {
|
|
|
|
|
// Keep the connection in the queue, so the user is not
|
|
|
|
|
// spammed with more logins until we next flush the queue,
|
2021-11-13 20:23:48 +00:00
|
|
|
|
// which will happen once they choose a better connection
|
2014-02-17 17:06:35 +00:00
|
|
|
|
// or we get to full connectivity through other means
|
|
|
|
|
} else if (result == PortalHelperResult.COMPLETED) {
|
|
|
|
|
this._closeConnectivityCheck(path);
|
|
|
|
|
} else if (result == PortalHelperResult.RECHECK) {
|
2019-12-19 19:50:37 +00:00
|
|
|
|
try {
|
|
|
|
|
const state = await this._client.check_connectivity_async(null);
|
|
|
|
|
if (state >= NM.ConnectivityState.FULL)
|
|
|
|
|
this._closeConnectivityCheck(path);
|
|
|
|
|
} catch (e) { }
|
2014-02-17 17:06:35 +00:00
|
|
|
|
} else {
|
2022-02-07 14:14:06 +00:00
|
|
|
|
log(`Invalid result from portal helper: ${result}`);
|
2014-02-17 17:06:35 +00:00
|
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2014-02-17 17:06:35 +00:00
|
|
|
|
|
2022-06-23 12:53:29 +00:00
|
|
|
|
async _syncConnectivity() {
|
2014-02-17 17:06:35 +00:00
|
|
|
|
if (this._mainConnection == null ||
|
2017-10-31 10:38:20 +00:00
|
|
|
|
this._mainConnection.state != NM.ActiveConnectionState.ACTIVATED) {
|
2014-02-17 17:06:35 +00:00
|
|
|
|
this._flushConnectivityQueue();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-31 10:38:20 +00:00
|
|
|
|
let isPortal = this._client.connectivity == NM.ConnectivityState.PORTAL;
|
2014-02-17 17:06:35 +00:00
|
|
|
|
// For testing, allow interpreting any value != FULL as PORTAL, because
|
|
|
|
|
// LIMITED (no upstream route after the default gateway) is easy to obtain
|
|
|
|
|
// with a tethered phone
|
|
|
|
|
// NONE is also possible, with a connection configured to force no default route
|
|
|
|
|
// (but in general we should only prompt a portal if we know there is a portal)
|
|
|
|
|
if (GLib.getenv('GNOME_SHELL_CONNECTIVITY_TEST') != null)
|
2022-01-18 20:02:04 +00:00
|
|
|
|
isPortal ||= this._client.connectivity < NM.ConnectivityState.FULL;
|
2017-02-19 15:38:07 +00:00
|
|
|
|
if (!isPortal || Main.sessionMode.isGreeter)
|
2014-02-17 17:06:35 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
let path = this._mainConnection.get_path();
|
2022-07-31 23:17:53 +00:00
|
|
|
|
if (this._connectivityQueue.has(path))
|
|
|
|
|
return;
|
2014-02-17 17:06:35 +00:00
|
|
|
|
|
|
|
|
|
let timestamp = global.get_current_time();
|
2022-06-23 12:53:29 +00:00
|
|
|
|
if (!this._portalHelperProxy) {
|
|
|
|
|
this._portalHelperProxy = new Gio.DBusProxy({
|
|
|
|
|
g_connection: Gio.DBus.session,
|
|
|
|
|
g_name: 'org.gnome.Shell.PortalHelper',
|
|
|
|
|
g_object_path: '/org/gnome/Shell/PortalHelper',
|
|
|
|
|
g_interface_name: PortalHelperInfo.name,
|
|
|
|
|
g_interface_info: PortalHelperInfo,
|
|
|
|
|
});
|
|
|
|
|
this._portalHelperProxy.connectSignal('Done',
|
2022-11-11 14:35:12 +00:00
|
|
|
|
(proxy, emitter, params) => {
|
|
|
|
|
this._portalHelperDone(params).catch(logError);
|
|
|
|
|
});
|
2022-06-23 12:53:29 +00:00
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
await this._portalHelperProxy.init_async(
|
|
|
|
|
GLib.PRIORITY_DEFAULT, null);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error(`Error launching the portal helper: ${e.message}`);
|
|
|
|
|
}
|
2014-02-17 17:06:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-03-06 15:02:52 +00:00
|
|
|
|
this._portalHelperProxy?.AuthenticateAsync(path, this._client.connectivity_check_uri, timestamp).catch(logError);
|
2022-06-23 12:53:29 +00:00
|
|
|
|
|
2022-07-31 23:17:53 +00:00
|
|
|
|
this._connectivityQueue.add(path);
|
2017-10-31 01:19:44 +00:00
|
|
|
|
}
|
2011-01-25 21:08:12 +00:00
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
|
_updateIcon() {
|
2022-08-03 02:33:48 +00:00
|
|
|
|
const [dev] = this._mainConnection?.get_devices() ?? [];
|
2022-08-03 04:03:40 +00:00
|
|
|
|
const primaryToggle = this._deviceToggles.get(dev?.device_type) ?? null;
|
|
|
|
|
this._primaryIndicatorBinding.source = primaryToggle;
|
2022-08-03 02:33:48 +00:00
|
|
|
|
|
2022-08-03 04:03:40 +00:00
|
|
|
|
if (!primaryToggle) {
|
2022-08-03 02:33:48 +00:00
|
|
|
|
if (this._client.connectivity === NM.ConnectivityState.FULL)
|
|
|
|
|
this._primaryIndicator.icon_name = 'network-wired-symbolic';
|
|
|
|
|
else
|
|
|
|
|
this._primaryIndicator.icon_name = 'network-wired-no-route-symbolic';
|
2011-01-25 21:08:12 +00:00
|
|
|
|
}
|
2022-08-03 02:33:48 +00:00
|
|
|
|
|
|
|
|
|
const state = this._client.get_state();
|
|
|
|
|
const connected = state === NM.State.CONNECTED_GLOBAL;
|
2022-08-03 04:03:40 +00:00
|
|
|
|
this._primaryIndicator.visible = (primaryToggle != null) || connected;
|
2011-01-25 21:08:12 +00:00
|
|
|
|
}
|
2019-07-16 09:24:13 +00:00
|
|
|
|
});
|