Messagelib
messageviewerutil.cpp
79 const bool hasBaseInHeader = extraHead.contains(QLatin1String("<base href=\""), Qt::CaseInsensitive);
80 if (hasBaseInHeader && (str.contains(QLatin1String("href=\"/"), Qt::CaseInsensitive) || str.contains(QLatin1String("<img src=\"/"), Qt::CaseInsensitive))) {
87 const int pos = (httpPos < httpsPos) ? ((httpPos >= 0) ? httpPos : httpsPos) : ((httpsPos >= 0) ? httpsPos : httpPos);
96 // <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
127 QRegularExpression(QStringLiteral("<img.*src=\"https?:/.*\".*>"), QRegularExpression::CaseInsensitiveOption);
131 QRegularExpression(QStringLiteral("<img.*src=https?:/.*>"), QRegularExpression::CaseInsensitiveOption);
198 bool Util::saveContents(QWidget *parent, const KMime::Content::List &contents, QList<QUrl> &urlList)
209 KFileWidget::getStartUrl(QUrl(QStringLiteral("kfiledialog:///attachmentDir")), recentDirClass));
228 QUrl localUrl = KFileWidget::getStartUrl(QUrl(QStringLiteral("kfiledialog:///attachmentDir")), recentDirClass);
231 url = QFileDialog::getSaveFileUrl(parent, i18n("Save Attachment"), localUrl, QString(), nullptr, options);
246 PimCommon::RenameFileDialog::RenameFileDialogResult result = PimCommon::RenameFileDialog::RENAMEFILE_IGNORE;
255 fileName = i18nc("filename for the %1-th unnamed attachment", "attachment.%1", unnamedAtmCount);
298 if (!(result == PimCommon::RenameFileDialog::RENAMEFILE_OVERWRITEALL || result == PimCommon::RenameFileDialog::RENAMEFILE_IGNOREALL)) {
308 QPointer<PimCommon::RenameFileDialog> dlg = new PimCommon::RenameFileDialog(curUrl, multiple, parent);
310 if (result == PimCommon::RenameFileDialog::RENAMEFILE_IGNORE || result == PimCommon::RenameFileDialog::RENAMEFILE_IGNOREALL) {
421 qCWarning(MESSAGEVIEWER_LOG) << "Port the encryption/signature handling when saving a KMime::Content.";
481 bool Util::saveAttachments(const KMime::Content::List &contents, QWidget *parent, QList<QUrl> &urlList)
491 QString Util::generateFileNameForExtension(const Akonadi::Item &msgBase, const QString &extension)
496 fileName = MessageCore::StringUtil::cleanFileName(MessageCore::StringUtil::cleanSubject(msgBase.payload<KMime::Message::Ptr>().data()).trimmed());
513 bool Util::saveMessageInMboxAndGetUrl(QUrl &url, const Akonadi::Item::List &retrievedMsgs, QWidget *parent, bool appendMessages)
524 const QUrl startUrl = KFileWidget::getStartUrl(QUrl(QStringLiteral("kfiledialog:///savemessage")), fileClass);
557 KMessageBox::error(parent, i18n("File %1 could not be loaded.", localFileName), i18n("Error loading message"));
559 KMessageBox::error(parent, i18n("File %1 could not be created.", localFileName), i18n("Error saving message"));
575 KRecentDirs::add(fileClass, localUrl.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash).path());
601 bool Util::saveMessageInMbox(const Akonadi::Item::List &retrievedMsgs, QWidget *parent, bool appendMessages)
607 QAction *Util::createAppAction(const KService::Ptr &service, bool singleOffer, QActionGroup *actionGroup, QObject *parent)
626 static QRegularExpression divRef(QStringLiteral("</div>"), QRegularExpression::CaseInsensitiveOption);
630 static QRegularExpression bodyRef(QStringLiteral("body.s*>.s*div"), QRegularExpression::CaseInsensitiveOption);
661 Gravatar::GravatarCache::self()->setMaximumSize(Gravatar::GravatarSettings::self()->gravatarCacheSize());
674 const QStringView styleStr = QStringView(style).mid(indexStyle + 7, indexEnd - (indexStyle + 7));
679 if (!style.trimmed().contains(QLatin1String("white-space")) && !style.trimmed().contains(QLatin1String("text-align"))) {
694 // yes, "parsing" HTML with regexps is very very wrong, but it's still better than not filtering
700 static QRegularExpression docTypeRegularExpression = QRegularExpression(QStringLiteral("<!DOCTYPE[^>]*>"), QRegularExpression::CaseInsensitiveOption);
712 static QRegularExpression htmlRegularExpression = QRegularExpression(QStringLiteral("<html[^>]*>"), QRegularExpression::CaseInsensitiveOption);
715 static QRegularExpression headEndRegularExpression = QRegularExpression(QStringLiteral("^<head/>"), QRegularExpression::CaseInsensitiveOption);
733 QRegularExpression(QStringLiteral("<style>\\s*body\\s*{"), QRegularExpression::CaseInsensitiveOption | QRegularExpression::MultilineOption);
735 const int bodyStyleStartIndex = messageInfo.extraHead.indexOf(styleBodyRegularExpression, 0, &matchBodyStyle);
737 const auto endIndex = messageInfo.extraHead.indexOf(QLatin1String("</style>"), bodyStyleStartIndex, Qt::CaseInsensitive);
739 messageInfo.extraHead = messageInfo.extraHead.remove(bodyStyleStartIndex, endIndex - bodyStyleStartIndex + 8);
744 static QRegularExpression body = QRegularExpression(QStringLiteral("<body[^>]*>"), QRegularExpression::CaseInsensitiveOption);
755 QRegularExpression(QStringLiteral("(</html></div>|</html>)$"), QRegularExpression::CaseInsensitiveOption);
757 // s = s.remove(QRegularExpression(QStringLiteral("</html>$"), QRegularExpression::CaseInsensitiveOption)).trimmed();
758 static QRegularExpression bodyEndRegularExpression = QRegularExpression(QStringLiteral("</body>$"), QRegularExpression::CaseInsensitiveOption);
773 if (data.contains("charset=\"utf-8\"") || data.contains("charset=\"UTF-8\"") || data.contains("charset=UTF-8")) {
777 // qDebug() << " codec ******************************************: " << codec << " currentCodec : " <<currentCodec;
790 if (data.contains("charset=\"utf-8\"") || data.contains("charset=\"UTF-8\"") || data.contains("charset=UTF-8")) {
void append(const T &value)
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const const
QString errorString() const const
bool isEmpty() const const
QString cleanSubject(KMime::Message *msg)
Return this mails subject, with all "forward" and "reply" prefixes removed.
Definition: stringutil.cpp:722
QString xi18nc(const char *context, const char *text, const TYPE &arg...)
bool contains(const Key &key) const const
bool save(const QString &fileName=QString())
QByteArray toLower() const const
static QString fileName(const KMime::Content *node)
Returns a usable filename for a node, that can be the filename from the content disposition header,...
Definition: mimetreeparser/src/nodehelper.cpp:632
QString number(int n, int base)
WriteOnly
CaseInsensitive
QVariant fromValue(const T &value)
ButtonCode warningContinueCancel(QWidget *parent, const QString &text, const QString &title=QString(), const KGuiItem &buttonContinue=KStandardGuiItem::cont(), const KGuiItem &buttonCancel=KStandardGuiItem::cancel(), const QString &dontAskAgainName=QString(), Options options=Notify)
QByteArray mimeType() const
bool remove()
virtual bool open(QIODevice::OpenMode mode) override
QString scheme() const const
MESSAGEVIEWER_EXPORT bool containsExternalReferences(const QString &str, const QString &extraHead)
Checks whether str contains external references.
Definition: messageviewerutil.cpp:77
MESSAGECORE_EXPORT KMime::Content * nextSibling(const KMime::Content *node)
Returns the next sibling node of the given node.
Definition: messagecore/src/helpers/nodehelper.cpp:14
KJOBWIDGETS_EXPORT void setWindow(KJob *job, QWidget *widget)
QString trimmed() const const
void clear()
QStringView mid(qsizetype start) const const
QIcon fromTheme(const QString &name)
QIODevice * device() const const
QDataStream & operator<<(QDataStream &out, const KDateTime &dateTime)
Parses messages and generates HTML display code out of them.
Definition: objecttreeparser.h:245
bool openUrl(const QUrl &url)
MBoxEntry appendMessage(const KMime::Message::Ptr &message)
int lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const const
T & first()
bool exists() const const
static QUrl getStartUrl(const QUrl &startDir, QString &recentDirClass)
Content * topLevel() const
bool hasPayload() const
void setDevice(QIODevice *d)
KIOFILEWIDGETS_EXPORT void add(const QString &fileClass, const QString &directory)
virtual QString fileName() const const override
virtual QString fileName() const const override
QTextCodec * codecForLocale()
const MESSAGEVIEWER_EXPORT QTextCodec * codecForName(const QByteArray &_str)
Return a QTextCodec for the specified charset.
Definition: messageviewerutil.cpp:646
typedef Options
bool isValid() const const
QString toString(QUrl::FormattingOptions options) const const
QString i18n(const char *text, const TYPE &arg...)
bool isEmpty() const const
void setStatusTip(const QString &statusTip)
RemoveFilename
SkipEmptyParts
bool isEmpty() const const
bool load(const QString &fileName)
QUrl getSaveFileUrl(QWidget *parent, const QString &caption, const QUrl &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options, const QStringList &supportedSchemes)
QUrl fromLocalFile(const QString &localFile)
QString fileName(QUrl::ComponentFormattingOptions options) const const
int writeRawData(const char *s, int len)
int length() const const
QString toDisplayString(QUrl::FormattingOptions options) const const
QTextCodec * codecForName(const QByteArray &name)
QFuture< void > filter(Sequence &sequence, KeepFunctor filterFunction)
void setFileName(const QString &name)
bool isEmpty() const const
QString toLocalFile() const const
KIOCORE_EXPORT QUrl upUrl(const QUrl &url)
QString join(const QString &separator) const const
virtual void close() override
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const const
ButtonCode questionTwoActions(QWidget *parent, const QString &text, const QString &title, const KGuiItem &primaryAction, const KGuiItem &secondaryAction, const QString &dontAskAgainName=QString(), Options options=Notify)
bool contains(char ch) const const
whatsThis
CaseInsensitiveOption
void error(QWidget *parent, const QString &text, const QString &title, const KGuiItem &buttonOk, Options options=Notify)
QString & remove(int position, int n)
QString i18np(const char *singular, const char *plural, const TYPE &arg...)
QByteArray decodedContent()
void setData(const QVariant &userData)
FileCopyJob * file_copy(const QUrl &src, const QUrl &dest, JobFlags flags)=delete
bool isEmpty() const const
QUrl getExistingDirectoryUrl(QWidget *parent, const QString &caption, const QUrl &dir, QFileDialog::Options options, const QStringList &supportedSchemes)
QString path(QUrl::ComponentFormattingOptions options) const const
void setToolTip(const QString &tip)
QString & insert(int position, QChar ch)
QString left(int n) const const
void setPath(const QString &path, QUrl::ParsingMode mode)
QString cleanFileName(const QString &name)
Cleans a filename by replacing characters not allowed or wanted on the filesystem e....
Definition: stringutil.cpp:686
bool isLocalFile() const const
const QList< QKeySequence > & next()
QUrl adjusted(QUrl::FormattingOptions options) const const
KIOCORE_EXPORT StatJob * statDetails(const QUrl &url, KIO::StatJob::StatSide side, KIO::StatDetails details=KIO::StatDefaultDetails, JobFlags flags=DefaultFlags)
const QChar at(int position) const const
QString i18nc(const char *context, const char *text, const TYPE &arg...)
int count(const T &value) const const
int size() const const
void information(QWidget *parent, const QString &text, const QString &title=QString(), const QString &dontShowAgainName=QString(), Options options=Notify)
Headers::ContentType * contentType(bool create=true)
QAction * addAction(QAction *action)
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
bool open()
QString mid(int position, int n) const const
KGuiItem overwrite()
QString message
QString captured(int nth) const const
char * data()
int capturedLength(int nth) const const
MESSAGECORE_EXPORT KMime::Content * firstChild(const KMime::Content *node)
Returns the first child node of the given node.
Definition: messagecore/src/helpers/nodehelper.cpp:54
T payload() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Mar 22 2023 04:07:15 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Mar 22 2023 04:07:15 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.