From 4ff42edc4ff244fb6e62d67b5780e1ffae8df5ec Mon Sep 17 00:00:00 2001 From: Vladimir Kolesnikov Date: Thu, 14 Feb 2013 01:27:00 +0200 Subject: [PATCH] Qt 5 compatibility --- src/mimemessage.cpp | 29 ++++++++++++++--------------- src/mimemessage.h | 2 +- src/mimemultipart.cpp | 4 ++-- src/mimepart.cpp | 2 +- src/mimeqpencoder.cpp | 2 +- src/mimetext.cpp | 2 +- 6 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/mimemessage.cpp b/src/mimemessage.cpp index 3eae06e..ec79503 100644 --- a/src/mimemessage.cpp +++ b/src/mimemessage.cpp @@ -148,20 +148,20 @@ QString MimeMessage::toString() return QString(out.buffer()); } -QString MimeMessage::formatAddress(EmailAddress *address, MimePart::Encoding encoding) { - QString result; - if (address->getName() != "") +QByteArray MimeMessage::formatAddress(EmailAddress *address, MimePart::Encoding encoding) { + QByteArray result; + if (!address->getName().isEmpty()) { switch (encoding) { case MimePart::Base64: - result.append(" =?utf-8?B?" + QByteArray().append(address->getName()).toBase64() + "?="); + result.append(" =?utf-8?B?" + address->getName().toLocal8Bit().toBase64() + "?="); break; case MimePart::QuotedPrintable: - result.append(" =?utf-8?Q?" + QuotedPrintable::encode(QByteArray().append(address->getName())).replace(' ', "_").replace(':',"=3A") + "?="); + result.append(" =?utf-8?Q?" + QuotedPrintable::encode(address->getName().toLocal8Bit()).toLocal8Bit().replace(' ', "_").replace(':',"=3A") + "?="); break; default: - result.append(" " + address->getName()); + result.append(" ").append(address->getName().toLocal8Bit()); } } result.append(" <" + address->getAddress() + ">"); @@ -172,17 +172,16 @@ void MimeMessage::writeToDevice(QIODevice &out) { /* =========== MIME HEADER ============ */ /* ---------- Sender / From ----------- */ - QString header; + QByteArray header; header.append("From:" + formatAddress(sender, hEncoding) + "\r\n"); /* ---------------------------------- */ /* ------- Recipients / To ---------- */ header.append("To:"); - QList::iterator it; int i; - for (i = 0, it = recipientsTo.begin(); it != recipientsTo.end(); ++it, ++i) + for (int i = 0; iwriteToDevice(out); } diff --git a/src/mimemessage.h b/src/mimemessage.h index 7f7edc6..9735c6a 100644 --- a/src/mimemessage.h +++ b/src/mimemessage.h @@ -85,7 +85,7 @@ protected: MimePart::Encoding hEncoding; - static QString formatAddress(EmailAddress*, MimePart::Encoding); + static QByteArray formatAddress(EmailAddress*, MimePart::Encoding); /* [4] --- */ diff --git a/src/mimemultipart.cpp b/src/mimemultipart.cpp index 8f14144..c5086a4 100644 --- a/src/mimemultipart.cpp +++ b/src/mimemultipart.cpp @@ -60,13 +60,13 @@ void MimeMultiPart::writeContent(QIODevice &device) { content = ""; for (it = parts.begin(); it != parts.end(); it++) { device.write("--" ); - device.write(cBoundary.toAscii()); + device.write(cBoundary.toLatin1()); device.write("\r\n"); (*it)->writeToDevice(device); }; device.write("--"); - device.write(cBoundary.toAscii()); + device.write(cBoundary.toLatin1()); device.write("--\r\n"); } diff --git a/src/mimepart.cpp b/src/mimepart.cpp index 1e85da9..58d1f5b 100644 --- a/src/mimepart.cpp +++ b/src/mimepart.cpp @@ -191,7 +191,7 @@ void MimePart::writeToDevice(QIODevice &device) { /* === End of Header Prepare === */ - device.write(header.toAscii()); + device.write(header.toLatin1()); writeContent(device); } diff --git a/src/mimeqpencoder.cpp b/src/mimeqpencoder.cpp index 5d7e89e..20670c9 100644 --- a/src/mimeqpencoder.cpp +++ b/src/mimeqpencoder.cpp @@ -4,5 +4,5 @@ MimeQpEncoder::MimeQpEncoder() {} QByteArray MimeQpEncoder::encode(const QByteArray &data) { - return QuotedPrintable::encode(data).toAscii(); + return QuotedPrintable::encode(data).toLatin1(); } diff --git a/src/mimetext.cpp b/src/mimetext.cpp index 338cf1e..288c6b9 100644 --- a/src/mimetext.cpp +++ b/src/mimetext.cpp @@ -51,7 +51,7 @@ const QString & MimeText::getText() const /* [3] Protected Methods */ void MimeText::writeContent(QIODevice &device) { - this->content = text.toAscii(); + this->content = text.toLocal8Bit(); MimePart::writeContent(device); }