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 QPtrList<IBBConnection> IBBConnectionList;
80
typedef QPtrListIterator<IBBConnection> IBBConnectionListIt;
81
class IBBManager : public QObject
88
Client *client() const;
90
IBBConnection *takeIncoming();
96
void ibb_incomingRequest(const Jid &from, const QString &id, const QDomElement &);
97
void ibb_incomingData(const Jid &from, const QString &streamid, const QString &id, const QByteArray &data, bool close);
103
QString genKey() const;
105
friend class IBBConnection;
106
IBBConnection *findConnection(const QString &sid, const Jid &peer="") const;
107
QString genUniqueKey() const;
108
void link(IBBConnection *);
109
void unlink(IBBConnection *);
110
void doAccept(IBBConnection *c, const QString &id);
111
void doReject(IBBConnection *c, const QString &id, int, const QString &);
114
class JT_IBB : public Task
118
enum { ModeRequest, ModeSendData };
119
JT_IBB(Task *, bool serve=false);
122
void request(const Jid &, const QDomElement &comment);
123
void sendData(const Jid &, const QString &streamid, const QByteArray &data, bool close);
124
void respondSuccess(const Jid &, const QString &id, const QString &streamid);
125
void respondError(const Jid &, const QString &id, int code, const QString &str);
126
void respondAck(const Jid &to, const QString &id);
129
bool take(const QDomElement &);
131
QString streamid() const;
136
void incomingRequest(const Jid &from, const QString &id, const QDomElement &);
137
void incomingData(const Jid &from, const QString &streamid, const QString &id, const QByteArray &data, bool close);