diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-05-17 08:20:48 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-05-17 08:20:48 +0000 |
commit | aa0726b20f398264f0a2abc60215be044b106f9c (patch) | |
tree | 070fdbc19a1106cfdd7f651a8ce76bb1b89a513d /src/kgpgme.cpp | |
parent | d3cf5b3e75aadc3b02d0b56f030d4c3f8c2c749d (diff) | |
download | basket-aa0726b20f398264f0a2abc60215be044b106f9c.tar.gz basket-aa0726b20f398264f0a2abc60215be044b106f9c.zip |
TQt4 port basket
This enables compilation under both Qt3 and Qt4
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/basket@1232416 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/kgpgme.cpp')
-rw-r--r-- | src/kgpgme.cpp | 110 |
1 files changed, 55 insertions, 55 deletions
diff --git a/src/kgpgme.cpp b/src/kgpgme.cpp index 4aaeeeb..5f6d355 100644 --- a/src/kgpgme.cpp +++ b/src/kgpgme.cpp @@ -28,9 +28,9 @@ #include <kiconloader.h> #include <klistview.h> #include <kdebug.h> -#include <qcheckbox.h> -#include <qlayout.h> -#include <qlabel.h> +#include <tqcheckbox.h> +#include <tqlayout.h> +#include <tqlabel.h> #include <klocale.h> #include <locale.h> #include <errno.h> @@ -46,15 +46,15 @@ class KGpgSelKey : public KDialogBase public: - KGpgSelKey(QWidget *parent, const char *name, QString preselected, + KGpgSelKey(TQWidget *tqparent, const char *name, TQString preselected, const KGpgMe& gpg): - KDialogBase( parent, name, true,i18n("Private Key List"),Ok | Cancel) { - QString keyname; - QVBoxLayout* vbox; - QWidget* page = new QWidget(this); - QLabel* labeltxt; + KDialogBase( tqparent, name, true,i18n("Private Key List"),Ok | Cancel) { + TQString keyname; + TQVBoxLayout* vbox; + TQWidget* page = new TQWidget(this); + TQLabel* labeltxt; KIconLoader* loader = KGlobal::iconLoader(); - QPixmap keyPair = loader->loadIcon("kgpg_key2", KIcon::Small, 20); + TQPixmap keyPair = loader->loadIcon("kgpg_key2", KIcon::Small, 20); setMinimumSize(350,100); keysListpr = new KListView(page); @@ -66,13 +66,13 @@ class KGpgSelKey : public KDialogBase keysListpr->setFullWidth(true); keysListpr->setAllColumnsShowFocus(true); - labeltxt = new QLabel(i18n("Choose a secret key:"),page); - vbox = new QVBoxLayout(page); + labeltxt = new TQLabel(i18n("Choose a secret key:"),page); + vbox = new TQVBoxLayout(page); KGpgKeyList list = gpg.keys(true); for(KGpgKeyList::iterator it = list.begin(); it != list.end(); ++it) { - QString name = gpg.checkForUtf8((*it).name); + TQString name = gpg.checkForUtf8((*it).name); KListViewItem *item = new KListViewItem(keysListpr, name, (*it).email, (*it).id); item->setPixmap(0,keyPair); @@ -90,8 +90,8 @@ class KGpgSelKey : public KDialogBase setMainWidget(page); }; - QString key() { - QListViewItem* item = keysListpr->selectedItem(); + TQString key() { + TQListViewItem* item = keysListpr->selectedItem(); if(item) return item->text(2); @@ -138,12 +138,12 @@ void KGpgMe::init(gpgme_protocol_t proto) err = gpgme_engine_check_version(proto); if(err) { - KMessageBox::error(kapp->activeWindow(), QString("%1: %2") - .arg(gpgme_strsource(err)).arg(gpgme_strerror(err))); + KMessageBox::error(TQT_TQWIDGET(kapp->activeWindow()), TQString("%1: %2") + .tqarg(gpgme_strsource(err)).tqarg(gpgme_strerror(err))); } } -QString KGpgMe::checkForUtf8(QString txt) +TQString KGpgMe::checkForUtf8(TQString txt) { // code borrowed from KGpg which borrowed it from gpa const char *s; @@ -151,34 +151,34 @@ QString KGpgMe::checkForUtf8(QString txt) // Make sure the encoding is UTF-8. // Test structure suggested by Werner Koch if(txt.isEmpty()) - return QString::null; + return TQString(); for(s = txt.ascii(); *s && !(*s & 0x80); s++) ; - if (*s && !strchr (txt.ascii(), 0xc3) && (txt.find("\\x")==-1)) + if (*s && !strchr (txt.ascii(), 0xc3) && (txt.tqfind("\\x")==-1)) return txt; // The string is not in UTF-8 //if (strchr (txt.ascii(), 0xc3)) return (txt+" +++"); - if (txt.find("\\x")==-1) - return QString::fromUtf8(txt.ascii()); - // if (!strchr (txt.ascii(), 0xc3) || (txt.find("\\x")!=-1)) { - for(int idx = 0 ; (idx = txt.find( "\\x", idx )) >= 0 ; ++idx) { + if (txt.tqfind("\\x")==-1) + return TQString::fromUtf8(txt.ascii()); + // if (!strchr (txt.ascii(), 0xc3) || (txt.tqfind("\\x")!=-1)) { + for(int idx = 0 ; (idx = txt.tqfind( "\\x", idx )) >= 0 ; ++idx) { char str[2] = "x"; - str[0] = (char)QString(txt.mid(idx + 2, 2)).toShort(0, 16); - txt.replace(idx, 4, str); + str[0] = (char)TQString(txt.mid(idx + 2, 2)).toShort(0, 16); + txt.tqreplace(idx, 4, str); } if (!strchr (txt.ascii(), 0xc3)) - return QString::fromUtf8(txt.ascii()); + return TQString::fromUtf8(txt.ascii()); else - return QString::fromUtf8(QString::fromUtf8(txt.ascii()).ascii()); + return TQString::fromUtf8(TQString::fromUtf8(txt.ascii()).ascii()); // perform Utf8 twice, or some keys display badly return txt; } -QString KGpgMe::selectKey(QString previous) +TQString KGpgMe::selectKey(TQString previous) { - KGpgSelKey dlg(kapp->activeWindow(), "", previous, *this); + KGpgSelKey dlg(TQT_TQWIDGET(kapp->activeWindow()), "", previous, *this); if(dlg.exec()) return dlg.key(); @@ -220,21 +220,21 @@ KGpgKeyList KGpgMe::keys(bool privateKeys /* = false */) const } if(err) { - KMessageBox::error(kapp->activeWindow(), QString("%1: %2") - .arg(gpgme_strsource(err)).arg(gpgme_strerror(err))); + KMessageBox::error(TQT_TQWIDGET(kapp->activeWindow()), TQString("%1: %2") + .tqarg(gpgme_strsource(err)).tqarg(gpgme_strerror(err))); } else { result = gpgme_op_keylist_result(m_ctx); if (result->truncated) { - KMessageBox::error(kapp->activeWindow(), + KMessageBox::error(TQT_TQWIDGET(kapp->activeWindow()), i18n("Key listing unexpectedly truncated.")); } } return keys; } -bool KGpgMe::encrypt(const QByteArray& inBuffer, Q_ULONG length, - QByteArray* outBuffer, QString keyid /* = QString::null */) +bool KGpgMe::encrypt(const TQByteArray& inBuffer, TQ_ULONG length, + TQByteArray* outBuffer, TQString keyid /* = TQString() */) { gpgme_error_t err = 0; gpgme_data_t in = 0, out = 0; @@ -262,9 +262,9 @@ bool KGpgMe::encrypt(const QByteArray& inBuffer, Q_ULONG length, if(!err) { result = gpgme_op_encrypt_result(m_ctx); if (result->invalid_recipients) { - KMessageBox::error(kapp->activeWindow(), QString("%1: %2") - .arg(i18n("That public key is not meant for encryption")) - .arg(result->invalid_recipients->fpr)); + KMessageBox::error(TQT_TQWIDGET(kapp->activeWindow()), TQString("%1: %2") + .tqarg(i18n("That public key is not meant for encryption")) + .tqarg(result->invalid_recipients->fpr)); } else { err = readToBuffer(out, outBuffer); @@ -275,8 +275,8 @@ bool KGpgMe::encrypt(const QByteArray& inBuffer, Q_ULONG length, } } if(err != GPG_ERR_NO_ERROR && err != GPG_ERR_CANCELED) { - KMessageBox::error(kapp->activeWindow(), QString("%1: %2") - .arg(gpgme_strsource(err)).arg(gpgme_strerror(err))); + KMessageBox::error(TQT_TQWIDGET(kapp->activeWindow()), TQString("%1: %2") + .tqarg(gpgme_strsource(err)).tqarg(gpgme_strerror(err))); } if(err != GPG_ERR_NO_ERROR) clearCache(); @@ -289,7 +289,7 @@ bool KGpgMe::encrypt(const QByteArray& inBuffer, Q_ULONG length, return (err == GPG_ERR_NO_ERROR); } -bool KGpgMe::decrypt(const QByteArray& inBuffer, QByteArray* outBuffer) +bool KGpgMe::decrypt(const TQByteArray& inBuffer, TQByteArray* outBuffer) { gpgme_error_t err = 0; gpgme_data_t in = 0, out = 0; @@ -305,9 +305,9 @@ bool KGpgMe::decrypt(const QByteArray& inBuffer, QByteArray* outBuffer) if(!err) { result = gpgme_op_decrypt_result(m_ctx); if(result->unsupported_algorithm) { - KMessageBox::error(kapp->activeWindow(), QString("%1: %2") - .arg(i18n("Unsupported algorithm")) - .arg(result->unsupported_algorithm)); + KMessageBox::error(TQT_TQWIDGET(kapp->activeWindow()), TQString("%1: %2") + .tqarg(i18n("Unsupported algorithm")) + .tqarg(result->unsupported_algorithm)); } else { err = readToBuffer(out, outBuffer); @@ -317,8 +317,8 @@ bool KGpgMe::decrypt(const QByteArray& inBuffer, QByteArray* outBuffer) } } if(err != GPG_ERR_NO_ERROR && err != GPG_ERR_CANCELED) { - KMessageBox::error(kapp->activeWindow(), QString("%1: %2") - .arg(gpgme_strsource(err)).arg(gpgme_strerror(err))); + KMessageBox::error(TQT_TQWIDGET(kapp->activeWindow()), TQString("%1: %2") + .tqarg(gpgme_strsource(err)).tqarg(gpgme_strerror(err))); } if(err != GPG_ERR_NO_ERROR) clearCache(); @@ -331,7 +331,7 @@ bool KGpgMe::decrypt(const QByteArray& inBuffer, QByteArray* outBuffer) #define BUF_SIZE (32 * 1024) -gpgme_error_t KGpgMe::readToBuffer(gpgme_data_t in, QByteArray* outBuffer) const +gpgme_error_t KGpgMe::readToBuffer(gpgme_data_t in, TQByteArray* outBuffer) const { int ret; gpgme_error_t err = GPG_ERR_NO_ERROR; @@ -346,7 +346,7 @@ gpgme_error_t KGpgMe::readToBuffer(gpgme_data_t in, QByteArray* outBuffer) const if(buf) { while((ret = gpgme_data_read(in, buf, BUF_SIZE)) > 0) { uint size = outBuffer->size(); - if(outBuffer->resize(size + ret)) + if(outBuffer->tqresize(size + ret)) memcpy(outBuffer->data() + size, buf, ret); } if(ret < 0) @@ -359,9 +359,9 @@ gpgme_error_t KGpgMe::readToBuffer(gpgme_data_t in, QByteArray* outBuffer) const bool KGpgMe::isGnuPGAgentAvailable() { - QString agent_info = getenv("GPG_AGENT_INFO"); + TQString agent_info = getenv("GPG_AGENT_INFO"); - if (agent_info.find(':') > 0) + if (agent_info.tqfind(':') > 0) return true; return false; } @@ -369,13 +369,13 @@ bool KGpgMe::isGnuPGAgentAvailable() void KGpgMe::setPassphraseCb() { bool agent = false; - QString agent_info; + TQString agent_info; agent_info = getenv("GPG_AGENT_INFO"); if(m_useGnuPGAgent) { - if (agent_info.find(':')) + if (agent_info.tqfind(':')) agent = true; if(agent_info.startsWith("disable:")) setenv("GPG_AGENT_INFO", agent_info.mid(8), 1); @@ -404,8 +404,8 @@ gpgme_error_t KGpgMe::passphrase(const char* uid_hint, int last_was_bad, int fd) { gpgme_error_t res = GPG_ERR_CANCELED; - QString s; - QString gpg_hint = checkForUtf8(uid_hint); + TQString s; + TQString gpg_hint = checkForUtf8(uid_hint); int result; if(last_was_bad){ @@ -420,7 +420,7 @@ gpgme_error_t KGpgMe::passphrase(const char* uid_hint, s += gpg_hint; if(m_cache.isEmpty()){ - QCString password; + TQCString password; if(m_saving) result = KPasswordDialog::getNewPassword(password, s); |