Messagelib

messageviewerutil.h
1/*
2 * SPDX-FileCopyrightText: 2005 Till Adam <adam@kde.org>
3 * SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0
4 */
5
6#pragma once
7
8#include "messageviewer_export.h"
9#include <Akonadi/Item>
10#include <KMime/Content>
11#include <KService>
12#include <QStringConverter>
13class QUrl;
14class QWidget;
15class QActionGroup;
16class QAction;
17
18namespace KMime
19{
20class Message;
21}
22
23namespace MessageViewer
24{
25/**
26 * The Util namespace contains a collection of helper functions use in
27 * various places.
28 */
29namespace Util
30{
31// return true if we should proceed, false if we should abort
32[[nodiscard]] MESSAGEVIEWER_EXPORT bool containsExternalReferences(const QString &str, const QString &extraHead);
33[[nodiscard]] bool MESSAGEVIEWER_EXPORT checkOverwrite(const QUrl &url, QWidget *w);
34[[nodiscard]] MESSAGEVIEWER_EXPORT bool
35saveMessageInMboxAndGetUrl(QUrl &url, const Akonadi::Item::List &retrievedMsgs, QWidget *parent, bool appendMessages = false);
36[[nodiscard]] MESSAGEVIEWER_EXPORT bool saveMessageInMbox(const Akonadi::Item::List &retrievedMsgs, QWidget *parent, bool appendMessages = false);
37[[nodiscard]] MESSAGEVIEWER_EXPORT bool excludeExtraHeader(const QString &s);
38[[nodiscard]] MESSAGEVIEWER_EXPORT QString generateMboxFileName(const Akonadi::Item &msgBase);
39[[nodiscard]] MESSAGEVIEWER_EXPORT bool saveAttachments(const KMime::Content::List &contents, QWidget *parent, QList<QUrl> &saveUrl);
40/**
41 * @brief Replaces the @c node message part by an empty attachment with information about deleted attachment.
42 *
43 * @param node A message part representing an attachment. The part will be replaced by a new empty party with
44 * filename "Deleted: <original attachment name>". Must not be @p null.
45 * @return Returns whether the message was actually modified.
46 */
47[[nodiscard]] MESSAGEVIEWER_EXPORT bool deleteAttachment(KMime::Content *node);
48/**
49 * @brief Calls deleteAttachment() for each node in the @p contents list.
50 *
51 * @param contents List of attachments to replace by an empty part (see deleteAttachment())
52 * @return Returns number of attachments that have actually been replaced.
53 * @see deleteAttachment()
54 */
55[[nodiscard]] MESSAGEVIEWER_EXPORT int deleteAttachments(const KMime::Content::List &contents);
56
57[[nodiscard]] MESSAGEVIEWER_EXPORT QAction *createAppAction(const KService::Ptr &service, bool singleOffer, QActionGroup *actionGroup, QObject *parent);
58/** Return a QTextCodec for the specified charset.
59 * This function is a bit more tolerant, than QTextCodec::codecForName */
60MESSAGEVIEWER_EXPORT QStringConverter::Encoding htmlEncoding(const QByteArray &data, const QByteArray &codec);
61struct HtmlMessageInfo {
62 QString htmlSource;
63 QString extraHead;
64 QString bodyStyle;
65 [[nodiscard]] bool operator==(const HtmlMessageInfo &other) const
66 {
67 return other.htmlSource == htmlSource && other.extraHead == extraHead && other.bodyStyle == bodyStyle;
68 }
69};
70
71[[nodiscard]] MESSAGEVIEWER_EXPORT HtmlMessageInfo processHtml(const QString &htmlSource);
72[[nodiscard]] MESSAGEVIEWER_EXPORT QByteArray htmlCodec(const QByteArray &data, const QByteArray &currentCodec);
73[[nodiscard]] MESSAGEVIEWER_EXPORT QString generateFileNameForExtension(const Akonadi::Item &msgBase, const QString &extension);
74[[nodiscard]] MESSAGEVIEWER_EXPORT QString parseBodyStyle(const QString &style);
75}
76}
77Q_DECLARE_TYPEINFO(MessageViewer::Util::HtmlMessageInfo, Q_RELOCATABLE_TYPE);
78Q_DECLARE_METATYPE(MessageViewer::Util::HtmlMessageInfo)
79MESSAGEVIEWER_EXPORT QDebug operator<<(QDebug d, const MessageViewer::Util::HtmlMessageInfo &t);
80Q_DECLARE_METATYPE(KService::Ptr)
MESSAGEVIEWER_EXPORT QStringConverter::Encoding htmlEncoding(const QByteArray &data, const QByteArray &codec)
Return a QTextCodec for the specified charset.
MESSAGEVIEWER_EXPORT bool containsExternalReferences(const QString &str, const QString &extraHead)
Checks whether str contains external references.
MESSAGEVIEWER_EXPORT bool deleteAttachment(KMime::Content *node)
Replaces the node message part by an empty attachment with information about deleted attachment.
MESSAGEVIEWER_EXPORT int deleteAttachments(const KMime::Content::List &contents)
Calls deleteAttachment() for each node in the contents list.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:12:43 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.