AlexaClientSDK  1.19.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Classes | Functions | Variables
alexaClientSDK::capabilityAgents::alerts::storage Namespace Reference

Classes

class  AlertStorageInterface
 
struct  AssetOrderItem
 
struct  AssetOrderItemCompare
 
class  SQLiteAlertStorage
 

Functions

static const std::string TAG ("SQLiteAlertStorage")
 String to identify log entries originating from this file. More...
 
static bool alertTypeToDbField (const std::string &alertType, int *dbType)
 
static bool alertStateToDbField (Alert::State state, int *dbState)
 
static bool dbFieldToAlertState (int dbState, Alert::State *state)
 
static bool createAlertsTable (SQLiteDatabase *db)
 
static bool createAlertAssetsTable (SQLiteDatabase *db)
 
static bool createAlertAssetPlayOrderItemsTable (SQLiteDatabase *db)
 
static bool storeAlertAssets (SQLiteDatabase *db, int alertId, const std::unordered_map< std::string, Alert::Asset > &assets)
 
static bool storeAlertAssetPlayOrderItems (SQLiteDatabase *db, int alertId, const std::vector< std::string > &assetPlayOrderItems)
 
static bool loadAlertAssets (SQLiteDatabase *db, std::map< int, std::vector< Alert::Asset >> *alertAssetsMap)
 
static bool loadAlertAssetPlayOrderItems (SQLiteDatabase *db, std::map< int, std::set< AssetOrderItem, AssetOrderItemCompare >> *alertAssetOrderItemsMap)
 
static bool eraseAlert (SQLiteDatabase *db, int alertId)
 
static bool eraseAlertAssets (SQLiteDatabase *db, int alertId)
 
static bool eraseAlertAssetPlayOrderItems (SQLiteDatabase *db, int alertId)
 
static bool eraseAlertByAlertId (SQLiteDatabase *db, int alertId)
 
static void printOneLineSummary (SQLiteDatabase *db)
 
static void printAlertsSummary (SQLiteDatabase *db, const std::vector< std::shared_ptr< Alert >> &alerts, bool shouldPrintEverything=false)
 

Variables

static const std::string ALERTS_CAPABILITY_AGENT_CONFIGURATION_ROOT_KEY = "alertsCapabilityAgent"
 The key in our config file to find the root of settings for this Capability Agent. More...
 
static const std::string ALERTS_CAPABILITY_AGENT_DB_FILE_PATH_KEY = "databaseFilePath"
 The key in our config file to find the database file path. More...
 
static const int ALERT_EVENT_TYPE_ALARM = 1
 A definition which we will store in the database to indicate Alarm type. More...
 
static const int ALERT_EVENT_TYPE_TIMER = 2
 A definition which we will store in the database to indicate Timer type. More...
 
static const int ALERT_EVENT_TYPE_REMINDER = 3
 A definition which we will store in the database to indicate Reminder type. More...
 
static const std::string ALERT_EVENT_TYPE_ALARM_STRING = "ALARM"
 This is the string value this code will expect form an Alert of Alarm type. More...
 
static const std::string ALERT_EVENT_TYPE_TIMER_STRING = "TIMER"
 This is the string value this code will expect form an Alert of Timer type. More...
 
static const std::string ALERT_EVENT_TYPE_REMINDER_STRING = "REMINDER"
 This is the string value this code will expect form an Alert of Reminder type. More...
 
static const int ALERT_STATE_UNSET = 1
 A definition which we will store in the database to indicate an Alert's Unset state. More...
 
static const int ALERT_STATE_SET = 2
 A definition which we will store in the database to indicate an Alert's Set state. More...
 
static const int ALERT_STATE_ACTIVATING = 3
 A definition which we will store in the database to indicate an Alert's Activating state. More...
 
static const int ALERT_STATE_ACTIVE = 4
 A definition which we will store in the database to indicate an Alert's Active state. More...
 
static const int ALERT_STATE_SNOOZING = 5
 A definition which we will store in the database to indicate an Alert's Snoozing state. More...
 
static const int ALERT_STATE_SNOOZED = 6
 A definition which we will store in the database to indicate an Alert's Snoozed state. More...
 
static const int ALERT_STATE_STOPPING = 7
 A definition which we will store in the database to indicate an Alert's Stopping state. More...
 
static const int ALERT_STATE_STOPPED = 8
 A definition which we will store in the database to indicate an Alert's Stopped state. More...
 
static const int ALERT_STATE_COMPLETED = 9
 A definition which we will store in the database to indicate an Alert's Completed state. More...
 
static const int ALERT_STATE_READY = 10
 A definition which we will store in the database to indicate an Alert's Ready state. More...
 
static const std::string DATABASE_COLUMN_ID_NAME = "id"
 The name of the 'id' field we will use as the primary key in our tables. More...
 
static const int ALERTS_DATABASE_VERSION_ONE = 1
 A symbolic name for version one of our database. More...
 
static const int ALERTS_DATABASE_VERSION_TWO = 2
 A symbolic name for version two of our database. More...
 
static const std::string ALERTS_TABLE_NAME = "alerts"
 The name of the alerts table. More...
 
static const std::string ALERTS_V2_TABLE_NAME = "alerts_v2"
 The name of the alerts (v2) table. More...
 
static const std::string CREATE_ALERTS_TABLE_SQL_STRING
 The SQL string to create the alerts table. More...
 
static const std::string ALERT_ASSETS_TABLE_NAME = "alertAssets"
 The name of the alertAssets table. More...
 
static const std::string CREATE_ALERT_ASSETS_TABLE_SQL_STRING
 The SQL string to create the alertAssets table. More...
 
static const std::string ALERT_ASSET_PLAY_ORDER_ITEMS_TABLE_NAME = "alertAssetPlayOrderItems"
 The name of the alertAssetPlayOrderItems table. More...
 
static const std::string CREATE_ALERT_ASSET_PLAY_ORDER_ITEMS_TABLE_SQL_STRING
 The SQL string to create the alertAssetPlayOrderItems table. More...
 

Function Documentation

◆ alertStateToDbField()

static bool alexaClientSDK::capabilityAgents::alerts::storage::alertStateToDbField ( Alert::State  state,
int *  dbState 
)
static

Utility function to convert an alert state into a value we can store in the database.

Parameters
stateThe state of an alert.
[out]dbStateThe destination of the converted state which may be stored in a database.
Returns
Whether the state was successfully converted.

◆ alertTypeToDbField()

static bool alexaClientSDK::capabilityAgents::alerts::storage::alertTypeToDbField ( const std::string &  alertType,
int *  dbType 
)
static

Utility function to convert an alert type string into a value we can store in the database.

Parameters
alertTypeA string reflecting the type of an alert.
[out]dbTypeThe destination of the converted type which may be stored in a database.
Returns
Whether the type was successfully converted.

◆ createAlertAssetPlayOrderItemsTable()

static bool alexaClientSDK::capabilityAgents::alerts::storage::createAlertAssetPlayOrderItemsTable ( SQLiteDatabase db)
static

Utility function to create the AlertAssetPlayOrderItems table within the database.

Parameters
dbThe SQLiteDatabase object.
Returns
Whether the table was successfully created.

◆ createAlertAssetsTable()

static bool alexaClientSDK::capabilityAgents::alerts::storage::createAlertAssetsTable ( SQLiteDatabase db)
static

Utility function to create the AlertAssets table within the database.

Parameters
dbThe SQLiteDatabase object.
Returns
Whether the table was successfully created.

◆ createAlertsTable()

static bool alexaClientSDK::capabilityAgents::alerts::storage::createAlertsTable ( SQLiteDatabase db)
static

Utility function to create the Alerts table within the database.

Parameters
dbThe SQLiteDatabase object.
Returns
Whether the table was successfully created.

◆ dbFieldToAlertState()

static bool alexaClientSDK::capabilityAgents::alerts::storage::dbFieldToAlertState ( int  dbState,
Alert::State state 
)
static

Utility function to convert a database value for an alert state into its Alert equivalent.

Parameters
dbStateThe state of an alert, as stored in the database.
[out]dbStateThe destination of the converted state.
Returns
Whether the database value was successfully converted.

◆ eraseAlert()

static bool alexaClientSDK::capabilityAgents::alerts::storage::eraseAlert ( SQLiteDatabase db,
int  alertId 
)
static

A utility function to delete alert records from the database for a given alert id. This function will clean up records in the alerts table.

Parameters
dbThe database object.
alertIdThe alert id of the alert to be deleted.
Returns
Whether the delete operation was successful.

◆ eraseAlertAssetPlayOrderItems()

static bool alexaClientSDK::capabilityAgents::alerts::storage::eraseAlertAssetPlayOrderItems ( SQLiteDatabase db,
int  alertId 
)
static

A utility function to delete alert records from the database for a given alert id. This function will clean up records in the alertAssetPlayOrderItems table.

Parameters
dbThe database object.
alertIdThe alert id of the alert to be deleted.
Returns
Whether the delete operation was successful.

◆ eraseAlertAssets()

static bool alexaClientSDK::capabilityAgents::alerts::storage::eraseAlertAssets ( SQLiteDatabase db,
int  alertId 
)
static

A utility function to delete alert records from the database for a given alert id. This function will clean up records in the alertAssets table.

Parameters
dbThe database object.
alertIdThe alert id of the alert to be deleted.
Returns
Whether the delete operation was successful.

◆ eraseAlertByAlertId()

static bool alexaClientSDK::capabilityAgents::alerts::storage::eraseAlertByAlertId ( SQLiteDatabase db,
int  alertId 
)
static

A utility function to delete an alert from the database for a given alert id. This will clean up records in all tables which are associated with the alert.

Parameters
dbThe DB object.
alertIdThe alert id of the alert to be deleted.
Returns
Whether the delete operation was successful.

◆ loadAlertAssetPlayOrderItems()

static bool alexaClientSDK::capabilityAgents::alerts::storage::loadAlertAssetPlayOrderItems ( SQLiteDatabase db,
std::map< int, std::set< AssetOrderItem, AssetOrderItemCompare >> *  alertAssetOrderItemsMap 
)
static

Reads the assets order from the database and stores this data on the given map.

Parameters
dbThe database object to read data from.
alertAssetOrderItemsMapThe map that will receive data.
Returns
true if data was loaded successfully from the database

◆ loadAlertAssets()

static bool alexaClientSDK::capabilityAgents::alerts::storage::loadAlertAssets ( SQLiteDatabase db,
std::map< int, std::vector< Alert::Asset >> *  alertAssetsMap 
)
static

Loads asset data into the map.

Parameters
dbThe database object to read data from.
alertAssetsMapThe map that will receive the assets.
Returns
true if data was loaded successfully

◆ printAlertsSummary()

static void alexaClientSDK::capabilityAgents::alerts::storage::printAlertsSummary ( SQLiteDatabase db,
const std::vector< std::shared_ptr< Alert >> &  alerts,
bool  shouldPrintEverything = false 
)
static

Utility diagnostic function to print the details of all the alerts stored in the database.

Parameters
dbThe database object.
shouldPrintEverythingIf true, then all details of an alert will be printed. If false, then summary information will be printed instead.

◆ printOneLineSummary()

static void alexaClientSDK::capabilityAgents::alerts::storage::printOneLineSummary ( SQLiteDatabase db)
static

Utility diagnostic function to print a one-line summary of all alerts in the database.

Parameters
dbThe database object.

◆ storeAlertAssetPlayOrderItems()

static bool alexaClientSDK::capabilityAgents::alerts::storage::storeAlertAssetPlayOrderItems ( SQLiteDatabase db,
int  alertId,
const std::vector< std::string > &  assetPlayOrderItems 
)
static

◆ storeAlertAssets()

static bool alexaClientSDK::capabilityAgents::alerts::storage::storeAlertAssets ( SQLiteDatabase db,
int  alertId,
const std::unordered_map< std::string, Alert::Asset > &  assets 
)
static

◆ TAG()

static const std::string alexaClientSDK::capabilityAgents::alerts::storage::TAG ( "SQLiteAlertStorage"  )
static

String to identify log entries originating from this file.

Variable Documentation

◆ ALERT_ASSET_PLAY_ORDER_ITEMS_TABLE_NAME

const std::string alexaClientSDK::capabilityAgents::alerts::storage::ALERT_ASSET_PLAY_ORDER_ITEMS_TABLE_NAME = "alertAssetPlayOrderItems"
static

The name of the alertAssetPlayOrderItems table.

◆ ALERT_ASSETS_TABLE_NAME

const std::string alexaClientSDK::capabilityAgents::alerts::storage::ALERT_ASSETS_TABLE_NAME = "alertAssets"
static

The name of the alertAssets table.

◆ ALERT_EVENT_TYPE_ALARM

const int alexaClientSDK::capabilityAgents::alerts::storage::ALERT_EVENT_TYPE_ALARM = 1
static

A definition which we will store in the database to indicate Alarm type.

◆ ALERT_EVENT_TYPE_ALARM_STRING

const std::string alexaClientSDK::capabilityAgents::alerts::storage::ALERT_EVENT_TYPE_ALARM_STRING = "ALARM"
static

This is the string value this code will expect form an Alert of Alarm type.

◆ ALERT_EVENT_TYPE_REMINDER

const int alexaClientSDK::capabilityAgents::alerts::storage::ALERT_EVENT_TYPE_REMINDER = 3
static

A definition which we will store in the database to indicate Reminder type.

◆ ALERT_EVENT_TYPE_REMINDER_STRING

const std::string alexaClientSDK::capabilityAgents::alerts::storage::ALERT_EVENT_TYPE_REMINDER_STRING = "REMINDER"
static

This is the string value this code will expect form an Alert of Reminder type.

◆ ALERT_EVENT_TYPE_TIMER

const int alexaClientSDK::capabilityAgents::alerts::storage::ALERT_EVENT_TYPE_TIMER = 2
static

A definition which we will store in the database to indicate Timer type.

◆ ALERT_EVENT_TYPE_TIMER_STRING

const std::string alexaClientSDK::capabilityAgents::alerts::storage::ALERT_EVENT_TYPE_TIMER_STRING = "TIMER"
static

This is the string value this code will expect form an Alert of Timer type.

◆ ALERT_STATE_ACTIVATING

const int alexaClientSDK::capabilityAgents::alerts::storage::ALERT_STATE_ACTIVATING = 3
static

A definition which we will store in the database to indicate an Alert's Activating state.

◆ ALERT_STATE_ACTIVE

const int alexaClientSDK::capabilityAgents::alerts::storage::ALERT_STATE_ACTIVE = 4
static

A definition which we will store in the database to indicate an Alert's Active state.

◆ ALERT_STATE_COMPLETED

const int alexaClientSDK::capabilityAgents::alerts::storage::ALERT_STATE_COMPLETED = 9
static

A definition which we will store in the database to indicate an Alert's Completed state.

◆ ALERT_STATE_READY

const int alexaClientSDK::capabilityAgents::alerts::storage::ALERT_STATE_READY = 10
static

A definition which we will store in the database to indicate an Alert's Ready state.

◆ ALERT_STATE_SET

const int alexaClientSDK::capabilityAgents::alerts::storage::ALERT_STATE_SET = 2
static

A definition which we will store in the database to indicate an Alert's Set state.

◆ ALERT_STATE_SNOOZED

const int alexaClientSDK::capabilityAgents::alerts::storage::ALERT_STATE_SNOOZED = 6
static

A definition which we will store in the database to indicate an Alert's Snoozed state.

◆ ALERT_STATE_SNOOZING

const int alexaClientSDK::capabilityAgents::alerts::storage::ALERT_STATE_SNOOZING = 5
static

A definition which we will store in the database to indicate an Alert's Snoozing state.

◆ ALERT_STATE_STOPPED

const int alexaClientSDK::capabilityAgents::alerts::storage::ALERT_STATE_STOPPED = 8
static

A definition which we will store in the database to indicate an Alert's Stopped state.

◆ ALERT_STATE_STOPPING

const int alexaClientSDK::capabilityAgents::alerts::storage::ALERT_STATE_STOPPING = 7
static

A definition which we will store in the database to indicate an Alert's Stopping state.

◆ ALERT_STATE_UNSET

const int alexaClientSDK::capabilityAgents::alerts::storage::ALERT_STATE_UNSET = 1
static

A definition which we will store in the database to indicate an Alert's Unset state.

◆ ALERTS_CAPABILITY_AGENT_CONFIGURATION_ROOT_KEY

const std::string alexaClientSDK::capabilityAgents::alerts::storage::ALERTS_CAPABILITY_AGENT_CONFIGURATION_ROOT_KEY = "alertsCapabilityAgent"
static

The key in our config file to find the root of settings for this Capability Agent.

◆ ALERTS_CAPABILITY_AGENT_DB_FILE_PATH_KEY

const std::string alexaClientSDK::capabilityAgents::alerts::storage::ALERTS_CAPABILITY_AGENT_DB_FILE_PATH_KEY = "databaseFilePath"
static

The key in our config file to find the database file path.

◆ ALERTS_DATABASE_VERSION_ONE

const int alexaClientSDK::capabilityAgents::alerts::storage::ALERTS_DATABASE_VERSION_ONE = 1
static

A symbolic name for version one of our database.

◆ ALERTS_DATABASE_VERSION_TWO

const int alexaClientSDK::capabilityAgents::alerts::storage::ALERTS_DATABASE_VERSION_TWO = 2
static

A symbolic name for version two of our database.

◆ ALERTS_TABLE_NAME

const std::string alexaClientSDK::capabilityAgents::alerts::storage::ALERTS_TABLE_NAME = "alerts"
static

The name of the alerts table.

◆ ALERTS_V2_TABLE_NAME

const std::string alexaClientSDK::capabilityAgents::alerts::storage::ALERTS_V2_TABLE_NAME = "alerts_v2"
static

The name of the alerts (v2) table.

◆ CREATE_ALERT_ASSET_PLAY_ORDER_ITEMS_TABLE_SQL_STRING

const std::string alexaClientSDK::capabilityAgents::alerts::storage::CREATE_ALERT_ASSET_PLAY_ORDER_ITEMS_TABLE_SQL_STRING
static
Initial value:
= std::string("CREATE TABLE ") +
"id INT PRIMARY KEY NOT NULL," +
"alert_id INT NOT NULL," +
"asset_play_order_position INT NOT NULL," +
"asset_play_order_token TEXT NOT NULL);"
static const std::string ALERT_ASSET_PLAY_ORDER_ITEMS_TABLE_NAME
The name of the alertAssetPlayOrderItems table.
Definition: SQLiteAlertStorage.cpp:133

The SQL string to create the alertAssetPlayOrderItems table.

◆ CREATE_ALERT_ASSETS_TABLE_SQL_STRING

const std::string alexaClientSDK::capabilityAgents::alerts::storage::CREATE_ALERT_ASSETS_TABLE_SQL_STRING
static
Initial value:
= std::string("CREATE TABLE ") +
"id INT PRIMARY KEY NOT NULL," +
"alert_id INT NOT NULL," +
"avs_id TEXT NOT NULL," +
"url TEXT NOT NULL);"
static const std::string ALERT_ASSETS_TABLE_NAME
The name of the alertAssets table.
Definition: SQLiteAlertStorage.cpp:121

The SQL string to create the alertAssets table.

◆ CREATE_ALERTS_TABLE_SQL_STRING

const std::string alexaClientSDK::capabilityAgents::alerts::storage::CREATE_ALERTS_TABLE_SQL_STRING
static
Initial value:
= std::string("CREATE TABLE ") +
DATABASE_COLUMN_ID_NAME + " INT PRIMARY KEY NOT NULL," +
"token TEXT NOT NULL," +
"type INT NOT NULL," +
"state INT NOT NULL," +
"scheduled_time_unix INT NOT NULL," +
"scheduled_time_iso_8601 TEXT NOT NULL," +
"asset_loop_count INT NOT NULL," +
"asset_loop_pause_milliseconds INT NOT NULL," +
"background_asset TEXT NOT NULL);"
static const std::string DATABASE_COLUMN_ID_NAME
The name of the &#39;id&#39; field we will use as the primary key in our tables.
Definition: SQLiteAlertStorage.cpp:93
static const std::string ALERTS_V2_TABLE_NAME
The name of the alerts (v2) table.
Definition: SQLiteAlertStorage.cpp:104

The SQL string to create the alerts table.

◆ DATABASE_COLUMN_ID_NAME

const std::string alexaClientSDK::capabilityAgents::alerts::storage::DATABASE_COLUMN_ID_NAME = "id"
static

The name of the 'id' field we will use as the primary key in our tables.

AlexaClientSDK 1.19.0 - Copyright 2016-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0