diff --git a/src/fdosecrets/objects/Collection.cpp b/src/fdosecrets/objects/Collection.cpp index 3cac4815..c961f9b4 100644 --- a/src/fdosecrets/objects/Collection.cpp +++ b/src/fdosecrets/objects/Collection.cpp @@ -600,11 +600,11 @@ namespace FdoSecrets return qobject_cast(parent()); } - void Collection::doLock() + bool Collection::doLock() { Q_ASSERT(m_backend); - m_backend->lock(); + return m_backend->lock(); } void Collection::doUnlock() diff --git a/src/fdosecrets/objects/Collection.h b/src/fdosecrets/objects/Collection.h index 6098880f..da6dcb38 100644 --- a/src/fdosecrets/objects/Collection.h +++ b/src/fdosecrets/objects/Collection.h @@ -102,7 +102,7 @@ namespace FdoSecrets public slots: // expose some methods for Prmopt to use - void doLock(); + bool doLock(); void doUnlock(); // will remove self void doDelete(); diff --git a/src/fdosecrets/objects/Prompt.cpp b/src/fdosecrets/objects/Prompt.cpp index 6a2458a4..cb3cb4f4 100644 --- a/src/fdosecrets/objects/Prompt.cpp +++ b/src/fdosecrets/objects/Prompt.cpp @@ -65,7 +65,7 @@ namespace FdoSecrets DBusReturn PromptBase::dismiss() { - emit completed(true, {}); + emit completed(true, ""); return {}; } @@ -95,7 +95,7 @@ namespace FdoSecrets // only need to delete in backend, collection will react itself. auto accepted = service()->doCloseDatabase(m_collection->backend()); - emit completed(!accepted, {}); + emit completed(!accepted, ""); return {}; } @@ -125,11 +125,17 @@ namespace FdoSecrets } emit collectionCreated(coll); - emit completed(false, coll->objectPath().path()); + emit completed(false, QVariant::fromValue(coll->objectPath())); return {}; } + DBusReturn CreateCollectionPrompt::dismiss() + { + emit completed(true, QVariant::fromValue(QDBusObjectPath{"/"})); + return {}; + } + LockCollectionsPrompt::LockCollectionsPrompt(Service* parent, const QList& colls) : PromptBase(parent) { @@ -153,19 +159,26 @@ namespace FdoSecrets MessageBox::OverrideParent override(findWindow(windowId)); - QList locked; for (const auto& c : asConst(m_collections)) { if (c) { - c->doLock(); - locked << c->objectPath(); + if (!c->doLock()) { + return dismiss(); + } + m_locked << c->objectPath(); } } - emit completed(false, QVariant::fromValue(locked)); + emit completed(false, QVariant::fromValue(m_locked)); return {}; } + DBusReturn LockCollectionsPrompt::dismiss() + { + emit completed(true, QVariant::fromValue(m_locked)); + return {}; + } + UnlockCollectionsPrompt::UnlockCollectionsPrompt(Service* parent, const QList& colls) : PromptBase(parent) { @@ -191,6 +204,7 @@ namespace FdoSecrets for (const auto& c : asConst(m_collections)) { if (c) { + // doUnlock is nonblocking connect(c, &Collection::doneUnlockCollection, this, &UnlockCollectionsPrompt::collectionUnlockFinished); c->doUnlock(); } @@ -226,6 +240,11 @@ namespace FdoSecrets emit completed(m_unlocked.isEmpty(), QVariant::fromValue(m_unlocked)); } } + DBusReturn UnlockCollectionsPrompt::dismiss() + { + emit completed(true, QVariant::fromValue(m_unlocked)); + return {}; + } DeleteItemPrompt::DeleteItemPrompt(Service* parent, Item* item) : PromptBase(parent) @@ -250,14 +269,18 @@ namespace FdoSecrets // delete item's backend. Item will be notified after the backend is deleted. if (m_item) { if (FdoSecrets::settings()->noConfirmDeleteItem()) { - MessageBox::setNextAnswer(MessageBox::Move); + // based on permanent or not, different button is used + if (m_item->isDeletePermanent()) { + MessageBox::setNextAnswer(MessageBox::Delete); + } else { + MessageBox::setNextAnswer(MessageBox::Move); + } } m_item->collection()->doDeleteEntries({m_item->backend()}); } - emit completed(false, {}); + emit completed(false, ""); return {}; } - } // namespace FdoSecrets diff --git a/src/fdosecrets/objects/Prompt.h b/src/fdosecrets/objects/Prompt.h index fee1cb9f..683642df 100644 --- a/src/fdosecrets/objects/Prompt.h +++ b/src/fdosecrets/objects/Prompt.h @@ -73,6 +73,7 @@ namespace FdoSecrets explicit CreateCollectionPrompt(Service* parent); DBusReturn prompt(const QString& windowId) override; + DBusReturn dismiss() override; signals: void collectionCreated(Collection* coll); @@ -85,9 +86,11 @@ namespace FdoSecrets explicit LockCollectionsPrompt(Service* parent, const QList& colls); DBusReturn prompt(const QString& windowId) override; + DBusReturn dismiss() override; private: QList> m_collections; + QList m_locked; }; class UnlockCollectionsPrompt : public PromptBase @@ -97,6 +100,7 @@ namespace FdoSecrets explicit UnlockCollectionsPrompt(Service* parent, const QList& coll); DBusReturn prompt(const QString& windowId) override; + DBusReturn dismiss() override; private slots: void collectionUnlockFinished(bool accepted);