diff options
author | ubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2008-08-10 12:31:25 +0000 |
---|---|---|
committer | ubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2008-08-10 12:31:25 +0000 |
commit | bc7f67698de453ccffadc59f823632acba852798 (patch) | |
tree | fe85f84f876e25743d3bbb6679e1bf8132d2e73c | |
parent | some source-beatyfying with astyle, use absolute path to find icons (diff) | |
download | gpg4usb-bc7f67698de453ccffadc59f823632acba852798.tar.gz gpg4usb-bc7f67698de453ccffadc59f823632acba852798.zip |
source beutyfication with astyle, following http://techbase.kde.org/Policies/Kdelibs_Coding_Style
git-svn-id: http://cpunk.de/svn/src/gpg4usb@121 34ebc366-c3a9-4b3c-9f84-69acf7962910
-rw-r--r-- | context.cpp | 424 | ||||
-rw-r--r-- | context.h | 31 | ||||
-rw-r--r-- | gpgwin.cpp | 13 | ||||
-rw-r--r-- | keylist.cpp | 14 | ||||
-rw-r--r-- | keylist.h | 21 | ||||
-rw-r--r-- | main.cpp | 2 |
6 files changed, 253 insertions, 252 deletions
diff --git a/context.cpp b/context.cpp index dd864bf..67e931b 100644 --- a/context.cpp +++ b/context.cpp @@ -19,13 +19,13 @@ * MA 02110-1301, USA. */ -#include "context.h" #include <locale.h> #include <sstream> #include <QApplication> #include <QtGui> #include <QMessageBox> #include <errno.h> +#include "context.h" #ifdef _WIN32 #include <windows.h> @@ -33,34 +33,36 @@ #endif -namespace GpgME { +namespace GpgME +{ - /** Constructor - * Set up gpgme-context, set paths to app-run path - */ - Context::Context( ) { +/** Constructor + * Set up gpgme-context, set paths to app-run path + */ +Context::Context() +{ - /** get current dir */ + /** get application path */ QString appPath = qApp->applicationDirPath(); /** The function `gpgme_check_version' must be called before any other * function in the library, because it initializes the thread support * subsystem in GPGME. (from the info page) */ - gpgme_check_version (NULL); + gpgme_check_version(NULL); - setlocale (LC_ALL, ""); + setlocale(LC_ALL, ""); /** set locale, because tests do also */ - gpgme_set_locale (NULL, LC_CTYPE, setlocale (LC_CTYPE, NULL)); + gpgme_set_locale(NULL, LC_CTYPE, setlocale(LC_CTYPE, NULL)); #ifndef _WIN32 - gpgme_set_locale (NULL, LC_MESSAGES, setlocale (LC_MESSAGES, NULL)); + gpgme_set_locale(NULL, LC_MESSAGES, setlocale(LC_MESSAGES, NULL)); #endif - err = gpgme_new ( &m_ctx ); + err = gpgme_new(&m_ctx); checkErr(err); - /** here come the settings, instead of /usr/bin/gpg - * a executable in the same path as app is used. - * also lin/win must be checked, for calling gpg.exe if needed - */ + /** here come the settings, instead of /usr/bin/gpg + * a executable in the same path as app is used. + * also lin/win must be checked, for calling gpg.exe if needed + */ #ifdef _WIN32 QString gpgBin = appPath + "\bin\gpg.exe"; QString gpgKeys = appPath + "\keydb"; @@ -70,124 +72,130 @@ namespace GpgME { QString gpgBin = appPath + "/bin/gpg"; QString gpgKeys = appPath + "/keydb"; /*err = gpgme_ctx_set_engine_info (m_ctx, GPGME_PROTOCOL_OpenPGP, - "./bin/gpg", "./keydb");*/ + "./bin/gpg", "./keydb");*/ #endif - err = gpgme_ctx_set_engine_info (m_ctx, GPGME_PROTOCOL_OpenPGP, - gpgBin.toAscii().constData(), gpgKeys.toAscii().constData()); + err = gpgme_ctx_set_engine_info(m_ctx, GPGME_PROTOCOL_OpenPGP, + gpgBin.toAscii().constData(), + gpgKeys.toAscii().constData()); checkErr(err); /** Setting the output type must be done at the beginning */ /** think this means ascii-amor --> ? */ - gpgme_set_armor (m_ctx, 1); + gpgme_set_armor(m_ctx, 1); /** passphrase-callback */ gpgme_set_passphrase_cb(m_ctx, passphraseCb, this); /** check if app is called with -d from command line */ - if(qApp->arguments().contains("-d")) { - qDebug() << "gpgme_data_t debug on"; - debug = true; + if (qApp->arguments().contains("-d")) { + qDebug() << "gpgme_data_t debug on"; + debug = true; } else { - debug = false; + debug = false; } - } +} - /** Destructor - * Release gpgme-context - */ - Context::~Context() { - if ( m_ctx ) gpgme_release( m_ctx ); +/** Destructor + * Release gpgme-context + */ +Context::~Context() +{ + if (m_ctx) gpgme_release(m_ctx); m_ctx = 0; - } +} - /** Import Key from QByteArray - * - */ - void Context::importKey(QByteArray inBuffer) { - err = gpgme_data_new_from_mem (&in, inBuffer.data(), inBuffer.size(), 1); +/** Import Key from QByteArray + * + */ +void Context::importKey(QByteArray inBuffer) +{ + err = gpgme_data_new_from_mem(&in, inBuffer.data(), inBuffer.size(), 1); checkErr(err); - err = gpgme_op_import (m_ctx, in); + err = gpgme_op_import(m_ctx, in); checkErr(err); - gpgme_data_release (in); - } + gpgme_data_release(in); +} - /** List all availabe Keys (VERY much like kgpgme) - */ - GpgKeyList Context::listKeys() { +/** List all availabe Keys (VERY much like kgpgme) + */ +GpgKeyList Context::listKeys() +{ gpgme_error_t err; gpgme_key_t key; GpgKeyList keys; //TODO dont run the loop more often than necessary // list all keys ( the 0 is for all ) - err = gpgme_op_keylist_start (m_ctx, NULL, 0); + err = gpgme_op_keylist_start(m_ctx, NULL, 0); checkErr(err); - while (!(err = gpgme_op_keylist_next (m_ctx, &key))) { - GpgKey gpgkey; + while (!(err = gpgme_op_keylist_next(m_ctx, &key))) { + GpgKey gpgkey; - if(!key->subkeys) - continue; + if (!key->subkeys) + continue; - gpgkey.id = key->subkeys->keyid; + gpgkey.id = key->subkeys->keyid; - if(key->uids) { - gpgkey.name = key->uids->name; - gpgkey.email = key->uids->email; - } - keys.append(gpgkey); - gpgme_key_unref(key); + if (key->uids) { + gpgkey.name = key->uids->name; + gpgkey.email = key->uids->email; + } + keys.append(gpgkey); + gpgme_key_unref(key); } gpgme_op_keylist_end(m_ctx); // list only private keys ( the 1 does ) - gpgme_op_keylist_start (m_ctx, NULL, 1); - while (!(err = gpgme_op_keylist_next (m_ctx, &key))) { - if(!key->subkeys) - continue; - // iterate keys, mark privates - GpgKeyList::iterator it = keys.begin(); - while (it != keys.end()) { - if(key->subkeys->keyid == it->id.toStdString()) - it->privkey = 1; - it++; - } - - gpgme_key_unref(key); + gpgme_op_keylist_start(m_ctx, NULL, 1); + while (!(err = gpgme_op_keylist_next(m_ctx, &key))) { + if (!key->subkeys) + continue; + // iterate keys, mark privates + GpgKeyList::iterator it = keys.begin(); + while (it != keys.end()) { + if (key->subkeys->keyid == it->id.toStdString()) + it->privkey = 1; + it++; + } + + gpgme_key_unref(key); } gpgme_op_keylist_end(m_ctx); return keys; - } +} - /** Delete keys - */ +/** Delete keys + */ - void Context::deleteKeys(QList<QString> *uidList) { +void Context::deleteKeys(QList<QString> *uidList) +{ QString tmp; gpgme_key_t key; - foreach( tmp, *uidList ) { - gpgme_op_keylist_start(m_ctx, tmp.toAscii().constData(), 0); - gpgme_op_keylist_next(m_ctx, &key); - gpgme_op_keylist_end(m_ctx); - gpgme_op_delete(m_ctx, key, 1); + foreach(tmp, *uidList) { + gpgme_op_keylist_start(m_ctx, tmp.toAscii().constData(), 0); + gpgme_op_keylist_next(m_ctx, &key); + gpgme_op_keylist_end(m_ctx); + gpgme_op_delete(m_ctx, key, 1); } - } +} - /** Encrypt String, return String - * should also use QByteArray, so be removed - * in should be std::vector<key> & recipients (703 in context.cpp) - */ - bool Context::encrypt(QList<QString> *uidList, const QByteArray& inBuffer, QByteArray* outBuffer){ +/** Encrypt String, return String + * should also use QByteArray, so be removed + * in should be std::vector<key> & recipients (703 in context.cpp) + */ +bool Context::encrypt(QList<QString> *uidList, const QByteArray &inBuffer, QByteArray *outBuffer) +{ gpgme_data_t in = 0, out = 0; outBuffer->resize(0); - if(uidList->count()==0) { - QMessageBox::critical(0, "No Key Selected", "No Key Selected"); - return false; + if (uidList->count() == 0) { + QMessageBox::critical(0, "No Key Selected", "No Key Selected"); + return false; } //gpgme_encrypt_result_t e_result; @@ -195,21 +203,21 @@ namespace GpgME { /* get key for user */ for (int i = 0; i < uidList->count(); i++) { - // the last 0 is for public keys, 1 would return private keys - gpgme_op_keylist_start(m_ctx, uidList->at(i).toAscii().constData(), 0); - gpgme_op_keylist_next(m_ctx, &recipients[i]); - gpgme_op_keylist_end(m_ctx); + // the last 0 is for public keys, 1 would return private keys + gpgme_op_keylist_start(m_ctx, uidList->at(i).toAscii().constData(), 0); + gpgme_op_keylist_next(m_ctx, &recipients[i]); + gpgme_op_keylist_end(m_ctx); } //Last entry in array has to be NULL recipients[uidList->count()] = NULL; - //If the last parameter isnt 0, a private copy of data is made - err = gpgme_data_new_from_mem (&in, inBuffer.data(), inBuffer.size(), 1); + //If the last parameter isnt 0, a private copy of data is made + err = gpgme_data_new_from_mem(&in, inBuffer.data(), inBuffer.size(), 1); checkErr(err); - err = gpgme_data_new (&out); + err = gpgme_data_new(&out); checkErr(err); - err = gpgme_op_encrypt (m_ctx, recipients, GPGME_ENCRYPT_ALWAYS_TRUST, in, out); + err = gpgme_op_encrypt(m_ctx, recipients, GPGME_ENCRYPT_ALWAYS_TRUST, in, out); checkErr(err); err = readToBuffer(out, outBuffer); @@ -217,173 +225,171 @@ namespace GpgME { /* unref all keys */ for (int i = 0; i <= uidList->count(); i++) { - gpgme_key_unref (recipients[i]); + gpgme_key_unref(recipients[i]); } - gpgme_data_release (in); - gpgme_data_release (out); + gpgme_data_release(in); + gpgme_data_release(out); return true; - } +} - /** Decrypt QByteAarray, return QByteArray - * from http://basket.kde.org/ (kgpgme.cpp) - */ - bool Context::decrypt(const QByteArray& inBuffer, QByteArray* outBuffer) - { +/** Decrypt QByteAarray, return QByteArray + * mainly from http://basket.kde.org/ (kgpgme.cpp) + */ +bool Context::decrypt(const QByteArray &inBuffer, QByteArray *outBuffer) +{ gpgme_data_t in = 0, out = 0; gpgme_decrypt_result_t result = 0; outBuffer->resize(0); - if(m_ctx) { - err = gpgme_data_new_from_mem(&in, inBuffer.data(), inBuffer.size(), 1); - checkErr(err); - if(!err) { - err = gpgme_data_new(&out); + if (m_ctx) { + err = gpgme_data_new_from_mem(&in, inBuffer.data(), inBuffer.size(), 1); checkErr(err); - if(!err) { - err = gpgme_op_decrypt(m_ctx, in, out); - checkErr(err); - if(!err) { - result = gpgme_op_decrypt_result(m_ctx); - if(result->unsupported_algorithm) { - QMessageBox::critical(0,"Unsupported algorithm", result->unsupported_algorithm); + if (!err) { + err = gpgme_data_new(&out); + checkErr(err); + if (!err) { + err = gpgme_op_decrypt(m_ctx, in, out); + checkErr(err); + if (!err) { + result = gpgme_op_decrypt_result(m_ctx); + if (result->unsupported_algorithm) { + QMessageBox::critical(0, "Unsupported algorithm", result->unsupported_algorithm); + } else { + err = readToBuffer(out, outBuffer); + checkErr(err); + } + } } - else { - err = readToBuffer(out, outBuffer); - checkErr(err); - } - } } - } } - if(err != GPG_ERR_NO_ERROR && err != GPG_ERR_CANCELED) { - QMessageBox::critical(0, "Error encrypting:", gpgme_strerror(err)); + if (err != GPG_ERR_NO_ERROR && err != GPG_ERR_CANCELED) { + QMessageBox::critical(0, "Error encrypting:", gpgme_strerror(err)); } - if(err != GPG_ERR_NO_ERROR) - clearCache(); - if(in) - gpgme_data_release(in); - if(out) - gpgme_data_release(out); + if (err != GPG_ERR_NO_ERROR) + clearCache(); + if (in) + gpgme_data_release(in); + if (out) + gpgme_data_release(out); return (err == GPG_ERR_NO_ERROR); - } - - /** Read gpgme-Data to QByteArray - * mainly from http://basket.kde.org/ (kgpgme.cpp) - * maybe const ? - */ - #define BUF_SIZE (32 * 1024) - gpgme_error_t Context::readToBuffer(gpgme_data_t in, QByteArray* outBuffer) - { +} + +/** Read gpgme-Data to QByteArray + * mainly from http://basket.kde.org/ (kgpgme.cpp) + */ +#define BUF_SIZE (32 * 1024) +gpgme_error_t Context::readToBuffer(gpgme_data_t in, QByteArray *outBuffer) +{ int ret; gpgme_error_t err = GPG_ERR_NO_ERROR; ret = gpgme_data_seek(in, 0, SEEK_SET); - if(ret) { - err = gpgme_err_code_from_errno(errno); - checkErr(err, "failed dataseek in readToBuffer"); - } else { - char *buf = new char[BUF_SIZE + 2]; - - if(buf) { - while((ret = gpgme_data_read(in, buf, BUF_SIZE)) > 0) { - uint size = outBuffer->size(); - outBuffer->resize(size + ret); - memcpy(outBuffer->data() + size, buf, ret); - } - if(ret < 0) { - err = gpgme_err_code_from_errno(errno); - checkErr(err, "failed data_read in readToBuffer"); + if (ret) { + err = gpgme_err_code_from_errno(errno); + checkErr(err, "failed dataseek in readToBuffer"); + } else { + char *buf = new char[BUF_SIZE + 2]; + + if (buf) { + while ((ret = gpgme_data_read(in, buf, BUF_SIZE)) > 0) { + uint size = outBuffer->size(); + outBuffer->resize(size + ret); + memcpy(outBuffer->data() + size, buf, ret); + } + if (ret < 0) { + err = gpgme_err_code_from_errno(errno); + checkErr(err, "failed data_read in readToBuffer"); + } + delete[] buf; } - delete[] buf; - } } return err; - } - - /** The Passphrase window, if not provided by env-Var GPG_AGENT_INFO - * Copied from http://basket.kde.org/ (kgpgme.cpp) - */ - gpgme_error_t Context::passphraseCb(void* hook, const char* uid_hint, - const char* passphrase_info, - int last_was_bad, int fd) - { - Context* gpg = static_cast<Context*>(hook); +} + +/** The Passphrase window, if not provided by env-Var GPG_AGENT_INFO + * originally copied from http://basket.kde.org/ (kgpgme.cpp), but modified + */ +gpgme_error_t Context::passphraseCb(void *hook, const char *uid_hint, + const char *passphrase_info, + int last_was_bad, int fd) +{ + Context *gpg = static_cast<Context*>(hook); return gpg->passphrase(uid_hint, passphrase_info, last_was_bad, fd); - } +} - gpgme_error_t Context::passphrase(const char* uid_hint, - const char* /*passphrase_info*/, - int last_was_bad, int fd) - { +gpgme_error_t Context::passphrase(const char *uid_hint, + const char * /*passphrase_info*/, + int last_was_bad, int fd) +{ gpgme_error_t res = GPG_ERR_CANCELED; QString s; QString gpg_hint = uid_hint; bool result; - if(last_was_bad){ - s += "<i>Wrong password.</i><br><br>\n\n"; - clearCache(); + if (last_was_bad) { + s += "<i>Wrong password.</i><br><br>\n\n"; + clearCache(); } /** if uid provided */ - if(!gpg_hint.isEmpty()) { - // remove UID, leave only username & email - gpg_hint.remove(0, gpg_hint.indexOf(" ")); - s += "<b>Enter Password for</b><br>\n" + gpg_hint + "\n"; + if (!gpg_hint.isEmpty()) { + // remove UID, leave only username & email + gpg_hint.remove(0, gpg_hint.indexOf(" ")); + s += "<b>Enter Password for</b><br>\n" + gpg_hint + "\n"; } - if(m_cache.isEmpty()){ - QString password = QInputDialog::getText(0, "Enter Password", - s, QLineEdit::Password, - "", &result); + if (m_cache.isEmpty()) { + QString password = QInputDialog::getText(0, "Enter Password", + s, QLineEdit::Password, + "", &result); - if(result == 1) m_cache = password.toAscii(); - } - else - result = 0; + if (result == 1) m_cache = password.toAscii(); + } else + result = 0; - if(result == 1) { + if (result == 1) { #ifndef _WIN32 - write(fd, m_cache.data(), m_cache.length()); + write(fd, m_cache.data(), m_cache.length()); #else - DWORD written; - WriteFile ((HANDLE) fd, m_cache.data(), m_cache.length(), &written, 0); + DWORD written; + WriteFile((HANDLE) fd, m_cache.data(), m_cache.length(), &written, 0); #endif - res = 0; + res = 0; } #ifndef _WIN32 write(fd, "\n", 1); #else DWORD written; - WriteFile ((HANDLE) fd, "\n", 1, &written, 0); + WriteFile((HANDLE) fd, "\n", 1, &written, 0); #endif return res; - } - - /** also from kgpgme.cpp, seems to clear password from mem */ - void Context::clearCache() - { - if(m_cache.size() > 0) - { - m_cache.fill('\0'); - m_cache.truncate(0); +} + +/** also from kgpgme.cpp, seems to clear password from mem */ +void Context::clearCache() +{ + if (m_cache.size() > 0) { + m_cache.fill('\0'); + m_cache.truncate(0); } - } +} - // error-handling - void Context::checkErr(gpgme_error_t err, QString comment) const { - if(err != GPG_ERR_NO_ERROR && err != GPG_ERR_CANCELED) { - qDebug() << "[Error " << comment << "] Source: " << gpgme_strsource(err) << " String: " << gpgme_strerror(err); +// error-handling +void Context::checkErr(gpgme_error_t err, QString comment) const +{ + if (err != GPG_ERR_NO_ERROR && err != GPG_ERR_CANCELED) { + qDebug() << "[Error " << comment << "] Source: " << gpgme_strsource(err) << " String: " << gpgme_strerror(err); } - } +} - void Context::checkErr(gpgme_error_t err) const { - if(err != GPG_ERR_NO_ERROR && err != GPG_ERR_CANCELED) { - qDebug() << "[Error] Source: " << gpgme_strsource(err) << " String: " << gpgme_strerror(err); +void Context::checkErr(gpgme_error_t err) const +{ + if (err != GPG_ERR_NO_ERROR && err != GPG_ERR_CANCELED) { + qDebug() << "[Error] Source: " << gpgme_strsource(err) << " String: " << gpgme_strerror(err); } - } +} } @@ -29,21 +29,22 @@ class GpgKey { - public: +public: QString id; QString name; QString email; int privkey; - //bool privkey; }; typedef QLinkedList< GpgKey > GpgKeyList; -namespace GpgME { +namespace GpgME +{ - class Context { +class Context +{ - public: +public: Context(); // Consttructor ~Context(); // Destructor @@ -51,29 +52,29 @@ namespace GpgME { void importKey(QByteArray inBuffer); GpgKeyList listKeys(); void deleteKeys(QList<QString> *uidList); - bool encrypt(QList<QString> *uidList, const QByteArray& inBuffer, QByteArray* outBuffer); - - bool decrypt(const QByteArray& inBuffer, QByteArray* outBuffer); + bool encrypt(QList<QString> *uidList, const QByteArray &inBuffer, + QByteArray *outBuffer); + bool decrypt(const QByteArray &inBuffer, QByteArray *outBuffer); void clearCache(); - private: +private: gpgme_ctx_t m_ctx; gpgme_data_t in, out; gpgme_error_t err; - gpgme_error_t readToBuffer(gpgme_data_t in, QByteArray* outBuffer); + gpgme_error_t readToBuffer(gpgme_data_t in, QByteArray *outBuffer); QByteArray m_cache; bool debug; void checkErr(gpgme_error_t err) const; void checkErr(gpgme_error_t err, QString comment) const; static gpgme_error_t passphraseCb(void *hook, const char *uid_hint, - const char *passphrase_info, - int last_was_bad, int fd); + const char *passphrase_info, + int last_was_bad, int fd); gpgme_error_t passphrase(const char *uid_hint, - const char *passphrase_info, - int last_was_bad, int fd); + const char *passphrase_info, + int last_was_bad, int fd); - }; +}; } // namespace GpgME #endif // __SGPGMEPP_CONTEXT_H__ @@ -303,11 +303,6 @@ bool GpgWin::maybeSave() bool GpgWin::saveFile(const QString &fileName) { - /*QString fileName = QFileDialog::getSaveFileName(this, - tr("Choose a file name"), ".", - tr("Text (*.txt)","All (*)")); - if (fileName.isEmpty()) - return false;*/ QFile file(fileName); if (!file.open(QFile::WriteOnly | QFile::Text)) { QMessageBox::warning(this, tr("File"), @@ -362,7 +357,7 @@ void GpgWin::encrypt() QList<QString> *uidList = m_keyList->getChecked(); QByteArray *tmp = new QByteArray(); - if ( myCtx->encrypt(uidList, edit->toPlainText().toAscii(), tmp) ) { + if (myCtx->encrypt(uidList, edit->toPlainText().toAscii(), tmp)) { QString *tmp2 = new QString(*tmp); edit->setPlainText(*tmp2); } @@ -373,7 +368,7 @@ void GpgWin::decrypt() { QByteArray *tmp = new QByteArray(); myCtx->decrypt(edit->toPlainText().toAscii(), tmp); - if (!tmp->isEmpty()){ + if (!tmp->isEmpty()) { QString *tmp2 = new QString(*tmp); edit->setPlainText(*tmp2); } @@ -388,12 +383,12 @@ void GpgWin::importKeyFromEdit() void GpgWin::importKeyFromFile() { - QString fileName = QFileDialog::getOpenFileName(this,tr("Open Key"),"", tr("Key Files")+" (*.asc *.txt);;All Files (*.*)"); + QString fileName = QFileDialog::getOpenFileName(this, tr("Open Key"), "", tr("Key Files") + " (*.asc *.txt);;All Files (*.*)"); if (! fileName.isNull()) { QFile file; file.setFileName(fileName); if (!file.open(QIODevice::ReadOnly)) { - qDebug() << tr("couldn't open file: ")+fileName; + qDebug() << tr("couldn't open file: ") + fileName; } QByteArray inBuffer = file.readAll(); diff --git a/keylist.cpp b/keylist.cpp index 9580bb7..710afc7 100644 --- a/keylist.cpp +++ b/keylist.cpp @@ -33,7 +33,7 @@ KeyList::KeyList(QWidget *parent) m_idList = new QList<QString>(); m_deleteButton = new QPushButton(tr("Delete Selected Keys")); - connect(m_deleteButton, SIGNAL(clicked()), this, SLOT( deleteKeys() ) ); + connect(m_deleteButton, SIGNAL(clicked()), this, SLOT(deleteKeys())); QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(m_keyList); @@ -49,7 +49,7 @@ void KeyList::setContext(GpgME::Context *ctx) refresh(); } -void KeyList::setIconPath( QString path ) +void KeyList::setIconPath(QString path) { this->iconPath = path; } @@ -70,10 +70,10 @@ void KeyList::refresh() GpgKeyList::iterator it = keys.begin(); while (it != keys.end()) { QListWidgetItem *tmp = new QListWidgetItem( - it->name + " <" + it->email +">" + it->name + " <" + it->email + ">" ); - tmp->setFlags( Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable ); - tmp->setCheckState( Qt::Unchecked ); + tmp->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable); + tmp->setCheckState(Qt::Unchecked); if (it->privkey == 1) tmp->setIcon(QIcon(iconPath + "kgpg_key2.png")); m_keyList->addItem(tmp); @@ -83,7 +83,7 @@ void KeyList::refresh() } -QList<QString>* KeyList::getChecked() +QList<QString> *KeyList::getChecked() { QList<QString> *ret = new QList<QString>(); for (int i = 0; i < m_keyList->count(); i++) { @@ -94,7 +94,7 @@ QList<QString>* KeyList::getChecked() return ret; } -QList<QString>* KeyList::getSelected() +QList<QString> *KeyList::getSelected() { QList<QString> *ret = new QList<QString>(); for (int i = 0; i < m_keyList->count(); i++) { @@ -23,25 +23,25 @@ #include <QPushButton> #include "context.h" - class QMenu; +class QMenu; class KeyList : public QWidget { - Q_OBJECT + Q_OBJECT - public slots: - void deleteKeys(); - void deleteKey(); +public slots: + void deleteKeys(); + void deleteKey(); - public: +public: KeyList(QWidget *parent = 0); void setContext(GpgME::Context *ctx); void setIconPath(QString iconPath); - QList<QString>* getChecked(); - QList<QString>* getSelected(); + QList<QString> *getChecked(); + QList<QString> *getSelected(); void refresh(); - private: +private: GpgME::Context *m_ctx; QListWidget *m_keyList; QList<QString> *m_idList; @@ -50,7 +50,6 @@ class KeyList : public QWidget void createActions(); QString iconPath; - - protected: +protected: void contextMenuEvent(QContextMenuEvent *event); }; @@ -36,7 +36,7 @@ int main(int argc, char *argv[]) //internationalize QString locale = QLocale::system().name(); QTranslator translator; - translator.load(QString("ts/gpg4usb_") + locale ); + translator.load(QString("ts/gpg4usb_") + locale); app.installTranslator(&translator); GpgWin *window = new GpgWin(); |