Main methods used in the Sailfish framework.
Authenticate the user by login and password
To authenticate the user by login and password, use the "auth" method:
std::string hhive::HHive::auth (
std::string login,
std::string password
)
Arguments:
login. User login.
password. User password.
The method returns JSON as a string with server response.
User authentication with password change
To authenticate user with password change, use the authWithChangePassword method:
std::string hhive::HHive:: authWithChangePassword (
std::string login,
std::string password,
std::string newPassword,
std::string confirmNewPassword,
)
Arguments:
login. User login.
password. User login.
newPassword. New user password.
confirmNewPassword. Repeat new user password.
The method returns JSON as a string with server response.
To get a certificates list, use the getDSSCertificates method:
std::string hhive::HHive::getDSSCertificates (
std::string password
)
Arguments:
password. DSS user password.
The method returns JSON as a string with server response.
To sign a cell, use the signDSSCertificate method:
std::string hhive::HHive::signDSSCertificate (
std::string resource,
std::string tableName,
std::string requestParams,
std::string column,
std::string row,
std::string password,
std::string certificateID,
std::string certificatePin
)
Arguments:
resource. Resource name.
tableName. Table name with server cache.
requestParams. Parameters, with which a request to get data of cached resource was called.
column. Table column name.
hhiveID. Row name.
password. DSS user password.
certificateID. Certificate ID.
certificatePin. Certificate PIN.
The method returns JSON as a string with server response.
Mobile platform server accessibility check
To check mobile platform server accessibility, use the status method:
std::string hhive::HHive:: status (
std::string serverUrl,
)
Arguments:
serverUrl. Mobile platform server URL.
The method returns JSON as a string with server response.
To set mobile platform server URL, use the setUrl method:
void hhive::HHive::setUrl (
std::string url
)
Arguments:
url. Mobile platform server URL.
To get mobile platform server URL, use the url method:
std::string hhive::HHive::url (
)
const
To set API version, use the setApi method:
void hhive::HHive::setApi (
std::string api
)
Arguments:
api. API version.
To set application name, use the setApp method:
void hhive::HHive::setApp (
std::string app
)
Arguments:
app. Application name.
Display framework log in the console (setLogEnabled)
The setLogEnabled method determines whether framework log is displayed in the console.
void hhive::HHive::setLogEnabled (
bool enabled
)
Input parameters:
Parameter | Data type | Description |
enabled | Bool | Determine whether framework log is displayed in the console. Available values:
|
To connect to database, use the openDatabase method:
bool hhive::HHive::openDatabase (
std::string path,
std::string key
)
Arguments:
path. Path to the database containing database name.
key. Database password.
NOTE. Password can be an empty string.
The method returns True if the connection is successful, otherwise the method returns False.
Change database encryption key (reKeyDatabase)
To change database encryption key, use the reKeyDatabase method:
bool hhive::HHive::reKeyDatabase (
std::string path,
std::string key
)
Arguments:
path. Path to the database containing database name.
key. New database encryption key.
NOTE. New database encryption key can be an empty string.
The method returns True if the connection is successful, otherwise the method returns False.
NOTE. Before changing encryption key open the database using the openDatabase or resources method. After closing the mobile application or executing the closeDatabase method, the new database encryption key will be used.
Example:
hh.openDatabase("testDatabase.sqlite3","Key1");
hh.reKeyDatabase("testDatabase.sqlite3","Key2");
hh.closeDatabase("testDatabase.sqlite3");
hh.openDatabase("testDatabase.sqlite3","Key2");
Execute request in opened database
To execute a request in an opened database, use the "query" method:
std::string hhive::HHive::query (
std::string database,
std::string query
)
Arguments:
database. Path to the database containing database name.
query. SQL query.
To get resource tables list, use the getTablesName method:
std::string hhive::HHive::getTablesName ( std::string database,
std::string resource,
std::string params,
std::string tableName
)
Arguments:
database. Path to the database containing database name.
resource. Resource name.
params. Parameters that were used to get resource data.
tableName. Table name on server. It is used to get a specific table in a multi-table resource.
The method returns JSON as a string with table names list.
To delete the saved version of cache by parameters from database, use the dropCache method:
std::string hhive::HHive::dropCache ( std::string database,
std::string resource,
std::string params
)
Arguments:
database. Path to the database containing database name.
resource. Resource name.
params. Parameters that were used to get resource data.
The method returns request execution result as JSON.
To disconnect database, use the closeDatabase method:
bool hhive::HHive::closeDatabase (
std::string path
)
Arguments:
path. Path to the database containing database name.
The method returns True if disconnection was successful, otherwise the method returns False.
The resources method requests a list of all resources:
std::string hhive::HHive::resources (
std::string databasePath
)
Arguments:
databasePath. Database file name.
NOTE. If the file does not exist at the specified path, it is created automatically.
The method saves the obtained resources list to database.
Synchronous request to get resource data with scalar parameters
The deltaStreamRequest method synchronously requests resource data with scalar parameters:
std::string hhive::HHive::deltaStreamRequest (
const std::string & resource,
const DeltaParams & params
)
Arguments:
resource. Resource name.
params. Additional request parameters.
The method returns JSON as a string with server response.
Asynchronous request to get resource data with scalar parameters
The deltaStreamRequestAsync method asynchronously requests resource data with scalar parameters:
std::string hhive::HHive::deltaStreamRequestAsync (
const std::string & resource,
const DeltaParams & params
)
Arguments:
resource. Resource name.
params. Additional request parameters.
The method returns the object std::future<std::string>, to which the JSON string with server response will be written.
Synchronous request to get resource data with table parameters
The tableRequest method synchronously requests resource data with table parameters:
std::string hhive::HHive::tableRequest (
std::string resource,
std::string transactionID,
TableParams params
)
Arguments:
resource. Resource name.
transactionID. Transaction ID.
params. Additional request parameters.
The method returns JSON as a string with server response.
Asynchronous request to get resource data with table parameters
The tableRequestAsync method asynchronously requests resource data with table parameters:
std::string hhive::HHive::tableRequestAsync (
std::string resource,
std::string transactionID,
TableParams params
)
Arguments:
resource. Resource name.
transactionID. Transaction ID.
params. Additional request parameters.
The method returns the object std::future<std::string>, to which the JSON string with server response will be written.
Synchronous request to get resource data with table or scalar parameters
The tableStreamRequest method synchronously requests resource data with table or scalar parameters:
std::string hhive::HHive::tableStreamRequest (
std::string resource,
std::string transactionID,
TableStreamParams params
)
Arguments:
resource. Resource name.
transactionID. Transaction ID.
NOTE. It is set only for resource with table parameters.
params. Additional request parameters.
The method returns JSON as a string with server response.
Asynchronous request to get resource data with table or scalar parameters
The tableStreamRequestAsync method asynchronously requests resource data with table or scalar parameters:
std::string hhive::HHive::tableStreamRequestAsync (
std::string resource,
std::string transactionID,
TableStreamParams params
)
Arguments:
resource. Resource name.
transactionID. Transaction ID.
NOTE. It is set only for resource with table parameters.
params. Additional request parameters.
The method returns the object std::future<std::string>, to which the JSON string with server response will be written.
Resume resource downloading (useDownload)
The useDownload method determines whether resource downloading is resumed.
void hhive::HHive::useDownload (
bool val
)
Input parameter:
Parameter | Data type | Description |
val | Bool | Determine resuming of resource downloading. Available values:
|
The method is used on failed attempt to download resource to resume resource downloading with saving the state at the moment of interruption. If resource downloading has failed or mobile platform server connection is lost, the mobile application keeps requesting resource.
To resume resource downloading, use the retryCount and retryInterval properties of the DeltaParams, TableParams, TableStreamParams auxiliary classes on executing of methods for working with resources.
Order of using resuming of resource downloading:
Specify the path to the folder with files of the current resource downloading state using the setFilePath method after initializing Sailfish framework in the mobile application directory.
Enable resuming of resource downloading. To enable resuming of resource downloading, use the useDownload method with the True value.
Execute necessary methods for working with resources.
Disable resuming of resource downloading. To disable resuming of resource downloading, use the useDownload method with the False value.
Set the path to the folder with files of the current resource downloading state (setFilePath)
The setFilePath method sets the path to the folder in the mobile application directory, which will store files of the current resource downloading state.
void hhive::HHive::setFilePath (
std::string path
)
Input parameter:
Parameter | Data type | Description |
path | String | The path to the folder in the mobile application directory, which will store files of the current resource downloading state. The path is not set by default. |
To set an environment name, use the setEnvironment method:
void hhive::HHive::setEnvironment (
std::string environment
)
Arguments:
environment. Environment name.
To set a project name, use the setProject method:
void hhive::HHive::setProject (
std::string project
)
Arguments:
project. Project name.
To set a device identifier, use the setDevice method:
void hhive::HHive::setDevice (
std::string device
)
Arguments:
device. Device identifier.
To get an environment name, use the "environment" method:
std::string hhive::HHive::environment (
)
const
To get a project name, use the "project" name:
std::string hhive::HHive::project (
)
const
To get a device identifier, use the "device" method:
std::string hhive::HHive::device (
)
const
Upload file to server (putFile)
To load a file to server, use the putFile method:
std::string hhive::HHive::putFile (
std::string mountName,
std::string filename,
std::string localFilename,
std::string password
)
Arguments:
mountName. Mount point name on server.
filename. Path to the file on server containing file name.
localFilename. The path to the local file containing local file name.
password. Encryption password. When the file is sent to server, it is decrypted and is sent in the open format. If password is set as empty, encryption is not applied.
The method returns JSON as a string with server response.
To get a file, use the getFile method:
std::string hhive::HHive::getFile (
std::string mountName,
std::string filename,
std::string localFilename,
std::string password
)
Arguments:
mountName. Mount point name on server.
filename. Path to the file on server containing file name.
localFilename. The path to local file containing file name.
password. Encryption password. When obtained, the file is encrypted and stored encrypted on mobile device. If the password is set as empty, encryption is not applied.
The method returns JSON as a string with server response.
Encryption of file, string, byte array
To encrypt the file to a new file, use the cryptFileToFile method:
bool cryptFileToFile(std::string filename, std::string destFilename, std::string password)
To encrypt the file to a string, use the cryptFileToString method:
std::string cryptFileToString(std::string filename, std::string password)
To encrypt the string to a new file, use the cryptStringToFile method:
bool cryptStringToFile(std::string filename, std::string content,std::string password);
To encrypt the byte array to a new file, use the cryptByteArrayToFile method:
bool cryptByteArrayToFile(std::string filename, std::vector<char> content,std::string password);
To encrypt the string to a new string, use the cryptStringToString method:
std::string cryptStringToString(std::string content, std::string password);
Arguments:
filename. The path to source file. The path to the encrypted file in the method for encrypting byte array to file.
destFilename. The path to the new encrypted file.
password. Encryption password.
content. String or byte array contents.
The methods return JSON as a string with server response.
Decryption of file, string, byte array
To decrypt the file to a new file, use the decryptToFile method:
decryptToFile(std::string filename, std::string destFilename, std::string password)
To decrypt the file to a string, use the decryptToString method:
decryptToString(std::string filename, std::string password)
To decrypt the file to a byte array, use the decryptToByteArray method:
std::vector<char> decryptToByteArray(std::string filename, std::string password)
To decrypt the string to a new file, use the decryptFromStringToFile method:
bool decryptFromStringToFile(std::string content, std::string filename, std::string password);
To decrypt the string to a new string, use the decryptStringToString method:
std::string decryptStringToString(std::string content, std::string password);
Arguments:
filename. The path to source file. The path to the decrypted file in the method for decrypting the string to a new file.
destFilename. The path to the decrypted file.
password. Encryption password.
content. String contents.
The methods return JSON as a string with server response.
Get information about on server (getFileMeta)
To get information about file on server, use the getFileMeta method:
std::string hhive::HHive::getFileMeta (
std::string mountName,
std::string filename
)
Arguments:
mountName. Mount point name on server.
filename. Path to the file containing file name.
The method returns JSON as a string with server response.
Get directory contents (getDirectoryContent)
To get directory contents, use the getDirectoryContent method:
std::string hhive::HHive::getDirectoryContent (
std::string mountName,
std::string dirPath
)
Arguments:
mountName. Mount point name on server.
filename. Path to directory.
The method returns JSON as a string with server response, directory contents as a files list, and folders of the specified directory.
Delete file on server (deleteFile)
To delete file on server, use the deleteFile method:
std::string hhive::HHive::deleteFile (
std::string mountName,
std::string filename
)
NOTE. Local files are not deleted.
Arguments:
mountName. Name of mount point on server.
filename. Path to the file on server containing file name.
Get data about completed transaction
To get data about completed transaction, use the getTransaction method:
std::string hhive::HHive::getTransaction (
std::string resource,
std::string transactionID
)
Arguments:
resource. Resource name.
transactionID. Transaction ID.
The method returns JSON as a string with server response.
Get completed transactions list with table resource
To get completed transactions list with table resource, use the getAllTransaction method:
std::string hhive::HHive::getAllTransaction (
std::string resource
)
Arguments:
resource. Resource name.
To delete transaction on server, use the deleteTransaction method:
std::string hhive::HHive::deleteTransaction (
std::string resource,
std::string transactionID
)
Arguments:
resource. Resource name.
transactionID. Transaction ID.
To initialize and set up the Sailfish framework, see the Initializing and Setting Up Sailfish Framework section.
See also:
Sailfish Framework | Initializing and Setting Up Sailfish Framework | Auxiliary Classes