- 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)
|
MimeAttachment::MimeAttachment(QFile *file)
|
||||||
: MimeFile(file)
|
: MimeFile(file)
|
||||||
{
|
{
|
||||||
|
}
|
||||||
|
MimeAttachment::MimeAttachment(const QByteArray& stream, const QString& fileName): MimeFile(stream, fileName)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MimeAttachment::~MimeAttachment()
|
MimeAttachment::~MimeAttachment()
|
||||||
|
@ -31,6 +31,8 @@ public:
|
|||||||
/* [1] Constructors and Destructors */
|
/* [1] Constructors and Destructors */
|
||||||
|
|
||||||
MimeAttachment(QFile* file);
|
MimeAttachment(QFile* file);
|
||||||
|
MimeAttachment(const QByteArray& stream, const QString& fileName);
|
||||||
|
|
||||||
~MimeAttachment();
|
~MimeAttachment();
|
||||||
|
|
||||||
/* [1] --- */
|
/* [1] --- */
|
||||||
|
@ -28,9 +28,18 @@ MimeFile::MimeFile(QFile *file)
|
|||||||
this->cName = QFileInfo(*file).fileName();
|
this->cName = QFileInfo(*file).fileName();
|
||||||
this->cEncoding = Base64;
|
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()
|
MimeFile::~MimeFile()
|
||||||
{
|
{
|
||||||
|
if (file)
|
||||||
delete file;
|
delete file;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,10 +55,12 @@ MimeFile::~MimeFile()
|
|||||||
|
|
||||||
void MimeFile::prepare()
|
void MimeFile::prepare()
|
||||||
{
|
{
|
||||||
|
if (this->file)
|
||||||
|
{
|
||||||
file->open(QIODevice::ReadOnly);
|
file->open(QIODevice::ReadOnly);
|
||||||
this->content = file->readAll();
|
this->content = file->readAll();
|
||||||
file->close();
|
file->close();
|
||||||
|
}
|
||||||
/* !!! IMPORTANT !!!! */
|
/* !!! IMPORTANT !!!! */
|
||||||
MimePart::prepare();
|
MimePart::prepare();
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ public:
|
|||||||
|
|
||||||
/* [1] Constructors and Destructors */
|
/* [1] Constructors and Destructors */
|
||||||
|
|
||||||
|
MimeFile(const QByteArray& stream, const QString& fileName);
|
||||||
MimeFile(QFile *f);
|
MimeFile(QFile *f);
|
||||||
~MimeFile();
|
~MimeFile();
|
||||||
|
|
||||||
|
@ -23,16 +23,22 @@
|
|||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
|
|
||||||
/* [1] Constructors and Destructors */
|
/* [1] Constructors and Destructors */
|
||||||
|
|
||||||
MimeMessage::MimeMessage(bool createAutoMimeContent) :
|
MimeMessage::MimeMessage(bool createAutoMimeContent) :
|
||||||
hEncoding(MimePart::_8Bit)
|
hEncoding(MimePart::_8Bit)
|
||||||
{
|
{
|
||||||
if (createAutoMimeContent)
|
if (createAutoMimeContent)
|
||||||
this->content = new MimeMultiPart();
|
this->content = new MimeMultiPart();
|
||||||
|
|
||||||
|
autoMimeContentCreated = createAutoMimeContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
MimeMessage::~MimeMessage()
|
MimeMessage::~MimeMessage()
|
||||||
{
|
{
|
||||||
|
if (this->autoMimeContentCreated)
|
||||||
|
{
|
||||||
|
this->autoMimeContentCreated = false;
|
||||||
|
delete (this->content);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* [1] --- */
|
/* [1] --- */
|
||||||
@ -44,6 +50,11 @@ MimePart& MimeMessage::getContent() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MimeMessage::setContent(MimePart *content) {
|
void MimeMessage::setContent(MimePart *content) {
|
||||||
|
if (this->autoMimeContentCreated)
|
||||||
|
{
|
||||||
|
this->autoMimeContentCreated = false;
|
||||||
|
delete (this->content);
|
||||||
|
}
|
||||||
this->content = content;
|
this->content = content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,8 @@ protected:
|
|||||||
QList<EmailAddress*> recipientsTo, recipientsCc, recipientsBcc;
|
QList<EmailAddress*> recipientsTo, recipientsCc, recipientsBcc;
|
||||||
QString subject;
|
QString subject;
|
||||||
MimePart *content;
|
MimePart *content;
|
||||||
|
bool autoMimeContentCreated;
|
||||||
|
|
||||||
MimePart::Encoding hEncoding;
|
MimePart::Encoding hEncoding;
|
||||||
|
|
||||||
/* [4] --- */
|
/* [4] --- */
|
||||||
|
Loading…
Reference in New Issue
Block a user