Skip to content

Commit

Permalink
Call 'pass git init' on creation of password-store when useGit
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisdegreef committed Aug 2, 2015
1 parent d5e22d2 commit 704b9f1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
9 changes: 8 additions & 1 deletion dialog.cpp
Expand Up @@ -495,7 +495,7 @@ void Dialog::wizard()
}

QStringList names = mainWindow->getSecretKeys();
//qDebug() << names;
qDebug() << names;
if (QFile(gpg).exists() && names.empty()) {
KeygenDialog d(this);
if (!d.exec()) {
Expand All @@ -511,11 +511,17 @@ void Dialog::wizard()
tr("Would you like to create a password-store at %1?").arg(passStore),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
QDir().mkdir(passStore);

if(useGit()) {
mainWindow->executePassGitInit();
}
mainWindow->userDialog(passStore);
}
}

if(!QFile(passStore + ".gpg-id").exists()){
qDebug() << ".gpg-id file does not exist";

if (!clean) {
criticalMessage(tr("Password store not initialised"),
tr("The folder %1 doesn't seem to be a password store or is not yet initialised.").arg(passStore));
Expand All @@ -528,6 +534,7 @@ void Dialog::wizard()
passStore = ui->storePath->text();
}
if (!QFile(passStore + ".gpg-id").exists()) {
qDebug() << ".gpg-id file still does not exist :/";
// appears not to be store
// init yes / no ?
mainWindow->userDialog(passStore);
Expand Down
11 changes: 10 additions & 1 deletion mainwindow.cpp
Expand Up @@ -68,9 +68,12 @@ MainWindow::~MainWindow()
QSettings &MainWindow::getSettings() {
if (!settings) {
QString portable_ini = QCoreApplication::applicationDirPath() + QDir::separator() + "qtpass.ini";
qDebug() << "Settings file: " + portable_ini;
if (QFile(portable_ini).exists()) {
qDebug() << "Settings file exists, loading it in";
settings.reset(new QSettings(portable_ini, QSettings::IniFormat));
} else {
qDebug() << "Settings file does not exist, use defaults";
settings.reset(new QSettings("IJHack", "QtPass"));
}
}
Expand Down Expand Up @@ -543,6 +546,11 @@ void MainWindow::executePass(QString args, QString input) {
executeWrapper(passExecutable, args, input);
}

void MainWindow::executePassGitInit() {
qDebug() << "Pass git init called";
executePass("git init");
}

/**
* @brief MainWindow::executeWrapper
* @param app
Expand All @@ -564,8 +572,9 @@ void MainWindow::executeWrapper(QString app, QString args, QString input) {
item.app = app;
item.args = args;
item.input = input;

execQueue->enqueue(item);
//qDebug() << item.app + "," + item.args + "," + item.input;
qDebug() << item.app + "," + item.args + "," + item.input;
return;
}
wrapperRunning = true;
Expand Down
1 change: 1 addition & 0 deletions mainwindow.h
Expand Up @@ -47,6 +47,7 @@ enum actionType { GPG, GIT, EDIT, DELETE, GPG_INTERNAL, PWGEN };
void generateKeyPair(QString, QDialog *);
void userDialog(QString = "");
QString generatePassword();
void executePassGitInit();

protected:
void closeEvent(QCloseEvent *event);
Expand Down

0 comments on commit 704b9f1

Please sign in to comment.