dca_interface  6.3.4
Options to obtain an initial local database

Using the default local database as part of your distribution

This solution has the advantage that the workflow is completely handled by the API. When your application calls the dca::UpdateModule::performUpdate() and dca::DcaInstance::schedule() functions, a new database will be downloaded and used automatically.
If your application implements a schedule subscriber to receive schedule notifications, your application will be informed when the download starts and completes, and will also be informed of the download progress.
This is the recommended solution, and by default the SCA has empty databases installed, so that this workflow can start straight away.
The only disadvantage here is that no queries on the database will be successful until the complete database has been downloaded.

Install/download a local database as part of your installation

The most recent URL or Mail local signature database can be downloaded by using the dca::UpdateModule::performUpdate and dca::DcaInstance::schedule() functions provided by the API.
Sample code is provided to demonstrate the use of these functions to download a complete database. The code can be found under samples/dbdownloadsample.

Using a remote database connection while downloading a local database

This is the most complex solution. You must first set up a local database connection and associated URL Classifier:
myDbCD.useLocalDatabase = true;
myDbCD.dbType = DBT_Url;
dca::DbConnection myLocalDbConnection = myDca.createDbConnection( myLicense, myDbCD );
UrlDbClassifier myLocalClassifier = myUrlClassification::createDbClassifier( myLocalDbConnection );
G_UrlClassifierToUse = myLocalClassifier;
Next, you must determine whether the database is empty or not. This can be done by examining the version number of a the database once a local database connection has been established. If the version number is set to "6.00000000", an empty database is being used.
If the database is empty, you must set up a remote database connection as detailed in the example program found under samples/urldbsample_remote.
Use this dca::DbConnection to create a new URL Classifier and perform the URL Classification remotely.
DbConnection myRemoteDbConnection;
UrlDbClassifier myRemoteClassifier;
if( myLocalDbConnection.getVersion() == "6.00000000" ) {
// default empty database is being used
// create and use remote connection ...
DbConnectionData myDbCD;
myDbCD.useLocalDatabase = false;
myDbCD.dbType = DBT_Url;
myDbCD.remoteServerData.encryptionKey = "...";
myDbCD.remoteServerData.encryptionData = "...";
myRemoteDbConnection = myDca.createDbConnection( myLicense, myDbCD );
myRemoteClassifier = myUrlClassification::createDbClassifier( remoteDbConnection );
G_UrlClassifierToUse = myRemoteClassifier;
}
Your application must set up dedicated threads to call dca::UpdateModule::performUpdate() and dca::DcaInstance::schedule(). You must also implement a schedule subscriber object to receive notification that a complete database has been downloaded.
Once the schedule subscriber has been notified that a complete database been successfully installed, you must switch from the remote connection to the local connection.
...
UrlDbClassifier G_UrlClassifierToUse;
...
G_UrlClassifierToUse = myRemoteClassifier; // switch to remote
...
G_UrlClassifierToUse = myLocalClassifier; // switch to local
Note
This workflow is usually used only once for the first start of your application.
See also
How to implement updates in a client application, Schedule Subscribers
Stores the connection data for a database.
Definition: base_classes.h:815
Database connection class for a local or remote database.
Definition: base_classes.h:859
bool useLocalDatabase
Set to true to connect to a local or custom database, set to false to use a remote database.
Definition: base_classes.h:821
const DbType DBT_Url
Used for DbConnection classes for URL classification.
DbType dbType
The type of the database.
Definition: base_classes.h:820
DbConnection createDbConnection(const License &aLicense, const DbConnectionData &dbcData, const ProxySettings &proxySettings=ProxySettings(), LogLevel aLogLevel=LOG_Initial) const
Creates a DbConnection object using the given DbConnectionData.