AlexaClientSDK  1.26.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Classes | Namespaces | Macros | Functions | Variables
SQLiteAlertStorage.cpp File Reference
#include "acsdkAlerts/Storage/SQLiteAlertStorage.h"
#include "acsdkAlerts/Alarm.h"
#include "acsdkAlerts/Reminder.h"
#include "acsdkAlerts/Timer.h"
#include <SQLiteStorage/SQLiteStatement.h>
#include <SQLiteStorage/SQLiteUtils.h>
#include <AVSCommon/Utils/File/FileUtils.h>
#include <AVSCommon/Utils/Logger/Logger.h>
#include <AVSCommon/Utils/Metrics/DataPointCounterBuilder.h>
#include <AVSCommon/Utils/Metrics/MetricEventBuilder.h>
#include <AVSCommon/Utils/String/StringUtils.h>
#include <fstream>
#include <set>
Include dependency graph for SQLiteAlertStorage.cpp:

Classes

struct  alexaClientSDK::acsdkAlerts::storage::AssetOrderItem
 
struct  alexaClientSDK::acsdkAlerts::storage::AssetOrderItemCompare
 

Namespaces

 alexaClientSDK
 Whether or not curl logs should be emitted.
 
 alexaClientSDK::acsdkAlerts
 
 alexaClientSDK::acsdkAlerts::storage
 

Macros

#define LX(event)   alexaClientSDK::avsCommon::utils::logger::LogEntry(TAG, event)
 

Functions

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

Variables

static const std::string alexaClientSDK::acsdkAlerts::storage::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 alexaClientSDK::acsdkAlerts::storage::ALERTS_CAPABILITY_AGENT_DB_FILE_PATH_KEY = "databaseFilePath"
 The key in our config file to find the database file path. More...
 
static const int alexaClientSDK::acsdkAlerts::storage::ALERT_EVENT_TYPE_ALARM = 1
 A definition which we will store in the database to indicate Alarm type. More...
 
static const int alexaClientSDK::acsdkAlerts::storage::ALERT_EVENT_TYPE_TIMER = 2
 A definition which we will store in the database to indicate Timer type. More...
 
static const int alexaClientSDK::acsdkAlerts::storage::ALERT_EVENT_TYPE_REMINDER = 3
 A definition which we will store in the database to indicate Reminder type. More...
 
static const std::string alexaClientSDK::acsdkAlerts::storage::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 alexaClientSDK::acsdkAlerts::storage::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 alexaClientSDK::acsdkAlerts::storage::ALERT_EVENT_TYPE_REMINDER_STRING = "REMINDER"
 This is the string value this code will expect form an Alert of Reminder type. More...
 
static const std::string alexaClientSDK::acsdkAlerts::storage::OFFLINE_STOPPED_ALERT_TOKEN_KEY = "token"
 The value of the offline stopped alert token key. More...
 
static const std::string alexaClientSDK::acsdkAlerts::storage::OFFLINE_STOPPED_ALERT_SCHEDULED_TIME_KEY = "scheduledTime"
 The value of the offline stopped alert scheduledTime key. More...
 
static const std::string alexaClientSDK::acsdkAlerts::storage::OFFLINE_STOPPED_ALERT_EVENT_TIME_KEY = "eventTime"
 The value of the offline stopped alert eventTime key. More...
 
static const std::string alexaClientSDK::acsdkAlerts::storage::OFFLINE_STOPPED_ALERT_ID_KEY = "id"
 The value of the offline stopped alert id key. More...
 
static const int alexaClientSDK::acsdkAlerts::storage::ALERT_STATE_UNSET = 1
 A definition which we will store in the database to indicate an Alert's Unset state. More...
 
static const int alexaClientSDK::acsdkAlerts::storage::ALERT_STATE_SET = 2
 A definition which we will store in the database to indicate an Alert's Set state. More...
 
static const int alexaClientSDK::acsdkAlerts::storage::ALERT_STATE_ACTIVATING = 3
 A definition which we will store in the database to indicate an Alert's Activating state. More...
 
static const int alexaClientSDK::acsdkAlerts::storage::ALERT_STATE_ACTIVE = 4
 A definition which we will store in the database to indicate an Alert's Active state. More...
 
static const int alexaClientSDK::acsdkAlerts::storage::ALERT_STATE_SNOOZING = 5
 A definition which we will store in the database to indicate an Alert's Snoozing state. More...
 
static const int alexaClientSDK::acsdkAlerts::storage::ALERT_STATE_SNOOZED = 6
 A definition which we will store in the database to indicate an Alert's Snoozed state. More...
 
static const int alexaClientSDK::acsdkAlerts::storage::ALERT_STATE_STOPPING = 7
 A definition which we will store in the database to indicate an Alert's Stopping state. More...
 
static const int alexaClientSDK::acsdkAlerts::storage::ALERT_STATE_STOPPED = 8
 A definition which we will store in the database to indicate an Alert's Stopped state. More...
 
static const int alexaClientSDK::acsdkAlerts::storage::ALERT_STATE_COMPLETED = 9
 A definition which we will store in the database to indicate an Alert's Completed state. More...
 
static const int alexaClientSDK::acsdkAlerts::storage::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 alexaClientSDK::acsdkAlerts::storage::DATABASE_COLUMN_ID_NAME = "id"
 The name of the 'id' field we will use as the primary key in our tables. More...
 
static const std::string alexaClientSDK::acsdkAlerts::storage::DATABASE_COLUMN_TOKEN_NAME = "token"
 The name of the 'token' field used in alerts table. More...
 
static const std::string alexaClientSDK::acsdkAlerts::storage::DATABASE_COLUMN_TYPE_NAME = "type"
 The name of the 'type' field used in alerts table. More...
 
static const std::string alexaClientSDK::acsdkAlerts::storage::DATABASE_COLUMN_STATE_NAME = "state"
 The name of the 'state' field used in alerts table. More...
 
static const std::string alexaClientSDK::acsdkAlerts::storage::DATABASE_COLUMN_SCHEDULED_TIME_UNIX_NAME = "scheduled_time_unix"
 The name of the 'scheduled_time_unix' field used in alerts table. More...
 
static const std::string alexaClientSDK::acsdkAlerts::storage::DATABASE_COLUMN_SCHEDULED_TIME_ISO_8601_NAME = "scheduled_time_iso_8601"
 The name of the 'scheduled_time_iso_8601' field used in alerts table. More...
 
static const std::string alexaClientSDK::acsdkAlerts::storage::DATABASE_COLUMN_ASSET_LOOP_COUNT_NAME = "asset_loop_count"
 The name of the 'asset_loop_count' field used in alerts table. More...
 
static const std::string alexaClientSDK::acsdkAlerts::storage::DATABASE_COLUMN_ASSET_LOOP_PAUSE_MILLISECONDS_NAME = "asset_loop_pause_milliseconds"
 The name of the 'asset_loop_pause_milliseconds' field used in alerts table. More...
 
static const std::string alexaClientSDK::acsdkAlerts::storage::DATABASE_COLUMN_BACKGROUND_ASSET_NAME = "background_asset"
 The name of the 'background_asset' field used in alerts table. More...
 
static const std::string alexaClientSDK::acsdkAlerts::storage::DATABASE_COLUMN_ORIGINAL_TIME_NAME = "original_time"
 The name of the 'original_time' field used in alerts table. More...
 
static const std::string alexaClientSDK::acsdkAlerts::storage::DATABASE_COLUMN_LABEL_NAME = "label"
 The name of the 'label' field used in alerts table. More...
 
static const std::string alexaClientSDK::acsdkAlerts::storage::DATABASE_COLUMN_CREATED_TIME_NAME = "created_time_iso_8601"
 The name of the 'created_time_iso_8601' field used in alerts table. More...
 
static const int alexaClientSDK::acsdkAlerts::storage::ALERTS_DATABASE_VERSION_TWO = 2
 A symbolic name for version two of our database. More...
 
static const int alexaClientSDK::acsdkAlerts::storage::ALERTS_DATABASE_VERSION_THREE = 3
 A symbolic name for version three of our database. More...
 
static const std::string alexaClientSDK::acsdkAlerts::storage::ALERTS_V2_TABLE_NAME = "alerts_v2"
 The name of the alerts (v2) table. More...
 
static const std::string alexaClientSDK::acsdkAlerts::storage::ALERTS_V3_TABLE_NAME = "alerts_v3"
 The name of the alerts (v3) table. More...
 
static const std::string alexaClientSDK::acsdkAlerts::storage::CREATE_ALERTS_TABLE_SQL_STRING
 The SQL string to create the alerts table. More...
 
static const std::string alexaClientSDK::acsdkAlerts::storage::ALERT_ASSETS_TABLE_NAME = "alertAssets"
 The name of the alertAssets table. More...
 
static const std::string alexaClientSDK::acsdkAlerts::storage::CREATE_ALERT_ASSETS_TABLE_SQL_STRING
 The SQL string to create the alertAssets table. More...
 
static const std::string alexaClientSDK::acsdkAlerts::storage::OFFLINE_ALERTS_TABLE_NAME = "offlineAlerts"
 The name of the offline alerts (v1) table. More...
 
static const std::string alexaClientSDK::acsdkAlerts::storage::OFFLINE_ALERTS_V2_TABLE_NAME = "offlineAlerts_v2"
 The name of the offline alerts (v2) table. More...
 
static const int alexaClientSDK::acsdkAlerts::storage::OFFLINE_ALERTS_DATABASE_VERSION_ONE = 1
 A symbolic name for version one of our offline alerts database. More...
 
static const int alexaClientSDK::acsdkAlerts::storage::OFFLINE_ALERTS_DATABASE_VERSION_TWO = 2
 A symbolic name for version two of our offline alerts database. More...
 
static const std::string alexaClientSDK::acsdkAlerts::storage::CREATE_OFFLINE_ALERTS_TABLE_SQL_STRING
 The SQL string to create the offline alerts table. More...
 
static const std::string alexaClientSDK::acsdkAlerts::storage::ALERT_ASSET_PLAY_ORDER_ITEMS_TABLE_NAME = "alertAssetPlayOrderItems"
 The name of the alertAssetPlayOrderItems table. More...
 
static const std::string alexaClientSDK::acsdkAlerts::storage::CREATE_ALERT_ASSET_PLAY_ORDER_ITEMS_TABLE_SQL_STRING
 The SQL string to create the alertAssetPlayOrderItems table. More...
 
static const std::string alexaClientSDK::acsdkAlerts::storage::ALERT_METRIC_PREFIX = "ALERT-"
 The prefix for alert metrics. More...
 
static const std::string alexaClientSDK::acsdkAlerts::storage::ALERT_DATABASE_OPEN_FAILED = "databaseOpenFailed"
 The event names for metrics. More...
 
static const std::string alexaClientSDK::acsdkAlerts::storage::OFFLINE_ALERTS_V1ToV2_MIGRATION_FAILED = "offlineAlertsV1ToV2MigrationFailed"
 
static const std::string alexaClientSDK::acsdkAlerts::storage::ALERTS_V2ToV3_MIGRATION_FAILED = "alertsV2ToV3MigrationFailed"
 
static const std::string alexaClientSDK::acsdkAlerts::storage::CREATE_OFFLINE_ALERTS_V2_FAILED = "createOfflineAlertsV2Failed"
 
static const std::string alexaClientSDK::acsdkAlerts::storage::CREATE_ALERTS_V3_FAILED = "createAlertsV3Failed"
 
static const std::string alexaClientSDK::acsdkAlerts::storage::CREATE_DATABASE_FAILED = "createDatabaseFailed"
 
static const std::vector< int > alexaClientSDK::acsdkAlerts::storage::RETRY_TABLE = {10, 20, 40}
 The table with entries for retry times in milliseconds. More...
 
static const size_t alexaClientSDK::acsdkAlerts::storage::RETRY_TIME_MAXIMUM = RETRY_TABLE.size()
 The maximum retry times. More...
 

Macro Definition Documentation

◆ LX

#define LX (   event)    alexaClientSDK::avsCommon::utils::logger::LogEntry(TAG, event)

Create a LogEntry using this file's TAG and the specified event string.

Parameters
Theevent string for this LogEntry.

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