Merge pull request #10 from sjinks/dev
Fixed some bugs and memory leaks
This commit is contained in:
commit
208b072ad3
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
*.o
|
||||
*.so
|
||||
*.so.*
|
||||
Makefile
|
||||
moc_*.cpp
|
@ -48,7 +48,6 @@ HEADERS += \
|
||||
mimebase64encoder.h \
|
||||
mimeqpencoder.h \
|
||||
mimeqpformatter.h \
|
||||
mimepart.cpp.autosave \
|
||||
mimebase64formatter.h \
|
||||
mimecontentformatter.h
|
||||
|
||||
|
@ -20,11 +20,10 @@
|
||||
#define EMAILADDRESS_H
|
||||
|
||||
#include "smtpmime_global.h"
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
class SMTP_MIME_EXPORT EmailAddress : public QObject
|
||||
class SMTP_MIME_EXPORT EmailAddress
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
/* [1] Constructors and Destructors */
|
||||
|
@ -20,14 +20,12 @@
|
||||
#define MIMEATTACHMENT_H
|
||||
|
||||
|
||||
#include <QFile>
|
||||
#include "smtpmime_global.h"
|
||||
#include "mimepart.h"
|
||||
#include "mimefile.h"
|
||||
|
||||
class SMTP_MIME_EXPORT MimeAttachment : public MimeFile
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
/* [1] Constructors and Destructors */
|
||||
|
@ -19,13 +19,13 @@
|
||||
#ifndef MIMEFILE_H
|
||||
#define MIMEFILE_H
|
||||
|
||||
#include <QFile>
|
||||
#include "mimepart.h"
|
||||
#include "smtpmime_global.h"
|
||||
|
||||
class QFile;
|
||||
|
||||
class SMTP_MIME_EXPORT MimeFile : public MimePart
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
/* [1] Constructors and Destructors */
|
||||
|
@ -24,7 +24,6 @@
|
||||
|
||||
class SMTP_MIME_EXPORT MimeHtml : public MimeText
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
/* [1] Constructors and Destructors */
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "mimemultipart.h"
|
||||
#include <QIODevice>
|
||||
#include <QTime>
|
||||
#include <QCryptographicHash>
|
||||
|
||||
|
@ -20,13 +20,11 @@
|
||||
#define MIMEMULTIPART_H
|
||||
|
||||
#include <QList>
|
||||
#include <QTextStream>
|
||||
#include "smtpmime_global.h"
|
||||
#include "mimepart.h"
|
||||
|
||||
class SMTP_MIME_EXPORT MimeMultiPart : public MimePart
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
/* [0] Enums */
|
||||
|
@ -19,13 +19,14 @@
|
||||
#ifndef MIMEPART_H
|
||||
#define MIMEPART_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QTextStream>
|
||||
#include "smtpmime_global.h"
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
|
||||
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] --- */
|
||||
|
||||
|
@ -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<len) {
|
||||
output.append(input.at(i).toLatin1());
|
||||
++i;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
@ -19,20 +19,13 @@
|
||||
#ifndef QUOTEDPRINTABLE_H
|
||||
#define QUOTEDPRINTABLE_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
#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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
#include <QtGui/QApplication>
|
||||
#include <QCoreApplication>
|
||||
#include <QtTest/QTest>
|
||||
#include <QDebug>
|
||||
@ -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";
|
||||
|
@ -4,7 +4,8 @@
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += testlib gui
|
||||
QT += testlib
|
||||
QT -= gui
|
||||
|
||||
TARGET = test
|
||||
CONFIG += console
|
||||
|
Loading…
Reference in New Issue
Block a user