Merge pull request #11 from sjinks/dev

Qt 5 compatibility
This commit is contained in:
Tőkés Attila 2013-08-04 10:19:58 -07:00
commit 07140fee85
6 changed files with 20 additions and 21 deletions

View File

@ -148,20 +148,20 @@ QString MimeMessage::toString()
return QString(out.buffer()); return QString(out.buffer());
} }
QString MimeMessage::formatAddress(EmailAddress *address, MimePart::Encoding encoding) { QByteArray MimeMessage::formatAddress(EmailAddress *address, MimePart::Encoding encoding) {
QString result; QByteArray result;
if (address->getName() != "") if (!address->getName().isEmpty())
{ {
switch (encoding) switch (encoding)
{ {
case MimePart::Base64: case MimePart::Base64:
result.append(" =?utf-8?B?" + QByteArray().append(address->getName()).toBase64() + "?="); result.append(" =?utf-8?B?" + address->getName().toLocal8Bit().toBase64() + "?=");
break; break;
case MimePart::QuotedPrintable: 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; break;
default: default:
result.append(" " + address->getName()); result.append(" ").append(address->getName().toLocal8Bit());
} }
} }
result.append(" <" + address->getAddress() + ">"); result.append(" <" + address->getAddress() + ">");
@ -172,17 +172,16 @@ void MimeMessage::writeToDevice(QIODevice &out) {
/* =========== MIME HEADER ============ */ /* =========== MIME HEADER ============ */
/* ---------- Sender / From ----------- */ /* ---------- Sender / From ----------- */
QString header; QByteArray header;
header.append("From:" + formatAddress(sender, hEncoding) + "\r\n"); header.append("From:" + formatAddress(sender, hEncoding) + "\r\n");
/* ---------------------------------- */ /* ---------------------------------- */
/* ------- Recipients / To ---------- */ /* ------- Recipients / To ---------- */
header.append("To:"); header.append("To:");
QList<EmailAddress*>::iterator it; int i; for (int i = 0; i<recipientsTo.size(); ++i)
for (i = 0, it = recipientsTo.begin(); it != recipientsTo.end(); ++it, ++i)
{ {
if (i != 0) { header.append(","); } if (i != 0) { header.append(","); }
header.append(formatAddress(*it, hEncoding)); header.append(formatAddress(recipientsTo.at(i), hEncoding));
} }
header.append("\r\n"); header.append("\r\n");
/* ---------------------------------- */ /* ---------------------------------- */
@ -191,10 +190,10 @@ void MimeMessage::writeToDevice(QIODevice &out) {
if (recipientsCc.size() != 0) { if (recipientsCc.size() != 0) {
header.append("Cc:"); header.append("Cc:");
} }
for (i = 0, it = recipientsCc.begin(); it != recipientsCc.end(); ++it, ++i) for (int i = 0; i<recipientsCc.size(); ++i)
{ {
if (i != 0) { header.append(","); } if (i != 0) { header.append(","); }
header.append(formatAddress(*it, hEncoding)); header.append(formatAddress(recipientsCc.at(i), hEncoding));
} }
if (recipientsCc.size() != 0) { if (recipientsCc.size() != 0) {
header.append("\r\n"); header.append("\r\n");
@ -208,10 +207,10 @@ void MimeMessage::writeToDevice(QIODevice &out) {
switch (hEncoding) switch (hEncoding)
{ {
case MimePart::Base64: case MimePart::Base64:
header.append("=?utf-8?B?" + QByteArray().append(subject).toBase64() + "?="); header.append("=?utf-8?B?" + subject.toLocal8Bit().toBase64() + "?=");
break; break;
case MimePart::QuotedPrintable: case MimePart::QuotedPrintable:
header.append("=?utf-8?Q?" + QuotedPrintable::encode(QByteArray().append(subject)).replace(' ', "_").replace(':',"=3A") + "?="); header.append("=?utf-8?Q?" + QuotedPrintable::encode(subject.toLocal8Bit()).toLocal8Bit().replace(' ', "_").replace(':',"=3A") + "?=");
break; break;
default: default:
header.append(subject); header.append(subject);
@ -221,7 +220,7 @@ void MimeMessage::writeToDevice(QIODevice &out) {
header.append("\r\n"); header.append("\r\n");
header.append("MIME-Version: 1.0\r\n"); header.append("MIME-Version: 1.0\r\n");
out.write(header.toAscii()); out.write(header);
content->writeToDevice(out); content->writeToDevice(out);
} }

View File

@ -85,7 +85,7 @@ protected:
MimePart::Encoding hEncoding; MimePart::Encoding hEncoding;
static QString formatAddress(EmailAddress*, MimePart::Encoding); static QByteArray formatAddress(EmailAddress*, MimePart::Encoding);
/* [4] --- */ /* [4] --- */

View File

@ -60,13 +60,13 @@ void MimeMultiPart::writeContent(QIODevice &device) {
content = ""; content = "";
for (it = parts.begin(); it != parts.end(); it++) { for (it = parts.begin(); it != parts.end(); it++) {
device.write("--" ); device.write("--" );
device.write(cBoundary.toAscii()); device.write(cBoundary.toLatin1());
device.write("\r\n"); device.write("\r\n");
(*it)->writeToDevice(device); (*it)->writeToDevice(device);
}; };
device.write("--"); device.write("--");
device.write(cBoundary.toAscii()); device.write(cBoundary.toLatin1());
device.write("--\r\n"); device.write("--\r\n");
} }

View File

@ -191,7 +191,7 @@ void MimePart::writeToDevice(QIODevice &device) {
/* === End of Header Prepare === */ /* === End of Header Prepare === */
device.write(header.toAscii()); device.write(header.toLatin1());
writeContent(device); writeContent(device);
} }

View File

@ -4,5 +4,5 @@
MimeQpEncoder::MimeQpEncoder() {} MimeQpEncoder::MimeQpEncoder() {}
QByteArray MimeQpEncoder::encode(const QByteArray &data) { QByteArray MimeQpEncoder::encode(const QByteArray &data) {
return QuotedPrintable::encode(data).toAscii(); return QuotedPrintable::encode(data).toLatin1();
} }

View File

@ -51,7 +51,7 @@ const QString & MimeText::getText() const
/* [3] Protected Methods */ /* [3] Protected Methods */
void MimeText::writeContent(QIODevice &device) { void MimeText::writeContent(QIODevice &device) {
this->content = text.toAscii(); this->content = text.toLocal8Bit();
MimePart::writeContent(device); MimePart::writeContent(device);
} }