File indexing completed on 2024-06-23 05:18:39

0001 /*
0002   SPDX-FileCopyrightText: 2009 Constantin Berzan <exit3219@gmail.com>
0003   SPDX-FileCopyrightText: 2009 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.net
0004   SPDX-FileCopyrightText: 2009 Leo Franchi <lfranchi@kde.org>
0005 
0006   SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #pragma once
0010 
0011 #include "messagecomposer_export.h"
0012 #include <Akonadi/Item>
0013 #include <Akonadi/MessageStatus>
0014 #include <KMime/Message>
0015 #include <Libkleo/Enum>
0016 
0017 class QTextDocument;
0018 
0019 namespace KMime
0020 {
0021 class Content;
0022 }
0023 
0024 namespace MessageComposer
0025 {
0026 namespace Util
0027 {
0028 [[nodiscard]] MESSAGECOMPOSER_EXPORT QByteArray selectCharset(const QList<QByteArray> &charsets, const QString &text);
0029 
0030 [[nodiscard]] MESSAGECOMPOSER_EXPORT QStringList AttachmentKeywords();
0031 [[nodiscard]] MESSAGECOMPOSER_EXPORT QString cleanedUpHeaderString(const QString &s);
0032 
0033 [[nodiscard]] MESSAGECOMPOSER_EXPORT bool sendMailDispatcherIsOnline(QWidget *parent = nullptr);
0034 
0035 /**
0036  * find mimetype in message
0037  */
0038 [[nodiscard]] MESSAGECOMPOSER_EXPORT KMime::Content *findTypeInMessage(KMime::Content *data, const QByteArray &mimeType, const QByteArray &subType);
0039 
0040 /**
0041  * Adds private headers to the given @p message that links it to the original message.
0042  *
0043  * @param message The message to add the link information to.
0044  * @param id The item id of the original message.
0045  * @param status The status (replied or forwarded) that links the message to the original message.
0046  */
0047 MESSAGECOMPOSER_EXPORT void addLinkInformation(const KMime::Message::Ptr &message, Akonadi::Item::Id item, Akonadi::MessageStatus status);
0048 
0049 /**
0050  * Reads the private headers of the given @p message to extract link information to its original message.
0051  *
0052  * @param message The message to read the link information from.
0053  * @param id Will contain the item id of the original message.
0054  * @param status Will contain the status (replied or forwarded) that linked the message to the original message.
0055  * @returns Whether the mail contains valid link information or not.
0056  */
0057 [[nodiscard]] MESSAGECOMPOSER_EXPORT bool
0058 getLinkInformation(const KMime::Message::Ptr &msg, QList<Akonadi::Item::Id> &id, QList<Akonadi::MessageStatus> &status);
0059 
0060 /**
0061  * Returns whether the item represents a valid KMime::Message that is not
0062  * in the Akonadi store (yet). This happens when operating on messages
0063  * attached to other mails, for example. Such items are not "valid", in
0064  * the akonadi sense, since jobs cannot sensibly use them, but they do
0065  * contain a valid message pointer.
0066  */
0067 [[nodiscard]] MESSAGECOMPOSER_EXPORT bool isStandaloneMessage(const Akonadi::Item &item);
0068 
0069 /**
0070  * Retrieve the KMime::Message from the item, if there is one.
0071  * @returns A valid message pointer, or 0, is the item does not contain
0072  * a valid message.
0073  */
0074 [[nodiscard]] MESSAGECOMPOSER_EXPORT KMime::Message::Ptr message(const Akonadi::Item &item);
0075 
0076 [[nodiscard]] MESSAGECOMPOSER_EXPORT bool hasMissingAttachments(const QStringList &attachmentKeywords, QTextDocument *doc, const QString &subj);
0077 
0078 [[nodiscard]] MESSAGECOMPOSER_EXPORT QStringList cleanEmailList(const QStringList &emails);
0079 [[nodiscard]] MESSAGECOMPOSER_EXPORT QStringList cleanUpEmailListAndEncoding(const QStringList &emails);
0080 MESSAGECOMPOSER_EXPORT void addCustomHeaders(const KMime::Message::Ptr &message, const QMap<QByteArray, QString> &customHeader);
0081 }
0082 }