2
* ibb.h - Inband bytestream
3
* Copyright (C) 2001, 2002 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
28
#include "bytestream.h"
36
// this is an IBB connection. use it much like a qsocket
37
class IBBConnection : public ByteStream
41
enum { ErrRequest, ErrData };
42
enum { Idle, Requesting, WaitingForAccept, Active };
43
IBBConnection(IBBManager *);
46
void connectToJid(const Jid &peer, const QDomElement &comment);
52
QString streamid() const;
53
QDomElement comment() const;
56
void write(const QByteArray &);
57
QByteArray read(int bytes=0);
58
int bytesAvailable() const;
59
int bytesToWrite() const;
72
void reset(bool clear=false);
74
friend class IBBManager;
75
void waitForAccept(const Jid &peer, const QString &sid, const QDomElement &comment, const QString &iq_id);
76
void takeIncomingData(const QByteArray &, bool close);
79
typedef QList<IBBConnection*> IBBConnectionList;
80
class IBBManager : public QObject
87
Client *client() const;
89
IBBConnection *takeIncoming();
95
void ibb_incomingRequest(const Jid &from, const QString &id, const QDomElement &);
96
void ibb_incomingData(const Jid &from, const QString &streamid, const QString &id, const QByteArray &data, bool close);
102
QString genKey() const;
104
friend class IBBConnection;
105
IBBConnection *findConnection(const QString &sid, const Jid &peer="") const;
106
QString genUniqueKey() const;
107
void link(IBBConnection *);
108
void unlink(IBBConnection *);
109
void doAccept(IBBConnection *c, const QString &id);
110
void doReject(IBBConnection *c, const QString &id, int, const QString &);
113
class JT_IBB : public Task
117
enum { ModeRequest, ModeSendData };
118
JT_IBB(Task *, bool serve=false);
121
void request(const Jid &, const QDomElement &comment);
122
void sendData(const Jid &, const QString &streamid, const QByteArray &data, bool close);
123
void respondSuccess(const Jid &, const QString &id, const QString &streamid);
124
void respondError(const Jid &, const QString &id, int code, const QString &str);
125
void respondAck(const Jid &to, const QString &id);
128
bool take(const QDomElement &);
130
QString streamid() const;
135
void incomingRequest(const Jid &from, const QString &id, const QDomElement &);
136
void incomingData(const Jid &from, const QString &streamid, const QString &id, const QByteArray &data, bool close);