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 | |
Generally useful Utility functions.
| void Tonido::Util::addEndingSeparator | ( | const std::string & | a_dirName, |
| std::string & | a_dirWithPathSeparator | ||
| ) |
Adds a separator to the path, if it is not there.
| [in] | a_dirName | folder name |
| [out] | a_dirWithPathSeparator | output 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.
| [in] | a_url | url to add separator for |
| [out] | a_urlWithSeparator | output url with separator |
| std::string Tonido::Util::allowBROnly | ( | const std::string & | a_originalHTML | ) |
Cleans strings only allowing
tags.
| [in] | a_originalHTML | HTML text to clean strings |
| 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.
| [in] | args | message to check the authentication for |
| [in] | a_source | message source |
| [in] | a_role | message role |
| [in] | a_location | message location |
| [in] | a_authContext | auth context |
| 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
| [in] | a_originalHTML | HTML text to clean bad stuff |
| [in] | isStrict | true if use strict clean, false otherwise |
| 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)
| [in] | a_version | first string |
| [in] | a_systemVersion | second string |
| [in] | a_lessThan | if true check for less, otherwise check for above |
| std::string Tonido::Util::convertPathToNative | ( | const std::string & | a_file | ) |
Converts a given path to native path.
| [in] | a_file | path to convert |
| std::string Tonido::Util::convertPathToNonNative | ( | const std::string & | a_file | ) |
Converts a given path to non native path.
| [in] | a_file | path to convert |
| std::string Tonido::Util::convertPathToWindows | ( | const std::string & | a_path | ) |
Converts a given path to windows format.
| [in] | a_path | path to convert |
| Poco::UUID Tonido::Util::createUUIDFromString | ( | const std::string & | a_string | ) |
Creates UUID from a given string.
| [in] | a_string | buffer to create UUID for |
| Poco::UUID Tonido::Util::generateUUID | ( | ) |
Creates UUID safely without conflicts.
| std::string Tonido::Util::getDesktopPath | ( | ) |
Gets the Desktop Path.
| std::string Tonido::Util::getDirectoryListXML | ( | const std::string & | directory | ) |
Gets the list of directories in a directory as XML.
| [in] | directory | directory to read |
| std::string Tonido::Util::getExtension | ( | const std::string & | a_Name | ) |
getExtension
| [in] | a_name | name of the file |
| 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.
| [in] | a_fileName | filename of the file to compute the CRC checksum for |
| [out] | a_checksum | generated checksum |
| [in] | a_offset | starting file offset, -1 means beginning of the file |
| [in] | a_length | length to use |
| std::string Tonido::Util::getFileEntryXML | ( | const std::string & | a_path, |
| int | favoriteListID, | ||
| int | favoriteID, | ||
| int | order, | ||
| const std::string & | a_filter | ||
| ) |
getFileEntryXML
| [in] | a_name | name of the file |
| 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.
| [in] | file | directory to read |
| 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.
| [in] | file | directory to read |
| std::string Tonido::Util::getFolderImage | ( | const std::string & | a_path | ) |
getFolderImage
| [in] | a_name | path |
| std::string Tonido::Util::getMacID | ( | ) |
getMacID
| [in] | none |
| 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.
| [in] | a_fileName | filename of the file to compute the MD5 checksum for |
| [out] | a_checksum | generated checksum |
| [in] | a_offset | starting file offset, -1 means beginning of the file |
| [in] | a_length | length to use |
| bool Tonido::Util::getPrivateIPAddress | ( | std::string & | a_host, |
| bool & | isLoopback | ||
| ) |
Gets the Private IP Address of this host.
| [out] | a_host | output host address |
| [out] | isLoopback | true if it is localhost, false otherwise |
| std::string Tonido::Util::getPublicBaseURL | ( | ) |
getPublicBaseURL
| [in] | none |
| std::string Tonido::Util::getSHA1Hash | ( | const std::string & | a_value | ) |
Gets the SHA1 Hash for a given string.
| [in] | a_value | buffer to compute the MD5 checksum for |
| std::string Tonido::Util::getUserHomePath | ( | ) |
Gets the User Home Path.
| bool Tonido::Util::isAllowedFile | ( | const std::string & | a_name | ) |
isAllowedFile
| [in] | a_name | name of the file |
| bool Tonido::Util::isAllowedPath | ( | const std::string & | a_path, |
| bool | a_strict = false |
||
| ) |
isAllowedPath
| [in] | a_path | name of the path that allows certain operations |
| bool Tonido::Util::isAlpha | ( | const std::string & | a_string | ) |
Checks if a given string contains only alphabets.
| [in] | a_string | string to check alphabets |
| bool Tonido::Util::isAlphaNumeric | ( | const std::string & | a_string | ) |
Checks if a given string contains only alphabets and numbers.
| [in] | a_string | string to check alphabets and numbers |
| bool Tonido::Util::isAlphaSpace | ( | const std::string & | a_string | ) |
Checks if a given string contains only Alphabets or space.
| [in] | a_string | string to check alphabets or space |
| bool Tonido::Util::isDirMounted | ( | const std::string & | a_dir | ) |
isDirMounted
| [in] | a_dir | directory to check if available |
| bool Tonido::Util::isEmailID | ( | const std::string & | a_string | ) |
Checks if a given string is a valid email id.
| [in] | a_string | string to check email id |
| bool Tonido::Util::isNumeric | ( | const std::string & | a_string | ) |
Checks if a given string contains only numbers.
| [in] | a_string | string to check numbers |
| 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
| [in] | a_string | string to check alphabets or space |
| bool Tonido::Util::largeFileSeekg | ( | Poco::FileInputStream * | a_stream, |
| int64_bt | a_offset | ||
| ) |
Safe Large File Seek for files larger than 2 GB.
| [in,out] | a_stream | file stream |
| [in] | a_offset | file offset |
| bool Tonido::Util::largeFileSeekp | ( | Poco::FileOutputStream * | a_stream, |
| int64_bt | a_offset | ||
| ) |
Safe Large File Seek for files larger than 2 GB.
| [in,out] | a_stream | file stream |
| [in] | a_offset | file offset |
| void Tonido::Util::launchDefaultBrowser | ( | const std::string & | a_url | ) |
Launches the default web browser.
| [in] | a_url | url to start browser for |
| std::string Tonido::Util::localNiceTimeStrFromUTCTime | ( | const Poco::DateTime & | a_utcDate | ) |
Get Local Time string from UTC time.
| [in] | a_utcDate | UTC time |
| std::string Tonido::Util::localTimeStrFromUTCStr | ( | const std::string & | a_utcString | ) |
Get Local Time string from UTC time string.
| [in] | a_utcString | UTC time string |
| std::string Tonido::Util::localTimeStrFromUTCTime | ( | const Poco::DateTime & | a_utcDate | ) |
Get Local Time string from UTC time.
| [in] | a_utcDate | UTC time |
| std::string Tonido::Util::readableFileSize | ( | int64_bt | a_fileSize, |
| int | a_precision = 2 |
||
| ) |
Gets a human readable file size.
| [in] | a_fileSize | file size |
| [in] | a_precision | precision |
| std::string Tonido::Util::readableTimeSpan | ( | Poco::Timespan & | a_timeSpan | ) |
Gets a human readable time span.
| [in] | a_timeSpan | time span |
| bool Tonido::Util::registerTonido | ( | bool | a_sendIPs, |
| const std::string & | a_tag, | ||
| const std::string & | a_url = "" |
||
| ) |
registerTonido
| [in] | a_tag | tag to use for registration |
| std::string Tonido::Util::sanitizeSQL | ( | const std::string & | a_originalString | ) |
Sanitize SQL characters like "'" (single quote) ???
| [in] | a_originalString | string to sanitize |
| std::string Tonido::Util::sanitizeString | ( | const std::string & | a_originalString, |
| bool | strongClean = true |
||
| ) |
Cleans strings of all bad stuff, including HTML tags.
| [in] | a_originalString | string to clean bad stuff |
| [in] | strongClean | true if use strong clean, false otherwise |
| bool Tonido::Util::setCustomPermissions | ( | const std::string & | path, |
| bool | recursive | ||
| ) |
setCustomPermissions
| [in] | path | where we want to set permissions |
| std::string Tonido::Util::setWorkingDirectoryToExePath | ( | ) |
Sets the current working directory to be the same as the executable path.
| 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.
| [in] | a_fullFolderName | full file path |
| [out] | a_exeName | output exe name |
| [out] | a_folderPath | output folder path |
| std::string Tonido::Util::trim | ( | const std::string & | a_originalString | ) |
Trims leading and trailing spaces of ASCII spaces.
| [in] | a_originalString | string to trim spaces |