diff options
author | Toni Spets <toni.spets@iki.fi> | 2018-05-10 16:12:36 +0300 |
---|---|---|
committer | Jonathan White <support@dmapps.us> | 2020-04-08 20:44:27 +0300 |
commit | ef668f552ed20b801f62b9cd2b6cf395c01bab0c (patch) | |
tree | a376f1cf23ac3f67859e96a48a62e1d28cac6362 /src/gui/DatabaseWidget.cpp | |
parent | d41a37c9bc4947c9aa7bbbe5fa46f74933a74795 (diff) |
SSH Agent: Entry context menu control
Diffstat (limited to 'src/gui/DatabaseWidget.cpp')
-rw-r--r-- | src/gui/DatabaseWidget.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index e6cc9f309..a9f628735 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -699,6 +699,50 @@ void DatabaseWidget::setClipboardTextAndMinimize(const QString& text) } } +#ifdef WITH_XC_SSHAGENT +void DatabaseWidget::addToAgent() +{ + Entry* currentEntry = m_entryView->currentEntry(); + Q_ASSERT(currentEntry); + if (!currentEntry) { + return; + } + + KeeAgentSettings settings; + if (!settings.fromEntry(currentEntry)) { + return; + } + + OpenSSHKey key; + if (settings.toOpenSSHKey(currentEntry, key, true)) { + SSHAgent::instance()->addIdentity(key, settings); + } else { + m_messageWidget->showMessage(key.errorString(), MessageWidget::Error); + } +} + +void DatabaseWidget::removeFromAgent() +{ + Entry* currentEntry = m_entryView->currentEntry(); + Q_ASSERT(currentEntry); + if (!currentEntry) { + return; + } + + KeeAgentSettings settings; + if (!settings.fromEntry(currentEntry)) { + return; + } + + OpenSSHKey key; + if (settings.toOpenSSHKey(currentEntry, key, false)) { + SSHAgent::instance()->removeIdentity(key); + } else { + m_messageWidget->showMessage(key.errorString(), MessageWidget::Error); + } +} +#endif + void DatabaseWidget::performAutoType() { auto currentEntry = currentSelectedEntry(); @@ -1625,6 +1669,19 @@ bool DatabaseWidget::currentEntryHasTotp() return currentEntry->hasTotp(); } +#ifdef WITH_XC_SSHAGENT +bool DatabaseWidget::currentEntryHasSshKey() +{ + Entry* currentEntry = m_entryView->currentEntry(); + Q_ASSERT(currentEntry); + if (!currentEntry) { + return false; + } + + return KeeAgentSettings::inEntry(currentEntry); +} +#endif + bool DatabaseWidget::currentEntryHasNotes() { auto currentEntry = currentSelectedEntry(); |