Changeset View
Changeset View
Standalone View
Standalone View
src/runtime/kwalletd/kwalletd.cpp
Show First 20 Lines • Show All 1172 Lines • ▼ Show 20 Line(s) | |||||
1173 | QStringList KWalletD::wallets() const | 1173 | QStringList KWalletD::wallets() const | ||
1174 | { | 1174 | { | ||
1175 | QString path = KWallet::Backend::getSaveLocation(); | 1175 | QString path = KWallet::Backend::getSaveLocation(); | ||
1176 | QDir dir(path, QStringLiteral("*.kwl")); | 1176 | QDir dir(path, QStringLiteral("*.kwl")); | ||
1177 | QStringList rc; | 1177 | QStringList rc; | ||
1178 | 1178 | | |||
1179 | dir.setFilter(QDir::Files | QDir::Hidden); | 1179 | dir.setFilter(QDir::Files | QDir::Hidden); | ||
1180 | 1180 | | |||
1181 | foreach (const QFileInfo& fi, dir.entryInfoList()) { | 1181 | const auto list = dir.entryInfoList(); | ||
1182 | for (const QFileInfo& fi : list) { | ||||
1182 | QString fn = fi.fileName(); | 1183 | QString fn = fi.fileName(); | ||
1183 | if (fn.endsWith(QLatin1String(".kwl"))) { | 1184 | if (fn.endsWith(QLatin1String(".kwl"))) { | ||
1184 | fn.truncate(fn.length() - 4); | 1185 | fn.truncate(fn.length() - 4); | ||
1185 | } | 1186 | } | ||
1186 | rc += fn; | 1187 | rc += fn; | ||
1187 | } | 1188 | } | ||
1188 | return rc; | 1189 | return rc; | ||
1189 | } | 1190 | } | ||
▲ Show 20 Lines • Show All 114 Lines • ▼ Show 20 Line(s) | |||||
1304 | QVariantMap KWalletD::readMapList(int handle, const QString& folder, | 1305 | QVariantMap KWalletD::readMapList(int handle, const QString& folder, | ||
1305 | const QString& key, const QString& appid) | 1306 | const QString& key, const QString& appid) | ||
1306 | { | 1307 | { | ||
1307 | KWallet::Backend* b; | 1308 | KWallet::Backend* b; | ||
1308 | 1309 | | |||
1309 | if ((b = getWallet(appid, handle))) { | 1310 | if ((b = getWallet(appid, handle))) { | ||
1310 | b->setFolder(folder); | 1311 | b->setFolder(folder); | ||
1311 | QVariantMap rc; | 1312 | QVariantMap rc; | ||
1312 | foreach (KWallet::Entry* entry, b->readEntryList(key)) { | 1313 | const auto lst = b->readEntryList(key); | ||
1314 | for (KWallet::Entry* entry : lst) { | ||||
1313 | if (entry->type() == KWallet::Wallet::Map) { | 1315 | if (entry->type() == KWallet::Wallet::Map) { | ||
1314 | rc.insert(entry->key(), entry->map()); | 1316 | rc.insert(entry->key(), entry->map()); | ||
1315 | } | 1317 | } | ||
1316 | } | 1318 | } | ||
1317 | return rc; | 1319 | return rc; | ||
1318 | } | 1320 | } | ||
1319 | 1321 | | |||
1320 | return QVariantMap(); | 1322 | return QVariantMap(); | ||
Show All 18 Lines | |||||
1339 | QVariantMap KWalletD::readEntryList(int handle, const QString& folder, | 1341 | QVariantMap KWalletD::readEntryList(int handle, const QString& folder, | ||
1340 | const QString& key, const QString& appid) | 1342 | const QString& key, const QString& appid) | ||
1341 | { | 1343 | { | ||
1342 | KWallet::Backend* b; | 1344 | KWallet::Backend* b; | ||
1343 | 1345 | | |||
1344 | if ((b = getWallet(appid, handle))) { | 1346 | if ((b = getWallet(appid, handle))) { | ||
1345 | b->setFolder(folder); | 1347 | b->setFolder(folder); | ||
1346 | QVariantMap rc; | 1348 | QVariantMap rc; | ||
1347 | foreach (KWallet::Entry* entry, b->readEntryList(key)) { | 1349 | const auto lst = b->readEntryList(key); | ||
1350 | for (KWallet::Entry* entry : lst) { | ||||
1348 | rc.insert(entry->key(), entry->value()); | 1351 | rc.insert(entry->key(), entry->value()); | ||
1349 | } | 1352 | } | ||
1350 | return rc; | 1353 | return rc; | ||
1351 | } | 1354 | } | ||
1352 | 1355 | | |||
1353 | return QVariantMap(); | 1356 | return QVariantMap(); | ||
1354 | } | 1357 | } | ||
1355 | 1358 | | |||
Show All 29 Lines | |||||
1385 | QVariantMap KWalletD::readPasswordList(int handle, const QString& folder, | 1388 | QVariantMap KWalletD::readPasswordList(int handle, const QString& folder, | ||
1386 | const QString& key, const QString& appid) | 1389 | const QString& key, const QString& appid) | ||
1387 | { | 1390 | { | ||
1388 | KWallet::Backend* b; | 1391 | KWallet::Backend* b; | ||
1389 | 1392 | | |||
1390 | if ((b = getWallet(appid, handle))) { | 1393 | if ((b = getWallet(appid, handle))) { | ||
1391 | b->setFolder(folder); | 1394 | b->setFolder(folder); | ||
1392 | QVariantMap rc; | 1395 | QVariantMap rc; | ||
1393 | foreach (KWallet::Entry* entry, b->readEntryList(key)) { | 1396 | const auto lst = b->readEntryList(key); | ||
1397 | for (KWallet::Entry* entry : lst) { | ||||
1394 | if (entry->type() == KWallet::Wallet::Password) { | 1398 | if (entry->type() == KWallet::Wallet::Password) { | ||
1395 | rc.insert(entry->key(), entry->password()); | 1399 | rc.insert(entry->key(), entry->password()); | ||
1396 | } | 1400 | } | ||
1397 | } | 1401 | } | ||
1398 | return rc; | 1402 | return rc; | ||
1399 | } | 1403 | } | ||
1400 | 1404 | | |||
1401 | return QVariantMap(); | 1405 | return QVariantMap(); | ||
▲ Show 20 Lines • Show All 143 Lines • ▼ Show 20 Line(s) | 1544 | { | |||
1545 | if (!newOwner.isEmpty()) { | 1549 | if (!newOwner.isEmpty()) { | ||
1546 | return; // no application exit, don't care. | 1550 | return; // no application exit, don't care. | ||
1547 | } | 1551 | } | ||
1548 | 1552 | | |||
1549 | // as we don't have the application id we have to cycle | 1553 | // as we don't have the application id we have to cycle | ||
1550 | // all sessions. As an application can basically open wallets | 1554 | // all sessions. As an application can basically open wallets | ||
1551 | // with several appids, we can't stop if we found one. | 1555 | // with several appids, we can't stop if we found one. | ||
1552 | QString service(oldOwner); | 1556 | QString service(oldOwner); | ||
1553 | QList<KWalletAppHandlePair> sessremove(_sessions.findSessions(service)); | 1557 | const QList<KWalletAppHandlePair> sessremove(_sessions.findSessions(service)); | ||
1554 | KWallet::Backend* b = nullptr; | 1558 | KWallet::Backend* b = nullptr; | ||
1555 | 1559 | | |||
1556 | // check all sessions for wallets to close | 1560 | // check all sessions for wallets to close | ||
1557 | Q_FOREACH (const KWalletAppHandlePair& s, sessremove) { | 1561 | for (const KWalletAppHandlePair& s : sessremove) { | ||
1558 | b = getWallet(s.first, s.second); | 1562 | b = getWallet(s.first, s.second); | ||
1559 | if (b) { | 1563 | if (b) { | ||
1560 | b->deref(); | 1564 | b->deref(); | ||
1561 | internalClose(b, s.second, false); | 1565 | internalClose(b, s.second, false); | ||
1562 | } | 1566 | } | ||
1563 | } | 1567 | } | ||
1564 | 1568 | | |||
1565 | // remove all the sessions in case they aren't gone yet | 1569 | // remove all the sessions in case they aren't gone yet | ||
1566 | Q_FOREACH (const KWalletAppHandlePair& s, sessremove) { | 1570 | for (const KWalletAppHandlePair& s : sessremove) { | ||
1567 | _sessions.removeSession(s.first, service, s.second); | 1571 | _sessions.removeSession(s.first, service, s.second); | ||
1568 | } | 1572 | } | ||
1569 | 1573 | | |||
1570 | // cancel all open-transactions still running for the service | 1574 | // cancel all open-transactions still running for the service | ||
1571 | QList<KWalletTransaction*>::iterator tit; | 1575 | QList<KWalletTransaction*>::iterator tit; | ||
1572 | for (tit = _transactions.begin(); tit != _transactions.end(); ++tit) { | 1576 | for (tit = _transactions.begin(); tit != _transactions.end(); ++tit) { | ||
1573 | if ((*tit)->tType == KWalletTransaction::Open | 1577 | if ((*tit)->tType == KWalletTransaction::Open | ||
1574 | && (*tit)->service == oldOwner) { | 1578 | && (*tit)->service == oldOwner) { | ||
▲ Show 20 Lines • Show All 108 Lines • ▼ Show 20 Line(s) | |||||
1683 | void KWalletD::emitFolderUpdated(const QString& wallet, const QString& folder) | 1687 | void KWalletD::emitFolderUpdated(const QString& wallet, const QString& folder) | ||
1684 | { | 1688 | { | ||
1685 | emit folderUpdated(wallet, folder); | 1689 | emit folderUpdated(wallet, folder); | ||
1686 | } | 1690 | } | ||
1687 | 1691 | | |||
1688 | void KWalletD::emitWalletListDirty() | 1692 | void KWalletD::emitWalletListDirty() | ||
1689 | { | 1693 | { | ||
1690 | const QStringList walletsInDisk = wallets(); | 1694 | const QStringList walletsInDisk = wallets(); | ||
1691 | foreach (auto i, _wallets.values()) { | 1695 | const auto lst = _wallets.values(); | ||
1696 | for (auto i : lst) { | ||||
1692 | if (!walletsInDisk.contains(i->walletName())) { | 1697 | if (!walletsInDisk.contains(i->walletName())) { | ||
1693 | internalClose(i, _wallets.key(i), true, false); | 1698 | internalClose(i, _wallets.key(i), true, false); | ||
1694 | } | 1699 | } | ||
1695 | } | 1700 | } | ||
1696 | emit walletListDirty(); | 1701 | emit walletListDirty(); | ||
1697 | } | 1702 | } | ||
1698 | 1703 | | |||
1699 | void KWalletD::reconfigure() | 1704 | void KWalletD::reconfigure() | ||
▲ Show 20 Lines • Show All 229 Lines • Show Last 20 Lines |