Commit f0e9da03 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖

Use ETM or CommonKernel API to resolve full collection

Instead of using MailCommon::Util method, which did the same as what
CommonKernel->collectionFromId() did. The MailCommon method was removed
and CommonKernel now uses the new fast API directly from ETM.
parent cca9c210
......@@ -60,7 +60,7 @@ set(KMAILTRANSPORT_LIB_VERSION "5.6.40")
set(KONTACTINTERFACE_LIB_VERSION "5.6.40")
set(KMIME_LIB_VERSION "5.6.40")
set(KPIMTEXTEDIT_LIB_VERSION "5.6.40")
set(AKONADI_VERSION "5.6.40")
set(AKONADI_VERSION "5.6.42")
set(KTNEF_LIB_VERSION "5.6.40")
set(KDEPIM_LIB_VERSION "${KDEPIM_VERSION_NUMBER}")
......
......@@ -46,6 +46,8 @@ public:
void archiveFolder(const QString &path, Akonadi::Collection::Id collectionId);
ArchiveMailKernel *kernel() const { return mArchiveMailKernel; }
public Q_SLOTS:
void load();
void slotArchiveNow(ArchiveMailInfo *info);
......
......@@ -20,11 +20,15 @@
#include "archivejob.h"
#include "archivemailinfo.h"
#include "archivemailmanager.h"
#include "archivemailkernel.h"
#include "archivemailagent_debug.h"
#include "MailCommon/MailUtil"
#include <MailCommon/MailUtil>
#include <MailCommon/BackupJob>
#include <AkonadiCore/EntityMimeTypeFilterModel>
#include <KNotification>
#include <KLocalizedString>
#include <QIcon>
......@@ -76,7 +80,7 @@ void ArchiveJob::execute()
}
MailCommon::BackupJob *backupJob = new MailCommon::BackupJob();
backupJob->setRootFolder(MailCommon::Util::updatedCollection(collection));
backupJob->setRootFolder(Akonadi::EntityTreeModel::updatedCollection(mManager->kernel()->collectionModel(), collection));
backupJob->setSaveLocation(archivePath);
backupJob->setArchiveType(mInfo->archiveType());
......
......@@ -28,6 +28,8 @@
#include <AkonadiCore/itemmodifyjob.h>
#include <AkonadiCore/itemmovejob.h>
#include <AkonadiCore/itemdeletejob.h>
#include <AkonadiCore/EntityTreeModel>
#include <AkonadiCore/EntityMimeTypeFilterModel>
#include <Akonadi/KMime/MessageParts>
#include <kconfig.h>
#include <kconfiggroup.h>
......@@ -40,7 +42,7 @@
#include <MailCommon/FilterImporterExporter>
#include <MailCommon/FilterLog>
#include <MailCommon/MailFilter>
#include <MailCommon/MailUtil>
#include <MailCommon/MailKernel>
#include <QTimer>
......@@ -458,7 +460,9 @@ bool FilterManager::processContextItem(ItemContext context)
const KMime::Message::Ptr msg = context.item().payload<KMime::Message::Ptr>();
msg->assemble();
const bool itemCanDelete = (MailCommon::Util::updatedCollection(context.item().parentCollection()).rights() & Akonadi::Collection::CanDeleteItem);
auto col = Akonadi::EntityTreeModel::updatedCollection(MailCommon::Kernel::self()->kernelIf()->collectionModel(),
context.item().parentCollection());
const bool itemCanDelete = (col.rights() & Akonadi::Collection::CanDeleteItem);
if (context.deleteItem()) {
if (itemCanDelete) {
Akonadi::ItemDeleteJob *deleteJob = new Akonadi::ItemDeleteJob(context.item(), this);
......
......@@ -25,6 +25,7 @@
#include <KMime/Message>
#include <KEmailAddress>
#include <MailCommon/MailUtil>
#include <QUrl>
CreateForwardMessageJob::CreateForwardMessageJob(QObject *parent)
......@@ -45,7 +46,9 @@ void CreateForwardMessageJob::setSettings(const CreateForwardMessageJobSettings
void CreateForwardMessageJob::start()
{
mMessageFactory = new MessageComposer::MessageFactoryNG(mSettings.mMsg, mSettings.mItem.id(), MailCommon::Util::updatedCollection(mSettings.mItem.parentCollection()));
const auto col = CommonKernel->collectionFromId(mSettings.mItem.parentCollection().id());
mMessageFactory = new MessageComposer::MessageFactoryNG(mSettings.mMsg, mSettings.mItem.id(),
col);
connect(mMessageFactory, &MessageComposer::MessageFactoryNG::createForwardDone, this, &CreateForwardMessageJob::slotCreateForwardDone);
mMessageFactory->setIdentityManager(KMKernel::self()->identityManager());
mMessageFactory->setFolderIdentity(MailCommon::Util::folderIdentity(mSettings.mItem));
......
......@@ -29,6 +29,7 @@
#include <QUrl>
#include <QDebug>
CreateReplyMessageJob::CreateReplyMessageJob(QObject *parent)
: QObject(parent)
, mMessageFactory(nullptr)
......@@ -57,7 +58,8 @@ inline KMail::Composer::TemplateContext replyContext(MessageComposer::MessageFac
void CreateReplyMessageJob::start()
{
mMessageFactory = new MessageComposer::MessageFactoryNG(mSettings.mMsg, mSettings.mItem.id(), MailCommon::Util::updatedCollection(mSettings.mItem.parentCollection()));
const auto col = CommonKernel->collectionFromId(mSettings.mItem.parentCollection().id());
mMessageFactory = new MessageComposer::MessageFactoryNG(mSettings.mMsg, mSettings.mItem.id(), col);
mMessageFactory->setIdentityManager(KMKernel::self()->identityManager());
mMessageFactory->setFolderIdentity(MailCommon::Util::folderIdentity(mSettings.mItem));
mMessageFactory->setMailingListAddresses(KMail::Util::mailingListsFromMessage(mSettings.mItem));
......
......@@ -63,7 +63,7 @@ void RemoveCollectionJob::slotDelayedRemoveFolder(KJob *job)
const bool hasNotSubDirectory = listOfCollection.isEmpty();
const Akonadi::Collection::Id id = fetchJob->property("collectionId").toLongLong();
Akonadi::Collection col = MailCommon::Util::updatedCollection(CommonKernel->collectionFromId(id));
const auto col = CommonKernel->collectionFromId(id);
QString str;
QString title;
QString buttonLabel;
......
......@@ -935,7 +935,8 @@ KMCommand::Result KMForwardCommand::execute()
if (answer == KMessageBox::Yes) {
Akonadi::Item firstItem(msgList.first());
MessageFactoryNG factory(KMime::Message::Ptr(new KMime::Message), firstItem.id(), MailCommon::Util::updatedCollection(firstItem.parentCollection()));
MessageFactoryNG factory(KMime::Message::Ptr(new KMime::Message), firstItem.id(),
CommonKernel->collectionFromId(firstItem.parentCollection().id()));
factory.setIdentityManager(KMKernel::self()->identityManager());
factory.setFolderIdentity(MailCommon::Util::folderIdentity(firstItem));
......@@ -990,7 +991,8 @@ KMCommand::Result KMForwardAttachedCommand::execute()
{
Akonadi::Item::List msgList = retrievedMsgs();
Akonadi::Item firstItem(msgList.first());
MessageFactoryNG factory(KMime::Message::Ptr(new KMime::Message), firstItem.id(), MailCommon::Util::updatedCollection(firstItem.parentCollection()));
MessageFactoryNG factory(KMime::Message::Ptr(new KMime::Message), firstItem.id(),
CommonKernel->collectionFromId(firstItem.parentCollection().id()));
factory.setIdentityManager(KMKernel::self()->identityManager());
factory.setFolderIdentity(MailCommon::Util::folderIdentity(firstItem));
......@@ -1056,7 +1058,7 @@ KMCommand::Result KMRedirectCommand::execute()
if (!msg) {
return Failed;
}
MessageFactoryNG factory(msg, item.id(), MailCommon::Util::updatedCollection(item.parentCollection()));
MessageFactoryNG factory(msg, item.id(), CommonKernel->collectionFromId(item.parentCollection().id()));
factory.setIdentityManager(KMKernel::self()->identityManager());
factory.setFolderIdentity(MailCommon::Util::folderIdentity(item));
......@@ -1661,7 +1663,7 @@ KMCommand::Result KMResendMessageCommand::execute()
if (!msg) {
return Failed;
}
MessageFactoryNG factory(msg, item.id(), MailCommon::Util::updatedCollection(item.parentCollection()));
MessageFactoryNG factory(msg, item.id(), CommonKernel->collectionFromId(item.parentCollection().id()));
factory.setIdentityManager(KMKernel::self()->identityManager());
factory.setFolderIdentity(MailCommon::Util::folderIdentity(item));
KMime::Message::Ptr newMsg = factory.createResend();
......
......@@ -750,7 +750,8 @@ void KMKernel::setAccountStatus(bool goOnline)
}
}
if (goOnline && MessageComposer::MessageComposerSettings::self()->sendImmediate()) {
const qint64 nbMsgOutboxCollection = MailCommon::Util::updatedCollection(CommonKernel->outboxCollectionFolder()).statistics().count();
const auto col = CommonKernel->collectionFromId(CommonKernel->outboxCollectionFolder().id());
const qint64 nbMsgOutboxCollection = col.statistics().count();
if (nbMsgOutboxCollection > 0) {
kmkernel->msgSender()->sendQueued();
}
......
......@@ -464,7 +464,7 @@ void KMMainWidget::slotCollectionFetched(int collectionId)
// This is the right time to update the caption (which still says "Loading...")
// and to update the actions that depend on the number of mails in the folder.
if (collectionId == mCurrentCollection.id()) {
setCurrentCollection(MailCommon::Util::updatedCollection(mCurrentCollection));
setCurrentCollection(CommonKernel->collectionFromId(mCurrentCollection.id()));
updateMessageActions();
updateFolderMenu();
}
......@@ -1214,7 +1214,7 @@ void KMMainWidget::slotCollectionStatisticsChanged(Akonadi::Collection::Id id, c
} else if (id == mCurrentCollection.id()) {
updateMoveAction(statistic);
updateAllToTrashAction(statistic.count());
setCurrentCollection(MailCommon::Util::updatedCollection(mCurrentCollection));
setCurrentCollection(CommonKernel->collectionFromId(mCurrentCollection.id()));
}
}
......@@ -2633,8 +2633,7 @@ void KMMainWidget::slotItemsFetchedForActivation(KMCommand *command)
: MessageViewer::MessageViewerSettings::self()->useFixedFont();
win->setUseFixedFont(useFixedFont);
const Akonadi::Collection parentCollection = MailCommon::Util::parentCollectionFromItem(msg);
win->showMessage(overrideEncoding(), msg, parentCollection);
win->showMessage(overrideEncoding(), msg, CommonKernel->collectionFromId(msg.parentCollection().id()));
win->show();
}
......@@ -3899,7 +3898,8 @@ void KMMainWidget::updateMessageActionsDelayed()
updateMoveAction(false);
}
const qint64 nbMsgOutboxCollection = MailCommon::Util::updatedCollection(CommonKernel->outboxCollectionFolder()).statistics().count();
const auto col = CommonKernel->collectionFromId(CommonKernel->outboxCollectionFolder().id());
const qint64 nbMsgOutboxCollection = col.statistics().count();
mSendQueued->setEnabled(nbMsgOutboxCollection > 0);
mSendActionMenu->setEnabled(nbMsgOutboxCollection > 0);
......
......@@ -692,8 +692,8 @@ void KMReaderWin::update(bool force)
void KMReaderWin::slotUrlClicked(const Akonadi::Item &item, const QUrl &url)
{
if (item.isValid() && item.parentCollection().isValid()) {
QSharedPointer<FolderSettings> fd = FolderSettings::forCollection(
MailCommon::Util::updatedCollection(item.parentCollection()), false);
const auto col = CommonKernel->collectionFromId(item.parentCollection().id());
QSharedPointer<FolderSettings> fd = FolderSettings::forCollection(col, false);
KMail::Util::handleClickedURL(url, fd, item.parentCollection());
return;
}
......
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