diff --git a/src/mimeattachment.cpp b/src/mimeattachment.cpp index eac36f7..0dea622 100644 --- a/src/mimeattachment.cpp +++ b/src/mimeattachment.cpp @@ -24,6 +24,10 @@ MimeAttachment::MimeAttachment(QFile *file) : MimeFile(file) { +} +MimeAttachment::MimeAttachment(const QByteArray& stream, const QString& fileName): MimeFile(stream, fileName) +{ + } MimeAttachment::~MimeAttachment() diff --git a/src/mimeattachment.h b/src/mimeattachment.h index 4b79678..4f9efa0 100644 --- a/src/mimeattachment.h +++ b/src/mimeattachment.h @@ -31,6 +31,8 @@ public: /* [1] Constructors and Destructors */ MimeAttachment(QFile* file); + MimeAttachment(const QByteArray& stream, const QString& fileName); + ~MimeAttachment(); /* [1] --- */ diff --git a/src/mimefile.cpp b/src/mimefile.cpp index 59fb5bf..4991697 100644 --- a/src/mimefile.cpp +++ b/src/mimefile.cpp @@ -28,9 +28,18 @@ MimeFile::MimeFile(QFile *file) this->cName = QFileInfo(*file).fileName(); this->cEncoding = Base64; } +MimeFile::MimeFile(const QByteArray& stream, const QString& fileName) +{ + this->cEncoding = Base64; + this->cType = "application/octet-stream"; + this->file = 0; + this->cName = fileName; + this->content = stream; +} MimeFile::~MimeFile() { + if (file) delete file; } @@ -46,10 +55,12 @@ MimeFile::~MimeFile() void MimeFile::prepare() { + if (this->file) + { file->open(QIODevice::ReadOnly); this->content = file->readAll(); file->close(); - + } /* !!! IMPORTANT !!!! */ MimePart::prepare(); } diff --git a/src/mimefile.h b/src/mimefile.h index b72e947..9e1b46f 100644 --- a/src/mimefile.h +++ b/src/mimefile.h @@ -29,6 +29,7 @@ public: /* [1] Constructors and Destructors */ + MimeFile(const QByteArray& stream, const QString& fileName); MimeFile(QFile *f); ~MimeFile(); diff --git a/src/mimemessage.cpp b/src/mimemessage.cpp index 14a76c7..0c4ebc2 100644 --- a/src/mimemessage.cpp +++ b/src/mimemessage.cpp @@ -23,16 +23,22 @@ #include /* [1] Constructors and Destructors */ - MimeMessage::MimeMessage(bool createAutoMimeContent) : hEncoding(MimePart::_8Bit) { if (createAutoMimeContent) this->content = new MimeMultiPart(); + + autoMimeContentCreated = createAutoMimeContent; } MimeMessage::~MimeMessage() { + if (this->autoMimeContentCreated) + { + this->autoMimeContentCreated = false; + delete (this->content); + } } /* [1] --- */ @@ -44,6 +50,11 @@ MimePart& MimeMessage::getContent() { } void MimeMessage::setContent(MimePart *content) { + if (this->autoMimeContentCreated) + { + this->autoMimeContentCreated = false; + delete (this->content); + } this->content = content; } diff --git a/src/mimemessage.h b/src/mimemessage.h index d0297d1..b524f74 100644 --- a/src/mimemessage.h +++ b/src/mimemessage.h @@ -78,7 +78,8 @@ protected: QList recipientsTo, recipientsCc, recipientsBcc; QString subject; MimePart *content; - + bool autoMimeContentCreated; + MimePart::Encoding hEncoding; /* [4] --- */