summaryrefslogtreecommitdiffstats
path: root/kwallet/backend
diff options
context:
space:
mode:
Diffstat (limited to 'kwallet/backend')
-rw-r--r--kwallet/backend/kwalletbackend.cc124
-rw-r--r--kwallet/backend/kwalletbackend.h66
-rw-r--r--kwallet/backend/kwalletentry.cc18
-rw-r--r--kwallet/backend/kwalletentry.h22
-rw-r--r--kwallet/backend/tests/backendtest.cpp4
5 files changed, 117 insertions, 117 deletions
diff --git a/kwallet/backend/kwalletbackend.cc b/kwallet/backend/kwalletbackend.cc
index 5b9c29299..c208c4d69 100644
--- a/kwallet/backend/kwalletbackend.cc
+++ b/kwallet/backend/kwalletbackend.cc
@@ -29,9 +29,9 @@
#include <ksavefile.h>
#include <kstandarddirs.h>
-#include <qfile.h>
-#include <qfileinfo.h>
-#include <qregexp.h>
+#include <tqfile.h>
+#include <tqfileinfo.h>
+#include <tqregexp.h>
#include "blowfish.h"
#include "sha1.h"
@@ -59,7 +59,7 @@ static void initKWalletDir()
KGlobal::dirs()->addResourceType("kwallet", "share/apps/kwallet");
}
-Backend::Backend(const QString& name, bool isPath) : _name(name), _ref(0) {
+Backend::Backend(const TQString& name, bool isPath) : _name(name), _ref(0) {
initKWalletDir();
if (isPath) {
_path = name;
@@ -90,10 +90,10 @@ return 0;
}
-static int getRandomBlock(QByteArray& randBlock) {
+static int getRandomBlock(TQByteArray& randBlock) {
// First try /dev/urandom
- if (QFile::exists("/dev/urandom")) {
- QFile devrand("/dev/urandom");
+ if (TQFile::exists("/dev/urandom")) {
+ TQFile devrand("/dev/urandom");
if (devrand.open(IO_ReadOnly)) {
unsigned int rc = devrand.readBlock(randBlock.data(), randBlock.size());
@@ -107,8 +107,8 @@ static int getRandomBlock(QByteArray& randBlock) {
// If that failed, try /dev/random
// FIXME: open in noblocking mode!
- if (QFile::exists("/dev/random")) {
- QFile devrand("/dev/random");
+ if (TQFile::exists("/dev/random")) {
+ TQFile devrand("/dev/random");
if (devrand.open(IO_ReadOnly)) {
unsigned int rc = 0;
unsigned int cnt = 0;
@@ -134,8 +134,8 @@ static int getRandomBlock(QByteArray& randBlock) {
// EGD method
char *randFilename;
if ((randFilename = getenv("RANDFILE"))) {
- if (QFile::exists(randFilename)) {
- QFile devrand(randFilename);
+ if (TQFile::exists(randFilename)) {
+ TQFile devrand(randFilename);
if (devrand.open(IO_ReadOnly)) {
unsigned int rc = devrand.readBlock(randBlock.data(), randBlock.size());
if (rc != randBlock.size()) {
@@ -153,13 +153,13 @@ static int getRandomBlock(QByteArray& randBlock) {
// this should be SHA-512 for release probably
-static int password2hash(const QByteArray& password, QByteArray& hash) {
+static int password2hash(const TQByteArray& password, TQByteArray& hash) {
SHA1 sha;
int shasz = sha.size() / 8;
assert(shasz >= 20);
- QByteArray block1(shasz);
+ TQByteArray block1(shasz);
sha.process(password.data(), QMIN(password.size(), 16));
@@ -174,7 +174,7 @@ static int password2hash(const QByteArray& password, QByteArray& hash) {
if (password.size() > 16) {
sha.process(password.data() + 16, QMIN(password.size() - 16, 16));
- QByteArray block2(shasz);
+ TQByteArray block2(shasz);
// To make brute force take longer
for (int i = 0; i < 2000; i++) {
memcpy(block2.data(), sha.hash(), shasz);
@@ -187,7 +187,7 @@ static int password2hash(const QByteArray& password, QByteArray& hash) {
if (password.size() > 32) {
sha.process(password.data() + 32, QMIN(password.size() - 32, 16));
- QByteArray block3(shasz);
+ TQByteArray block3(shasz);
// To make brute force take longer
for (int i = 0; i < 2000; i++) {
memcpy(block3.data(), sha.hash(), shasz);
@@ -200,7 +200,7 @@ static int password2hash(const QByteArray& password, QByteArray& hash) {
if (password.size() > 48) {
sha.process(password.data() + 48, password.size() - 48);
- QByteArray block4(shasz);
+ TQByteArray block4(shasz);
// To make brute force take longer
for (int i = 0; i < 2000; i++) {
memcpy(block4.data(), sha.hash(), shasz);
@@ -243,16 +243,16 @@ static int password2hash(const QByteArray& password, QByteArray& hash) {
}
-bool Backend::exists(const QString& wallet) {
+bool Backend::exists(const TQString& wallet) {
initKWalletDir();
- QString path = KGlobal::dirs()->saveLocation("kwallet") + "/" + wallet + ".kwl";
+ TQString path = KGlobal::dirs()->saveLocation("kwallet") + "/" + wallet + ".kwl";
// Note: 60 bytes is presently the minimum size of a wallet file.
// Anything smaller is junk.
-return QFile::exists(path) && QFileInfo(path).size() >= 60;
+return TQFile::exists(path) && TQFileInfo(path).size() >= 60;
}
-QString Backend::openRCToString(int rc) {
+TQString Backend::openRCToString(int rc) {
switch (rc) {
case -255:
return i18n("Already open.");
@@ -275,24 +275,24 @@ QString Backend::openRCToString(int rc) {
case -6:
return i18n("Decryption error.");
default:
- return QString::null;
+ return TQString::null;
}
}
-int Backend::open(const QByteArray& password) {
+int Backend::open(const TQByteArray& password) {
if (_open) {
return -255; // already open
}
- QByteArray passhash;
+ TQByteArray passhash;
// No wallet existed. Let's create it.
// Note: 60 bytes is presently the minimum size of a wallet file.
// Anything smaller is junk and should be deleted.
- if (!QFile::exists(_path) || QFileInfo(_path).size() < 60) {
- QFile newfile(_path);
+ if (!TQFile::exists(_path) || TQFileInfo(_path).size() < 60) {
+ TQFile newfile(_path);
if (!newfile.open(IO_ReadWrite)) {
return -2; // error opening file
}
@@ -302,7 +302,7 @@ int Backend::open(const QByteArray& password) {
return 1; // new file opened, but OK
}
- QFile db(_path);
+ TQFile db(_path);
if (!db.open(IO_ReadOnly)) {
return -2; // error opening file
@@ -335,7 +335,7 @@ int Backend::open(const QByteArray& password) {
_hashes.clear();
// Read in the hashes
- QDataStream hds(&db);
+ TQDataStream hds(&db);
Q_UINT32 n;
hds >> n;
if (n > 0xffff) { // sanity check
@@ -345,13 +345,13 @@ int Backend::open(const QByteArray& password) {
for (size_t i = 0; i < n; ++i) {
KMD5::Digest d, d2; // judgment day
MD5Digest ba;
- QMap<MD5Digest,QValueList<MD5Digest> >::iterator it;
+ TQMap<MD5Digest,TQValueList<MD5Digest> >::iterator it;
Q_UINT32 fsz;
if (hds.atEnd()) return -43;
hds.readRawBytes(reinterpret_cast<char *>(d), 16);
hds >> fsz;
ba.duplicate(reinterpret_cast<char *>(d), 16);
- it = _hashes.insert(ba, QValueList<MD5Digest>());
+ it = _hashes.insert(ba, TQValueList<MD5Digest>());
for (size_t j = 0; j < fsz; ++j) {
hds.readRawBytes(reinterpret_cast<char *>(d2), 16);
ba.duplicate(reinterpret_cast<char *>(d2), 16);
@@ -360,7 +360,7 @@ int Backend::open(const QByteArray& password) {
}
// Read in the rest of the file.
- QByteArray encrypted = db.readAll();
+ TQByteArray encrypted = db.readAll();
assert(encrypted.size() < db.size());
BlowFish _bf;
@@ -432,17 +432,17 @@ int Backend::open(const QByteArray& password) {
sha.reset();
// chop off the leading blksz+4 bytes
- QByteArray tmpenc;
+ TQByteArray tmpenc;
tmpenc.duplicate(encrypted.data()+blksz+4, fsize);
encrypted.fill(0);
encrypted.duplicate(tmpenc.data(), tmpenc.size());
tmpenc.fill(0);
// Load the data structures up
- QDataStream eStream(encrypted, IO_ReadOnly);
+ TQDataStream eStream(encrypted, IO_ReadOnly);
while (!eStream.atEnd()) {
- QString folder;
+ TQString folder;
Q_UINT32 n;
eStream >> folder;
@@ -452,7 +452,7 @@ int Backend::open(const QByteArray& password) {
_entries[folder].clear();
for (size_t i = 0; i < n; i++) {
- QString key;
+ TQString key;
KWallet::Wallet::EntryType et = KWallet::Wallet::Unknown;
Entry *e = new Entry;
eStream >> key;
@@ -470,7 +470,7 @@ int Backend::open(const QByteArray& password) {
continue;
}
- QByteArray a;
+ TQByteArray a;
eStream >> a;
e->setValue(a);
e->setType(et);
@@ -484,13 +484,13 @@ int Backend::open(const QByteArray& password) {
}
-int Backend::sync(const QByteArray& password) {
+int Backend::sync(const TQByteArray& password) {
if (!_open) {
return -255; // not open yet
}
KSaveFile sf(_path, 0600);
- QFile *qf = sf.file();
+ TQFile *qf = sf.file();
if (!qf) {
sf.abort();
@@ -500,7 +500,7 @@ int Backend::sync(const QByteArray& password) {
qf->writeBlock(KWMAGIC, KWMAGIC_LEN);
// Write the version number
- QByteArray version(4);
+ TQByteArray version(4);
version[0] = KWALLET_VERSION_MAJOR;
version[1] = KWALLET_VERSION_MINOR;
version[2] = KWALLET_CIPHER_BLOWFISH_CBC;
@@ -508,20 +508,20 @@ int Backend::sync(const QByteArray& password) {
qf->writeBlock(version, 4);
// Holds the hashes we write out
- QByteArray hashes;
- QDataStream hashStream(hashes, IO_WriteOnly);
+ TQByteArray hashes;
+ TQDataStream hashStream(hashes, IO_WriteOnly);
KMD5 md5;
hashStream << static_cast<Q_UINT32>(_entries.count());
// Holds decrypted data prior to encryption
- QByteArray decrypted;
+ TQByteArray decrypted;
// FIXME: we should estimate the amount of data we will write in each
// buffer and resize them approximately in order to avoid extra
// resizes.
// populate decrypted
- QDataStream dStream(decrypted, IO_WriteOnly);
+ TQDataStream dStream(decrypted, IO_WriteOnly);
for (FolderMap::ConstIterator i = _entries.begin(); i != _entries.end(); ++i) {
dStream << i.key();
dStream << static_cast<Q_UINT32>(i.data().count());
@@ -552,7 +552,7 @@ int Backend::sync(const QByteArray& password) {
sha.process(decrypted.data(), decrypted.size());
// prepend and append the random data
- QByteArray wholeFile;
+ TQByteArray wholeFile;
long blksz = bf.blockSize();
long newsize = decrypted.size() +
blksz + // encrypted block
@@ -563,7 +563,7 @@ int Backend::sync(const QByteArray& password) {
newsize += delta;
wholeFile.resize(newsize);
- QByteArray randBlock;
+ TQByteArray randBlock;
randBlock.resize(blksz+delta);
if (getRandomBlock(randBlock) < 0) {
sha.reset();
@@ -597,7 +597,7 @@ int Backend::sync(const QByteArray& password) {
decrypted.fill(0);
// hash the passphrase
- QByteArray passhash;
+ TQByteArray passhash;
password2hash(password, passhash);
// encrypt the data
@@ -632,7 +632,7 @@ return 0;
}
-int Backend::close(const QByteArray& password) {
+int Backend::close(const TQByteArray& password) {
int rc = sync(password);
_open = false;
if (rc != 0) {
@@ -642,7 +642,7 @@ int Backend::close(const QByteArray& password) {
}
-const QString& Backend::walletName() const {
+const TQString& Backend::walletName() const {
return _name;
}
@@ -652,17 +652,17 @@ bool Backend::isOpen() const {
}
-QStringList Backend::folderList() const {
+TQStringList Backend::folderList() const {
return _entries.keys();
}
-QStringList Backend::entryList() const {
+TQStringList Backend::entryList() const {
return _entries[_folder].keys();
}
-Entry *Backend::readEntry(const QString& key) {
+Entry *Backend::readEntry(const TQString& key) {
Entry *rc = 0L;
if (_open && hasEntry(key)) {
@@ -673,14 +673,14 @@ return rc;
}
-QPtrList<Entry> Backend::readEntryList(const QString& key) {
- QPtrList<Entry> rc;
+TQPtrList<Entry> Backend::readEntryList(const TQString& key) {
+ TQPtrList<Entry> rc;
if (!_open) {
return rc;
}
- QRegExp re(key, true, true);
+ TQRegExp re(key, true, true);
const EntryMap& map = _entries[_folder];
for (EntryMap::ConstIterator i = map.begin(); i != map.end(); ++i) {
@@ -692,7 +692,7 @@ QPtrList<Entry> Backend::readEntryList(const QString& key) {
}
-bool Backend::createFolder(const QString& f) {
+bool Backend::createFolder(const TQString& f) {
if (_entries.contains(f)) {
return false;
}
@@ -701,13 +701,13 @@ bool Backend::createFolder(const QString& f) {
KMD5 folderMd5;
folderMd5.update(f.utf8());
- _hashes.insert(MD5Digest(folderMd5.rawDigest()), QValueList<MD5Digest>());
+ _hashes.insert(MD5Digest(folderMd5.rawDigest()), TQValueList<MD5Digest>());
return true;
}
-int Backend::renameEntry(const QString& oldName, const QString& newName) {
+int Backend::renameEntry(const TQString& oldName, const TQString& newName) {
EntryMap& emap = _entries[_folder];
EntryMap::Iterator oi = emap.find(oldName);
EntryMap::Iterator ni = emap.find(newName);
@@ -756,12 +756,12 @@ void Backend::writeEntry(Entry *e) {
}
-bool Backend::hasEntry(const QString& key) const {
+bool Backend::hasEntry(const TQString& key) const {
return _entries.contains(_folder) && _entries[_folder].contains(key);
}
-bool Backend::removeEntry(const QString& key) {
+bool Backend::removeEntry(const TQString& key) {
if (!_open) {
return false;
}
@@ -788,7 +788,7 @@ return false;
}
-bool Backend::removeFolder(const QString& f) {
+bool Backend::removeFolder(const TQString& f) {
if (!_open) {
return false;
}
@@ -797,7 +797,7 @@ bool Backend::removeFolder(const QString& f) {
if (fi != _entries.end()) {
if (_folder == f) {
- _folder = QString::null;
+ _folder = TQString::null;
}
for (EntryMap::Iterator ei = fi.data().begin(); ei != fi.data().end(); ++ei) {
@@ -816,14 +816,14 @@ return false;
}
-bool Backend::folderDoesNotExist(const QString& folder) const {
+bool Backend::folderDoesNotExist(const TQString& folder) const {
KMD5 md5;
md5.update(folder.utf8());
return !_hashes.contains(MD5Digest(md5.rawDigest()));
}
-bool Backend::entryDoesNotExist(const QString& folder, const QString& entry) const {
+bool Backend::entryDoesNotExist(const TQString& folder, const TQString& entry) const {
KMD5 md5;
md5.update(folder.utf8());
HashMap::const_iterator i = _hashes.find(MD5Digest(md5.rawDigest()));
diff --git a/kwallet/backend/kwalletbackend.h b/kwallet/backend/kwalletbackend.h
index f1e9e521d..9d46d25c9 100644
--- a/kwallet/backend/kwalletbackend.h
+++ b/kwallet/backend/kwalletbackend.h
@@ -24,9 +24,9 @@
#include <kmdcodec.h>
-#include <qstring.h>
-#include <qstringlist.h>
-#include <qmap.h>
+#include <tqstring.h>
+#include <tqstringlist.h>
+#include <tqmap.h>
#include "kwalletentry.h"
@@ -38,66 +38,66 @@ class MD5Digest;
*/
class KDE_EXPORT Backend {
public:
- Backend(const QString& name = "kdewallet", bool isPath = false);
+ Backend(const TQString& name = "kdewallet", bool isPath = false);
~Backend();
// Open and unlock the wallet.
- int open(const QByteArray& password);
+ int open(const TQByteArray& password);
// Close and lock the wallet (saving changes).
- int close(const QByteArray& password);
+ int close(const TQByteArray& password);
// Close the wallet, losing any changes.
int close();
// Write the wallet to disk
- int sync(const QByteArray& password);
+ int sync(const TQByteArray& password);
// Returns true if the current wallet is open.
bool isOpen() const;
// Returns the current wallet name.
- const QString& walletName() const;
+ const TQString& walletName() const;
// The list of folders.
- QStringList folderList() const;
+ TQStringList folderList() const;
// Force creation of a folder.
- bool createFolder(const QString& f);
+ bool createFolder(const TQString& f);
// Change the folder.
- void setFolder(const QString& f) { _folder = f; }
+ void setFolder(const TQString& f) { _folder = f; }
// Current folder. If empty, it's the global folder.
- const QString& folder() const { return _folder; }
+ const TQString& folder() const { return _folder; }
// Does it have this folder?
- bool hasFolder(const QString& f) const { return _entries.contains(f); }
+ bool hasFolder(const TQString& f) const { return _entries.contains(f); }
// Look up an entry. Returns null if it doesn't exist.
- Entry *readEntry(const QString& key);
+ Entry *readEntry(const TQString& key);
// Look up a list of entries. Supports wildcards.
// You delete the list.
- QPtrList<Entry> readEntryList(const QString& key);
+ TQPtrList<Entry> readEntryList(const TQString& key);
// Store an entry.
void writeEntry(Entry *e);
// Does this folder contain this entry?
- bool hasEntry(const QString& key) const;
+ bool hasEntry(const TQString& key) const;
// Returns true if the entry was removed
- bool removeEntry(const QString& key);
+ bool removeEntry(const TQString& key);
// Returns true if the folder was removed
- bool removeFolder(const QString& f);
+ bool removeFolder(const TQString& f);
// The list of entries in this folder.
- QStringList entryList() const;
+ TQStringList entryList() const;
// Rename an entry in this folder.
- int renameEntry(const QString& oldName, const QString& newName);
+ int renameEntry(const TQString& oldName, const TQString& newName);
int ref() { return ++_ref; }
@@ -105,37 +105,37 @@ class KDE_EXPORT Backend {
int refCount() const { return _ref; }
- static bool exists(const QString& wallet);
+ static bool exists(const TQString& wallet);
- bool folderDoesNotExist(const QString& folder) const;
+ bool folderDoesNotExist(const TQString& folder) const;
- bool entryDoesNotExist(const QString& folder, const QString& entry) const;
+ bool entryDoesNotExist(const TQString& folder, const TQString& entry) const;
- static QString openRCToString(int rc);
+ static TQString openRCToString(int rc);
private:
class BackendPrivate;
BackendPrivate *d;
- QString _name;
- QString _path;
+ TQString _name;
+ TQString _path;
bool _open;
- QString _folder;
+ TQString _folder;
int _ref;
// Map Folder->Entries
- typedef QMap< QString, Entry* > EntryMap;
- typedef QMap< QString, EntryMap > FolderMap;
+ typedef TQMap< TQString, Entry* > EntryMap;
+ typedef TQMap< TQString, EntryMap > FolderMap;
FolderMap _entries;
- typedef QMap<MD5Digest, QValueList<MD5Digest> > HashMap;
+ typedef TQMap<MD5Digest, TQValueList<MD5Digest> > HashMap;
HashMap _hashes;
};
/**
* @internal
*/
-class MD5Digest : public QByteArray {
+class MD5Digest : public TQByteArray {
public:
- MD5Digest() : QByteArray(16) {}
- MD5Digest(const KMD5::Digest d) : QByteArray() { duplicate(reinterpret_cast<const char *>(d), 16); }
+ MD5Digest() : TQByteArray(16) {}
+ MD5Digest(const KMD5::Digest d) : TQByteArray() { duplicate(reinterpret_cast<const char *>(d), 16); }
virtual ~MD5Digest() {}
int operator<(const MD5Digest& r) const {
diff --git a/kwallet/backend/kwalletentry.cc b/kwallet/backend/kwalletentry.cc
index da88610b1..4e74c03e3 100644
--- a/kwallet/backend/kwalletentry.cc
+++ b/kwallet/backend/kwalletentry.cc
@@ -31,25 +31,25 @@ Entry::~Entry() {
_value.fill(0);
}
-const QString& Entry::key() const {
+const TQString& Entry::key() const {
return _key;
}
-const QByteArray& Entry::value() const {
+const TQByteArray& Entry::value() const {
return _value;
}
-QString Entry::password() const {
-QString x;
- QDataStream qds(_value, IO_ReadOnly);
+TQString Entry::password() const {
+TQString x;
+ TQDataStream qds(_value, IO_ReadOnly);
qds >> x;
return x;
}
-void Entry::setValue(const QByteArray& val) {
+void Entry::setValue(const TQByteArray& val) {
// do a direct copy from one into the other without
// temporary variables
_value.fill(0);
@@ -57,14 +57,14 @@ void Entry::setValue(const QByteArray& val) {
}
-void Entry::setValue(const QString& val) {
+void Entry::setValue(const TQString& val) {
_value.fill(0);
- QDataStream qds(_value, IO_WriteOnly);
+ TQDataStream qds(_value, IO_WriteOnly);
qds << val;
}
-void Entry::setKey(const QString& key) {
+void Entry::setKey(const TQString& key) {
_key = key;
}
diff --git a/kwallet/backend/kwalletentry.h b/kwallet/backend/kwalletentry.h
index 7f8c88448..530e1a828 100644
--- a/kwallet/backend/kwalletentry.h
+++ b/kwallet/backend/kwalletentry.h
@@ -22,8 +22,8 @@
#ifndef _KWALLETENTRY_H
#define _KWALLETENTRY_H
-#include <qstring.h>
-#include <qdatastream.h>
+#include <tqstring.h>
+#include <tqdatastream.h>
#include "kwallet.h"
@@ -36,14 +36,14 @@ class KDE_EXPORT Entry {
Entry();
~Entry();
- const QString& key() const;
- const QByteArray& value() const;
- QString password() const;
- const QByteArray& map() const { return value(); }
+ const TQString& key() const;
+ const TQByteArray& value() const;
+ TQString password() const;
+ const TQByteArray& map() const { return value(); }
- void setValue(const QByteArray& val);
- void setValue(const QString& val);
- void setKey(const QString& key);
+ void setValue(const TQByteArray& val);
+ void setValue(const TQString& val);
+ void setKey(const TQString& key);
Wallet::EntryType type() const;
void setType(Wallet::EntryType type);
@@ -51,8 +51,8 @@ class KDE_EXPORT Entry {
void copy(const Entry* x);
private:
- QString _key;
- QByteArray _value;
+ TQString _key;
+ TQByteArray _value;
Wallet::EntryType _type;
};
diff --git a/kwallet/backend/tests/backendtest.cpp b/kwallet/backend/tests/backendtest.cpp
index a38c8cdb3..e7599b3a2 100644
--- a/kwallet/backend/tests/backendtest.cpp
+++ b/kwallet/backend/tests/backendtest.cpp
@@ -2,7 +2,7 @@
#include <stdio.h>
#include <kapplication.h>
-#include <qstring.h>
+#include <tqstring.h>
#include "kwalletbackend.h"
@@ -12,7 +12,7 @@ int main(int argc, char **argv) {
KWallet::Backend be("ktestwallet");
printf("KWalletBackend constructed\n");
- QByteArray apass, bpass, cpass;
+ TQByteArray apass, bpass, cpass;
apass.duplicate("apassword", 9);
bpass.duplicate("bpassword", 9);