Classes | Functions
Tonido::Util Namespace Reference

Generally useful Utility functions. More...

Classes

class  AttemptsTracker
 Tracks different kinds of (invalid) attempts within a specific period. More...
class  CompressFolderActivity
 An activity that compresses a folder. More...
class  ErrorLog
 Serializable binary dump error container. More...
class  ErrorUtil
 Helper class for Logging Message into an ErrorLog. More...
class  FileDownloadActivity
 An activity that downloads a file. More...
class  FolderCopyActivity
 An activity that copies a folder. More...
class  HTTP
 Utility classes related to HTTP input/output. More...
class  LimitTracker
 Tracks Limits. More...
class  MessageUtil
 Tonido::Data::Message Formatting and Creation Functions. More...
class  OpProcessor
 Processes incoming messages and then calls the appropriate function. More...
class  PoLoader
 Loads and parses a single po file. More...
class  PoManager
 Manages translation files. More...
class  CheckURLActivity
 An activity that checks whether Tonido URL is available. More...
class  SignatureVerifier
 Performs various RSA based PKI actions. More...
class  SingleUserBoxOffice
 This is like a. More...
class  UniqueTokenManager
 Manages Unique Tokens. More...
class  UpdatePluginActivity
 An activity that updates all plugins in one shot. More...
class  ValidTokenManager
 Manages a set of Valid Tokens. More...
class  VirtualFS
 Treats a Zip File as a simple file system. More...

Functions

BOOTSTRAP_API bool getMD5FileChecksum (const std::string &a_fileName, std::string &a_checkSum, int64_bt a_offset, int64_bt a_length, volatile bool *a_terminate=0)
 Gets the MD5 checksum of a given file.
BOOTSTRAP_API bool getFileCRC (const std::string &a_fileName, std::string &a_checkSum, int64_bt a_offset, int64_bt a_length, volatile bool *a_terminate=0)
 Gets the CRC checksum of a given file.
BOOTSTRAP_API std::string getSHA1Hash (const std::string &a_value)
 Gets the SHA1 Hash for a given string.
BOOTSTRAP_API void splitFolder (const std::string &a_fullFolderName, std::string &a_exeName, std::string &a_folderPath)
 Splits a given file path to fileName and the folder path.
BOOTSTRAP_API void addEndingSeparator (const std::string &a_dirName, std::string &a_dirWithPathSeparator)
 Adds a separator to the path, if it is not there.
BOOTSTRAP_API std::string convertPathToNative (const std::string &a_file)
 Converts a given path to native path.
BOOTSTRAP_API std::string convertPathToNonNative (const std::string &a_file)
 Converts a given path to non native path.
BOOTSTRAP_API std::string convertPathToWindows (const std::string &a_path)
 Converts a given path to windows format.
BOOTSTRAP_API std::string getDirectoryListXML (const std::string &directory)
 Gets the list of directories in a directory as XML.
BOOTSTRAP_API std::string getFileListXML (const std::string &file, int32_bt a_start, int32_bt a_limit, const std::string &a_filter, const std::string &a_search)
 Gets the list of files in a directory as XML.
BOOTSTRAP_API std::string getFileListPosXML (const std::string &file, const std::string &a_filter, const std::string &a_fileName)
 Gets the position of a file in a directory as XML.
BOOTSTRAP_API std::string getDesktopPath ()
 Gets the Desktop Path.
BOOTSTRAP_API std::string getUserHomePath ()
 Gets the User Home Path.
BOOTSTRAP_API std::string readableFileSize (int64_bt a_fileSize, int a_precision=2)
 Gets a human readable file size.
BOOTSTRAP_API std::string readableTimeSpan (Poco::Timespan &a_timeSpan)
 Gets a human readable time span.
BOOTSTRAP_API void addSeparatorToURL (const std::string &a_url, std::string &a_urlWithSeparator)
 Adds a separator to a url, if it is not there.
BOOTSTRAP_API bool checkAuthentication (Tonido::Data::Message::SharedPtr &args, Tonido::Data::AuthKey::AuthSource a_source, Tonido::Data::AuthKey::AuthRole a_role, Tonido::Data::AuthKey::AuthLocation a_location, const std::string &a_authContext="")
 Checks the authentication of a given message.
BOOTSTRAP_API std::string setWorkingDirectoryToExePath ()
 Sets the current working directory to be the same as the executable path.
BOOTSTRAP_API void launchDefaultBrowser (const std::string &a_url)
 Launches the default web browser.
BOOTSTRAP_API Poco::UUID generateUUID ()
 Creates UUID safely without conflicts.
BOOTSTRAP_API Poco::UUID createUUIDFromString (const std::string &a_string)
 Creates UUID from a given string.
BOOTSTRAP_API std::string localTimeStrFromUTCStr (const std::string &a_utcString)
 Get Local Time string from UTC time string.
BOOTSTRAP_API std::string localTimeStrFromUTCTime (const Poco::DateTime &a_utcDate)
 Get Local Time string from UTC time.
BOOTSTRAP_API std::string localNiceTimeStrFromUTCTime (const Poco::DateTime &a_utcDate)
 Get Local Time string from UTC time.
BOOTSTRAP_API bool isAlphaNumeric (const std::string &a_string)
 Checks if a given string contains only alphabets and numbers.
BOOTSTRAP_API bool isAlpha (const std::string &a_string)
 Checks if a given string contains only alphabets.
BOOTSTRAP_API bool isNumeric (const std::string &a_string)
 Checks if a given string contains only numbers.
BOOTSTRAP_API bool isAlphaSpace (const std::string &a_string)
 Checks if a given string contains only Alphabets or space.
BOOTSTRAP_API bool isEmailID (const std::string &a_string)
 Checks if a given string is a valid email id.
BOOTSTRAP_API bool isValidPassword (const std::string &a_string)
 Checks if a given string is a valid password.
BOOTSTRAP_API bool compareVersions (const std::string &a_version, const std::string &a_systemVersion, bool a_lessThan)
 Compares two string versions in dotted notation (x.x.x.x)
BOOTSTRAP_API std::string allowBROnly (const std::string &a_originalHTML)
 Cleans strings only allowing
tags.
BOOTSTRAP_API std::string cleanHTML (const std::string &a_originalHTML, bool isStrict=true)
 Cleans HTML of bad stuff leaving some innocous tags behind.
BOOTSTRAP_API std::string sanitizeString (const std::string &a_originalString, bool strongClean=true)
 Cleans strings of all bad stuff, including HTML tags.
BOOTSTRAP_API std::string trim (const std::string &a_originalString)
 Trims leading and trailing spaces of ASCII spaces.
BOOTSTRAP_API std::string sanitizeSQL (const std::string &a_originalString)
 Sanitize SQL characters like "'" (single quote) ???
BOOTSTRAP_API bool largeFileSeekg (Poco::FileInputStream *a_stream, int64_bt a_offset)
 Safe Large File Seek for files larger than 2 GB.
BOOTSTRAP_API bool largeFileSeekp (Poco::FileOutputStream *a_stream, int64_bt a_offset)
 Safe Large File Seek for files larger than 2 GB.
BOOTSTRAP_API bool getPrivateIPAddress (std::string &a_host, bool &isLoopback)
 Gets the Private IP Address of this host.
BOOTSTRAP_API bool isAllowedFile (const std::string &a_name)
 isAllowedFile
BOOTSTRAP_API bool isAllowedPath (const std::string &a_path, bool a_strict=false)
 isAllowedPath
BOOTSTRAP_API std::string getFileEntryXML (const std::string &a_path, int favoriteListID, int favoriteID, int order, const std::string &a_filter)
 getFileEntryXML
BOOTSTRAP_API std::string getFolderImage (const std::string &a_path)
 getFolderImage
BOOTSTRAP_API std::string getExtension (const std::string &a_Name)
 getExtension
BOOTSTRAP_API bool registerTonido (bool a_sendIPs, const std::string &a_tag, const std::string &a_url="")
 registerTonido
BOOTSTRAP_API std::string getMacID ()
 getMacID
BOOTSTRAP_API bool setCustomPermissions (const std::string &path, bool recursive)
 setCustomPermissions
BOOTSTRAP_API std::string getPublicBaseURL ()
 getPublicBaseURL
BOOTSTRAP_API bool isDirMounted (const std::string &a_dir)
 isDirMounted

Detailed Description

Generally useful Utility functions.


Function Documentation

void Tonido::Util::addEndingSeparator ( const std::string &  a_dirName,
std::string &  a_dirWithPathSeparator 
)

Adds a separator to the path, if it is not there.

Parameters:
[in]a_dirNamefolder name
[out]a_dirWithPathSeparatoroutput path with a separator
void Tonido::Util::addSeparatorToURL ( const std::string &  a_url,
std::string &  a_urlWithSeparator 
)

Adds a separator to a url, if it is not there.

Parameters:
[in]a_urlurl to add separator for
[out]a_urlWithSeparatoroutput url with separator
std::string Tonido::Util::allowBROnly ( const std::string &  a_originalHTML)

Cleans strings only allowing
tags.

Parameters:
[in]a_originalHTMLHTML text to clean strings
Returns:
new HTML text
bool Tonido::Util::checkAuthentication ( Tonido::Data::Message::SharedPtr &  args,
Tonido::Data::AuthKey::AuthSource  a_source,
Tonido::Data::AuthKey::AuthRole  a_role,
Tonido::Data::AuthKey::AuthLocation  a_location,
const std::string &  a_authContext = "" 
)

Checks the authentication of a given message.

Parameters:
[in]argsmessage to check the authentication for
[in]a_sourcemessage source
[in]a_rolemessage role
[in]a_locationmessage location
[in]a_authContextauth context
Returns:
true on successs, false otherwise
std::string Tonido::Util::cleanHTML ( const std::string &  a_originalHTML,
bool  isStrict = true 
)

Cleans HTML of bad stuff leaving some innocous tags behind.

TODO: This still needs work

Parameters:
[in]a_originalHTMLHTML text to clean bad stuff
[in]isStricttrue if use strict clean, false otherwise
Returns:
new HTML text
bool Tonido::Util::compareVersions ( const std::string &  a_version,
const std::string &  a_systemVersion,
bool  a_lessThan 
)

Compares two string versions in dotted notation (x.x.x.x)

Parameters:
[in]a_versionfirst string
[in]a_systemVersionsecond string
[in]a_lessThanif true check for less, otherwise check for above
Returns:
true on successs, false otherwise
std::string Tonido::Util::convertPathToNative ( const std::string &  a_file)

Converts a given path to native path.

Parameters:
[in]a_filepath to convert
Returns:
native path
std::string Tonido::Util::convertPathToNonNative ( const std::string &  a_file)

Converts a given path to non native path.

Parameters:
[in]a_filepath to convert
Returns:
non native path
std::string Tonido::Util::convertPathToWindows ( const std::string &  a_path)

Converts a given path to windows format.

Parameters:
[in]a_pathpath to convert
Returns:
windows format path
Poco::UUID Tonido::Util::createUUIDFromString ( const std::string &  a_string)

Creates UUID from a given string.

Parameters:
[in]a_stringbuffer to create UUID for
Returns:
new UUID
Poco::UUID Tonido::Util::generateUUID ( )

Creates UUID safely without conflicts.

Returns:
new UUID
std::string Tonido::Util::getDesktopPath ( )

Gets the Desktop Path.

Returns:
desktop path
std::string Tonido::Util::getDirectoryListXML ( const std::string &  directory)

Gets the list of directories in a directory as XML.

Parameters:
[in]directorydirectory to read
Returns:
list of directories as XML
std::string Tonido::Util::getExtension ( const std::string &  a_Name)

getExtension

Parameters:
[in]a_namename of the file
Returns:
extension of the file, empty otherwise
bool Tonido::Util::getFileCRC ( const std::string &  a_fileName,
std::string &  a_checkSum,
int64_bt  a_offset,
int64_bt  a_length,
volatile bool *  a_terminate = 0 
)

Gets the CRC checksum of a given file.

Parameters:
[in]a_fileNamefilename of the file to compute the CRC checksum for
[out]a_checksumgenerated checksum
[in]a_offsetstarting file offset, -1 means beginning of the file
[in]a_lengthlength to use
Returns:
true if succeeded, false otherwise
std::string Tonido::Util::getFileEntryXML ( const std::string &  a_path,
int  favoriteListID,
int  favoriteID,
int  order,
const std::string &  a_filter 
)

getFileEntryXML

Parameters:
[in]a_namename of the file
Returns:
xml with entry, empty otherwise
std::string Tonido::Util::getFileListPosXML ( const std::string &  file,
const std::string &  a_filter,
const std::string &  a_fileName 
)

Gets the position of a file in a directory as XML.

Parameters:
[in]filedirectory to read
Returns:
list of files as XML
std::string Tonido::Util::getFileListXML ( const std::string &  file,
int32_bt  a_start,
int32_bt  a_limit,
const std::string &  a_filter,
const std::string &  a_search 
)

Gets the list of files in a directory as XML.

Parameters:
[in]filedirectory to read
Returns:
list of files as XML
std::string Tonido::Util::getFolderImage ( const std::string &  a_path)

getFolderImage

Parameters:
[in]a_namepath
Returns:
a image file in that folder, empty otherwise
std::string Tonido::Util::getMacID ( )

getMacID

Parameters:
[in]none
Returns:
a macid of the device
bool Tonido::Util::getMD5FileChecksum ( const std::string &  a_fileName,
std::string &  a_checkSum,
int64_bt  a_offset,
int64_bt  a_length,
volatile bool *  a_terminate = 0 
)

Gets the MD5 checksum of a given file.

Parameters:
[in]a_fileNamefilename of the file to compute the MD5 checksum for
[out]a_checksumgenerated checksum
[in]a_offsetstarting file offset, -1 means beginning of the file
[in]a_lengthlength to use
Returns:
true if succeeded, false otherwise
bool Tonido::Util::getPrivateIPAddress ( std::string &  a_host,
bool &  isLoopback 
)

Gets the Private IP Address of this host.

Parameters:
[out]a_hostoutput host address
[out]isLoopbacktrue if it is localhost, false otherwise
Returns:
true if success, false otherwise
std::string Tonido::Util::getPublicBaseURL ( )

getPublicBaseURL

Parameters:
[in]none
Returns:
Base Public URL
std::string Tonido::Util::getSHA1Hash ( const std::string &  a_value)

Gets the SHA1 Hash for a given string.

Parameters:
[in]a_valuebuffer to compute the MD5 checksum for
Returns:
generated checksum
std::string Tonido::Util::getUserHomePath ( )

Gets the User Home Path.

Returns:
user home path
bool Tonido::Util::isAllowedFile ( const std::string &  a_name)

isAllowedFile

Parameters:
[in]a_namename of the file
Returns:
true if allowed, false otherwise
bool Tonido::Util::isAllowedPath ( const std::string &  a_path,
bool  a_strict = false 
)

isAllowedPath

Parameters:
[in]a_pathname of the path that allows certain operations
Returns:
true if allowed, false otherwise
bool Tonido::Util::isAlpha ( const std::string &  a_string)

Checks if a given string contains only alphabets.

Parameters:
[in]a_stringstring to check alphabets
Returns:
true on successs, false otherwise
bool Tonido::Util::isAlphaNumeric ( const std::string &  a_string)

Checks if a given string contains only alphabets and numbers.

Parameters:
[in]a_stringstring to check alphabets and numbers
Returns:
true on successs, false otherwise
bool Tonido::Util::isAlphaSpace ( const std::string &  a_string)

Checks if a given string contains only Alphabets or space.

Parameters:
[in]a_stringstring to check alphabets or space
Returns:
true on successs, false otherwise
bool Tonido::Util::isDirMounted ( const std::string &  a_dir)

isDirMounted

Parameters:
[in]a_dirdirectory to check if available
Returns:
true if mounted, false otherwise
bool Tonido::Util::isEmailID ( const std::string &  a_string)

Checks if a given string is a valid email id.

Parameters:
[in]a_stringstring to check email id
Returns:
true on successs, false otherwise
bool Tonido::Util::isNumeric ( const std::string &  a_string)

Checks if a given string contains only numbers.

Parameters:
[in]a_stringstring to check numbers
Returns:
true on successs, false otherwise
bool Tonido::Util::isValidPassword ( const std::string &  a_string)

Checks if a given string is a valid password.

The current password requirements are atleast 8 chars with atleast 1 number

Parameters:
[in]a_stringstring to check alphabets or space
Returns:
true on successs, false otherwise
bool Tonido::Util::largeFileSeekg ( Poco::FileInputStream *  a_stream,
int64_bt  a_offset 
)

Safe Large File Seek for files larger than 2 GB.

Parameters:
[in,out]a_streamfile stream
[in]a_offsetfile offset
Returns:
true if succeeded, false otherwise
bool Tonido::Util::largeFileSeekp ( Poco::FileOutputStream *  a_stream,
int64_bt  a_offset 
)

Safe Large File Seek for files larger than 2 GB.

Parameters:
[in,out]a_streamfile stream
[in]a_offsetfile offset
Returns:
true if succeeded, false otherwise
void Tonido::Util::launchDefaultBrowser ( const std::string &  a_url)

Launches the default web browser.

Parameters:
[in]a_urlurl to start browser for
std::string Tonido::Util::localNiceTimeStrFromUTCTime ( const Poco::DateTime &  a_utcDate)

Get Local Time string from UTC time.

Parameters:
[in]a_utcDateUTC time
Returns:
local time string
std::string Tonido::Util::localTimeStrFromUTCStr ( const std::string &  a_utcString)

Get Local Time string from UTC time string.

Parameters:
[in]a_utcStringUTC time string
Returns:
local time string
std::string Tonido::Util::localTimeStrFromUTCTime ( const Poco::DateTime &  a_utcDate)

Get Local Time string from UTC time.

Parameters:
[in]a_utcDateUTC time
Returns:
local time string
std::string Tonido::Util::readableFileSize ( int64_bt  a_fileSize,
int  a_precision = 2 
)

Gets a human readable file size.

Parameters:
[in]a_fileSizefile size
[in]a_precisionprecision
Returns:
human readable file size
std::string Tonido::Util::readableTimeSpan ( Poco::Timespan &  a_timeSpan)

Gets a human readable time span.

Parameters:
[in]a_timeSpantime span
Returns:
human readable time span
bool Tonido::Util::registerTonido ( bool  a_sendIPs,
const std::string &  a_tag,
const std::string &  a_url = "" 
)

registerTonido

Parameters:
[in]a_tagtag to use for registration
Returns:
true if success, false otherwise
std::string Tonido::Util::sanitizeSQL ( const std::string &  a_originalString)

Sanitize SQL characters like "'" (single quote) ???

Parameters:
[in]a_originalStringstring to sanitize
Returns:
new string
std::string Tonido::Util::sanitizeString ( const std::string &  a_originalString,
bool  strongClean = true 
)

Cleans strings of all bad stuff, including HTML tags.

Parameters:
[in]a_originalStringstring to clean bad stuff
[in]strongCleantrue if use strong clean, false otherwise
Returns:
new string
bool Tonido::Util::setCustomPermissions ( const std::string &  path,
bool  recursive 
)

setCustomPermissions

Parameters:
[in]pathwhere we want to set permissions
Returns:
true on success, false otherwise
std::string Tonido::Util::setWorkingDirectoryToExePath ( )

Sets the current working directory to be the same as the executable path.

Returns:
current working directory
void Tonido::Util::splitFolder ( const std::string &  a_fullFolderName,
std::string &  a_exeName,
std::string &  a_folderPath 
)

Splits a given file path to fileName and the folder path.

Parameters:
[in]a_fullFolderNamefull file path
[out]a_exeNameoutput exe name
[out]a_folderPathoutput folder path
std::string Tonido::Util::trim ( const std::string &  a_originalString)

Trims leading and trailing spaces of ASCII spaces.

Parameters:
[in]a_originalStringstring to trim spaces
Returns:
new string

Generated on Wed Oct 12 2011 21:46:54. © CodeLathe LLC 2007-2011. All Rights Reserved.