1 /**************************************************************************** 2 ** 3 ** Copyright (C) Qxt Foundation. Some rights reserved. 4 ** 5 ** This file is part of the QxtWeb module of the Qxt library. 6 ** 7 ** This library is free software; you can redistribute it and/or modify it 8 ** under the terms of the Common Public License, version 1.0, as published 9 ** by IBM, and/or under the terms of the GNU Lesser General Public License, 10 ** version 2.1, as published by the Free Software Foundation. 11 ** 12 ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY 13 ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY 14 ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR 15 ** FITNESS FOR A PARTICULAR PURPOSE. 16 ** 17 ** You should have received a copy of the CPL and the LGPL along with this 18 ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files 19 ** included with the source distribution for more information. 20 ** If you did not receive a copy of the licenses, contact the Qxt Foundation. 21 ** 22 ** <http://libqxt.org> <foundation@libqxt.org> 23 ** 24 ****************************************************************************/ 25 #ifndef QXTSMTP_P_H 26 #define QXTSMTP_P_H 27 28 #include "qxtsmtp.h" 29 #include <QHash> 30 #include <QString> 31 #include <QList> 32 #include <QPair> 33 34 class QxtSmtpPrivate : public QObject, public QxtPrivate<QxtSmtp> 35 { 36 Q_OBJECT 37 public: 38 QxtSmtpPrivate(); 39 40 QXT_DECLARE_PUBLIC(QxtSmtp) 41 42 enum SmtpState 43 { 44 Disconnected, 45 StartState, 46 EhloSent, 47 EhloGreetReceived, 48 EhloExtensionsReceived, 49 EhloDone, 50 HeloSent, 51 StartTLSSent, 52 AuthRequestSent, 53 AuthUsernameSent, 54 AuthSent, 55 Authenticated, 56 MailToSent, 57 RcptAckPending, 58 SendingBody, 59 BodySent, 60 Waiting, 61 Resetting 62 }; 63 64 enum AuthType 65 { 66 AuthPlain, 67 AuthLogin, 68 AuthCramMD5 69 }; 70 71 bool useSecure, disableStartTLS; 72 SmtpState state;// rather then an int use the enum. makes sure invalid states are entered at compile time, and makes debugging easier 73 AuthType authType; 74 QByteArray buffer, username, password; 75 QHash<QString, QString> extensions; 76 QList<QPair<int, QxtMailMessage> > pending; 77 QStringList recipients; 78 int nextID, rcptNumber, rcptAck; 79 bool mailAck; 80 81 #ifndef QT_NO_OPENSSL 82 QSslSocket* socket; 83 #else 84 QTcpSocket* socket; 85 #endif 86 87 void parseEhlo(const QByteArray& code, bool cont, const QString& line); 88 void startTLS(); 89 void authenticate(); 90 91 void authCramMD5(const QByteArray& challenge = QByteArray()); 92 void authPlain(); 93 void authLogin(); 94 95 void sendNextRcpt(const QByteArray& code, const QByteArray & line); 96 void sendBody(const QByteArray& code, const QByteArray & line); 97 98 public slots: 99 void socketError(QAbstractSocket::SocketError err); 100 void socketRead(); 101 102 void ehlo(); 103 void sendNext(); 104 }; 105 106 #endif // QXTSMTP_P_H 107