2
* filetransfer.h - File Transfer
3
* Copyright (C) 2004 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
21
#ifndef XMPP_FILETRANSFER_H
22
#define XMPP_FILETRANSFER_H
26
#if QT_VERSION < 0x030200
27
typedef long int Q_LLONG;
35
class FileTransfer : public QObject
39
enum { ErrReject, ErrNeg, ErrConnect, ErrProxy, ErrStream };
40
enum { Idle, Requesting, Connecting, WaitingForAccept, Active };
43
void setProxy(const Jid &proxy);
46
void sendFile(const Jid &to, const QString &fname, Q_LLONG size, const QString &desc);
47
Q_LLONG offset() const;
48
Q_LLONG length() const;
49
int dataSizeNeeded() const;
50
void writeFileData(const QByteArray &a);
54
QString fileName() const;
55
Q_LLONG fileSize() const;
56
QString description() const;
57
bool rangeSupported() const;
58
void accept(Q_LLONG offset=0, Q_LLONG length=0);
61
void close(); // reject, or stop sending/receiving
62
S5BConnection *s5bConnection() const; // active link
65
void accepted(); // indicates S5BConnection has started
67
void readyRead(const QByteArray &a);
68
void bytesWritten(int);
74
void s5b_connectionClosed();
76
void s5b_bytesWritten(int);
86
friend class FileTransferManager;
87
FileTransfer(FileTransferManager *, QObject *parent=0);
88
void man_waitForAccept(const FTRequest &req);
89
void takeConnection(S5BConnection *c);
92
class FileTransferManager : public QObject
96
FileTransferManager(Client *);
97
~FileTransferManager();
99
Client *client() const;
100
FileTransfer *createTransfer();
101
FileTransfer *takeIncoming();
104
void incomingReady();
107
void pft_incoming(const FTRequest &req);
114
void s5b_incomingReady(S5BConnection *);
116
friend class FileTransfer;
117
QString link(FileTransfer *);
118
void con_accept(FileTransfer *);
119
void con_reject(FileTransfer *);
120
void unlink(FileTransfer *);
123
class JT_FT : public Task
130
void request(const Jid &to, const QString &id, const QString &fname, Q_LLONG size, const QString &desc, const QStringList &streamTypes);
131
Q_LLONG rangeOffset() const;
132
Q_LLONG rangeLength() const;
133
QString streamType() const;
136
bool take(const QDomElement &);
151
QStringList streamTypes;
153
class JT_PushFT : public Task
157
JT_PushFT(Task *parent);
160
void respondSuccess(const Jid &to, const QString &id, Q_LLONG rangeOffset, Q_LLONG rangeLength, const QString &streamType);
161
void respondError(const Jid &to, const QString &id, int code, const QString &str);
163
bool take(const QDomElement &);
166
void incoming(const FTRequest &req);