Complete transitioning away from nm-applet
Wireless and 3g dialog code has moved to gnome-control-center, so we can stop calling out to nm-applet. Also, we can now enable the notifications provided by the shell and kill a bit of code about auth that is not actually needed. https://bugzilla.gnome.org/show_bug.cgi?id=650244
This commit is contained in:
parent
2ebdc81c8f
commit
d896248ff8
@ -45,17 +45,6 @@ const NM80211ApSecurityFlags = NetworkManager['80211ApSecurityFlags'];
|
|||||||
// (the remaining are placed into More...)
|
// (the remaining are placed into More...)
|
||||||
const NUM_VISIBLE_NETWORKS = 5;
|
const NUM_VISIBLE_NETWORKS = 5;
|
||||||
|
|
||||||
const NMAppletHelperInterface = {
|
|
||||||
name: 'org.gnome.network_manager_applet',
|
|
||||||
methods: [
|
|
||||||
{ name: 'ConnectToHiddenNetwork', inSignature: '', outSignature: '' },
|
|
||||||
{ name: 'CreateWifiNetwork', inSignature: '', outSignature: '' },
|
|
||||||
{ name: 'ConnectTo8021xNetwork', inSignature: 'oo', outSignature: '' },
|
|
||||||
{ name: 'ConnectTo3gNetwork', inSignature: 'o', outSignature: '' }
|
|
||||||
],
|
|
||||||
};
|
|
||||||
const NMAppletProxy = DBus.makeProxyClass(NMAppletHelperInterface);
|
|
||||||
|
|
||||||
function macToArray(string) {
|
function macToArray(string) {
|
||||||
return string.split(':').map(function(el) {
|
return string.split(':').map(function(el) {
|
||||||
return parseInt(el, 16);
|
return parseInt(el, 16);
|
||||||
@ -635,15 +624,8 @@ NMDevice.prototype = {
|
|||||||
this.emit('network-lost');
|
this.emit('network-lost');
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(newstate) {
|
if (newstate == NetworkManager.DeviceState.FAILED) {
|
||||||
case NetworkManager.DeviceState.NEED_AUTH:
|
|
||||||
// FIXME: make this have a real effect
|
|
||||||
// (currently we rely on a running nm-applet)
|
|
||||||
this.emit('need-auth');
|
|
||||||
break;
|
|
||||||
case NetworkManager.DeviceState.FAILED:
|
|
||||||
this.emit('activation-failed', reason);
|
this.emit('activation-failed', reason);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this._updateStatusItem();
|
this._updateStatusItem();
|
||||||
@ -752,10 +734,6 @@ NMDeviceModem.prototype = {
|
|||||||
this.mobileDevice = null;
|
this.mobileDevice = null;
|
||||||
this._connectionType = 'ppp';
|
this._connectionType = 'ppp';
|
||||||
|
|
||||||
this._applet_proxy = new NMAppletProxy(DBus.session,
|
|
||||||
'org.gnome.network_manager_applet',
|
|
||||||
'/org/gnome/network_manager_applet');
|
|
||||||
|
|
||||||
this._capabilities = device.current_capabilities;
|
this._capabilities = device.current_capabilities;
|
||||||
if (this._capabilities & NetworkManager.DeviceModemCapabilities.GSM_UMTS) {
|
if (this._capabilities & NetworkManager.DeviceModemCapabilities.GSM_UMTS) {
|
||||||
is_wwan = true;
|
is_wwan = true;
|
||||||
@ -857,12 +835,10 @@ NMDeviceModem.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_createAutomaticConnection: function() {
|
_createAutomaticConnection: function() {
|
||||||
// Mobile wizard is handled by nm-applet for now...
|
// Mobile wizard is too complex for the shell UI and
|
||||||
this._applet_proxy.ConnectTo3gNetworkRemote(this.device.get_path(),
|
// is handled by the network panel
|
||||||
Lang.bind(this, function(results, err) {
|
Util.spawn(['gnome-control-center', 'network',
|
||||||
if (err)
|
'connect-3g', this.device.get_path()]);
|
||||||
log(err);
|
|
||||||
}));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -974,10 +950,6 @@ NMDeviceWireless.prototype = {
|
|||||||
this._overflowItem = null;
|
this._overflowItem = null;
|
||||||
this._networks = [ ];
|
this._networks = [ ];
|
||||||
|
|
||||||
this._applet_proxy = new NMAppletProxy(DBus.session,
|
|
||||||
'org.gnome.network_manager_applet',
|
|
||||||
'/org/gnome/network_manager_applet');
|
|
||||||
|
|
||||||
// breaking the layers with this, but cannot call
|
// breaking the layers with this, but cannot call
|
||||||
// this.connectionValid until I have a device
|
// this.connectionValid until I have a device
|
||||||
this.device = device;
|
this.device = device;
|
||||||
@ -1525,13 +1497,10 @@ NMDeviceWireless.prototype = {
|
|||||||
let accessPoints = sortAccessPoints(apObj.accessPoints);
|
let accessPoints = sortAccessPoints(apObj.accessPoints);
|
||||||
if ( (accessPoints[0]._secType == NMAccessPointSecurity.WPA2_ENT)
|
if ( (accessPoints[0]._secType == NMAccessPointSecurity.WPA2_ENT)
|
||||||
|| (accessPoints[0]._secType == NMAccessPointSecurity.WPA_ENT)) {
|
|| (accessPoints[0]._secType == NMAccessPointSecurity.WPA_ENT)) {
|
||||||
// 802.1x-enabled APs get handled by nm-applet for now...
|
// 802.1x-enabled APs require further configuration, so they're
|
||||||
this._applet_proxy.ConnectTo8021xNetworkRemote(this.device.get_path(),
|
// handled in gnome-control-center
|
||||||
accessPoints[0].dbus_path,
|
Util.spawn(['gnome-control-center', 'network', 'connect-8021x-wifi',
|
||||||
Lang.bind(this, function(results, err) {
|
this.device.get_path(), accessPoints[0].dbus_path]);
|
||||||
if (err)
|
|
||||||
log(err);
|
|
||||||
}));
|
|
||||||
} else {
|
} else {
|
||||||
let connection = this._createAutomaticConnection(apObj);
|
let connection = this._createAutomaticConnection(apObj);
|
||||||
this._client.add_and_activate_connection(connection, this.device, accessPoints[0].dbus_path, null)
|
this._client.add_and_activate_connection(connection, this.device, accessPoints[0].dbus_path, null)
|
||||||
@ -1699,8 +1668,7 @@ NMApplet.prototype = {
|
|||||||
_ensureSource: function() {
|
_ensureSource: function() {
|
||||||
if (!this._source) {
|
if (!this._source) {
|
||||||
this._source = new NMMessageTraySource();
|
this._source = new NMMessageTraySource();
|
||||||
this._source._destroyId = this._source.connect('destroy', Lang.bind(this, function() {
|
this._source.connect('destroy', Lang.bind(this, function() {
|
||||||
this._source._destroyId = 0;
|
|
||||||
this._source = null;
|
this._source = null;
|
||||||
}));
|
}));
|
||||||
Main.messageTray.add(this._source);
|
Main.messageTray.add(this._source);
|
||||||
@ -1748,6 +1716,28 @@ NMApplet.prototype = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_notifyForDevice: function(device, iconName, title, text, urgency) {
|
||||||
|
if (device._notification)
|
||||||
|
device._notification.destroy();
|
||||||
|
|
||||||
|
/* must call after destroying previous notification,
|
||||||
|
or this._source will be cleared */
|
||||||
|
this._ensureSource();
|
||||||
|
|
||||||
|
let icon = new St.Icon({ icon_name: iconName,
|
||||||
|
icon_type: St.IconType.SYMBOLIC,
|
||||||
|
icon_size: this._source.ICON_SIZE
|
||||||
|
});
|
||||||
|
device._notification = new MessageTray.Notification(this._source, title, text,
|
||||||
|
{ icon: icon });
|
||||||
|
device._notification.setUrgency(urgency);
|
||||||
|
device._notification.setTransient(true);
|
||||||
|
device._notification.connect('destroy', function() {
|
||||||
|
device._notification = null;
|
||||||
|
});
|
||||||
|
this._source.notify(device._notification);
|
||||||
|
},
|
||||||
|
|
||||||
_deviceAdded: function(client, device) {
|
_deviceAdded: function(client, device) {
|
||||||
if (device._delegate) {
|
if (device._delegate) {
|
||||||
// already seen, not adding again
|
// already seen, not adding again
|
||||||
@ -1757,42 +1747,29 @@ NMApplet.prototype = {
|
|||||||
if (wrapperClass) {
|
if (wrapperClass) {
|
||||||
let wrapper = new wrapperClass(this._client, device, this._connections);
|
let wrapper = new wrapperClass(this._client, device, this._connections);
|
||||||
|
|
||||||
// FIXME: these notifications are duplicate with those exposed by nm-applet
|
wrapper._networkLostId = wrapper.connect('network-lost', Lang.bind(this, function(device) {
|
||||||
// uncomment this code in 3.2, when we'll conflict with and kill nm-applet
|
this._notifyForDevice(device, 'network-offline',
|
||||||
/* wrapper._networkLostId = wrapper.connect('network-lost', Lang.bind(this, function(emitter) {
|
_("Connectivity lost"),
|
||||||
this._ensureSource();
|
_("You're no longer connected to the network"),
|
||||||
let icon = new St.Icon({ icon_name: 'network-offline',
|
// set critical urgency to popup the notification automatically
|
||||||
icon_type: St.IconType.SYMBOLIC,
|
MessageTray.Urgency.CRITICAL);
|
||||||
icon_size: this._source.ICON_SIZE
|
|
||||||
});
|
|
||||||
let notification = new MessageTray.Notification(this._source,
|
|
||||||
_("Connectivity lost"),
|
|
||||||
_("You're no longer connected to the network"),
|
|
||||||
{ icon: icon });
|
|
||||||
this._source.notify(notification);
|
|
||||||
}));
|
}));
|
||||||
wrapper._activationFailedId = wrapper.connect('activation-failed', Lang.bind(this, function(wrapper, reason) {
|
wrapper._activationFailedId = wrapper.connect('activation-failed', Lang.bind(this, function(device, reason) {
|
||||||
this._ensureSource();
|
|
||||||
let icon = new St.Icon({ icon_name: 'network-error',
|
|
||||||
icon_type: St.IconType.SYMBOLIC,
|
|
||||||
icon_size: this._source.ICON_SIZE,
|
|
||||||
});
|
|
||||||
let banner;
|
|
||||||
// XXX: nm-applet has no special text depending on reason
|
// XXX: nm-applet has no special text depending on reason
|
||||||
// but I'm not sure of this generic message
|
// but I'm not sure of this generic message
|
||||||
let notification = new MessageTray.Notification(this._source,
|
this._notifyForDevice(device, 'network-error',
|
||||||
_("Connection failed"),
|
_("Connection failed"),
|
||||||
_("Activation of network connection failed"),
|
_("Activation of network connection failed"),
|
||||||
{ icon: icon });
|
MessageTray.Urgency.HIGH);
|
||||||
this._source.notify(notification);
|
}));
|
||||||
})); */
|
|
||||||
wrapper._deviceStateChangedId = wrapper.connect('state-changed', Lang.bind(this, function(dev) {
|
wrapper._deviceStateChangedId = wrapper.connect('state-changed', Lang.bind(this, function(dev) {
|
||||||
this._syncSectionTitle(dev.category);
|
this._syncSectionTitle(dev.category);
|
||||||
}));
|
}));
|
||||||
wrapper._destroyId = wrapper.connect('destroy', function(wrapper) {
|
wrapper._destroyId = wrapper.connect('destroy', function(wrapper) {
|
||||||
//wrapper.disconnect(wrapper._networkLostId);
|
wrapper.disconnect(wrapper._networkLostId);
|
||||||
//wrapper.disconnect(wrapper._activationFailedId);
|
wrapper.disconnect(wrapper._activationFailedId);
|
||||||
wrapper.disconnect(wrapper._deviceStateChangedId);
|
wrapper.disconnect(wrapper._deviceStateChangedId);
|
||||||
|
wrapper.disconnect(wrapper._destroyId);
|
||||||
});
|
});
|
||||||
let section = this._devices[wrapper.category].section;
|
let section = this._devices[wrapper.category].section;
|
||||||
let devices = this._devices[wrapper.category].devices;
|
let devices = this._devices[wrapper.category].devices;
|
||||||
@ -1837,11 +1814,8 @@ NMApplet.prototype = {
|
|||||||
active._primaryDevice.setActiveConnection(null);
|
active._primaryDevice.setActiveConnection(null);
|
||||||
active._primaryDevice = null;
|
active._primaryDevice = null;
|
||||||
}
|
}
|
||||||
if (active._notifyStateId) {
|
|
||||||
active.disconnect(active._notifyStateId);
|
|
||||||
active._notifyStateId = 0;
|
|
||||||
}
|
|
||||||
if (active._inited) {
|
if (active._inited) {
|
||||||
|
active.disconnect(active._notifyStateId);
|
||||||
active.disconnect(active._notifyDefaultId);
|
active.disconnect(active._notifyDefaultId);
|
||||||
active.disconnect(active._notifyDefault6Id);
|
active.disconnect(active._notifyDefault6Id);
|
||||||
active._inited = false;
|
active._inited = false;
|
||||||
@ -1859,14 +1833,7 @@ NMApplet.prototype = {
|
|||||||
if (!a._inited) {
|
if (!a._inited) {
|
||||||
a._notifyDefaultId = a.connect('notify::default', Lang.bind(this, this._updateIcon));
|
a._notifyDefaultId = a.connect('notify::default', Lang.bind(this, this._updateIcon));
|
||||||
a._notifyDefault6Id = a.connect('notify::default6', Lang.bind(this, this._updateIcon));
|
a._notifyDefault6Id = a.connect('notify::default6', Lang.bind(this, this._updateIcon));
|
||||||
if (a.state == NetworkManager.ActiveConnectionState.ACTIVATING) // prepare to notify to the user
|
a._notifyStateId = a.connect('notify::state', Lang.bind(this, this._updateIcon));
|
||||||
a._notifyStateId = a.connect('notify::state', Lang.bind(this, this._notifyActiveConnection));
|
|
||||||
else {
|
|
||||||
// notify as soon as possible
|
|
||||||
Mainloop.idle_add(Lang.bind(this, function() {
|
|
||||||
this._notifyActiveConnection(a);
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
a._inited = true;
|
a._inited = true;
|
||||||
}
|
}
|
||||||
@ -1916,63 +1883,6 @@ NMApplet.prototype = {
|
|||||||
this._mainConnection = activating || default_ip4 || default_ip6 || this._activeConnections[0] || null;
|
this._mainConnection = activating || default_ip4 || default_ip6 || this._activeConnections[0] || null;
|
||||||
},
|
},
|
||||||
|
|
||||||
_notifyActiveConnection: function(active) {
|
|
||||||
// FIXME: duplicate notifications when nm-applet is running
|
|
||||||
// This code will come back when nm-applet is killed
|
|
||||||
this._syncNMState();
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (active.state == NetworkManager.ActiveConnectionState.ACTIVATED) {
|
|
||||||
|
|
||||||
// notify only connections that are visible
|
|
||||||
if (active._connection) {
|
|
||||||
this._ensureSource();
|
|
||||||
|
|
||||||
let icon;
|
|
||||||
let banner;
|
|
||||||
switch (active._section) {
|
|
||||||
case NMConnectionCategory.WWAN:
|
|
||||||
icon = 'network-cellular-signal-excellent';
|
|
||||||
banner = _("You're now connected to mobile broadband connection '%s'").format(active._connection._name);
|
|
||||||
break;
|
|
||||||
case NMConnectionCategory.WIRELESS:
|
|
||||||
icon = 'network-wireless-signal-excellent';
|
|
||||||
banner = _("You're now connected to wireless network '%s'").format(active._connection._name);
|
|
||||||
break;
|
|
||||||
case NMConnectionCategory.WIRED:
|
|
||||||
icon = 'network-wired';
|
|
||||||
banner = _("You're now connected to wired network '%s'").format(active._connection._name);
|
|
||||||
break;
|
|
||||||
case NMConnectionCategory.VPN:
|
|
||||||
icon = 'network-vpn';
|
|
||||||
banner = _("You're now connected to VPN network '%s'").format(active._connection._name);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
// a fallback for a generic 'connected' icon
|
|
||||||
icon = 'network-transmit-receive';
|
|
||||||
banner = _("You're now connected to '%s'").format(active._connection._name);
|
|
||||||
}
|
|
||||||
|
|
||||||
let iconActor = new St.Icon({ icon_name: icon,
|
|
||||||
icon_type: St.IconType.SYMBOLIC,
|
|
||||||
icon_size: this._source.ICON_SIZE
|
|
||||||
});
|
|
||||||
let notification = new MessageTray.Notification(this._source,
|
|
||||||
_("Connection established"),
|
|
||||||
banner,
|
|
||||||
{ icon: iconActor });
|
|
||||||
this._source.notify(notification);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (active._stateChangeId) {
|
|
||||||
active.disconnect(active._stateChangeId);
|
|
||||||
active._stateChangeId = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this._syncNMState();
|
|
||||||
},
|
|
||||||
|
|
||||||
_readConnections: function() {
|
_readConnections: function() {
|
||||||
let connections = this._settings.list_connections();
|
let connections = this._settings.list_connections();
|
||||||
for (let i = 0; i < connections.length; i++) {
|
for (let i = 0; i < connections.length; i++) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user