SSH Agent: Entry context menu control

This commit is contained in:
Toni Spets
2018-05-10 16:12:36 +03:00
committed by Jonathan White
parent d41a37c9bc
commit ef668f552e
10 changed files with 128 additions and 0 deletions

View File

@@ -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();