Skip to content

Commit a740e6e

Browse files
committed
Merge pull request #64 from IJHack/develop
Many deadlocks and other nasty bugs fixed
2 parents 55a0a69 + fe3b3cf commit a740e6e

File tree

6 files changed

+138
-15
lines changed

6 files changed

+138
-15
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,4 @@ notifications:
4343
matrix:
4444
allow_failures:
4545
- os: osx
46+

mainwindow.cpp

+31-11
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ MainWindow::~MainWindow()
6464

6565
QSettings &MainWindow::getSettings() {
6666
if (!settings) {
67-
QString portable_ini = QCoreApplication::applicationDirPath() + "/qtpass.ini";
67+
QString portable_ini = QCoreApplication::applicationDirPath() + QDir::separator() + "qtpass.ini";
6868
if (QFile(portable_ini).exists()) {
6969
settings.reset(new QSettings(portable_ini, QSettings::IniFormat));
7070
} else {
@@ -255,6 +255,7 @@ bool MainWindow::checkConfig() {
255255
ui->updateButton->hide();
256256
}
257257
ui->lineEdit->setFocus();
258+
258259
startupPhase = false;
259260
return true;
260261
}
@@ -459,7 +460,10 @@ void MainWindow::executeWrapper(QString app, QString args, QString input) {
459460
// Happens a lot if e.g. git binary is not set.
460461
// This will result in bogus "QProcess::FailedToStart" messages,
461462
// also hiding legitimate errors from the gpg commands.
462-
if (app.isEmpty()) return;
463+
if (app.isEmpty()) {
464+
qDebug() << "Trying to execute nothing..";
465+
return;
466+
}
463467
// Convert to absolute path, just in case
464468
app = QDir(QCoreApplication::applicationDirPath()).absoluteFilePath(app);
465469
if (wrapperRunning) {
@@ -583,6 +587,8 @@ void MainWindow::enableUiElements(bool state) {
583587
ui->lineEdit->setEnabled(state);
584588
ui->addButton->setEnabled(state);
585589
ui->usersButton->setEnabled(state);
590+
ui->configButton->setEnabled(state);
591+
// is a file selected?
586592
state &= ui->treeView->currentIndex().isValid();
587593
ui->deleteButton->setEnabled(state);
588594
ui->editButton->setEnabled(state);
@@ -786,8 +792,12 @@ QString MainWindow::getRecipientString(QString for_file, QString separator, int
786792
* @param file
787793
* @param overwrite
788794
*/
789-
void MainWindow::setPassword(QString file, bool overwrite)
795+
void MainWindow::setPassword(QString file, bool overwrite, bool isNew = false)
790796
{
797+
if (!isNew && lastDecrypt.isEmpty()) {
798+
// warn?
799+
return;
800+
}
791801
bool ok;
792802
#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
793803
QString newValue = QInputDialog::getMultiLineText(this, tr("New Value"),
@@ -844,7 +854,7 @@ void MainWindow::on_addButton_clicked()
844854
file += ".gpg";
845855
}
846856
lastDecrypt = "";
847-
setPassword(file, false);
857+
setPassword(file, false, true);
848858
}
849859

850860
/**
@@ -870,21 +880,25 @@ void MainWindow::on_deleteButton_clicked()
870880
QFile(file).remove();
871881
}
872882
} else {
873-
file = getDir(ui->treeView->currentIndex(), false);
883+
file = getDir(ui->treeView->currentIndex(), usePass);
874884
if (QMessageBox::question(this, tr("Delete folder?"),
875885
tr("Are you sure you want to delete %1?").arg(QDir::separator() + getDir(ui->treeView->currentIndex(), true)),
876886
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) {
877887
return;
878888
}
879-
// TODO GIT
889+
if (usePass) {
890+
currentAction = DELETE;
891+
executePass("rm -r \"" + file + '"');
892+
} else {
893+
// TODO GIT
880894
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
881-
QDir dir(file);
882-
dir.removeRecursively();
895+
QDir dir(file);
896+
dir.removeRecursively();
883897
#else
884-
removeDir(file);
898+
removeDir(file);
885899
#endif
900+
}
886901
}
887-
888902
}
889903

890904
/**
@@ -937,6 +951,9 @@ void MainWindow::on_editButton_clicked()
937951
*/
938952
QList<UserInfo> MainWindow::listKeys(QString keystring, bool secret)
939953
{
954+
while (!process->atEnd() || !execQueue->isEmpty()) {
955+
Util::qSleep(100);
956+
}
940957
QList<UserInfo> users;
941958
currentAction = GPG_INTERNAL;
942959
QString listopt = secret ? "--list-secret-keys " : "--list-keys ";
@@ -1056,7 +1073,7 @@ void MainWindow::on_usersButton_clicked()
10561073
tr("None of the selected keys have a secret key available.\n"
10571074
"You will not be able to decrypt any newly added passwords!"));
10581075
}
1059-
if (!useWebDav){
1076+
if (!useWebDav && !gitExecutable.isEmpty()){
10601077
if (addFile) {
10611078
executeWrapper(gitExecutable, "add \"" + gpgIdFile + '"');
10621079
}
@@ -1329,6 +1346,9 @@ void MainWindow::addFolder()
13291346
*/
13301347
void MainWindow::editPassword()
13311348
{
1349+
while (!process->atEnd() || !execQueue->isEmpty()) {
1350+
Util::qSleep(100);
1351+
}
13321352
// TODO move to editbutton stuff possibly?
13331353
currentDir = getDir(ui->treeView->currentIndex(), false);
13341354
lastDecrypt = "Could not decrypt";

mainwindow.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ private slots:
121121
QModelIndex firstFile(QModelIndex parentIndex);
122122
QString getDir(const QModelIndex &, bool);
123123
QString getFile(const QModelIndex &, bool);
124-
void setPassword(QString, bool);
124+
void setPassword(QString, bool, bool);
125125
QSettings &getSettings();
126126
QList<UserInfo> listKeys(QString keystring = "", bool secret = false);
127127
QStringList getRecipientList(QString for_file);

qtpass.iss

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
; Script generated by the Inno Script Studio Wizard.
2+
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
3+
4+
#define MyAppName "QtPass"
5+
#define MyAppVersion "0.8.4"
6+
#define MyAppPublisher "IJhack"
7+
#define MyAppURL "http://qtpass.org/"
8+
#define MyAppExeName "qtpass.exe"
9+
10+
[Setup]
11+
; NOTE: The value of AppId uniquely identifies this application.
12+
; Do not use the same AppId value in installers for other applications.
13+
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
14+
AppId={{C64A2871-0C42-4A90-9071-D84DC30563BF}
15+
AppName={#MyAppName}
16+
AppVersion={#MyAppVersion}
17+
;AppVerName={#MyAppName} {#MyAppVersion}
18+
AppPublisher={#MyAppPublisher}
19+
AppPublisherURL={#MyAppURL}
20+
AppSupportURL={#MyAppURL}
21+
AppUpdatesURL={#MyAppURL}
22+
DefaultDirName={pf}\{#MyAppName}
23+
DefaultGroupName={#MyAppName}
24+
LicenseFile=C:\Users\IEUser\Desktop\QtPass\LICENSE.txt
25+
OutputBaseFilename=setup
26+
Compression=lzma
27+
SolidCompression=yes
28+
ShowLanguageDialog=no
29+
30+
[Languages]
31+
Name: "english"; MessagesFile: "compiler:Default.isl"
32+
Name: "brazilianportuguese"; MessagesFile: "compiler:Languages\BrazilianPortuguese.isl"
33+
Name: "catalan"; MessagesFile: "compiler:Languages\Catalan.isl"
34+
Name: "corsican"; MessagesFile: "compiler:Languages\Corsican.isl"
35+
Name: "czech"; MessagesFile: "compiler:Languages\Czech.isl"
36+
Name: "danish"; MessagesFile: "compiler:Languages\Danish.isl"
37+
Name: "dutch"; MessagesFile: "compiler:Languages\Dutch.isl"
38+
Name: "finnish"; MessagesFile: "compiler:Languages\Finnish.isl"
39+
Name: "french"; MessagesFile: "compiler:Languages\French.isl"
40+
Name: "german"; MessagesFile: "compiler:Languages\German.isl"
41+
Name: "greek"; MessagesFile: "compiler:Languages\Greek.isl"
42+
Name: "hebrew"; MessagesFile: "compiler:Languages\Hebrew.isl"
43+
Name: "hungarian"; MessagesFile: "compiler:Languages\Hungarian.isl"
44+
Name: "italian"; MessagesFile: "compiler:Languages\Italian.isl"
45+
Name: "japanese"; MessagesFile: "compiler:Languages\Japanese.isl"
46+
Name: "nepali"; MessagesFile: "compiler:Languages\Nepali.islu"
47+
Name: "norwegian"; MessagesFile: "compiler:Languages\Norwegian.isl"
48+
Name: "polish"; MessagesFile: "compiler:Languages\Polish.isl"
49+
Name: "portuguese"; MessagesFile: "compiler:Languages\Portuguese.isl"
50+
Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"
51+
Name: "scottishgaelic"; MessagesFile: "compiler:Languages\ScottishGaelic.isl"
52+
Name: "serbiancyrillic"; MessagesFile: "compiler:Languages\SerbianCyrillic.isl"
53+
Name: "serbianlatin"; MessagesFile: "compiler:Languages\SerbianLatin.isl"
54+
Name: "slovenian"; MessagesFile: "compiler:Languages\Slovenian.isl"
55+
Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl"
56+
Name: "turkish"; MessagesFile: "compiler:Languages\Turkish.isl"
57+
Name: "ukrainian"; MessagesFile: "compiler:Languages\Ukrainian.isl"
58+
59+
[Tasks]
60+
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
61+
62+
[Files]
63+
Source: "C:\Users\IEUser\Desktop\QtPass\qtpass.exe"; DestDir: "{app}"; Flags: ignoreversion
64+
Source: "..\..\Desktop\QtPass\Qt5Gui.dll"; DestDir: "{app}"; Flags: ignoreversion
65+
Source: "..\..\Desktop\QtPass\Qt5Network.dll"; DestDir: "{app}"; Flags: ignoreversion
66+
Source: "..\..\Desktop\QtPass\Qt5Widgets.dll"; DestDir: "{app}"; Flags: ignoreversion
67+
Source: "..\..\Desktop\QtPass\README.txt"; DestDir: "{app}"; Flags: ignoreversion
68+
Source: "..\..\Desktop\QtPass\icudt53.dll"; DestDir: "{app}"; Flags: ignoreversion
69+
Source: "..\..\Desktop\QtPass\icuin53.dll"; DestDir: "{app}"; Flags: ignoreversion
70+
Source: "..\..\Desktop\QtPass\icuuc53.dll"; DestDir: "{app}"; Flags: ignoreversion
71+
Source: "..\..\Desktop\QtPass\libgcc_s_dw2-1.dll"; DestDir: "{app}"; Flags: ignoreversion
72+
Source: "..\..\Desktop\QtPass\libstdc++-6.dll"; DestDir: "{app}"; Flags: ignoreversion
73+
Source: "..\..\Desktop\QtPass\libwinpthread-1.dll"; DestDir: "{app}"; Flags: ignoreversion
74+
Source: "..\..\Desktop\QtPass\LICENSE.txt"; DestDir: "{app}"; Flags: ignoreversion
75+
Source: "..\..\Desktop\QtPass\Qt5Core.dll"; DestDir: "{app}"; Flags: ignoreversion
76+
Source: "..\..\Desktop\QtPass\platforms\qwindows.dll"; DestDir: "{app}\platforms\"; Flags: ignoreversion
77+
78+
[Icons]
79+
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
80+
Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"
81+
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
82+
83+
[Run]
84+
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

util.cpp

+20-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
#include <QString>
55
#include <QDir>
66
#include "util.h"
7-
7+
#ifdef Q_OS_WIN
8+
#include <windows.h>
9+
#endif
810
QProcessEnvironment Util::_env;
911
bool Util::_envInitialised;
1012

@@ -42,7 +44,7 @@ QString Util::findPasswordStore()
4244
if (_env.contains("PASSWORD_STORE_DIR")) {
4345
path = _env.value("PASSWORD_STORE_DIR");
4446
} else {
45-
path = QDir::homePath()+"/.password-store/";
47+
path = QDir::homePath() + QDir::separator() + ".password-store" + QDir::separator();
4648
}
4749
return Util::normalizeFolderPath(path);
4850
}
@@ -53,7 +55,7 @@ QString Util::findPasswordStore()
5355
* @return
5456
*/
5557
QString Util::normalizeFolderPath(QString path) {
56-
if (!path.endsWith(QDir::separator())) {
58+
if (!path.endsWith("/") && !path.endsWith(QDir::separator())) {
5759
path += QDir::separator();
5860
}
5961
return path;
@@ -112,3 +114,18 @@ bool Util::checkConfig(QString passStore, QString passExecutable, QString gpgExe
112114
{
113115
return !QFile(passStore + ".gpg-id").exists() || (!QFile(passExecutable).exists() && !QFile(gpgExecutable).exists());
114116
}
117+
118+
119+
/**
120+
* @brief Util::qSleep
121+
* @param ms
122+
*/\
123+
void Util::qSleep(int ms)
124+
{
125+
#ifdef Q_OS_WIN
126+
Sleep(uint(ms));
127+
#else
128+
struct timespec ts = { ms / 1000, (ms % 1000) * 1000 * 1000 };
129+
nanosleep(&ts, NULL);
130+
#endif
131+
}

util.h

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class Util
1111
static QString findPasswordStore();
1212
static QString normalizeFolderPath(QString);
1313
static bool checkConfig(QString, QString, QString);
14+
static void qSleep(int);
1415

1516
private:
1617
static void initialiseEnvironment();

0 commit comments

Comments
 (0)