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

« back to all changes in this revision

Viewing changes to iris/jabber/filetransfer.h

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2005-01-10 17:41:43 UTC
  • mfrom: (1.2.1 upstream) (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050110174143-ltocv5zapl6blf5d
Tags: 0.9.3-1
* New upstream release
* Cleaned up debian/rules (some things are done by upstream Makefiles now)
* Fixed some lintian warnings:
  - removed executable bit from some .png files
  - moved psi.desktop to /usr/share/applications
* Updated menu files

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * filetransfer.h - File Transfer
 
3
 * Copyright (C) 2004  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 XMPP_FILETRANSFER_H
 
22
#define XMPP_FILETRANSFER_H
 
23
 
 
24
#include"im.h"
 
25
 
 
26
#if QT_VERSION < 0x030200
 
27
typedef long int Q_LLONG;
 
28
#endif
 
29
 
 
30
namespace XMPP
 
31
{
 
32
        class S5BConnection;
 
33
        struct FTRequest;
 
34
 
 
35
        class FileTransfer : public QObject
 
36
        {
 
37
                Q_OBJECT
 
38
        public:
 
39
                enum { ErrReject, ErrNeg, ErrConnect, ErrProxy, ErrStream };
 
40
                enum { Idle, Requesting, Connecting, WaitingForAccept, Active };
 
41
                ~FileTransfer();
 
42
 
 
43
                void setProxy(const Jid &proxy);
 
44
 
 
45
                // send
 
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);
 
51
 
 
52
                // receive
 
53
                Jid peer() const;
 
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);
 
59
 
 
60
                // both
 
61
                void close(); // reject, or stop sending/receiving
 
62
                S5BConnection *s5bConnection() const; // active link
 
63
 
 
64
        signals:
 
65
                void accepted(); // indicates S5BConnection has started
 
66
                void connected();
 
67
                void readyRead(const QByteArray &a);
 
68
                void bytesWritten(int);
 
69
                void error(int);
 
70
 
 
71
        private slots:
 
72
                void ft_finished();
 
73
                void s5b_connected();
 
74
                void s5b_connectionClosed();
 
75
                void s5b_readyRead();
 
76
                void s5b_bytesWritten(int);
 
77
                void s5b_error(int);
 
78
                void doAccept();
 
79
 
 
80
        private:
 
81
                class Private;
 
82
                Private *d;
 
83
 
 
84
                void reset();
 
85
 
 
86
                friend class FileTransferManager;
 
87
                FileTransfer(FileTransferManager *, QObject *parent=0);
 
88
                void man_waitForAccept(const FTRequest &req);
 
89
                void takeConnection(S5BConnection *c);
 
90
        };
 
91
 
 
92
        class FileTransferManager : public QObject
 
93
        {
 
94
                Q_OBJECT
 
95
        public:
 
96
                FileTransferManager(Client *);
 
97
                ~FileTransferManager();
 
98
 
 
99
                Client *client() const;
 
100
                FileTransfer *createTransfer();
 
101
                FileTransfer *takeIncoming();
 
102
 
 
103
        signals:
 
104
                void incomingReady();
 
105
 
 
106
        private slots:
 
107
                void pft_incoming(const FTRequest &req);
 
108
 
 
109
        private:
 
110
                class Private;
 
111
                Private *d;
 
112
 
 
113
                friend class Client;
 
114
                void s5b_incomingReady(S5BConnection *);
 
115
 
 
116
                friend class FileTransfer;
 
117
                QString link(FileTransfer *);
 
118
                void con_accept(FileTransfer *);
 
119
                void con_reject(FileTransfer *);
 
120
                void unlink(FileTransfer *);
 
121
        };
 
122
 
 
123
        class JT_FT : public Task
 
124
        {
 
125
                Q_OBJECT
 
126
        public:
 
127
                JT_FT(Task *parent);
 
128
                ~JT_FT();
 
129
 
 
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;
 
134
 
 
135
                void onGo();
 
136
                bool take(const QDomElement &);
 
137
 
 
138
        private:
 
139
                class Private;
 
140
                Private *d;
 
141
        };
 
142
 
 
143
        struct FTRequest
 
144
        {
 
145
                Jid from;
 
146
                QString iq_id, id;
 
147
                QString fname;
 
148
                Q_LLONG size;
 
149
                QString desc;
 
150
                bool rangeSupported;
 
151
                QStringList streamTypes;
 
152
        };
 
153
        class JT_PushFT : public Task
 
154
        {
 
155
                Q_OBJECT
 
156
        public:
 
157
                JT_PushFT(Task *parent);
 
158
                ~JT_PushFT();
 
159
 
 
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);
 
162
 
 
163
                bool take(const QDomElement &);
 
164
 
 
165
        signals:
 
166
                void incoming(const FTRequest &req);
 
167
        };
 
168
}
 
169
 
 
170
#endif