network: Reformat connection code

This makes the code flow the same between removeConnection and checkConnection.

https://bugzilla.gnome.org/show_bug.cgi?id=701755
This commit is contained in:
Jasper St. Pierre 2013-05-22 17:35:29 -04:00
parent 380a71dd21
commit aee7cd73c4

View File

@ -1943,19 +1943,20 @@ const NMApplet = new Lang.Class({
let section = connection._section; let section = connection._section;
if (section == NMConnectionCategory.VPN) { if (section == NMConnectionCategory.INVALID)
this._vpnSection.removeConnection(connection); return;
} else if (section != NMConnectionCategory.INVALID) {
let devices = this._devices[section].devices;
for (let i = 0; i < devices.length; i++)
devices[i].removeConnection(connection);
}
if (section == NMConnectionCategory.VIRTUAL) { if (section == NMConnectionCategory.VIRTUAL) {
let iface = connection.get_virtual_iface_name(); let iface = connection.get_virtual_iface_name();
let wrapper = this._findVirtualDevice(iface); let wrapper = this._findVirtualDevice(iface);
if (wrapper && !wrapper.hasConnections()) if (wrapper && !wrapper.hasConnections())
this._removeDeviceWrapper(wrapper); this._removeDeviceWrapper(wrapper);
} else if (section == NMConnectionCategory.VPN) {
this._vpnSection.removeConnection(connection);
} else {
let devices = this._devices[section].devices;
for (let i = 0; i < devices.length; i++)
devices[i].removeConnection(connection);
} }
connection.disconnect(connection._removedId); connection.disconnect(connection._removedId);
@ -1971,6 +1972,9 @@ const NMApplet = new Lang.Class({
let section = connection._section; let section = connection._section;
if (section == NMConnectionCategory.INVALID)
return;
if (section == NMConnectionCategory.VIRTUAL) { if (section == NMConnectionCategory.VIRTUAL) {
let wrapperClass = this._vtypes[connection._type]; let wrapperClass = this._vtypes[connection._type];
if (!wrapperClass) if (!wrapperClass)
@ -1990,11 +1994,7 @@ const NMApplet = new Lang.Class({
break; break;
} }
} }
} } else if (section == NMConnectionCategory.VPN) {
if (section == NMConnectionCategory.INVALID)
return;
if (section == NMConnectionCategory.VPN) {
this._vpnSection.checkConnection(connection); this._vpnSection.checkConnection(connection);
} else { } else {
let devices = this._devices[section].devices; let devices = this._devices[section].devices;