1 /*
2  * bytestream_manager.h - base class for bytestreams over xmpp
3  * Copyright (C) 2003  Justin Karneges, Rion
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  */
20 
21 #ifndef BYTESTREAM_MANAGER_H
22 #define BYTESTREAM_MANAGER_H
23 
24 #include <QObject>
25 #include "xmpp/jid/jid.h"
26 #include "bytestream.h"
27 
28 namespace XMPP
29 {
30 	class Client;
31 	class BytestreamManager;
32 
33 	class BSConnection : public ByteStream
34 	{
35 	public:
36 		enum Error { ErrRefused = ErrCustom, ErrConnect, ErrProxy, ErrSocket };
37 		enum State { Idle, Requesting, Connecting, WaitingForAccept, Active };
38 
ByteStream(parent)39 		BSConnection(QObject *parent = 0) : ByteStream(parent) {}
40 
41 		virtual void connectToJid(const Jid &peer, const QString &sid) = 0;
42 		virtual void accept() = 0;
43 
44 		virtual Jid peer() const = 0;
45 		virtual QString sid() const = 0;
46 		virtual BytestreamManager* manager() const = 0;
47 	};
48 
49 	class BytestreamManager : public QObject
50 	{
51 		Q_OBJECT
52 
53 	public:
54 		BytestreamManager(Client *);
55 		virtual ~BytestreamManager();
56 
57 		virtual bool isAcceptableSID(const Jid &peer, const QString &sid) const = 0;
58 		QString genUniqueSID(const Jid &peer) const;
59 		virtual BSConnection* createConnection() = 0;
60 		virtual void deleteConnection(BSConnection *c, int msec = 0);
61 
62 	protected:
63 		virtual const char* sidPrefix() const = 0;
64 
65 	signals:
66 		void incomingReady();
67 	};
68 }
69 
70 #endif
71