Skip to content

Commit

Permalink
OTP button calls external pass otp -c
Browse files Browse the repository at this point in the history
Signed-off-by: Ettore Dreucci <ettore.dreucci@gmail.com>
  • Loading branch information
Noettore committed May 9, 2018
1 parent cd10e78 commit 76de909
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/imitatepass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void ImitatePass::Show(QString file) {
executeGpg(PASS_SHOW, args);
}

void ImitatePass::OTPShow(QString file) {
void ImitatePass::OtpShow(QString file) {

}

Expand Down
2 changes: 1 addition & 1 deletion src/imitatepass.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class ImitatePass : public Pass, private simpleTransaction {
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 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;
Expand Down
11 changes: 5 additions & 6 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void MainWindow::initToolBarButtons() {
connect(ui->actionConfig, SIGNAL(triggered()), this, SLOT(onConfig()));

//if (check if pass otp is installed)
connect(ui->actionOTP, SIGNAL(triggered()), this, SLOT(onOTP()));
connect(ui->actionOtp, SIGNAL(triggered()), this, SLOT(onOtp()));

ui->actionAddPassword->setIcon(
QIcon::fromTheme("document-new", QIcon(":/icons/document-new.svg")));
Expand Down Expand Up @@ -921,10 +921,9 @@ void MainWindow::onDelete() {
/**
* @brief MainWindow::onOTP try and generate (selected) OTP code.
*/
void MainWindow::onOTP() {
void MainWindow::onOtp() {
QString file = getFile(ui->treeView->currentIndex(), true);
generateOTP(file);
QTextStream(stdout) << "OTP" << endl;
generateOtp(file);
}

/**
Expand Down Expand Up @@ -1290,11 +1289,11 @@ 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) {
void MainWindow::generateOtp(const QString &file) {
if (!file.isEmpty()) {
if (QtPassSettings::isUseGit() && QtPassSettings::isAutoPull())
onUpdate(true);
QtPassSettings::getPass()->OTPShow(file);
QtPassSettings::getPass()->OtpShow(file);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private slots:
void addFolder();
void onEdit();
void onDelete();
void onOTP();
void onOtp();
void onPush();
void onUpdate(bool block = false);
void onUsers();
Expand All @@ -82,7 +82,7 @@ private slots:
void showBrowserContextMenu(const QPoint &pos);
void openFolder();
void editPassword(const QString &);
void generateOTP(const QString &);
void generateOtp(const QString &);
void focusInput();
void copyTextToClipboard(const QString &text);
void copyPasswordFromTreeview();
Expand Down
4 changes: 2 additions & 2 deletions src/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ p, li { white-space: pre-wrap; }
<addaction name="separator"/>
<addaction name="actionEdit"/>
<addaction name="actionDelete"/>
<addaction name="actionOTP"/>
<addaction name="actionOtp"/>
<addaction name="separator"/>
<addaction name="actionPush"/>
<addaction name="actionUpdate"/>
Expand Down Expand Up @@ -362,7 +362,7 @@ p, li { white-space: pre-wrap; }
<string>Delete</string>
</property>
</action>
<action name="actionOTP">
<action name="actionOtp">
<property name="text">
<string>OTP</string>
</property>
Expand Down
2 changes: 2 additions & 0 deletions src/pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ void Pass::finished(int id, int exitCode, const QString &out,
case PASS_SHOW:
emit finishedShow(out);
break;
case PASS_OTP_SHOW:
emit finishedOtpShow(out);
case PASS_INSERT:
emit finishedInsert(out, err);
break;
Expand Down
3 changes: 2 additions & 1 deletion src/pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Pass : public QObject {
virtual void GitPull_b() = 0;
virtual void GitPush() = 0;
virtual void Show(QString file) = 0;
virtual void OTPShow(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,
Expand Down Expand Up @@ -88,6 +88,7 @@ protected slots:
void finishedGitPull(const QString &, const QString &);
void finishedGitPush(const QString &, const QString &);
void finishedShow(const QString &);
void finishedOtpShow(const QString &);
void finishedInsert(const QString &, const QString &);
void finishedRemove(const QString &, const QString &);
void finishedInit(const QString &, const QString &);
Expand Down
2 changes: 1 addition & 1 deletion src/realpass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void RealPass::Show(QString file) {
executePass(PASS_SHOW, {"show", file}, "", true);
}

void RealPass::OTPShow(QString file) {
void RealPass::OtpShow(QString file) {
executePass(PASS_OTP_SHOW, {"otp", "-c", file}, "", true);
}

Expand Down
2 changes: 1 addition & 1 deletion src/realpass.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class RealPass : public Pass {
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 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;
Expand Down

0 comments on commit 76de909

Please sign in to comment.