util.cpp File Reference

Go to the source code of this file.

Functions

QDateTime mythCurrentDateTime ()
 Returns the current QDateTime object, stripped of its msec component.
int calc_utc_offset (void)
void encodeLongLong (QStringList &list, long long num)
 Encodes a long for streaming in the MythTV protocol.
long long decodeLongLong (QStringList &list, uint offset)
 Inefficiently decodes a long encoded for streaming in the MythTV protocol.
long long decodeLongLong (QStringList &list, QStringList::const_iterator &it)
 Decodes a long encoded for streaming in the MythTV protocol.
QRgb blendColors (QRgb source, QRgb add, int alpha)
 Inefficient alpha blending function.
uint myth_system (const QString &command, int flags)
 Runs a system command inside the /bin/sh shell.
memset & si (si)
memset & pi (pi)
 strcpy (ch, cmd)
 if (!::CreateProcessA(NULL, ch, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL,&si,&pi))
QString cutDownString (const QString &text, QFont *testFont, uint maxwidth)
 Returns a string based on "text" that fits within "maxwidth" pixels.
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.
long long stringToLongLong (const QString &str)
 Converts QString representing long long to a long long.
QString longLongToString (long long ll)
 Returns QString representation of long long.
bool getUptime (time_t &uptime)
 Returns uptime statistics.
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.
bool getMemStats (int &totalMB, int &freeMB, int &totalVM, int &freeVM)
 Returns memory statistics in megabytes.
void myth_eject ()
 Eject a disk, unmount a drive, open a tray.
bool hasUtf8 (const char *str)
 Quess whether a string is UTF-8.
u_short in_cksum (u_short *addr, int len)
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)
double MythGetPixelAspectRatio (void)
unsigned long long myth_get_approximate_large_file_size (const QString &fname)
bool IsPulseAudioRunning (void)
 Is A/V Sync destruction daemon is running on this host?

Variables

STARTUPINFO si
PROCESS_INFORMATION pi
si cb = sizeof(si)
QString cmd = QString("cmd.exe /c %1").arg(command.utf8()).ascii()
char * ch = new char[cmd.length() + 1]


Function Documentation

mythCurrentDateTime (  ) 

int calc_utc_offset ( void   ) 

Definition at line 81 of file util.cpp.

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

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().

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().

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.

blendColors ( QRgb  source,
QRgb  add,
int  alpha 
)

Inefficient alpha blending function.

Definition at line 200 of file util.cpp.

myth_system ( const QString &  command,
int  flags 
)

memset& si ( si   ) 

memset& pi ( pi   ) 

strcpy ( ch  ,
cmd   
)

if ( !::  CreateProcessANULL, ch, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL,&si,&pi  ) 

Definition at line 333 of file util.cpp.

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().

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().

MythUTCToLocal ( const QDateTime &  utc  ) 

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().

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().

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().

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().

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().

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().

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.

u_short in_cksum ( u_short *  addr,
int  len 
)

Definition at line 650 of file util.cpp.

Referenced by ping().

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().

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().

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.

QString createTempFile ( QString  name_template,
bool  dir 
)

double MythGetPixelAspectRatio ( void   ) 

Definition at line 936 of file util.cpp.

Referenced by GalleryUtil::ScaleToDest().

unsigned long long myth_get_approximate_large_file_size ( const QString &  fname  ) 

Definition at line 945 of file util.cpp.

Referenced by PreviewGenerator::GetScreenGrab().

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().


Variable Documentation

STARTUPINFO si

PROCESS_INFORMATION pi

si cb = sizeof(si)

QString cmd = QString("cmd.exe /c %1").arg(command.utf8()).ascii()

char* ch = new char[cmd.length() + 1]

Definition at line 331 of file util.cpp.

Referenced by aac_sync(), ac3_decode_frame(), AC3_encode_frame(), AC3_encode_init(), ac3_parse_audio_block(), MHIText::AddText(), adpcm_decode_frame(), av_audio_convert(), average_quantized_coeffs(), QCodecs::base64Decode(), bit_alloc(), bit_alloc_masking(), build_sb_samples_from_noise(), UIListBtnTypeItem::CalcDimensions(), MHResidentProgram::CallProgram(), compute_bit_allocation(), copy_samples(), decode_iso6937(), do_imdct(), MHParseBinary::DoParse(), encode_block(), encode_frame(), extract_hot_key(), ff_mpc_dequantize_and_synth(), fill_coding_method_array(), fill_tone_level_array(), DiSEqCDevDevice::FindDevice(), fix_coding_method_array(), flac_encode_frame(), get_transform_coeffs(), MHIText::GetBounds(), GuideGrid::GetSelection(), getSideInfo1(), getSideInfo2(), MHGenericInteger::GetValue(), http_connect(), init_frame(), init_tone_level_dequantization(), mp_decode_frame(), mp_decode_layer1(), mp_decode_layer2(), mp_decode_layer3(), mpc7_decode_frame(), mpc8_decode_frame(), mpc_synth(), OSDListBtnTypeItem::OSDListBtnTypeItem(), output_audio_block(), output_subframes(), MHParseBinary::ParseInt(), DataDirectProcessor::ParseLineup(), MHEngine::ParseProgram(), DeviceTree::PopulateTree(), MHOctetString::PrintMe(), process_subpacket_9(), NetworkControl::processKey(), putSideInfo1(), putSideInfo2(), qdm2_decode(), qdm2_fft_tone_synthesizer(), qdm2_synthesis_filter(), UIImageGridType::recalculateLayout(), MHText::Redraw(), remove_dithering(), roq_dpcm_encode_frame(), rtsp_send_cmd(), DataDirectProcessor::SaveLineup(), DataDirectProcessor::SaveLineupChanges(), DataDirectProcessor::SetAll(), DiSEqCDevSwitch::SetNumPorts(), MHIntegerVar::SetVariableValue(), sonic_decode_frame(), sonic_encode_frame(), DiSEqCDevSwitch::Store(), SwitchSetting::SwitchSetting(), synthfilt_build_sb_samples(), GuideGrid::toggleChannelFavorite(), uncouple_channels(), vorbis_parse_audio_packet(), wma_decode_block(), and wma_decode_frame().


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