Commit 8ae525eb authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

improve dkimmenu

parent 9639d008
......@@ -56,6 +56,11 @@ void DKIMManager::setPolicy(const DKIMCheckPolicy &policy)
mCheckPolicy = policy;
}
void DKIMManager::recheckDKim(const Akonadi::Item &item)
{
checkFullInfo(item);
}
void DKIMManager::checkDKim(const Akonadi::Item &item)
{
if (mCheckPolicy.saveDkimResult()) {
......
......@@ -47,6 +47,7 @@ public:
Q_REQUIRED_RESULT DKIMCheckPolicy policy() const;
void setPolicy(const DKIMCheckPolicy &policy);
void recheckDKim(const Akonadi::Item &item);
Q_SIGNALS:
void result(const MessageViewer::DKIMCheckSignatureJob::CheckSignatureResult &checkResult, Akonadi::Item::Id id);
void clearInfo();
......
......@@ -41,7 +41,7 @@ QMenu *DKIMViewerMenu::menu() const
void DKIMViewerMenu::initialize()
{
mMenu = new QMenu;
mMenu = new QMenu(i18n("DKIM"));
QAction *checkSignature = mMenu->addAction(i18n("Recheck DKIM Signature"));
connect(checkSignature, &QAction::triggered, this, &DKIMViewerMenu::recheckSignature);
......
......@@ -1286,15 +1286,11 @@ void ViewerPrivate::setMessageItem(const Akonadi::Item &item, MimeTreeParser::Up
#ifdef USE_DKIM_CHECKER
if (!mPrinting) {
if (MessageViewer::MessageViewerSettings::self()->enabledDkim()) {
const Akonadi::Collection parentCollection = mMessageItem.parentCollection();
if ((Akonadi::SpecialMailCollections::self()->defaultCollection(Akonadi::SpecialMailCollections::SentMail) != parentCollection)
&& (Akonadi::SpecialMailCollections::self()->defaultCollection(Akonadi::SpecialMailCollections::Outbox) != parentCollection)
&& (Akonadi::SpecialMailCollections::self()->defaultCollection(Akonadi::SpecialMailCollections::Templates) != parentCollection)
&& (Akonadi::SpecialMailCollections::self()->defaultCollection(Akonadi::SpecialMailCollections::Drafts) != parentCollection)) {
if (messageIsInSpecialFolder()) {
mDkimWidgetInfo->clear();
} else {
mDkimWidgetInfo->setCurrentItemId(mMessageItem.id());
MessageViewer::DKIMManager::self()->checkDKim(mMessageItem);
} else {
mDkimWidgetInfo->clear();
}
}
}
......@@ -1303,6 +1299,19 @@ void ViewerPrivate::setMessageItem(const Akonadi::Item &item, MimeTreeParser::Up
setMessageInternal(mMessageItem.payload<KMime::Message::Ptr>(), updateMode);
}
bool ViewerPrivate::messageIsInSpecialFolder() const
{
const Akonadi::Collection parentCollection = mMessageItem.parentCollection();
if ((Akonadi::SpecialMailCollections::self()->defaultCollection(Akonadi::SpecialMailCollections::SentMail) != parentCollection)
&& (Akonadi::SpecialMailCollections::self()->defaultCollection(Akonadi::SpecialMailCollections::Outbox) != parentCollection)
&& (Akonadi::SpecialMailCollections::self()->defaultCollection(Akonadi::SpecialMailCollections::Templates) != parentCollection)
&& (Akonadi::SpecialMailCollections::self()->defaultCollection(Akonadi::SpecialMailCollections::Drafts) != parentCollection)) {
return false;
} else {
return true;
}
}
void ViewerPrivate::setMessage(const KMime::Message::Ptr &aMsg, MimeTreeParser::UpdateMode updateMode)
{
resetStateForNewMessage();
......@@ -3108,15 +3117,20 @@ void ViewerPrivate::updateShowMultiMessagesButton(bool enablePreviousButton, boo
#ifdef USE_DKIM_CHECKER
DKIMViewerMenu *ViewerPrivate::dkimViewerMenu()
{
if (!mDkimViewerMenu) {
mDkimViewerMenu = new MessageViewer::DKIMViewerMenu(this);
connect(mDkimViewerMenu, &DKIMViewerMenu::recheckSignature, this, [this]() {
//TODO
});
connect(mDkimViewerMenu, &DKIMViewerMenu::updateDKimKey, this, [this]() {
//TODO
});
if (MessageViewer::MessageViewerSettings::self()->enabledDkim()) {
if (!messageIsInSpecialFolder()) {
if (!mDkimViewerMenu) {
mDkimViewerMenu = new MessageViewer::DKIMViewerMenu(this);
connect(mDkimViewerMenu, &DKIMViewerMenu::recheckSignature, this, [this]() {
MessageViewer::DKIMManager::self()->checkDKim(mMessageItem);
});
connect(mDkimViewerMenu, &DKIMViewerMenu::updateDKimKey, this, [this]() {
//TODO
});
}
return mDkimViewerMenu;
}
}
return mDkimViewerMenu;
return nullptr;
}
#endif
......@@ -596,7 +596,8 @@ private:
void replyMessageToAuthor(KMime::Content *atmNode);
void replyMessageToAll(KMime::Content *atmNode);
bool urlIsAMalwareButContinue();
Q_REQUIRED_RESULT bool urlIsAMalwareButContinue();
Q_REQUIRED_RESULT bool messageIsInSpecialFolder() const;
void slotCheckedUrlFinished(const QUrl &url, WebEngineViewer::CheckPhishingUrlUtil::UrlStatus status);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment