Some string literal cleanup

Avoid implicit conversions to QString, remove some helpers only
used in _dbus from the Private.
This commit is contained in:
Frank Osterfeld 2013-10-12 20:24:49 +02:00
parent b66a182a85
commit 887719567d
3 changed files with 65 additions and 46 deletions

View File

@ -14,6 +14,16 @@
using namespace QKeychain;
static QString typeKey( const QString& key )
{
return QString::fromLatin1( "%1/type" ).arg( key );
}
static QString dataKey( const QString& key )
{
return QString::fromLatin1( "%1/data" ).arg( key );
}
class GnomeKeyring : private QLibrary {
public:
enum Result {
@ -111,7 +121,7 @@ private:
NETWORK_PASSWORD = &schema;
find_password = reinterpret_cast<find_password_fn*>( resolve( "gnome_keyring_find_password" ) );
store_password = reinterpret_cast<store_password_fn*>(resolve( "gnome_keyring_store_password" ) );
store_password = reinterpret_cast<store_password_fn*>( resolve( "gnome_keyring_store_password" ) );
delete_password = reinterpret_cast<delete_password_fn*>( resolve( "gnome_keyring_delete_password" ) );
}
@ -145,7 +155,7 @@ enum KeyringBackend {
static KeyringBackend detectKeyringBackend()
{
if ( getenv( "GNOME_KEYRING_CONTROL" ) && GnomeKeyring::isSupported() )
if ( !qgetenv( "GNOME_KEYRING_CONTROL" ).isNull() && GnomeKeyring::isSupported() )
return Backend_GnomeKeyring;
else
return Backend_Kwallet;
@ -177,7 +187,7 @@ void ReadPasswordJobPrivate::scheduledStart() {
else
{
// D-Bus is not reachable so none can tell us something about KWalletd
QDBusError err( QDBusError::NoServer, "D-Bus is not running" );
QDBusError err( QDBusError::NoServer, tr("D-Bus is not running") );
fallbackOnError( err );
}
break;
@ -243,10 +253,10 @@ void ReadPasswordJobPrivate::fallbackOnError(const QDBusError& err )
QSettings* actual = q->settings() ? q->settings() : local.get();
WritePasswordJobPrivate::Mode mode;
if ( q->insecureFallback() && actual->contains( dataKey() ) ) {
if ( q->insecureFallback() && actual->contains( dataKey( key ) ) ) {
mode = (WritePasswordJobPrivate::Mode)actual->value( typeKey() ).toInt();
data = actual->value( dataKey() ).toByteArray();
mode = (WritePasswordJobPrivate::Mode)actual->value( typeKey( key ) ).toInt();
data = actual->value( dataKey( key ) ).toByteArray();
q->emitFinished();
} else {
@ -257,16 +267,6 @@ void ReadPasswordJobPrivate::fallbackOnError(const QDBusError& err )
}
}
const QString ReadPasswordJobPrivate::typeKey()
{
return QString( "%1/type" ).arg( key );
}
const QString ReadPasswordJobPrivate::dataKey()
{
return QString( "%1/data" ).arg( key );
}
void ReadPasswordJobPrivate::kwalletOpenFinished( QDBusPendingCallWatcher* watcher ) {
watcher->deleteLater();
const QDBusPendingReply<int> reply = *watcher;
@ -280,12 +280,12 @@ void ReadPasswordJobPrivate::kwalletOpenFinished( QDBusPendingCallWatcher* watch
return;
}
if ( actual->contains( dataKey() ) ) {
if ( actual->contains( dataKey( key ) ) ) {
// We previously stored data in the insecure QSettings, but now have KWallet available.
// Do the migration
data = actual->value( dataKey() ).toByteArray();
mode = (WritePasswordJobPrivate::Mode)actual->value( typeKey() ).toInt();
data = actual->value( dataKey( key ) ).toByteArray();
mode = (WritePasswordJobPrivate::Mode)actual->value( typeKey( key ) ).toInt();
actual->remove( key );
q->emitFinished();
@ -411,7 +411,7 @@ void WritePasswordJobPrivate::scheduledStart() {
else
{
// D-Bus is not reachable so none can tell us something about KWalletd
QDBusError err( QDBusError::NoServer, "D-Bus is not running" );
QDBusError err( QDBusError::NoServer, tr("D-Bus is not running") );
fallbackOnError( err );
}
}
@ -435,11 +435,11 @@ void WritePasswordJobPrivate::fallbackOnError(const QDBusError &err)
return;
}
actual->setValue( QString( "%1/type" ).arg( key ), (int)mode );
actual->setValue( QString::fromLatin1( "%1/type" ).arg( key ), (int)mode );
if ( mode == Text )
actual->setValue( QString( "%1/data" ).arg( key ), textData.toUtf8() );
actual->setValue( QString::fromLatin1( "%1/data" ).arg( key ), textData.toUtf8() );
else if ( mode == Binary )
actual->setValue( QString( "%1/data" ).arg( key ), binaryData );
actual->setValue( QString::fromLatin1( "%1/data" ).arg( key ), binaryData );
actual->sync();
q->emitFinished();

View File

@ -71,8 +71,6 @@ public:
friend class QKeychain::JobExecutor;
void fallbackOnError(const QDBusError& err);
const QString typeKey();
const QString dataKey();
private Q_SLOTS:
void kwalletWalletFound( QDBusPendingCallWatcher* watcher );
void kwalletOpenFinished( QDBusPendingCallWatcher* watcher );

View File

@ -4,32 +4,47 @@
<context>
<name>QKeychain::ReadPasswordJobPrivate</name>
<message>
<location filename="../keychain_dbus.cpp" line="166"/>
<location filename="../keychain_dbus.cpp" line="176"/>
<source>Unknown error</source>
<translation>Unbekannter Fehler</translation>
</message>
<message>
<location filename="../keychain_dbus.cpp" line="245"/>
<location filename="../keychain_dbus.cpp" line="190"/>
<source>D-Bus is not running</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../keychain_dbus.cpp" line="264"/>
<source>No keychain service available</source>
<translation>Kein Schlüsselbund-Dienst verfügbar</translation>
</message>
<message>
<location filename="../keychain_dbus.cpp" line="247"/>
<location filename="../keychain_dbus.cpp" line="266"/>
<source>Could not open wallet: %1; %2</source>
<translation>Konnte Brieftasche nicht öffnen: %1; %2</translation>
</message>
<message>
<location filename="../keychain_dbus.cpp" line="304"/>
<location filename="../keychain_dbus.cpp" line="313"/>
<source>Access to keychain denied</source>
<translation>Zugriff auf Schlüsselbund verweigert</translation>
</message>
<message>
<location filename="../keychain_dbus.cpp" line="317"/>
<location filename="../keychain_dbus.cpp" line="334"/>
<source>Could not determine data type: %1; %2</source>
<translation>Datentyp kann nicht ermittelt werden: %1: %2</translation>
</message>
<message>
<location filename="../keychain_dbus.cpp" line="336"/>
<location filename="../keychain_dbus.cpp" line="352"/>
<source>Unsupported entry type &apos;Map&apos;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../keychain_dbus.cpp" line="355"/>
<source>Unknown kwallet entry type &apos;%1&apos;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../keychain_dbus.cpp" line="370"/>
<source>Could not read password: %1; %2</source>
<translation>Passwort konnte nicht ausgelesen werden: %1; %2</translation>
</message>
@ -39,6 +54,7 @@
<translation>Passwort nicht gefunden</translation>
</message>
<message>
<location filename="../keychain_dbus.cpp" line="343"/>
<location filename="../keychain_win.cpp" line="27"/>
<source>Entry not found</source>
<translation>Eintrag nicht gefunden</translation>
@ -52,19 +68,24 @@
<context>
<name>QKeychain::WritePasswordJobPrivate</name>
<message>
<location filename="../keychain_dbus.cpp" line="357"/>
<location filename="../keychain_dbus.cpp" line="365"/>
<location filename="../keychain_dbus.cpp" line="391"/>
<location filename="../keychain_dbus.cpp" line="399"/>
<source>Unknown error</source>
<translation>Unbekannter Fehler</translation>
</message>
<message>
<location filename="../keychain_dbus.cpp" line="392"/>
<location filename="../keychain_dbus.cpp" line="468"/>
<location filename="../keychain_dbus.cpp" line="414"/>
<source>D-Bus is not running</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../keychain_dbus.cpp" line="426"/>
<location filename="../keychain_dbus.cpp" line="502"/>
<source>Could not open wallet: %1; %2</source>
<translation>Konnte Brieftasche nicht öffnen: %1; %2</translation>
</message>
<message>
<location filename="../keychain_dbus.cpp" line="446"/>
<location filename="../keychain_dbus.cpp" line="480"/>
<source>Access to keychain denied</source>
<translation>Zugriff auf Schlüsselbund verweigert</translation>
</message>
@ -97,52 +118,52 @@
<context>
<name>QObject</name>
<message>
<location filename="../keychain_dbus.cpp" line="193"/>
<location filename="../keychain_dbus.cpp" line="212"/>
<source>Access to keychain denied</source>
<translation>Zugriff auf Schlüsselbund verweigert</translation>
</message>
<message>
<location filename="../keychain_dbus.cpp" line="195"/>
<location filename="../keychain_dbus.cpp" line="214"/>
<source>No keyring daemon</source>
<translation>Kein Schlüsselbund-Dienst </translation>
</message>
<message>
<location filename="../keychain_dbus.cpp" line="197"/>
<location filename="../keychain_dbus.cpp" line="216"/>
<source>Already unlocked</source>
<translation>Bereits entsperrt</translation>
</message>
<message>
<location filename="../keychain_dbus.cpp" line="199"/>
<location filename="../keychain_dbus.cpp" line="218"/>
<source>No such keyring</source>
<translation>Kein solcher Schlüsselbund</translation>
</message>
<message>
<location filename="../keychain_dbus.cpp" line="201"/>
<location filename="../keychain_dbus.cpp" line="220"/>
<source>Bad arguments</source>
<translation>Ungültige Argumente</translation>
</message>
<message>
<location filename="../keychain_dbus.cpp" line="203"/>
<location filename="../keychain_dbus.cpp" line="222"/>
<source>I/O error</source>
<translation>Ein-/Ausgabe-Fehler</translation>
</message>
<message>
<location filename="../keychain_dbus.cpp" line="205"/>
<location filename="../keychain_dbus.cpp" line="224"/>
<source>Cancelled</source>
<translation>Abgebrochen</translation>
</message>
<message>
<location filename="../keychain_dbus.cpp" line="207"/>
<location filename="../keychain_dbus.cpp" line="226"/>
<source>Keyring already exists</source>
<translation>Schlüsselbund existiert bereits</translation>
</message>
<message>
<location filename="../keychain_dbus.cpp" line="209"/>
<location filename="../keychain_dbus.cpp" line="228"/>
<source>No match</source>
<translation>Kein Treffer</translation>
</message>
<message>
<location filename="../keychain_dbus.cpp" line="214"/>
<location filename="../keychain_dbus.cpp" line="233"/>
<source>Unknown error</source>
<translation>Unbekannter Fehler</translation>
</message>