2011-09-28 09:16:26 -04:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2013-06-12 00:03:36 -04:00
|
|
|
const Clutter = imports.gi.Clutter;
|
2011-01-25 16:08:12 -05:00
|
|
|
const GLib = imports.gi.GLib;
|
|
|
|
const GObject = imports.gi.GObject;
|
2012-08-26 09:49:18 -04:00
|
|
|
const Gio = imports.gi.Gio;
|
2013-06-12 00:03:36 -04:00
|
|
|
const Gtk = imports.gi.Gtk;
|
2011-01-25 16:08:12 -05:00
|
|
|
const Lang = imports.lang;
|
|
|
|
const NetworkManager = imports.gi.NetworkManager;
|
|
|
|
const NMClient = imports.gi.NMClient;
|
2013-04-25 14:00:11 -04:00
|
|
|
const NMGtk = imports.gi.NMGtk;
|
2011-01-25 16:08:12 -05:00
|
|
|
const Signals = imports.signals;
|
2014-02-17 09:04:40 -05:00
|
|
|
const Shell = imports.gi.Shell;
|
2011-01-25 16:08:12 -05:00
|
|
|
const St = imports.gi.St;
|
|
|
|
|
2014-01-28 17:18:10 -05:00
|
|
|
const Animation = imports.ui.animation;
|
2011-01-25 16:08:12 -05:00
|
|
|
const Main = imports.ui.main;
|
|
|
|
const PanelMenu = imports.ui.panelMenu;
|
|
|
|
const PopupMenu = imports.ui.popupMenu;
|
|
|
|
const MessageTray = imports.ui.messageTray;
|
2013-06-12 00:03:36 -04:00
|
|
|
const ModalDialog = imports.ui.modalDialog;
|
2011-01-25 16:08:12 -05:00
|
|
|
const ModemManager = imports.misc.modemManager;
|
2014-01-28 17:18:10 -05:00
|
|
|
const Rfkill = imports.ui.status.rfkill;
|
2011-01-25 16:08:12 -05:00
|
|
|
const Util = imports.misc.util;
|
|
|
|
|
|
|
|
const NMConnectionCategory = {
|
2011-03-26 13:38:20 -04:00
|
|
|
INVALID: 'invalid',
|
2014-01-23 14:25:06 -05:00
|
|
|
WIRED: 'wired',
|
2011-01-25 16:08:12 -05:00
|
|
|
WIRELESS: 'wireless',
|
|
|
|
WWAN: 'wwan',
|
|
|
|
VPN: 'vpn'
|
|
|
|
};
|
|
|
|
|
|
|
|
const NMAccessPointSecurity = {
|
|
|
|
NONE: 1,
|
|
|
|
WEP: 2,
|
2011-05-03 13:21:45 -04:00
|
|
|
WPA_PSK: 3,
|
|
|
|
WPA2_PSK: 4,
|
|
|
|
WPA_ENT: 5,
|
|
|
|
WPA2_ENT: 6
|
2011-01-25 16:08:12 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
// small optimization, to avoid using [] all the time
|
|
|
|
const NM80211Mode = NetworkManager['80211Mode'];
|
|
|
|
const NM80211ApFlags = NetworkManager['80211ApFlags'];
|
|
|
|
const NM80211ApSecurityFlags = NetworkManager['80211ApSecurityFlags'];
|
|
|
|
|
2014-02-17 12:06:35 -05:00
|
|
|
const PortalHelperResult = {
|
|
|
|
CANCELLED: 0,
|
|
|
|
COMPLETED: 1,
|
|
|
|
RECHECK: 2
|
|
|
|
};
|
|
|
|
|
|
|
|
const PortalHelperIface = '<node> \
|
|
|
|
<interface name="org.gnome.Shell.PortalHelper"> \
|
|
|
|
<method name="Authenticate"> \
|
|
|
|
<arg type="o" direction="in" name="connection" /> \
|
|
|
|
<arg type="s" direction="in" name="url" /> \
|
|
|
|
<arg type="u" direction="in" name="timestamp" /> \
|
|
|
|
</method> \
|
|
|
|
<method name="Close"> \
|
|
|
|
<arg type="o" direction="in" name="connection" /> \
|
|
|
|
</method> \
|
|
|
|
<method name="Refresh"> \
|
|
|
|
<arg type="o" direction="in" name="connection" /> \
|
|
|
|
</method> \
|
|
|
|
<signal name="Done"> \
|
|
|
|
<arg type="o" name="connection" /> \
|
|
|
|
<arg type="u" name="result" /> \
|
|
|
|
</signal> \
|
|
|
|
</interface> \
|
|
|
|
</node>';
|
|
|
|
const PortalHelperProxy = Gio.DBusProxy.makeProxyWrapper(PortalHelperIface);
|
|
|
|
|
2011-01-25 16:08:12 -05:00
|
|
|
function ssidCompare(one, two) {
|
|
|
|
if (!one || !two)
|
|
|
|
return false;
|
|
|
|
if (one.length != two.length)
|
|
|
|
return false;
|
|
|
|
for (let i = 0; i < one.length; i++) {
|
|
|
|
if (one[i] != two[i])
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function signalToIcon(value) {
|
|
|
|
if (value > 80)
|
|
|
|
return 'excellent';
|
|
|
|
if (value > 55)
|
|
|
|
return 'good';
|
|
|
|
if (value > 30)
|
|
|
|
return 'ok';
|
|
|
|
if (value > 5)
|
|
|
|
return 'weak';
|
|
|
|
return 'none';
|
|
|
|
}
|
|
|
|
|
2011-08-03 14:05:53 -04:00
|
|
|
function ssidToLabel(ssid) {
|
|
|
|
let label = NetworkManager.utils_ssid_to_utf8(ssid);
|
|
|
|
if (!label)
|
|
|
|
label = _("<unknown>");
|
|
|
|
return label;
|
|
|
|
}
|
|
|
|
|
2013-10-03 08:20:31 -04:00
|
|
|
function ensureActiveConnectionProps(active, settings) {
|
|
|
|
if (!active._connection) {
|
|
|
|
active._connection = settings.get_connection_by_path(active.connection);
|
|
|
|
|
|
|
|
// This list is guaranteed to have only one device in it.
|
|
|
|
let device = active.get_devices()[0]._delegate;
|
|
|
|
active._primaryDevice = device;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-02 13:39:58 -04:00
|
|
|
function createSettingsAction(label, device) {
|
|
|
|
let item = new PopupMenu.PopupMenuItem(label);
|
|
|
|
|
|
|
|
item.connect('activate', function() {
|
|
|
|
Util.spawnApp(['gnome-control-center', 'network', 'show-device',
|
|
|
|
device.get_path()]);
|
|
|
|
});
|
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
2013-06-11 20:13:37 -04:00
|
|
|
const NMConnectionItem = new Lang.Class({
|
|
|
|
Name: 'NMConnectionItem',
|
2011-01-25 16:08:12 -05:00
|
|
|
|
2013-06-11 20:13:37 -04:00
|
|
|
_init: function(section, connection) {
|
|
|
|
this._section = section;
|
|
|
|
this._connection = connection;
|
|
|
|
this._activeConnection = null;
|
|
|
|
this._activeConnectionChangedId = 0;
|
2011-03-25 11:27:56 -04:00
|
|
|
|
2014-02-08 09:02:05 -05:00
|
|
|
this._buildUI();
|
|
|
|
this._sync();
|
|
|
|
},
|
|
|
|
|
|
|
|
_buildUI: function() {
|
2013-04-29 15:11:14 -04:00
|
|
|
this.labelItem = new PopupMenu.PopupMenuItem('');
|
|
|
|
this.labelItem.connect('activate', Lang.bind(this, this._toggle));
|
|
|
|
|
2014-02-08 09:02:05 -05:00
|
|
|
this.radioItem = new PopupMenu.PopupMenuItem(this._connection.get_id(), false);
|
|
|
|
this.radioItem.connect('activate', Lang.bind(this, this._activate));
|
2013-06-11 20:13:37 -04:00
|
|
|
},
|
2011-01-25 16:08:12 -05:00
|
|
|
|
2013-06-11 20:13:37 -04:00
|
|
|
destroy: function() {
|
2013-04-29 15:11:14 -04:00
|
|
|
this.labelItem.destroy();
|
2014-02-08 09:02:05 -05:00
|
|
|
this.radioItem.destroy();
|
2013-04-29 15:11:14 -04:00
|
|
|
},
|
|
|
|
|
2014-02-08 08:32:23 -05:00
|
|
|
updateForConnection: function(connection) {
|
|
|
|
// 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;
|
2014-02-08 09:02:05 -05:00
|
|
|
this.radioItem.label.text = connection.get_id();
|
2014-02-08 08:32:23 -05:00
|
|
|
this._sync();
|
|
|
|
this.emit('name-changed');
|
|
|
|
},
|
|
|
|
|
2013-04-29 15:11:14 -04:00
|
|
|
getName: function() {
|
2013-08-19 17:07:37 -04:00
|
|
|
return this._connection.get_id();
|
2013-06-11 20:13:37 -04:00
|
|
|
},
|
2011-03-25 11:27:56 -04:00
|
|
|
|
2013-06-11 20:13:37 -04:00
|
|
|
isActive: function() {
|
|
|
|
if (this._activeConnection == null)
|
|
|
|
return false;
|
2011-03-25 11:27:56 -04:00
|
|
|
|
2013-08-19 17:49:11 -04:00
|
|
|
return this._activeConnection.state <= NetworkManager.ActiveConnectionState.ACTIVATED;
|
2011-01-25 16:08:12 -05:00
|
|
|
},
|
|
|
|
|
2013-06-11 20:13:37 -04:00
|
|
|
_sync: function() {
|
2013-04-29 15:11:14 -04:00
|
|
|
let isActive = this.isActive();
|
2014-01-28 15:30:28 -05:00
|
|
|
this.labelItem.label.text = isActive ? _("Turn Off") : this._section.getConnectLabel();
|
2014-02-08 09:02:05 -05:00
|
|
|
this.radioItem.setOrnament(isActive ? PopupMenu.Ornament.DOT : PopupMenu.Ornament.NONE);
|
2013-06-11 20:13:37 -04:00
|
|
|
this.emit('icon-changed');
|
2011-01-25 16:08:12 -05:00
|
|
|
},
|
|
|
|
|
2013-06-11 20:13:37 -04:00
|
|
|
_toggle: function() {
|
|
|
|
if (this._activeConnection == null)
|
|
|
|
this._section.activateConnection(this._connection);
|
2011-04-07 17:21:08 -04:00
|
|
|
else
|
2013-06-11 20:13:37 -04:00
|
|
|
this._section.deactivateConnection(this._activeConnection);
|
2011-01-25 16:08:12 -05:00
|
|
|
|
2013-06-11 20:13:37 -04:00
|
|
|
this._sync();
|
|
|
|
},
|
|
|
|
|
2014-02-08 09:02:05 -05:00
|
|
|
_activate: function() {
|
|
|
|
if (this._activeConnection == null)
|
|
|
|
this._section.activateConnection(this._connection);
|
|
|
|
|
|
|
|
this._sync();
|
2013-06-11 20:13:37 -04:00
|
|
|
},
|
2011-01-25 16:08:12 -05:00
|
|
|
|
2013-06-11 20:13:37 -04:00
|
|
|
_connectionStateChanged: function(ac, newstate, reason) {
|
|
|
|
this._sync();
|
|
|
|
},
|
|
|
|
|
|
|
|
setActiveConnection: function(activeConnection) {
|
|
|
|
if (this._activeConnectionChangedId > 0) {
|
|
|
|
this._activeConnection.disconnect(this._activeConnectionChangedId);
|
|
|
|
this._activeConnectionChangedId = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._activeConnection = activeConnection;
|
|
|
|
|
|
|
|
if (this._activeConnection)
|
2013-08-19 17:38:59 -04:00
|
|
|
this._activeConnectionChangedId = this._activeConnection.connect('notify::state',
|
2013-06-11 20:13:37 -04:00
|
|
|
Lang.bind(this, this._connectionStateChanged));
|
|
|
|
|
|
|
|
this._sync();
|
|
|
|
},
|
|
|
|
});
|
|
|
|
Signals.addSignalMethods(NMConnectionItem.prototype);
|
|
|
|
|
|
|
|
const NMConnectionSection = new Lang.Class({
|
|
|
|
Name: 'NMConnectionSection',
|
2011-11-20 11:07:14 -05:00
|
|
|
Abstract: true,
|
2011-01-25 16:08:12 -05:00
|
|
|
|
2013-06-11 20:13:37 -04:00
|
|
|
_init: function(client) {
|
2013-04-26 19:28:48 -04:00
|
|
|
this._client = client;
|
|
|
|
|
2014-01-14 17:49:47 -05:00
|
|
|
this._connectionItems = new Map();
|
2013-04-26 19:28:48 -04:00
|
|
|
this._connections = [];
|
|
|
|
|
2013-04-29 15:11:14 -04:00
|
|
|
this._labelSection = new PopupMenu.PopupMenuSection();
|
2014-02-08 09:02:05 -05:00
|
|
|
this._radioSection = new PopupMenu.PopupMenuSection();
|
2013-04-26 19:28:48 -04:00
|
|
|
|
2013-04-29 15:11:14 -04:00
|
|
|
this.item = new PopupMenu.PopupSubMenuMenuItem('', true);
|
|
|
|
this.item.menu.addMenuItem(this._labelSection);
|
2014-02-08 09:02:05 -05:00
|
|
|
this.item.menu.addMenuItem(this._radioSection);
|
2013-04-26 19:28:48 -04:00
|
|
|
|
2014-03-15 07:40:13 -04:00
|
|
|
this._notifyConnectivityId = this._client.connect('notify::connectivity', Lang.bind(this, this._iconChanged));
|
2013-06-11 20:13:37 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
destroy: function() {
|
2014-03-15 07:40:13 -04:00
|
|
|
if (this._notifyConnectivityId != 0) {
|
|
|
|
this._client.disconnect(this._notifyConnectivityId);
|
|
|
|
this._notifyConnectivityId = 0;
|
|
|
|
}
|
|
|
|
|
2013-10-02 18:11:48 -04:00
|
|
|
this.item.destroy();
|
2013-06-11 20:13:37 -04:00
|
|
|
},
|
|
|
|
|
2014-03-15 07:40:13 -04:00
|
|
|
_iconChanged: function() {
|
|
|
|
this._sync();
|
|
|
|
this.emit('icon-changed');
|
|
|
|
},
|
|
|
|
|
2013-04-29 15:11:14 -04:00
|
|
|
_sync: function() {
|
2014-01-14 17:49:47 -05:00
|
|
|
let nItems = this._connectionItems.size;
|
2013-04-29 15:11:14 -04:00
|
|
|
|
2014-02-08 09:02:05 -05:00
|
|
|
this._radioSection.actor.visible = (nItems > 1);
|
2013-04-29 15:11:14 -04:00
|
|
|
this._labelSection.actor.visible = (nItems == 1);
|
|
|
|
|
|
|
|
this.item.status.text = this._getStatus();
|
|
|
|
this.item.icon.icon_name = this._getMenuIcon();
|
2013-08-18 14:16:49 -04:00
|
|
|
|
|
|
|
// desc can be undefined at cold-plug, before we called
|
|
|
|
// NMGtk.disambiguate_device_names() at least once
|
|
|
|
let desc = this._getDescription();
|
|
|
|
if (desc)
|
|
|
|
this.item.label.text = desc;
|
|
|
|
else
|
|
|
|
this.item.label.text = '';
|
2013-04-29 15:11:14 -04:00
|
|
|
},
|
|
|
|
|
2014-01-29 16:46:37 -05:00
|
|
|
_getMenuIcon: function() {
|
|
|
|
return this.getIndicatorIcon();
|
|
|
|
},
|
|
|
|
|
2014-01-28 15:30:28 -05:00
|
|
|
getConnectLabel: function() {
|
|
|
|
return _("Connect");
|
|
|
|
},
|
|
|
|
|
2013-06-11 20:13:37 -04:00
|
|
|
_connectionValid: function(connection) {
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
|
|
|
|
_connectionSortFunction: function(one, two) {
|
2014-02-08 08:33:32 -05:00
|
|
|
return GLib.utf8_collate(one.get_id(), two.get_id());
|
2013-06-11 20:13:37 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
_makeConnectionItem: function(connection) {
|
|
|
|
return new NMConnectionItem(this, connection);
|
2012-08-29 10:22:24 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
checkConnection: function(connection) {
|
2013-06-11 20:13:37 -04:00
|
|
|
if (!this._connectionValid(connection))
|
|
|
|
return;
|
2012-08-29 10:22:24 -04:00
|
|
|
|
2014-02-08 08:32:23 -05:00
|
|
|
// This function is called everytime connection is added or updated
|
|
|
|
// In the usual case, we already added this connection and UUID
|
|
|
|
// didn't change. So we need to check if we already have an item,
|
|
|
|
// and update it for properties in the connection that changed
|
|
|
|
// (the only one we care about is the name)
|
|
|
|
// But it's also possible we didn't know about this connection
|
|
|
|
// (eg, during coldplug, or because it was updated and suddenly
|
|
|
|
// it's valid for this device), in which case we add a new item
|
|
|
|
|
|
|
|
let item = this._connectionItems.get(connection.get_uuid());
|
|
|
|
if (item)
|
|
|
|
item.updateForConnection(connection);
|
|
|
|
else
|
|
|
|
this._addConnection(connection);
|
2012-08-29 10:22:24 -04:00
|
|
|
},
|
|
|
|
|
2013-06-11 20:13:37 -04:00
|
|
|
_addConnection: function(connection) {
|
|
|
|
let item = this._makeConnectionItem(connection);
|
|
|
|
if (!item)
|
|
|
|
return;
|
2012-08-29 10:22:24 -04:00
|
|
|
|
2013-06-11 20:13:37 -04:00
|
|
|
item.connect('icon-changed', Lang.bind(this, function() {
|
2014-03-15 07:40:13 -04:00
|
|
|
this._iconChanged();
|
2013-06-11 20:13:37 -04:00
|
|
|
}));
|
|
|
|
item.connect('activation-failed', Lang.bind(this, function(item, reason) {
|
|
|
|
this.emit('activation-failed', reason);
|
|
|
|
}));
|
2014-02-08 08:32:23 -05:00
|
|
|
item.connect('name-changed', Lang.bind(this, this._sync));
|
2013-06-11 20:13:37 -04:00
|
|
|
|
2013-09-10 21:53:19 -04:00
|
|
|
let pos = Util.insertSorted(this._connections, connection, Lang.bind(this, this._connectionSortFunction));
|
2013-04-29 15:11:14 -04:00
|
|
|
this._labelSection.addMenuItem(item.labelItem, pos);
|
2014-02-08 09:02:05 -05:00
|
|
|
this._radioSection.addMenuItem(item.radioItem, pos);
|
2013-06-11 20:13:37 -04:00
|
|
|
this._connectionItems.set(connection.get_uuid(), item);
|
2013-04-29 15:11:14 -04:00
|
|
|
this._sync();
|
2012-08-29 10:22:24 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
removeConnection: function(connection) {
|
2014-03-08 13:54:09 -05:00
|
|
|
let uuid = connection.get_uuid();
|
|
|
|
let item = this._connectionItems.get(uuid);
|
|
|
|
if (item == undefined)
|
|
|
|
return;
|
|
|
|
|
|
|
|
item.destroy();
|
|
|
|
this._connectionItems.delete(uuid);
|
2012-08-29 10:22:24 -04:00
|
|
|
|
2013-06-11 20:13:37 -04:00
|
|
|
let pos = this._connections.indexOf(connection);
|
2012-08-29 10:22:24 -04:00
|
|
|
this._connections.splice(pos, 1);
|
2013-04-29 15:11:14 -04:00
|
|
|
|
|
|
|
this._sync();
|
2012-08-29 10:22:24 -04:00
|
|
|
},
|
2013-06-11 20:13:37 -04:00
|
|
|
});
|
|
|
|
Signals.addSignalMethods(NMConnectionSection.prototype);
|
2012-08-29 10:22:24 -04:00
|
|
|
|
2013-06-11 20:13:37 -04:00
|
|
|
const NMConnectionDevice = new Lang.Class({
|
|
|
|
Name: 'NMConnectionDevice',
|
|
|
|
Extends: NMConnectionSection,
|
|
|
|
Abstract: true,
|
2012-08-29 10:22:24 -04:00
|
|
|
|
2013-10-03 08:20:31 -04:00
|
|
|
_init: function(client, device, settings) {
|
2013-06-11 20:13:37 -04:00
|
|
|
this.parent(client);
|
|
|
|
this._device = device;
|
2013-10-03 08:20:31 -04:00
|
|
|
this._settings = settings;
|
2012-08-29 10:22:24 -04:00
|
|
|
|
2013-04-29 15:11:14 -04:00
|
|
|
this._autoConnectItem = this.item.menu.addAction(_("Connect"), Lang.bind(this, this._autoConnect));
|
2014-02-08 09:02:05 -05:00
|
|
|
this._deactivateItem = this._radioSection.addAction(_("Turn Off"), Lang.bind(this, this.deactivateConnection));
|
2013-04-29 15:11:14 -04:00
|
|
|
|
2013-06-11 20:13:37 -04:00
|
|
|
this._stateChangedId = this._device.connect('state-changed', Lang.bind(this, this._deviceStateChanged));
|
|
|
|
this._activeConnectionChangedId = this._device.connect('notify::active-connection', Lang.bind(this, this._activeConnectionChanged));
|
2012-08-29 10:22:24 -04:00
|
|
|
},
|
2011-01-25 16:08:12 -05:00
|
|
|
|
2014-02-03 18:04:43 -05:00
|
|
|
_canReachInternet: function() {
|
|
|
|
if (this._client.primary_connection != this._device.active_connection)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return this._client.connectivity == NetworkManager.ConnectivityState.FULL;
|
|
|
|
},
|
|
|
|
|
2014-01-23 14:25:06 -05:00
|
|
|
_autoConnect: function() {
|
|
|
|
let connection = new NetworkManager.Connection();
|
|
|
|
this._client.add_and_activate_connection(connection, this._device, null, null);
|
|
|
|
},
|
|
|
|
|
2011-01-25 16:08:12 -05:00
|
|
|
destroy: function() {
|
2013-06-11 20:13:37 -04:00
|
|
|
if (this._stateChangedId) {
|
|
|
|
GObject.Object.prototype.disconnect.call(this._device, this._stateChangedId);
|
|
|
|
this._stateChangedId = 0;
|
|
|
|
}
|
|
|
|
if (this._activeConnectionChangedId) {
|
|
|
|
GObject.Object.prototype.disconnect.call(this._device, this._activeConnectionChangedId);
|
2014-01-23 16:11:11 -05:00
|
|
|
this._activeConnectionChangedId = 0;
|
2012-10-03 17:38:35 -04:00
|
|
|
}
|
|
|
|
|
2013-06-11 20:13:37 -04:00
|
|
|
this.parent();
|
2011-01-25 16:08:12 -05:00
|
|
|
},
|
|
|
|
|
2013-04-29 15:11:14 -04:00
|
|
|
_activeConnectionChanged: function() {
|
|
|
|
if (this._activeConnection) {
|
|
|
|
let item = this._connectionItems.get(this._activeConnection._connection.get_uuid());
|
|
|
|
item.setActiveConnection(null);
|
|
|
|
}
|
|
|
|
|
|
|
|
this._activeConnection = this._device.active_connection;
|
|
|
|
|
|
|
|
if (this._activeConnection) {
|
2013-10-03 08:20:31 -04:00
|
|
|
ensureActiveConnectionProps(this._activeConnection, this._settings);
|
2013-04-29 15:11:14 -04:00
|
|
|
let item = this._connectionItems.get(this._activeConnection._connection.get_uuid());
|
|
|
|
item.setActiveConnection(this._activeConnection);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-06-11 20:13:37 -04:00
|
|
|
_deviceStateChanged: function(device, newstate, oldstate, reason) {
|
|
|
|
if (newstate == oldstate) {
|
|
|
|
log('device emitted state-changed without actually changing state');
|
|
|
|
return;
|
|
|
|
}
|
2012-12-04 08:49:34 -05:00
|
|
|
|
2013-06-11 20:13:37 -04:00
|
|
|
/* 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 == NetworkManager.DeviceState.FAILED &&
|
|
|
|
reason != NetworkManager.DeviceStateReason.NO_SECRETS) {
|
|
|
|
this.emit('activation-failed', reason);
|
2012-12-04 08:49:34 -05:00
|
|
|
}
|
2013-06-11 20:13:37 -04:00
|
|
|
|
2013-04-29 15:11:14 -04:00
|
|
|
this._sync();
|
2013-06-11 20:13:37 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
_connectionValid: function(connection) {
|
|
|
|
return this._device.connection_valid(connection);
|
|
|
|
},
|
|
|
|
|
|
|
|
activateConnection: function(connection) {
|
|
|
|
this._client.activate_connection(connection, this._device, null, null);
|
|
|
|
},
|
|
|
|
|
|
|
|
deactivateConnection: function(activeConnection) {
|
|
|
|
this._device.disconnect(null);
|
2012-12-04 08:49:34 -05:00
|
|
|
},
|
|
|
|
|
2013-07-17 01:01:44 -04:00
|
|
|
setDeviceDescription: function(desc) {
|
|
|
|
this._description = desc;
|
|
|
|
this._sync();
|
|
|
|
},
|
|
|
|
|
2013-04-29 15:11:14 -04:00
|
|
|
_getDescription: function() {
|
2013-07-17 01:01:44 -04:00
|
|
|
return this._description;
|
2011-01-25 16:08:12 -05:00
|
|
|
},
|
|
|
|
|
2013-04-29 15:11:14 -04:00
|
|
|
_sync: function() {
|
2014-01-14 17:49:47 -05:00
|
|
|
let nItems = this._connectionItems.size;
|
2013-04-29 15:11:14 -04:00
|
|
|
this._autoConnectItem.actor.visible = (nItems == 0);
|
2014-02-08 09:02:05 -05:00
|
|
|
this._deactivateItem.actor.visible = this._device.state > NetworkManager.DeviceState.DISCONNECTED;
|
2013-04-29 15:11:14 -04:00
|
|
|
this.parent();
|
2011-01-25 16:08:12 -05:00
|
|
|
},
|
|
|
|
|
2013-06-11 20:13:37 -04:00
|
|
|
_getStatus: function() {
|
2013-06-11 19:56:17 -04:00
|
|
|
if (!this._device)
|
2013-08-19 17:14:15 -04:00
|
|
|
return '';
|
2012-12-04 08:49:34 -05:00
|
|
|
|
2013-06-11 19:56:17 -04:00
|
|
|
switch(this._device.state) {
|
2011-01-25 16:08:12 -05:00
|
|
|
case NetworkManager.DeviceState.DISCONNECTED:
|
2013-10-03 08:26:21 -04:00
|
|
|
return _("Off");
|
2011-01-25 16:08:12 -05:00
|
|
|
case NetworkManager.DeviceState.ACTIVATED:
|
2014-03-04 08:02:00 -05:00
|
|
|
return _("Connected");
|
2011-05-09 10:15:03 -04:00
|
|
|
case NetworkManager.DeviceState.UNMANAGED:
|
|
|
|
/* Translators: this is for network devices that are physically present but are not
|
|
|
|
under NetworkManager's control (and thus cannot be used in the menu) */
|
2014-04-04 07:30:37 -04:00
|
|
|
return _("Unmanaged");
|
2011-05-09 10:15:03 -04:00
|
|
|
case NetworkManager.DeviceState.DEACTIVATING:
|
2014-04-04 07:30:37 -04:00
|
|
|
return _("Disconnecting");
|
2011-01-25 16:08:12 -05:00
|
|
|
case NetworkManager.DeviceState.PREPARE:
|
|
|
|
case NetworkManager.DeviceState.CONFIG:
|
|
|
|
case NetworkManager.DeviceState.IP_CONFIG:
|
2011-04-19 09:31:54 -04:00
|
|
|
case NetworkManager.DeviceState.IP_CHECK:
|
|
|
|
case NetworkManager.DeviceState.SECONDARIES:
|
2014-04-04 07:30:37 -04:00
|
|
|
return _("Connecting");
|
2011-01-25 16:08:12 -05:00
|
|
|
case NetworkManager.DeviceState.NEED_AUTH:
|
|
|
|
/* Translators: this is for network connections that require some kind of key or password */
|
2014-04-04 07:30:37 -04:00
|
|
|
return _("Authentication required");
|
2011-01-25 16:08:12 -05:00
|
|
|
case NetworkManager.DeviceState.UNAVAILABLE:
|
2011-03-25 12:10:38 -04:00
|
|
|
// This state is actually a compound of various states (generically unavailable,
|
2013-06-12 14:38:20 -04:00
|
|
|
// firmware missing), that are exposed by different properties (whose state may
|
|
|
|
// or may not updated when we receive state-changed).
|
2013-06-11 19:56:17 -04:00
|
|
|
if (this._device.firmware_missing) {
|
2011-03-25 12:10:38 -04:00
|
|
|
/* Translators: this is for devices that require some kind of firmware or kernel
|
|
|
|
module, which is missing */
|
2014-04-04 07:30:37 -04:00
|
|
|
return _("Firmware missing");
|
2011-03-25 12:10:38 -04:00
|
|
|
}
|
|
|
|
/* Translators: this is for a network device that cannot be activated (for example it
|
|
|
|
is disabled by rfkill, or it has no coverage */
|
2014-04-04 07:30:37 -04:00
|
|
|
return _("Unavailable");
|
2011-01-25 16:08:12 -05:00
|
|
|
case NetworkManager.DeviceState.FAILED:
|
2014-04-04 07:30:37 -04:00
|
|
|
return _("Connection failed");
|
2011-01-25 16:08:12 -05:00
|
|
|
default:
|
2013-06-11 19:56:17 -04:00
|
|
|
log('Device state invalid, is %d'.format(this._device.state));
|
2011-01-25 16:08:12 -05:00
|
|
|
return 'invalid';
|
|
|
|
}
|
|
|
|
},
|
2011-11-20 11:07:14 -05:00
|
|
|
});
|
2011-01-25 16:08:12 -05:00
|
|
|
|
2014-01-23 14:25:06 -05:00
|
|
|
const NMDeviceWired = new Lang.Class({
|
|
|
|
Name: 'NMDeviceWired',
|
|
|
|
Extends: NMConnectionDevice,
|
|
|
|
category: NMConnectionCategory.WIRED,
|
|
|
|
|
|
|
|
_init: function(client, device, settings) {
|
|
|
|
this.parent(client, device, settings);
|
|
|
|
|
|
|
|
this.item.menu.addMenuItem(createSettingsAction(_("Wired Settings"), device));
|
|
|
|
},
|
|
|
|
|
2014-01-28 17:41:13 -05:00
|
|
|
_hasCarrier: function() {
|
|
|
|
if (this._device instanceof NMClient.DeviceEthernet)
|
|
|
|
return this._device.carrier;
|
|
|
|
else
|
|
|
|
return true;
|
2014-01-23 14:25:06 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_sync: function() {
|
2014-01-28 17:41:13 -05:00
|
|
|
this.item.actor.visible = this._hasCarrier();
|
2014-01-23 14:25:06 -05:00
|
|
|
this.parent();
|
|
|
|
},
|
|
|
|
|
|
|
|
getIndicatorIcon: function() {
|
2014-01-29 16:46:37 -05:00
|
|
|
if (this._device.active_connection) {
|
|
|
|
let state = this._device.active_connection.state;
|
|
|
|
|
2014-02-03 18:04:43 -05:00
|
|
|
if (state == NetworkManager.ActiveConnectionState.ACTIVATING) {
|
2014-01-29 16:46:37 -05:00
|
|
|
return 'network-wired-acquiring-symbolic';
|
2014-02-03 18:04:43 -05:00
|
|
|
} else if (state == NetworkManager.ActiveConnectionState.ACTIVATED) {
|
|
|
|
if (this._canReachInternet())
|
|
|
|
return 'network-wired-symbolic';
|
|
|
|
else
|
|
|
|
return 'network-wired-no-route-symbolic';
|
|
|
|
} else {
|
2014-01-29 16:46:37 -05:00
|
|
|
return 'network-wired-disconnected-symbolic';
|
2014-02-03 18:04:43 -05:00
|
|
|
}
|
2014-01-29 16:46:37 -05:00
|
|
|
} else
|
2014-01-23 14:25:06 -05:00
|
|
|
return 'network-wired-disconnected-symbolic';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2011-11-20 11:07:14 -05:00
|
|
|
const NMDeviceModem = new Lang.Class({
|
|
|
|
Name: 'NMDeviceModem',
|
2013-06-11 20:13:37 -04:00
|
|
|
Extends: NMConnectionDevice,
|
2013-06-12 15:27:09 -04:00
|
|
|
category: NMConnectionCategory.WWAN,
|
2011-01-25 16:08:12 -05:00
|
|
|
|
2013-10-03 08:20:31 -04:00
|
|
|
_init: function(client, device, settings) {
|
|
|
|
this.parent(client, device, settings);
|
2013-10-02 13:39:58 -04:00
|
|
|
|
|
|
|
this.item.menu.addMenuItem(createSettingsAction(_("Mobile Broadband Settings"), device));
|
|
|
|
|
2013-06-11 20:13:37 -04: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);
|
|
|
|
else if (capabilities & NetworkManager.DeviceModemCapabilities.GSM_UMTS)
|
|
|
|
this._mobileDevice = new ModemManager.ModemGsm(device.udi);
|
|
|
|
else if (capabilities & NetworkManager.DeviceModemCapabilities.CDMA_EVDO)
|
|
|
|
this._mobileDevice = new ModemManager.ModemCdma(device.udi);
|
|
|
|
else if (capabilities & NetworkManager.DeviceModemCapabilities.LTE)
|
|
|
|
this._mobileDevice = new ModemManager.ModemGsm(device.udi);
|
|
|
|
|
|
|
|
if (this._mobileDevice) {
|
2013-10-03 08:49:21 -04:00
|
|
|
this._operatorNameId = this._mobileDevice.connect('notify::operator-name', Lang.bind(this, this._sync));
|
2013-06-11 20:13:37 -04:00
|
|
|
this._signalQualityId = this._mobileDevice.connect('notify::signal-quality', Lang.bind(this, function() {
|
2014-03-15 07:40:13 -04:00
|
|
|
this._iconChanged();
|
2011-01-25 16:08:12 -05:00
|
|
|
}));
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-04-29 15:11:14 -04:00
|
|
|
_autoConnect: function() {
|
|
|
|
Util.spawn(['gnome-control-center', 'network',
|
|
|
|
'connect-3g', this._device.get_path()]);
|
|
|
|
},
|
|
|
|
|
2011-01-25 16:08:12 -05:00
|
|
|
destroy: function() {
|
|
|
|
if (this._operatorNameId) {
|
2013-06-11 20:13:37 -04:00
|
|
|
this._mobileDevice.disconnect(this._operatorNameId);
|
2011-01-25 16:08:12 -05:00
|
|
|
this._operatorNameId = 0;
|
|
|
|
}
|
|
|
|
if (this._signalQualityId) {
|
2013-06-11 20:13:37 -04:00
|
|
|
this._mobileDevice.disconnect(this._signalQualityId);
|
2011-01-25 16:08:12 -05:00
|
|
|
this._signalQualityId = 0;
|
|
|
|
}
|
|
|
|
|
2011-11-20 11:07:14 -05:00
|
|
|
this.parent();
|
2011-01-25 16:08:12 -05:00
|
|
|
},
|
|
|
|
|
2013-10-03 08:31:58 -04:00
|
|
|
_getStatus: function() {
|
|
|
|
if (!this._client.wwan_hardware_enabled)
|
|
|
|
return _("Hardware Disabled");
|
|
|
|
else if (!this._client.wwan_enabled)
|
|
|
|
/* Translators: this is for a network device that cannot be activated
|
|
|
|
because it's disabled by rfkill (airplane mode) */
|
|
|
|
return _("Disabled");
|
2013-10-03 08:49:21 -04:00
|
|
|
else if (this._device.state == NetworkManager.DeviceState.ACTIVATED &&
|
|
|
|
this._mobileDevice && this._mobileDevice.operator_name)
|
|
|
|
return this._mobileDevice.operator_name;
|
2013-10-03 08:31:58 -04:00
|
|
|
else
|
|
|
|
return this.parent();
|
|
|
|
},
|
|
|
|
|
2014-01-29 16:46:37 -05:00
|
|
|
getIndicatorIcon: function() {
|
|
|
|
if (this._device.active_connection) {
|
|
|
|
if (this._device.active_connection.state == NetworkManager.ActiveConnectionState.ACTIVATING)
|
|
|
|
return 'network-cellular-acquiring-symbolic';
|
|
|
|
|
|
|
|
return this._getSignalIcon();
|
|
|
|
} else {
|
2013-04-29 15:11:14 -04:00
|
|
|
return 'network-cellular-signal-none-symbolic';
|
2014-01-29 16:46:37 -05:00
|
|
|
}
|
2011-01-25 16:08:12 -05:00
|
|
|
},
|
|
|
|
|
2013-04-29 15:11:14 -04:00
|
|
|
_getSignalIcon: function() {
|
|
|
|
return 'network-cellular-signal-' + signalToIcon(this._mobileDevice.signal_quality) + '-symbolic';
|
2012-08-31 15:43:30 -04:00
|
|
|
},
|
2011-11-20 11:07:14 -05:00
|
|
|
});
|
2011-01-25 16:08:12 -05:00
|
|
|
|
2011-11-20 11:07:14 -05:00
|
|
|
const NMDeviceBluetooth = new Lang.Class({
|
|
|
|
Name: 'NMDeviceBluetooth',
|
2013-06-11 20:13:37 -04:00
|
|
|
Extends: NMConnectionDevice,
|
2013-07-17 01:10:42 -04:00
|
|
|
category: NMConnectionCategory.WWAN,
|
2011-01-25 16:08:12 -05:00
|
|
|
|
2013-10-02 13:39:58 -04:00
|
|
|
_init: function(client, device, settings) {
|
|
|
|
this.parent(client, device, settings);
|
|
|
|
|
|
|
|
this.item.menu.addMenuItem(createSettingsAction(_("Mobile Broadband Settings"), device));
|
|
|
|
},
|
|
|
|
|
2014-01-28 15:30:28 -05:00
|
|
|
_getDescription: function() {
|
|
|
|
return this._device.name;
|
|
|
|
},
|
|
|
|
|
|
|
|
getConnectLabel: function() {
|
|
|
|
return _("Use as Internet connection");
|
|
|
|
},
|
|
|
|
|
2013-04-29 15:11:14 -04:00
|
|
|
getIndicatorIcon: function() {
|
2014-01-29 16:46:37 -05:00
|
|
|
if (this._device.active_connection) {
|
|
|
|
let state = this._device.active_connection.state;
|
|
|
|
if (state == NetworkManager.ActiveConnectionState.ACTIVATING)
|
|
|
|
return 'network-cellular-acquiring-symbolic';
|
|
|
|
else if (state == NetworkManager.ActiveConnectionState.ACTIVATED)
|
|
|
|
return 'network-cellular-connected-symbolic';
|
|
|
|
else
|
|
|
|
return 'network-cellular-signal-none-symbolic';
|
|
|
|
} else {
|
2013-04-29 15:11:14 -04:00
|
|
|
return 'network-cellular-signal-none-symbolic';
|
2014-01-29 16:46:37 -05:00
|
|
|
}
|
2013-04-29 15:11:14 -04:00
|
|
|
}
|
2011-11-20 11:07:14 -05:00
|
|
|
});
|
2011-01-25 16:08:12 -05:00
|
|
|
|
2013-06-12 00:03:36 -04:00
|
|
|
const NMWirelessDialogItem = new Lang.Class({
|
|
|
|
Name: 'NMWirelessDialogItem',
|
|
|
|
|
|
|
|
_init: function(network) {
|
|
|
|
this._network = network;
|
|
|
|
this._ap = network.accessPoints[0];
|
|
|
|
|
2013-10-17 13:04:13 -04:00
|
|
|
this.actor = new St.BoxLayout({ style_class: 'nm-dialog-item',
|
|
|
|
can_focus: true,
|
|
|
|
reactive: true });
|
2013-06-12 00:03:36 -04:00
|
|
|
this.actor.connect('key-focus-in', Lang.bind(this, function() {
|
|
|
|
this.emit('selected');
|
|
|
|
}));
|
2013-10-17 13:04:13 -04:00
|
|
|
let action = new Clutter.ClickAction();
|
|
|
|
action.connect('clicked', Lang.bind(this, function() {
|
2013-06-12 00:03:36 -04:00
|
|
|
this.actor.grab_key_focus();
|
|
|
|
}));
|
2013-10-17 13:04:13 -04:00
|
|
|
this.actor.add_action(action);
|
2013-06-12 00:03:36 -04:00
|
|
|
|
|
|
|
let title = ssidToLabel(this._ap.get_ssid());
|
|
|
|
this._label = new St.Label({ text: title });
|
|
|
|
|
|
|
|
this.actor.label_actor = this._label;
|
2013-10-17 13:04:13 -04:00
|
|
|
this.actor.add(this._label, { x_align: St.Align.START });
|
2013-08-19 10:31:31 -04:00
|
|
|
|
|
|
|
this._selectedIcon = new St.Icon({ style_class: 'nm-dialog-icon',
|
|
|
|
icon_name: 'object-select-symbolic' });
|
2013-10-17 13:04:13 -04:00
|
|
|
this.actor.add(this._selectedIcon);
|
2013-06-12 00:03:36 -04:00
|
|
|
|
|
|
|
this._icons = new St.BoxLayout({ style_class: 'nm-dialog-icons' });
|
2013-10-17 13:04:13 -04:00
|
|
|
this.actor.add(this._icons, { expand: true, x_fill: false, x_align: St.Align.END });
|
2013-06-12 00:03:36 -04:00
|
|
|
|
|
|
|
this._secureIcon = new St.Icon({ style_class: 'nm-dialog-icon' });
|
|
|
|
if (this._ap._secType != NMAccessPointSecurity.NONE)
|
|
|
|
this._secureIcon.icon_name = 'network-wireless-encrypted-symbolic';
|
|
|
|
this._icons.add_actor(this._secureIcon);
|
|
|
|
|
2013-08-19 10:31:31 -04:00
|
|
|
this._signalIcon = new St.Icon({ style_class: 'nm-dialog-icon' });
|
2013-06-12 00:03:36 -04:00
|
|
|
this._icons.add_actor(this._signalIcon);
|
2013-09-20 12:50:36 -04:00
|
|
|
|
|
|
|
this._sync();
|
|
|
|
},
|
|
|
|
|
|
|
|
_sync: function() {
|
|
|
|
this._signalIcon.icon_name = this._getSignalIcon();
|
2013-06-12 00:03:36 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
updateBestAP: function(ap) {
|
|
|
|
this._ap = ap;
|
2013-09-20 12:50:36 -04:00
|
|
|
this._sync();
|
2013-06-12 00:03:36 -04:00
|
|
|
},
|
|
|
|
|
2013-08-19 10:31:31 -04:00
|
|
|
setActive: function(isActive) {
|
|
|
|
this._selectedIcon.opacity = isActive ? 255 : 0;
|
|
|
|
},
|
|
|
|
|
2013-09-20 12:50:36 -04:00
|
|
|
_getSignalIcon: function() {
|
2013-06-12 00:03:36 -04:00
|
|
|
if (this._ap.mode == NM80211Mode.ADHOC)
|
|
|
|
return 'network-workgroup-symbolic';
|
|
|
|
else
|
|
|
|
return 'network-wireless-signal-' + signalToIcon(this._ap.strength) + '-symbolic';
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Signals.addSignalMethods(NMWirelessDialogItem.prototype);
|
|
|
|
|
|
|
|
const NMWirelessDialog = new Lang.Class({
|
|
|
|
Name: 'NMWirelessDialog',
|
|
|
|
Extends: ModalDialog.ModalDialog,
|
|
|
|
|
2014-01-28 17:19:48 -05:00
|
|
|
_init: function(client, device, settings) {
|
2013-06-12 00:03:36 -04:00
|
|
|
this.parent({ styleClass: 'nm-dialog' });
|
|
|
|
|
|
|
|
this._client = client;
|
|
|
|
this._device = device;
|
|
|
|
|
2014-01-28 17:18:10 -05:00
|
|
|
this._wirelessEnabledChangedId = this._client.connect('notify::wireless-enabled',
|
|
|
|
Lang.bind(this, this._syncView));
|
|
|
|
|
|
|
|
this._rfkill = Rfkill.getRfkillManager();
|
|
|
|
this._airplaneModeChangedId = this._rfkill.connect('airplane-mode-changed',
|
|
|
|
Lang.bind(this, this._syncView));
|
|
|
|
|
2013-06-12 00:03:36 -04:00
|
|
|
this._networks = [];
|
|
|
|
this._buildLayout();
|
|
|
|
|
2014-01-28 17:19:48 -05:00
|
|
|
let connections = settings.list_connections();
|
|
|
|
this._connections = connections.filter(Lang.bind(this, function(connection) {
|
|
|
|
return device.connection_valid(connection);
|
|
|
|
}));
|
2013-06-12 00:03:36 -04:00
|
|
|
|
|
|
|
this._apAddedId = device.connect('access-point-added', Lang.bind(this, this._accessPointAdded));
|
|
|
|
this._apRemovedId = device.connect('access-point-removed', Lang.bind(this, this._accessPointRemoved));
|
2013-08-19 10:31:31 -04:00
|
|
|
this._activeApChangedId = device.connect('notify::active-access-point', Lang.bind(this, this._activeApChanged));
|
2013-06-12 00:03:36 -04:00
|
|
|
|
|
|
|
// accessPointAdded will also create dialog items
|
|
|
|
let accessPoints = device.get_access_points() || [ ];
|
|
|
|
accessPoints.forEach(Lang.bind(this, function(ap) {
|
|
|
|
this._accessPointAdded(this._device, ap);
|
|
|
|
}));
|
|
|
|
|
|
|
|
this._selectedNetwork = null;
|
2013-08-19 10:31:31 -04:00
|
|
|
this._activeApChanged();
|
2013-06-12 00:03:36 -04:00
|
|
|
this._updateSensitivity();
|
2014-01-28 17:18:10 -05:00
|
|
|
this._syncView();
|
2014-01-29 16:28:17 -05:00
|
|
|
|
|
|
|
if (accessPoints.length == 0) {
|
|
|
|
/* If there are no visible access points, request a scan */
|
|
|
|
this._device.request_scan_simple(null);
|
|
|
|
}
|
2013-06-12 00:03:36 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
destroy: function() {
|
|
|
|
if (this._apAddedId) {
|
|
|
|
GObject.Object.prototype.disconnect.call(this._device, this._apAddedId);
|
|
|
|
this._apAddedId = 0;
|
|
|
|
}
|
|
|
|
if (this._apRemovedId) {
|
|
|
|
GObject.Object.prototype.disconnect.call(this._device, this._apRemovedId);
|
|
|
|
this._apRemovedId = 0;
|
|
|
|
}
|
2013-08-19 10:31:31 -04:00
|
|
|
if (this._activeApChangedId) {
|
|
|
|
GObject.Object.prototype.disconnect.call(this._device, this._activeApChangedId);
|
|
|
|
this._activeApChangedId = 0;
|
|
|
|
}
|
2014-01-28 17:18:10 -05:00
|
|
|
if (this._wirelessEnabledChangedId) {
|
|
|
|
this._client.disconnect(this._wirelessEnabledChangedId);
|
|
|
|
this._wirelessEnabledChangedId = 0;
|
|
|
|
}
|
|
|
|
if (this._airplaneModeChangedId) {
|
|
|
|
this._rfkill.disconnect(this._airplaneModeChangedId);
|
|
|
|
this._airplaneModeChangedId = 0;
|
|
|
|
}
|
2013-06-12 00:03:36 -04:00
|
|
|
|
|
|
|
this.parent();
|
|
|
|
},
|
|
|
|
|
2013-08-19 10:31:31 -04:00
|
|
|
_activeApChanged: function() {
|
|
|
|
if (this._activeNetwork)
|
|
|
|
this._activeNetwork.item.setActive(false);
|
|
|
|
|
|
|
|
this._activeNetwork = null;
|
|
|
|
if (this._device.active_access_point) {
|
|
|
|
let idx = this._findNetwork(this._device.active_access_point);
|
|
|
|
if (idx >= 0)
|
|
|
|
this._activeNetwork = this._networks[idx];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this._activeNetwork)
|
|
|
|
this._activeNetwork.item.setActive(true);
|
|
|
|
this._updateSensitivity();
|
|
|
|
},
|
|
|
|
|
2013-06-12 00:03:36 -04:00
|
|
|
_updateSensitivity: function() {
|
2014-01-28 17:18:10 -05:00
|
|
|
let connectSensitive = this._client.wireless_enabled && this._selectedNetwork && (this._selectedNetwork != this._activeNetwork);
|
2013-06-12 00:03:36 -04:00
|
|
|
this._connectButton.reactive = connectSensitive;
|
|
|
|
this._connectButton.can_focus = connectSensitive;
|
|
|
|
},
|
|
|
|
|
2014-01-28 17:18:10 -05:00
|
|
|
_syncView: function() {
|
|
|
|
if (this._rfkill.airplaneMode) {
|
|
|
|
this._airplaneBox.show();
|
|
|
|
|
|
|
|
this._airplaneIcon.icon_name = 'airplane-mode-symbolic';
|
|
|
|
this._airplaneHeadline.text = _("Airplane Mode is On");
|
|
|
|
this._airplaneText.text = _("Wi-Fi is disabled when airplane mode is on.");
|
|
|
|
this._airplaneButton.label = _("Turn Off Airplane Mode");
|
|
|
|
|
|
|
|
this._airplaneButton.visible = !this._rfkill.hwAirplaneMode;
|
|
|
|
this._airplaneInactive.visible = this._rfkill.hwAirplaneMode;
|
|
|
|
this._noNetworksBox.hide();
|
|
|
|
} else if (!this._client.wireless_enabled) {
|
|
|
|
this._airplaneBox.show();
|
|
|
|
|
|
|
|
this._airplaneIcon.icon_name = 'dialog-information-symbolic';
|
|
|
|
this._airplaneHeadline.text = _("Wi-Fi is Off");
|
|
|
|
this._airplaneText.text = _("Wi-Fi needs to be turned on in order to connect to a network.");
|
|
|
|
this._airplaneButton.label = _("Turn On Wi-Fi");
|
|
|
|
|
|
|
|
this._airplaneButton.show();
|
|
|
|
this._airplaneInactive.hide();
|
|
|
|
this._noNetworksBox.hide();
|
|
|
|
} else {
|
|
|
|
this._airplaneBox.hide();
|
|
|
|
|
|
|
|
this._noNetworksBox.visible = (this._networks.length == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this._noNetworksBox.visible)
|
|
|
|
this._noNetworksSpinner.play();
|
|
|
|
else
|
|
|
|
this._noNetworksSpinner.stop();
|
2013-08-12 13:19:32 -04:00
|
|
|
},
|
|
|
|
|
2013-06-12 00:03:36 -04:00
|
|
|
_buildLayout: function() {
|
|
|
|
let headline = new St.BoxLayout({ style_class: 'nm-dialog-header-hbox' });
|
|
|
|
|
|
|
|
let icon = new St.Icon({ style_class: 'nm-dialog-header-icon',
|
|
|
|
icon_name: 'network-wireless-signal-excellent-symbolic' });
|
|
|
|
|
|
|
|
let titleBox = new St.BoxLayout({ vertical: true });
|
|
|
|
let title = new St.Label({ style_class: 'nm-dialog-header',
|
|
|
|
text: _("Wi-Fi Networks") });
|
|
|
|
let subtitle = new St.Label({ style_class: 'nm-dialog-subheader',
|
|
|
|
text: _("Select a network") });
|
|
|
|
titleBox.add(title);
|
|
|
|
titleBox.add(subtitle);
|
|
|
|
|
|
|
|
headline.add(icon);
|
|
|
|
headline.add(titleBox);
|
|
|
|
|
|
|
|
this.contentLayout.style_class = 'nm-dialog-content';
|
|
|
|
this.contentLayout.add(headline);
|
|
|
|
|
2013-08-12 13:19:32 -04:00
|
|
|
this._stack = new St.Widget({ layout_manager: new Clutter.BinLayout() });
|
|
|
|
|
2013-06-12 00:03:36 -04:00
|
|
|
this._itemBox = new St.BoxLayout({ vertical: true });
|
|
|
|
this._scrollView = new St.ScrollView({ style_class: 'nm-dialog-scroll-view' });
|
2013-08-12 13:19:32 -04:00
|
|
|
this._scrollView.set_x_expand(true);
|
|
|
|
this._scrollView.set_y_expand(true);
|
2013-06-12 00:03:36 -04:00
|
|
|
this._scrollView.set_policy(Gtk.PolicyType.NEVER,
|
|
|
|
Gtk.PolicyType.AUTOMATIC);
|
|
|
|
this._scrollView.add_actor(this._itemBox);
|
2013-08-12 13:19:32 -04:00
|
|
|
this._stack.add_child(this._scrollView);
|
|
|
|
|
2014-01-28 17:18:10 -05:00
|
|
|
this._noNetworksBox = new St.BoxLayout({ vertical: true,
|
|
|
|
style_class: 'no-networks-box',
|
|
|
|
x_align: Clutter.ActorAlign.CENTER,
|
|
|
|
y_align: Clutter.ActorAlign.CENTER });
|
|
|
|
|
2014-09-18 22:24:46 -04:00
|
|
|
let file = Gio.File.new_for_uri('resource:///org/gnome/shell/theme/process-working.svg');
|
2014-09-18 20:04:00 -04:00
|
|
|
this._noNetworksSpinner = new Animation.AnimatedIcon(file, 24, 24);
|
2014-01-28 17:18:10 -05:00
|
|
|
this._noNetworksBox.add_actor(this._noNetworksSpinner.actor);
|
|
|
|
this._noNetworksBox.add_actor(new St.Label({ style_class: 'no-networks-label',
|
|
|
|
text: _("No Networks") }));
|
|
|
|
this._stack.add_child(this._noNetworksBox);
|
|
|
|
|
|
|
|
this._airplaneBox = new St.BoxLayout({ vertical: true,
|
|
|
|
style_class: 'nm-dialog-airplane-box',
|
2013-08-12 13:19:32 -04:00
|
|
|
x_align: Clutter.ActorAlign.CENTER,
|
2014-01-28 17:18:10 -05:00
|
|
|
y_align: Clutter.ActorAlign.CENTER });
|
|
|
|
this._airplaneIcon = new St.Icon({ icon_size: 48 });
|
2015-01-15 19:39:52 -05:00
|
|
|
this._airplaneHeadline = new St.Label({ style_class: 'nm-dialog-airplane-headline headline' });
|
2014-01-28 17:18:10 -05:00
|
|
|
this._airplaneText = new St.Label({ style_class: 'nm-dialog-airplane-text' });
|
|
|
|
|
|
|
|
let airplaneSubStack = new St.Widget({ layout_manager: new Clutter.BinLayout });
|
2015-01-16 09:33:56 -05:00
|
|
|
this._airplaneButton = new St.Button({ style_class: 'modal-dialog-button button' });
|
2014-01-28 17:18:10 -05:00
|
|
|
this._airplaneButton.connect('clicked', Lang.bind(this, function() {
|
|
|
|
if (this._rfkill.airplaneMode)
|
|
|
|
this._rfkill.airplaneMode = false;
|
|
|
|
else
|
|
|
|
this._client.wireless_enabled = true;
|
|
|
|
}));
|
|
|
|
airplaneSubStack.add_actor(this._airplaneButton);
|
|
|
|
this._airplaneInactive = new St.Label({ style_class: 'nm-dialog-airplane-text',
|
|
|
|
text: _("Use hardware switch to turn off") });
|
|
|
|
airplaneSubStack.add_actor(this._airplaneInactive);
|
|
|
|
|
|
|
|
this._airplaneBox.add(this._airplaneIcon, { x_align: St.Align.MIDDLE });
|
|
|
|
this._airplaneBox.add(this._airplaneHeadline, { x_align: St.Align.MIDDLE });
|
|
|
|
this._airplaneBox.add(this._airplaneText, { x_align: St.Align.MIDDLE });
|
|
|
|
this._airplaneBox.add(airplaneSubStack, { x_align: St.Align.MIDDLE });
|
|
|
|
this._stack.add_child(this._airplaneBox);
|
2013-08-12 13:19:32 -04:00
|
|
|
|
|
|
|
this.contentLayout.add(this._stack, { expand: true });
|
2013-06-12 00:03:36 -04:00
|
|
|
|
|
|
|
this._disconnectButton = this.addButton({ action: Lang.bind(this, this.close),
|
|
|
|
label: _("Cancel"),
|
|
|
|
key: Clutter.Escape });
|
|
|
|
this._connectButton = this.addButton({ action: Lang.bind(this, this._connect),
|
|
|
|
label: _("Connect"),
|
|
|
|
key: Clutter.Return },
|
|
|
|
{ expand: true,
|
|
|
|
x_fill: false,
|
|
|
|
x_align: St.Align.END });
|
|
|
|
},
|
|
|
|
|
|
|
|
_connect: function() {
|
|
|
|
let network = this._selectedNetwork;
|
|
|
|
if (network.connections.length > 0) {
|
|
|
|
let connection = network.connections[0];
|
2014-01-23 14:35:10 -05:00
|
|
|
this._client.activate_connection(connection, this._device, null, null);
|
2013-06-12 00:03:36 -04:00
|
|
|
} else {
|
2014-01-23 14:35:10 -05:00
|
|
|
let accessPoints = network.accessPoints;
|
2013-06-12 00:03:36 -04:00
|
|
|
if ((accessPoints[0]._secType == NMAccessPointSecurity.WPA2_ENT)
|
|
|
|
|| (accessPoints[0]._secType == NMAccessPointSecurity.WPA_ENT)) {
|
|
|
|
// 802.1x-enabled APs require further configuration, so they're
|
|
|
|
// handled in gnome-control-center
|
|
|
|
Util.spawn(['gnome-control-center', 'network', 'connect-8021x-wifi',
|
|
|
|
this._device.get_path(), accessPoints[0].dbus_path]);
|
|
|
|
} else {
|
|
|
|
let connection = new NetworkManager.Connection();
|
|
|
|
this._client.add_and_activate_connection(connection, this._device, accessPoints[0].dbus_path, null)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this.close();
|
|
|
|
},
|
|
|
|
|
|
|
|
_notifySsidCb: function(accessPoint) {
|
|
|
|
if (accessPoint.get_ssid() != null) {
|
|
|
|
accessPoint.disconnect(accessPoint._notifySsidId);
|
|
|
|
accessPoint._notifySsidId = 0;
|
|
|
|
this._accessPointAdded(this._device, accessPoint);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_getApSecurityType: function(accessPoint) {
|
|
|
|
if (accessPoint._secType)
|
|
|
|
return accessPoint._secType;
|
|
|
|
|
|
|
|
let flags = accessPoint.flags;
|
|
|
|
let wpa_flags = accessPoint.wpa_flags;
|
|
|
|
let rsn_flags = accessPoint.rsn_flags;
|
|
|
|
let type;
|
|
|
|
if (rsn_flags != NM80211ApSecurityFlags.NONE) {
|
|
|
|
/* RSN check first so that WPA+WPA2 APs are treated as RSN/WPA2 */
|
|
|
|
if (rsn_flags & NM80211ApSecurityFlags.KEY_MGMT_802_1X)
|
|
|
|
type = NMAccessPointSecurity.WPA2_ENT;
|
|
|
|
else if (rsn_flags & NM80211ApSecurityFlags.KEY_MGMT_PSK)
|
|
|
|
type = NMAccessPointSecurity.WPA2_PSK;
|
|
|
|
} else if (wpa_flags != NM80211ApSecurityFlags.NONE) {
|
|
|
|
if (wpa_flags & NM80211ApSecurityFlags.KEY_MGMT_802_1X)
|
|
|
|
type = NMAccessPointSecurity.WPA_ENT;
|
|
|
|
else if (wpa_flags & NM80211ApSecurityFlags.KEY_MGMT_PSK)
|
|
|
|
type = NMAccessPointSecurity.WPA_PSK;
|
|
|
|
} else {
|
|
|
|
if (flags & NM80211ApFlags.PRIVACY)
|
|
|
|
type = NMAccessPointSecurity.WEP;
|
|
|
|
else
|
|
|
|
type = NMAccessPointSecurity.NONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// cache the found value to avoid checking flags all the time
|
|
|
|
accessPoint._secType = type;
|
|
|
|
return type;
|
|
|
|
},
|
|
|
|
|
|
|
|
_networkSortFunction: function(one, two) {
|
|
|
|
let oneHasConnection = one.connections.length != 0;
|
|
|
|
let twoHasConnection = two.connections.length != 0;
|
|
|
|
|
|
|
|
// place known connections first
|
|
|
|
// (-1 = good order, 1 = wrong order)
|
|
|
|
if (oneHasConnection && !twoHasConnection)
|
|
|
|
return -1;
|
|
|
|
else if (!oneHasConnection && twoHasConnection)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
let oneStrength = one.accessPoints[0].strength;
|
|
|
|
let twoStrength = two.accessPoints[0].strength;
|
|
|
|
|
|
|
|
// place stronger connections first
|
|
|
|
if (oneStrength != twoStrength)
|
|
|
|
return oneStrength < twoStrength ? 1 : -1;
|
|
|
|
|
|
|
|
let oneHasSecurity = one.security != NMAccessPointSecurity.NONE;
|
|
|
|
let twoHasSecurity = two.security != NMAccessPointSecurity.NONE;
|
|
|
|
|
|
|
|
// place secure connections first
|
|
|
|
// (we treat WEP/WPA/WPA2 the same as there is no way to
|
|
|
|
// take them apart from the UI)
|
|
|
|
if (oneHasSecurity && !twoHasSecurity)
|
|
|
|
return -1;
|
|
|
|
else if (!oneHasSecurity && twoHasSecurity)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
// sort alphabetically
|
|
|
|
return GLib.utf8_collate(one.ssidText, two.ssidText);
|
|
|
|
},
|
|
|
|
|
|
|
|
_networkCompare: function(network, accessPoint) {
|
|
|
|
if (!ssidCompare(network.ssid, accessPoint.get_ssid()))
|
|
|
|
return false;
|
|
|
|
if (network.mode != accessPoint.mode)
|
|
|
|
return false;
|
|
|
|
if (network.security != this._getApSecurityType(accessPoint))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
|
|
|
|
_findExistingNetwork: function(accessPoint) {
|
|
|
|
for (let i = 0; i < this._networks.length; i++) {
|
|
|
|
let network = this._networks[i];
|
|
|
|
for (let j = 0; j < network.accessPoints.length; j++) {
|
|
|
|
if (network.accessPoints[j] == accessPoint)
|
|
|
|
return { network: i, ap: j };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
|
|
|
|
_findNetwork: function(accessPoint) {
|
|
|
|
if (accessPoint.get_ssid() == null)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
for (let i = 0; i < this._networks.length; i++) {
|
|
|
|
if (this._networkCompare(this._networks[i], accessPoint))
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
},
|
|
|
|
|
|
|
|
_checkConnections: function(network, accessPoint) {
|
|
|
|
this._connections.forEach(function(connection) {
|
|
|
|
if (accessPoint.connection_valid(connection) &&
|
|
|
|
network.connections.indexOf(connection) == -1) {
|
|
|
|
network.connections.push(connection);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
_accessPointAdded: function(device, accessPoint) {
|
|
|
|
if (accessPoint.get_ssid() == null) {
|
|
|
|
// This access point is not visible yet
|
|
|
|
// Wait for it to get a ssid
|
|
|
|
accessPoint._notifySsidId = accessPoint.connect('notify::ssid', Lang.bind(this, this._notifySsidCb));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let pos = this._findNetwork(accessPoint);
|
|
|
|
let network;
|
|
|
|
|
|
|
|
if (pos != -1) {
|
|
|
|
network = this._networks[pos];
|
|
|
|
if (network.accessPoints.indexOf(accessPoint) != -1) {
|
|
|
|
log('Access point was already seen, not adding again');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Util.insertSorted(network.accessPoints, accessPoint, function(one, two) {
|
|
|
|
return two.strength - one.strength;
|
|
|
|
});
|
|
|
|
network.item.updateBestAP(network.accessPoints[0]);
|
|
|
|
this._checkConnections(network, accessPoint);
|
|
|
|
|
|
|
|
this._resortItems();
|
|
|
|
} else {
|
|
|
|
network = { ssid: accessPoint.get_ssid(),
|
|
|
|
mode: accessPoint.mode,
|
|
|
|
security: this._getApSecurityType(accessPoint),
|
|
|
|
connections: [ ],
|
|
|
|
item: null,
|
|
|
|
accessPoints: [ accessPoint ]
|
|
|
|
};
|
|
|
|
network.ssidText = ssidToLabel(network.ssid);
|
|
|
|
this._checkConnections(network, accessPoint);
|
|
|
|
|
|
|
|
let newPos = Util.insertSorted(this._networks, network, this._networkSortFunction);
|
|
|
|
this._createNetworkItem(network);
|
|
|
|
this._itemBox.insert_child_at_index(network.item.actor, newPos);
|
|
|
|
}
|
2013-08-12 13:19:32 -04:00
|
|
|
|
2014-01-28 17:18:10 -05:00
|
|
|
this._syncView();
|
2013-06-12 00:03:36 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
_accessPointRemoved: function(device, accessPoint) {
|
|
|
|
let res = this._findExistingNetwork(accessPoint);
|
|
|
|
|
|
|
|
if (res == null) {
|
|
|
|
log('Removing an access point that was never added');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let network = this._networks[res.network];
|
|
|
|
network.accessPoints.splice(res.ap, 1);
|
|
|
|
|
|
|
|
if (network.accessPoints.length == 0) {
|
2014-01-29 16:29:58 -05:00
|
|
|
network.item.actor.destroy();
|
2013-06-12 00:03:36 -04:00
|
|
|
this._networks.splice(res.network, 1);
|
|
|
|
} else {
|
|
|
|
network.item.updateBestAP(network.accessPoints[0]);
|
|
|
|
this._resortItems();
|
|
|
|
}
|
2013-08-12 13:19:32 -04:00
|
|
|
|
2014-01-28 17:18:10 -05:00
|
|
|
this._syncView();
|
2013-06-12 00:03:36 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
_resortItems: function() {
|
|
|
|
let adjustment = this._scrollView.vscroll.adjustment;
|
|
|
|
let scrollValue = adjustment.value;
|
|
|
|
|
|
|
|
this._itemBox.remove_all_children();
|
|
|
|
this._networks.forEach(Lang.bind(this, function(network) {
|
|
|
|
this._itemBox.add_child(network.item.actor);
|
|
|
|
}));
|
|
|
|
|
|
|
|
adjustment.value = scrollValue;
|
|
|
|
},
|
|
|
|
|
|
|
|
_selectNetwork: function(network) {
|
|
|
|
if (this._selectedNetwork)
|
2013-10-17 13:04:13 -04:00
|
|
|
this._selectedNetwork.item.actor.remove_style_pseudo_class('selected');
|
2013-06-12 00:03:36 -04:00
|
|
|
|
|
|
|
this._selectedNetwork = network;
|
|
|
|
this._updateSensitivity();
|
|
|
|
|
|
|
|
if (this._selectedNetwork)
|
2013-10-17 13:04:13 -04:00
|
|
|
this._selectedNetwork.item.actor.add_style_pseudo_class('selected');
|
2013-06-12 00:03:36 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
_createNetworkItem: function(network) {
|
|
|
|
network.item = new NMWirelessDialogItem(network);
|
2013-08-19 10:31:31 -04:00
|
|
|
network.item.setActive(network == this._selectedNetwork);
|
2013-06-12 00:03:36 -04:00
|
|
|
network.item.connect('selected', Lang.bind(this, function() {
|
|
|
|
Util.ensureActorVisibleInScrollView(this._scrollView, network.item.actor);
|
|
|
|
this._selectNetwork(network);
|
|
|
|
}));
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
const NMDeviceWireless = new Lang.Class({
|
|
|
|
Name: 'NMDeviceWireless',
|
|
|
|
category: NMConnectionCategory.WIRELESS,
|
|
|
|
|
2014-01-28 17:19:48 -05:00
|
|
|
_init: function(client, device, settings) {
|
2013-06-12 00:03:36 -04:00
|
|
|
this._client = client;
|
|
|
|
this._device = device;
|
2014-01-28 17:19:48 -05:00
|
|
|
this._settings = settings;
|
2013-06-12 00:03:36 -04:00
|
|
|
|
|
|
|
this._description = '';
|
|
|
|
|
|
|
|
this.item = new PopupMenu.PopupSubMenuMenuItem('', true);
|
|
|
|
this.item.menu.addAction(_("Select Network"), Lang.bind(this, this._showDialog));
|
|
|
|
|
|
|
|
this._toggleItem = new PopupMenu.PopupMenuItem('');
|
|
|
|
this._toggleItem.connect('activate', Lang.bind(this, this._toggleWifi));
|
|
|
|
this.item.menu.addMenuItem(this._toggleItem);
|
|
|
|
|
2013-10-02 13:39:58 -04:00
|
|
|
this.item.menu.addMenuItem(createSettingsAction(_("Wi-Fi Settings"), device));
|
2013-06-12 00:03:36 -04:00
|
|
|
|
2013-10-08 15:23:30 -04:00
|
|
|
this._wirelessEnabledChangedId = this._client.connect('notify::wireless-enabled', Lang.bind(this, this._sync));
|
|
|
|
this._wirelessHwEnabledChangedId = this._client.connect('notify::wireless-hardware-enabled', Lang.bind(this, this._sync));
|
2013-06-12 00:03:36 -04:00
|
|
|
this._activeApChangedId = this._device.connect('notify::active-access-point', Lang.bind(this, this._activeApChanged));
|
|
|
|
this._stateChangedId = this._device.connect('state-changed', Lang.bind(this, this._deviceStateChanged));
|
2014-03-15 07:40:13 -04:00
|
|
|
this._notifyConnectivityId = this._client.connect('notify::connectivity', Lang.bind(this, this._iconChanged));
|
2013-06-12 00:03:36 -04:00
|
|
|
|
|
|
|
this._sync();
|
|
|
|
},
|
|
|
|
|
2014-03-15 07:40:13 -04:00
|
|
|
_iconChanged: function() {
|
|
|
|
this._sync();
|
|
|
|
this.emit('icon-changed');
|
|
|
|
},
|
|
|
|
|
2013-06-12 00:03:36 -04:00
|
|
|
destroy: function() {
|
|
|
|
if (this._activeApChangedId) {
|
|
|
|
GObject.Object.prototype.disconnect.call(this._device, this._activeApChangedId);
|
|
|
|
this._activeApChangedId = 0;
|
|
|
|
}
|
|
|
|
if (this._stateChangedId) {
|
|
|
|
GObject.Object.prototype.disconnect.call(this._device, this._stateChangedId);
|
|
|
|
this._stateChangedId = 0;
|
|
|
|
}
|
|
|
|
if (this._strengthChangedId > 0) {
|
|
|
|
this._activeAccessPoint.disconnect(this._strengthChangedId);
|
|
|
|
this._strengthChangedId = 0;
|
|
|
|
}
|
2013-10-08 15:23:30 -04:00
|
|
|
if (this._wirelessEnabledChangedId) {
|
|
|
|
this._client.disconnect(this._wirelessEnabledChangedId);
|
|
|
|
this._wirelessEnabledChangedId = 0;
|
|
|
|
}
|
|
|
|
if (this._wirelessHwEnabledChangedId) {
|
|
|
|
this._client.disconnect(this._wirelessHwEnabledChangedId);
|
|
|
|
this._wirelessHwEnabledChangedId = 0;
|
|
|
|
}
|
2014-02-24 11:25:38 -05:00
|
|
|
if (this._dialog) {
|
|
|
|
this._dialog.destroy();
|
|
|
|
this._dialog = null;
|
|
|
|
}
|
2014-03-15 07:40:13 -04:00
|
|
|
if (this._notifyConnectivityId) {
|
|
|
|
this._client.disconnect(this._notifyConnectivityId);
|
|
|
|
this._notifyConnectivityId = 0;
|
|
|
|
}
|
2013-06-12 00:03:36 -04:00
|
|
|
|
|
|
|
this.item.destroy();
|
|
|
|
},
|
|
|
|
|
|
|
|
_deviceStateChanged: function(device, newstate, oldstate, reason) {
|
|
|
|
if (newstate == oldstate) {
|
|
|
|
log('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 == NetworkManager.DeviceState.FAILED &&
|
|
|
|
reason != NetworkManager.DeviceStateReason.NO_SECRETS) {
|
|
|
|
this.emit('activation-failed', reason);
|
|
|
|
}
|
|
|
|
|
|
|
|
this._sync();
|
|
|
|
},
|
|
|
|
|
|
|
|
_toggleWifi: function() {
|
|
|
|
this._client.wireless_enabled = !this._client.wireless_enabled;
|
|
|
|
},
|
|
|
|
|
|
|
|
_showDialog: function() {
|
2014-01-28 17:19:48 -05:00
|
|
|
this._dialog = new NMWirelessDialog(this._client, this._device, this._settings);
|
2013-06-12 00:03:36 -04:00
|
|
|
this._dialog.connect('closed', Lang.bind(this, this._dialogClosed));
|
|
|
|
this._dialog.open();
|
|
|
|
},
|
|
|
|
|
|
|
|
_dialogClosed: function() {
|
|
|
|
this._dialog.destroy();
|
|
|
|
this._dialog = null;
|
|
|
|
},
|
|
|
|
|
|
|
|
_strengthChanged: function() {
|
2014-03-15 07:40:13 -04:00
|
|
|
this._iconChanged();
|
2013-06-12 00:03:36 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
_activeApChanged: function() {
|
|
|
|
if (this._activeAccessPoint) {
|
|
|
|
this._activeAccessPoint.disconnect(this._strengthChangedId);
|
|
|
|
this._strengthChangedId = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._activeAccessPoint = this._device.active_access_point;
|
|
|
|
|
|
|
|
if (this._activeAccessPoint) {
|
|
|
|
this._strengthChangedId = this._activeAccessPoint.connect('notify::strength',
|
|
|
|
Lang.bind(this, this._strengthChanged));
|
|
|
|
}
|
|
|
|
|
|
|
|
this._sync();
|
|
|
|
},
|
|
|
|
|
|
|
|
_sync: function() {
|
|
|
|
this._toggleItem.label.text = this._client.wireless_enabled ? _("Turn Off") : _("Turn On");
|
2013-10-08 15:24:30 -04:00
|
|
|
this._toggleItem.actor.visible = this._client.wireless_hardware_enabled;
|
2013-06-12 00:03:36 -04:00
|
|
|
|
|
|
|
this.item.status.text = this._getStatus();
|
|
|
|
this.item.icon.icon_name = this._getMenuIcon();
|
|
|
|
this.item.label.text = this._description;
|
|
|
|
},
|
|
|
|
|
|
|
|
setDeviceDescription: function(desc) {
|
|
|
|
this._description = desc;
|
|
|
|
this._sync();
|
|
|
|
},
|
|
|
|
|
|
|
|
_getStatus: function() {
|
|
|
|
let ap = this._device.active_access_point;
|
|
|
|
|
2014-02-03 18:04:43 -05:00
|
|
|
if (this._isHotSpotMaster())
|
|
|
|
return _("Hotspot Active");
|
|
|
|
else if (this._device.state >= NetworkManager.DeviceState.PREPARE &&
|
|
|
|
this._device.state < NetworkManager.DeviceState.ACTIVATED)
|
|
|
|
return _("Connecting");
|
|
|
|
else if (ap)
|
2013-10-02 10:48:35 -04:00
|
|
|
return ssidToLabel(ap.get_ssid());
|
|
|
|
else if (!this._client.wireless_hardware_enabled)
|
|
|
|
return _("Hardware Disabled");
|
|
|
|
else if (!this._client.wireless_enabled)
|
|
|
|
return _("Off");
|
|
|
|
else if (this._device.state == NetworkManager.DeviceState.DISCONNECTED)
|
|
|
|
return _("Not Connected");
|
|
|
|
else
|
|
|
|
return '';
|
2013-06-12 00:03:36 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
_getMenuIcon: function() {
|
|
|
|
if (this._device.active_connection)
|
|
|
|
return this.getIndicatorIcon();
|
|
|
|
else
|
|
|
|
return 'network-wireless-signal-none-symbolic';
|
|
|
|
},
|
|
|
|
|
2014-02-03 18:04:43 -05:00
|
|
|
_canReachInternet: function() {
|
|
|
|
if (this._client.primary_connection != this._device.active_connection)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return this._client.connectivity == NetworkManager.ConnectivityState.FULL;
|
|
|
|
},
|
|
|
|
|
|
|
|
_isHotSpotMaster: function() {
|
|
|
|
if (!this._device.active_connection)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
let connection = this._settings.get_connection_by_path(this._device.active_connection.connection);
|
|
|
|
if (!connection)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
let ip4config = connection.get_setting_ip4_config();
|
|
|
|
if (!ip4config)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return ip4config.get_method() == NetworkManager.SETTING_IP4_CONFIG_METHOD_SHARED;
|
|
|
|
},
|
|
|
|
|
2013-06-12 00:03:36 -04:00
|
|
|
getIndicatorIcon: function() {
|
2014-01-29 16:46:37 -05:00
|
|
|
if (this._device.state < NetworkManager.DeviceState.PREPARE)
|
|
|
|
return 'network-wireless-disconnected-symbolic';
|
|
|
|
if (this._device.state < NetworkManager.DeviceState.ACTIVATED)
|
2013-06-12 00:03:36 -04:00
|
|
|
return 'network-wireless-acquiring-symbolic';
|
|
|
|
|
2014-02-03 18:04:43 -05:00
|
|
|
if (this._isHotSpotMaster())
|
|
|
|
return 'network-wireless-hotspot-symbolic';
|
|
|
|
|
2013-06-12 00:03:36 -04:00
|
|
|
let ap = this._device.active_access_point;
|
|
|
|
if (!ap) {
|
|
|
|
if (this._device.mode != NM80211Mode.ADHOC)
|
|
|
|
log('An active wireless connection, in infrastructure mode, involves no access point?');
|
|
|
|
|
2014-02-03 18:04:43 -05:00
|
|
|
if (this._canReachInternet())
|
|
|
|
return 'network-wireless-connected-symbolic';
|
|
|
|
else
|
|
|
|
return 'network-wireless-no-route-symbolic';
|
2013-06-12 00:03:36 -04:00
|
|
|
}
|
|
|
|
|
2014-02-03 18:04:43 -05:00
|
|
|
if (this._canReachInternet())
|
|
|
|
return 'network-wireless-signal-' + signalToIcon(ap.strength) + '-symbolic';
|
|
|
|
else
|
|
|
|
return 'network-wireless-no-route-symbolic';
|
2013-06-12 00:03:36 -04:00
|
|
|
},
|
|
|
|
});
|
|
|
|
Signals.addSignalMethods(NMDeviceWireless.prototype);
|
|
|
|
|
2013-04-26 19:21:02 -04:00
|
|
|
const NMVPNConnectionItem = new Lang.Class({
|
|
|
|
Name: 'NMVPNConnectionItem',
|
2013-06-11 20:13:37 -04:00
|
|
|
Extends: NMConnectionItem,
|
2012-08-29 10:22:24 -04:00
|
|
|
|
2013-04-26 19:21:02 -04:00
|
|
|
isActive: function() {
|
|
|
|
if (this._activeConnection == null)
|
|
|
|
return false;
|
|
|
|
|
2013-08-19 17:49:11 -04:00
|
|
|
return this._activeConnection.vpn_state != NetworkManager.VPNConnectionState.DISCONNECTED;
|
2013-04-26 19:21:02 -04:00
|
|
|
},
|
|
|
|
|
2014-02-08 09:02:05 -05:00
|
|
|
_buildUI: function() {
|
|
|
|
this.labelItem = new PopupMenu.PopupMenuItem('');
|
|
|
|
this.labelItem.connect('activate', Lang.bind(this, this._toggle));
|
|
|
|
|
|
|
|
this.radioItem = new PopupMenu.PopupSwitchMenuItem(this._connection.get_id(), false);
|
|
|
|
this.radioItem.connect('toggled', Lang.bind(this, this._toggle));
|
|
|
|
},
|
|
|
|
|
|
|
|
_sync: function() {
|
|
|
|
let isActive = this.isActive();
|
|
|
|
this.labelItem.label.text = isActive ? _("Turn Off") : this._section.getConnectLabel();
|
|
|
|
this.radioItem.setToggleState(isActive);
|
|
|
|
this.radioItem.setStatus(this._getStatus());
|
|
|
|
this.emit('icon-changed');
|
|
|
|
},
|
|
|
|
|
2013-04-26 19:21:02 -04:00
|
|
|
_getStatus: function() {
|
|
|
|
if (this._activeConnection == null)
|
|
|
|
return null;
|
|
|
|
|
|
|
|
switch(this._activeConnection.vpn_state) {
|
2012-08-29 10:22:24 -04:00
|
|
|
case NetworkManager.VPNConnectionState.DISCONNECTED:
|
|
|
|
case NetworkManager.VPNConnectionState.ACTIVATED:
|
|
|
|
return null;
|
|
|
|
case NetworkManager.VPNConnectionState.PREPARE:
|
|
|
|
case NetworkManager.VPNConnectionState.CONNECT:
|
|
|
|
case NetworkManager.VPNConnectionState.IP_CONFIG_GET:
|
|
|
|
return _("connecting...");
|
|
|
|
case NetworkManager.VPNConnectionState.NEED_AUTH:
|
|
|
|
/* Translators: this is for network connections that require some kind of key or password */
|
|
|
|
return _("authentication required");
|
|
|
|
case NetworkManager.VPNConnectionState.FAILED:
|
|
|
|
return _("connection failed");
|
|
|
|
default:
|
|
|
|
return 'invalid';
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-04-26 19:21:02 -04:00
|
|
|
_connectionStateChanged: function(ac, newstate, reason) {
|
2012-10-02 15:02:59 -04:00
|
|
|
if (newstate == NetworkManager.VPNConnectionState.FAILED &&
|
|
|
|
reason != NetworkManager.VPNConnectionStateReason.NO_SECRETS) {
|
2012-08-29 10:22:24 -04:00
|
|
|
// FIXME: if we ever want to show something based on reason,
|
|
|
|
// we need to convert from NetworkManager.VPNConnectionStateReason
|
|
|
|
// to NetworkManager.DeviceStateReason
|
|
|
|
this.emit('activation-failed', reason);
|
|
|
|
}
|
|
|
|
|
2013-10-01 10:24:01 -04:00
|
|
|
this.emit('icon-changed');
|
2013-06-11 20:13:37 -04:00
|
|
|
this.parent();
|
2013-04-26 19:21:02 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
setActiveConnection: function(activeConnection) {
|
|
|
|
if (this._activeConnectionChangedId > 0) {
|
|
|
|
this._activeConnection.disconnect(this._activeConnectionChangedId);
|
|
|
|
this._activeConnectionChangedId = 0;
|
2012-08-29 10:22:24 -04:00
|
|
|
}
|
2013-04-29 15:20:45 -04:00
|
|
|
|
2013-04-26 19:21:02 -04:00
|
|
|
this._activeConnection = activeConnection;
|
|
|
|
|
|
|
|
if (this._activeConnection)
|
|
|
|
this._activeConnectionChangedId = this._activeConnection.connect('vpn-state-changed',
|
|
|
|
Lang.bind(this, this._connectionStateChanged));
|
|
|
|
|
|
|
|
this._sync();
|
2013-04-29 15:20:45 -04:00
|
|
|
},
|
|
|
|
|
2013-04-26 19:21:02 -04:00
|
|
|
getIndicatorIcon: function() {
|
|
|
|
if (this._activeConnection) {
|
2013-08-19 17:30:06 -04:00
|
|
|
if (this._activeConnection.vpn_state < NetworkManager.VPNConnectionState.ACTIVATED)
|
2013-04-29 15:20:45 -04:00
|
|
|
return 'network-vpn-acquiring-symbolic';
|
|
|
|
else
|
|
|
|
return 'network-vpn-symbolic';
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
},
|
2013-04-26 19:21:02 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
const NMVPNSection = new Lang.Class({
|
|
|
|
Name: 'NMVPNSection',
|
2013-06-11 20:13:37 -04:00
|
|
|
Extends: NMConnectionSection,
|
2013-04-26 19:21:02 -04:00
|
|
|
category: NMConnectionCategory.VPN,
|
|
|
|
|
2013-04-29 15:11:14 -04:00
|
|
|
_init: function(client) {
|
|
|
|
this.parent(client);
|
2014-02-17 09:04:40 -05:00
|
|
|
|
|
|
|
this._vpnSettings = new PopupMenu.PopupMenuItem('');
|
|
|
|
this.item.menu.addMenuItem(this._vpnSettings);
|
|
|
|
this._vpnSettings.connect('activate', Lang.bind(this, this._onSettingsActivate));
|
|
|
|
|
2013-04-29 15:11:14 -04:00
|
|
|
this._sync();
|
|
|
|
},
|
|
|
|
|
|
|
|
_sync: function() {
|
2014-01-14 17:49:47 -05:00
|
|
|
let nItems = this._connectionItems.size;
|
2013-04-29 15:11:14 -04:00
|
|
|
this.item.actor.visible = (nItems > 0);
|
2014-02-17 09:04:40 -05:00
|
|
|
|
|
|
|
if (nItems > 1)
|
|
|
|
this._vpnSettings.label.text = _("Network Settings");
|
|
|
|
else
|
|
|
|
this._vpnSettings.label.text = _("VPN Settings");
|
|
|
|
|
2013-04-29 15:11:14 -04:00
|
|
|
this.parent();
|
|
|
|
},
|
|
|
|
|
2014-02-17 09:04:40 -05:00
|
|
|
_onSettingsActivate: function() {
|
|
|
|
let nItems = this._connectionItems.size;
|
|
|
|
if (nItems > 1) {
|
|
|
|
let appSys = Shell.AppSystem.get_default();
|
|
|
|
let app = appSys.lookup_app('gnome-network-panel.desktop');
|
|
|
|
app.launch(0, -1);
|
|
|
|
} else {
|
|
|
|
let connection = this._connections[0];
|
|
|
|
Util.spawnApp(['gnome-control-center', 'network', 'show-device',
|
|
|
|
connection.get_path()]);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-04-29 15:11:14 -04:00
|
|
|
_getDescription: function() {
|
|
|
|
return _("VPN");
|
|
|
|
},
|
|
|
|
|
2014-03-04 08:02:00 -05:00
|
|
|
_getStatus: function() {
|
|
|
|
let values = this._connectionItems.values();
|
|
|
|
for (let item of values) {
|
|
|
|
if (item.isActive())
|
|
|
|
return item.getName();
|
|
|
|
}
|
|
|
|
|
|
|
|
return _("Off");
|
|
|
|
},
|
|
|
|
|
2013-04-29 15:11:14 -04:00
|
|
|
_getMenuIcon: function() {
|
|
|
|
return this.getIndicatorIcon() || 'network-vpn-symbolic';
|
|
|
|
},
|
|
|
|
|
2013-06-11 20:13:37 -04:00
|
|
|
activateConnection: function(connection) {
|
|
|
|
this._client.activate_connection(connection, null, null, null);
|
2013-04-26 19:21:02 -04:00
|
|
|
},
|
|
|
|
|
2013-06-11 20:13:37 -04:00
|
|
|
deactivateConnection: function(activeConnection) {
|
|
|
|
this._client.deactivate_connection(activeConnection);
|
2013-04-26 19:21:02 -04:00
|
|
|
},
|
|
|
|
|
2013-08-23 16:21:30 -04:00
|
|
|
setActiveConnections: function(vpnConnections) {
|
2014-01-14 17:49:47 -05:00
|
|
|
let connections = this._connectionItems.values();
|
|
|
|
for (let item of connections) {
|
2013-08-23 16:21:30 -04:00
|
|
|
item.setActiveConnection(null);
|
2014-01-14 17:49:47 -05:00
|
|
|
}
|
2013-08-23 16:21:30 -04:00
|
|
|
vpnConnections.forEach(Lang.bind(this, function(a) {
|
|
|
|
let item = this._connectionItems.get(a._connection.get_uuid());
|
|
|
|
item.setActiveConnection(a);
|
|
|
|
}));
|
2013-04-26 19:21:02 -04:00
|
|
|
},
|
2013-04-29 15:20:45 -04:00
|
|
|
|
2013-06-11 20:13:37 -04:00
|
|
|
_makeConnectionItem: function(connection) {
|
|
|
|
return new NMVPNConnectionItem(this, connection);
|
|
|
|
},
|
|
|
|
|
2013-04-29 15:20:45 -04:00
|
|
|
getIndicatorIcon: function() {
|
2013-04-26 19:21:02 -04:00
|
|
|
let items = this._connectionItems.values();
|
2014-01-14 17:49:47 -05:00
|
|
|
for (let item of items) {
|
2013-04-26 19:21:02 -04:00
|
|
|
let icon = item.getIndicatorIcon();
|
2013-04-29 15:20:45 -04:00
|
|
|
if (icon)
|
|
|
|
return icon;
|
|
|
|
}
|
|
|
|
return '';
|
2012-08-29 10:22:24 -04:00
|
|
|
},
|
|
|
|
});
|
2013-04-26 19:21:02 -04:00
|
|
|
Signals.addSignalMethods(NMVPNSection.prototype);
|
2012-08-29 10:22:24 -04:00
|
|
|
|
2011-11-20 09:38:48 -05:00
|
|
|
const NMApplet = new Lang.Class({
|
|
|
|
Name: 'NMApplet',
|
2013-06-06 17:27:25 -04:00
|
|
|
Extends: PanelMenu.SystemIndicator,
|
2011-01-25 16:08:12 -05:00
|
|
|
|
|
|
|
_init: function() {
|
2013-06-06 17:27:25 -04:00
|
|
|
this.parent();
|
2012-06-19 13:50:37 -04:00
|
|
|
|
2013-07-19 06:05:47 -04:00
|
|
|
this._primaryIndicator = this._addIndicator();
|
|
|
|
this._vpnIndicator = this._addIndicator();
|
2011-01-25 16:08:12 -05:00
|
|
|
|
2012-09-03 13:57:53 -04:00
|
|
|
// Device types
|
|
|
|
this._dtypes = { };
|
2014-01-23 14:25:06 -05:00
|
|
|
this._dtypes[NetworkManager.DeviceType.ETHERNET] = NMDeviceWired;
|
2013-06-12 00:03:36 -04:00
|
|
|
this._dtypes[NetworkManager.DeviceType.WIFI] = NMDeviceWireless;
|
2012-09-03 13:57:53 -04:00
|
|
|
this._dtypes[NetworkManager.DeviceType.MODEM] = NMDeviceModem;
|
|
|
|
this._dtypes[NetworkManager.DeviceType.BT] = NMDeviceBluetooth;
|
|
|
|
// TODO: WiMax support
|
|
|
|
|
|
|
|
// Connection types
|
|
|
|
this._ctypes = { };
|
2014-01-23 14:25:06 -05:00
|
|
|
this._ctypes[NetworkManager.SETTING_WIRED_SETTING_NAME] = NMConnectionCategory.WIRED;
|
2012-09-03 13:57:53 -04:00
|
|
|
this._ctypes[NetworkManager.SETTING_WIRELESS_SETTING_NAME] = NMConnectionCategory.WIRELESS;
|
|
|
|
this._ctypes[NetworkManager.SETTING_BLUETOOTH_SETTING_NAME] = NMConnectionCategory.WWAN;
|
|
|
|
this._ctypes[NetworkManager.SETTING_CDMA_SETTING_NAME] = NMConnectionCategory.WWAN;
|
|
|
|
this._ctypes[NetworkManager.SETTING_GSM_SETTING_NAME] = NMConnectionCategory.WWAN;
|
|
|
|
this._ctypes[NetworkManager.SETTING_VPN_SETTING_NAME] = NMConnectionCategory.VPN;
|
|
|
|
|
|
|
|
NMClient.Client.new_async(null, Lang.bind(this, this._clientGot));
|
|
|
|
NMClient.RemoteSettings.new_async(null, null, Lang.bind(this, this._remoteSettingsGot));
|
|
|
|
},
|
|
|
|
|
|
|
|
_clientGot: function(obj, result) {
|
|
|
|
this._client = NMClient.Client.new_finish(result);
|
|
|
|
|
|
|
|
this._tryLateInit();
|
|
|
|
},
|
|
|
|
|
|
|
|
_remoteSettingsGot: function(obj, result) {
|
|
|
|
this._settings = NMClient.RemoteSettings.new_finish(result);
|
|
|
|
|
|
|
|
this._tryLateInit();
|
|
|
|
},
|
|
|
|
|
2014-01-23 14:25:06 -05:00
|
|
|
_createDeviceCategory: function() {
|
|
|
|
let category = {
|
|
|
|
section: new PopupMenu.PopupMenuSection(),
|
|
|
|
devices: [ ],
|
|
|
|
};
|
|
|
|
this.menu.addMenuItem(category.section);
|
|
|
|
return category;
|
|
|
|
},
|
|
|
|
|
2012-09-03 13:57:53 -04:00
|
|
|
_tryLateInit: function() {
|
|
|
|
if (!this._client || !this._settings)
|
|
|
|
return;
|
2011-01-25 16:08:12 -05:00
|
|
|
|
2012-05-18 12:34:07 -04:00
|
|
|
this._activeConnections = [ ];
|
|
|
|
this._connections = [ ];
|
2014-02-17 12:06:35 -05:00
|
|
|
this._connectivityQueue = [ ];
|
2012-05-18 12:34:07 -04:00
|
|
|
|
|
|
|
this._mainConnection = null;
|
2013-04-29 15:20:45 -04:00
|
|
|
this._mainConnectionIconChangedId = 0;
|
2012-05-18 12:34:07 -04:00
|
|
|
|
2013-08-27 14:58:50 -04:00
|
|
|
this._notification = null;
|
|
|
|
|
2012-08-29 13:42:11 -04:00
|
|
|
this._nmDevices = [];
|
2011-01-25 16:08:12 -05:00
|
|
|
this._devices = { };
|
|
|
|
|
2014-01-23 14:25:06 -05:00
|
|
|
this._devices.wired = this._createDeviceCategory();
|
|
|
|
this._devices.wireless = this._createDeviceCategory();
|
|
|
|
this._devices.wwan = this._createDeviceCategory();
|
2011-01-25 16:08:12 -05:00
|
|
|
|
2013-04-29 13:12:14 -04:00
|
|
|
this._vpnSection = new NMVPNSection(this._client);
|
2012-08-29 10:22:24 -04:00
|
|
|
this._vpnSection.connect('activation-failed', Lang.bind(this, this._onActivationFailed));
|
2013-04-29 15:20:45 -04:00
|
|
|
this._vpnSection.connect('icon-changed', Lang.bind(this, this._updateIcon));
|
2013-06-07 13:23:57 -04:00
|
|
|
this.menu.addMenuItem(this._vpnSection.item);
|
2011-01-25 16:08:12 -05:00
|
|
|
|
2012-09-03 13:57:53 -04:00
|
|
|
this._readConnections();
|
|
|
|
this._readDevices();
|
|
|
|
this._syncNMState();
|
|
|
|
|
|
|
|
this._client.connect('notify::manager-running', Lang.bind(this, this._syncNMState));
|
|
|
|
this._client.connect('notify::networking-enabled', Lang.bind(this, this._syncNMState));
|
|
|
|
this._client.connect('notify::state', Lang.bind(this, this._syncNMState));
|
2013-08-31 22:33:03 -04:00
|
|
|
this._client.connect('notify::primary-connection', Lang.bind(this, this._syncMainConnection));
|
2013-09-18 13:18:42 -04:00
|
|
|
this._client.connect('notify::activating-connection', Lang.bind(this, this._syncMainConnection));
|
2013-08-23 16:21:30 -04:00
|
|
|
this._client.connect('notify::active-connections', Lang.bind(this, this._syncVPNConnections));
|
2014-02-17 12:06:35 -05:00
|
|
|
this._client.connect('notify::connectivity', Lang.bind(this, this._syncConnectivity));
|
2012-09-03 13:57:53 -04:00
|
|
|
this._client.connect('device-added', Lang.bind(this, this._deviceAdded));
|
|
|
|
this._client.connect('device-removed', Lang.bind(this, this._deviceRemoved));
|
|
|
|
this._settings.connect('new-connection', Lang.bind(this, this._newConnection));
|
2013-06-12 03:37:50 -04:00
|
|
|
|
|
|
|
Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated));
|
|
|
|
this._sessionUpdated();
|
|
|
|
},
|
|
|
|
|
|
|
|
_sessionUpdated: function() {
|
|
|
|
let sensitive = !Main.sessionMode.isLocked && !Main.sessionMode.isGreeter;
|
2013-06-07 13:23:57 -04:00
|
|
|
this.menu.setSensitive(sensitive);
|
2011-01-25 16:08:12 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_ensureSource: function() {
|
|
|
|
if (!this._source) {
|
2011-10-08 18:00:32 -04:00
|
|
|
this._source = new MessageTray.Source(_("Network Manager"),
|
2012-08-31 17:25:26 -04:00
|
|
|
'network-transmit-receive');
|
2013-10-13 16:01:56 -04:00
|
|
|
this._source.policy = new MessageTray.NotificationApplicationPolicy('gnome-network-panel');
|
2011-10-08 18:00:32 -04:00
|
|
|
|
2011-08-22 12:21:31 -04:00
|
|
|
this._source.connect('destroy', Lang.bind(this, function() {
|
2011-01-25 16:08:12 -05:00
|
|
|
this._source = null;
|
|
|
|
}));
|
|
|
|
Main.messageTray.add(this._source);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_readDevices: function() {
|
|
|
|
let devices = this._client.get_devices() || [ ];
|
|
|
|
for (let i = 0; i < devices.length; ++i) {
|
2012-08-29 13:42:11 -04:00
|
|
|
this._deviceAdded(this._client, devices[i], true);
|
2011-01-25 16:08:12 -05:00
|
|
|
}
|
2012-08-29 13:42:11 -04:00
|
|
|
this._syncDeviceNames();
|
2011-01-25 16:08:12 -05:00
|
|
|
},
|
|
|
|
|
2013-08-27 14:58:50 -04:00
|
|
|
_notify: function(iconName, title, text, urgency) {
|
|
|
|
if (this._notification)
|
|
|
|
this._notification.destroy();
|
2011-08-22 12:21:31 -04:00
|
|
|
|
|
|
|
this._ensureSource();
|
|
|
|
|
2012-09-14 10:33:52 -04:00
|
|
|
let gicon = new Gio.ThemedIcon({ name: iconName });
|
2013-08-27 14:58:50 -04:00
|
|
|
this._notification = new MessageTray.Notification(this._source, title, text, { gicon: gicon });
|
|
|
|
this._notification.setUrgency(urgency);
|
|
|
|
this._notification.setTransient(true);
|
|
|
|
this._notification.connect('destroy', function() {
|
|
|
|
this._notification = null;
|
2011-08-22 12:21:31 -04:00
|
|
|
});
|
2013-08-27 14:58:50 -04:00
|
|
|
this._source.notify(this._notification);
|
2011-08-22 12:21:31 -04:00
|
|
|
},
|
|
|
|
|
2012-08-29 10:22:24 -04:00
|
|
|
_onActivationFailed: function(device, reason) {
|
|
|
|
// XXX: nm-applet has no special text depending on reason
|
|
|
|
// but I'm not sure of this generic message
|
2013-08-27 14:58:50 -04:00
|
|
|
this._notify('network-error-symbolic',
|
|
|
|
_("Connection failed"),
|
|
|
|
_("Activation of network connection failed"),
|
|
|
|
MessageTray.Urgency.HIGH);
|
2012-08-29 10:22:24 -04:00
|
|
|
},
|
|
|
|
|
2012-08-29 13:42:11 -04:00
|
|
|
_syncDeviceNames: function() {
|
2013-04-25 14:00:11 -04:00
|
|
|
let names = NMGtk.utils_disambiguate_device_names(this._nmDevices);
|
|
|
|
for (let i = 0; i < this._nmDevices.length; i++) {
|
|
|
|
let device = this._nmDevices[i];
|
2013-07-17 01:01:44 -04:00
|
|
|
let description = names[i];
|
2013-04-25 14:00:11 -04:00
|
|
|
if (device._delegate)
|
2013-07-17 01:01:44 -04:00
|
|
|
device._delegate.setDeviceDescription(description);
|
2012-08-29 13:42:11 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_deviceAdded: function(client, device, skipSyncDeviceNames) {
|
2011-01-25 16:08:12 -05:00
|
|
|
if (device._delegate) {
|
|
|
|
// already seen, not adding again
|
|
|
|
return;
|
|
|
|
}
|
2012-12-04 08:49:34 -05:00
|
|
|
|
2011-01-25 16:08:12 -05:00
|
|
|
let wrapperClass = this._dtypes[device.get_device_type()];
|
|
|
|
if (wrapperClass) {
|
2013-06-12 00:03:36 -04:00
|
|
|
let wrapper = new wrapperClass(this._client, device, this._settings);
|
2013-06-11 20:13:37 -04:00
|
|
|
device._delegate = wrapper;
|
2012-12-04 08:49:34 -05:00
|
|
|
this._addDeviceWrapper(wrapper);
|
2011-01-25 16:08:12 -05:00
|
|
|
|
2012-08-29 13:42:11 -04:00
|
|
|
this._nmDevices.push(device);
|
|
|
|
if (!skipSyncDeviceNames)
|
|
|
|
this._syncDeviceNames();
|
2013-07-17 01:10:42 -04:00
|
|
|
|
2013-06-12 00:03:36 -04:00
|
|
|
if (wrapper instanceof NMConnectionSection) {
|
|
|
|
this._connections.forEach(function(connection) {
|
|
|
|
wrapper.checkConnection(connection);
|
|
|
|
});
|
|
|
|
}
|
2012-08-21 10:55:40 -04:00
|
|
|
}
|
2011-01-25 16:08:12 -05:00
|
|
|
},
|
|
|
|
|
2012-12-04 08:49:34 -05:00
|
|
|
_addDeviceWrapper: function(wrapper) {
|
|
|
|
wrapper._activationFailedId = wrapper.connect('activation-failed',
|
|
|
|
Lang.bind(this, this._onActivationFailed));
|
|
|
|
|
|
|
|
let section = this._devices[wrapper.category].section;
|
2013-04-29 15:11:14 -04:00
|
|
|
section.addMenuItem(wrapper.item);
|
2012-12-04 08:49:34 -05:00
|
|
|
|
|
|
|
let devices = this._devices[wrapper.category].devices;
|
|
|
|
devices.push(wrapper);
|
|
|
|
},
|
|
|
|
|
2011-01-25 16:08:12 -05:00
|
|
|
_deviceRemoved: function(client, device) {
|
2012-12-04 08:49:34 -05:00
|
|
|
let pos = this._nmDevices.indexOf(device);
|
|
|
|
if (pos != -1) {
|
|
|
|
this._nmDevices.splice(pos, 1);
|
|
|
|
this._syncDeviceNames();
|
|
|
|
}
|
|
|
|
|
|
|
|
let wrapper = device._delegate;
|
|
|
|
if (!wrapper) {
|
2011-01-25 16:08:12 -05:00
|
|
|
log('Removing a network device that was not added');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-06-12 16:05:31 -04:00
|
|
|
this._removeDeviceWrapper(wrapper);
|
2012-12-04 08:49:34 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_removeDeviceWrapper: function(wrapper) {
|
2013-04-26 00:25:14 -04:00
|
|
|
wrapper.disconnect(wrapper._activationFailedId);
|
2011-01-25 16:08:12 -05:00
|
|
|
wrapper.destroy();
|
|
|
|
|
|
|
|
let devices = this._devices[wrapper.category].devices;
|
|
|
|
let pos = devices.indexOf(wrapper);
|
|
|
|
devices.splice(pos, 1);
|
|
|
|
},
|
|
|
|
|
2013-08-23 16:21:30 -04:00
|
|
|
_getMainConnection: function() {
|
|
|
|
let connection;
|
|
|
|
|
2013-08-31 22:33:03 -04:00
|
|
|
connection = this._client.get_primary_connection();
|
2013-08-23 16:21:30 -04:00
|
|
|
if (connection) {
|
2013-10-03 08:20:31 -04:00
|
|
|
ensureActiveConnectionProps(connection, this._settings);
|
2013-08-23 16:21:30 -04:00
|
|
|
return connection;
|
2011-01-25 16:08:12 -05:00
|
|
|
}
|
|
|
|
|
2013-08-23 16:21:30 -04:00
|
|
|
connection = this._client.get_activating_connection();
|
|
|
|
if (connection) {
|
2013-10-03 08:20:31 -04:00
|
|
|
ensureActiveConnectionProps(connection, this._settings);
|
2013-08-23 16:21:30 -04:00
|
|
|
return connection;
|
2011-01-25 16:08:12 -05:00
|
|
|
}
|
|
|
|
|
2013-08-23 16:21:30 -04:00
|
|
|
return null;
|
|
|
|
},
|
|
|
|
|
|
|
|
_syncMainConnection: function() {
|
2013-04-29 15:20:45 -04:00
|
|
|
if (this._mainConnectionIconChangedId > 0) {
|
|
|
|
this._mainConnection._primaryDevice.disconnect(this._mainConnectionIconChangedId);
|
|
|
|
this._mainConnectionIconChangedId = 0;
|
|
|
|
}
|
|
|
|
|
2013-08-23 16:21:30 -04:00
|
|
|
if (this._mainConnectionStateChangedId > 0) {
|
|
|
|
this._mainConnection.disconnect(this._mainConnectionStateChangedId);
|
|
|
|
this._mainConnectionStateChangedId = 0;
|
2011-01-25 16:08:12 -05:00
|
|
|
}
|
|
|
|
|
2013-08-23 16:21:30 -04:00
|
|
|
this._mainConnection = this._getMainConnection();
|
2013-04-29 15:20:45 -04:00
|
|
|
|
|
|
|
if (this._mainConnection) {
|
2013-08-23 16:21:30 -04:00
|
|
|
if (this._mainConnection._primaryDevice)
|
|
|
|
this._mainConnectionIconChangedId = this._mainConnection._primaryDevice.connect('icon-changed', Lang.bind(this, this._updateIcon));
|
|
|
|
this._mainConnectionStateChangedId = this._mainConnection.connect('notify::state', Lang.bind(this, this._mainConnectionStateChanged));
|
|
|
|
this._mainConnectionStateChanged();
|
2013-04-29 15:20:45 -04:00
|
|
|
}
|
2013-08-16 19:32:54 -04:00
|
|
|
|
|
|
|
this._updateIcon();
|
2014-02-17 12:06:35 -05:00
|
|
|
this._syncConnectivity();
|
2011-01-25 16:08:12 -05:00
|
|
|
},
|
|
|
|
|
2013-08-23 16:21:30 -04:00
|
|
|
_syncVPNConnections: function() {
|
|
|
|
let activeConnections = this._client.get_active_connections() || [];
|
|
|
|
let vpnConnections = activeConnections.filter(function(a) {
|
|
|
|
return (a instanceof NMClient.VPNConnection);
|
|
|
|
});
|
|
|
|
vpnConnections.forEach(Lang.bind(this, function(a) {
|
2013-10-12 20:10:22 -04:00
|
|
|
ensureActiveConnectionProps(a, this._settings);
|
2013-08-23 16:21:30 -04:00
|
|
|
}));
|
|
|
|
this._vpnSection.setActiveConnections(vpnConnections);
|
2011-09-04 15:17:33 -04:00
|
|
|
|
2013-08-23 16:21:30 -04:00
|
|
|
this._updateIcon();
|
|
|
|
},
|
|
|
|
|
|
|
|
_mainConnectionStateChanged: function() {
|
2013-08-27 14:58:50 -04:00
|
|
|
if (this._mainConnection.state == NetworkManager.ActiveConnectionState.ACTIVATED && this._notification)
|
|
|
|
this._notification.destroy();
|
2011-09-04 15:17:33 -04:00
|
|
|
},
|
|
|
|
|
2012-08-21 10:55:40 -04:00
|
|
|
_ignoreConnection: function(connection) {
|
|
|
|
let setting = connection.get_setting_connection();
|
|
|
|
if (!setting)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// Ignore slave connections
|
|
|
|
if (setting.get_master())
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
2013-04-25 16:24:14 -04:00
|
|
|
_addConnection: function(connection) {
|
2012-08-21 10:55:40 -04:00
|
|
|
if (this._ignoreConnection(connection))
|
|
|
|
return;
|
2012-05-31 13:13:16 -04:00
|
|
|
if (connection._updatedId) {
|
2011-01-25 16:08:12 -05:00
|
|
|
// connection was already seen
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
connection._removedId = connection.connect('removed', Lang.bind(this, this._connectionRemoved));
|
|
|
|
connection._updatedId = connection.connect('updated', Lang.bind(this, this._updateConnection));
|
|
|
|
|
|
|
|
this._updateConnection(connection);
|
|
|
|
this._connections.push(connection);
|
2013-04-25 16:24:14 -04:00
|
|
|
},
|
2011-01-25 16:08:12 -05:00
|
|
|
|
2013-04-25 16:24:14 -04:00
|
|
|
_readConnections: function() {
|
|
|
|
let connections = this._settings.list_connections();
|
|
|
|
connections.forEach(Lang.bind(this, this._addConnection));
|
|
|
|
},
|
|
|
|
|
|
|
|
_newConnection: function(settings, connection) {
|
|
|
|
this._addConnection(connection);
|
2011-01-25 16:08:12 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_connectionRemoved: function(connection) {
|
|
|
|
let pos = this._connections.indexOf(connection);
|
|
|
|
if (pos != -1)
|
2014-11-16 18:50:14 -05:00
|
|
|
this._connections.splice(pos, 1);
|
2011-01-25 16:08:12 -05:00
|
|
|
|
|
|
|
let section = connection._section;
|
2011-03-26 13:38:20 -04:00
|
|
|
|
2013-05-22 17:35:29 -04:00
|
|
|
if (section == NMConnectionCategory.INVALID)
|
|
|
|
return;
|
2011-01-25 16:08:12 -05:00
|
|
|
|
2013-06-12 16:05:31 -04:00
|
|
|
if (section == NMConnectionCategory.VPN) {
|
2013-05-22 17:35:29 -04:00
|
|
|
this._vpnSection.removeConnection(connection);
|
|
|
|
} else {
|
|
|
|
let devices = this._devices[section].devices;
|
2013-06-12 00:03:36 -04:00
|
|
|
for (let i = 0; i < devices.length; i++) {
|
|
|
|
if (devices[i] instanceof NMConnectionSection)
|
|
|
|
devices[i].removeConnection(connection);
|
|
|
|
}
|
2012-12-04 08:49:34 -05:00
|
|
|
}
|
|
|
|
|
2011-01-25 16:08:12 -05:00
|
|
|
connection.disconnect(connection._removedId);
|
|
|
|
connection.disconnect(connection._updatedId);
|
2012-05-31 13:13:16 -04:00
|
|
|
connection._removedId = connection._updatedId = 0;
|
2011-01-25 16:08:12 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_updateConnection: function(connection) {
|
|
|
|
let connectionSettings = connection.get_setting_by_name(NetworkManager.SETTING_CONNECTION_SETTING_NAME);
|
|
|
|
connection._type = connectionSettings.type;
|
2011-03-26 13:38:20 -04:00
|
|
|
connection._section = this._ctypes[connection._type] || NMConnectionCategory.INVALID;
|
2011-01-25 16:08:12 -05:00
|
|
|
|
|
|
|
let section = connection._section;
|
2011-03-26 13:38:20 -04:00
|
|
|
|
2013-05-22 17:35:29 -04:00
|
|
|
if (section == NMConnectionCategory.INVALID)
|
|
|
|
return;
|
|
|
|
|
2013-06-12 16:05:31 -04:00
|
|
|
if (section == NMConnectionCategory.VPN) {
|
2012-08-29 10:22:24 -04:00
|
|
|
this._vpnSection.checkConnection(connection);
|
2011-01-25 16:08:12 -05:00
|
|
|
} else {
|
|
|
|
let devices = this._devices[section].devices;
|
2013-08-07 06:44:38 -04:00
|
|
|
devices.forEach(function(wrapper) {
|
|
|
|
if (wrapper instanceof NMConnectionSection)
|
|
|
|
wrapper.checkConnection(connection);
|
|
|
|
});
|
2011-01-25 16:08:12 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_syncNMState: function() {
|
2013-06-06 17:27:25 -04:00
|
|
|
this.indicators.visible = this._client.manager_running;
|
2013-06-07 13:23:57 -04:00
|
|
|
this.menu.actor.visible = this._client.networking_enabled;
|
2014-02-17 12:06:35 -05:00
|
|
|
|
|
|
|
this._syncConnectivity();
|
|
|
|
},
|
|
|
|
|
|
|
|
_flushConnectivityQueue: function() {
|
|
|
|
if (this._portalHelperProxy) {
|
|
|
|
for (let item of this._connectivityQueue)
|
|
|
|
this._portalHelperProxy.CloseRemote(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
this._connectivityQueue = [];
|
|
|
|
},
|
|
|
|
|
|
|
|
_closeConnectivityCheck: function(path) {
|
|
|
|
let index = this._connectivityQueue.indexOf(path);
|
|
|
|
|
|
|
|
if (index >= 0) {
|
|
|
|
if (this._portalHelperProxy)
|
|
|
|
this._portalHelperProxy.CloseRemote(path);
|
|
|
|
|
|
|
|
this._connectivityQueue.splice(index, 1);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_portalHelperDone: function(proxy, emitter, parameters) {
|
|
|
|
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,
|
|
|
|
// which will happen once he chooses a better connection
|
|
|
|
// or we get to full connectivity through other means
|
|
|
|
} else if (result == PortalHelperResult.COMPLETED) {
|
|
|
|
this._closeConnectivityCheck(path);
|
|
|
|
return;
|
|
|
|
} else if (result == PortalHelperResult.RECHECK) {
|
|
|
|
this._client.check_connectivity_async(null, Lang.bind(this, function(client, result) {
|
|
|
|
try {
|
|
|
|
let state = client.check_connectivity_finish(result);
|
|
|
|
if (state >= NetworkManager.ConnectivityState.FULL)
|
|
|
|
this._closeConnectivityCheck(path);
|
|
|
|
} catch(e) { }
|
|
|
|
}));
|
|
|
|
} else {
|
|
|
|
log('Invalid result from portal helper: ' + result);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_syncConnectivity: function() {
|
|
|
|
if (this._mainConnection == null ||
|
|
|
|
this._mainConnection.state != NetworkManager.ActiveConnectionState.ACTIVATED) {
|
|
|
|
this._flushConnectivityQueue();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let isPortal = this._client.connectivity == NetworkManager.ConnectivityState.PORTAL;
|
|
|
|
// 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)
|
|
|
|
isPortal = isPortal || this._client.connectivity < NetworkManager.ConnectivityState.FULL;
|
|
|
|
if (!isPortal)
|
|
|
|
return;
|
|
|
|
|
|
|
|
let path = this._mainConnection.get_path();
|
|
|
|
for (let item of this._connectivityQueue) {
|
|
|
|
if (item == path)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let timestamp = global.get_current_time();
|
|
|
|
if (this._portalHelperProxy) {
|
|
|
|
this._portalHelperProxy.AuthenticateRemote(path, '', timestamp);
|
|
|
|
} else {
|
|
|
|
new PortalHelperProxy(Gio.DBus.session, 'org.gnome.Shell.PortalHelper',
|
|
|
|
'/org/gnome/Shell/PortalHelper', Lang.bind(this, function (proxy, error) {
|
|
|
|
if (error) {
|
|
|
|
log('Error launching the portal helper: ' + error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._portalHelperProxy = proxy;
|
|
|
|
proxy.connectSignal('Done', Lang.bind(this, this._portalHelperDone));
|
|
|
|
|
|
|
|
proxy.AuthenticateRemote(path, '', timestamp);
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
|
|
|
this._connectivityQueue.push(path);
|
2011-01-25 16:08:12 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_updateIcon: function() {
|
2013-08-23 16:21:30 -04:00
|
|
|
if (!this._client.networking_enabled || !this._mainConnection) {
|
2014-03-10 14:11:50 -04:00
|
|
|
this._primaryIndicator.visible = false;
|
2011-01-25 16:08:12 -05:00
|
|
|
} else {
|
2013-04-29 15:20:45 -04:00
|
|
|
let dev = this._mainConnection._primaryDevice;
|
2013-08-23 16:21:30 -04:00
|
|
|
this._primaryIndicator.visible = (dev != null);
|
|
|
|
if (dev)
|
|
|
|
this._primaryIndicator.icon_name = dev.getIndicatorIcon();
|
2011-01-25 16:08:12 -05:00
|
|
|
}
|
|
|
|
|
2013-06-06 17:27:25 -04:00
|
|
|
this._vpnIndicator.icon_name = this._vpnSection.getIndicatorIcon();
|
|
|
|
this._vpnIndicator.visible = (this._vpnIndicator.icon_name != '');
|
2011-01-25 16:08:12 -05:00
|
|
|
}
|
2011-11-20 09:38:48 -05:00
|
|
|
});
|