Commit 74904c4c authored by Volker Krause's avatar Volker Krause

Extend MessagePart API as needed for porting the vcard plugin

Reviewers: knauss

Reviewed By: knauss

Subscribers: #kde_pim

Tags: #kde_pim

Differential Revision: https://phabricator.kde.org/D8179
parent 1fb129aa
......@@ -47,6 +47,7 @@
#include <KLocalizedString>
#include <QTextCodec>
#include <QUrl>
using namespace MimeTreeParser;
......@@ -99,6 +100,16 @@ PartMetaData *MessagePart::partMetaData() const
return &d->mMetaData;
}
Interface::BodyPartMemento* MessagePart::memento() const
{
return nodeHelper()->bodyPartMemento(content(), "__plugin__");
}
void MessagePart::setMemento(Interface::BodyPartMemento *memento)
{
nodeHelper()->setBodyPartMemento(content(), "__plugin__", memento);
}
KMime::Content *MessagePart::content() const
{
return d->mNode;
......@@ -134,6 +145,18 @@ QString MessagePart::attachmentLink() const
return mOtp->nodeHelper()->asHREF(content(), QStringLiteral("body"));
}
QString MessagePart::makeLink(const QString &path) const
{
// FIXME: use a PRNG for the first arg, instead of a serial number
static int serial = 0;
if (path.isEmpty()) {
return {};
}
return QStringLiteral("x-kmail:/bodypart/%1/%2/%3")
.arg(serial++).arg(content()->index().toString())
.arg(QString::fromLatin1(QUrl::toPercentEncoding(path, "/")));
}
void MessagePart::setIsRoot(bool root)
{
d->mRoot = root;
......
......@@ -106,6 +106,11 @@ public:
/** @see NodeHelper::asHREF */
QString attachmentLink() const;
/** Returns a string respresentation of an URL that can be used
* to invoke a BodyPartURLHandler for this body part.
*/
QString makeLink(const QString &path) const;
void setIsRoot(bool root);
bool isRoot() const;
......@@ -114,6 +119,9 @@ public:
PartMetaData *partMetaData() const;
Interface::BodyPartMemento *memento() const;
void setMemento(Interface::BodyPartMemento *memento);
/* only a function that should be removed if the refactoring is over */
virtual void fix() const;
......
......@@ -54,7 +54,7 @@ class MIMETREEPARSER_EXPORT PartNodeBodyPart : public Interface::BodyPart
public:
explicit PartNodeBodyPart(ObjectTreeParser *otp, ProcessResult *result, KMime::Content *topLevelContent, KMime::Content *content, NodeHelper *nodeHelper);
QString makeLink(const QString &path) const override;
MIMETREEPARSER_DEPRECATED QString makeLink(const QString &path) const override;
QString asText() const override;
QByteArray asBinary() const override;
QString contentTypeParameter(const char *param) const override;
......
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