5#ifndef QXMPPOUTGOINGCLIENT_P_H
6#define QXMPPOUTGOINGCLIENT_P_H
8#include "QXmppOutgoingClient.h"
9#include "QXmppPromise.h"
10#include "QXmppSaslManager_p.h"
11#include "QXmppSasl_p.h"
12#include "QXmppStreamManagement_p.h"
14#include "StreamError.h"
15#include "XmppSocket.h"
24using namespace QXmpp::Private;
26namespace QXmpp::Private {
28using LegacyError = std::variant<QAbstractSocket::SocketError, QXmpp::TimeoutError, QXmppStanza::Error::Condition>;
34 static constexpr QStringView TaskName = u
"STARTTLS";
36 HandleElementResult handleElement(
const QDomElement &el);
56 using Result = std::variant<BoundAddress, QXmppStanza::Error, ProtocolError>;
57 static constexpr QStringView TaskName = u
"resource binding";
59 explicit BindManager(SendDataInterface *socket) : m_socket(socket) { }
62 HandleElementResult handleElement(
const QDomElement &el);
65 SendDataInterface *m_socket;
67 std::optional<QXmppPromise<Result>> m_promise;
70struct NonSaslAuthOptions {
76class NonSaslAuthManager
79 using OptionsResult = std::variant<NonSaslAuthOptions, QXmppError>;
80 using AuthResult = std::variant<Success, QXmppError>;
81 static constexpr QStringView TaskName = u
"Non-SASL authentication";
83 explicit NonSaslAuthManager(SendDataInterface *socket) : m_socket(socket) { }
86 QXmppTask<AuthResult> authenticate(
bool plainText,
const QString &username,
const QString &password,
const QString &resource,
const QString &streamId);
87 HandleElementResult handleElement(
const QDomElement &el);
100 SendDataInterface *m_socket;
101 std::variant<NoQuery, OptionsQuery, AuthQuery> m_query;
108 explicit PingManager(QXmppOutgoingClient *q);
110 void onDataReceived();
115 QXmppOutgoingClient *q;
117 QTimer *timeoutTimer;
120using IqResult = QXmppOutgoingClient::IqResult;
126 explicit IqState(QString jid) : jid(std::move(jid)) { }
127 IqState(IqState &&) =
default;
128 IqState &operator=(IqState &&) =
default;
129 IqState(
const IqState &) =
delete;
130 IqState &operator=(
const IqState &) =
delete;
134class OutgoingIqManager
137 OutgoingIqManager(
QXmppLoggable *l, StreamAckManager &streamAckMananger);
138 ~OutgoingIqManager();
143 bool hasId(
const QString &
id)
const;
144 bool isIdValid(
const QString &
id)
const;
147 void finish(
const QString &
id, IqResult &&result);
150 void onSessionOpened(
const SessionBegin &);
151 void onSessionClosed(
const SessionEnd &);
152 bool handleStanza(
const QDomElement &stanza);
155 void warning(
const QString &message);
158 StreamAckManager &m_streamAckManager;
159 std::unordered_map<QString, IqState> m_requests;
164class QXmppOutgoingClientPrivate
169 QXmppOutgoingClient::ConnectionError details;
170 LegacyError legacyError;
173 explicit QXmppOutgoingClientPrivate(QXmppOutgoingClient *q);
174 void connectToHost(
const ServerAddress &);
175 void connectToAddressList(std::vector<ServerAddress> &&);
176 void connectToNextAddress();
181 std::optional<Error> error;
185 StreamAckManager streamAckManager;
186 OutgoingIqManager iqManager;
189 std::vector<ServerAddress> serverAddresses;
190 std::size_t nextServerAddressIndex = 0;
194 } nextAddressState = Current;
199 std::optional<StreamErrorElement::SeeOtherHost> redirect;
202 bool isAuthenticated =
false;
203 bool bindModeAvailable =
false;
204 bool sessionStarted =
false;
205 AuthenticationMethod authenticationMethod = AuthenticationMethod::Sasl;
206 std::optional<Bind2Bound> bind2Bound;
208 std::variant<QXmppOutgoingClient *, StarttlsManager, NonSaslAuthManager, SaslManager, Sasl2Manager, C2sStreamManager *, BindManager> listener;
209 FastTokenManager fastTokenManager;
210 C2sStreamManager c2sStreamManager;
211 CarbonManager carbonManager;
212 CsiManager csiManager;
213 PingManager pingManager;
215 template<
typename T,
typename... Args>
216 T &setListener(Args... args)
218 listener = T { args... };
219 return std::get<T>(listener);
223 QXmppOutgoingClient *q;
The QXmppConfiguration class holds configuration options.
Definition QXmppConfiguration.h:37
The QXmppIq class is the base class for all IQs.
Definition QXmppIq.h:23
The QXmppLoggable class represents a source of logging messages.
Definition QXmppLogger.h:109
Create and update QXmppTask objects to communicate results of asynchronous operations.
Definition QXmppTask.h:81
Definition QXmppTask.h:330
std::variant< T, QXmppError > Result
Definition QXmppGlobal.h:209