Added more debug level logging.

This commit is contained in:
Attila Tőkés 2013-08-06 22:36:50 +03:00
parent 07140fee85
commit 45e6340ff3
3 changed files with 27 additions and 7 deletions

View File

@ -57,7 +57,6 @@ const QList<MimePart*> & MimeMultiPart::getParts() const {
void MimeMultiPart::writeContent(QIODevice &device) { void MimeMultiPart::writeContent(QIODevice &device) {
QList<MimePart*>::iterator it; QList<MimePart*>::iterator it;
content = "";
for (it = parts.begin(); it != parts.end(); it++) { for (it = parts.begin(); it != parts.end(); it++) {
device.write("--" ); device.write("--" );
device.write(cBoundary.toLatin1()); device.write(cBoundary.toLatin1());

View File

@ -22,7 +22,7 @@
#include <QByteArray> #include <QByteArray>
#include <QTimer> #include <QTimer>
#include <QEventLoop> #include <QEventLoop>
#include <QMetaEnum>
/* [1] Constructors and destructors */ /* [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; this->state = state;
#ifdef QT_NO_DEBUG #ifdef QT_NO_DEBUG
@ -321,7 +321,7 @@ void SmtpClient::changeState(ClientState state) {
} }
#else #else
// emit all in debug mode // emit all in debug mode
qDebug() << "State:" << state; qDebug() << "[SmtpClient] State:" << staticMetaObject.enumerator(staticMetaObject.indexOfEnumerator("ClientState")).valueToKey(state);
emit stateChanged(state); emit stateChanged(state);
#endif #endif
@ -461,6 +461,11 @@ void SmtpClient::changeState(ClientState state) {
case _MAIL_4_SEND_DATA: case _MAIL_4_SEND_DATA:
email->writeToDevice(*socket); email->writeToDevice(*socket);
#ifndef QT_NO_DEBUG
qDebug() << "[Socket] OUT:";
qDebug() << email->toString();
#endif
sendMessage("\r\n."); sendMessage("\r\n.");
break; break;
@ -582,7 +587,6 @@ void SmtpClient::processResponse() {
changeState(_READY_MailSent); changeState(_READY_MailSent);
break; break;
default: default:
; ;
} }
@ -590,6 +594,11 @@ void SmtpClient::processResponse() {
void SmtpClient::sendMessage(const QString &text) void SmtpClient::sendMessage(const QString &text)
{ {
#ifndef QT_NO_DEBUG
qDebug() << "[Socket] OUT:" << text;
#endif
socket->flush(); socket->flush();
socket->write(text.toUtf8() + "\r\n"); socket->write(text.toUtf8() + "\r\n");
} }
@ -600,6 +609,11 @@ void SmtpClient::sendMessage(const QString &text)
/* [5] Slots for the socket's signals */ /* [5] Slots for the socket's signals */
void SmtpClient::socketStateChanged(QAbstractSocket::SocketState state) { void SmtpClient::socketStateChanged(QAbstractSocket::SocketState state) {
#ifndef QT_NO_DEBUG
qDebug() << "[Socket] State:" << state;
#endif
switch (state) switch (state)
{ {
case QAbstractSocket::ConnectedState: case QAbstractSocket::ConnectedState:
@ -616,7 +630,7 @@ void SmtpClient::socketStateChanged(QAbstractSocket::SocketState state) {
void SmtpClient::socketError(QAbstractSocket::SocketError socketError) { void SmtpClient::socketError(QAbstractSocket::SocketError socketError) {
#ifndef QT_NO_DEBUG #ifndef QT_NO_DEBUG
qDebug() << "SocketError:" << socketError << socket->error(); qDebug() << "[Socket] ERROR:" << socketError;
#else #else
Q_UNUSED(socketError); Q_UNUSED(socketError);
#endif #endif
@ -630,9 +644,15 @@ void SmtpClient::socketReadyRead()
while (socket->canReadLine()) { while (socket->canReadLine()) {
// Save the server's response // Save the server's response
responseLine = socket->readLine(); responseLine = socket->readLine();
tempResponse += responseLine; tempResponse += responseLine;
#ifndef QT_NO_DEBUG
qDebug() << "[Socket] IN: " << responseLine;
#endif
} }
// Is this the last line of the response // Is this the last line of the response
if (responseLine[3] == ' ') { if (responseLine[3] == ' ') {
responseText = tempResponse; responseText = tempResponse;

View File

@ -29,6 +29,7 @@
class SMTP_MIME_EXPORT SmtpClient : public QObject class SMTP_MIME_EXPORT SmtpClient : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_ENUMS (AuthMethod SmtpError ConnectionType ClientState)
public: public:
/* [0] Enumerations */ /* [0] Enumerations */