Commit 195f0fc7 authored by Laurent Montel's avatar Laurent Montel 😁

Move all method from messagehelpers

parent 70a39301
cmake_minimum_required(VERSION 3.0)
set(PIM_VERSION "5.5.47")
set(PIM_VERSION "5.5.48")
if (POLICY CMP0053)
cmake_policy(SET CMP0053 NEW)
......
......@@ -55,7 +55,6 @@
#include <sonnet/dictionarycombobox.h>
#include <KIdentityManagement/Identity>
#include <messagecore/messagehelpers.h>
#include <MessageCore/StringUtil>
#include <MessageCore/NodeHelper>
......
......@@ -37,7 +37,6 @@
#include <kmime/kmime_dateformatter.h>
#include <KEmailAddress>
#include <MessageCore/MailingList>
#include <messagecore/messagehelpers.h>
#include <MessageCore/StringUtil>
#include "helper/messagehelper.h"
#include <KLocalizedString>
......@@ -456,7 +455,7 @@ QPair< KMime::Message::Ptr, QList< KMime::Content * > > MessageFactoryNG::create
// the selected mails
MessageHelper::initHeader(msg, m_identityManager, 0);
} else if (numberOfItems == 1) {
KMime::Message::Ptr firstMsg = MessageCore::Util::message(items.first());
KMime::Message::Ptr firstMsg = MessageComposer::Util::message(items.first());
const uint originalIdentity = identityUoid(firstMsg);
MessageHelper::initFromMessage(msg, firstMsg, m_identityManager, originalIdentity);
msg->subject()->fromUnicodeString(MessageHelper::forwardSubject(firstMsg), "utf-8");
......@@ -473,7 +472,7 @@ QPair< KMime::Message::Ptr, QList< KMime::Content * > > MessageFactoryNG::create
// iterate through all the messages to be forwarded
attachments.reserve(items.count());
for (const Akonadi::Item &item : qAsConst(items)) {
attachments << createForwardAttachmentMessage(MessageCore::Util::message(item));
attachments << createForwardAttachmentMessage(MessageComposer::Util::message(item));
MessageComposer::Util::addLinkInformation(msg, item.id(), Akonadi::MessageStatus::statusForwarded());
}
}
......@@ -784,7 +783,7 @@ QPair< KMime::Message::Ptr, KMime::Content * > MessageFactoryNG::createForwardDi
int id = 0;
for (const Akonadi::Item &item : qAsConst(items)) {
KMime::Message::Ptr fMsg = MessageCore::Util::message(item);
KMime::Message::Ptr fMsg = MessageComposer::Util::message(item);
if (id == 0) {
if (auto hrd = fMsg->headerByType("X-KMail-Identity")) {
id = hrd->asUnicodeString().toInt();
......
......@@ -34,7 +34,6 @@
#include <mailtransport/transport.h>
#include <mailtransport/transportmanager.h>
#include <MessageCore/StringUtil>
#include <messagecore/messagehelpers.h>
using namespace KMime::Types;
using namespace KPIM;
......
......@@ -41,7 +41,6 @@
#include <AkonadiCore/agentinstance.h>
#include <AkonadiCore/agentinstancecreatejob.h>
#include <AkonadiCore/agentmanager.h>
#include <messagecore/messagehelpers.h>
KMime::Content *setBodyAndCTE(QByteArray &encodedBody, KMime::Headers::ContentType *contentType, KMime::Content *ret)
{
......@@ -413,3 +412,13 @@ bool MessageComposer::Util::isStandaloneMessage(const Akonadi::Item &item)
return item.hasPayload<KMime::Message::Ptr>() && !item.isValid();
}
KMime::Message::Ptr MessageComposer::Util::message(const Akonadi::Item &item)
{
if (!item.hasPayload<KMime::Message::Ptr>()) {
qCWarning(MESSAGECOMPOSER_LOG) << "Payload is not a MessagePtr!";
return KMime::Message::Ptr();
}
return item.payload<KMime::Message::Ptr>();
}
......@@ -85,6 +85,13 @@ MESSAGECOMPOSER_EXPORT bool getLinkInformation(const KMime::Message::Ptr &msg, Q
*/
MESSAGECOMPOSER_EXPORT bool isStandaloneMessage(const Akonadi::Item &item);
/**
* Retrieve the KMime::Message from the item, if there is one.
* @returns A valid message pointer, or 0, is the item does not contain
* a valid message.
*/
MESSAGECOMPOSER_EXPORT KMime::Message::Ptr message(const Akonadi::Item &item);
}
}
......
......@@ -25,7 +25,6 @@ set(messagecore_misc_LIB_SRCS
set(messagecore_helper_LIB_SRCS
helpers/messagehelpers.cpp
helpers/nodehelper.cpp
)
......@@ -142,7 +141,6 @@ ecm_generate_headers(MessageCore_Camelcaseattachment_HEADERS
ecm_generate_headers(MessageCore_Camelcasehelpers_HEADERS
HEADER_NAMES
NodeHelper
MessageHelpers
REQUIRED_HEADERS MessageCore_helpers_HEADERS
PREFIX MessageCore
RELATIVE helpers
......
/*
* This file is part of KDEPIM.
* Copyright (c) 2010 Till Adam <adam@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "messagehelpers.h"
#include "messagecore_debug.h"
using namespace MessageCore;
using namespace MessageCore::Util;
KMime::Message::Ptr MessageCore::Util::message(const Akonadi::Item &item)
{
if (!item.hasPayload<KMime::Message::Ptr>()) {
qCWarning(MESSAGECORE_LOG) << "Payload is not a MessagePtr!";
return KMime::Message::Ptr();
}
return item.payload<KMime::Message::Ptr>();
}
/*
* This file is part of KDEPIM.
* Copyright (c) 2010 Till Adam <adam@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef MESSAGECORE_MESSAGEHELPERS_H
#define MESSAGECORE_MESSAGEHELPERS_H
#include "messagecore_export.h"
#include <item.h>
#include <Akonadi/KMime/MessageStatus>
#include <KMime/Message>
namespace MessageCore
{
namespace Util
{
/**
* Retrieve the KMime::Message from the item, if there is one.
* @returns A valid message pointer, or 0, is the item does not contain
* a valid message.
*/
MESSAGECORE_EXPORT KMime::Message::Ptr message(const Akonadi::Item &item);
}
}
#endif
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