mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kutils: lock from all KPasswdStore methods
also the implementation internally opens the store if it is not open already Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
67d44cd10f
commit
fa41515d34
1 changed files with 13 additions and 6 deletions
|
@ -120,31 +120,38 @@ bool KPasswdStore::openStore(const qlonglong windowid)
|
|||
void KPasswdStore::setCacheOnly(const bool cacheonly)
|
||||
{
|
||||
d->ensureInterface();
|
||||
KLockFile klockfile(getLockName(d->cookie, d->storeid));
|
||||
klockfile.lock();
|
||||
d->interface->call("setCacheOnly", d->cookie, d->storeid, cacheonly);
|
||||
klockfile.unlock();
|
||||
}
|
||||
|
||||
bool KPasswdStore::cacheOnly() const
|
||||
{
|
||||
d->ensureInterface();
|
||||
KLockFile klockfile(getLockName(d->cookie, d->storeid));
|
||||
klockfile.lock();
|
||||
QDBusReply<bool> result = d->interface->call("cacheOnly", d->cookie, d->storeid);
|
||||
klockfile.unlock();
|
||||
return result.value();
|
||||
}
|
||||
|
||||
QString KPasswdStore::getPasswd(const QByteArray &key, const qlonglong windowid)
|
||||
{
|
||||
if (!openStore(windowid) && !cacheOnly()) {
|
||||
return QString();
|
||||
}
|
||||
d->ensureInterface();
|
||||
KLockFile klockfile(getLockName(d->cookie, d->storeid));
|
||||
klockfile.lock();
|
||||
QDBusReply<QString> result = d->interface->call("getPasswd", d->cookie, d->storeid, key, windowid);
|
||||
return result.value();
|
||||
}
|
||||
|
||||
bool KPasswdStore::storePasswd(const QByteArray &key, const QString &passwd, const qlonglong windowid)
|
||||
{
|
||||
if (!openStore(windowid) && !cacheOnly()) {
|
||||
return false;
|
||||
}
|
||||
d->ensureInterface();
|
||||
KLockFile klockfile(getLockName(d->cookie, d->storeid));
|
||||
klockfile.lock();
|
||||
QDBusReply<bool> result = d->interface->call("storePasswd", d->cookie, d->storeid, key, passwd, windowid);
|
||||
klockfile.unlock();
|
||||
return result.value();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue