aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910>2012-05-15 00:20:24 +0000
committernils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910>2012-05-15 00:20:24 +0000
commit6409a4e066bed4d9694accba65c126555806a047 (patch)
tree6c8c63db84a90cedf783fd3a70ba84a4d8d27f22
parentshow error if file could not be read, don't crash on invalid data for verify (diff)
downloadgpg4usb-6409a4e066bed4d9694accba65c126555806a047.tar.gz
gpg4usb-6409a4e066bed4d9694accba65c126555806a047.zip
fix creation of windows registry key on import from GnuPG, if gnupg key doesn't already exist
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@913 34ebc366-c3a9-4b3c-9f84-69acf7962910
-rw-r--r--wizard.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/wizard.cpp b/wizard.cpp
index 5921cda..a7e19e0 100644
--- a/wizard.cpp
+++ b/wizard.cpp
@@ -22,6 +22,10 @@
#include "wizard.h"
+#ifdef Q_OS_WIN
+#include "windows.h"
+#endif
+
Wizard::Wizard(GpgME::GpgContext *ctx, KeyMgmt *keyMgmt, QWidget *parent)
: QWizard(parent)
{
@@ -316,16 +320,25 @@ void ImportFromGnupgPage::importKeysFromGnupg()
wizard()->next();
}
+
QString ImportFromGnupgPage::getGnuPGHome()
{
QString gnuPGHome="";
#ifdef _WIN32
+ bool existsAndSuccess = false;
+
+ HKEY hKey;
+
+ existsAndSuccess = (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\GNU\\GNUPG", 0, KEY_READ, &hKey) == ERROR_SUCCESS);
+
+ if (existsAndSuccess) {
QSettings gnuPGsettings("HKEY_CURRENT_USER\\Software\\GNU\\GNUPG", QSettings::NativeFormat);
- gnuPGHome = gnuPGsettings.value("HomeDir").toString();
- if (gnuPGHome.isEmpty()) {
- return NULL;
+ if (gnuPGsettings.contains("HomeDir")) {
+ gnuPGHome = gnuPGsettings.value("HomeDir").toString();
+ } else {
+ return NULL;
+ }
}
-
#else
gnuPGHome=QDir::homePath()+"/.gnupg";
if (! QFile(gnuPGHome).exists()) {