2
* xmpp.h - XMPP "core" library API
3
* Copyright (C) 2003 Justin Karneges
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Lesser General Public
7
* License as published by the Free Software Foundation; either
8
* version 2.1 of the License, or (at your option) any later version.
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
* Lesser General Public License for more details.
15
* You should have received a copy of the GNU Lesser General Public
16
* License along with this library; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27
#include <qhostaddress.h>
32
#include "xmpp/jid/jid.h"
33
#include "xmpp_stanza.h"
34
#include "xmpp_stream.h"
35
#include "xmpp_clientstream.h"
46
#include <QtCrypto> // For QCA::SASL::Params
50
// CS_IMPORT_BEGIN cutestuff/bytestream.h
61
virtual void msg(const QString &)=0;
62
virtual void outgoingTag(const QString &)=0;
63
virtual void incomingTag(const QString &)=0;
64
virtual void outgoingXml(const QDomElement &)=0;
65
virtual void incomingXml(const QDomElement &)=0;
68
void setDebug(Debug *);
70
class Connector : public QObject
74
Connector(QObject *parent=0);
77
virtual void connectToServer(const QString &server)=0;
78
virtual ByteStream *stream() const=0;
79
virtual void done()=0;
82
bool havePeerAddress() const;
83
QHostAddress peerAddress() const;
84
quint16 peerPort() const;
86
virtual QString host() const;
93
void setUseSSL(bool b);
94
void setPeerAddressNone();
95
void setPeerAddress(const QHostAddress &addr, quint16 port);
104
class AdvancedConnector : public Connector
108
enum Error { ErrConnectionRefused, ErrHostNotFound, ErrProxyConnect, ErrProxyNeg, ErrProxyAuth, ErrStream };
109
AdvancedConnector(QObject *parent=0);
110
virtual ~AdvancedConnector();
115
enum { None, HttpConnect, HttpPoll, Socks };
120
QString host() const;
121
quint16 port() const;
123
QString user() const;
124
QString pass() const;
125
int pollInterval() const;
127
void setHttpConnect(const QString &host, quint16 port);
128
void setHttpPoll(const QString &host, quint16 port, const QString &url);
129
void setSocks(const QString &host, quint16 port);
130
void setUserPass(const QString &user, const QString &pass);
131
void setPollInterval(int secs);
135
QString v_host, v_url;
137
QString v_user, v_pass;
141
void setProxy(const Proxy &proxy);
142
void setOptHostPort(const QString &host, quint16 port);
143
void setOptHostsPort(const QStringList &hosts, quint16 port);
144
void setOptProbe(bool);
145
void setOptSSL(bool);
147
void changePollInterval(int secs);
149
void connectToServer(const QString &server);
150
ByteStream *stream() const;
153
int errorCode() const;
155
virtual QString host() const;
158
void srvLookup(const QString &server);
159
void srvResult(bool success);
160
void httpSyncStarted();
161
void httpSyncFinished();
168
void http_syncStarted();
169
void http_syncFinished();
182
class TLSHandler : public QObject
186
TLSHandler(QObject *parent=0);
187
virtual ~TLSHandler();
189
virtual void reset()=0;
190
virtual void startClient(const QString &host)=0;
191
virtual void write(const QByteArray &a)=0;
192
virtual void writeIncoming(const QByteArray &a)=0;
198
void readyRead(const QByteArray &a);
199
void readyReadOutgoing(const QByteArray &a, int plainBytes);
202
class QCATLSHandler : public TLSHandler
206
QCATLSHandler(QCA::TLS *parent);
209
QCA::TLS *tls() const;
210
int tlsError() const;
212
void setXMPPCertCheck(bool enable);
213
bool XMPPCertCheck();
214
bool certMatchesHostname();
217
void startClient(const QString &host);
218
void write(const QByteArray &a);
219
void writeIncoming(const QByteArray &a);
222
void tlsHandshaken();
225
void continueAfterHandshake();
228
void tls_handshaken();
229
void tls_readyRead();
230
void tls_readyReadOutgoing();