Beispiel #1
0
// static
bool OTKeyring::KWallet_DeleteSecret(const OTString& strUser,
                                     const std::string& str_display)
{
    OT_ASSERT(strUser.Exists());

    KWallet::Wallet* pWallet = OTKeyring::OpenKWallet();

    if (nullptr != pWallet) {
        const QString qstrKey(strUser.Get());

        bool bResult = false;

        if (pWallet->removeEntry(qstrKey) == 0) // delete the entry
            bResult = true;
        else
            otErr << "OTKeyring::KWallet_DeleteSecret: Failed trying to erase "
                     "secret from KWallet.\n";

        return bResult;
    }

    otErr << "OTKeyring::KWallet_DeleteSecret: Unable to open kwallet.\n";

    return false;
}
Beispiel #2
0
void EncryptedStore::savePasswordInKWallet()
{
    Q_D(KOdfStore);
    KWallet::Wallet *wallet = KWallet::Wallet::openWallet(KWallet::Wallet::LocalWallet(), d->window ? d->window->winId() : 0);
    if (wallet) {
        if (!wallet->hasFolder(KWallet::Wallet::PasswordFolder())) {
            wallet->createFolder(KWallet::Wallet::PasswordFolder());
        }
        if (wallet->setFolder(KWallet::Wallet::PasswordFolder())) {
            if (wallet->hasEntry(m_filename + "/opendocument")) {
                wallet->removeEntry(m_filename + "/opendocument");
            }
            wallet->writePassword(m_filename + "/opendocument", m_password.toByteArray().data());
        }
        delete wallet;
    }
}