fileTransfer.h

Idź do dokumentacji tego pliku.
00001 #ifndef FILETRANSFER_H
00002 #define FILETRANSFER_H
00003 #include <QtNetwork>
00004 #include <QFile>
00005 #include <QThread>
00006 
00011 class SendFileThread : public QThread
00012 {
00013 Q_OBJECT
00014 
00015 public:
00016 
00024         SendFileThread (QObject *parent, const QString &path, const QHostAddress &ip, quint16 port);
00025 
00029         void cancelTransfer ();
00030 
00031 protected:
00032 
00036         void run ();
00037 
00038 private:
00039         QString path;   
00040         QHostAddress ip;        
00041         quint16 port;           
00042         bool cancel_transfer;   
00044 signals:
00045 
00051         void transferEnd (bool ok);
00052 
00058         void transferProgres (int perc);
00059 };
00060 
00061 
00067 class FileTransfer : public QObject
00068 {
00069 Q_OBJECT
00070 
00071 public:
00072 
00076         FileTransfer();
00077 
00081         ~FileTransfer();
00082 
00090         void sendFile (const QHostAddress &ip, quint16 port, const QString &path);
00091 
00101         void receiveFile (const QHostAddress &ip, quint16 port, const QString &path, qint64 file_size);
00102 
00107          QHostAddress getIp();
00108 
00113         void cancelTransfer();
00114 
00115 signals:
00116 
00122     void posOfProgresBarChanged(int perc);
00123 
00129         void transferEnd (bool ok);
00130 
00131 private:
00132         QHostAddress ip;                
00133         QTcpServer receive_file_server; 
00134         QTcpSocket *receive_file_socket;        
00135         SendFileThread *send_file_thread;       
00136         qint64 file_size;               
00137         qint64 transfer_bytes;  
00138         QFile   *out_file;      
00140 private slots:
00141 
00147         void receiveSocketError(QAbstractSocket::SocketError err);
00148 
00153         void receiveFile ();
00154 
00159         void newConnection();
00160 
00166         void threadTransferProgres (int perc);
00167 
00173         void threadTransferEnd (bool ok);
00174 };
00175 #endif

Wygenerowano Sun Jun 11 12:55:08 2006 dla lanChat programem  doxygen 1.4.6