Changeset View
Changeset View
Standalone View
Standalone View
src/api/KWallet/kwallet.cpp
Show First 20 Lines • Show All 173 Lines • ▼ Show 20 Line(s) | 149 | #if HAVE_KSECRETSSERVICE | |||
---|---|---|---|---|---|
174 | int forEachItemThatMatches(const QString &key, V verb) | 174 | int forEachItemThatMatches(const QString &key, V verb) | ||
175 | { | 175 | { | ||
176 | int rc = -1; | 176 | int rc = -1; | ||
177 | KSecretsService::StringStringMap attrs; | 177 | KSecretsService::StringStringMap attrs; | ||
178 | attrs[KSS_ATTR_ENTRYFOLDER] = folder; | 178 | attrs[KSS_ATTR_ENTRYFOLDER] = folder; | ||
179 | KSecretsService::SearchCollectionItemsJob *searchItemsJob = secretsCollection->searchItems(attrs); | 179 | KSecretsService::SearchCollectionItemsJob *searchItemsJob = secretsCollection->searchItems(attrs); | ||
180 | if (searchItemsJob->exec()) { | 180 | if (searchItemsJob->exec()) { | ||
181 | QRegExp re(key, Qt::CaseSensitive, QRegExp::Wildcard); | 181 | QRegExp re(key, Qt::CaseSensitive, QRegExp::Wildcard); | ||
182 | foreach (KSecretsService::SearchCollectionItemsJob::Item item, searchItemsJob->items()) { | 182 | const auto list = searchItemsJob->items(); | ||
183 | for (KSecretsService::SearchCollectionItemsJob::Item item : list) { | ||||
183 | KSecretsService::ReadItemPropertyJob *readLabelJob = item->label(); | 184 | KSecretsService::ReadItemPropertyJob *readLabelJob = item->label(); | ||
184 | if (readLabelJob->exec()) { | 185 | if (readLabelJob->exec()) { | ||
185 | QString label = readLabelJob->propertyValue().toString(); | 186 | QString label = readLabelJob->propertyValue().toString(); | ||
186 | if (re.exactMatch(label)) { | 187 | if (re.exactMatch(label)) { | ||
187 | if (verb(this, label, item.data())) { | 188 | if (verb(this, label, item.data())) { | ||
188 | rc = 0; // one successful iteration already produced results, so success return | 189 | rc = 0; // one successful iteration already produced results, so success return | ||
189 | } | 190 | } | ||
190 | } | 191 | } | ||
▲ Show 20 Lines • Show All 522 Lines • ▼ Show 20 Line(s) | 713 | #if HAVE_KSECRETSSERVICE | |||
713 | if (walletLauncher()->m_useKSecretsService) { | 714 | if (walletLauncher()->m_useKSecretsService) { | ||
714 | QStringList result; | 715 | QStringList result; | ||
715 | 716 | | |||
716 | KSecretsService::StringStringMap attrs; | 717 | KSecretsService::StringStringMap attrs; | ||
717 | attrs[KSS_ATTR_ENTRYFOLDER] = ""; // search for items having this attribute no matter what value it has | 718 | attrs[KSS_ATTR_ENTRYFOLDER] = ""; // search for items having this attribute no matter what value it has | ||
718 | KSecretsService::SearchCollectionItemsJob *searchJob = d->secretsCollection->searchItems(attrs); | 719 | KSecretsService::SearchCollectionItemsJob *searchJob = d->secretsCollection->searchItems(attrs); | ||
719 | 720 | | |||
720 | if (searchJob->exec()) { | 721 | if (searchJob->exec()) { | ||
721 | KSecretsService::ReadCollectionItemsJob::ItemList itemList = searchJob->items(); | 722 | const KSecretsService::ReadCollectionItemsJob::ItemList itemList = searchJob->items(); | ||
722 | foreach (const KSecretsService::ReadCollectionItemsJob::Item &item, itemList) { | 723 | for (const KSecretsService::ReadCollectionItemsJob::Item &item : itemList) { | ||
723 | KSecretsService::ReadItemPropertyJob *readAttrsJob = item->attributes(); | 724 | KSecretsService::ReadItemPropertyJob *readAttrsJob = item->attributes(); | ||
724 | if (readAttrsJob->exec()) { | 725 | if (readAttrsJob->exec()) { | ||
725 | KSecretsService::StringStringMap attrs = readAttrsJob->propertyValue().value<KSecretsService::StringStringMap>(); | 726 | KSecretsService::StringStringMap attrs = readAttrsJob->propertyValue().value<KSecretsService::StringStringMap>(); | ||
726 | const QString folder = attrs[KSS_ATTR_ENTRYFOLDER]; | 727 | const QString folder = attrs[KSS_ATTR_ENTRYFOLDER]; | ||
727 | if (!folder.isEmpty() && !result.contains(folder)) { | 728 | if (!folder.isEmpty() && !result.contains(folder)) { | ||
728 | result.append(folder); | 729 | result.append(folder); | ||
729 | } | 730 | } | ||
730 | } else { | 731 | } else { | ||
Show All 26 Lines | |||||
757 | { | 758 | { | ||
758 | #if HAVE_KSECRETSSERVICE | 759 | #if HAVE_KSECRETSSERVICE | ||
759 | if (walletLauncher()->m_useKSecretsService) { | 760 | if (walletLauncher()->m_useKSecretsService) { | ||
760 | QStringList result; | 761 | QStringList result; | ||
761 | KSecretsService::StringStringMap attrs; | 762 | KSecretsService::StringStringMap attrs; | ||
762 | attrs[KSS_ATTR_ENTRYFOLDER] = d->folder; | 763 | attrs[KSS_ATTR_ENTRYFOLDER] = d->folder; | ||
763 | KSecretsService::SearchCollectionItemsJob *readItemsJob = d->secretsCollection->searchItems(attrs); | 764 | KSecretsService::SearchCollectionItemsJob *readItemsJob = d->secretsCollection->searchItems(attrs); | ||
764 | if (readItemsJob->exec()) { | 765 | if (readItemsJob->exec()) { | ||
765 | foreach (KSecretsService::SearchCollectionItemsJob::Item item, readItemsJob->items()) { | 766 | const auto list = readItemsJob->items(); | ||
767 | for (KSecretsService::SearchCollectionItemsJob::Item item : list) { | ||||
766 | KSecretsService::ReadItemPropertyJob *readLabelJob = item->label(); | 768 | KSecretsService::ReadItemPropertyJob *readLabelJob = item->label(); | ||
767 | if (readLabelJob->exec()) { | 769 | if (readLabelJob->exec()) { | ||
768 | result.append(readLabelJob->propertyValue().toString()); | 770 | result.append(readLabelJob->propertyValue().toString()); | ||
769 | } else { | 771 | } else { | ||
770 | qCDebug(KWALLET_API_LOG) << "Cannot execute readLabelJob" << readItemsJob->errorString(); | 772 | qCDebug(KWALLET_API_LOG) << "Cannot execute readLabelJob" << readItemsJob->errorString(); | ||
771 | } | 773 | } | ||
772 | } | 774 | } | ||
773 | } else { | 775 | } else { | ||
▲ Show 20 Lines • Show All 115 Lines • ▼ Show 20 Line(s) | |||||
889 | #if HAVE_KSECRETSSERVICE | 891 | #if HAVE_KSECRETSSERVICE | ||
890 | if (walletLauncher()->m_useKSecretsService) { | 892 | if (walletLauncher()->m_useKSecretsService) { | ||
891 | bool result = false; | 893 | bool result = false; | ||
892 | // search for all items having the folder f then delete them | 894 | // search for all items having the folder f then delete them | ||
893 | KSecretsService::StringStringMap attrs; | 895 | KSecretsService::StringStringMap attrs; | ||
894 | attrs[KSS_ATTR_ENTRYFOLDER] = f; | 896 | attrs[KSS_ATTR_ENTRYFOLDER] = f; | ||
895 | KSecretsService::SearchCollectionItemsJob *searchJob = d->secretsCollection->searchItems(attrs); | 897 | KSecretsService::SearchCollectionItemsJob *searchJob = d->secretsCollection->searchItems(attrs); | ||
896 | if (searchJob->exec()) { | 898 | if (searchJob->exec()) { | ||
897 | KSecretsService::SearchCollectionItemsJob::ItemList itemList = searchJob->items(); | 899 | const KSecretsService::SearchCollectionItemsJob::ItemList itemList = searchJob->items(); | ||
898 | if (!itemList.isEmpty()) { | 900 | if (!itemList.isEmpty()) { | ||
899 | result = true; | 901 | result = true; | ||
900 | foreach (const KSecretsService::SearchCollectionItemsJob::Item &item, itemList) { | 902 | for (const KSecretsService::SearchCollectionItemsJob::Item &item : itemList) { | ||
901 | KSecretsService::SecretItemDeleteJob *deleteJob = item->deleteItem(); | 903 | KSecretsService::SecretItemDeleteJob *deleteJob = item->deleteItem(); | ||
902 | if (!deleteJob->exec()) { | 904 | if (!deleteJob->exec()) { | ||
903 | qCDebug(KWALLET_API_LOG) << "Cannot delete item : " << deleteJob->errorString(); | 905 | qCDebug(KWALLET_API_LOG) << "Cannot delete item : " << deleteJob->errorString(); | ||
904 | result = false; | 906 | result = false; | ||
905 | } | 907 | } | ||
906 | result &= true; | 908 | result &= true; | ||
907 | } | 909 | } | ||
908 | } | 910 | } | ||
▲ Show 20 Lines • Show All 764 Lines • Show Last 20 Lines |