- Added support for ByteArray Attachments
- Removed memoryleak from MimeMessage
This commit is contained in:
parent
dac7a04d6f
commit
93873f8b1c
@ -24,6 +24,10 @@
|
||||
MimeAttachment::MimeAttachment(QFile *file)
|
||||
: MimeFile(file)
|
||||
{
|
||||
}
|
||||
MimeAttachment::MimeAttachment(const QByteArray& stream, const QString& fileName): MimeFile(stream, fileName)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
MimeAttachment::~MimeAttachment()
|
||||
|
@ -31,6 +31,8 @@ public:
|
||||
/* [1] Constructors and Destructors */
|
||||
|
||||
MimeAttachment(QFile* file);
|
||||
MimeAttachment(const QByteArray& stream, const QString& fileName);
|
||||
|
||||
~MimeAttachment();
|
||||
|
||||
/* [1] --- */
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ public:
|
||||
|
||||
/* [1] Constructors and Destructors */
|
||||
|
||||
MimeFile(const QByteArray& stream, const QString& fileName);
|
||||
MimeFile(QFile *f);
|
||||
~MimeFile();
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -78,6 +78,7 @@ protected:
|
||||
QList<EmailAddress*> recipientsTo, recipientsCc, recipientsBcc;
|
||||
QString subject;
|
||||
MimePart *content;
|
||||
bool autoMimeContentCreated;
|
||||
|
||||
MimePart::Encoding hEncoding;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user