- Added support for ByteArray Attachments

- Removed memoryleak from MimeMessage
This commit is contained in:
LascauxSRL 2013-08-08 10:45:39 +02:00
parent dac7a04d6f
commit 93873f8b1c
6 changed files with 33 additions and 3 deletions

View File

@ -24,6 +24,10 @@
MimeAttachment::MimeAttachment(QFile *file)
: MimeFile(file)
{
}
MimeAttachment::MimeAttachment(const QByteArray& stream, const QString& fileName): MimeFile(stream, fileName)
{
}
MimeAttachment::~MimeAttachment()

View File

@ -31,6 +31,8 @@ public:
/* [1] Constructors and Destructors */
MimeAttachment(QFile* file);
MimeAttachment(const QByteArray& stream, const QString& fileName);
~MimeAttachment();
/* [1] --- */

View File

@ -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();
}

View File

@ -29,6 +29,7 @@ public:
/* [1] Constructors and Destructors */
MimeFile(const QByteArray& stream, const QString& fileName);
MimeFile(QFile *f);
~MimeFile();

View File

@ -23,16 +23,22 @@
#include <typeinfo>
/* [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;
}

View File

@ -78,7 +78,8 @@ protected:
QList<EmailAddress*> recipientsTo, recipientsCc, recipientsBcc;
QString subject;
MimePart *content;
bool autoMimeContentCreated;
MimePart::Encoding hEncoding;
/* [4] --- */