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 fdeven 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., 51 Franklin Street, Fifth Floor, Boston, MA
20 #ifndef OFTMETATRANSFER_H
21 #define OFTMETATRANSFER_H
23 #include <QtCore/QFile>
24 #include <QtNetwork/QAbstractSocket>
26 #include "oscartypes.h"
30 class OftMetaTransfer
: public QObject
34 /** Receive constructor */
35 OftMetaTransfer( const QByteArray
& cookie
, const QString
& dir
, QTcpSocket
*socket
);
37 /** Send constructor */
38 OftMetaTransfer( const QByteArray
& cookie
, const QStringList
& files
, QTcpSocket
*socket
);
42 void start(); //start sending file
45 void doCancel(); //one of the users is cancelling us
48 void fileIncoming( const QString
& fileName
, unsigned int fileSize
);
49 void fileReceived( const QString
& fileName
, unsigned int bytesSent
);
51 void fileOutgoing( const QString
& fileName
, unsigned int fileSize
);
52 void fileSent( const QString
& fileName
, unsigned int fileSize
);
54 void fileProcessed( unsigned int bytesSent
, unsigned int fileSize
);
56 void transferCompleted();
57 void transferError( int errorCode
, const QString
&error
);
61 void socketError( QAbstractSocket::SocketError
);
64 void emitTransferCompleted();
68 void handelReceiveSetup( const Oscar::OFT
&oft
);
69 void handelReceiveResumeSetup( const Oscar::OFT
&oft
);
71 void handelSendSetup( const Oscar::OFT
&oft
);
72 void handelSendResumeSetup( const Oscar::OFT
&oft
);
73 void handleSendResumeRequest( const Oscar::OFT
&oft
);
74 void handelSendDone( const Oscar::OFT
&oft
);
80 void resume(); //receiver wants to resume partial file
81 void rAgree(); //sender agrees to resume
82 void rAck(); //resume ack
83 void saveData(); //save incoming data to disk
84 void readOft(); //handle incoming oft packet
85 Oscar::DWORD
checksum( int max
= -1 ); //return checksum of our file, up to max bytes
86 //XXX this does put an arbitrary limit on file size
92 QString m_dir
; //directory where we save files
93 QStringList m_files
; //list of files that we want to send
95 QTcpSocket
*m_socket
; //where we actually send file data
96 enum State
{ SetupReceive
, SetupSend
, Receiving
, Sending
, Done
};