diff --git a/keychain.cpp b/keychain.cpp index ded13da..caf3e37 100644 --- a/keychain.cpp +++ b/keychain.cpp @@ -32,13 +32,13 @@ QString Keychain::errorString() const { return d->errorString; } -void Keychain::writePassword( const QString &key, const QString &password, OverwriteMode om ) { - writeEntry( key, password.toUtf8(), om ); +void Keychain::writePassword( const QString &key, const QString &password ) { + writeEntry( key, password.toUtf8() ); } -void Keychain::writeEntry( const QString& key, const QByteArray& ba, OverwriteMode om ) { +void Keychain::writeEntry( const QString& key, const QByteArray& ba ) { QString err; - const Error ret = d->writeEntryImpl( key, ba, om, &err ); + const Error ret = d->writeEntryImpl( key, ba, &err ); d->error = ret; d->errorString = err; } diff --git a/keychain.h b/keychain.h index 3e6abf0..70d071c 100644 --- a/keychain.h +++ b/keychain.h @@ -50,14 +50,6 @@ public: OtherError /**< Something else went wrong (errorString() might provide details) */ }; - /** - * Overwrite mode when writing passwords to the keychain - */ - enum OverwriteMode { - DoNotOverwrite, /**< Do not overwrite existing entries */ - ForceOverwrite /**< Replace old data by new one */ - }; - /** * The service name used as identifier. */ @@ -82,8 +74,7 @@ public: * @param om Whether to overwrite existing passwords */ void writePassword( const QString& key, - const QString& password, - OverwriteMode om=DoNotOverwrite ); + const QString& password ); /** * Stores @p data in the keychain, for a given @p key. @@ -94,8 +85,7 @@ public: * @param om Whether to overwrite existing passwords */ void writeEntry( const QString& key, - const QByteArray& data, - OverwriteMode om=DoNotOverwrite ); + const QByteArray& data ); /** * Reads the password for a given @p key from the keychain. diff --git a/keychain_mac.cpp b/keychain_mac.cpp index f81e066..e1c1fc5 100644 --- a/keychain_mac.cpp +++ b/keychain_mac.cpp @@ -82,7 +82,6 @@ Keychain::Error Keychain::Private::readEntryImpl( QByteArray* pw, Keychain::Error Keychain::Private::writeEntryImpl( const QString& account, const QByteArray& data, - Keychain::OverwriteMode ov, QString* err ) { Q_ASSERT( err ); err->clear(); @@ -101,15 +100,11 @@ Keychain::Error Keychain::Private::writeEntryImpl( const QString& account, switch ( ret ) { case errSecDuplicateItem: { - if ( ov == Keychain::DoNotOverwrite ) { - *err = tr("Entry already exists"); - return EntryAlreadyExists; - } Error derr = deleteEntryImpl( account, err ); if ( derr != NoError ) return CouldNotDeleteEntry; else - return writeEntryImpl( account, data, ov, err ); + return writeEntryImpl( account, data, err ); } default: *err = strForStatus( ret ); diff --git a/keychain_p.h b/keychain_p.h index 2e84931..4abb0a1 100644 --- a/keychain_p.h +++ b/keychain_p.h @@ -21,7 +21,6 @@ public: Keychain::Error writeEntryImpl( const QString& account, const QByteArray& data, - Keychain::OverwriteMode, QString* errorString ); Keychain::Error deleteEntryImpl( const QString& account, QString* errorString ); diff --git a/testclient.cpp b/testclient.cpp index 15d310f..0507a2d 100644 --- a/testclient.cpp +++ b/testclient.cpp @@ -40,7 +40,7 @@ int main( int argc, char** argv ) { if ( ++it != args.constEnd() ) return printUsage(); Keychain k( QLatin1String("qtkeychain-testclient") ); - k.writePassword( acc, pass, Keychain::ForceOverwrite ); + k.writePassword( acc, pass ); if ( k.error() ) { std::cerr << "Storing password failed: " << qPrintable(k.errorString()) << std::endl; return 1;