00001 #ifndef REMOTEFILE_H_
00002 #define REMOTEFILE_H_
00003
00004 #include <qstring.h>
00005 #include <qmutex.h>
00006
00007 #include "mythexp.h"
00008
00009 class MythContext;
00010 class MythSocket;
00011
00012 class MPUBLIC RemoteFile
00013 {
00014 public:
00015 RemoteFile(const QString &url, bool usereadahead = true, int retries = -1);
00016 ~RemoteFile();
00017
00018 bool Open();
00019 void Close(void);
00020
00021 long long Seek(long long pos, int whence, long long curpos = -1);
00022
00023 int Read(void *data, int size);
00024 void Reset(void);
00025
00026 bool SaveAs(QByteArray &data);
00027
00028 void SetTimeout(bool fast);
00029
00030 bool isOpen(void) const
00031 { return sock && controlSock; }
00032 long long GetFileSize(void) const
00033 { return filesize; }
00034
00035 const MythSocket *getSocket(void) const
00036 { return sock; }
00037 MythSocket *getSocket(void)
00038 { return sock; }
00039
00040 private:
00041 MythSocket *openSocket(bool control);
00042
00043 QString path;
00044 bool usereadahead;
00045 int retries;
00046 long long filesize;
00047 bool timeoutisfast;
00048 long long readposition;
00049 int recordernum;
00050
00051 mutable QMutex lock;
00052 MythSocket *controlSock;
00053 MythSocket *sock;
00054 QString query;
00055 };
00056
00057 #endif