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);
58struct HtmlMessageInfo {
59 QString htmlSource;
60 QString extraHead;
61 QString bodyStyle;
62 [[nodiscard]] bool operator==(const HtmlMessageInfo &other) const
63 {
64 return other.htmlSource == htmlSource && other.extraHead == extraHead && other.bodyStyle == bodyStyle;
65 }
66};
67
68[[nodiscard]] MESSAGEVIEWER_EXPORT HtmlMessageInfo processHtml(const QString &htmlSource);
69[[nodiscard]] MESSAGEVIEWER_EXPORT QString generateFileNameForExtension(const Akonadi::Item &msgBase, const QString &extension);
70[[nodiscard]] MESSAGEVIEWER_EXPORT QString parseBodyStyle(const QString &style);
71}
72}
73Q_DECLARE_TYPEINFO(MessageViewer::Util::HtmlMessageInfo, Q_RELOCATABLE_TYPE);
74Q_DECLARE_METATYPE(MessageViewer::Util::HtmlMessageInfo)
75MESSAGEVIEWER_EXPORT QDebug operator<<(QDebug d, const MessageViewer::Util::HtmlMessageInfo &t);
76Q_DECLARE_METATYPE(KService::Ptr)
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 Mon Nov 4 2024 16:33:26 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.