00001 #ifndef FILETRANSFER_H_ 00002 #define FILETRANSFER_H_ 00003 00004 // ANSI C headers 00005 #include <stdint.h> 00006 00007 using namespace std; 00008 00009 #include <QMutex> 00010 #include <QString> 00011 #include <QWaitCondition> 00012 00013 #include <vector> 00014 00015 #include "mythsocket.h" 00016 #include "sockethandler.h" 00017 00018 class ProgramInfo; 00019 class RingBuffer; 00020 00021 class FileTransfer : public SocketHandler 00022 { 00023 Q_OBJECT 00024 00025 friend class QObject; // quiet OSX gcc warning 00026 00027 public: 00028 FileTransfer(QString &filename, MythSocket *remote, 00029 MythSocketManager *parent, 00030 bool usereadahead, int timeout_ms); 00031 FileTransfer(QString &filename, MythSocket *remote, 00032 MythSocketManager *parent, bool write); 00033 00034 bool isOpen(void); 00035 00036 void Stop(void); 00037 00038 void Pause(void); 00039 void Unpause(void); 00040 int RequestBlock(int size); 00041 int WriteBlock(int size); 00042 00043 long long Seek(long long curpos, long long pos, int whence); 00044 00045 uint64_t GetFileSize(void); 00046 00047 void SetTimeout(bool fast); 00048 00049 private: 00050 ~FileTransfer(); 00051 00052 volatile bool readthreadlive; 00053 bool readsLocked; 00054 QWaitCondition readsUnlockedCond; 00055 00056 ProgramInfo *pginfo; 00057 RingBuffer *rbuffer; 00058 bool ateof; 00059 00060 vector<char> requestBuffer; 00061 00062 QMutex lock; 00063 00064 bool writemode; 00065 }; 00066 00067 #endif
1.6.3