Messagelib

messageviewerutil.h
1 /*******************************************************************************
2 **
3 ** Filename : util
4 ** Created on : 03 April, 2005
5 ** SPDX-FileCopyrightText : 2005 Till Adam <[email protected]>
6 **
7 *******************************************************************************/
8 
9 /*******************************************************************************
10 **
11 ** This program is free software; you can redistribute it and/or modify
12 ** it under the terms of the GNU General Public License as published by
13 ** the Free Software Foundation; either version 2 of the License, or
14 ** (at your option) any later version.
15 **
16 ** It is distributed in the hope that it will be useful, but
17 ** WITHOUT ANY WARRANTY; without even the implied warranty of
18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ** General Public License for more details.
20 **
21 ** You should have received a copy of the GNU General Public License
22 ** along with this program; if not, write to the Free Software
23 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 **
25 ** In addition, as a special exception, the copyright holders give
26 ** permission to link the code of this program with any edition of
27 ** the Qt library by Trolltech AS, Norway (or with modified versions
28 ** of Qt that use the same license as Qt), and distribute linked
29 ** combinations including the two. You must obey the GNU General
30 ** Public License in all respects for all of the code used other than
31 ** Qt. If you modify this file, you may extend this exception to
32 ** your version of the file, but you are not obligated to do so. If
33 ** you do not wish to do so, delete this exception statement from
34 ** your version.
35 **
36 *******************************************************************************/
37 #pragma once
38 
39 #include "messageviewer_export.h"
40 #include <Akonadi/Item>
41 #include <KMime/Content>
42 #include <KService>
43 #include <QTextCodec>
44 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
45 #include <QStringConverter>
46 #endif
47 class QUrl;
48 class QWidget;
49 class QActionGroup;
50 class QAction;
51 
52 namespace KMime
53 {
54 class Message;
55 }
56 
57 namespace MessageViewer
58 {
59 /**
60  * The Util namespace contains a collection of helper functions use in
61  * various places.
62  */
63 namespace Util
64 {
65 // return true if we should proceed, false if we should abort
66 Q_REQUIRED_RESULT MESSAGEVIEWER_EXPORT bool containsExternalReferences(const QString &str, const QString &extraHead);
67 Q_REQUIRED_RESULT bool MESSAGEVIEWER_EXPORT checkOverwrite(const QUrl &url, QWidget *w);
68 Q_REQUIRED_RESULT MESSAGEVIEWER_EXPORT bool
69 saveMessageInMboxAndGetUrl(QUrl &url, const Akonadi::Item::List &retrievedMsgs, QWidget *parent, bool appendMessages = false);
70 Q_REQUIRED_RESULT MESSAGEVIEWER_EXPORT bool saveMessageInMbox(const Akonadi::Item::List &retrievedMsgs, QWidget *parent, bool appendMessages = false);
71 Q_REQUIRED_RESULT MESSAGEVIEWER_EXPORT bool excludeExtraHeader(const QString &s);
72 Q_REQUIRED_RESULT MESSAGEVIEWER_EXPORT QString generateMboxFileName(const Akonadi::Item &msgBase);
73 Q_REQUIRED_RESULT MESSAGEVIEWER_EXPORT bool saveAttachments(const KMime::Content::List &contents, QWidget *parent, QList<QUrl> &saveUrl);
74 
75 Q_REQUIRED_RESULT MESSAGEVIEWER_EXPORT QAction *createAppAction(const KService::Ptr &service, bool singleOffer, QActionGroup *actionGroup, QObject *parent);
76 /** Return a QTextCodec for the specified charset.
77  * This function is a bit more tolerant, than QTextCodec::codecForName */
78 MESSAGEVIEWER_EXPORT const QTextCodec *codecForName(const QByteArray &_str);
79 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
80 MESSAGEVIEWER_EXPORT QStringConverter::Encoding htmlEncoding(const QByteArray &data, const QByteArray &codec);
81 #endif
82 struct HtmlMessageInfo {
83  QString htmlSource;
84  QString extraHead;
85  QString bodyStyle;
86  Q_REQUIRED_RESULT bool operator==(const HtmlMessageInfo &other) const
87  {
88  return other.htmlSource == htmlSource && other.extraHead == extraHead && other.bodyStyle == bodyStyle;
89  }
90 };
91 
92 Q_REQUIRED_RESULT MESSAGEVIEWER_EXPORT HtmlMessageInfo processHtml(const QString &htmlSource);
93 Q_REQUIRED_RESULT MESSAGEVIEWER_EXPORT QByteArray htmlCodec(const QByteArray &data, const QByteArray &currentCodec);
94 Q_REQUIRED_RESULT MESSAGEVIEWER_EXPORT QString generateFileNameForExtension(const Akonadi::Item &msgBase, const QString &extension);
95 Q_REQUIRED_RESULT MESSAGEVIEWER_EXPORT QString parseBodyStyle(const QString &style);
96 }
97 }
98 Q_DECLARE_TYPEINFO(MessageViewer::Util::HtmlMessageInfo, Q_MOVABLE_TYPE);
99 Q_DECLARE_METATYPE(MessageViewer::Util::HtmlMessageInfo)
100 MESSAGEVIEWER_EXPORT QDebug operator<<(QDebug d, const MessageViewer::Util::HtmlMessageInfo &t);
101 Q_DECLARE_METATYPE(KService::Ptr)
MESSAGEVIEWER_EXPORT bool containsExternalReferences(const QString &str, const QString &extraHead)
Checks whether str contains external references.
QDataStream & operator<<(QDataStream &out, const KDateTime &dateTime)
const MESSAGEVIEWER_EXPORT QTextCodec * codecForName(const QByteArray &_str)
Return a QTextCodec for the specified charset.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Mar 26 2023 04:08:11 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.