From cf5b3e797421e7dbf2c0d7b1efff91fc07277652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20Knau=C3=9F?= Date: Wed, 20 Jul 2016 17:35:29 +0200 Subject: new thoughts for interface --- framework/domain/mimetreeparser/interface.h | 246 ++++++++++++++-------------- 1 file changed, 122 insertions(+), 124 deletions(-) (limited to 'framework/domain/mimetreeparser/interface.h') diff --git a/framework/domain/mimetreeparser/interface.h b/framework/domain/mimetreeparser/interface.h index 0aef7fd0..5133b87e 100644 --- a/framework/domain/mimetreeparser/interface.h +++ b/framework/domain/mimetreeparser/interface.h @@ -29,11 +29,14 @@ class Part; class PartPrivate; -class MimePart; -class MimePartPrivate; +class MailMime; +class MailMimePrivate; -class ContentPart; -class ContentPartPrivate; +class AlternativePart; +class AlternativePartPrivate; + +class SinglePart; +class SinglePartPrivate; class EncryptionPart; class EncryptionPartPrivate; @@ -44,12 +47,14 @@ class AttachmentPartPrivate; class EncapsulatedPart; class EncapsulatedPartPrivate; -class CertPart; -class CertPartPrivate; - class Content; class ContentPrivate; +class CertContent; +class CertContentPrivate; + +class EncryptionError; + class Key; class Signature; class Encryption; @@ -57,30 +62,48 @@ class Encryption; class Parser; class ParserPrivate; -class Part +/* + * A MessagePart that is based on a KMime::Content + */ +class MailMime { public: - typedef std::shared_ptr Ptr; - Part(); - virtual QByteArray type() const; + typedef std::shared_ptr Ptr; + /** + * Various possible values for the "Content-Disposition" header. + */ + enum Disposition { + Invalid, ///< Default, invalid value + Inline, ///< inline + Attachment ///< attachment + }; - bool hasSubParts() const; - QVector subParts() const; - Part *parent() const; + // interessting header parts of a KMime::Content + QMimeType mimetype() const; + Disposition disposition() const; + QUrl label() const; + QByteArray cid() const; + QByteArray charset() const; + + // Unique identifier to ecactly this KMime::Content + QByteArray link() const; + + QByteArray content() const; + //Use default charset + QString encodedContent() const; + + // overwrite default charset with given charset + QString encodedContent(QByteArray charset) const; - virtual QVector signatures() const; - virtual QVector encryptions() const; private: - std::unique_ptr d; - friend class ParserPrivate; - friend class PartPrivate; + std::unique_ptr d; }; class Content { public: typedef std::shared_ptr Ptr; - Content(const QByteArray &content, ContentPart *parent); + Content(const QByteArray &content, Part *parent); virtual ~Content(); QByteArray content() const; @@ -95,123 +118,122 @@ public: virtual QVector signatures() const; virtual QVector encryptions() const; + MailMime::Ptr mailMime() const; + virtual QByteArray type() const; private: std::unique_ptr d; }; -/* - * A MessagePart that is based on a KMime::Content - */ -class MimePart : public Part +class PlainTextContent : public Content { public: - typedef std::shared_ptr Ptr; - /** - * Various possible values for the "Content-Disposition" header. - */ - enum Disposition { - Invalid, ///< Default, invalid value - Inline, ///< inline - Attachment ///< attachment - }; + QByteArray type() const Q_DECL_OVERRIDE; +}; - // interessting header parts of a KMime::Content - QMimeType mimetype() const; - Disposition disposition() const; - QUrl label() const; - QByteArray cid() const; - QByteArray charset() const; +class HtmlContent : public Content +{ +public: + QByteArray type() const Q_DECL_OVERRIDE; +}; - // we wanna overrwrite the charset of the content, because some clients set the charset wrong - void setCharset(QByteArray charset); +/* + * importing a cert GpgMe::ImportResult + * checking a cert (if it is a valid cert) + */ - // Unique identifier to ecactly this KMime::Content - QByteArray link() const; +class CertContent : public Content +{ +public: + typedef std::shared_ptr Ptr; - QByteArray content() const; + QByteArray type() const Q_DECL_OVERRIDE; + enum CertType { + Pgp, + SMime + }; - //Use default charset - QString encodedContent() const; + enum CertSubType { + Public, + Private + }; - // overwrite default charset with given charset - QString encodedContent(QByteArray charset) const; + CertType certType() const; + CertSubType certSubType() const; + int keyLength() const; - QByteArray type() const Q_DECL_OVERRIDE; private: - std::unique_ptr d; + std::unique_ptr d; }; -/* - * The main ContentPart - * is MimePart a good parent class? - * do we wanna need parts of the header of the connected KMime::Contents - * usecases: - * - - * for htmlonly it is representating only one MimePart (ok) - * for plaintext only also only one MimePart (ok) - * for alternative, we are represating three messageparts - * - "headers" do we return?, we can use setType to make it possible to select and than return these headers - */ -class ContentPart : public Part +class Part { public: - typedef std::shared_ptr Ptr; - enum Type { - PlainText = 0x0001, - Html = 0x0002 - }; - Q_DECLARE_FLAGS(Types, Type) - - ContentPart(); - virtual ~ContentPart(); - - QVector content(Type ct) const; + typedef std::shared_ptr Ptr; + Part(); + virtual QByteArray type() const; - Types availableContents() const; + virtual QVector availableContents() const; + virtual QVector content() const; - QByteArray type() const Q_DECL_OVERRIDE; + bool hasSubParts() const; + QVector subParts() const; + Part *parent() const; + virtual QVector signatures() const; + virtual QVector encryptions() const; + virtual MailMime::Ptr mailMime() const; private: - std::unique_ptr d; - + std::unique_ptr d; friend class ParserPrivate; + friend class PartPrivate; }; -Q_DECLARE_OPERATORS_FOR_FLAGS(ContentPart::Types); - -class AttachmentPart : public MimePart +class AlternativePart : public Part { public: - typedef std::shared_ptr Ptr; + typedef std::shared_ptr Ptr; + + AlternativePart(); + virtual ~AlternativePart(); + + QVector content() const Q_DECL_OVERRIDE; + QVector availableContents() const Q_DECL_OVERRIDE; + QVector content(const QByteArray& ct) const; + QByteArray type() const Q_DECL_OVERRIDE; private: - std::unique_ptr d; + std::unique_ptr d; friend class ParserPrivate; }; -/* - * Open Questions: - * - How to make the string translateable for multiple clients, so that multiple clients can show same error messages, - * that helps users to understand what is going on ? - * - Does openpgp have translations already? - */ -class EncryptionError +class SinglePart : public Part { -public: - int errorId() const; - QString errorString() const; + public: + typedef std::shared_ptr Ptr; + + SinglePart(); + virtual ~SinglePart(); + + QVector content() const Q_DECL_OVERRIDE; + QVector availableContents() const Q_DECL_OVERRIDE; + + QByteArray type() const Q_DECL_OVERRIDE; +private: + std::unique_ptr d; + + friend class ParserPrivate; }; -class EncryptionPart : public MimePart + +class EncryptionPart : public Part { public: typedef std::shared_ptr Ptr; QByteArray type() const Q_DECL_OVERRIDE; EncryptionError error() const; - private: std::unique_ptr d; }; @@ -222,7 +244,7 @@ private: * from/to... */ -class EncapsulatedPart : public AttachmentPart +class EncapsulatedPart : public SinglePart { public: typedef std::shared_ptr Ptr; @@ -233,33 +255,11 @@ private: std::unique_ptr d; }; -/* - * importing a cert GpgMe::ImportResult - * checking a cert (if it is a valid cert) - */ - -class CertPart : public AttachmentPart +class EncryptionError { public: - typedef std::shared_ptr Ptr; - QByteArray type() const Q_DECL_OVERRIDE; - - enum CertType { - Pgp, - SMime - }; - - enum CertSubType { - Public, - Private - }; - - CertType certType() const; - CertSubType certSubType() const; - int keyLength() const; - -private: - std::unique_ptr d; + int errorId() const; + QString errorString() const; }; class Key @@ -312,10 +312,8 @@ public: Part::Ptr getPart(QUrl url); template QVector collect(const Part::Ptr &start, std::function select, std::function filter) const; - QVector collectAttachments(Part::Ptr start, std::function select, std::function filter) const; - ContentPart::Ptr collectContentPart(Part::Ptr start, std::function select, std::function filter) const; - ContentPart::Ptr collectContentPart(const Part::Ptr& start) const; - ContentPart::Ptr collectContentPart() const; + //QVector collectAttachments(Part::Ptr start, std::function select, std::function filter) const; + QVector collectContentParts() const; //template <> QVector collect() const; //template <> static StatusObject verifySignature(const Signature signature) const; -- cgit v1.2.3