summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnne Jan Brouwer <brouwer@annejan.com>2015-07-07 02:02:11 +0200
committerAnne Jan Brouwer <brouwer@annejan.com>2015-07-07 02:02:11 +0200
commitd8ace2a71163b7f0788626067b81982674971e01 (patch)
treecfd54af78ccb909cb940dce5dc98d3d528b0b795
parent9ad76a33a65ea9831decc5d2357456000223e560 (diff)
parent7a4fcab8b071b1e55b5d510645d4c24f3fe382dc (diff)
Merge pull request #64 from IJHack/develop
Many deadlocks and other nasty bugs fixed
-rw-r--r--.travis.yml1
-rw-r--r--mainwindow.cpp42
-rw-r--r--mainwindow.h2
-rw-r--r--qtpass.iss84
-rw-r--r--util.cpp23
-rw-r--r--util.h1
6 files changed, 138 insertions, 15 deletions
diff --git a/.travis.yml b/.travis.yml
index 85a9df89..8f64e5ae 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -43,3 +43,4 @@ notifications:
matrix:
allow_failures:
- os: osx
+
diff --git a/mainwindow.cpp b/mainwindow.cpp
index dbe117bf..c0991381 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -64,7 +64,7 @@ MainWindow::~MainWindow()
QSettings &MainWindow::getSettings() {
if (!settings) {
- QString portable_ini = QCoreApplication::applicationDirPath() + "/qtpass.ini";
+ QString portable_ini = QCoreApplication::applicationDirPath() + QDir::separator() + "qtpass.ini";
if (QFile(portable_ini).exists()) {
settings.reset(new QSettings(portable_ini, QSettings::IniFormat));
} else {
@@ -255,6 +255,7 @@ bool MainWindow::checkConfig() {
ui->updateButton->hide();
}
ui->lineEdit->setFocus();
+
startupPhase = false;
return true;
}
@@ -459,7 +460,10 @@ void MainWindow::executeWrapper(QString app, QString args, QString input) {
// Happens a lot if e.g. git binary is not set.
// This will result in bogus "QProcess::FailedToStart" messages,
// also hiding legitimate errors from the gpg commands.
- if (app.isEmpty()) return;
+ if (app.isEmpty()) {
+ qDebug() << "Trying to execute nothing..";
+ return;
+ }
// Convert to absolute path, just in case
app = QDir(QCoreApplication::applicationDirPath()).absoluteFilePath(app);
if (wrapperRunning) {
@@ -583,6 +587,8 @@ void MainWindow::enableUiElements(bool state) {
ui->lineEdit->setEnabled(state);
ui->addButton->setEnabled(state);
ui->usersButton->setEnabled(state);
+ ui->configButton->setEnabled(state);
+ // is a file selected?
state &= ui->treeView->currentIndex().isValid();
ui->deleteButton->setEnabled(state);
ui->editButton->setEnabled(state);
@@ -786,8 +792,12 @@ QString MainWindow::getRecipientString(QString for_file, QString separator, int
* @param file
* @param overwrite
*/
-void MainWindow::setPassword(QString file, bool overwrite)
+void MainWindow::setPassword(QString file, bool overwrite, bool isNew = false)
{
+ if (!isNew && lastDecrypt.isEmpty()) {
+ // warn?
+ return;
+ }
bool ok;
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
QString newValue = QInputDialog::getMultiLineText(this, tr("New Value"),
@@ -844,7 +854,7 @@ void MainWindow::on_addButton_clicked()
file += ".gpg";
}
lastDecrypt = "";
- setPassword(file, false);
+ setPassword(file, false, true);
}
/**
@@ -870,21 +880,25 @@ void MainWindow::on_deleteButton_clicked()
QFile(file).remove();
}
} else {
- file = getDir(ui->treeView->currentIndex(), false);
+ file = getDir(ui->treeView->currentIndex(), usePass);
if (QMessageBox::question(this, tr("Delete folder?"),
tr("Are you sure you want to delete %1?").arg(QDir::separator() + getDir(ui->treeView->currentIndex(), true)),
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) {
return;
}
- // TODO GIT
+ if (usePass) {
+ currentAction = DELETE;
+ executePass("rm -r \"" + file + '"');
+ } else {
+ // TODO GIT
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
- QDir dir(file);
- dir.removeRecursively();
+ QDir dir(file);
+ dir.removeRecursively();
#else
- removeDir(file);
+ removeDir(file);
#endif
+ }
}
-
}
/**
@@ -937,6 +951,9 @@ void MainWindow::on_editButton_clicked()
*/
QList<UserInfo> MainWindow::listKeys(QString keystring, bool secret)
{
+ while (!process->atEnd() || !execQueue->isEmpty()) {
+ Util::qSleep(100);
+ }
QList<UserInfo> users;
currentAction = GPG_INTERNAL;
QString listopt = secret ? "--list-secret-keys " : "--list-keys ";
@@ -1056,7 +1073,7 @@ void MainWindow::on_usersButton_clicked()
tr("None of the selected keys have a secret key available.\n"
"You will not be able to decrypt any newly added passwords!"));
}
- if (!useWebDav){
+ if (!useWebDav && !gitExecutable.isEmpty()){
if (addFile) {
executeWrapper(gitExecutable, "add \"" + gpgIdFile + '"');
}
@@ -1329,6 +1346,9 @@ void MainWindow::addFolder()
*/
void MainWindow::editPassword()
{
+ while (!process->atEnd() || !execQueue->isEmpty()) {
+ Util::qSleep(100);
+ }
// TODO move to editbutton stuff possibly?
currentDir = getDir(ui->treeView->currentIndex(), false);
lastDecrypt = "Could not decrypt";
diff --git a/mainwindow.h b/mainwindow.h
index 163e626e..4df8cbc4 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -121,7 +121,7 @@ private:
QModelIndex firstFile(QModelIndex parentIndex);
QString getDir(const QModelIndex &, bool);
QString getFile(const QModelIndex &, bool);
- void setPassword(QString, bool);
+ void setPassword(QString, bool, bool);
QSettings &getSettings();
QList<UserInfo> listKeys(QString keystring = "", bool secret = false);
QStringList getRecipientList(QString for_file);
diff --git a/qtpass.iss b/qtpass.iss
new file mode 100644
index 00000000..163814e9
--- /dev/null
+++ b/qtpass.iss
@@ -0,0 +1,84 @@
+; Script generated by the Inno Script Studio Wizard.
+; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
+
+#define MyAppName "QtPass"
+#define MyAppVersion "0.8.4"
+#define MyAppPublisher "IJhack"
+#define MyAppURL "http://qtpass.org/"
+#define MyAppExeName "qtpass.exe"
+
+[Setup]
+; NOTE: The value of AppId uniquely identifies this application.
+; Do not use the same AppId value in installers for other applications.
+; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
+AppId={{C64A2871-0C42-4A90-9071-D84DC30563BF}
+AppName={#MyAppName}
+AppVersion={#MyAppVersion}
+;AppVerName={#MyAppName} {#MyAppVersion}
+AppPublisher={#MyAppPublisher}
+AppPublisherURL={#MyAppURL}
+AppSupportURL={#MyAppURL}
+AppUpdatesURL={#MyAppURL}
+DefaultDirName={pf}\{#MyAppName}
+DefaultGroupName={#MyAppName}
+LicenseFile=C:\Users\IEUser\Desktop\QtPass\LICENSE.txt
+OutputBaseFilename=setup
+Compression=lzma
+SolidCompression=yes
+ShowLanguageDialog=no
+
+[Languages]
+Name: "english"; MessagesFile: "compiler:Default.isl"
+Name: "brazilianportuguese"; MessagesFile: "compiler:Languages\BrazilianPortuguese.isl"
+Name: "catalan"; MessagesFile: "compiler:Languages\Catalan.isl"
+Name: "corsican"; MessagesFile: "compiler:Languages\Corsican.isl"
+Name: "czech"; MessagesFile: "compiler:Languages\Czech.isl"
+Name: "danish"; MessagesFile: "compiler:Languages\Danish.isl"
+Name: "dutch"; MessagesFile: "compiler:Languages\Dutch.isl"
+Name: "finnish"; MessagesFile: "compiler:Languages\Finnish.isl"
+Name: "french"; MessagesFile: "compiler:Languages\French.isl"
+Name: "german"; MessagesFile: "compiler:Languages\German.isl"
+Name: "greek"; MessagesFile: "compiler:Languages\Greek.isl"
+Name: "hebrew"; MessagesFile: "compiler:Languages\Hebrew.isl"
+Name: "hungarian"; MessagesFile: "compiler:Languages\Hungarian.isl"
+Name: "italian"; MessagesFile: "compiler:Languages\Italian.isl"
+Name: "japanese"; MessagesFile: "compiler:Languages\Japanese.isl"
+Name: "nepali"; MessagesFile: "compiler:Languages\Nepali.islu"
+Name: "norwegian"; MessagesFile: "compiler:Languages\Norwegian.isl"
+Name: "polish"; MessagesFile: "compiler:Languages\Polish.isl"
+Name: "portuguese"; MessagesFile: "compiler:Languages\Portuguese.isl"
+Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"
+Name: "scottishgaelic"; MessagesFile: "compiler:Languages\ScottishGaelic.isl"
+Name: "serbiancyrillic"; MessagesFile: "compiler:Languages\SerbianCyrillic.isl"
+Name: "serbianlatin"; MessagesFile: "compiler:Languages\SerbianLatin.isl"
+Name: "slovenian"; MessagesFile: "compiler:Languages\Slovenian.isl"
+Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl"
+Name: "turkish"; MessagesFile: "compiler:Languages\Turkish.isl"
+Name: "ukrainian"; MessagesFile: "compiler:Languages\Ukrainian.isl"
+
+[Tasks]
+Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
+
+[Files]
+Source: "C:\Users\IEUser\Desktop\QtPass\qtpass.exe"; DestDir: "{app}"; Flags: ignoreversion
+Source: "..\..\Desktop\QtPass\Qt5Gui.dll"; DestDir: "{app}"; Flags: ignoreversion
+Source: "..\..\Desktop\QtPass\Qt5Network.dll"; DestDir: "{app}"; Flags: ignoreversion
+Source: "..\..\Desktop\QtPass\Qt5Widgets.dll"; DestDir: "{app}"; Flags: ignoreversion
+Source: "..\..\Desktop\QtPass\README.txt"; DestDir: "{app}"; Flags: ignoreversion
+Source: "..\..\Desktop\QtPass\icudt53.dll"; DestDir: "{app}"; Flags: ignoreversion
+Source: "..\..\Desktop\QtPass\icuin53.dll"; DestDir: "{app}"; Flags: ignoreversion
+Source: "..\..\Desktop\QtPass\icuuc53.dll"; DestDir: "{app}"; Flags: ignoreversion
+Source: "..\..\Desktop\QtPass\libgcc_s_dw2-1.dll"; DestDir: "{app}"; Flags: ignoreversion
+Source: "..\..\Desktop\QtPass\libstdc++-6.dll"; DestDir: "{app}"; Flags: ignoreversion
+Source: "..\..\Desktop\QtPass\libwinpthread-1.dll"; DestDir: "{app}"; Flags: ignoreversion
+Source: "..\..\Desktop\QtPass\LICENSE.txt"; DestDir: "{app}"; Flags: ignoreversion
+Source: "..\..\Desktop\QtPass\Qt5Core.dll"; DestDir: "{app}"; Flags: ignoreversion
+Source: "..\..\Desktop\QtPass\platforms\qwindows.dll"; DestDir: "{app}\platforms\"; Flags: ignoreversion
+
+[Icons]
+Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
+Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"
+Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
+
+[Run]
+Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
diff --git a/util.cpp b/util.cpp
index 74c84c1e..ecc86007 100644
--- a/util.cpp
+++ b/util.cpp
@@ -4,7 +4,9 @@
#include <QString>
#include <QDir>
#include "util.h"
-
+#ifdef Q_OS_WIN
+#include <windows.h>
+#endif
QProcessEnvironment Util::_env;
bool Util::_envInitialised;
@@ -42,7 +44,7 @@ QString Util::findPasswordStore()
if (_env.contains("PASSWORD_STORE_DIR")) {
path = _env.value("PASSWORD_STORE_DIR");
} else {
- path = QDir::homePath()+"/.password-store/";
+ path = QDir::homePath() + QDir::separator() + ".password-store" + QDir::separator();
}
return Util::normalizeFolderPath(path);
}
@@ -53,7 +55,7 @@ QString Util::findPasswordStore()
* @return
*/
QString Util::normalizeFolderPath(QString path) {
- if (!path.endsWith(QDir::separator())) {
+ if (!path.endsWith("/") && !path.endsWith(QDir::separator())) {
path += QDir::separator();
}
return path;
@@ -112,3 +114,18 @@ bool Util::checkConfig(QString passStore, QString passExecutable, QString gpgExe
{
return !QFile(passStore + ".gpg-id").exists() || (!QFile(passExecutable).exists() && !QFile(gpgExecutable).exists());
}
+
+
+/**
+ * @brief Util::qSleep
+ * @param ms
+ */\
+void Util::qSleep(int ms)
+{
+#ifdef Q_OS_WIN
+ Sleep(uint(ms));
+#else
+ struct timespec ts = { ms / 1000, (ms % 1000) * 1000 * 1000 };
+ nanosleep(&ts, NULL);
+#endif
+}
diff --git a/util.h b/util.h
index f3587858..53e1af98 100644
--- a/util.h
+++ b/util.h
@@ -11,6 +11,7 @@ public:
static QString findPasswordStore();
static QString normalizeFolderPath(QString);
static bool checkConfig(QString, QString, QString);
+ static void qSleep(int);
private:
static void initialiseEnvironment();