From 45e6340ff391927813402205dabc5140887e090a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20T=C5=91k=C3=A9s?= Date: Tue, 6 Aug 2013 22:36:50 +0300 Subject: [PATCH] Added more debug level logging. --- src/mimemultipart.cpp | 1 - src/smtpclient.cpp | 32 ++++++++++++++++++++++++++------ src/smtpclient.h | 1 + 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/mimemultipart.cpp b/src/mimemultipart.cpp index c5086a4..c922108 100644 --- a/src/mimemultipart.cpp +++ b/src/mimemultipart.cpp @@ -57,7 +57,6 @@ const QList & MimeMultiPart::getParts() const { void MimeMultiPart::writeContent(QIODevice &device) { QList::iterator it; - content = ""; for (it = parts.begin(); it != parts.end(); it++) { device.write("--" ); device.write(cBoundary.toLatin1()); diff --git a/src/smtpclient.cpp b/src/smtpclient.cpp index 39cd786..27b8e63 100644 --- a/src/smtpclient.cpp +++ b/src/smtpclient.cpp @@ -22,7 +22,7 @@ #include #include #include - +#include /* [1] Constructors and destructors */ @@ -311,7 +311,7 @@ void SmtpClient::setConnectionType(ConnectionType ct) } } -void SmtpClient::changeState(ClientState state) { +void SmtpClient::changeState(SmtpClient::ClientState state) { this->state = state; #ifdef QT_NO_DEBUG @@ -321,7 +321,7 @@ void SmtpClient::changeState(ClientState state) { } #else // emit all in debug mode - qDebug() << "State:" << state; + qDebug() << "[SmtpClient] State:" << staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("ClientState")).valueToKey(state); emit stateChanged(state); #endif @@ -461,6 +461,11 @@ void SmtpClient::changeState(ClientState state) { case _MAIL_4_SEND_DATA: email->writeToDevice(*socket); + +#ifndef QT_NO_DEBUG + qDebug() << "[Socket] OUT:"; + qDebug() << email->toString(); +#endif sendMessage("\r\n."); break; @@ -582,7 +587,6 @@ void SmtpClient::processResponse() { changeState(_READY_MailSent); break; - default: ; } @@ -590,6 +594,11 @@ void SmtpClient::processResponse() { void SmtpClient::sendMessage(const QString &text) { + +#ifndef QT_NO_DEBUG + qDebug() << "[Socket] OUT:" << text; +#endif + socket->flush(); socket->write(text.toUtf8() + "\r\n"); } @@ -600,6 +609,11 @@ void SmtpClient::sendMessage(const QString &text) /* [5] Slots for the socket's signals */ void SmtpClient::socketStateChanged(QAbstractSocket::SocketState state) { + +#ifndef QT_NO_DEBUG + qDebug() << "[Socket] State:" << state; +#endif + switch (state) { case QAbstractSocket::ConnectedState: @@ -616,7 +630,7 @@ void SmtpClient::socketStateChanged(QAbstractSocket::SocketState state) { void SmtpClient::socketError(QAbstractSocket::SocketError socketError) { #ifndef QT_NO_DEBUG - qDebug() << "SocketError:" << socketError << socket->error(); + qDebug() << "[Socket] ERROR:" << socketError; #else Q_UNUSED(socketError); #endif @@ -630,9 +644,15 @@ void SmtpClient::socketReadyRead() while (socket->canReadLine()) { // Save the server's response responseLine = socket->readLine(); - tempResponse += responseLine; + tempResponse += responseLine; + +#ifndef QT_NO_DEBUG + qDebug() << "[Socket] IN: " << responseLine; +#endif } + + // Is this the last line of the response if (responseLine[3] == ' ') { responseText = tempResponse; diff --git a/src/smtpclient.h b/src/smtpclient.h index 9673a5b..a7892e3 100644 --- a/src/smtpclient.h +++ b/src/smtpclient.h @@ -29,6 +29,7 @@ class SMTP_MIME_EXPORT SmtpClient : public QObject { Q_OBJECT + Q_ENUMS (AuthMethod SmtpError ConnectionType ClientState) public: /* [0] Enumerations */