~ubuntu-branches/ubuntu/trusty/kvirc/trusty

« back to all changes in this revision

Viewing changes to src/modules/dcc/send.h

  • Committer: Bazaar Package Importer
  • Author(s): Kai Wasserbäch, Kai Wasserbäch, Raúl Sánchez Siles
  • Date: 2011-02-12 10:40:21 UTC
  • mfrom: (14.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20110212104021-5mh4f75jlku20mnt
The combined "Twisted Experiment" and "Nocturnal Raid" release.

[ Kai Wasserbäch ]
* Synced to upstream's SVN revision 5467.
* debian/rules:
  - Added .PHONY line.
  - Resurrect -DMANUAL_REVISION, got lost somewhere and we build SVN
    revisions again.
  - Replace "-DWITH_NO_EMBEDDED_CODE=YES" with "-DWANT_CRYPTOPP=YES".
  - Change the remaining -DWITH/-DWITHOUT to the new -DWANT syntax.
* debian/control:
  - Removed DMUA, I'm a DD now.
  - Changed my e-mail address.
  - Removed unneeded relationships (no upgrades over two releases are
    supported).
  - Fix Suggests for kvirc-dbg.
  - kvirc-data: Make the "Suggests: kvirc" a Recommends, doesn't make much
    sense to install the -data package without the program.
* debian/source/local-options: Added with "unapply-patches".
* debian/kvirc.lintian-overrides: Updated to work for 4.1.1.
* debian/patches/21_make_shared-mime-info_B-D_superfluous.patch: Updated.
* debian/kvirc-data.install: Added .notifyrc.

[ Raúl Sánchez Siles ]
* Stating the right version where kvirc-data break and replace should happen.
* Fixing link to license file.
* Added French and Portuguese man pages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef _SEND_H_
2
 
#define _SEND_H_
3
 
//=============================================================================
4
 
//
5
 
//   File : send.h
6
 
//   Creation date : Tue Sep 24 09 2000 15:06:12 by Szymon Stefanek
7
 
//
8
 
//   This file is part of the KVirc irc client distribution
9
 
//   Copyright (C) 2000-2008 Szymon Stefanek (pragma at kvirc dot net)
10
 
//
11
 
//   This program is FREE software. You can redistribute it and/or
12
 
//   modify it under the terms of the GNU General Public License
13
 
//   as published by the Free Software Foundation; either version 2
14
 
//   of the License, or (at your opinion) any later version.
15
 
//
16
 
//   This program is distributed in the HOPE that it will be USEFUL,
17
 
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19
 
//   See the GNU General Public License for more details.
20
 
//
21
 
//   You should have received a copy of the GNU General Public License
22
 
//   along with this program. If not, write to the Free Software Foundation,
23
 
//   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24
 
//
25
 
//=============================================================================
26
 
 
27
 
#include "descriptor.h"
28
 
#include "window.h"
29
 
#include "thread.h"
30
 
 
31
 
#include "kvi_window.h"
32
 
#include "kvi_string.h"
33
 
#include "kvi_sockettype.h"
34
 
#include "kvi_pointerlist.h"
35
 
#include "kvi_filetransfer.h"
36
 
#include "kvi_time.h"
37
 
#include "kvi_tal_popupmenu.h"
38
 
#include "kvi_tal_hbox.h"
39
 
#include "kvi_tal_vbox.h"
40
 
 
41
 
#include <QLabel>
42
 
#include <QProgressBar>
43
 
#include <QFile>
44
 
#include <QDialog>
45
 
#include <QCheckBox>
46
 
 
47
 
class QSpinBox;
48
 
class QTimer;
49
 
class QPainter;
50
 
class KviDccFileTransfer;
51
 
class KviDccMarshal;
52
 
class KviTalPopupMenu;
53
 
 
54
 
typedef struct _KviDccSendThreadOptions
55
 
{
56
 
        KviStr       szFileName;
57
 
        quint64      uStartPosition;
58
 
        int          iPacketSize;
59
 
        int          iIdleStepLengthInMSec;
60
 
        bool         bFastSend;
61
 
        bool         bNoAcks;
62
 
        bool         bIsTdcc;
63
 
        unsigned int uMaxBandwidth;
64
 
} KviDccSendThreadOptions;
65
 
 
66
 
 
67
 
class KviDccSendThread : public KviDccThread
68
 
{
69
 
public:
70
 
        KviDccSendThread(QObject * par,kvi_socket_t fd,KviDccSendThreadOptions * opt);
71
 
        ~KviDccSendThread();
72
 
private:
73
 
        // stats: SHARED!!!
74
 
        uint           m_uAverageSpeed;
75
 
        uint           m_uInstantSpeed;
76
 
        quint64        m_uFilePosition;
77
 
        quint64        m_uAckedBytes;
78
 
        quint64        m_uTotalSentBytes;
79
 
        // internal
80
 
        unsigned long  m_uStartTime;
81
 
        unsigned long  m_uInstantSpeedInterval;
82
 
        quint64        m_uInstantSentBytes;
83
 
        KviDccSendThreadOptions * m_pOpt;
84
 
        KviMSecTimeInterval * m_pTimeInterval;             // used for computing the instant bandwidth but not only
85
 
public:
86
 
        void initGetInfo();
87
 
        uint averageSpeed(){ return m_uAverageSpeed; };
88
 
        uint instantSpeed(){ return m_uInstantSpeed; };
89
 
        quint64 filePosition(){ return m_uFilePosition; };
90
 
        // sent ONLY in this session
91
 
        quint64 sentBytes(){ return m_uTotalSentBytes; };
92
 
        quint64 ackedBytes(){ return m_uAckedBytes; };
93
 
        unsigned int bandwidthLimit(){ return m_pOpt->uMaxBandwidth; };
94
 
        void setBandwidthLimit(unsigned int uMaxBandwidth){ m_pOpt->uMaxBandwidth = uMaxBandwidth; };
95
 
        void doneGetInfo();
96
 
protected:
97
 
        void updateStats();
98
 
        virtual void run();
99
 
};
100
 
 
101
 
typedef struct _KviDccRecvThreadOptions
102
 
{
103
 
        bool         bResume;
104
 
        KviStr       szFileName;
105
 
        quint64      uTotalFileSize;
106
 
        int          iIdleStepLengthInMSec;
107
 
        bool         bSendZeroAck;
108
 
        bool         bNoAcks;
109
 
        bool         bIsTdcc;
110
 
        unsigned int uMaxBandwidth;
111
 
} KviDccRecvThreadOptions;
112
 
 
113
 
class KviDccRecvThread : public KviDccThread
114
 
{
115
 
public:
116
 
        KviDccRecvThread(QObject * par,kvi_socket_t fd,KviDccRecvThreadOptions * opt);
117
 
        ~KviDccRecvThread();
118
 
protected:
119
 
        KviDccRecvThreadOptions * m_pOpt;
120
 
 
121
 
        // stats: SHARED!
122
 
        uint                  m_uAverageSpeed;
123
 
        uint                  m_uInstantSpeed;
124
 
        quint64               m_uFilePosition;
125
 
        quint64               m_uTotalReceivedBytes;
126
 
 
127
 
        // internal
128
 
        unsigned long         m_uStartTime;
129
 
        KviMSecTimeInterval * m_pTimeInterval;             // used for computing the instant bandwidth
130
 
        quint64              m_uInstantReceivedBytes;
131
 
        quint64               m_uInstantSpeedInterval;
132
 
        QFile               * m_pFile;
133
 
public:
134
 
        void initGetInfo();
135
 
        uint averageSpeed(){ return m_uAverageSpeed; };
136
 
        uint instantSpeed(){ return m_uInstantSpeed; };
137
 
        quint64 filePosition(){ return m_uFilePosition; };
138
 
        // received ONLY in this session
139
 
        quint64 receivedBytes(){ return m_uTotalReceivedBytes; };
140
 
        unsigned int bandwidthLimit(){ return m_pOpt->uMaxBandwidth; };
141
 
        void setBandwidthLimit(unsigned int uMaxBandwidth){ m_pOpt->uMaxBandwidth = uMaxBandwidth; };
142
 
        void doneGetInfo();
143
 
protected:
144
 
        void postMessageEvent(const char * msg);
145
 
        void updateStats();
146
 
        bool sendAck(int filePos);
147
 
        virtual void run();
148
 
};
149
 
 
150
 
 
151
 
class KviDccFileTransferBandwidthDialog : public QDialog
152
 
{
153
 
        Q_OBJECT
154
 
public:
155
 
        KviDccFileTransferBandwidthDialog(QWidget * pParent,KviDccFileTransfer * t);
156
 
        ~KviDccFileTransferBandwidthDialog();
157
 
protected:
158
 
        KviDccFileTransfer * m_pTransfer;
159
 
        QCheckBox * m_pEnableLimitCheck;
160
 
        QSpinBox * m_pLimitBox;
161
 
protected:
162
 
        virtual void closeEvent(QCloseEvent *e);
163
 
protected slots:
164
 
        void okClicked();
165
 
        void cancelClicked();
166
 
};
167
 
 
168
 
 
169
 
class KviDccFileTransfer : public KviFileTransfer, public KviDccMarshalOutputContext
170
 
{
171
 
        enum GeneralStatus { Connecting , Transferring , Success , Failure };
172
 
        Q_OBJECT
173
 
public:
174
 
        KviDccFileTransfer(KviDccDescriptor * dcc);
175
 
        ~KviDccFileTransfer();
176
 
private:
177
 
        KviDccSendThread       * m_pSlaveSendThread;
178
 
        KviDccRecvThread       * m_pSlaveRecvThread;
179
 
        KviDccDescriptor       * m_pDescriptor;
180
 
        KviDccMarshal          * m_pMarshal;
181
 
 
182
 
        KviStr                   m_szTarget;
183
 
        KviStr                   m_szDccType;
184
 
        QString                  m_szTransferIdString;
185
 
 
186
 
        QString                  m_szStatusString;
187
 
        GeneralStatus            m_eGeneralStatus;
188
 
 
189
 
        QString                  m_szTransferLog; // html
190
 
 
191
 
        kvi_time_t               m_tTransferStartTime;
192
 
        kvi_time_t               m_tTransferEndTime;
193
 
        // cached stats
194
 
        quint64                  m_uTotalFileSize; // total file size to transfer
195
 
 
196
 
        unsigned int             m_uMaxBandwidth;
197
 
        KviDccFileTransferBandwidthDialog * m_pBandwidthDialog;
198
 
 
199
 
        QTimer                 * m_pResumeTimer; // used to signal resume timeout
200
 
public:
201
 
        bool resumeAccepted(const char * filename,const char * port,const char *szZeroPortTag);
202
 
        bool doResume(const char * filename,const char * port,quint64 filePos);
203
 
 
204
 
        static void init();
205
 
        static void done();
206
 
        static unsigned int runningTransfersCount();
207
 
        static KviDccFileTransfer * nonFailedTransferWithLocalFileName(const QString &szLocalFileName);
208
 
        static unsigned int transferCount();
209
 
        static bool handleResumeAccepted(const char * filename,const char * port,const char * szZeroPortTag);
210
 
        static bool handleResumeRequest(const char * filename,const char * port,quint64 filePos);
211
 
 
212
 
        virtual bool event(QEvent *e);
213
 
 
214
 
        virtual KviWindow * dccMarshalOutputWindow();
215
 
        virtual const char * dccMarshalOutputContextString();
216
 
 
217
 
        virtual void displayPaint(QPainter * p,int column, QRect rect);
218
 
        virtual int displayHeight(int iLineSpacing);
219
 
        virtual void fillContextPopup(KviTalPopupMenu * m);
220
 
        virtual void fillStatusString(QString &szBuffer);
221
 
        virtual bool active();
222
 
        virtual QString tipText();
223
 
        virtual QString localFileName();
224
 
 
225
 
        bool isFileUpload(){ return m_pDescriptor->isFileUpload(); };
226
 
 
227
 
        unsigned int averageSpeed();
228
 
        unsigned int transferredBytes();
229
 
 
230
 
        int bandwidthLimit();
231
 
        void setBandwidthLimit(int iVal);
232
 
protected:
233
 
        void startConnection();
234
 
        void listenOrConnect();
235
 
        void addToTransferLog(const QString &s);
236
 
        void outputAndLog(const QString &s);
237
 
        void outputAndLog(int msgtype,const QString &s);
238
 
        KviWindow * eventWindow();
239
 
protected slots:
240
 
        void connectionInProgress();
241
 
        void sslError(const char * msg);
242
 
        void startingSSLHandshake();
243
 
        void handleMarshalError(int err);
244
 
        void connected();
245
 
        void bandwidthDialogDestroyed();
246
 
        void configureBandwidth();
247
 
        void resumeTimedOut();
248
 
public slots:
249
 
        void abort();
250
 
        void retryDCC();
251
 
        void retryTDCC();
252
 
        void retryRevDCC();
253
 
};
254
 
 
255
 
#endif //_SEND_H_