util.h File Reference

Go to the source code of this file.

Classes

class  MythTimer
struct  timing_ab_t

Functions

MPUBLIC QDateTime mythCurrentDateTime ()
 Returns the current QDateTime object, stripped of its msec component.
MPUBLIC int calc_utc_offset (void)
MPUBLIC long long absLongLong (long long n)
MPUBLIC void encodeLongLong (QStringList &list, long long num)
 Encodes a long for streaming in the MythTV protocol.
MPUBLIC long long decodeLongLong (QStringList &list, uint offset)
 Inefficiently decodes a long encoded for streaming in the MythTV protocol.
MPUBLIC long long decodeLongLong (QStringList &list, QStringList::const_iterator &it)
 Decodes a long encoded for streaming in the MythTV protocol.
MPUBLIC QRgb blendColors (QRgb source, QRgb add, int alpha)
 Inefficient alpha blending function.
MPUBLIC uint myth_system (const QString &command, int flags=0)
 Runs a system command inside the /bin/sh shell.
MPUBLIC QString cutDownString (const QString &text, QFont *testFont, uint maxwidth)
 Returns a string based on "text" that fits within "maxwidth" pixels.
MPUBLIC QDateTime MythUTCToLocal (const QDateTime &utc)
 Converts a QDateTime in UTC to local time.
MPUBLIC int MythSecsTo (const QDateTime &from, const QDateTime &to)
 Returns "'to' - 'from'" for two QDateTime's in seconds.
MPUBLIC long long stringToLongLong (const QString &str)
 Converts QString representing long long to a long long.
MPUBLIC QString longLongToString (long long ll)
 Returns QString representation of long long.
MPUBLIC long long getDiskSpace (const QString &, long long &, long long &)
 Returns free space on disk containing file in KiB, or -1 if it does not succeed.
MPUBLIC bool getUptime (time_t &uptime)
 Returns uptime statistics.
MPUBLIC bool getMemStats (int &totalMB, int &freeMB, int &totalVM, int &freeVM)
 Returns memory statistics in megabytes.
MPUBLIC void myth_eject (void)
 Eject a disk, unmount a drive, open a tray.
MPUBLIC bool hasUtf8 (const char *str)
 Quess whether a string is UTF-8.
MPUBLIC bool ping (const QString &host, int timeout)
 Can we ping host within timeout seconds?
MPUBLIC bool telnet (const QString &host, int port)
 Can we talk to port on host?
MPUBLIC long long copy (QFile &dst, QFile &src, uint block_size=0)
 Copies src file to dst file.
MPUBLIC QString createTempFile (QString name_template="/tmp/mythtv_XXXXXX", bool dir=false)
MPUBLIC unsigned long long myth_get_approximate_large_file_size (const QString &fname)
MPUBLIC double MythGetPixelAspectRatio (void)
MPUBLIC bool IsPulseAudioRunning (void)
 Is A/V Sync destruction daemon is running on this host?
void rdtsc (uint64_t &x)


Function Documentation

MPUBLIC QDateTime mythCurrentDateTime (  ) 

MPUBLIC int calc_utc_offset ( void   ) 

Definition at line 81 of file util.cpp.

Referenced by calc_eit_utc_offset(), and MPEGStreamData::MPEGStreamData().

MPUBLIC long long absLongLong ( long long  n  )  [inline]

MPUBLIC void encodeLongLong ( QStringList &  list,
long long  num 
)

Encodes a long for streaming in the MythTV protocol.

We need this for Qt3.1 compatibility, since it will not print or read a 64 bit number directly. We encode the long long as strings representing two signed 32 bit integers.

See also:
decodeLongLong(QStringList&,uint) decodeLongLong(QStringList&,QStringList::const_iterator&)

Definition at line 111 of file util.cpp.

Referenced by BackendQueryDiskSpace(), PlaybackSock::GenPreviewPixmap(), RemoteEncoder::GetKeyframePosition(), MainServer::HandleAnnounce(), MainServer::HandleBookmarkQuery(), MainServer::HandleCutMapQuery(), MainServer::HandleFileTransferQuery(), MainServer::HandleRecorderQuery(), MainServer::HandleRemoteEncoder(), PreviewGenerator::RemotePreviewRun(), and RemoteFile::Seek().

MPUBLIC long long decodeLongLong ( QStringList &  list,
uint  offset 
)

Inefficiently decodes a long encoded for streaming in the MythTV protocol.

We need this for Qt3.1 compatibility, since it will not print or read a 64 bit number directly.

The long long is represented as two signed 32 bit integers.

Note: This decode performs two O(n) linear searches of the list, The iterator decode function is much more efficient.

Parameters:
list List to search for offset and offset+1 in.
offset Offset in list where to find first 32 bits of long long.
See also:
encodeLongLong(QStringList&,long long), decodeLongLong(QStringList&,QStringList::const_iterator&)

Definition at line 134 of file util.cpp.

Referenced by BackendQueryDiskSpace(), RemoteEncoder::FillPositionMap(), HttpStatus::FillStatusXML(), RemoteEncoder::GetFilePosition(), GetFilesystemInfos(), RemoteEncoder::GetFramesWritten(), RemoteEncoder::GetKeyframePosition(), RemoteEncoder::GetMaxBitrate(), PlaybackSock::GetMaxBitrate(), MainServer::HandleFileTransferQuery(), MainServer::HandleGenPreviewPixmap(), MainServer::HandleRecorderQuery(), MainServer::HandleSetBookmark(), RemoteFile::openSocket(), RemoteGetFreeSpace(), and RemoteFile::Seek().

MPUBLIC long long decodeLongLong ( QStringList &  list,
QStringList::const_iterator &  it 
)

Decodes a long encoded for streaming in the MythTV protocol.

We need this for Qt3.1 compatibility, since it will not print or read a 64 bit number directly.

The long long is represented as two signed 32 bit integers.

Parameters:
list List to search for offset and offset+1 in.
it Iterator pointing to first 32 bits of long long.
See also:
encodeLongLong(QStringList&,long long), decodeLongLong(QStringList&,uint)

Definition at line 165 of file util.cpp.

MPUBLIC QRgb blendColors ( QRgb  source,
QRgb  add,
int  alpha 
)

Inefficient alpha blending function.

Definition at line 200 of file util.cpp.

MPUBLIC uint myth_system ( const QString &  command,
int  flags 
)

MPUBLIC QString cutDownString ( const QString &  text,
QFont *  testFont,
uint  maxwidth 
)

Returns a string based on "text" that fits within "maxwidth" pixels.

Definition at line 356 of file util.cpp.

Referenced by PlaybackBox::initPopup().

MPUBLIC QDateTime MythUTCToLocal ( const QDateTime &  utc  ) 

MPUBLIC int MythSecsTo ( const QDateTime &  from,
const QDateTime &  to 
)

Returns "'to' - 'from'" for two QDateTime's in seconds.

Definition at line 385 of file util.cpp.

Referenced by calc_utc_offset(), and MythUTCToLocal().

MPUBLIC long long stringToLongLong ( const QString &  str  ) 

Converts QString representing long long to a long long.

This is needed to input 64 bit numbers with Qt 3.1.

Definition at line 410 of file util.cpp.

Referenced by UPnpCDSTv::AddItem(), TV::customEvent(), AutoExpire::ExpireEpisodesOverMax(), AutoExpire::FillDBOrdered(), ProgramList::FromRecorded(), ProgramInfo::GetFilesize(), ProgramInfo::GetProgramFromRecorded(), and MainServer::HandleQueryRecordings().

MPUBLIC QString longLongToString ( long long  ll  ) 

Returns QString representation of long long.

This is needed to output 64 bit numbers with Qt 3.1.

Definition at line 425 of file util.cpp.

Referenced by UPnpCDSTv::AddItem(), MythXML::FillProgramInfo(), StorageGroup::FindNextDirMostFree(), ProgramInfo::SetFilesize(), and ProgramInfo::ToMap().

MPUBLIC long long getDiskSpace ( const QString &  file_on_disk,
long long &  total,
long long &  used 
)

Returns free space on disk containing file in KiB, or -1 if it does not succeed.

Parameters:
file_on_disk file on the file system we wish to stat.

Definition at line 484 of file util.cpp.

Referenced by BackendQueryDiskSpace(), NativeArchive::copyFile(), MythburnWizard::filenameEditLostFocus(), ExportNativeWizard::filenameEditLostFocus(), StorageGroup::FindNextDirMostFree(), getMemStats(), MythburnWizard::setDestination(), and ExportNativeWizard::setDestination().

MPUBLIC bool getUptime ( time_t &  uptime  ) 

Returns uptime statistics.

Todo:
Update Statistics are not supported (by MythTV) on NT or DOS.
Returns:
true if successful, false otherwise.

Definition at line 438 of file util.cpp.

Referenced by StatusBox::doMachineStatus(), and MainServer::HandleQueryUptime().

MPUBLIC bool getMemStats ( int &  totalMB,
int &  freeMB,
int &  totalVM,
int &  freeVM 
)

Returns memory statistics in megabytes.

Todo:
Memory Statistics are not supported (by MythTV) on NT or DOS.
Returns:
true if it succeeds, false otherwise.

Definition at line 522 of file util.cpp.

Referenced by StatusBox::doMachineStatus(), and MainServer::HandleQueryMemStats().

MPUBLIC void myth_eject ( void   ) 

Eject a disk, unmount a drive, open a tray.

If the Media Monitor is enabled, we use its fully-featured routine. Otherwise, we guess a drive and use a primitive OS-specific command

Definition at line 586 of file util.cpp.

Referenced by MythThemedMenuPrivate::handleAction(), IconView::HandleEject(), and MythThemedMenuPrivate::keyHandler().

MPUBLIC bool hasUtf8 ( const char *  str  ) 

Quess whether a string is UTF-8.

Note:
This does not attempt to validate the whole string. It just checks if it has any UTF-8 sequences in it.

Definition at line 611 of file util.cpp.

MPUBLIC bool ping ( const QString &  host,
int  timeout 
)

Can we ping host within timeout seconds?

Definition at line 689 of file util.cpp.

Referenced by MythContextPrivate::TestDBconnection().

MPUBLIC bool telnet ( const QString &  host,
int  port 
)

Can we talk to port on host?

Definition at line 800 of file util.cpp.

Referenced by MythContextPrivate::TestDBconnection().

MPUBLIC long long copy ( QFile &  dst,
QFile &  src,
uint  block_size 
)

Copies src file to dst file.

If the dst file is open, it must be open for writing. If the src file is open, if must be open for reading.

The files will be in the same open or close state after this function runs as they were prior to this function being called.

This function does not care if the files are actual files. For compatibility with pipes and socket streams the file location will not be reset to 0 at the end of this function. If the function is succesful the file pointers will be at the end of the copied data.

Parameters:
dst Destination QFile
src Source QFile
block_size Optional block size in bytes, must be at least 1024, otherwise the default of 16 KB will be used.
Returns:
bytes copied on success, -1 on failure.

Definition at line 834 of file util.cpp.

MPUBLIC QString createTempFile ( QString  name_template = "/tmp/mythtv_XXXXXX",
bool  dir = false 
)

MPUBLIC unsigned long long myth_get_approximate_large_file_size ( const QString &  fname  ) 

Definition at line 945 of file util.cpp.

Referenced by PreviewGenerator::GetScreenGrab().

MPUBLIC double MythGetPixelAspectRatio ( void   ) 

Definition at line 936 of file util.cpp.

Referenced by GalleryUtil::ScaleToDest().

MPUBLIC bool IsPulseAudioRunning ( void   ) 

Is A/V Sync destruction daemon is running on this host?

Definition at line 965 of file util.cpp.

Referenced by pulseaudio_handle_startup().

void rdtsc ( uint64_t x  )  [inline]

Definition at line 94 of file util.h.

Referenced by ff_h263_decode_frame().


Generated on Sat Dec 18 05:15:56 2010 for MythTV by  doxygen 1.5.5