diff options
author | ubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2012-08-01 20:59:46 +0000 |
---|---|---|
committer | ubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2012-08-01 20:59:46 +0000 |
commit | 797de0bf290820e0f5512a8fb6ad794876aa470f (patch) | |
tree | 0edccbe43bf9212e99d1da84726dc5e4f2921b8e | |
parent | branch 0.3.2-mac (diff) | |
download | gpg4usb-797de0bf290820e0f5512a8fb6ad794876aa470f.tar.gz gpg4usb-797de0bf290820e0f5512a8fb6ad794876aa470f.zip |
start removing gpgme
git-svn-id: http://cpunk.de/svn/src/gpg4usb/branches/0.3.2-mac@920 34ebc366-c3a9-4b3c-9f84-69acf7962910
-rw-r--r-- | gpg4usb.pro | 14 | ||||
-rw-r--r-- | gpgcontext.cpp | 86 | ||||
-rw-r--r-- | main.cpp | 4 | ||||
-rw-r--r-- | mainwindow.cpp | 1 | ||||
-rwxr-xr-x | release/bin/gpg-mac | bin | 0 -> 2714192 bytes |
5 files changed, 39 insertions, 66 deletions
diff --git a/gpg4usb.pro b/gpg4usb.pro index ed58560..d621071 100644 --- a/gpg4usb.pro +++ b/gpg4usb.pro @@ -13,8 +13,8 @@ INCLUDEPATH += . \ #DEFINES += GPG4USB_NON_PORTABLE -#CONFIG += release static -CONFIG += debug +CONFIG += release static +#CONFIG += release QT += network # Input HEADERS += attachments.h \ @@ -39,6 +39,7 @@ HEADERS += attachments.h \ verifykeydetailbox.h \ wizard.h \ helppage.h \ +# gpgproc.h \ gpgconstants.h SOURCES += attachments.cpp \ @@ -64,6 +65,7 @@ SOURCES += attachments.cpp \ verifykeydetailbox.cpp \ wizard.cpp \ helppage.cpp \ +# gpgproc.cpp \ gpgconstants.cpp RC_FILE = gpg4usb.rc @@ -71,12 +73,12 @@ RC_FILE = gpg4usb.rc RESOURCES = gpg4usb.qrc # comment out line below for static building -LIBS += -lgpgme \ - -lgpg-error \ +#LIBS += -lgpgme \ +# -lgpg-error \ # comment in for static buildding in windows -#INCLUDEPATH += ./winbuild/include -#LIBS +=./winbuild/lib/libgpgme.a ./winbuild/lib/libgpg-error.a +INCLUDEPATH += ./macbuild/include +LIBS +=./macbuild/lib/libgpgme.a ./macbuild/lib/libgpg-error.a DEFINES += _FILE_OFFSET_BITS=64 diff --git a/gpgcontext.cpp b/gpgcontext.cpp index 2eef101..251d372 100644 --- a/gpgcontext.cpp +++ b/gpgcontext.cpp @@ -41,60 +41,34 @@ GpgContext::GpgContext() /** 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); - // TODO: Set gpgme_language to config - /*QSettings settings; - qDebug() << " - " << settings.value("int/lang").toLocale().name(); - qDebug() << " - " << QLocale(settings.value("int/lang").toString()).name();*/ - - // the locale set here is used for the other setlocale calls which have NULL - // -> NULL means use default, which is configured here - setlocale(LC_ALL, ""); - - /** set locale, because tests do also */ - gpgme_set_locale(NULL, LC_CTYPE, setlocale(LC_CTYPE, NULL)); - //qDebug() << "Locale set to" << LC_CTYPE << " - " << setlocale(LC_CTYPE, NULL); -#ifndef _WIN32 - gpgme_set_locale(NULL, LC_MESSAGES, setlocale(LC_MESSAGES, NULL)); +#ifdef Q_WS_WIN + QString gpgBin = appPath + "/bin/gpg.exe"; + QString gpgKeys = appPath + "/keydb"; #endif +#ifdef Q_WS_MAC + QString gpgBin = appPath + "/bin/gpg-mac.app"; - err = gpgme_new(&mCtx); + QString gpgKeys = appPath + "/keydb"; - 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 - */ -#ifdef _WIN32 - QString gpgBin = appPath + "/bin/gpg.exe"; -#else - QString gpgBin = appPath + "/bin/gpg"; + qDebug() << "gpg bin:" << gpgBin; + qDebug() << "gpg keydb: " << gpgKeys; #endif +#ifdef Q_WS_X11 + QString gpgBin = appPath + "/bin/gpg"; QString gpgKeys = appPath + "/keydb"; - /* err = gpgme_ctx_set_engine_info(mCtx, GPGME_PROTOCOL_OpenPGP, - gpgBin.toUtf8().constData(), - gpgKeys.toUtf8().constData());*/ -#ifndef GPG4USB_NON_PORTABLE - err = gpgme_ctx_set_engine_info(mCtx, GPGME_PROTOCOL_OpenPGP, - gpgBin.toLocal8Bit().constData(), - gpgKeys.toLocal8Bit().constData()); - checkErr(err); #endif - /** Setting the output type must be done at the beginning */ - /** think this means ascii-armor --> ? */ - gpgme_set_armor(mCtx, 1); - /** passphrase-callback */ - gpgme_set_passphrase_cb(mCtx, passphraseCb, this); + QStringList args; + args << "--homedir" << gpgKeys << "--list-keys"; - /** check if app is called with -d from command line */ - if (qApp->arguments().contains("-d")) { - qDebug() << "gpgme_data_t debug on"; - debug = true; - } else { - debug = false; - } + QProcess gpg; + gpg.setProcessChannelMode(QProcess::MergedChannels); + gpg.start(gpgBin, args); + + gpg.waitForFinished(-1); + + qDebug() << "huhu" << gpg.readAll(); connect(this,SIGNAL(keyDBChanged()),this,SLOT(refreshKeyList())); refreshKeyList(); @@ -105,8 +79,8 @@ GpgContext::GpgContext() */ GpgContext::~GpgContext() { - if (mCtx) gpgme_release(mCtx); - mCtx = 0; + //if (mCtx) gpgme_release(mCtx); + //mCtx = 0; } /** Import Key from QByteArray @@ -234,15 +208,13 @@ gpgme_key_t GpgContext::getKeyDetails(QString uid) */ GpgKeyList GpgContext::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(mCtx, NULL, 0); - checkErr(err); - while (!(err = gpgme_op_keylist_next(mCtx, &key))) { + +/* while (!(err = gpgme_op_keylist_next(mCtx, &key))) { GpgKey gpgkey; if (!key->subkeys) @@ -259,12 +231,10 @@ GpgKeyList GpgContext::listKeys() } keys.append(gpgkey); gpgme_key_unref(key); - } - gpgme_op_keylist_end(mCtx); + }*/ // list only private keys ( the 1 does ) - gpgme_op_keylist_start(mCtx, NULL, 1); - while (!(err = gpgme_op_keylist_next(mCtx, &key))) { +/* while (!(err = gpgme_op_keylist_next(mCtx, &key))) { if (!key->subkeys) continue; // iterate keys, mark privates @@ -276,8 +246,7 @@ GpgKeyList GpgContext::listKeys() } gpgme_key_unref(key); - } - gpgme_op_keylist_end(mCtx); + }*/ return keys; } @@ -798,3 +767,4 @@ QString GpgContext::getGpgmeVersion() { + @@ -56,8 +56,8 @@ int main(int argc, char *argv[]) putenv(QString("GNUPGHOME=" + appPath + "/keydb").toAscii().data()); // this may help with newer gpgme versions on windows - //putenv(QString("GPGME_GPGPATH=" + appPath.replace("/", "\\") + "\\bin\\gpg.exe").toAscii().data()); - + putenv(QString("GPGME_GPGPATH=" + appPath + "/gpg-mac").toAscii().data()); + qDebug() << appPath + "/gpg-mac"; // QSettings uses org-name for automatically setting path... app.setOrganizationName("conf"); diff --git a/mainwindow.cpp b/mainwindow.cpp index 2e067dc..a608be8 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -23,6 +23,7 @@ MainWindow::MainWindow() { + qDebug() << "hallo"; mCtx = new GpgME::GpgContext(); /* get path were app was started */ diff --git a/release/bin/gpg-mac b/release/bin/gpg-mac Binary files differnew file mode 100755 index 0000000..fe9fe0e --- /dev/null +++ b/release/bin/gpg-mac |