SSH Agent: Reload settings when KeeAgent.settings attachment changed

Signed-off-by: Konrad Vité <kvite@paktolos.net>
This commit is contained in:
Konrad Vité 2025-02-12 16:16:23 +01:00
parent 76860ce57a
commit 6063508e7a
3 changed files with 20 additions and 1 deletions

View file

@ -661,6 +661,12 @@ void EditEntryWidget::updateSSHAgentAttachments()
setSSHAgentSettings();
}
if (KeeAgentSettings::inEntryAttachments(m_attachments.data())) {
m_sshAgentSettings.reset();
m_sshAgentSettings.fromEntryAttachments(m_attachments.data());
setSSHAgentSettings();
}
m_sshAgentUi->attachmentComboBox->clear();
m_sshAgentUi->attachmentComboBox->addItem("");

View file

@ -533,7 +533,19 @@ bool KeeAgentSettings::inEntryAttachments(const EntryAttachments* attachments)
*/
bool KeeAgentSettings::fromEntry(const Entry* entry)
{
const auto attachments = entry->attachments();
return KeeAgentSettings::fromEntryAttachments(entry->attachments());
}
/**
* Read settings from entry attachments as an XML attachment.
*
* Sets error string on error.
*
* @param entry EntryAttachments to read the attachment from
* @return true if XML document was loaded
*/
bool KeeAgentSettings::fromEntryAttachments(const EntryAttachments* attachments)
{
if (attachments->hasKey("KeeAgent.settings")) {
return fromXml(attachments->value("KeeAgent.settings"));
}

View file

@ -61,6 +61,7 @@ public:
static bool inEntryAttachments(const EntryAttachments* attachments);
bool fromEntry(const Entry* entry);
bool fromEntryAttachments(const EntryAttachments* attachments);
void toEntry(Entry* entry) const;
bool keyConfigured() const;
bool toOpenSSHKey(const Entry* entry, OpenSSHKey& key, bool decrypt);