KSmtp::Session

KSmtp::Session Class Reference

#include <session.h>

Inheritance diagram for KSmtp::Session:

Public Types

enum  State {
  Disconnected = 0, Ready, Handshake, NotAuthenticated,
  Authenticated, Quitting
}
 

Signals

void connectionError (const QString &error)
 
void stateChanged (KSmtp::Session::State state)
 

Public Member Functions

 Session (const QString &hostName, quint16 port, QObject *parent=nullptr)
 
bool allowsTls () const
 
QStringList availableAuthModes () const
 
QString customHostname () const
 
QString hostName () const
 
void open ()
 
void openAndWait ()
 
quint16 port () const
 
void quit ()
 
void quitAndWait ()
 
void setCustomHostname (const QString &hostname)
 
void setSocketTimeout (int ms)
 
void setUiProxy (const SessionUiProxy::Ptr &uiProxy)
 
void setUseNetworkProxy (bool useProxy)
 
int sizeLimit () const
 
int socketTimeout () const
 
State state () const
 
SessionUiProxy::Ptr uiProxy () const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo ()
 
void dumpObjectInfo () const const
 
void dumpObjectTree ()
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
qobject_cast (QObject *object)
 
qobject_cast (const QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
QThreadthread () const const
 

Additional Inherited Members

- Properties inherited from QObject
 objectName
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Public Attributes inherited from QObject
typedef QObjectList
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Detailed Description

The Session class.

Definition at line 34 of file session.h.

Member Enumeration Documentation

Enumerator
Disconnected 

The Session is not connected to the server.

Ready 

(internal)

Handshake 

(internal)

NotAuthenticated 

The Session is ready for login.

See also
KSmtp::LoginJob
Authenticated 

The Session is ready to send email.

See also
KSmtp::SendJob
Quitting 

(internal)

Definition at line 39 of file session.h.

Constructor & Destructor Documentation

Session::Session ( const QString hostName,
quint16  port,
QObject parent = nullptr 
)
explicit

Creates a new SMTP session to the specified host and port.

After creating the session, call setUseNetworkProxy() if necessary and then either open() or openAndWait() to open the connection.

See also
open(), openAndWait()

Definition at line 109 of file session.cpp.

Member Function Documentation

bool Session::allowsTls ( ) const

Returns true if the SMTP server has indicated that it allows TLS connections, false otherwise.

The session must be at least in the NotAuthenticated state. Before that, allowsTls() always returns false.

See also
KSmtp::LoginJob::setUseTls()

Definition at line 162 of file session.cpp.

QStringList Session::availableAuthModes ( ) const
Todo:
: return parsed auth modes, instead of strings.

Definition at line 167 of file session.cpp.

QString Session::hostName ( ) const

Returns the host name that has been provided in the Session's constructor.

See also
port()

Definition at line 147 of file session.cpp.

void Session::open ( )

Opens the connection to the server.

You should connect to stateChanged() before calling this method, and wait until the session's state is NotAuthenticated (Session is ready for a LoginJob) or Disconnected (connecting to the server failed)

See also
openAndWait()

Definition at line 207 of file session.cpp.

void Session::openAndWait ( )

Opens the connection to the server and blocks the execution until the Session is in the NotAuthenticated state (ready for a LoginJob) or Disconnected (connecting to the server failed)

See also
open()

Definition at line 213 of file session.cpp.

quint16 Session::port ( ) const

Returns the port number that has been provided in the Session's constructor.

See also
hostName()

Definition at line 152 of file session.cpp.

void Session::quit ( )

Requests the server to quit the connection.

This sends a "QUIT" command to the server and will not close the connection until it receives a response. That means you should not delete this object right after calling close, instead wait for stateChanged() to change to Disconnected, or use quitAndWait().

See RFC 821, Chapter 4.1.1, "QUIT".

See also
quitAndWait()

Definition at line 222 of file session.cpp.

void Session::quitAndWait ( )

Requests the server to quit the connection and blocks the execution until the server replies and closes the connection.

See RFC 821, Chapter 4.1.1, "QUIT".

See also
quit()

Definition at line 232 of file session.cpp.

void Session::setCustomHostname ( const QString hostname)

Custom hostname to send in EHLO/HELO command.

Definition at line 197 of file session.cpp.

void Session::setUseNetworkProxy ( bool  useProxy)

Sets whether the SMTP network connection should use the system proxy settings.

The default is to not use the proxy.

Definition at line 132 of file session.cpp.

int Session::sizeLimit ( ) const

Returns the maximum message size in bytes that the server accepts.

You can use SendJob::size() to get the size of the message that you are trying to send

See also
KSmtp::SendJob::size()

Definition at line 172 of file session.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Aug 7 2020 23:07:20 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.