Changeset View
Changeset View
Standalone View
Standalone View
src/api/KWallet/kwallet.cpp
Show First 20 Lines • Show All 170 Lines • ▼ Show 20 Line(s) | 147 | #if HAVE_KSECRETSSERVICE | |||
---|---|---|---|---|---|
171 | template <typename V> | 171 | template <typename V> | ||
172 | int forEachItemThatMatches(const QString &key, V verb) | 172 | int forEachItemThatMatches(const QString &key, V verb) | ||
173 | { | 173 | { | ||
174 | int rc = -1; | 174 | int rc = -1; | ||
175 | KSecretsService::StringStringMap attrs; | 175 | KSecretsService::StringStringMap attrs; | ||
176 | attrs[KSS_ATTR_ENTRYFOLDER] = folder; | 176 | attrs[KSS_ATTR_ENTRYFOLDER] = folder; | ||
177 | KSecretsService::SearchCollectionItemsJob *searchItemsJob = secretsCollection->searchItems(attrs); | 177 | KSecretsService::SearchCollectionItemsJob *searchItemsJob = secretsCollection->searchItems(attrs); | ||
178 | if (searchItemsJob->exec()) { | 178 | if (searchItemsJob->exec()) { | ||
179 | const QRegularExpression re(QRegularExpression::wildcardToRegularExpression(key)); | 179 | const QRegExp re(key, Qt::CaseSensitive, QRegExp::Wildcard); | ||
180 | const auto list = searchItemsJob->items(); | 180 | const auto list = searchItemsJob->items(); | ||
181 | QRegularExpressionMatch match; | | |||
182 | for (KSecretsService::SearchCollectionItemsJob::Item item : list) { | 181 | for (KSecretsService::SearchCollectionItemsJob::Item item : list) { | ||
183 | KSecretsService::ReadItemPropertyJob *readLabelJob = item->label(); | 182 | KSecretsService::ReadItemPropertyJob *readLabelJob = item->label(); | ||
184 | if (readLabelJob->exec()) { | 183 | if (readLabelJob->exec()) { | ||
185 | QString label = readLabelJob->propertyValue().toString(); | 184 | QString label = readLabelJob->propertyValue().toString(); | ||
186 | match = re.match(label); | 185 | if (re.exactMatch(label)) { | ||
187 | if (match.hasMatch()) { | | |||
188 | if (verb(this, label, item.data())) { | 186 | if (verb(this, label, item.data())) { | ||
189 | rc = 0; // one successful iteration already produced results, so success return | 187 | rc = 0; // one successful iteration already produced results, so success return | ||
190 | } | 188 | } | ||
191 | } | 189 | } | ||
192 | } else { | 190 | } else { | ||
193 | qCDebug(KWALLET_API_LOG) << "Cannot execute ReadItemPropertyJob " << readLabelJob->errorString(); | 191 | qCDebug(KWALLET_API_LOG) << "Cannot execute ReadItemPropertyJob " << readLabelJob->errorString(); | ||
194 | } | 192 | } | ||
195 | } | 193 | } | ||
▲ Show 20 Lines • Show All 1479 Lines • Show Last 20 Lines |