diff options
author | Ettore Dreucci <ettore.dreucci@gmail.com> | 2018-05-08 00:48:42 +0200 |
---|---|---|
committer | Ettore Dreucci <ettore.dreucci@gmail.com> | 2018-05-09 12:13:49 +0200 |
commit | cd10e786998907ab10006718c584105674a6c2d8 (patch) | |
tree | a289cac8ab3aeb3004a348f55bf9eb4456391216 | |
parent | a1063f2a494ab1b6d5e52bee71a77acdad7d98a8 (diff) |
Started integrating pass otp plugin
Signed-off-by: Ettore Dreucci <ettore.dreucci@gmail.com>
-rw-r--r-- | src/enums.h | 4 | ||||
-rw-r--r-- | src/imitatepass.cpp | 4 | ||||
-rw-r--r-- | src/imitatepass.h | 1 | ||||
-rw-r--r-- | src/mainwindow.cpp | 24 | ||||
-rw-r--r-- | src/mainwindow.h | 2 | ||||
-rw-r--r-- | src/mainwindow.ui | 12 | ||||
-rw-r--r-- | src/pass.h | 1 | ||||
-rw-r--r-- | src/realpass.cpp | 5 | ||||
-rw-r--r-- | src/realpass.h | 1 |
9 files changed, 53 insertions, 1 deletions
diff --git a/src/enums.h b/src/enums.h index 49014bba..b6b48411 100644 --- a/src/enums.h +++ b/src/enums.h @@ -30,7 +30,9 @@ enum PROCESS { GIT_MOVE, GIT_COPY, PROCESS_COUNT, - INVALID + INVALID, + PASS_OTP_SHOW, + }; } // namespace Enums diff --git a/src/imitatepass.cpp b/src/imitatepass.cpp index 9a9b7e6f..883b12a2 100644 --- a/src/imitatepass.cpp +++ b/src/imitatepass.cpp @@ -50,6 +50,10 @@ void ImitatePass::Show(QString file) { executeGpg(PASS_SHOW, args); } +void ImitatePass::OTPShow(QString file) { + +} + /** * @brief ImitatePass::Insert create new file with encrypted content * diff --git a/src/imitatepass.h b/src/imitatepass.h index 32f5a639..e33c4996 100644 --- a/src/imitatepass.h +++ b/src/imitatepass.h @@ -51,6 +51,7 @@ public: virtual void GitPull_b() Q_DECL_OVERRIDE; virtual void GitPush() Q_DECL_OVERRIDE; virtual void Show(QString file) Q_DECL_OVERRIDE; + virtual void OTPShow(QString file) Q_DECL_OVERRIDE; virtual void Insert(QString file, QString value, bool overwrite = false) Q_DECL_OVERRIDE; virtual void Remove(QString file, bool isDir = false) Q_DECL_OVERRIDE; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index bc913ccf..ffe85b9e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -104,6 +104,9 @@ void MainWindow::initToolBarButtons() { connect(ui->actionUsers, SIGNAL(triggered()), this, SLOT(onUsers())); connect(ui->actionConfig, SIGNAL(triggered()), this, SLOT(onConfig())); + //if (check if pass otp is installed) + connect(ui->actionOTP, SIGNAL(triggered()), this, SLOT(onOTP())); + ui->actionAddPassword->setIcon( QIcon::fromTheme("document-new", QIcon(":/icons/document-new.svg"))); ui->actionAddFolder->setIcon( @@ -916,6 +919,15 @@ void MainWindow::onDelete() { } /** + * @brief MainWindow::onOTP try and generate (selected) OTP code. + */ +void MainWindow::onOTP() { + QString file = getFile(ui->treeView->currentIndex(), true); + generateOTP(file); + QTextStream(stdout) << "OTP" << endl; +} + +/** * @brief MainWindow::onEdit try and edit (selected) password. */ void MainWindow::onEdit() { @@ -1275,6 +1287,18 @@ void MainWindow::editPassword(const QString &file) { } /** + * @brief Mainwindow::generateOTP read OTP url and generate an OTP code + * via pass otp, then copies the code to the clipboard. + */ +void MainWindow::generateOTP(const QString &file) { + if (!file.isEmpty()) { + if (QtPassSettings::isUseGit() && QtPassSettings::isAutoPull()) + onUpdate(true); + QtPassSettings::getPass()->OTPShow(file); + } +} + +/** * @brief MainWindow::clearTemplateWidgets empty the template widget fields in * the UI */ diff --git a/src/mainwindow.h b/src/mainwindow.h index d93e3b85..db6152fb 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -63,6 +63,7 @@ private slots: void addFolder(); void onEdit(); void onDelete(); + void onOTP(); void onPush(); void onUpdate(bool block = false); void onUsers(); @@ -81,6 +82,7 @@ private slots: void showBrowserContextMenu(const QPoint &pos); void openFolder(); void editPassword(const QString &); + void generateOTP(const QString &); void focusInput(); void copyTextToClipboard(const QString &text); void copyPasswordFromTreeview(); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 65a6747b..3507b283 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -319,6 +319,7 @@ p, li { white-space: pre-wrap; } <addaction name="separator"/> <addaction name="actionEdit"/> <addaction name="actionDelete"/> + <addaction name="actionOTP"/> <addaction name="separator"/> <addaction name="actionPush"/> <addaction name="actionUpdate"/> @@ -361,6 +362,17 @@ p, li { white-space: pre-wrap; } <string>Delete</string> </property> </action> + <action name="actionOTP"> + <property name="text"> + <string>OTP</string> + </property> + <property name="toolTip"> + <string>Generate OTP</string> + </property> + <property name="shortcut"> + <string>Ctrl+G</string> + </property> + </action> <action name="actionPush"> <property name="text"> <string>Push</string> @@ -43,6 +43,7 @@ public: virtual void GitPull_b() = 0; virtual void GitPush() = 0; virtual void Show(QString file) = 0; + virtual void OTPShow(QString file) = 0; virtual void Insert(QString file, QString value, bool force) = 0; virtual void Remove(QString file, bool isDir) = 0; virtual void Move(const QString srcDir, const QString dest, diff --git a/src/realpass.cpp b/src/realpass.cpp index 5684eccd..7446d73f 100644 --- a/src/realpass.cpp +++ b/src/realpass.cpp @@ -44,6 +44,11 @@ void RealPass::Show(QString file) { executePass(PASS_SHOW, {"show", file}, "", true); } +void RealPass::OTPShow(QString file) { + executePass(PASS_OTP_SHOW, {"otp", "-c", file}, "", true); +} + + /** * @brief RealPass::Insert pass insert */ diff --git a/src/realpass.h b/src/realpass.h index 2c17a0f2..76dc7d2e 100644 --- a/src/realpass.h +++ b/src/realpass.h @@ -20,6 +20,7 @@ public: virtual void GitPull_b() Q_DECL_OVERRIDE; virtual void GitPush() Q_DECL_OVERRIDE; virtual void Show(QString file) Q_DECL_OVERRIDE; + virtual void OTPShow(QString file) Q_DECL_OVERRIDE; virtual void Insert(QString file, QString value, bool overwrite = false) Q_DECL_OVERRIDE; virtual void Remove(QString file, bool isDir = false) Q_DECL_OVERRIDE; |