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 <QtCore/QTimer>
25 #include <QtNetwork/QAbstractSocket>
27 #include "oscartypes.h"
31 class OftMetaTransfer
: public QObject
35 /** Receive constructor */
36 OftMetaTransfer( const QByteArray
& cookie
, const QString
& dir
, QTcpSocket
*socket
);
38 /** Send constructor */
39 OftMetaTransfer( const QByteArray
& cookie
, const QStringList
& files
, QTcpSocket
*socket
);
43 void start(); //start sending file
46 void doCancel(); //one of the users is cancelling us
49 void fileIncoming( const QString
& fileName
, unsigned int fileSize
);
50 void fileReceived( const QString
& fileName
, unsigned int bytesSent
);
52 void fileOutgoing( const QString
& fileName
, unsigned int fileSize
);
53 void fileSent( const QString
& fileName
, unsigned int fileSize
);
55 void fileProcessed( unsigned int bytesSent
, unsigned int fileSize
);
57 void transferCompleted();
58 void transferError( int errorCode
, const QString
&error
);
62 void socketError( QAbstractSocket::SocketError
);
69 void handelReceiveSetup( const Oscar::OFT
&oft
);
70 void handelReceiveResumeSetup( const Oscar::OFT
&oft
);
72 void handelSendSetup( const Oscar::OFT
&oft
);
73 void handelSendResumeSetup( const Oscar::OFT
&oft
);
74 void handleSendResumeRequest( const Oscar::OFT
&oft
);
75 void handelSendDone( const Oscar::OFT
&oft
);
81 void resume(); //receiver wants to resume partial file
82 void rAgree(); //sender agrees to resume
83 void rAck(); //resume ack
84 void saveData(); //save incoming data to disk
85 void readOft(); //handle incoming oft packet
86 Oscar::DWORD
checksum( int max
= -1 ); //return checksum of our file, up to max bytes
87 //XXX this does put an arbitrary limit on file size
93 QString m_dir
; //directory where we save files
94 QStringList m_files
; //list of files that we want to send
96 QTcpSocket
*m_socket
; //where we actually send file data
97 QTimer m_timer
; //if we're idle too long, then give up
98 enum State
{ SetupReceive
, SetupSend
, Receiving
, Sending
, Done
};