MailTransport

socket.h
1/*
2 SPDX-FileCopyrightText: 2006-2007 KovoKs <info@kovoks.nl>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "mailtransport_export.h"
10
11#include <QSslSocket>
12
13#include <memory>
14
15namespace MailTransport
16{
17class SocketPrivate;
18
19/**
20 * @class Socket
21 * Responsible for communicating with the server, it's designed to work
22 * with the ServerTest class.
23 * @author Tom Albers <tomalbers@kde.nl>
24 */
25class Socket : public QObject
26{
28
29public:
30 /**
31 * Constructor, it will not auto connect. Call reconnect() to connect to
32 * the parameters given.
33 * @param parent the parent
34 */
35 explicit Socket(QObject *parent);
36
37 /**
38 * Destructor
39 */
40 ~Socket() override;
41
42 /**
43 * Existing connection will be closed and a new connection will be
44 * made
45 */
46 virtual void reconnect();
47
48 /**
49 * Write @p text to the socket
50 */
51 virtual void write(const QString &text);
52
53 /**
54 * @return true when the connection is live and kicking
55 */
56 virtual bool available();
57
58 /**
59 * set the protocol to use
60 */
61 void setProtocol(const QString &proto);
62
63 /**
64 * set the server to use
65 */
66 void setServer(const QString &server);
67
68 /**
69 * set the port to use. If not specified, it will use the default
70 * belonging to the protocol.
71 */
72 void setPort(int port);
73
74 /**
75 * returns the used port.
76 */
77 int port() const;
78
79 /**
80 * this will be a secure connection
81 */
82 void setSecure(bool what);
83
84 /**
85 * If you want to start TLS encryption, call this. For example after the starttls command.
86 */
87 void startTLS();
88
89private:
90 Q_DECLARE_PRIVATE(Socket)
91 std::unique_ptr<SocketPrivate> const d;
92
93 Q_PRIVATE_SLOT(d, void slotConnected())
94 Q_PRIVATE_SLOT(d, void slotStateChanged(QAbstractSocket::SocketState state))
95 Q_PRIVATE_SLOT(d, void slotModeChanged(QSslSocket::SslMode state))
96 Q_PRIVATE_SLOT(d, void slotSocketRead())
97 Q_PRIVATE_SLOT(d, void slotSslErrors(const QList<QSslError> &errors))
98
100 /**
101 * emits the incoming data
102 */
103 void data(const QString &);
104
105 /**
106 * emitted when there is a connection (ready to send something).
107 */
108 void connected();
109
110 /**
111 * emitted when not connected.
112 */
113 void failed();
114
115 /**
116 * emitted when startShake() is completed.
117 */
118 void tlsDone();
119};
120} // namespace MailTransport
Responsible for communicating with the server, it's designed to work with the ServerTest class.
Definition socket.h:26
void connected()
emitted when there is a connection (ready to send something).
Socket(QObject *parent)
Constructor, it will not auto connect.
Definition socket.cpp:118
void setServer(const QString &server)
set the server to use
Definition socket.cpp:193
void setPort(int port)
set the port to use.
Definition socket.cpp:198
virtual void reconnect()
Existing connection will be closed and a new connection will be made.
Definition socket.cpp:130
void failed()
emitted when not connected.
int port() const
returns the used port.
Definition socket.cpp:203
void data(const QString &)
emits the incoming data
virtual bool available()
Definition socket.cpp:174
void setSecure(bool what)
this will be a secure connection
Definition socket.cpp:208
void setProtocol(const QString &proto)
set the protocol to use
Definition socket.cpp:188
virtual void write(const QString &text)
Write text to the socket.
Definition socket.cpp:156
~Socket() override
Destructor.
Definition socket.cpp:125
void tlsDone()
emitted when startShake() is completed.
void startTLS()
If you want to start TLS encryption, call this.
Definition socket.cpp:181
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:35:38 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.