MythTV  0.25-pre
Enumerations | Functions
util.cpp File Reference

Go to the source code of this file.

Enumerations

enum  { IOPRIO_CLASS_NONE, IOPRIO_CLASS_RT, IOPRIO_CLASS_BE, IOPRIO_CLASS_IDLE }
enum  { IOPRIO_WHO_PROCESS = 1, IOPRIO_WHO_PGRP, IOPRIO_WHO_USER }

Functions

QDateTime mythCurrentDateTime ()
 Returns the current QDateTime object, stripped of its msec component.
QDateTime myth_dt_from_string (const QString &dtstr)
QString MythDateTimeToString (const QDateTime &datetime, uint format)
QString MythDateToString (const QDate &date, uint format)
QString MythTimeToString (const QTime &time, uint format)
int calc_utc_offset (void)
static bool compare_zone_files (QFileInfo first_file_info, QFileInfo second_file_info)
static QString findZoneinfoFile (QString zoneinfo_file_path, QString zoneinfo_dir_path)
static bool parse_zone_id_config_string (QString &zone_id)
static bool read_time_zone_id (QString filename, QString &zone_id)
static QString getSystemTimeZoneID (void)
QString getTimeZoneID (void)
 Returns the zoneinfo time zone ID or as much time zone information as possible.
static bool compare_zone_IDs (QString firstZoneID, QString secondZoneID)
static void print_timezone_info (QString master_zone_id, QString local_zone_id, int master_utc_offset, int local_utc_offset, QString master_time, QString local_time)
bool checkTimeZone (void)
 Verifies the time zone settings on this system agree with those on the master backend.
bool checkTimeZone (const QStringList &master_settings)
 This overloaded version allows for the use of an existing (not managed by MythContext) connection to the backend.
int MythSecsTo (const QDateTime &from, const QDateTime &to)
 Returns "'to' - 'from'" for two QDateTime's in seconds.
QDateTime MythUTCToLocal (const QDateTime &utc)
 Converts a QDateTime in UTC to local time.
bool getUptime (time_t &uptime)
 Returns uptime statistics.
bool getMemStats (int &totalMB, int &freeMB, int &totalVM, int &freeVM)
 Returns memory statistics in megabytes.
bool hasUtf8 (const char *str)
 Guess whether a string is UTF-8.
bool ping (const QString &host, int timeout)
 Can we ping host within timeout seconds?
bool telnet (const QString &host, int port)
 Can we talk to port on host?
long long copy (QFile &dst, QFile &src, uint block_size)
 Copies src file to dst file.
QString createTempFile (QString name_template, bool dir)
void makeFileAccessible (QString filename)
 Makes a file accessible to all frontends/backends.
QString getResponse (const QString &query, const QString &def)
 In an interactive shell, prompt the user to input a string.
int intResponse (const QString &query, int def)
 In an interactive shell, prompt the user to input a number.
QString getSymlinkTarget (const QString &start_file, QStringList *intermediaries, unsigned maxLinks)
void sendPlaybackStart (void)
void sendPlaybackEnd (void)
bool IsMACAddress (QString MAC)
QString FileHash (QString filename)
bool WakeOnLAN (QString MAC)
bool IsPulseAudioRunning (void)
 Is A/V Sync destruction daemon is running on this host?
bool myth_nice (int val)
void myth_yield (void)
bool myth_ioprio (int val)
bool MythRemoveDirectory (QDir &aDir)
QString & ShellEscape (QString &string)
void setHttpProxy (void)
 Get network proxy settings from OS, and use for [Q]Http[Comms].
void wrapList (QStringList &list, int width)
QString xml_indent (uint level)

Enumeration Type Documentation

anonymous enum
Enumerator:
IOPRIO_CLASS_NONE 
IOPRIO_CLASS_RT 
IOPRIO_CLASS_BE 
IOPRIO_CLASS_IDLE 

Definition at line 1349 of file util.cpp.

anonymous enum
Enumerator:
IOPRIO_WHO_PROCESS 
IOPRIO_WHO_PGRP 
IOPRIO_WHO_USER 

Definition at line 1350 of file util.cpp.


Function Documentation

QDateTime myth_dt_from_string ( const QString &  dtstr)
QString MythDateTimeToString ( const QDateTime &  datetime,
uint  format 
)
QString MythDateToString ( const QDate &  date,
uint  format 
)
QString MythTimeToString ( const QTime &  time,
uint  format 
)
static bool compare_zone_files ( QFileInfo  first_file_info,
QFileInfo  second_file_info 
) [static]

Definition at line 185 of file util.cpp.

Referenced by compare_zone_IDs(), and findZoneinfoFile().

static QString findZoneinfoFile ( QString  zoneinfo_file_path,
QString  zoneinfo_dir_path 
) [static]

Definition at line 238 of file util.cpp.

Referenced by getSystemTimeZoneID().

static bool parse_zone_id_config_string ( QString &  zone_id) [static]

Definition at line 279 of file util.cpp.

Referenced by read_time_zone_id().

static bool read_time_zone_id ( QString  filename,
QString &  zone_id 
) [static]

Definition at line 307 of file util.cpp.

Referenced by getSystemTimeZoneID().

static QString getSystemTimeZoneID ( void  ) [static]

Definition at line 341 of file util.cpp.

Referenced by getTimeZoneID().

Returns the zoneinfo time zone ID or as much time zone information as possible.

Definition at line 431 of file util.cpp.

Referenced by checkTimeZone(), connect_to_master(), Myth::GetTimeZone(), BaseRequestHandler::HandleQueryTimeZone(), and MainServer::HandleQueryTimeZone().

static bool compare_zone_IDs ( QString  firstZoneID,
QString  secondZoneID 
) [static]

Definition at line 466 of file util.cpp.

Referenced by checkTimeZone().

static void print_timezone_info ( QString  master_zone_id,
QString  local_zone_id,
int  master_utc_offset,
int  local_utc_offset,
QString  master_time,
QString  local_time 
) [static]

Definition at line 486 of file util.cpp.

Referenced by checkTimeZone().

Verifies the time zone settings on this system agree with those on the master backend.

Definition at line 502 of file util.cpp.

Referenced by checkTimeZone(), connect_to_master(), and BackendConnectionManager::customEvent().

bool checkTimeZone ( const QStringList &  master_settings)

This overloaded version allows for the use of an existing (not managed by MythContext) connection to the backend.

Definition at line 522 of file util.cpp.

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

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

Definition at line 614 of file util.cpp.

Referenced by calc_utc_offset(), and MythUTCToLocal().

MythUTCToLocal ( const QDateTime &  utc)
getUptime ( time_t &  uptime)

Returns uptime statistics.

Returns:
true if successful, false otherwise.

Definition at line 638 of file util.cpp.

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

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 685 of file util.cpp.

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

bool hasUtf8 ( const char *  str)

Guess 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 753 of file util.cpp.

bool ping ( const QString &  host,
int  timeout 
)

Can we ping host within timeout seconds?

Some unixes don't like the -t argument. To make sure a ping failure is actually caused by a defunct server, we might have to do a ping without the -t, which will cause a long timeout.

Definition at line 798 of file util.cpp.

Referenced by setHttpProxy(), and MythContextPrivate::TestDBconnection().

bool telnet ( const QString &  host,
int  port 
)

Can we talk to port on host?

Definition at line 842 of file util.cpp.

Referenced by setHttpProxy().

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 successful the file pointers will be at the end of the copied data.

Parameters:
dstDestination QFile
srcSource QFile
block_sizeOptional 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 873 of file util.cpp.

Referenced by mythburn::copyRemote(), VAAPIContext::CopySurfaceToFrame(), mythburn::doProcessFile(), mythburn::doProcessFileProjectX(), VideoVisualGoom::Draw(), mythburn::getFileInformation(), PrivateDecoderCrystalHD::GetFrame(), nv_python_libs.common.common_api.Common::getUrlData(), ImportRecorder::Open(), mythburn::preProcessFile(), MythImage::Reflect(), strDup(), strDupSize(), trail_space(), nv_python_libs.xsltfunctions.traileraddicts_api.xpathFunctions::traileraddictsLinkGenerationMovie(), and ThumbFinder::updateThumb().

QString createTempFile ( QString  name_template,
bool  dir 
)
makeFileAccessible ( QString  filename)

Makes a file accessible to all frontends/backends.

This function abstracts the functionality of making a file accessible to all frontends and backends. Currently it contains a permissions hack that makes a file accessible even on a system with an improperly configured environment (umask/group) where the frontend and backend are being run as different users or where a NFS share is used but UID's/GID's differ on different hosts.

Though the function currently only changes the file mode to 0666, by abstracting the functionality, it will be easier to make changes in the future if a better approach is chosen. Similarly, using this function allows the hack to be applied only when required if code is written to detect or allow the user to specify their system is misconfigured.

Parameters:
filenamePath of file to make accessible

Definition at line 1002 of file util.cpp.

Referenced by DataDirectProcessor::SaveLineupToCache(), and PreviewGenerator::SavePreview().

QString getResponse ( const QString &  query,
const QString &  def 
)

In an interactive shell, prompt the user to input a string.

Definition at line 1011 of file util.cpp.

Referenced by intResponse(), ChannelData::promptForChannelUpdates(), MythContextPrivate::PromptForDatabaseParams(), and SchemaUpgradeWizard::PromptForUpgrade().

int intResponse ( const QString &  query,
int  def 
)

In an interactive shell, prompt the user to input a number.

Definition at line 1050 of file util.cpp.

Referenced by MythContextPrivate::PromptForDatabaseParams().

QString getSymlinkTarget ( const QString &  start_file,
QStringList *  intermediaries,
unsigned  maxLinks 
)

Definition at line 1116 of file util.cpp.

Referenced by VideoPlayMythSystem::Play(), playDisc(), and TV::StartTV().

Definition at line 1122 of file util.cpp.

Referenced by VideoPlayMythSystem::Play(), playDisc(), and TV::StartTV().

bool IsMACAddress ( QString  MAC)

Definition at line 1128 of file util.cpp.

Referenced by Scheduler::WakeUpSlave().

QString FileHash ( QString  filename)
bool WakeOnLAN ( QString  MAC)

Definition at line 1216 of file util.cpp.

Referenced by Scheduler::WakeUpSlave().

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

Definition at line 1258 of file util.cpp.

Referenced by AudioOutput::OpenAudio(), and PulseHandler::Suspend().

bool myth_nice ( int  val)

Definition at line 1290 of file util.cpp.

bool myth_ioprio ( int  val)
bool MythRemoveDirectory ( QDir &  aDir)
QString& ShellEscape ( QString &  string)

Definition at line 1415 of file util.cpp.

Referenced by Search::executeSearch().

Get network proxy settings from OS, and use for [Q]Http[Comms].

The HTTP_PROXY environment var. is parsed for values like; "proxy-host", "proxy-host:8080", "http://host:8080" and "http"//user:password:1080", and that is used for any Qt-based Http fetches. We also test connectivity here with ping and telnet, and warn if it fails.

If there is was no env. var, we use Qt to get proxy settings from the OS, and search through them for a proxy server we can connect to.

Definition at line 1443 of file util.cpp.

Referenced by main().

void wrapList ( QStringList &  list,
int  width 
)

Definition at line 1545 of file util.cpp.

Referenced by CommandLineArg::GetHelpString(), and CommandLineArg::GetLongHelpString().

QString xml_indent ( uint  level)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends