diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4bac168 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*.o +*.so +*.so.* +Makefile +moc_*.cpp diff --git a/src/SMTPEmail.pro b/src/SMTPEmail.pro index 4abab5f..df601fd 100644 --- a/src/SMTPEmail.pro +++ b/src/SMTPEmail.pro @@ -48,7 +48,6 @@ HEADERS += \ mimebase64encoder.h \ mimeqpencoder.h \ mimeqpformatter.h \ - mimepart.cpp.autosave \ mimebase64formatter.h \ mimecontentformatter.h diff --git a/src/emailaddress.h b/src/emailaddress.h index 44f1a2e..e3eb6e5 100644 --- a/src/emailaddress.h +++ b/src/emailaddress.h @@ -20,11 +20,10 @@ #define EMAILADDRESS_H #include "smtpmime_global.h" -#include +#include -class SMTP_MIME_EXPORT EmailAddress : public QObject +class SMTP_MIME_EXPORT EmailAddress { - Q_OBJECT public: /* [1] Constructors and Destructors */ diff --git a/src/mimeattachment.h b/src/mimeattachment.h index 90a5780..8b8e4cd 100644 --- a/src/mimeattachment.h +++ b/src/mimeattachment.h @@ -20,14 +20,12 @@ #define MIMEATTACHMENT_H -#include #include "smtpmime_global.h" #include "mimepart.h" #include "mimefile.h" class SMTP_MIME_EXPORT MimeAttachment : public MimeFile { - Q_OBJECT public: /* [1] Constructors and Destructors */ diff --git a/src/mimefile.h b/src/mimefile.h index 8540c77..0ec74f2 100644 --- a/src/mimefile.h +++ b/src/mimefile.h @@ -19,13 +19,13 @@ #ifndef MIMEFILE_H #define MIMEFILE_H -#include #include "mimepart.h" #include "smtpmime_global.h" +class QFile; + class SMTP_MIME_EXPORT MimeFile : public MimePart { - Q_OBJECT public: /* [1] Constructors and Destructors */ diff --git a/src/mimehtml.h b/src/mimehtml.h index 5d59bc4..b8b7098 100644 --- a/src/mimehtml.h +++ b/src/mimehtml.h @@ -24,7 +24,6 @@ class SMTP_MIME_EXPORT MimeHtml : public MimeText { - Q_OBJECT public: /* [1] Constructors and Destructors */ diff --git a/src/mimemultipart.cpp b/src/mimemultipart.cpp index b3a70d1..8f14144 100644 --- a/src/mimemultipart.cpp +++ b/src/mimemultipart.cpp @@ -17,6 +17,7 @@ */ #include "mimemultipart.h" +#include #include #include diff --git a/src/mimemultipart.h b/src/mimemultipart.h index 6355347..f4770c4 100644 --- a/src/mimemultipart.h +++ b/src/mimemultipart.h @@ -20,13 +20,11 @@ #define MIMEMULTIPART_H #include -#include #include "smtpmime_global.h" #include "mimepart.h" class SMTP_MIME_EXPORT MimeMultiPart : public MimePart { - Q_OBJECT public: /* [0] Enums */ diff --git a/src/mimepart.h b/src/mimepart.h index 49bbb19..bb3d65a 100644 --- a/src/mimepart.h +++ b/src/mimepart.h @@ -19,13 +19,14 @@ #ifndef MIMEPART_H #define MIMEPART_H -#include -#include #include "smtpmime_global.h" +#include +#include -class SMTP_MIME_EXPORT MimePart : public QObject +class QIODevice; + +class SMTP_MIME_EXPORT MimePart { - Q_OBJECT public: /* [0] Enumerations */ @@ -43,7 +44,7 @@ public: /* [1] Constructors and Destructors */ MimePart(); - ~MimePart(); + virtual ~MimePart(); /* [1] --- */ diff --git a/src/quotedprintable.cpp b/src/quotedprintable.cpp index e7e130c..1d83ddb 100644 --- a/src/quotedprintable.cpp +++ b/src/quotedprintable.cpp @@ -18,49 +18,63 @@ #include "quotedprintable.h" -QString& QuotedPrintable::encode(const QByteArray &input) +QString QuotedPrintable::encode(const QByteArray &input) { - QString *output = new QString(); + QString output; char byte; - const char hex[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; + static const char hex[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; for (int i = 0; i < input.length() ; ++i) { byte = input[i]; - if ((byte == 0x20) || (byte >= 33) && (byte <= 126) && (byte != 61)) { - output->append(byte); + if ((byte == 0x20) || ((byte >= 33) && (byte <= 126) && (byte != 61))) { + output.append(byte); } else { - output->append('='); - output->append(hex[((byte >> 4) & 0x0F)]); - output->append(hex[(byte & 0x0F)]); + output.append('=').append(hex[((byte >> 4) & 0x0F)]).append(hex[(byte & 0x0F)]); } } - return *output; + return output; } -QByteArray& QuotedPrintable::decode(const QString &input) +QByteArray QuotedPrintable::decode(const QString &input) { - // 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F - const int hexVal[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 10, 11, 12, 13, 14, 15}; + // 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F + static const int hexVal[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 10, 11, 12, 13, 14, 15}; - QByteArray *output = new QByteArray(); + QByteArray output; - for (int i = 0; i < input.length(); ++i) + int len = input.length(); + int i; + for (i = 0; i < len-2; ++i) { - if (input.at(i).toAscii() == '=') + if (input.at(i).toLatin1() == '=') { - output->append((hexVal[input.at(++i).toAscii() - '0'] << 4) + hexVal[input.at(++i).toAscii() - '0']); + int x = input.at(i+1).toLatin1() - '0'; + int y = input.at(i+2).toLatin1() - '0'; + if (x >= 0 && y >= 0 && x < 23 && y < 23) { + output.append(char((hexVal[x] << 4) + hexVal[y])); + } + else { + output.append('=').append(char(x + '0')).append(char(y + '0')); + } + + i += 2; } else { - output->append(input.at(i).toAscii()); + output.append(input.at(i).toLatin1()); } } - return *output; + while (i #include +#include #include "smtpmime_global.h" -class SMTP_MIME_EXPORT QuotedPrintable : public QObject -{ - Q_OBJECT -public: - - static QString& encode(const QByteArray &input); - static QByteArray& decode(const QString &input); - -private: - QuotedPrintable(); -}; +namespace QuotedPrintable { + SMTP_MIME_EXPORT QString encode(const QByteArray &input); + SMTP_MIME_EXPORT QByteArray decode(const QString &input); +} #endif // QUOTEDPRINTABLE_H diff --git a/src/smtpclient.cpp b/src/smtpclient.cpp index cbbcd5f..39cd786 100644 --- a/src/smtpclient.cpp +++ b/src/smtpclient.cpp @@ -617,6 +617,8 @@ void SmtpClient::socketStateChanged(QAbstractSocket::SocketState state) { void SmtpClient::socketError(QAbstractSocket::SocketError socketError) { #ifndef QT_NO_DEBUG qDebug() << "SocketError:" << socketError << socket->error(); +#else + Q_UNUSED(socketError); #endif emit error(SocketError); } diff --git a/test/main.cpp b/test/main.cpp index 3d3900b..1a51960 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -1,4 +1,3 @@ -#include #include #include #include @@ -6,16 +5,17 @@ bool success = true; -void runTest(QObject *test) { - int retVal = QTest::qExec(test); +static void runTest(QObject *test, int argc, char** argv) { + int retVal = QTest::qExec(test, argc, argv); + delete test; success &= retVal == 0; } int main(int argc, char *argv[]) { - QApplication a(argc, argv); + QCoreApplication a(argc, argv); - runTest(new ConnectionTest()); + runTest(new ConnectionTest(), argc, argv); if (success) qDebug() << "SUCCESS"; diff --git a/test/test.pro b/test/test.pro index 499b18e..0641456 100644 --- a/test/test.pro +++ b/test/test.pro @@ -4,7 +4,8 @@ # #------------------------------------------------- -QT += testlib gui +QT += testlib +QT -= gui TARGET = test CONFIG += console