diff options
author | Anne Jan Brouwer <brouwer@annejan.com> | 2016-11-23 03:23:49 +0100 |
---|---|---|
committer | Anne Jan Brouwer <brouwer@annejan.com> | 2016-11-23 03:23:49 +0100 |
commit | e412d328f4a730a017de0cc0876c6efccd737fd2 (patch) | |
tree | 5461e9f78e0028846236b894b5098aa9f5247774 | |
parent | b3914787421fa0a2adb5e2e7a051d5c43290d013 (diff) |
housekeeping
31 files changed, 1668 insertions, 1687 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b6b4f9a..fd0d80cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ **Merged pull requests:** +- refactoring - pass ifce, process mgmt [\#234](https://github.com/IJHack/QtPass/pull/234) ([tezeb](https://github.com/tezeb)) - Solve Doubleclick issue [\#230](https://github.com/IJHack/QtPass/pull/230) ([jounathaen](https://github.com/jounathaen)) - refactoring, new QtPassSettings class, all settings should be read and written here [\#224](https://github.com/IJHack/QtPass/pull/224) ([YoshiMan](https://github.com/YoshiMan)) - Moved @YoshiMan 's copy buttons inside the line Edit [\#222](https://github.com/IJHack/QtPass/pull/222) ([jounathaen](https://github.com/jounathaen)) diff --git a/imitatepass.cpp b/imitatepass.cpp index 74131247..4e39bba8 100644 --- a/imitatepass.cpp +++ b/imitatepass.cpp @@ -2,45 +2,42 @@ #include "mainwindow.h" #include "qtpasssettings.h" -ImitatePass::ImitatePass() -{ - -} +ImitatePass::ImitatePass() {} /** * @brief ImitatePass::GitInit git init wrapper */ void ImitatePass::GitInit() { - executeWrapper(QtPassSettings::getGitExecutable(), - "init \"" + QtPassSettings::getPassStore() + '"'); + executeWrapper(QtPassSettings::getGitExecutable(), + "init \"" + QtPassSettings::getPassStore() + '"'); } /** * @brief ImitatePass::GitPull git init wrapper */ void ImitatePass::GitPull() { - executeWrapper(QtPassSettings::getGitExecutable(), "pull"); + executeWrapper(QtPassSettings::getGitExecutable(), "pull"); } /** * @brief ImitatePass::GitPush git init wrapper */ void ImitatePass::GitPush() { - executeWrapper(QtPassSettings::getGitExecutable(), "push"); + executeWrapper(QtPassSettings::getGitExecutable(), "push"); } /** * @brief ImitatePass::Show git init wrapper */ QProcess::ExitStatus ImitatePass::Show(QString file, bool block) { - // TODO(bezet): apparently not yet needed - // file += ".gpg"; - executeWrapper(QtPassSettings::getGpgExecutable(), - "-d --quiet --yes --no-encrypt-to --batch --use-agent \"" + - file + '"'); - if(block) - return waitForProcess(); - return QProcess::NormalExit; + // TODO(bezet): apparently not yet needed + // file += ".gpg"; + executeWrapper(QtPassSettings::getGpgExecutable(), + "-d --quiet --yes --no-encrypt-to --batch --use-agent \"" + + file + '"'); + if (block) + return waitForProcess(); + return QProcess::NormalExit; } /** @@ -51,58 +48,57 @@ QProcess::ExitStatus ImitatePass::Show(QString file, bool block) { * @param overwrite whether to overwrite existing file */ void ImitatePass::Insert(QString file, QString newValue, bool overwrite) { - file += ".gpg"; - // TODO(bezet): getRecipientString is in MainWindow for now - fix this ;) - QString recipients = Pass::getRecipientString(file, " -r "); - if (recipients.isEmpty()) { - // TODO(bezet): probably throw here - emit critical(tr("Can not edit"), - tr("Could not read encryption key to use, .gpg-id " - "file missing or invalid.")); - return; - } - QString force(overwrite ? " --yes " : " "); - executeWrapper(QtPassSettings::getGpgExecutable(), - force + "--batch -eq --output \"" + file + "\" " + - recipients + " -", - newValue); - if (!QtPassSettings::isUseWebDav() && QtPassSettings::isUseGit()) { - if (!overwrite) - executeWrapper(QtPassSettings::getGitExecutable(), - "add \"" + file + '"'); - QString path = - QDir(QtPassSettings::getPassStore()).relativeFilePath(file); - path.replace(QRegExp("\\.gpg$"), ""); - executeWrapper(QtPassSettings::getGitExecutable(), - "commit \"" + file + "\" -m \"" + - (overwrite ? "Edit" : "Add") + " for " + path + - " using QtPass.\""); - } + file += ".gpg"; + // TODO(bezet): getRecipientString is in MainWindow for now - fix this ;) + QString recipients = Pass::getRecipientString(file, " -r "); + if (recipients.isEmpty()) { + // TODO(bezet): probably throw here + emit critical(tr("Can not edit"), + tr("Could not read encryption key to use, .gpg-id " + "file missing or invalid.")); + return; + } + QString force(overwrite ? " --yes " : " "); + executeWrapper(QtPassSettings::getGpgExecutable(), + force + "--batch -eq --output \"" + file + "\" " + recipients + + " -", + newValue); + if (!QtPassSettings::isUseWebDav() && QtPassSettings::isUseGit()) { + if (!overwrite) + executeWrapper(QtPassSettings::getGitExecutable(), "add \"" + file + '"'); + QString path = QDir(QtPassSettings::getPassStore()).relativeFilePath(file); + path.replace(QRegExp("\\.gpg$"), ""); + executeWrapper(QtPassSettings::getGitExecutable(), + "commit \"" + file + "\" -m \"" + + (overwrite ? "Edit" : "Add") + " for " + path + + " using QtPass.\""); + } } /** * @brief ImitatePass::Remove git init wrapper */ void ImitatePass::Remove(QString file, bool isDir) { - if (QtPassSettings::isUseGit()) { - executeWrapper(QtPassSettings::getGitExecutable(), - QString("rm ") + (isDir?"-rf ":"-f ") + '"' + file + '"'); - // TODO(bezet): commit message used to have pass-like file name inside(ie. getFile(file, true) - executeWrapper(QtPassSettings::getGitExecutable(), - "commit \"" + file + "\" -m \"Remove for " + - file + - " using QtPass.\""); - } else { - if(isDir) { + if (QtPassSettings::isUseGit()) { + executeWrapper(QtPassSettings::getGitExecutable(), + QString("rm ") + (isDir ? "-rf " : "-f ") + '"' + file + + '"'); + // TODO(bezet): commit message used to have pass-like file name inside(ie. + // getFile(file, true) + executeWrapper(QtPassSettings::getGitExecutable(), + "commit \"" + file + "\" -m \"Remove for " + file + + " using QtPass.\""); + } else { + if (isDir) { #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) - QDir dir(file); - dir.removeRecursively(); + QDir dir(file); + dir.removeRecursively(); #else - removeDir(QtPassSettings::getPassStore() + file); + removeDir(QtPassSettings::getPassStore() + file); #endif - } else - QFile(file).remove(); - } + } else + QFile(file).remove(); + } } /** @@ -112,46 +108,47 @@ void ImitatePass::Remove(QString file, bool isDir) { * @param users list of users who shall be able to decrypt passwords in path */ void ImitatePass::Init(QString path, const QList<UserInfo> &users) { - QString gpgIdFile = path + ".gpg-id"; - QFile gpgId(gpgIdFile); - bool addFile = false; - if (QtPassSettings::isAddGPGId(true)) { - QFileInfo checkFile(gpgIdFile); - if (!checkFile.exists() || !checkFile.isFile()) - addFile = true; - } - if (!gpgId.open(QIODevice::WriteOnly | QIODevice::Text)) { - emit critical(tr("Cannot update"), - tr("Failed to open .gpg-id for writing.")); - return; - } - bool secret_selected = false; - foreach (const UserInfo &user, users) { - if (user.enabled) { - gpgId.write((user.key_id + "\n").toUtf8()); - secret_selected |= user.have_secret; - } - } - gpgId.close(); - if (!secret_selected) { - emit critical(tr("Check selected users!"), - tr("None of the selected keys have a secret key available.\n" - "You will not be able to decrypt any newly added passwords!")); - return; + QString gpgIdFile = path + ".gpg-id"; + QFile gpgId(gpgIdFile); + bool addFile = false; + if (QtPassSettings::isAddGPGId(true)) { + QFileInfo checkFile(gpgIdFile); + if (!checkFile.exists() || !checkFile.isFile()) + addFile = true; + } + if (!gpgId.open(QIODevice::WriteOnly | QIODevice::Text)) { + emit critical(tr("Cannot update"), + tr("Failed to open .gpg-id for writing.")); + return; + } + bool secret_selected = false; + foreach (const UserInfo &user, users) { + if (user.enabled) { + gpgId.write((user.key_id + "\n").toUtf8()); + secret_selected |= user.have_secret; } + } + gpgId.close(); + if (!secret_selected) { + emit critical( + tr("Check selected users!"), + tr("None of the selected keys have a secret key available.\n" + "You will not be able to decrypt any newly added passwords!")); + return; + } - if (!QtPassSettings::isUseWebDav() && QtPassSettings::isUseGit() && - !QtPassSettings::getGitExecutable().isEmpty()) { - if (addFile) - executeWrapper(QtPassSettings::getGitExecutable(), - "add \"" + gpgIdFile + '"'); - QString path = gpgIdFile; - path.replace(QRegExp("\\.gpg$"), ""); + if (!QtPassSettings::isUseWebDav() && QtPassSettings::isUseGit() && + !QtPassSettings::getGitExecutable().isEmpty()) { + if (addFile) executeWrapper(QtPassSettings::getGitExecutable(), - "commit \"" + gpgIdFile + "\" -m \"Added " + path + - " using QtPass.\""); - } - reencryptPath(path); + "add \"" + gpgIdFile + '"'); + QString path = gpgIdFile; + path.replace(QRegExp("\\.gpg$"), ""); + executeWrapper(QtPassSettings::getGitExecutable(), + "commit \"" + gpgIdFile + "\" -m \"Added " + path + + " using QtPass.\""); + } + reencryptPath(path); } /** @@ -243,16 +240,17 @@ void ImitatePass::reencryptPath(QString dir) { local_lastDecrypt = process.readAllStandardOutput(); emit lastDecrypt(local_lastDecrypt); - if (!local_lastDecrypt.isEmpty() && local_lastDecrypt != "Could not decrypt") { + if (!local_lastDecrypt.isEmpty() && + local_lastDecrypt != "Could not decrypt") { if (local_lastDecrypt.right(1) != "\n") local_lastDecrypt += "\n"; emit lastDecrypt(local_lastDecrypt); QString recipients = getRecipientString(fileName, " -r "); if (recipients.isEmpty()) { - emit critical(tr("Can not edit"), - tr("Could not read encryption key to use, .gpg-id " - "file missing or invalid.")); + emit critical(tr("Can not edit"), + tr("Could not read encryption key to use, .gpg-id " + "file missing or invalid.")); return; } executeWrapper(QtPassSettings::getGpgExecutable(), @@ -279,8 +277,8 @@ void ImitatePass::reencryptPath(QString dir) { } } if (QtPassSettings::isAutoPush()) { - emit statusMsg(tr("Updating password-store"), 2000); - GitPush(); + emit statusMsg(tr("Updating password-store"), 2000); + GitPush(); } emit endReencryptPath(); } diff --git a/imitatepass.h b/imitatepass.h index 26cb0fab..cc56cb62 100644 --- a/imitatepass.h +++ b/imitatepass.h @@ -3,28 +3,28 @@ #include "pass.h" -class ImitatePass : public Pass -{ - Q_OBJECT +class ImitatePass : public Pass { + Q_OBJECT + + bool removeDir(const QString &dirName); - bool removeDir(const QString &dirName); public: - ImitatePass(); - virtual ~ImitatePass() {} - virtual void GitInit() override; - virtual void GitPull() override; - virtual void GitPush() override; - virtual QProcess::ExitStatus Show(QString file, bool block=false) override; - virtual void Insert(QString file, QString value, bool overwrite=false) override; - virtual void Remove(QString file, bool isDir = false) override; - virtual void Init(QString path, const QList<UserInfo> &list) override; + ImitatePass(); + virtual ~ImitatePass() {} + virtual void GitInit() override; + virtual void GitPull() override; + virtual void GitPush() override; + virtual QProcess::ExitStatus Show(QString file, bool block = false) override; + virtual void Insert(QString file, QString value, + bool overwrite = false) override; + virtual void Remove(QString file, bool isDir = false) override; + virtual void Init(QString path, const QList<UserInfo> &list) override; - void reencryptPath(QString dir); + void reencryptPath(QString dir); signals: - void startReencryptPath(); - void endReencryptPath(); - void lastDecrypt(QString); - + void startReencryptPath(); + void endReencryptPath(); + void lastDecrypt(QString); }; #endif // IMITATEPASS_H diff --git a/localization/localization_ar_MA.ts b/localization/localization_ar_MA.ts index e0d646f4..209c72f0 100644 --- a/localization/localization_ar_MA.ts +++ b/localization/localization_ar_MA.ts @@ -364,46 +364,46 @@ email</source> <context> <name>ImitatePass</name> <message> - <location filename="../imitatepass.cpp" line="59"/> - <location filename="../imitatepass.cpp" line="253"/> + <location filename="../imitatepass.cpp" line="56"/> + <location filename="../imitatepass.cpp" line="251"/> <source>Can not edit</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../imitatepass.cpp" line="60"/> - <location filename="../imitatepass.cpp" line="254"/> + <location filename="../imitatepass.cpp" line="57"/> + <location filename="../imitatepass.cpp" line="252"/> <source>Could not read encryption key to use, .gpg-id file missing or invalid.</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../imitatepass.cpp" line="124"/> + <location filename="../imitatepass.cpp" line="120"/> <source>Cannot update</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../imitatepass.cpp" line="125"/> + <location filename="../imitatepass.cpp" line="121"/> <source>Failed to open .gpg-id for writing.</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../imitatepass.cpp" line="137"/> + <location filename="../imitatepass.cpp" line="134"/> <source>Check selected users!</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../imitatepass.cpp" line="138"/> + <location filename="../imitatepass.cpp" line="135"/> <source>None of the selected keys have a secret key available. You will not be able to decrypt any newly added passwords!</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../imitatepass.cpp" line="192"/> + <location filename="../imitatepass.cpp" line="189"/> <source>Re-encrypting from folder %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../imitatepass.cpp" line="196"/> - <location filename="../imitatepass.cpp" line="282"/> + <location filename="../imitatepass.cpp" line="193"/> + <location filename="../imitatepass.cpp" line="280"/> <source>Updating password-store</source> <translation type="unfinished"></translation> </message> @@ -511,14 +511,14 @@ Expire-Date: 0 <message> <location filename="../mainwindow.ui" line="72"/> <location filename="../mainwindow.ui" line="75"/> - <location filename="../mainwindow.cpp" line="1366"/> + <location filename="../mainwindow.cpp" line="1353"/> <source>Edit</source> <translation type="unfinished"></translation> </message> <message> <location filename="../mainwindow.ui" line="90"/> <location filename="../mainwindow.ui" line="93"/> - <location filename="../mainwindow.cpp" line="1378"/> + <location filename="../mainwindow.cpp" line="1365"/> <source>Delete</source> <translation type="unfinished"></translation> </message> @@ -549,7 +549,7 @@ Expire-Date: 0 </message> <message> <location filename="../mainwindow.ui" line="179"/> - <location filename="../mainwindow.cpp" line="1360"/> + <location filename="../mainwindow.cpp" line="1347"/> <source>Users</source> <translation type="unfinished"></translation> </message> @@ -591,212 +591,212 @@ p, li { white-space: pre-wrap; } <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="172"/> + <location filename="../mainwindow.cpp" line="171"/> <source>Failed to connect WebDAV: </source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="184"/> + <location filename="../mainwindow.cpp" line="183"/> <source>QtPass WebDAV password</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="185"/> + <location filename="../mainwindow.cpp" line="184"/> <source>Enter password to connect to WebDAV:</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="201"/> + <location filename="../mainwindow.cpp" line="200"/> <source>fusedav exited unexpectedly </source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="205"/> + <location filename="../mainwindow.cpp" line="204"/> <source>Failed to start fusedav to connect WebDAV: </source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="525"/> - <location filename="../mainwindow.cpp" line="534"/> + <location filename="../mainwindow.cpp" line="513"/> + <location filename="../mainwindow.cpp" line="522"/> <source>Updating password-store</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="1405"/> + <location filename="../mainwindow.cpp" line="1392"/> <source>New Folder: (Will be placed in %1 )</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="684"/> + <location filename="../mainwindow.cpp" line="672"/> <source>Password hidden</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="90"/> + <location filename="../mainwindow.cpp" line="89"/> <source>Add Password</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="91"/> + <location filename="../mainwindow.cpp" line="90"/> <source>Add Folder</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="688"/> + <location filename="../mainwindow.cpp" line="676"/> <source>Content hidden</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="782"/> + <location filename="../mainwindow.cpp" line="770"/> <source>Clipboard cleared</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="784"/> + <location filename="../mainwindow.cpp" line="772"/> <source>Clipboard not cleared</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="798"/> + <location filename="../mainwindow.cpp" line="786"/> <source>Password and Content hidden</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="848"/> + <location filename="../mainwindow.cpp" line="836"/> <source>QProcess::FailedToStart</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="851"/> + <location filename="../mainwindow.cpp" line="839"/> <source>QProcess::Crashed</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="854"/> + <location filename="../mainwindow.cpp" line="842"/> <source>QProcess::Timedout</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="857"/> + <location filename="../mainwindow.cpp" line="845"/> <source>QProcess::ReadError</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="860"/> + <location filename="../mainwindow.cpp" line="848"/> <source>QProcess::WriteError</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="863"/> + <location filename="../mainwindow.cpp" line="851"/> <source>QProcess::UnknownError</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="885"/> + <location filename="../mainwindow.cpp" line="874"/> <source>Looking for: %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="616"/> - <location filename="../mainwindow.cpp" line="1053"/> + <location filename="../mainwindow.cpp" line="604"/> + <location filename="../mainwindow.cpp" line="1040"/> <source>Can not edit</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="998"/> - <location filename="../mainwindow.cpp" line="1404"/> + <location filename="../mainwindow.cpp" line="987"/> + <location filename="../mainwindow.cpp" line="1391"/> <source>New file</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="1029"/> + <location filename="../mainwindow.cpp" line="1016"/> <source>Delete password?</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="1030"/> + <location filename="../mainwindow.cpp" line="1017"/> <source>Are you sure you want to delete %1?</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="1029"/> + <location filename="../mainwindow.cpp" line="1016"/> <source>Delete folder?</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="617"/> - <location filename="../mainwindow.cpp" line="1054"/> + <location filename="../mainwindow.cpp" line="605"/> + <location filename="../mainwindow.cpp" line="1041"/> <source>Selected password file does not exist, not able to edit</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="74"/> + <location filename="../mainwindow.cpp" line="73"/> <source>Welcome to QtPass %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="728"/> - <location filename="../mainwindow.cpp" line="1535"/> + <location filename="../mainwindow.cpp" line="716"/> + <location filename="../mainwindow.cpp" line="1523"/> <source>Password</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="999"/> + <location filename="../mainwindow.cpp" line="988"/> <source>New password file: (Will be placed in %1 )</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="1083"/> + <location filename="../mainwindow.cpp" line="1070"/> <source>Can not get key list</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="1084"/> + <location filename="../mainwindow.cpp" line="1071"/> <source>Unable to get list of available gpg keys</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="1115"/> + <location filename="../mainwindow.cpp" line="1102"/> <source>Key not found in keyring</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="1192"/> + <location filename="../mainwindow.cpp" line="1179"/> <source>Generating GPG key pair</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="1235"/> + <location filename="../mainwindow.cpp" line="1222"/> <source>Profile changed to %1</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="1358"/> + <location filename="../mainwindow.cpp" line="1345"/> <source>Add folder</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="1359"/> + <location filename="../mainwindow.cpp" line="1346"/> <source>Add password</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="1453"/> + <location filename="../mainwindow.cpp" line="1441"/> <source>No characters chosen</source> <translation type="unfinished"></translation> </message> <message> - <location filename="../mainwindow.cpp" line="1454"/> + <location filename="../m |