MythTV  master
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
RemoteFile Class Reference

#include <remotefile.h>

Collaboration diagram for RemoteFile:
Collaboration graph
[legend]

Public Member Functions

 RemoteFile (const QString &url="", bool write=false, bool usereadahead=true, int timeout_ms=2000, const QStringList *possibleAuxiliaryFiles=nullptr)
 
 ~RemoteFile ()
 
bool ReOpen (QString newFilename)
 
long long Seek (long long pos, int whence, long long curpos=-1)
 
QDateTime LastModified (void) const
 
int Write (const void *data, int size)
 
int Read (void *data, int size)
 
void Reset (void)
 
bool SetBlocking (bool block=true)
 Set write blocking mode for the ThreadedFileWriter instance. More...
 
bool SaveAs (QByteArray &data)
 
void SetTimeout (bool fast)
 
bool isOpen (void) const
 
bool isLocal (void) const
 
long long GetFileSize (void) const
 GetFileSize: returns the remote file's size at the time it was first opened Will query the server in order to get the size. More...
 
long long GetRealFileSize (void)
 GetRealFileSize: returns the current remote file's size. More...
 
QStringList GetAuxiliaryFiles (void) const
 

Static Public Member Functions

static bool DeleteFile (const QString &url)
 
static bool Exists (const QString &url, struct stat *fileinfo)
 
static bool Exists (const QString &url)
 
static QString GetFileHash (const QString &url)
 
static QDateTime LastModified (const QString &url)
 
static QString FindFile (const QString &filename, const QString &host, const QString &storageGroup, bool useRegex=false, bool allowFallback=false)
 Search all BE's for a file in the give storage group. More...
 
static QStringList FindFileList (const QString &filename, const QString &host, const QString &storageGroup, bool useRegex=false, bool allowFallback=false)
 Search all BE's for files in the give storage group. More...
 
static bool CopyFile (const QString &src, const QString &dest, bool overwrite=false, bool verify=false)
 
static bool MoveFile (const QString &src, const QString &dest, bool overwrite=false)
 
static bool isLocal (const QString &path)
 

Private Member Functions

bool Open (void)
 
bool OpenInternal (void)
 Attempts to resume from a disconnected step. More...
 
void Close (bool haslock=false)
 
bool CheckConnection (bool repos=true)
 Check current connection and re-establish it if lost. More...
 
bool IsConnected (void)
 Check if both the control and data sockets are currently connected. More...
 
bool Resume (bool repos=true)
 Attempts to resume from a disconnected step. More...
 
long long SeekInternal (long long pos, int whence, long long curpos=-1)
 
MythSocketopenSocket (bool control)
 

Private Attributes

QString path
 
bool usereadahead
 
int timeout_ms
 
long long filesize
 
bool timeoutisfast
 
long long readposition
 
long long lastposition
 
bool canresume
 
int recordernum
 
QMutex lock
 
MythSocketcontrolSock
 
MythSocketsock
 
QString query
 
bool writemode
 
bool completed
 
MythTimer lastSizeCheck
 
QStringList possibleauxfiles
 
QStringList auxfiles
 
int localFile
 
ThreadedFileWriterfileWriter
 

Detailed Description

Definition at line 17 of file remotefile.h.

Constructor & Destructor Documentation

◆ RemoteFile()

RemoteFile::RemoteFile ( const QString &  url = "",
bool  write = false,
bool  usereadahead = true,
int  timeout_ms = 2000,
const QStringList *  possibleAuxiliaryFiles = nullptr 
)

Definition at line 72 of file remotefile.cpp.

◆ ~RemoteFile()

RemoteFile::~RemoteFile ( )

Definition at line 100 of file remotefile.cpp.

Member Function Documentation

◆ ReOpen()

bool RemoteFile::ReOpen ( QString  newFilename)

Definition at line 347 of file remotefile.cpp.

Referenced by FileRingBuffer::ReOpen().

◆ Seek()

long long RemoteFile::Seek ( long long  pos,
int  whence,
long long  curpos = -1 
)

◆ DeleteFile()

bool RemoteFile::DeleteFile ( const QString &  url)
static

◆ Exists() [1/2]

bool RemoteFile::Exists ( const QString &  url,
struct stat *  fileinfo 
)
static

◆ Exists() [2/2]

bool RemoteFile::Exists ( const QString &  url)
static

Definition at line 459 of file remotefile.cpp.

◆ GetFileHash()

QString RemoteFile::GetFileHash ( const QString &  url)
static

Definition at line 560 of file remotefile.cpp.

Referenced by UpdateHashes(), and VideoMetadata::VideoFileHash().

◆ LastModified() [1/2]

QDateTime RemoteFile::LastModified ( const QString &  url)
static

Definition at line 1233 of file remotefile.cpp.

◆ LastModified() [2/2]

QDateTime RemoteFile::LastModified ( void  ) const

Definition at line 1275 of file remotefile.cpp.

Referenced by MythUIHelper::LoadCacheImage().

◆ FindFile()

QString RemoteFile::FindFile ( const QString &  filename,
const QString &  host,
const QString &  storageGroup,
bool  useRegex = false,
bool  allowFallback = false 
)
static

Search all BE's for a file in the give storage group.

Parameters
filenamethe partial path and filename to look for
hostsearch this host first if given or default to the master BE if empty
storageGroupthe name of the storage group to search
useRegexif true filename is assumed to be a regex expression of files to find
allowFallbackif false only 'host' will be searched otherwise all host will be searched until a match is found
Returns
a QString containing the myth URL pointing to the first file found or empty list if not found

Definition at line 1289 of file remotefile.cpp.

Referenced by MusicMetadata::Filename(), MythImage::Load(), and ImportCoverArtDialog::updateStatus().

◆ FindFileList()

QStringList RemoteFile::FindFileList ( const QString &  filename,
const QString &  host,
const QString &  storageGroup,
bool  useRegex = false,
bool  allowFallback = false 
)
static

Search all BE's for files in the give storage group.

Parameters
filenamethe partial path and filename to look for or regex
hostsearch this host first if given or default to the master BE if empty
storageGroupthe name of the storage group to search
useRegexif true filename is assumed to be a regex expression of files to find
allowFallbackif false only 'host' will be searched otherwise all host will be searched until a match is found
Returns
a QStringList list containing the myth URL's pointing to the file or empty list if not found

Definition at line 1310 of file remotefile.cpp.

Referenced by FindFile(), and findIcon().

◆ CopyFile()

bool RemoteFile::CopyFile ( const QString &  src,
const QString &  dest,
bool  overwrite = false,
bool  verify = false 
)
static

◆ MoveFile()

bool RemoteFile::MoveFile ( const QString &  src,
const QString &  dest,
bool  overwrite = false 
)
static

Definition at line 684 of file remotefile.cpp.

Referenced by TransferThread::run().

◆ Write()

int RemoteFile::Write ( const void *  data,
int  size 
)

Definition at line 845 of file remotefile.cpp.

Referenced by CopyFile(), MetadataImageDownload::run(), and RingBuffer::Write().

◆ Read()

int RemoteFile::Read ( void *  data,
int  size 
)

◆ Reset()

void RemoteFile::Reset ( void  )

Definition at line 753 of file remotefile.cpp.

◆ SetBlocking()

bool RemoteFile::SetBlocking ( bool  block = true)

Set write blocking mode for the ThreadedFileWriter instance.

Parameters
blockfalse if not blocking, true if blocking
Returns
old mode value

Definition at line 1394 of file remotefile.cpp.

Referenced by CopyFile(), and OpenInternal().

◆ SaveAs()

bool RemoteFile::SaveAs ( QByteArray &  data)

◆ SetTimeout()

void RemoteFile::SetTimeout ( bool  fast)

Definition at line 1205 of file remotefile.cpp.

◆ isOpen()

bool RemoteFile::isOpen ( void  ) const

◆ isLocal() [1/2]

bool RemoteFile::isLocal ( const QString &  path)
static

Definition at line 115 of file remotefile.cpp.

◆ isLocal() [2/2]

bool RemoteFile::isLocal ( void  ) const

◆ GetFileSize()

long long RemoteFile::GetFileSize ( void  ) const

GetFileSize: returns the remote file's size at the time it was first opened Will query the server in order to get the size.

If file isn't being modified by the server, that value will be cached

Definition at line 1103 of file remotefile.cpp.

Referenced by CheckRecordings(), CopyFile(), RemoteFileWrapper::GetFileSize(), GetFileSize(), GetRealFileSize(), RemoteAVFormatContext::SeekFunc(), and FileRingBuffer::SeekInternal().

◆ GetRealFileSize()

long long RemoteFile::GetRealFileSize ( void  )

GetRealFileSize: returns the current remote file's size.

Will query the server in order to get the size. If file isn't being modified by the server, that value will be cached. A QUERY_SIZE myth request will be made. If the server doesn't support this command the size will be queried using a QUERY_FILE_EXISTS request Avoid using GetRealFileSize from the GUI thread

Definition at line 1131 of file remotefile.cpp.

Referenced by _def_size(), FileRingBuffer::GetRealFileSizeInternal(), and SaveAs().

◆ GetAuxiliaryFiles()

QStringList RemoteFile::GetAuxiliaryFiles ( void  ) const
inline

Definition at line 64 of file remotefile.h.

Referenced by FileRingBuffer::OpenFile().

◆ Open()

bool RemoteFile::Open ( void  )
private

Definition at line 262 of file remotefile.cpp.

Referenced by RemoteFile(), and ReOpen().

◆ OpenInternal()

bool RemoteFile::OpenInternal ( void  )
private

Attempts to resume from a disconnected step.

Must have lock

Returns
True if reconnection succeeded

Definition at line 275 of file remotefile.cpp.

Referenced by Open(), and Resume().

◆ Close()

void RemoteFile::Close ( bool  haslock = false)
private

Definition at line 382 of file remotefile.cpp.

Referenced by CopyFile(), OpenInternal(), ReOpen(), Resume(), and ~RemoteFile().

◆ CheckConnection()

bool RemoteFile::CheckConnection ( bool  repos = true)
private

Check current connection and re-establish it if lost.

Returns
True if connection is working
Parameters
reposBool indicating if we are to reposition to the last known location if reconnection is required

Definition at line 1409 of file remotefile.cpp.

Referenced by GetRealFileSize(), Read(), ReOpen(), SeekInternal(), SetTimeout(), and Write().

◆ IsConnected()

bool RemoteFile::IsConnected ( void  )
private

Check if both the control and data sockets are currently connected.

Returns
True if both sockets are connected

Definition at line 1426 of file remotefile.cpp.

Referenced by CheckConnection().

◆ Resume()

bool RemoteFile::Resume ( bool  repos = true)
private

Attempts to resume from a disconnected step.

Must have lock

Returns
True if reconnection succeeded
Parameters
reposBool indicating if we are to reposition to the last known location

Definition at line 1437 of file remotefile.cpp.

Referenced by CheckConnection(), and Read().

◆ SeekInternal()

long long RemoteFile::SeekInternal ( long long  pos,
int  whence,
long long  curpos = -1 
)
private

Definition at line 773 of file remotefile.cpp.

Referenced by Resume(), and Seek().

◆ openSocket()

MythSocket * RemoteFile::openSocket ( bool  control)
private

Definition at line 128 of file remotefile.cpp.

Referenced by OpenInternal().

Member Data Documentation

◆ path

QString RemoteFile::path
private

◆ usereadahead

bool RemoteFile::usereadahead
private

Definition at line 79 of file remotefile.h.

Referenced by openSocket(), and RemoteFile().

◆ timeout_ms

int RemoteFile::timeout_ms
private

Definition at line 80 of file remotefile.h.

Referenced by openSocket(), and RemoteFile().

◆ filesize

long long RemoteFile::filesize
private

Definition at line 81 of file remotefile.h.

Referenced by GetFileSize(), GetRealFileSize(), and openSocket().

◆ timeoutisfast

bool RemoteFile::timeoutisfast
private

Definition at line 82 of file remotefile.h.

Referenced by SetTimeout().

◆ readposition

long long RemoteFile::readposition
private

Definition at line 83 of file remotefile.h.

Referenced by Resume(), and SeekInternal().

◆ lastposition

long long RemoteFile::lastposition
private

Definition at line 84 of file remotefile.h.

Referenced by Read(), Resume(), SeekInternal(), and Write().

◆ canresume

bool RemoteFile::canresume
private

Definition at line 85 of file remotefile.h.

Referenced by CheckConnection(), and OpenInternal().

◆ recordernum

int RemoteFile::recordernum
private

Definition at line 86 of file remotefile.h.

Referenced by Close(), GetRealFileSize(), openSocket(), Read(), ReOpen(), SeekInternal(), SetTimeout(), and Write().

◆ lock

QMutex RemoteFile::lock
mutableprivate

◆ controlSock

MythSocket* RemoteFile::controlSock
private

◆ sock

MythSocket* RemoteFile::sock
private

◆ query

QString RemoteFile::query
private

Definition at line 91 of file remotefile.h.

Referenced by Close(), GetRealFileSize(), Read(), ReOpen(), SeekInternal(), SetTimeout(), and Write().

◆ writemode

bool RemoteFile::writemode
private

◆ completed

bool RemoteFile::completed
private

Definition at line 94 of file remotefile.h.

Referenced by GetRealFileSize().

◆ lastSizeCheck

MythTimer RemoteFile::lastSizeCheck
private

Definition at line 95 of file remotefile.h.

Referenced by GetRealFileSize().

◆ possibleauxfiles

QStringList RemoteFile::possibleauxfiles
private

Definition at line 97 of file remotefile.h.

Referenced by openSocket(), and RemoteFile().

◆ auxfiles

QStringList RemoteFile::auxfiles
private

Definition at line 98 of file remotefile.h.

Referenced by openSocket().

◆ localFile

int RemoteFile::localFile
private

Definition at line 99 of file remotefile.h.

Referenced by Close(), isOpen(), OpenInternal(), Read(), and SeekInternal().

◆ fileWriter

ThreadedFileWriter* RemoteFile::fileWriter
private

Definition at line 100 of file remotefile.h.

Referenced by Close(), GetFileSize(), isOpen(), OpenInternal(), SeekInternal(), SetBlocking(), and Write().


The documentation for this class was generated from the following files: