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