Commit 18e86f06 authored by Sandro Knauß's avatar Sandro Knauß

Cleanup MimeTreeParser

parent 224dea6e
......@@ -41,13 +41,10 @@
#include <gpgme++/keylistresult.h>
#include <gpgme.h>
#include <QTextCodec>
#include <QWebPage>
#include <QWebElement>
#include <QWebFrame>
#include <KLocalizedString>
#include <QTextCodec>
using namespace MimeTreeParser;
//------MessagePart-----------------------
......@@ -351,26 +348,6 @@ void HtmlMessagePart::fix() const
mOtp->mHtmlContentCharset = mCharset;
}
QString HtmlMessagePart::processHtml(const QString &htmlSource, QString &extraHead)
{
// Create a DOM Document from the HTML source
QWebPage page(0);
page.settings()->setAttribute(QWebSettings::JavascriptEnabled, false);
page.settings()->setAttribute(QWebSettings::JavaEnabled, false);
page.settings()->setAttribute(QWebSettings::PluginsEnabled, false);
page.settings()->setAttribute(QWebSettings::AutoLoadImages, false);
QWebFrame *frame = page.mainFrame();
frame->setHtml(htmlSource);
const QWebElement body = frame->documentElement().findFirst(QStringLiteral("body"));
const QWebElement header = frame->documentElement().findFirst(QStringLiteral("head"));
extraHead = header.toInnerXml();
return body.toInnerXml();
}
QString HtmlMessagePart::text() const
{
return mBodyHTML;
......
......@@ -185,7 +185,6 @@ public:
void fix() const Q_DECL_OVERRIDE;
private:
QString processHtml(const QString &htmlSource, QString &extraHead);
KMime::Content *mNode;
Interface::ObjectTreeSource *mSource;
QString mBodyHTML;
......
......@@ -19,10 +19,8 @@
#include "nodehelper.h"
#include "mimetreeparser_debug.h"
#include "utils/iconnamecache.h"
#include "partmetadata.h"
#include "interfaces/bodypart.h"
#include "utils/mimetype.h"
#include "temporaryfile/attachmenttemporaryfilesdirs.h"
#include <MessageCore/NodeHelper>
......@@ -464,22 +462,6 @@ KMMsgSignatureState NodeHelper::overallSignatureState(KMime::Content *node) cons
return myState;
}
QString NodeHelper::iconName(KMime::Content *node, int size)
{
if (!node) {
return QString();
}
QByteArray mimeType = node->contentType()->mimeType();
if (mimeType.isNull() || mimeType == "application/octet-stream") {
const QString mime = Util::mimetype(node->contentDisposition()->filename()).name();
mimeType = mime.toLatin1();
}
mimeType = mimeType.toLower();
return Util::fileNameForMimetype(QLatin1String(mimeType), size, node->contentDisposition()->filename(),
node->contentType()->name());
}
void NodeHelper::magicSetType(KMime::Content *node, bool aAutoDecode)
{
const QByteArray body = (aAutoDecode) ? node->decodedContent() : node->body();
......@@ -880,30 +862,6 @@ KMime::Message *NodeHelper::messageWithExtraContent(KMime::Content *topLevelNode
return m;
}
NodeHelper::AttachmentDisplayInfo NodeHelper::attachmentDisplayInfo(KMime::Content *node)
{
AttachmentDisplayInfo info;
info.icon = iconName(node, KIconLoader::Small);
const QString name = node->contentType()->name();
info.label = name.isEmpty() ? fileName(node) : name;
if (info.label.isEmpty()) {
info.label = node->contentDescription()->asUnicodeString();
}
bool typeBlacklisted = node->contentType()->mediaType().toLower() == "multipart";
if (!typeBlacklisted) {
typeBlacklisted = KMime::isCryptoPart(node);
}
typeBlacklisted = typeBlacklisted || node == node->topLevel();
const bool firstTextChildOfEncapsulatedMsg =
node->contentType()->mediaType().toLower() == "text" &&
node->contentType()->subType().toLower() == "plain" &&
node->parent() && node->parent()->contentType()->mediaType().toLower() == "message";
typeBlacklisted = typeBlacklisted || firstTextChildOfEncapsulatedMsg;
info.displayInHeader = !info.label.isEmpty() && !info.icon.isEmpty() && !typeBlacklisted;
return info;
}
KMime::Content *NodeHelper::decryptedNodeForContent(KMime::Content *content) const
{
const QList<KMime::Content *> xc = extraContents(content);
......
......@@ -27,8 +27,6 @@
#include <KMime/Message>
#include <KIconLoader>
#include <QList>
#include <QMap>
#include <QSet>
......@@ -77,8 +75,6 @@ public:
void setPartMetaData(KMime::Content *node, const PartMetaData &metaData);
PartMetaData partMetaData(KMime::Content *node);
static QString iconName(KMime::Content *node, int size = KIconLoader::Desktop);
/**
* Set the 'Content-Type' by mime-magic from the contents of the body.
* If autoDecode is true the decoded body will be used for mime type
......@@ -216,13 +212,7 @@ public:
static QString fromAsString(KMime::Content *node);
struct AttachmentDisplayInfo {
QString label;
QString icon;
bool displayInHeader;
};
static AttachmentDisplayInfo attachmentDisplayInfo(KMime::Content *node);
KMime::Content *decryptedNodeForContent(KMime::Content *content) const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment