~ubuntu-branches/ubuntu/quantal/psi/quantal

« back to all changes in this revision

Viewing changes to iris/src/xmpp/xmpp-im/xmpp_ibb.h

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2009-09-25 17:49:51 UTC
  • mfrom: (6.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090925174951-lvm7kdap82o8xhn3
Tags: 0.13-1
* Updated to upstream version 0.13
* Set Standards-Version to 3.8.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * ibb.h - Inband bytestream
 
3
 * Copyright (C) 2001, 2002  Justin Karneges
 
4
 *
 
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.
 
9
 *
 
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.
 
14
 *
 
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
 
18
 *
 
19
 */
 
20
 
 
21
#ifndef JABBER_IBB_H
 
22
#define JABBER_IBB_H
 
23
 
 
24
#include <QList>
 
25
#include <qobject.h>
 
26
#include <qdom.h>
 
27
#include <qstring.h>
 
28
#include "bytestream.h"
 
29
#include "im.h"
 
30
 
 
31
namespace XMPP
 
32
{
 
33
        class Client;
 
34
        class IBBManager;
 
35
 
 
36
        // this is an IBB connection.  use it much like a qsocket
 
37
        class IBBConnection : public ByteStream
 
38
        {
 
39
                Q_OBJECT
 
40
        public:
 
41
                enum { ErrRequest, ErrData };
 
42
                enum { Idle, Requesting, WaitingForAccept, Active };
 
43
                IBBConnection(IBBManager *);
 
44
                ~IBBConnection();
 
45
 
 
46
                void connectToJid(const Jid &peer, const QDomElement &comment);
 
47
                void accept();
 
48
                void close();
 
49
 
 
50
                int state() const;
 
51
                Jid peer() const;
 
52
                QString streamid() const;
 
53
                QDomElement comment() const;
 
54
 
 
55
                bool isOpen() const;
 
56
                void write(const QByteArray &);
 
57
                QByteArray read(int bytes=0);
 
58
                int bytesAvailable() const;
 
59
                int bytesToWrite() const;
 
60
 
 
61
        signals:
 
62
                void connected();
 
63
 
 
64
        private slots:
 
65
                void ibb_finished();
 
66
                void trySend();
 
67
 
 
68
        private:
 
69
                class Private;
 
70
                Private *d;
 
71
 
 
72
                void reset(bool clear=false);
 
73
 
 
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);
 
77
        };
 
78
 
 
79
        typedef QList<IBBConnection*> IBBConnectionList;
 
80
        class IBBManager : public QObject
 
81
        {
 
82
                Q_OBJECT
 
83
        public:
 
84
                IBBManager(Client *);
 
85
                ~IBBManager();
 
86
 
 
87
                Client *client() const;
 
88
 
 
89
                IBBConnection *takeIncoming();
 
90
 
 
91
        signals:
 
92
                void incomingReady();
 
93
 
 
94
        private slots:
 
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);
 
97
 
 
98
        private:
 
99
                class Private;
 
100
                Private *d;
 
101
 
 
102
                QString genKey() const;
 
103
 
 
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 &);
 
111
        };
 
112
 
 
113
        class JT_IBB : public Task
 
114
        {
 
115
                Q_OBJECT
 
116
        public:
 
117
                enum { ModeRequest, ModeSendData };
 
118
                JT_IBB(Task *, bool serve=false);
 
119
                ~JT_IBB();
 
120
 
 
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);
 
126
 
 
127
                void onGo();
 
128
                bool take(const QDomElement &);
 
129
 
 
130
                QString streamid() const;
 
131
                Jid jid() const;
 
132
                int mode() const;
 
133
 
 
134
        signals:
 
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);
 
137
 
 
138
        private:
 
139
                class Private;
 
140
                Private *d;
 
141
        };
 
142
}
 
143
 
 
144
#endif