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.
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
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 at 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.
The DeltaParams, TableParams, TableStreamParams auxiliary classes contain basic attributes that can be used to set up resuming resource downloading on unsuccessful downloading attempt.
Basic attributes:
Property | Data type | Description |
retryCount | uint | Number of resource downloading repetitions. |
retryInterval | uint | Interval between repetitions. |
The order of using the functionality for resuming resource downloading:
After initializing Sailfish framework in the mobile application folder specify path to the folder with download resumption files.
Enable resuming resource downloading.
Execute resource requesting methods.
Disable resuming resource downloading.
Set path to download resumption file (setFilePath)
The setFilePath method sets path to the folder in the mobile application directory, which will store download resumption files.
void hhive::HHive::setFilePath (
std::string path
)
Input parameter:
Parameter | Data type | Description |
path | String | The path to the folder in mobile application directory, which will store download resumption files. |
Enable and disable resuming resource downloading (useDownload)
The useDownload method enables or disables resuming resource downloading.
void hhive::HHive::useDownload (
bool val
)
Input parameter:
Parameter | Data type | Description |
val | Bool | The checkbox that determines whether resuming resource downloading is used. |
Resuming resource downloading is disabled by default. To enable resuming resource downloading, call the useDownload method and set the input parameter to True; to disable, set the input parameter to False.
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
To load a file to server, use the putFile method:
std::string hhive::HHive::putFile (
std::string mountName,
std::string filename,
std::string localFilename
)
Arguments:
mountName. Mount point name at server
filename. Path to the file at server containing file name.
localFilename. Path to the local file containing local file name.
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
)
Arguments:
mountName. Mount point name at server
filename. Path to the file at server containing file name.
localFilename. Path to the local file containing file name.
The method returns JSON as a string with server response.
Get information about file at server
To get information about file at server, use the getFileMeta method:
std::string hhive::HHive::getFileMeta (
std::string mountName,
std::string filename
)
Arguments:
mountName. Mount point name at server
filename. Path to the file containing file name.
The method returns JSON as a string with server response.
To get directory contents, use the getDirectoryContent method:
std::string hhive::HHive::getDirectoryContent (
std::string mountName,
std::string dirPath
)
Arguments:
mountName. Mount point name at 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.
To delete file at 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 at server.
filename. Path to the file at 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 at 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