Commit e2398e12 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Move MDN code to kmreaderwin

parent 9c8f858e
Pipeline #214683 failed with stage
in 50 seconds
......@@ -42,11 +42,9 @@
#endif
#include <KSieveUi/SieveDebugDialog>
#include <MailCommon/FolderTreeView>
#include <MailCommon/MDNWarningJob>
#include <MailCommon/MailKernel>
#include <MailCommon/MailUtil>
#include <MailCommon/SearchRuleStatus>
#include <MessageComposer/MDNWarningWidgetJob>
#include "collectionpage/collectionmailinglistpage.h"
#include "collectionpage/collectionquotapage.h"
......@@ -123,7 +121,6 @@
#include <Akonadi/ItemFetchJob>
#include <Akonadi/ItemFetchScope>
#include <Akonadi/ItemModifyJob>
#include <Akonadi/MDNStateAttribute>
#include <Akonadi/MessageFlags>
#include <Akonadi/Session>
#include <Akonadi/StandardActionManager>
......@@ -1056,7 +1053,6 @@ void KMMainWidget::createWidgets()
connect(mMsgView->viewer(), &MessageViewer::Viewer::replyMessageTo, this, &KMMainWidget::slotReplyMessageTo);
connect(mMsgView->viewer(), &MessageViewer::Viewer::showStatusBarMessage, this, &KMMainWidget::setShowStatusBarMessage);
connect(mMsgView->viewer(), &MessageViewer::Viewer::zoomChanged, this, &KMMainWidget::setZoomChanged);
connect(mMsgView->viewer()->mdnWarning(), &MessageViewer::MDNWarningWidget::sendResponse, this, &KMMainWidget::slotSendMdnResponse);
if (mShowIntroductionAction) {
mShowIntroductionAction->setEnabled(true);
}
......@@ -1186,31 +1182,6 @@ void KMMainWidget::createWidgets()
connect(kmkernel->folderCollectionMonitor(), &Monitor::collectionStatisticsChanged, this, &KMMainWidget::slotCollectionStatisticsChanged);
}
void KMMainWidget::slotSendMdnResponse(MessageViewer::MDNWarningWidget::ResponseType type, KMime::MDN::SendingMode sendingMode)
{
MailCommon::MDNWarningJob::ResponseMDN response = MailCommon::MDNWarningJob::ResponseMDN::Unknown;
switch (type) {
case MessageViewer::MDNWarningWidget::ResponseType::Ignore:
response = MailCommon::MDNWarningJob::ResponseMDN::MDNIgnore;
break;
case MessageViewer::MDNWarningWidget::ResponseType::Send:
response = MailCommon::MDNWarningJob::ResponseMDN::Send;
break;
case MessageViewer::MDNWarningWidget::ResponseType::SendDeny:
response = MailCommon::MDNWarningJob::ResponseMDN::Denied;
break;
}
auto job = new MailCommon::MDNWarningJob(KMKernel::self(), this);
job->setItem(mMsgView->messageItem());
job->setResponse(response);
job->setSendingMode(sendingMode);
job->start();
connect(job, &MDNWarningJob::finished, this, [this]() {
mMsgView->viewer()->mdnWarning()->animatedHide();
});
}
void KMMainWidget::updateMoveAction(const Akonadi::CollectionStatistics &statistic)
{
const bool hasUnreadMails = (statistic.unreadCount() > 0);
......@@ -4494,18 +4465,6 @@ void KMMainWidget::slotMessageSelected(const Akonadi::Item &item)
}
}
void KMMainWidget::slotShowMdnInfo(const QPair<QString, bool> &mdnInfo)
{
if (mMsgView) {
if (!mdnInfo.first.isEmpty()) {
mMsgView->viewer()->mdnWarning()->setCanDeny(mdnInfo.second);
mMsgView->viewer()->mdnWarning()->setInformation(mdnInfo.first);
} else {
mMsgView->viewer()->mdnWarning()->animatedHide();
}
}
}
void KMMainWidget::itemsReceived(const Akonadi::Item::List &list)
{
qCDebug(KMAIL_LOG) << " list count " << list.count();
......@@ -4533,13 +4492,6 @@ void KMMainWidget::itemsReceived(const Akonadi::Item::List &list)
}
return;
}
if (!item.hasAttribute<Akonadi::MDNStateAttribute>()
|| (item.hasAttribute<Akonadi::MDNStateAttribute>()
&& item.attribute<Akonadi::MDNStateAttribute>()->mdnState() == Akonadi::MDNStateAttribute::MDNStateUnknown)) {
sendMdnInfo(item);
} else {
mMsgView->viewer()->mdnWarning()->animatedHide();
}
}
Akonadi::Item copyItem(item);
......@@ -4553,16 +4505,6 @@ void KMMainWidget::itemsReceived(const Akonadi::Item::List &list)
mMsgActions->setCurrentMessage(copyItem);
}
void KMMainWidget::sendMdnInfo(const Akonadi::Item &item)
{
auto job = new MessageComposer::MDNWarningWidgetJob(this);
job->setItem(item);
connect(job, &MessageComposer::MDNWarningWidgetJob::showMdnInfo, this, &KMMainWidget::slotShowMdnInfo);
if (!job->start()) {
qCWarning(KMAIL_LOG) << "Impossible to start MDNWarningWidgetJob";
}
}
void KMMainWidget::itemsFetchDone(KJob *job)
{
delete mShowBusySplashTimer;
......
......@@ -14,7 +14,6 @@
#include "kmreaderwin.h" //for inline actions
#include <MailCommon/FolderTreeWidget>
#include <MessageViewer/MDNWarningWidget>
#include "messageactions.h"
#include <Akonadi/StandardMailActionManager>
......@@ -515,7 +514,6 @@ private Q_SLOTS:
void slotReplyMessageTo(const KMime::Message::Ptr &message, bool replyToAll);
private:
void slotSendMdnResponse(MessageViewer::MDNWarningWidget::ResponseType type, KMime::MDN::SendingMode sendingMode);
void slotSetFocusToViewer();
void deleteSelectedMessages(bool confirmDelete); // completely delete message
bool showSearchDialog();
......@@ -535,8 +533,6 @@ private:
void redoSwitchFolder();
void undoSwitchFolder();
void updateMoveAllToTrash();
void slotShowMdnInfo(const QPair<QString, bool> &mdnInfo);
void sendMdnInfo(const Akonadi::Item &item);
void slotClearFolder();
void slotClearCacheDone();
......
......@@ -43,6 +43,7 @@ using namespace MessageViewer;
#include <MessageComposer/Composer>
#include <MessageComposer/InfoPart>
#include <MessageComposer/MDNWarningWidgetJob>
#include <MessageComposer/MessageSender>
#include <MessageComposer/TextPart>
#include <MessageViewer/AttachmentStrategy>
......@@ -65,6 +66,7 @@ using namespace MessageViewer;
#undef Never
#undef Always
#include <MailCommon/MDNWarningJob>
#include <MailCommon/MailUtil>
#include <KLazyLocalizedString>
......@@ -97,6 +99,7 @@ KMReaderWin::KMReaderWin(QWidget *aParent, QWidget *mainWindow, KActionCollectio
connect(mViewer, qOverload<const Akonadi::Item &>(&Viewer::deleteMessage), this, &KMReaderWin::slotDeleteMessage);
connect(mViewer, &MessageViewer::Viewer::showNextMessage, this, &KMReaderWin::showNextMessage);
connect(mViewer, &MessageViewer::Viewer::showPreviousMessage, this, &KMReaderWin::showPreviousMessage);
connect(mViewer->mdnWarning(), &MessageViewer::MDNWarningWidget::sendResponse, this, &KMReaderWin::slotSendMdnResponse);
mViewer->addMessageLoadedHandler(new MessageViewer::MarkMessageReadHandler(this));
// mViewer->addMessageLoadedHandler(new MailCommon::SendMdnHandler(kmkernel, this));
......@@ -676,6 +679,13 @@ void KMReaderWin::setMessage(const Akonadi::Item &item, MimeTreeParser::UpdateMo
qCDebug(KMAIL_LOG) << Q_FUNC_INFO << parentWidget();
mViewer->setFolderIdentity(MailCommon::Util::folderIdentity(item));
mViewer->setMessageItem(item, updateMode);
if (!item.hasAttribute<Akonadi::MDNStateAttribute>()
|| (item.hasAttribute<Akonadi::MDNStateAttribute>()
&& item.attribute<Akonadi::MDNStateAttribute>()->mdnState() == Akonadi::MDNStateAttribute::MDNStateUnknown)) {
sendMdnInfo(item);
} else {
mViewer->mdnWarning()->animatedHide();
}
}
void KMReaderWin::setMessage(const KMime::Message::Ptr &message)
......@@ -929,3 +939,48 @@ void KMReaderWin::slotPrintingFinished()
deleteLater();
}
}
void KMReaderWin::sendMdnInfo(const Akonadi::Item &item)
{
auto job = new MessageComposer::MDNWarningWidgetJob(this);
job->setItem(item);
connect(job, &MessageComposer::MDNWarningWidgetJob::showMdnInfo, this, &KMReaderWin::slotShowMdnInfo);
if (!job->start()) {
qCWarning(KMAIL_LOG) << "Impossible to start MDNWarningWidgetJob";
}
}
void KMReaderWin::slotShowMdnInfo(const QPair<QString, bool> &mdnInfo)
{
if (!mdnInfo.first.isEmpty()) {
mViewer->mdnWarning()->setCanDeny(mdnInfo.second);
mViewer->mdnWarning()->setInformation(mdnInfo.first);
} else {
mViewer->mdnWarning()->animatedHide();
}
}
void KMReaderWin::slotSendMdnResponse(MessageViewer::MDNWarningWidget::ResponseType type, KMime::MDN::SendingMode sendingMode)
{
MailCommon::MDNWarningJob::ResponseMDN response = MailCommon::MDNWarningJob::ResponseMDN::Unknown;
switch (type) {
case MessageViewer::MDNWarningWidget::ResponseType::Ignore:
response = MailCommon::MDNWarningJob::ResponseMDN::MDNIgnore;
break;
case MessageViewer::MDNWarningWidget::ResponseType::Send:
response = MailCommon::MDNWarningJob::ResponseMDN::Send;
break;
case MessageViewer::MDNWarningWidget::ResponseType::SendDeny:
response = MailCommon::MDNWarningJob::ResponseMDN::Denied;
break;
}
auto job = new MailCommon::MDNWarningJob(KMKernel::self(), this);
job->setItem(mViewer->messageItem());
job->setResponse(response);
job->setSendingMode(sendingMode);
job->start();
connect(job, &MDNWarningJob::finished, this, [this]() {
mViewer->mdnWarning()->animatedHide();
});
}
......@@ -12,6 +12,7 @@
#include <Akonadi/Item>
#include <KContacts/Addressee>
#include <MessageViewer/MDNWarningWidget>
#include <MessageViewer/Viewer>
#include <MimeTreeParser/BodyPart>
#include <QUrl>
......@@ -216,6 +217,9 @@ private:
void createActions();
void updateHtmlActions();
void slotContactHtmlPreferencesUpdated(const Akonadi::Item &contact, Akonadi::Item::Id id, bool showAsHTML, bool remoteContent);
void slotSendMdnResponse(MessageViewer::MDNWarningWidget::ResponseType type, KMime::MDN::SendingMode sendingMode);
void sendMdnInfo(const Akonadi::Item &item);
void slotShowMdnInfo(const QPair<QString, bool> &mdnInfo);
private:
KContacts::Addressee mSearchedAddress;
......
Supports Markdown
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