Added some documentation.
This commit is contained in:
parent
9e048495ba
commit
baa3cb2293
@ -23,8 +23,6 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QEventLoop>
|
#include <QEventLoop>
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
/* [1] Constructors and destructors */
|
/* [1] Constructors and destructors */
|
||||||
|
|
||||||
@ -56,100 +54,132 @@ SmtpClient::~SmtpClient() {}
|
|||||||
|
|
||||||
/* [2] Getters and Setters */
|
/* [2] Getters and Setters */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets the username to the specified value.
|
||||||
|
*/
|
||||||
void SmtpClient::setUser(const QString &user)
|
void SmtpClient::setUser(const QString &user)
|
||||||
{
|
{
|
||||||
this->user = user;
|
this->user = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets the password to the specified value
|
||||||
|
*/
|
||||||
void SmtpClient::setPassword(const QString &password)
|
void SmtpClient::setPassword(const QString &password)
|
||||||
{
|
{
|
||||||
this->password = password;
|
this->password = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Changes the authentication method to the specified.
|
||||||
|
*/
|
||||||
void SmtpClient::setAuthMethod(AuthMethod method)
|
void SmtpClient::setAuthMethod(AuthMethod method)
|
||||||
{
|
{
|
||||||
this->authMethod = method;
|
this->authMethod = method;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets the host of connection.
|
||||||
|
*/
|
||||||
void SmtpClient::setHost(QString &host)
|
void SmtpClient::setHost(QString &host)
|
||||||
{
|
{
|
||||||
this->host = host;
|
this->host = host;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets the connection port to the specified value.
|
||||||
|
* @param port
|
||||||
|
*/
|
||||||
void SmtpClient::setPort(int port)
|
void SmtpClient::setPort(int port)
|
||||||
{
|
{
|
||||||
this->port = port;
|
this->port = port;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SmtpClient::setConnectionType(ConnectionType ct)
|
/**
|
||||||
{
|
* @brief Returns the host name of the server.
|
||||||
this->connectionType = ct;
|
*/
|
||||||
|
|
||||||
switch (connectionType)
|
|
||||||
{
|
|
||||||
case TcpConnection:
|
|
||||||
socket = new QTcpSocket(this);
|
|
||||||
break;
|
|
||||||
case SslConnection:
|
|
||||||
case TlsConnection:
|
|
||||||
socket = new QSslSocket(this);
|
|
||||||
//QSslSocket &s = *((QSslSocket*) socket);
|
|
||||||
connect(socket, SIGNAL(encrypted()),
|
|
||||||
this, SLOT(socketEncrypted()));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const QString& SmtpClient::getHost() const
|
const QString& SmtpClient::getHost() const
|
||||||
{
|
{
|
||||||
return this->host;
|
return this->host;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the username used for authenticating.
|
||||||
|
*/
|
||||||
const QString& SmtpClient::getUser() const
|
const QString& SmtpClient::getUser() const
|
||||||
{
|
{
|
||||||
return this->user;
|
return this->user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the password used for authenticating.
|
||||||
|
*/
|
||||||
const QString& SmtpClient::getPassword() const
|
const QString& SmtpClient::getPassword() const
|
||||||
{
|
{
|
||||||
return this->password;
|
return this->password;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the authentication method used.
|
||||||
|
*/
|
||||||
SmtpClient::AuthMethod SmtpClient::getAuthMethod() const
|
SmtpClient::AuthMethod SmtpClient::getAuthMethod() const
|
||||||
{
|
{
|
||||||
return this->authMethod;
|
return this->authMethod;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return the port.
|
||||||
|
*/
|
||||||
int SmtpClient::getPort() const
|
int SmtpClient::getPort() const
|
||||||
{
|
{
|
||||||
return this->port;
|
return this->port;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the connection type used.
|
||||||
|
*/
|
||||||
SmtpClient::ConnectionType SmtpClient::getConnectionType() const
|
SmtpClient::ConnectionType SmtpClient::getConnectionType() const
|
||||||
{
|
{
|
||||||
return connectionType;
|
return connectionType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the client's name.
|
||||||
|
*/
|
||||||
const QString& SmtpClient::getName() const
|
const QString& SmtpClient::getName() const
|
||||||
{
|
{
|
||||||
return this->name;
|
return this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets the client's name. This name is sent by the EHLO command.
|
||||||
|
*/
|
||||||
void SmtpClient::setName(const QString &name)
|
void SmtpClient::setName(const QString &name)
|
||||||
{
|
{
|
||||||
this->name = name;
|
this->name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the last response of the server.
|
||||||
|
*/
|
||||||
const QString & SmtpClient::getResponseText() const
|
const QString & SmtpClient::getResponseText() const
|
||||||
{
|
{
|
||||||
return responseText;
|
return responseText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns the last response code recived by the client.
|
||||||
|
*/
|
||||||
int SmtpClient::getResponseCode() const
|
int SmtpClient::getResponseCode() const
|
||||||
{
|
{
|
||||||
return responseCode;
|
return responseCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Return the socket used by the client. The type of the of the
|
||||||
|
* connection is QTcpConnection in case of TcpConnection, and QSslSocket
|
||||||
|
* for SslConnection and TlsConnection.
|
||||||
|
*/
|
||||||
QTcpSocket* SmtpClient::getSocket() {
|
QTcpSocket* SmtpClient::getSocket() {
|
||||||
return socket;
|
return socket;
|
||||||
}
|
}
|
||||||
@ -229,6 +259,24 @@ bool SmtpClient::waitForMailSent(int msec) {
|
|||||||
|
|
||||||
/* [4] Protected methods */
|
/* [4] Protected methods */
|
||||||
|
|
||||||
|
void SmtpClient::setConnectionType(ConnectionType ct)
|
||||||
|
{
|
||||||
|
this->connectionType = ct;
|
||||||
|
|
||||||
|
switch (connectionType)
|
||||||
|
{
|
||||||
|
case TcpConnection:
|
||||||
|
socket = new QTcpSocket(this);
|
||||||
|
break;
|
||||||
|
case SslConnection:
|
||||||
|
case TlsConnection:
|
||||||
|
socket = new QSslSocket(this);
|
||||||
|
connect(socket, SIGNAL(encrypted()),
|
||||||
|
this, SLOT(socketEncrypted()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SmtpClient::changeState(ClientState state) {
|
void SmtpClient::changeState(ClientState state) {
|
||||||
this->state = state;
|
this->state = state;
|
||||||
|
|
||||||
|
@ -120,7 +120,6 @@ public:
|
|||||||
void setName(const QString &name);
|
void setName(const QString &name);
|
||||||
|
|
||||||
ConnectionType getConnectionType() const;
|
ConnectionType getConnectionType() const;
|
||||||
void setConnectionType(ConnectionType ct);
|
|
||||||
|
|
||||||
const QString & getUser() const;
|
const QString & getUser() const;
|
||||||
void setUser(const QString &host);
|
void setUser(const QString &host);
|
||||||
@ -193,10 +192,9 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
/* [5] Protected methods */
|
/* [5] Protected methods */
|
||||||
|
void setConnectionType(ConnectionType ct);
|
||||||
void changeState(ClientState state);
|
void changeState(ClientState state);
|
||||||
|
|
||||||
void processResponse();
|
void processResponse();
|
||||||
|
|
||||||
void sendMessage(const QString &text);
|
void sendMessage(const QString &text);
|
||||||
|
|
||||||
/* [5] --- */
|
/* [5] --- */
|
||||||
|
Loading…
Reference in New Issue
Block a user