network: port to libnm

The libnm-glib is depreacted for a long time already.

https://bugzilla.gnome.org/show_bug.cgi?id=789811
This commit is contained in:
Lubomir Rintel 2017-10-31 11:38:20 +01:00
parent bc5be10d78
commit d71af5e579
7 changed files with 255 additions and 317 deletions

View File

@ -2,7 +2,7 @@
const Gio = imports.gi.Gio; const Gio = imports.gi.Gio;
const Lang = imports.lang; const Lang = imports.lang;
const NMGtk = imports.gi.NMGtk; const NMA = imports.gi.NMA;
const Signals = imports.signals; const Signals = imports.signals;
// _getMobileProvidersDatabase: // _getMobileProvidersDatabase:
@ -14,7 +14,7 @@ let _mpd;
function _getMobileProvidersDatabase() { function _getMobileProvidersDatabase() {
if (_mpd == null) { if (_mpd == null) {
try { try {
_mpd = new NMGtk.MobileProvidersDatabase(); _mpd = new NMA.MobileProvidersDatabase();
_mpd.init(null); _mpd.init(null);
} catch (e) { } catch (e) {
log(e.message); log(e.message);

View File

@ -5,8 +5,7 @@ const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib; const GLib = imports.gi.GLib;
const GObject = imports.gi.GObject; const GObject = imports.gi.GObject;
const Lang = imports.lang; const Lang = imports.lang;
const NetworkManager = imports.gi.NetworkManager; const NM = imports.gi.NM;
const NMClient = imports.gi.NMClient;
const Pango = imports.gi.Pango; const Pango = imports.gi.Pango;
const Shell = imports.gi.Shell; const Shell = imports.gi.Shell;
const St = imports.gi.St; const St = imports.gi.St;
@ -173,7 +172,7 @@ var NetworkSecretDialog = new Lang.Class({
_validateStaticWep: function(secret) { _validateStaticWep: function(secret) {
let value = secret.value; let value = secret.value;
if (secret.wep_key_type == NetworkManager.WepKeyType.KEY) { if (secret.wep_key_type == NM.WepKeyType.KEY) {
if (value.length == 10 || value.length == 26) { if (value.length == 10 || value.length == 26) {
for (let i = 0; i < value.length; i++) { for (let i = 0; i < value.length; i++) {
if (!((value[i] >= 'a' && value[i] <= 'f') if (!((value[i] >= 'a' && value[i] <= 'f')
@ -189,7 +188,7 @@ var NetworkSecretDialog = new Lang.Class({
} }
} else } else
return false; return false;
} else if (secret.wep_key_type == NetworkManager.WepKeyType.PASSPHRASE) { } else if (secret.wep_key_type == NM.WepKeyType.PASSPHRASE) {
if (value.length < 0 || value.length > 64) if (value.length < 0 || value.length > 64)
return false; return false;
} }
@ -288,7 +287,7 @@ var NetworkSecretDialog = new Lang.Class({
switch (connectionType) { switch (connectionType) {
case '802-11-wireless': case '802-11-wireless':
wirelessSetting = this._connection.get_setting_wireless(); wirelessSetting = this._connection.get_setting_wireless();
ssid = NetworkManager.utils_ssid_to_utf8(wirelessSetting.get_ssid()); ssid = NM.utils_ssid_to_utf8(wirelessSetting.get_ssid().get_data());
content.title = _("Authentication required by wireless network"); content.title = _("Authentication required by wireless network");
content.message = _("Passwords or encryption keys are required to access the wireless network “%s”.").format(ssid); content.message = _("Passwords or encryption keys are required to access the wireless network “%s”.").format(ssid);
this._getWirelessSecrets(content.secrets, wirelessSetting); this._getWirelessSecrets(content.secrets, wirelessSetting);
@ -351,9 +350,9 @@ var VPNRequestHandler = new Lang.Class({
]; ];
if (authHelper.externalUIMode) if (authHelper.externalUIMode)
argv.push('--external-ui-mode'); argv.push('--external-ui-mode');
if (flags & NMClient.SecretAgentGetSecretsFlags.ALLOW_INTERACTION) if (flags & NM.SecretAgentGetSecretsFlags.ALLOW_INTERACTION)
argv.push('-i'); argv.push('-i');
if (flags & NMClient.SecretAgentGetSecretsFlags.REQUEST_NEW) if (flags & NM.SecretAgentGetSecretsFlags.REQUEST_NEW)
argv.push('-r'); argv.push('-r');
if (authHelper.supportsHints) { if (authHelper.supportsHints) {
for (let i = 0; i < hints.length; i++) { for (let i = 0; i < hints.length; i++) {
@ -580,7 +579,7 @@ var NetworkAgent = new Lang.Class({
_init: function() { _init: function() {
this._native = new Shell.NetworkAgent({ identifier: 'org.gnome.Shell.NetworkAgent', this._native = new Shell.NetworkAgent({ identifier: 'org.gnome.Shell.NetworkAgent',
capabilities: NMClient.SecretAgentCapabilities.VPN_HINTS capabilities: NM.SecretAgentCapabilities.VPN_HINTS
}); });
this._dialogs = { }; this._dialogs = { };
@ -597,6 +596,12 @@ var NetworkAgent = new Lang.Class({
this._native.connect('new-request', Lang.bind(this, this._newRequest)); this._native.connect('new-request', Lang.bind(this, this._newRequest));
this._native.connect('cancel-request', Lang.bind(this, this._cancelRequest)); this._native.connect('cancel-request', Lang.bind(this, this._cancelRequest));
try {
this._native.init(null);
} catch(e) {
this._native = null;
logError(e, 'error initializing the NetworkManager Agent');
}
this._enabled = false; this._enabled = false;
}, },
@ -634,7 +639,7 @@ var NetworkAgent = new Lang.Class({
switch (connectionType) { switch (connectionType) {
case '802-11-wireless': case '802-11-wireless':
let wirelessSetting = connection.get_setting_wireless(); let wirelessSetting = connection.get_setting_wireless();
let ssid = NetworkManager.utils_ssid_to_utf8(wirelessSetting.get_ssid()); let ssid = NM.utils_ssid_to_utf8(wirelessSetting.get_ssid());
title = _("Authentication required by wireless network"); title = _("Authentication required by wireless network");
body = _("Passwords or encryption keys are required to access the wireless network “%s”.").format(ssid); body = _("Passwords or encryption keys are required to access the wireless network “%s”.").format(ssid);
break; break;
@ -689,7 +694,7 @@ var NetworkAgent = new Lang.Class({
return; return;
} }
if (!(flags & NMClient.SecretAgentGetSecretsFlags.USER_REQUESTED)) if (!(flags & NM.SecretAgentGetSecretsFlags.USER_REQUESTED))
this._showNotification(requestId, connection, settingName, hints, flags); this._showNotification(requestId, connection, settingName, hints, flags);
else else
this._handleRequest(requestId, connection, settingName, hints, flags); this._handleRequest(requestId, connection, settingName, hints, flags);

View File

@ -6,9 +6,7 @@ const Gio = imports.gi.Gio;
const Gtk = imports.gi.Gtk; const Gtk = imports.gi.Gtk;
const Lang = imports.lang; const Lang = imports.lang;
const Mainloop = imports.mainloop; const Mainloop = imports.mainloop;
const NetworkManager = imports.gi.NetworkManager; const NM = imports.gi.NM;
const NMClient = imports.gi.NMClient;
const NMGtk = imports.gi.NMGtk;
const Signals = imports.signals; const Signals = imports.signals;
const Shell = imports.gi.Shell; const Shell = imports.gi.Shell;
const St = imports.gi.St; const St = imports.gi.St;
@ -43,9 +41,9 @@ const NMAccessPointSecurity = {
var MAX_DEVICE_ITEMS = 4; var MAX_DEVICE_ITEMS = 4;
// small optimization, to avoid using [] all the time // small optimization, to avoid using [] all the time
const NM80211Mode = NetworkManager['80211Mode']; const NM80211Mode = NM['80211Mode'];
const NM80211ApFlags = NetworkManager['80211ApFlags']; const NM80211ApFlags = NM['80211ApFlags'];
const NM80211ApSecurityFlags = NetworkManager['80211ApSecurityFlags']; const NM80211ApSecurityFlags = NM['80211ApSecurityFlags'];
var PortalHelperResult = { var PortalHelperResult = {
CANCELLED: 0, CANCELLED: 0,
@ -74,18 +72,6 @@ const PortalHelperIface = '<node> \
</node>'; </node>';
const PortalHelperProxy = Gio.DBusProxy.makeProxyWrapper(PortalHelperIface); const PortalHelperProxy = Gio.DBusProxy.makeProxyWrapper(PortalHelperIface);
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) { function signalToIcon(value) {
if (value > 80) if (value > 80)
return 'excellent'; return 'excellent';
@ -99,16 +85,14 @@ function signalToIcon(value) {
} }
function ssidToLabel(ssid) { function ssidToLabel(ssid) {
let label = NetworkManager.utils_ssid_to_utf8(ssid); let label = NM.utils_ssid_to_utf8(ssid.get_data());
if (!label) if (!label)
label = _("<unknown>"); label = _("<unknown>");
return label; return label;
} }
function ensureActiveConnectionProps(active, settings) { function ensureActiveConnectionProps(active, client) {
if (!active._connection) { if (!active._primaryDevice) {
active._connection = settings.get_connection_by_path(active.connection);
// This list is guaranteed to have only one device in it. // This list is guaranteed to have only one device in it.
let device = active.get_devices()[0]._delegate; let device = active.get_devices()[0]._delegate;
active._primaryDevice = device; active._primaryDevice = device;
@ -162,7 +146,7 @@ var NMConnectionItem = new Lang.Class({
if (this._activeConnection == null) if (this._activeConnection == null)
return false; return false;
return this._activeConnection.state <= NetworkManager.ActiveConnectionState.ACTIVATED; return this._activeConnection.state <= NM.ActiveConnectionState.ACTIVATED;
}, },
_sync: function() { _sync: function() {
@ -346,10 +330,9 @@ var NMConnectionDevice = new Lang.Class({
Extends: NMConnectionSection, Extends: NMConnectionSection,
Abstract: true, Abstract: true,
_init: function(client, device, settings) { _init: function(client, device) {
this.parent(client); this.parent(client);
this._device = device; this._device = device;
this._settings = settings;
this._description = ''; this._description = '';
this._autoConnectItem = this.item.menu.addAction(_("Connect"), Lang.bind(this, this._autoConnect)); this._autoConnectItem = this.item.menu.addAction(_("Connect"), Lang.bind(this, this._autoConnect));
@ -363,12 +346,12 @@ var NMConnectionDevice = new Lang.Class({
if (this._client.primary_connection != this._device.active_connection) if (this._client.primary_connection != this._device.active_connection)
return true; return true;
return this._client.connectivity == NetworkManager.ConnectivityState.FULL; return this._client.connectivity == NM.ConnectivityState.FULL;
}, },
_autoConnect: function() { _autoConnect: function() {
let connection = new NetworkManager.Connection(); let connection = new NM.SimpleConnection();
this._client.add_and_activate_connection(connection, this._device, null, null); this._client.add_and_activate_connection_async(connection, this._device, null, null, null);
}, },
destroy: function() { destroy: function() {
@ -386,17 +369,12 @@ var NMConnectionDevice = new Lang.Class({
_activeConnectionChanged: function() { _activeConnectionChanged: function() {
if (this._activeConnection) { if (this._activeConnection) {
let item = this._connectionItems.get(this._activeConnection._connection.get_uuid()); let item = this._connectionItems.get(this._activeConnection.connection.get_uuid());
item.setActiveConnection(null); item.setActiveConnection(null);
this._activeConnection = null;
} }
this._activeConnection = this._device.active_connection; this._sync();
if (this._activeConnection) {
ensureActiveConnectionProps(this._activeConnection, this._settings);
let item = this._connectionItems.get(this._activeConnection._connection.get_uuid());
item.setActiveConnection(this._activeConnection);
}
}, },
_deviceStateChanged: function(device, newstate, oldstate, reason) { _deviceStateChanged: function(device, newstate, oldstate, reason) {
@ -408,8 +386,8 @@ var NMConnectionDevice = new Lang.Class({
/* Emit a notification if activation fails, but don't do it /* Emit a notification if activation fails, but don't do it
if the reason is no secrets, as that indicates the user if the reason is no secrets, as that indicates the user
cancelled the agent dialog */ cancelled the agent dialog */
if (newstate == NetworkManager.DeviceState.FAILED && if (newstate == NM.DeviceState.FAILED &&
reason != NetworkManager.DeviceStateReason.NO_SECRETS) { reason != NM.DeviceStateReason.NO_SECRETS) {
this.emit('activation-failed', reason); this.emit('activation-failed', reason);
} }
@ -421,7 +399,7 @@ var NMConnectionDevice = new Lang.Class({
}, },
activateConnection: function(connection) { activateConnection: function(connection) {
this._client.activate_connection(connection, this._device, null, null); this._client.activate_connection_async(connection, this._device, null, null, null);
}, },
deactivateConnection: function(activeConnection) { deactivateConnection: function(activeConnection) {
@ -440,7 +418,18 @@ var NMConnectionDevice = new Lang.Class({
_sync: function() { _sync: function() {
let nItems = this._connectionItems.size; let nItems = this._connectionItems.size;
this._autoConnectItem.actor.visible = (nItems == 0); this._autoConnectItem.actor.visible = (nItems == 0);
this._deactivateItem.actor.visible = this._device.state > NetworkManager.DeviceState.DISCONNECTED; this._deactivateItem.actor.visible = this._device.state > NM.DeviceState.DISCONNECTED;
if (this._activeConnection == null) {
this._activeConnection = this._device.active_connection;
if (this._activeConnection) {
ensureActiveConnectionProps(this._activeConnection, this._client);
let item = this._connectionItems.get(this._activeConnection.connection.get_uuid());
item.setActiveConnection(this._activeConnection);
}
}
this.parent(); this.parent();
}, },
@ -449,31 +438,31 @@ var NMConnectionDevice = new Lang.Class({
return ''; return '';
switch(this._device.state) { switch(this._device.state) {
case NetworkManager.DeviceState.DISCONNECTED: case NM.DeviceState.DISCONNECTED:
/* Translators: %s is a network identifier */ /* Translators: %s is a network identifier */
return _("%s Off").format(this._getDescription()); return _("%s Off").format(this._getDescription());
case NetworkManager.DeviceState.ACTIVATED: case NM.DeviceState.ACTIVATED:
/* Translators: %s is a network identifier */ /* Translators: %s is a network identifier */
return _("%s Connected").format(this._getDescription()); return _("%s Connected").format(this._getDescription());
case NetworkManager.DeviceState.UNMANAGED: case NM.DeviceState.UNMANAGED:
/* Translators: this is for network devices that are physically present but are not /* 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); under NetworkManager's control (and thus cannot be used in the menu);
%s is a network identifier */ %s is a network identifier */
return _("%s Unmanaged").format(this._getDescription()); return _("%s Unmanaged").format(this._getDescription());
case NetworkManager.DeviceState.DEACTIVATING: case NM.DeviceState.DEACTIVATING:
/* Translators: %s is a network identifier */ /* Translators: %s is a network identifier */
return _("%s Disconnecting").format(this._getDescription()); return _("%s Disconnecting").format(this._getDescription());
case NetworkManager.DeviceState.PREPARE: case NM.DeviceState.PREPARE:
case NetworkManager.DeviceState.CONFIG: case NM.DeviceState.CONFIG:
case NetworkManager.DeviceState.IP_CONFIG: case NM.DeviceState.IP_CONFIG:
case NetworkManager.DeviceState.IP_CHECK: case NM.DeviceState.IP_CHECK:
case NetworkManager.DeviceState.SECONDARIES: case NM.DeviceState.SECONDARIES:
/* Translators: %s is a network identifier */ /* Translators: %s is a network identifier */
return _("%s Connecting").format(this._getDescription()); return _("%s Connecting").format(this._getDescription());
case NetworkManager.DeviceState.NEED_AUTH: case NM.DeviceState.NEED_AUTH:
/* Translators: this is for network connections that require some kind of key or password; %s is a network identifier */ /* Translators: this is for network connections that require some kind of key or password; %s is a network identifier */
return _("%s Requires Authentication").format(this._getDescription()); return _("%s Requires Authentication").format(this._getDescription());
case NetworkManager.DeviceState.UNAVAILABLE: case NM.DeviceState.UNAVAILABLE:
// This state is actually a compound of various states (generically unavailable, // This state is actually a compound of various states (generically unavailable,
// firmware missing), that are exposed by different properties (whose state may // firmware missing), that are exposed by different properties (whose state may
// or may not updated when we receive state-changed). // or may not updated when we receive state-changed).
@ -485,7 +474,7 @@ var NMConnectionDevice = new Lang.Class({
/* Translators: this is for a network device that cannot be activated (for example it /* Translators: this is for a network device that cannot be activated (for example it
is disabled by rfkill, or it has no coverage; %s is a network identifier */ is disabled by rfkill, or it has no coverage; %s is a network identifier */
return _("%s Unavailable").format(this._getDescription()); return _("%s Unavailable").format(this._getDescription());
case NetworkManager.DeviceState.FAILED: case NM.DeviceState.FAILED:
/* Translators: %s is a network identifier */ /* Translators: %s is a network identifier */
return _("%s Connection Failed").format(this._getDescription()); return _("%s Connection Failed").format(this._getDescription());
default: default:
@ -500,14 +489,14 @@ var NMDeviceWired = new Lang.Class({
Extends: NMConnectionDevice, Extends: NMConnectionDevice,
category: NMConnectionCategory.WIRED, category: NMConnectionCategory.WIRED,
_init: function(client, device, settings) { _init: function(client, device) {
this.parent(client, device, settings); this.parent(client, device);
this.item.menu.addSettingsAction(_("Wired Settings"), 'gnome-network-panel.desktop'); this.item.menu.addSettingsAction(_("Wired Settings"), 'gnome-network-panel.desktop');
}, },
_hasCarrier: function() { _hasCarrier: function() {
if (this._device instanceof NMClient.DeviceEthernet) if (this._device instanceof NM.DeviceEthernet)
return this._device.carrier; return this._device.carrier;
else else
return true; return true;
@ -522,9 +511,9 @@ var NMDeviceWired = new Lang.Class({
if (this._device.active_connection) { if (this._device.active_connection) {
let state = this._device.active_connection.state; let state = this._device.active_connection.state;
if (state == NetworkManager.ActiveConnectionState.ACTIVATING) { if (state == NM.ActiveConnectionState.ACTIVATING) {
return 'network-wired-acquiring-symbolic'; return 'network-wired-acquiring-symbolic';
} else if (state == NetworkManager.ActiveConnectionState.ACTIVATED) { } else if (state == NM.ActiveConnectionState.ACTIVATED) {
if (this._canReachInternet()) if (this._canReachInternet())
return 'network-wired-symbolic'; return 'network-wired-symbolic';
else else
@ -542,8 +531,8 @@ var NMDeviceModem = new Lang.Class({
Extends: NMConnectionDevice, Extends: NMConnectionDevice,
category: NMConnectionCategory.WWAN, category: NMConnectionCategory.WWAN,
_init: function(client, device, settings) { _init: function(client, device) {
this.parent(client, device, settings); this.parent(client, device);
this.item.menu.addSettingsAction(_("Mobile Broadband Settings"), 'gnome-network-panel.desktop'); this.item.menu.addSettingsAction(_("Mobile Broadband Settings"), 'gnome-network-panel.desktop');
@ -552,11 +541,11 @@ var NMDeviceModem = new Lang.Class({
let capabilities = device.current_capabilities; let capabilities = device.current_capabilities;
if (device.udi.indexOf('/org/freedesktop/ModemManager1/Modem') == 0) if (device.udi.indexOf('/org/freedesktop/ModemManager1/Modem') == 0)
this._mobileDevice = new ModemManager.BroadbandModem(device.udi, capabilities); this._mobileDevice = new ModemManager.BroadbandModem(device.udi, capabilities);
else if (capabilities & NetworkManager.DeviceModemCapabilities.GSM_UMTS) else if (capabilities & NM.DeviceModemCapabilities.GSM_UMTS)
this._mobileDevice = new ModemManager.ModemGsm(device.udi); this._mobileDevice = new ModemManager.ModemGsm(device.udi);
else if (capabilities & NetworkManager.DeviceModemCapabilities.CDMA_EVDO) else if (capabilities & NM.DeviceModemCapabilities.CDMA_EVDO)
this._mobileDevice = new ModemManager.ModemCdma(device.udi); this._mobileDevice = new ModemManager.ModemCdma(device.udi);
else if (capabilities & NetworkManager.DeviceModemCapabilities.LTE) else if (capabilities & NM.DeviceModemCapabilities.LTE)
this._mobileDevice = new ModemManager.ModemGsm(device.udi); this._mobileDevice = new ModemManager.ModemGsm(device.udi);
if (this._mobileDevice) { if (this._mobileDevice) {
@ -593,7 +582,7 @@ var NMDeviceModem = new Lang.Class({
/* Translators: this is for a network device that cannot be activated /* Translators: this is for a network device that cannot be activated
because it's disabled by rfkill (airplane mode); %s is a network identifier */ because it's disabled by rfkill (airplane mode); %s is a network identifier */
return _("%s Disabled").format(this._getDescription()); return _("%s Disabled").format(this._getDescription());
else if (this._device.state == NetworkManager.DeviceState.ACTIVATED && else if (this._device.state == NM.DeviceState.ACTIVATED &&
this._mobileDevice && this._mobileDevice.operator_name) this._mobileDevice && this._mobileDevice.operator_name)
return this._mobileDevice.operator_name; return this._mobileDevice.operator_name;
else else
@ -602,7 +591,7 @@ var NMDeviceModem = new Lang.Class({
getIndicatorIcon: function() { getIndicatorIcon: function() {
if (this._device.active_connection) { if (this._device.active_connection) {
if (this._device.active_connection.state == NetworkManager.ActiveConnectionState.ACTIVATING) if (this._device.active_connection.state == NM.ActiveConnectionState.ACTIVATING)
return 'network-cellular-acquiring-symbolic'; return 'network-cellular-acquiring-symbolic';
return this._getSignalIcon(); return this._getSignalIcon();
@ -621,8 +610,8 @@ var NMDeviceBluetooth = new Lang.Class({
Extends: NMConnectionDevice, Extends: NMConnectionDevice,
category: NMConnectionCategory.WWAN, category: NMConnectionCategory.WWAN,
_init: function(client, device, settings) { _init: function(client, device) {
this.parent(client, device, settings); this.parent(client, device);
this.item.menu.addSettingsAction(_("Bluetooth Settings"), 'gnome-network-panel.desktop'); this.item.menu.addSettingsAction(_("Bluetooth Settings"), 'gnome-network-panel.desktop');
}, },
@ -638,9 +627,9 @@ var NMDeviceBluetooth = new Lang.Class({
getIndicatorIcon: function() { getIndicatorIcon: function() {
if (this._device.active_connection) { if (this._device.active_connection) {
let state = this._device.active_connection.state; let state = this._device.active_connection.state;
if (state == NetworkManager.ActiveConnectionState.ACTIVATING) if (state == NM.ActiveConnectionState.ACTIVATING)
return 'network-cellular-acquiring-symbolic'; return 'network-cellular-acquiring-symbolic';
else if (state == NetworkManager.ActiveConnectionState.ACTIVATED) else if (state == NM.ActiveConnectionState.ACTIVATED)
return 'network-cellular-connected-symbolic'; return 'network-cellular-connected-symbolic';
else else
return 'network-cellular-signal-none-symbolic'; return 'network-cellular-signal-none-symbolic';
@ -719,7 +708,7 @@ var NMWirelessDialog = new Lang.Class({
Name: 'NMWirelessDialog', Name: 'NMWirelessDialog',
Extends: ModalDialog.ModalDialog, Extends: ModalDialog.ModalDialog,
_init: function(client, device, settings) { _init: function(client, device) {
this.parent({ styleClass: 'nm-dialog' }); this.parent({ styleClass: 'nm-dialog' });
this._client = client; this._client = client;
@ -735,7 +724,7 @@ var NMWirelessDialog = new Lang.Class({
this._networks = []; this._networks = [];
this._buildLayout(); this._buildLayout();
let connections = settings.list_connections(); let connections = client.get_connections();
this._connections = connections.filter(Lang.bind(this, function(connection) { this._connections = connections.filter(Lang.bind(this, function(connection) {
return device.connection_valid(connection); return device.connection_valid(connection);
})); }));
@ -799,7 +788,7 @@ var NMWirelessDialog = new Lang.Class({
}, },
_onScanTimeout: function() { _onScanTimeout: function() {
this._device.request_scan_simple(null); this._device.request_scan_async(null, null);
return GLib.SOURCE_CONTINUE; return GLib.SOURCE_CONTINUE;
}, },
@ -944,7 +933,7 @@ var NMWirelessDialog = new Lang.Class({
let network = this._selectedNetwork; let network = this._selectedNetwork;
if (network.connections.length > 0) { if (network.connections.length > 0) {
let connection = network.connections[0]; let connection = network.connections[0];
this._client.activate_connection(connection, this._device, null, null); this._client.activate_connection_async(connection, this._device, null, null, null);
} else { } else {
let accessPoints = network.accessPoints; let accessPoints = network.accessPoints;
if ((accessPoints[0]._secType == NMAccessPointSecurity.WPA2_ENT) if ((accessPoints[0]._secType == NMAccessPointSecurity.WPA2_ENT)
@ -952,10 +941,10 @@ var NMWirelessDialog = new Lang.Class({
// 802.1x-enabled APs require further configuration, so they're // 802.1x-enabled APs require further configuration, so they're
// handled in gnome-control-center // handled in gnome-control-center
Util.spawn(['gnome-control-center', 'wifi', 'connect-8021x-wifi', Util.spawn(['gnome-control-center', 'wifi', 'connect-8021x-wifi',
this._device.get_path(), accessPoints[0].dbus_path]); this._device.get_path(), accessPoints[0].path]);
} else { } else {
let connection = new NetworkManager.Connection(); let connection = new NM.SimpleConnection();
this._client.add_and_activate_connection(connection, this._device, accessPoints[0].dbus_path, null) this._client.add_and_activate_connection_async(connection, this._device, accessPoints[0].path, null, null)
} }
} }
@ -1035,7 +1024,7 @@ var NMWirelessDialog = new Lang.Class({
}, },
_networkCompare: function(network, accessPoint) { _networkCompare: function(network, accessPoint) {
if (!ssidCompare(network.ssid, accessPoint.get_ssid())) if (!network.ssid.equal (accessPoint.get_ssid()))
return false; return false;
if (network.mode != accessPoint.mode) if (network.mode != accessPoint.mode)
return false; return false;
@ -1180,10 +1169,9 @@ var NMDeviceWireless = new Lang.Class({
Name: 'NMDeviceWireless', Name: 'NMDeviceWireless',
category: NMConnectionCategory.WIRELESS, category: NMConnectionCategory.WIRELESS,
_init: function(client, device, settings) { _init: function(client, device) {
this._client = client; this._client = client;
this._device = device; this._device = device;
this._settings = settings;
this._description = ''; this._description = '';
@ -1252,8 +1240,8 @@ var NMDeviceWireless = new Lang.Class({
/* Emit a notification if activation fails, but don't do it /* Emit a notification if activation fails, but don't do it
if the reason is no secrets, as that indicates the user if the reason is no secrets, as that indicates the user
cancelled the agent dialog */ cancelled the agent dialog */
if (newstate == NetworkManager.DeviceState.FAILED && if (newstate == NM.DeviceState.FAILED &&
reason != NetworkManager.DeviceStateReason.NO_SECRETS) { reason != NM.DeviceStateReason.NO_SECRETS) {
this.emit('activation-failed', reason); this.emit('activation-failed', reason);
} }
@ -1265,7 +1253,7 @@ var NMDeviceWireless = new Lang.Class({
}, },
_showDialog: function() { _showDialog: function() {
this._dialog = new NMWirelessDialog(this._client, this._device, this._settings); this._dialog = new NMWirelessDialog(this._client, this._device);
this._dialog.connect('closed', Lang.bind(this, this._dialogClosed)); this._dialog.connect('closed', Lang.bind(this, this._dialogClosed));
this._dialog.open(); this._dialog.open();
}, },
@ -1314,8 +1302,8 @@ var NMDeviceWireless = new Lang.Class({
if (this._isHotSpotMaster()) if (this._isHotSpotMaster())
/* Translators: %s is a network identifier */ /* Translators: %s is a network identifier */
return _("%s Hotspot Active").format(this._description); return _("%s Hotspot Active").format(this._description);
else if (this._device.state >= NetworkManager.DeviceState.PREPARE && else if (this._device.state >= NM.DeviceState.PREPARE &&
this._device.state < NetworkManager.DeviceState.ACTIVATED) this._device.state < NM.DeviceState.ACTIVATED)
/* Translators: %s is a network identifier */ /* Translators: %s is a network identifier */
return _("%s Connecting").format(this._description); return _("%s Connecting").format(this._description);
else if (ap) else if (ap)
@ -1326,7 +1314,7 @@ var NMDeviceWireless = new Lang.Class({
else if (!this._client.wireless_enabled) else if (!this._client.wireless_enabled)
/* Translators: %s is a network identifier */ /* Translators: %s is a network identifier */
return _("%s Off").format(this._description); return _("%s Off").format(this._description);
else if (this._device.state == NetworkManager.DeviceState.DISCONNECTED) else if (this._device.state == NM.DeviceState.DISCONNECTED)
/* Translators: %s is a network identifier */ /* Translators: %s is a network identifier */
return _("%s Not Connected").format(this._description); return _("%s Not Connected").format(this._description);
else else
@ -1344,18 +1332,14 @@ var NMDeviceWireless = new Lang.Class({
if (this._client.primary_connection != this._device.active_connection) if (this._client.primary_connection != this._device.active_connection)
return true; return true;
return this._client.connectivity == NetworkManager.ConnectivityState.FULL; return this._client.connectivity == NM.ConnectivityState.FULL;
}, },
_isHotSpotMaster: function() { _isHotSpotMaster: function() {
if (!this._device.active_connection) if (!this._device.active_connection)
return false; return false;
let connectionPath = this._device.active_connection.connection; let connection = this._device.active_connection.connection;
if (!connectionPath)
return false;
let connection = this._settings.get_connection_by_path(connectionPath);
if (!connection) if (!connection)
return false; return false;
@ -1363,13 +1347,13 @@ var NMDeviceWireless = new Lang.Class({
if (!ip4config) if (!ip4config)
return false; return false;
return ip4config.get_method() == NetworkManager.SETTING_IP4_CONFIG_METHOD_SHARED; return ip4config.get_method() == NM.SETTING_IP4_CONFIG_METHOD_SHARED;
}, },
getIndicatorIcon: function() { getIndicatorIcon: function() {
if (this._device.state < NetworkManager.DeviceState.PREPARE) if (this._device.state < NM.DeviceState.PREPARE)
return 'network-wireless-disconnected-symbolic'; return 'network-wireless-disconnected-symbolic';
if (this._device.state < NetworkManager.DeviceState.ACTIVATED) if (this._device.state < NM.DeviceState.ACTIVATED)
return 'network-wireless-acquiring-symbolic'; return 'network-wireless-acquiring-symbolic';
if (this._isHotSpotMaster()) if (this._isHotSpotMaster())
@ -1394,15 +1378,15 @@ var NMDeviceWireless = new Lang.Class({
}); });
Signals.addSignalMethods(NMDeviceWireless.prototype); Signals.addSignalMethods(NMDeviceWireless.prototype);
var NMVPNConnectionItem = new Lang.Class({ var NMVpnConnectionItem = new Lang.Class({
Name: 'NMVPNConnectionItem', Name: 'NMVpnConnectionItem',
Extends: NMConnectionItem, Extends: NMConnectionItem,
isActive: function() { isActive: function() {
if (this._activeConnection == null) if (this._activeConnection == null)
return false; return false;
return this._activeConnection.vpn_state != NetworkManager.VPNConnectionState.DISCONNECTED; return this._activeConnection.vpn_state != NM.VpnConnectionState.DISCONNECTED;
}, },
_buildUI: function() { _buildUI: function() {
@ -1426,17 +1410,17 @@ var NMVPNConnectionItem = new Lang.Class({
return null; return null;
switch(this._activeConnection.vpn_state) { switch(this._activeConnection.vpn_state) {
case NetworkManager.VPNConnectionState.DISCONNECTED: case NM.VpnConnectionState.DISCONNECTED:
case NetworkManager.VPNConnectionState.ACTIVATED: case NM.VpnConnectionState.ACTIVATED:
return null; return null;
case NetworkManager.VPNConnectionState.PREPARE: case NM.VpnConnectionState.PREPARE:
case NetworkManager.VPNConnectionState.CONNECT: case NM.VpnConnectionState.CONNECT:
case NetworkManager.VPNConnectionState.IP_CONFIG_GET: case NM.VpnConnectionState.IP_CONFIG_GET:
return _("connecting…"); return _("connecting…");
case NetworkManager.VPNConnectionState.NEED_AUTH: case NM.VpnConnectionState.NEED_AUTH:
/* Translators: this is for network connections that require some kind of key or password */ /* Translators: this is for network connections that require some kind of key or password */
return _("authentication required"); return _("authentication required");
case NetworkManager.VPNConnectionState.FAILED: case NM.VpnConnectionState.FAILED:
return _("connection failed"); return _("connection failed");
default: default:
return 'invalid'; return 'invalid';
@ -1444,11 +1428,11 @@ var NMVPNConnectionItem = new Lang.Class({
}, },
_connectionStateChanged: function(ac, newstate, reason) { _connectionStateChanged: function(ac, newstate, reason) {
if (newstate == NetworkManager.VPNConnectionState.FAILED && if (newstate == NM.VpnConnectionState.FAILED &&
reason != NetworkManager.VPNConnectionStateReason.NO_SECRETS) { reason != NM.VpnConnectionStateReason.NO_SECRETS) {
// FIXME: if we ever want to show something based on reason, // FIXME: if we ever want to show something based on reason,
// we need to convert from NetworkManager.VPNConnectionStateReason // we need to convert from NM.VpnConnectionStateReason
// to NetworkManager.DeviceStateReason // to NM.DeviceStateReason
this.emit('activation-failed', reason); this.emit('activation-failed', reason);
} }
@ -1473,7 +1457,7 @@ var NMVPNConnectionItem = new Lang.Class({
getIndicatorIcon: function() { getIndicatorIcon: function() {
if (this._activeConnection) { if (this._activeConnection) {
if (this._activeConnection.vpn_state < NetworkManager.VPNConnectionState.ACTIVATED) if (this._activeConnection.vpn_state < NM.VpnConnectionState.ACTIVATED)
return 'network-vpn-acquiring-symbolic'; return 'network-vpn-acquiring-symbolic';
else else
return 'network-vpn-symbolic'; return 'network-vpn-symbolic';
@ -1483,8 +1467,8 @@ var NMVPNConnectionItem = new Lang.Class({
}, },
}); });
var NMVPNSection = new Lang.Class({ var NMVpnSection = new Lang.Class({
Name: 'NMVPNSection', Name: 'NMVpnSection',
Extends: NMConnectionSection, Extends: NMConnectionSection,
category: NMConnectionCategory.VPN, category: NMConnectionCategory.VPN,
@ -1522,11 +1506,11 @@ var NMVPNSection = new Lang.Class({
}, },
activateConnection: function(connection) { activateConnection: function(connection) {
this._client.activate_connection(connection, null, null, null); this._client.activate_connection_async(connection, null, null, null, null);
}, },
deactivateConnection: function(activeConnection) { deactivateConnection: function(activeConnection) {
this._client.deactivate_connection(activeConnection); this._client.deactivate_connection(activeConnection, null);
}, },
setActiveConnections: function(vpnConnections) { setActiveConnections: function(vpnConnections) {
@ -1535,15 +1519,15 @@ var NMVPNSection = new Lang.Class({
item.setActiveConnection(null); item.setActiveConnection(null);
} }
vpnConnections.forEach(Lang.bind(this, function(a) { vpnConnections.forEach(Lang.bind(this, function(a) {
if (a._connection) { if (a.connection) {
let item = this._connectionItems.get(a._connection.get_uuid()); let item = this._connectionItems.get(a.connection.get_uuid());
item.setActiveConnection(a); item.setActiveConnection(a);
} }
})); }));
}, },
_makeConnectionItem: function(connection) { _makeConnectionItem: function(connection) {
return new NMVPNConnectionItem(this, connection); return new NMVpnConnectionItem(this, connection);
}, },
getIndicatorIcon: function() { getIndicatorIcon: function() {
@ -1556,7 +1540,7 @@ var NMVPNSection = new Lang.Class({
return ''; return '';
}, },
}); });
Signals.addSignalMethods(NMVPNSection.prototype); Signals.addSignalMethods(NMVpnSection.prototype);
var DeviceCategory = new Lang.Class({ var DeviceCategory = new Lang.Class({
Name: 'DeviceCategory', Name: 'DeviceCategory',
@ -1637,40 +1621,25 @@ var NMApplet = new Lang.Class({
// Device types // Device types
this._dtypes = { }; this._dtypes = { };
this._dtypes[NetworkManager.DeviceType.ETHERNET] = NMDeviceWired; this._dtypes[NM.DeviceType.ETHERNET] = NMDeviceWired;
this._dtypes[NetworkManager.DeviceType.WIFI] = NMDeviceWireless; this._dtypes[NM.DeviceType.WIFI] = NMDeviceWireless;
this._dtypes[NetworkManager.DeviceType.MODEM] = NMDeviceModem; this._dtypes[NM.DeviceType.MODEM] = NMDeviceModem;
this._dtypes[NetworkManager.DeviceType.BT] = NMDeviceBluetooth; this._dtypes[NM.DeviceType.BT] = NMDeviceBluetooth;
// TODO: WiMax support
// Connection types // Connection types
this._ctypes = { }; this._ctypes = { };
this._ctypes[NetworkManager.SETTING_WIRED_SETTING_NAME] = NMConnectionCategory.WIRED; this._ctypes[NM.SETTING_WIRED_SETTING_NAME] = NMConnectionCategory.WIRED;
this._ctypes[NetworkManager.SETTING_WIRELESS_SETTING_NAME] = NMConnectionCategory.WIRELESS; this._ctypes[NM.SETTING_WIRELESS_SETTING_NAME] = NMConnectionCategory.WIRELESS;
this._ctypes[NetworkManager.SETTING_BLUETOOTH_SETTING_NAME] = NMConnectionCategory.WWAN; this._ctypes[NM.SETTING_BLUETOOTH_SETTING_NAME] = NMConnectionCategory.WWAN;
this._ctypes[NetworkManager.SETTING_CDMA_SETTING_NAME] = NMConnectionCategory.WWAN; this._ctypes[NM.SETTING_CDMA_SETTING_NAME] = NMConnectionCategory.WWAN;
this._ctypes[NetworkManager.SETTING_GSM_SETTING_NAME] = NMConnectionCategory.WWAN; this._ctypes[NM.SETTING_GSM_SETTING_NAME] = NMConnectionCategory.WWAN;
this._ctypes[NetworkManager.SETTING_VPN_SETTING_NAME] = NMConnectionCategory.VPN; this._ctypes[NM.SETTING_VPN_SETTING_NAME] = NMConnectionCategory.VPN;
NMClient.Client.new_async(null, Lang.bind(this, this._clientGot)); NM.Client.new_async(null, Lang.bind(this, this._clientGot));
NMClient.RemoteSettings.new_async(null, null, Lang.bind(this, this._remoteSettingsGot));
}, },
_clientGot: function(obj, result) { _clientGot: function(obj, result) {
this._client = NMClient.Client.new_finish(result); this._client = NM.Client.new_finish(result);
this._tryLateInit();
},
_remoteSettingsGot: function(obj, result) {
this._settings = NMClient.RemoteSettings.new_finish(result);
this._tryLateInit();
},
_tryLateInit: function() {
if (!this._client || !this._settings)
return;
this._activeConnections = [ ]; this._activeConnections = [ ];
this._connections = [ ]; this._connections = [ ];
@ -1693,7 +1662,7 @@ var NMApplet = new Lang.Class({
this.menu.addMenuItem(this._devices[category]); this.menu.addMenuItem(this._devices[category]);
} }
this._vpnSection = new NMVPNSection(this._client); this._vpnSection = new NMVpnSection(this._client);
this._vpnSection.connect('activation-failed', Lang.bind(this, this._onActivationFailed)); this._vpnSection.connect('activation-failed', Lang.bind(this, this._onActivationFailed));
this._vpnSection.connect('icon-changed', Lang.bind(this, this._updateIcon)); this._vpnSection.connect('icon-changed', Lang.bind(this, this._updateIcon));
this.menu.addMenuItem(this._vpnSection.item); this.menu.addMenuItem(this._vpnSection.item);
@ -1702,18 +1671,19 @@ var NMApplet = new Lang.Class({
this._readDevices(); this._readDevices();
this._syncNMState(); this._syncNMState();
this._syncMainConnection(); this._syncMainConnection();
this._syncVPNConnections(); this._syncVpnConnections();
this._client.connect('notify::manager-running', Lang.bind(this, this._syncNMState)); this._client.connect('notify::nm-running', Lang.bind(this, this._syncNMState));
this._client.connect('notify::networking-enabled', 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)); this._client.connect('notify::state', Lang.bind(this, this._syncNMState));
this._client.connect('notify::primary-connection', Lang.bind(this, this._syncMainConnection)); this._client.connect('notify::primary-connection', Lang.bind(this, this._syncMainConnection));
this._client.connect('notify::activating-connection', Lang.bind(this, this._syncMainConnection)); this._client.connect('notify::activating-connection', Lang.bind(this, this._syncMainConnection));
this._client.connect('notify::active-connections', Lang.bind(this, this._syncVPNConnections)); this._client.connect('notify::active-connections', Lang.bind(this, this._syncVpnConnections));
this._client.connect('notify::connectivity', Lang.bind(this, this._syncConnectivity)); this._client.connect('notify::connectivity', Lang.bind(this, this._syncConnectivity));
this._client.connect('device-added', Lang.bind(this, this._deviceAdded)); this._client.connect('device-added', Lang.bind(this, this._deviceAdded));
this._client.connect('device-removed', Lang.bind(this, this._deviceRemoved)); this._client.connect('device-removed', Lang.bind(this, this._deviceRemoved));
this._settings.connect('new-connection', Lang.bind(this, this._newConnection)); this._client.connect('connection-added', Lang.bind(this, this._connectionAdded));
this._client.connect('connection-removed', Lang.bind(this, this._connectionRemoved));
Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated)); Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated));
this._sessionUpdated(); this._sessionUpdated();
@ -1771,7 +1741,7 @@ var NMApplet = new Lang.Class({
}, },
_syncDeviceNames: function() { _syncDeviceNames: function() {
let names = NMGtk.utils_disambiguate_device_names(this._nmDevices); let names = NM.Device.disambiguate_names(this._nmDevices);
for (let i = 0; i < this._nmDevices.length; i++) { for (let i = 0; i < this._nmDevices.length; i++) {
let device = this._nmDevices[i]; let device = this._nmDevices[i];
let description = names[i]; let description = names[i];
@ -1788,7 +1758,7 @@ var NMApplet = new Lang.Class({
let wrapperClass = this._dtypes[device.get_device_type()]; let wrapperClass = this._dtypes[device.get_device_type()];
if (wrapperClass) { if (wrapperClass) {
let wrapper = new wrapperClass(this._client, device, this._settings); let wrapper = new wrapperClass(this._client, device);
device._delegate = wrapper; device._delegate = wrapper;
this._addDeviceWrapper(wrapper); this._addDeviceWrapper(wrapper);
@ -1845,13 +1815,13 @@ var NMApplet = new Lang.Class({
connection = this._client.get_primary_connection(); connection = this._client.get_primary_connection();
if (connection) { if (connection) {
ensureActiveConnectionProps(connection, this._settings); ensureActiveConnectionProps(connection, this._client);
return connection; return connection;
} }
connection = this._client.get_activating_connection(); connection = this._client.get_activating_connection();
if (connection) { if (connection) {
ensureActiveConnectionProps(connection, this._settings); ensureActiveConnectionProps(connection, this._client);
return connection; return connection;
} }
@ -1882,13 +1852,13 @@ var NMApplet = new Lang.Class({
this._syncConnectivity(); this._syncConnectivity();
}, },
_syncVPNConnections: function() { _syncVpnConnections: function() {
let activeConnections = this._client.get_active_connections() || []; let activeConnections = this._client.get_active_connections() || [];
let vpnConnections = activeConnections.filter(function(a) { let vpnConnections = activeConnections.filter(function(a) {
return (a instanceof NMClient.VPNConnection); return (a instanceof NM.VpnConnection);
}); });
vpnConnections.forEach(Lang.bind(this, function(a) { vpnConnections.forEach(Lang.bind(this, function(a) {
ensureActiveConnectionProps(a, this._settings); ensureActiveConnectionProps(a, this._client);
})); }));
this._vpnSection.setActiveConnections(vpnConnections); this._vpnSection.setActiveConnections(vpnConnections);
@ -1896,7 +1866,7 @@ var NMApplet = new Lang.Class({
}, },
_mainConnectionStateChanged: function() { _mainConnectionStateChanged: function() {
if (this._mainConnection.state == NetworkManager.ActiveConnectionState.ACTIVATED && this._notification) if (this._mainConnection.state == NM.ActiveConnectionState.ACTIVATED && this._notification)
this._notification.destroy(); this._notification.destroy();
}, },
@ -1920,23 +1890,22 @@ var NMApplet = new Lang.Class({
return; return;
} }
connection._removedId = connection.connect('removed', Lang.bind(this, this._connectionRemoved)); connection._updatedId = connection.connect('changed', Lang.bind(this, this._updateConnection));
connection._updatedId = connection.connect('updated', Lang.bind(this, this._updateConnection));
this._updateConnection(connection); this._updateConnection(connection);
this._connections.push(connection); this._connections.push(connection);
}, },
_readConnections: function() { _readConnections: function() {
let connections = this._settings.list_connections(); let connections = this._client.get_connections();
connections.forEach(Lang.bind(this, this._addConnection)); connections.forEach(Lang.bind(this, this._addConnection));
}, },
_newConnection: function(settings, connection) { _connectionAdded: function(client, connection) {
this._addConnection(connection); this._addConnection(connection);
}, },
_connectionRemoved: function(connection) { _connectionRemoved: function(client, connection) {
let pos = this._connections.indexOf(connection); let pos = this._connections.indexOf(connection);
if (pos != -1) if (pos != -1)
this._connections.splice(pos, 1); this._connections.splice(pos, 1);
@ -1956,13 +1925,12 @@ var NMApplet = new Lang.Class({
} }
} }
connection.disconnect(connection._removedId);
connection.disconnect(connection._updatedId); connection.disconnect(connection._updatedId);
connection._removedId = connection._updatedId = 0; connection._updatedId = 0;
}, },
_updateConnection: function(connection) { _updateConnection: function(connection) {
let connectionSettings = connection.get_setting_by_name(NetworkManager.SETTING_CONNECTION_SETTING_NAME); let connectionSettings = connection.get_setting_by_name(NM.SETTING_CONNECTION_SETTING_NAME);
connection._type = connectionSettings.type; connection._type = connectionSettings.type;
connection._section = this._ctypes[connection._type] || NMConnectionCategory.INVALID; connection._section = this._ctypes[connection._type] || NMConnectionCategory.INVALID;
@ -1983,7 +1951,7 @@ var NMApplet = new Lang.Class({
}, },
_syncNMState: function() { _syncNMState: function() {
this.indicators.visible = this._client.manager_running; this.indicators.visible = this._client.nm_running;
this.menu.actor.visible = this._client.networking_enabled; this.menu.actor.visible = this._client.networking_enabled;
this._syncConnectivity(); this._syncConnectivity();
@ -2024,7 +1992,7 @@ var NMApplet = new Lang.Class({
this._client.check_connectivity_async(null, Lang.bind(this, function(client, result) { this._client.check_connectivity_async(null, Lang.bind(this, function(client, result) {
try { try {
let state = client.check_connectivity_finish(result); let state = client.check_connectivity_finish(result);
if (state >= NetworkManager.ConnectivityState.FULL) if (state >= NM.ConnectivityState.FULL)
this._closeConnectivityCheck(path); this._closeConnectivityCheck(path);
} catch(e) { } } catch(e) { }
})); }));
@ -2035,19 +2003,19 @@ var NMApplet = new Lang.Class({
_syncConnectivity: function() { _syncConnectivity: function() {
if (this._mainConnection == null || if (this._mainConnection == null ||
this._mainConnection.state != NetworkManager.ActiveConnectionState.ACTIVATED) { this._mainConnection.state != NM.ActiveConnectionState.ACTIVATED) {
this._flushConnectivityQueue(); this._flushConnectivityQueue();
return; return;
} }
let isPortal = this._client.connectivity == NetworkManager.ConnectivityState.PORTAL; let isPortal = this._client.connectivity == NM.ConnectivityState.PORTAL;
// For testing, allow interpreting any value != FULL as PORTAL, because // For testing, allow interpreting any value != FULL as PORTAL, because
// LIMITED (no upstream route after the default gateway) is easy to obtain // LIMITED (no upstream route after the default gateway) is easy to obtain
// with a tethered phone // with a tethered phone
// NONE is also possible, with a connection configured to force no default route // 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) // (but in general we should only prompt a portal if we know there is a portal)
if (GLib.getenv('GNOME_SHELL_CONNECTIVITY_TEST') != null) if (GLib.getenv('GNOME_SHELL_CONNECTIVITY_TEST') != null)
isPortal = isPortal || this._client.connectivity < NetworkManager.ConnectivityState.FULL; isPortal = isPortal || this._client.connectivity < NM.ConnectivityState.FULL;
if (!isPortal || Main.sessionMode.isGreeter) if (!isPortal || Main.sessionMode.isGreeter)
return; return;
@ -2087,12 +2055,12 @@ var NMApplet = new Lang.Class({
dev = this._mainConnection._primaryDevice; dev = this._mainConnection._primaryDevice;
let state = this._client.get_state(); let state = this._client.get_state();
let connected = state == NetworkManager.State.CONNECTED_GLOBAL; let connected = state == NM.State.CONNECTED_GLOBAL;
this._primaryIndicator.visible = (dev != null) || connected; this._primaryIndicator.visible = (dev != null) || connected;
if (dev) { if (dev) {
this._primaryIndicator.icon_name = dev.getIndicatorIcon(); this._primaryIndicator.icon_name = dev.getIndicatorIcon();
} else if (connected) { } else if (connected) {
if (this._client.connectivity == NetworkManager.ConnectivityState.FULL) if (this._client.connectivity == NM.ConnectivityState.FULL)
this._primaryIndicator.icon_name = 'network-wired-symbolic'; this._primaryIndicator.icon_name = 'network-wired-symbolic';
else else
this._primaryIndicator.icon_name = 'network-wired-no-route-symbolic'; this._primaryIndicator.icon_name = 'network-wired-no-route-symbolic';

View File

@ -102,9 +102,7 @@ endif
nm_deps = [] nm_deps = []
if get_option('networkmanager') if get_option('networkmanager')
nm_deps += dependency('libnm-glib', version: nm_req) nm_deps += dependency('libnm', version: nm_req)
nm_deps += dependency('libnm-util', version: nm_req)
nm_deps += dependency('libnm-gtk', version: nm_req)
nm_deps += dependency('libsecret-1', version: secret_req) nm_deps += dependency('libsecret-1', version: secret_req)
have_networkmanager = true have_networkmanager = true

View File

@ -226,7 +226,7 @@ libshell_gir_includes = [
] ]
if have_networkmanager if have_networkmanager
libshell_gir_includes += ['NetworkManager-1.0', 'NMClient-1.0'] libshell_gir_includes += ['NM-1.0']
endif endif
libshell_gir_includes += [ libshell_gir_includes += [

View File

@ -2,6 +2,7 @@
/* /*
* Copyright 2011 Red Hat, Inc. * Copyright 2011 Red Hat, Inc.
* 2011 Giovanni Campagna <scampa.giovanni@gmail.com> * 2011 Giovanni Campagna <scampa.giovanni@gmail.com>
* 2017 Lubomir Rintel <lkundrak@v3.sk>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -21,7 +22,6 @@
#include "config.h" #include "config.h"
#include <string.h> #include <string.h>
#include <dbus/dbus-glib.h>
#include <libsecret/secret.h> #include <libsecret/secret.h>
@ -44,13 +44,10 @@ typedef struct {
gchar *setting_name; gchar *setting_name;
gchar **hints; gchar **hints;
NMSecretAgentGetSecretsFlags flags; NMSecretAgentGetSecretsFlags flags;
NMSecretAgentGetSecretsFunc callback; NMSecretAgentOldGetSecretsFunc callback;
gpointer callback_data; gpointer callback_data;
/* <gchar *setting_key, gchar *secret> */ GVariantDict *entries;
GHashTable *entries;
GHashTable *vpn_entries;
gboolean is_vpn;
} ShellAgentRequest; } ShellAgentRequest;
struct _ShellNetworkAgentPrivate { struct _ShellNetworkAgentPrivate {
@ -58,7 +55,7 @@ struct _ShellNetworkAgentPrivate {
GHashTable *requests; GHashTable *requests;
}; };
G_DEFINE_TYPE_WITH_PRIVATE (ShellNetworkAgent, shell_network_agent, NM_TYPE_SECRET_AGENT) G_DEFINE_TYPE_WITH_PRIVATE (ShellNetworkAgent, shell_network_agent, NM_TYPE_SECRET_AGENT_OLD)
static const SecretSchema network_agent_schema = { static const SecretSchema network_agent_schema = {
"org.freedesktop.NetworkManager.Connection", "org.freedesktop.NetworkManager.Connection",
@ -82,7 +79,7 @@ shell_agent_request_free (gpointer data)
g_object_unref (request->connection); g_object_unref (request->connection);
g_free (request->setting_name); g_free (request->setting_name);
g_strfreev (request->hints); g_strfreev (request->hints);
g_hash_table_destroy (request->entries); g_clear_pointer (&request->entries, g_variant_dict_unref);
g_slice_free (ShellAgentRequest, request); g_slice_free (ShellAgentRequest, request);
} }
@ -98,7 +95,7 @@ shell_agent_request_cancel (ShellAgentRequest *request)
error = g_error_new (NM_SECRET_AGENT_ERROR, error = g_error_new (NM_SECRET_AGENT_ERROR,
NM_SECRET_AGENT_ERROR_AGENT_CANCELED, NM_SECRET_AGENT_ERROR_AGENT_CANCELED,
"Canceled by NetworkManager"); "Canceled by NetworkManager");
request->callback (NM_SECRET_AGENT (self), request->connection, request->callback (NM_SECRET_AGENT_OLD (self), request->connection,
NULL, error, request->callback_data); NULL, error, request->callback_data);
g_signal_emit (self, signals[SIGNAL_CANCEL_REQUEST], 0, request->request_id); g_signal_emit (self, signals[SIGNAL_CANCEL_REQUEST], 0, request->request_id);
@ -135,7 +132,7 @@ shell_network_agent_finalize (GObject *object)
{ {
ShellAgentRequest *request = value; ShellAgentRequest *request = value;
request->callback (NM_SECRET_AGENT (object), request->callback (NM_SECRET_AGENT_OLD (object),
request->connection, request->connection,
NULL, error, NULL, error,
request->callback_data); request->callback_data);
@ -232,14 +229,6 @@ is_connection_always_ask (NMConnection *connection)
return FALSE; return FALSE;
} }
static void
gvalue_destroy_notify (gpointer data)
{
GValue *value = data;
g_value_unset (value);
g_slice_free (GValue, value);
}
static void static void
get_secrets_keyring_cb (GObject *source, get_secrets_keyring_cb (GObject *source,
GAsyncResult *result, GAsyncResult *result,
@ -252,8 +241,9 @@ get_secrets_keyring_cb (GObject *source,
GError *error = NULL; GError *error = NULL;
GList *items; GList *items;
GList *l; GList *l;
GHashTable *outer;
gboolean secrets_found = FALSE; gboolean secrets_found = FALSE;
GVariantBuilder builder_setting, builder_connection;
GVariant *setting;
items = secret_service_search_finish (NULL, result, &secret_error); items = secret_service_search_finish (NULL, result, &secret_error);
@ -271,14 +261,16 @@ get_secrets_keyring_cb (GObject *source,
{ {
g_set_error (&error, g_set_error (&error,
NM_SECRET_AGENT_ERROR, NM_SECRET_AGENT_ERROR,
NM_SECRET_AGENT_ERROR_INTERNAL_ERROR, NM_SECRET_AGENT_ERROR_FAILED,
"Internal error while retrieving secrets from the keyring (%s)", secret_error->message); "Internal error while retrieving secrets from the keyring (%s)", secret_error->message);
g_error_free (secret_error); g_error_free (secret_error);
closure->callback (NM_SECRET_AGENT (closure->self), closure->connection, NULL, error, closure->callback_data); closure->callback (NM_SECRET_AGENT_OLD (closure->self), closure->connection, NULL, error, closure->callback_data);
goto out; goto out;
} }
g_variant_builder_init (&builder_setting, NM_VARIANT_TYPE_SETTING);
for (l = items; l; l = g_list_next (l)) for (l = items; l; l = g_list_next (l))
{ {
SecretItem *item = l->data; SecretItem *item = l->data;
@ -297,18 +289,8 @@ get_secrets_keyring_cb (GObject *source,
{ {
if (g_strcmp0 (name, SHELL_KEYRING_SK_TAG) == 0) if (g_strcmp0 (name, SHELL_KEYRING_SK_TAG) == 0)
{ {
gchar *secret_name = g_strdup (attribute); g_variant_builder_add (&builder_setting, "{sv}", attribute,
g_variant_new_string (secret_value_get (secret, NULL)));
if (!closure->is_vpn)
{
GValue *secret_value = g_slice_new0 (GValue);
g_value_init (secret_value, G_TYPE_STRING);
g_value_set_string (secret_value, secret_value_get (secret, NULL));
g_hash_table_insert (closure->entries, secret_name, secret_value);
}
else
g_hash_table_insert (closure->vpn_entries, secret_name, g_strdup (secret_value_get (secret, NULL)));
secrets_found = TRUE; secrets_found = TRUE;
@ -321,6 +303,7 @@ get_secrets_keyring_cb (GObject *source,
} }
g_list_free_full (items, g_object_unref); g_list_free_full (items, g_object_unref);
setting = g_variant_builder_end (&builder_setting);
/* All VPN requests get sent to the VPN's auth dialog, since it knows better /* All VPN requests get sent to the VPN's auth dialog, since it knows better
* than the agent about what secrets are required. Otherwise, if no secrets * than the agent about what secrets are required. Otherwise, if no secrets
@ -328,21 +311,24 @@ get_secrets_keyring_cb (GObject *source,
* NetworkManager will fail the connection if not secrets are returned * NetworkManager will fail the connection if not secrets are returned
* instead of asking again with REQUEST_NEW. * instead of asking again with REQUEST_NEW.
*/ */
if (closure->is_vpn || if (strcmp(closure->setting_name, NM_SETTING_VPN_SETTING_NAME) == 0 ||
(!secrets_found && (closure->flags & NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION))) (!secrets_found && (closure->flags & NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION)))
{ {
nm_connection_update_secrets (closure->connection, closure->setting_name, closure->entries, NULL); nm_connection_update_secrets (closure->connection, closure->setting_name,
setting, NULL);
closure->entries = g_variant_dict_new (setting);
request_secrets_from_ui (closure); request_secrets_from_ui (closure);
return; return;
} }
outer = g_hash_table_new (g_str_hash, g_str_equal); g_variant_builder_init (&builder_connection, NM_VARIANT_TYPE_CONNECTION);
g_hash_table_insert (outer, closure->setting_name, closure->entries); g_variant_builder_add (&builder_connection, "{s@a{sv}}",
closure->setting_name, setting);
closure->callback (NM_SECRET_AGENT (closure->self), closure->connection, outer, NULL, closure->callback_data); closure->callback (NM_SECRET_AGENT_OLD (closure->self), closure->connection,
g_variant_builder_end (&builder_connection), NULL,
g_hash_table_destroy (outer); closure->callback_data);
out: out:
g_hash_table_remove (priv->requests, closure->request_id); g_hash_table_remove (priv->requests, closure->request_id);
@ -350,13 +336,13 @@ get_secrets_keyring_cb (GObject *source,
} }
static void static void
shell_network_agent_get_secrets (NMSecretAgent *agent, shell_network_agent_get_secrets (NMSecretAgentOld *agent,
NMConnection *connection, NMConnection *connection,
const gchar *connection_path, const gchar *connection_path,
const gchar *setting_name, const gchar *setting_name,
const gchar **hints, const gchar **hints,
NMSecretAgentGetSecretsFlags flags, NMSecretAgentGetSecretsFlags flags,
NMSecretAgentGetSecretsFunc callback, NMSecretAgentOldGetSecretsFunc callback,
gpointer callback_data) gpointer callback_data)
{ {
ShellNetworkAgent *self = SHELL_NETWORK_AGENT (agent); ShellNetworkAgent *self = SHELL_NETWORK_AGENT (agent);
@ -374,7 +360,7 @@ shell_network_agent_get_secrets (NMSecretAgent *agent,
shell_agent_request_cancel (request); shell_agent_request_cancel (request);
} }
request = g_slice_new (ShellAgentRequest); request = g_slice_new0 (ShellAgentRequest);
request->self = g_object_ref (self); request->self = g_object_ref (self);
request->cancellable = g_cancellable_new (); request->cancellable = g_cancellable_new ();
request->connection = g_object_ref (connection); request->connection = g_object_ref (connection);
@ -383,22 +369,6 @@ shell_network_agent_get_secrets (NMSecretAgent *agent,
request->flags = flags; request->flags = flags;
request->callback = callback; request->callback = callback;
request->callback_data = callback_data; request->callback_data = callback_data;
request->is_vpn = !strcmp(setting_name, NM_SETTING_VPN_SETTING_NAME);
request->entries = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, gvalue_destroy_notify);
if (request->is_vpn)
{
GValue *secret_value;
request->vpn_entries = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
secret_value = g_slice_new0 (GValue);
g_value_init (secret_value, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING));
g_value_take_boxed (secret_value, request->vpn_entries);
g_hash_table_insert (request->entries, g_strdup(NM_SETTING_VPN_SECRETS), secret_value);
}
else
request->vpn_entries = NULL;
request->request_id = request_id; request->request_id = request_id;
g_hash_table_replace (self->priv->requests, request->request_id, request); g_hash_table_replace (self->priv->requests, request->request_id, request);
@ -407,6 +377,7 @@ shell_network_agent_get_secrets (NMSecretAgent *agent,
((flags & NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION) ((flags & NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION)
&& is_connection_always_ask (request->connection))) && is_connection_always_ask (request->connection)))
{ {
request->entries = g_variant_dict_new (NULL);
request_secrets_from_ui (request); request_secrets_from_ui (request);
return; return;
} }
@ -431,7 +402,6 @@ shell_network_agent_set_password (ShellNetworkAgent *self,
{ {
ShellNetworkAgentPrivate *priv; ShellNetworkAgentPrivate *priv;
ShellAgentRequest *request; ShellAgentRequest *request;
GValue *value;
g_return_if_fail (SHELL_IS_NETWORK_AGENT (self)); g_return_if_fail (SHELL_IS_NETWORK_AGENT (self));
@ -439,18 +409,7 @@ shell_network_agent_set_password (ShellNetworkAgent *self,
request = g_hash_table_lookup (priv->requests, request_id); request = g_hash_table_lookup (priv->requests, request_id);
g_return_if_fail (request != NULL); g_return_if_fail (request != NULL);
if (!request->is_vpn) g_variant_dict_insert (request->entries, setting_key, "s", setting_value);
{
value = g_slice_new0 (GValue);
g_value_init (value, G_TYPE_STRING);
g_value_set_string (value, setting_value);
g_hash_table_replace (request->entries, g_strdup (setting_key), value);
}
else
{
g_hash_table_replace (request->vpn_entries, g_strdup (setting_key), g_strdup (setting_value));
}
} }
void void
@ -460,7 +419,8 @@ shell_network_agent_respond (ShellNetworkAgent *self,
{ {
ShellNetworkAgentPrivate *priv; ShellNetworkAgentPrivate *priv;
ShellAgentRequest *request; ShellAgentRequest *request;
GHashTable *outer; GVariantBuilder builder_connection;
GVariant *setting;
g_return_if_fail (SHELL_IS_NETWORK_AGENT (self)); g_return_if_fail (SHELL_IS_NETWORK_AGENT (self));
@ -474,7 +434,7 @@ shell_network_agent_respond (ShellNetworkAgent *self,
NM_SECRET_AGENT_ERROR_USER_CANCELED, NM_SECRET_AGENT_ERROR_USER_CANCELED,
"Network dialog was canceled by the user"); "Network dialog was canceled by the user");
request->callback (NM_SECRET_AGENT (self), request->connection, NULL, error, request->callback_data); request->callback (NM_SECRET_AGENT_OLD (self), request->connection, NULL, error, request->callback_data);
g_error_free (error); g_error_free (error);
g_hash_table_remove (priv->requests, request_id); g_hash_table_remove (priv->requests, request_id);
return; return;
@ -483,10 +443,10 @@ shell_network_agent_respond (ShellNetworkAgent *self,
if (response == SHELL_NETWORK_AGENT_INTERNAL_ERROR) if (response == SHELL_NETWORK_AGENT_INTERNAL_ERROR)
{ {
GError *error = g_error_new (NM_SECRET_AGENT_ERROR, GError *error = g_error_new (NM_SECRET_AGENT_ERROR,
NM_SECRET_AGENT_ERROR_INTERNAL_ERROR, NM_SECRET_AGENT_ERROR_FAILED,
"An internal error occurred while processing the request."); "An internal error occurred while processing the request.");
request->callback (NM_SECRET_AGENT (self), request->connection, NULL, error, request->callback_data); request->callback (NM_SECRET_AGENT_OLD (self), request->connection, NULL, error, request->callback_data);
g_error_free (error); g_error_free (error);
g_hash_table_remove (priv->requests, request_id); g_hash_table_remove (priv->requests, request_id);
return; return;
@ -494,28 +454,32 @@ shell_network_agent_respond (ShellNetworkAgent *self,
/* response == SHELL_NETWORK_AGENT_CONFIRMED */ /* response == SHELL_NETWORK_AGENT_CONFIRMED */
setting = g_variant_dict_end (request->entries);
/* Save any updated secrets */ /* Save any updated secrets */
if ((request->flags & NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION) || if ((request->flags & NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION) ||
(request->flags & NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW)) (request->flags & NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW))
{ {
NMConnection *dup = nm_connection_duplicate (request->connection); NMConnection *dup = nm_simple_connection_new_clone (request->connection);
nm_connection_update_secrets (dup, request->setting_name, request->entries, NULL); nm_connection_update_secrets (dup, request->setting_name, setting, NULL);
nm_secret_agent_save_secrets (NM_SECRET_AGENT (self), dup, NULL, NULL); nm_secret_agent_old_save_secrets (NM_SECRET_AGENT_OLD (self), dup, NULL, NULL);
g_object_unref (dup); g_object_unref (dup);
} }
outer = g_hash_table_new (g_str_hash, g_str_equal); g_variant_builder_init (&builder_connection, NM_VARIANT_TYPE_CONNECTION);
g_hash_table_insert (outer, request->setting_name, request->entries); g_variant_builder_add (&builder_connection, "{s@a{sv}}",
request->setting_name, setting);
request->callback (NM_SECRET_AGENT (self), request->connection, outer, NULL, request->callback_data); request->callback (NM_SECRET_AGENT_OLD (self), request->connection,
g_variant_builder_end (&builder_connection), NULL,
request->callback_data);
g_hash_table_destroy (outer);
g_hash_table_remove (priv->requests, request_id); g_hash_table_remove (priv->requests, request_id);
} }
static void static void
shell_network_agent_cancel_get_secrets (NMSecretAgent *agent, shell_network_agent_cancel_get_secrets (NMSecretAgentOld *agent,
const gchar *connection_path, const gchar *connection_path,
const gchar *setting_name) const gchar *setting_name)
{ {
@ -584,7 +548,7 @@ typedef struct
/* Sort of ref count, indicates the number of secrets we still need to save */ /* Sort of ref count, indicates the number of secrets we still need to save */
gint n_secrets; gint n_secrets;
NMSecretAgent *self; NMSecretAgentOld *self;
NMConnection *connection; NMConnection *connection;
gpointer callback; gpointer callback;
gpointer callback_data; gpointer callback_data;
@ -605,7 +569,7 @@ save_secret_cb (GObject *source,
gpointer user_data) gpointer user_data)
{ {
KeyringRequest *call = user_data; KeyringRequest *call = user_data;
NMSecretAgentSaveSecretsFunc callback = call->callback; NMSecretAgentOldSaveSecretsFunc callback = call->callback;
call->n_secrets--; call->n_secrets--;
@ -702,6 +666,9 @@ write_one_secret_to_keyring (NMSetting *setting,
} }
else else
{ {
if (!G_VALUE_HOLDS_STRING (value))
return;
secret = g_value_get_string (value); secret = g_value_get_string (value);
if (secret && strlen (secret)) if (secret && strlen (secret))
save_one_secret (r, setting, key, secret, NULL); save_one_secret (r, setting, key, secret, NULL);
@ -709,7 +676,7 @@ write_one_secret_to_keyring (NMSetting *setting,
} }
static void static void
save_delete_cb (NMSecretAgent *agent, save_delete_cb (NMSecretAgentOld *agent,
NMConnection *connection, NMConnection *connection,
GError *error, GError *error,
gpointer user_data) gpointer user_data)
@ -727,16 +694,16 @@ save_delete_cb (NMSecretAgent *agent,
if (r->n_secrets == 0) if (r->n_secrets == 0)
{ {
if (r->callback) if (r->callback)
((NMSecretAgentSaveSecretsFunc)r->callback) (agent, connection, NULL, r->callback_data); ((NMSecretAgentOldSaveSecretsFunc)r->callback) (agent, connection, NULL, r->callback_data);
keyring_request_free (r); keyring_request_free (r);
} }
} }
static void static void
shell_network_agent_save_secrets (NMSecretAgent *agent, shell_network_agent_save_secrets (NMSecretAgentOld *agent,
NMConnection *connection, NMConnection *connection,
const gchar *connection_path, const gchar *connection_path,
NMSecretAgentSaveSecretsFunc callback, NMSecretAgentOldSaveSecretsFunc callback,
gpointer callback_data) gpointer callback_data)
{ {
KeyringRequest *r; KeyringRequest *r;
@ -749,7 +716,7 @@ shell_network_agent_save_secrets (NMSecretAgent *agent,
r->callback_data = callback_data; r->callback_data = callback_data;
/* First delete any existing items in the keyring */ /* First delete any existing items in the keyring */
nm_secret_agent_delete_secrets (agent, connection, save_delete_cb, r); nm_secret_agent_old_delete_secrets (agent, connection, save_delete_cb, r);
} }
static void static void
@ -760,13 +727,13 @@ delete_items_cb (GObject *source,
KeyringRequest *r = user_data; KeyringRequest *r = user_data;
GError *secret_error = NULL; GError *secret_error = NULL;
GError *error = NULL; GError *error = NULL;
NMSecretAgentDeleteSecretsFunc callback = r->callback; NMSecretAgentOldDeleteSecretsFunc callback = r->callback;
secret_password_clear_finish (result, &secret_error); secret_password_clear_finish (result, &secret_error);
if (secret_error != NULL) if (secret_error != NULL)
{ {
error = g_error_new (NM_SECRET_AGENT_ERROR, error = g_error_new (NM_SECRET_AGENT_ERROR,
NM_SECRET_AGENT_ERROR_INTERNAL_ERROR, NM_SECRET_AGENT_ERROR_FAILED,
"The request could not be completed. Keyring result: %s", "The request could not be completed. Keyring result: %s",
secret_error->message); secret_error->message);
g_error_free (secret_error); g_error_free (secret_error);
@ -778,10 +745,10 @@ delete_items_cb (GObject *source,
} }
static void static void
shell_network_agent_delete_secrets (NMSecretAgent *agent, shell_network_agent_delete_secrets (NMSecretAgentOld *agent,
NMConnection *connection, NMConnection *connection,
const gchar *connection_path, const gchar *connection_path,
NMSecretAgentDeleteSecretsFunc callback, NMSecretAgentOldDeleteSecretsFunc callback,
gpointer callback_data) gpointer callback_data)
{ {
KeyringRequest *r; KeyringRequest *r;
@ -809,7 +776,7 @@ void
shell_network_agent_class_init (ShellNetworkAgentClass *klass) shell_network_agent_class_init (ShellNetworkAgentClass *klass)
{ {
GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
NMSecretAgentClass *agent_class = NM_SECRET_AGENT_CLASS (klass); NMSecretAgentOldClass *agent_class = NM_SECRET_AGENT_OLD_CLASS (klass);
gobject_class->finalize = shell_network_agent_finalize; gobject_class->finalize = shell_network_agent_finalize;

View File

@ -4,8 +4,8 @@
#include <glib-object.h> #include <glib-object.h>
#include <glib.h> #include <glib.h>
#include <nm-connection.h> #include <NetworkManager.h>
#include <nm-secret-agent.h> #include <nm-secret-agent-old.h>
G_BEGIN_DECLS G_BEGIN_DECLS
@ -29,7 +29,7 @@ typedef struct _ShellNetworkAgentPrivate ShellNetworkAgentPrivate;
struct _ShellNetworkAgent struct _ShellNetworkAgent
{ {
/*< private >*/ /*< private >*/
NMSecretAgent parent_instance; NMSecretAgentOld parent_instance;
ShellNetworkAgentPrivate *priv; ShellNetworkAgentPrivate *priv;
}; };
@ -37,7 +37,7 @@ struct _ShellNetworkAgent
struct _ShellNetworkAgentClass struct _ShellNetworkAgentClass
{ {
/*< private >*/ /*< private >*/
NMSecretAgentClass parent_class; NMSecretAgentOldClass parent_class;
}; };
/* used by SHELL_TYPE_NETWORK_AGENT */ /* used by SHELL_TYPE_NETWORK_AGENT */