168
167
d->uuidToPath.remove(uuid.toString());
170
169
Knm::Connection *con = d->connectionList->findConnection(uuid.toString());
171
con->removeCertificates();
172
170
d->connectionList->removeConnection(con);
174
172
emit connectionsChanged();
180
178
Q_D(NMDBusSettingsConnectionProvider);
181
179
RemoteConnection * connection = static_cast<RemoteConnection*>(sender());
182
180
kDebug() << connection->path();
183
182
QUuid uuid = d->uuidToPath.key(connection->path(), QUuid());
184
183
if (!uuid.isNull() && d->connections.contains(uuid.toString())) {
184
ConnectionDbus temp(new Knm::Connection(QUuid(), Knm::Connection::Wired));
185
185
Knm::Connection *con = d->connectionList->findConnection(uuid.toString());
186
186
ConnectionDbus dbusConverter(con);
187
187
dbusConverter.fromDbusMap(connection->GetSettings());
188
189
d->connectionList->updateConnection(con);
190
191
emit connectionsChanged();
214
215
void NMDBusSettingsConnectionProvider::clearConnections()
216
217
Q_D(NMDBusSettingsConnectionProvider);
217
foreach (const QString &key, d->connections.keys()) {
218
// Remove it from d->connections first to prevent a crash because
219
// of the "delete toDelete.second" emmiting a Delete signal captured by
220
// NMDBusSettingsConnectionProvider::onRemoteConnectionRemoved(), which deletes
221
// toDelete.second again.
222
RemoteConnection *toDelete = d->connections.take(key);
223
d->connectionList->removeConnection(key);
218
foreach (RemoteConnection * conn, d->connections.values()) {
219
// Qt::DirectConnection makes this call synchronous.
220
// The connection will actually be deleted by NMDBusSettingsConnectionProvider::onRemoteConnectionRemoved().
221
QMetaObject::invokeMethod(conn, "Removed", Qt::DirectConnection);
226
// Just to make sure d->connections is really clear.
223
// Just to make sure they are really clear.
227
224
d->connections.clear();
228
225
d->uuidToPath.clear();
229
226
emit connectionsChanged();
288
285
// Try to pin-unlock the modem.
289
286
QMetaObject::invokeMethod(modem, "unlockRequiredChanged", Qt::DirectConnection,
290
287
Q_ARG(QString, modem->unlockRequired()));
291
kDebug() << "Trying to enable modem";
336
331
RemoteConnection *remote = d->connections.value(uuid);
337
332
kDebug() << "Updating connection "<< remote->id() << objPath;
339
newConnection->saveCertificates();
340
newConnection->setSecrets();
334
newConnection->setUuid(uuid);
341
335
ConnectionDbus converter(newConnection);
342
336
QVariantMapMap map = converter.toDbusMap();
346
// FIXME: if connection's name (id in NM termonology) changed in the Update call above,
347
// NM will leave the old connection file intact and create/update a new connection file
348
// in /etc/NetworkManager/system-connections/ with the same uuid, which is wrong in my oppinion.
349
// Furthermore the old connection is not shown in kcm's because we use the uuid as connection identifier.
338
if (newConnection->name() == remote->id()) {
341
/* If connection's name (id in NM's termonology) changes during an Update
342
* NM will leave the old connection file intact and create a new connection file
343
* in /etc/NetworkManager/system-connections/ with the same uuid, which is wrong in my oppinion.
344
* Furthermore the old connection will not be shown in Plasma NM's connection list
345
* because we use connection's uuid as connection identifier.
346
* Deleting the old connection and creating a new one seems to work.
348
kDebug() << "Renaming connection:" << remote->id() << " -> " << newConnection->name();
349
QDBusPendingCall reply = remote->Delete();
350
reply.waitForFinished();
352
addConnection(newConnection);
351
355
// don't do any processing on d->connections and d->connectionList here
352
356
// because onRemoteConnectionUpdated() method will take care of them
358
362
kWarning() << "Connection could not found!"<< uuid;
362
365
void NMDBusSettingsConnectionProvider::addConnection(Knm::Connection *newConnection)
364
367
Q_D(NMDBusSettingsConnectionProvider);
365
newConnection->saveCertificates();
366
newConnection->setSecrets();
367
369
ConnectionDbus converter(newConnection);
368
370
QVariantMapMap map = converter.toDbusMap();
369
371
kDebug() << "Adding connection " << newConnection->name() << newConnection->uuid().toString();
373
375
if(newConnection && newConnection->name().isEmpty())
374
376
kWarning() << "Trying to add connection without a name!";
378
378
d->secretsToSave.insert(newConnection->uuid(), map);
379
379
QDBusPendingCall reply = d->iface->AddConnection(map);
380
380
//do not check if reply is valid or not because it's an async call and invalid till reply is really arrived
398
398
Q_D(NMDBusSettingsConnectionProvider);
399
399
QDBusObjectPath objPath = reply.argumentAt<0>();
400
emit addConnectionCompleted(true, QString());
402
401
// Hack to force NetworkManager to call the secrets agent to save this connections's secrets.
403
402
// This does not work for VPN connections.
405
404
QString uuid = d->uuidToPath.key(objPath.path(), QUuid()).toString();
406
405
RemoteConnection *remote = d->connections.value(uuid);
407
406
QVariantMapMap map = d->secretsToSave.take(uuid);
408
408
remote->Update(map);
409
emit addConnectionCompleted(true, QString());
410
411
kDebug() << "Connection added successfully: " << objPath.path() << uuid;
419
420
Q_D(NMDBusSettingsConnectionProvider);
421
if (!con->hasSecrets())
423
kDebug() << "Connection seems not to have any secret information. Ignoring...";
427
422
QUuid uuid = con->uuid();
428
423
if ( !d->uuidToPath.contains(uuid)){
429
424
kWarning() << "Secrets requested but connection not found!";
437
432
kDebug() << "Getting connection secrets for " << uuid.toString();
439
QStringList secretSettings = con->secretSettings();
434
QStringList secretSettings = con->hasPersistentSecretsSettings();
441
436
kDebug() << "Settings containing secret values are " << secretSettings;
520
515
kWarning() << "Connection could not found!"<< uuid;
518
ConnectionList * NMDBusSettingsConnectionProvider::connectionList()
520
Q_D(NMDBusSettingsConnectionProvider);
521
return d->connectionList;
523
523
// vim: sw=4 sts=4 et tw=100