-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
April 2022 Release of the APL 1.9 compliant APL Client Library
For more details on this release refer to CHANGELOG.md To learn about APL see: https://developer.amazon.com/docs/alexa-presentation-language/understand-apl.html
- Loading branch information
Robin Chen
committed
Apr 8, 2022
1 parent
ac96cbc
commit 53ed721
Showing
86 changed files
with
750 additions
and
638 deletions.
There are no files selected for viewing
92 changes: 92 additions & 0 deletions
92
APLClient/include/APLClient/Extensions/AttentionSystem/AplAttentionSystemExtension.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0/ | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
#ifndef APLCLIENT_EXTENSIONS_ATTENTIONSYSTEM_H | ||
#define APLCLIENT_EXTENSIONS_ATTENTIONSYSTEM_H | ||
|
||
#include "APLClient/Extensions/AplCoreExtensionInterface.h" | ||
|
||
namespace APLClient { | ||
namespace Extensions { | ||
namespace AttentionSystem { | ||
|
||
enum class AttentionState { | ||
IDLE, | ||
LISTENING, | ||
THINKING, | ||
SPEAKING | ||
}; | ||
|
||
static const std::string URI = "aplext:attentionsystem:10"; | ||
|
||
/** | ||
* The Attention system extension allows APL developers the ability to react to changes in the attention system state. | ||
*/ | ||
class AplAttentionSystemExtension : | ||
public AplCoreExtensionInterface, | ||
public std::enable_shared_from_this<AplAttentionSystemExtension> { | ||
|
||
public: | ||
AplAttentionSystemExtension(); | ||
|
||
/// @name AplCoreExtensionInterface Functions | ||
/// @{ | ||
std::string getUri() override; | ||
|
||
apl::Object getEnvironment() override; | ||
|
||
std::list<apl::ExtensionCommandDefinition> getCommandDefinitions() override; | ||
|
||
std::list<apl::ExtensionEventHandler> getEventHandlers() override; | ||
|
||
std::unordered_map<std::string, apl::LiveObjectPtr> getLiveDataObjects() override; | ||
|
||
void applySettings(const apl::Object &settings) override; | ||
/// @} | ||
|
||
/// @name AplCoreExtensionEventCallbackInterface Functions | ||
/// @{ | ||
void onExtensionEvent( | ||
const std::string& uri, | ||
const std::string& name, | ||
const apl::Object& source, | ||
const apl::Object& params, | ||
unsigned int event, | ||
std::shared_ptr<AplCoreExtensionEventCallbackResultInterface> resultCallback = nullptr | ||
) override; | ||
/// @} | ||
|
||
/** | ||
* Call to invoke the OnAttentionStateChanged ExtensionEventHandler and update the AttentionSystemState apl::LiveMap. | ||
* It is expected that this is called on every change in the AttentionSystem's attention state. | ||
* | ||
* @param state The system's attention state | ||
*/ | ||
void updateAttentionSystemState(const AttentionState& state); | ||
private: | ||
/// The document settings defined 'name' for the attentionSystemState data object | ||
std::string m_attentionSystemStateName; | ||
|
||
/// The @c apl::LiveMap for AttentionSystem attentionSystemState data. | ||
apl::LiveMapPtr m_attentionSystemState; | ||
}; | ||
|
||
using AplAttentionSystemExtensionionPtr = std::shared_ptr<AplAttentionSystemExtension>; | ||
|
||
} // namespace AttentionSystem | ||
} // namespace Extensions | ||
} // namespace APLClient | ||
|
||
#endif //APLCLIENT_EXTENSIONS_ATTENTIONSYSTEM_H |
76 changes: 0 additions & 76 deletions
76
APLClient/include/APLClient/Extensions/E2EEncryption/AplE2EEncryptionExtension.h
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
APLClient/src/Extensions/AttentionSystem/AplAttentionSystemExtension.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0/ | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
#include "APLClient/Extensions/AttentionSystem/AplAttentionSystemExtension.h" | ||
|
||
namespace APLClient { | ||
namespace Extensions { | ||
namespace AttentionSystem { | ||
|
||
/// String to identify log entries originating from this file. | ||
static const std::string TAG("AplAttentionSystemExtension"); | ||
|
||
static const std::map<AttentionState, std::string> attentionStateMapping = { | ||
{AttentionState::IDLE, "IDLE"}, | ||
{AttentionState::LISTENING, "LISTENING"}, | ||
{AttentionState::THINKING, "THINKING"}, | ||
{AttentionState::SPEAKING, "SPEAKING"} | ||
}; | ||
|
||
static const std::string SETTING_ATTENTION_SYSTEM_STATE_NAME = "attentionSystemStateName"; | ||
static const std::string PROPERTY_ATTENTION_STATE = "attentionState"; | ||
static const std::string EVENTHANDLER_ON_ATTENTION_STATE_CHANGED = "OnAttentionStateChanged"; | ||
|
||
AplAttentionSystemExtension::AplAttentionSystemExtension() { | ||
m_attentionSystemStateName = ""; | ||
m_attentionSystemState = apl::LiveMap::create(); | ||
m_attentionSystemState->set(PROPERTY_ATTENTION_STATE, "IDLE"); | ||
} | ||
|
||
std::string AplAttentionSystemExtension::getUri() { | ||
return URI; | ||
} | ||
|
||
apl::Object AplAttentionSystemExtension::getEnvironment() { | ||
auto env = std::make_shared<apl::ObjectMap>(); | ||
|
||
env->emplace("version", "1.0"); | ||
|
||
return apl::Object(env); | ||
} | ||
|
||
std::list<apl::ExtensionCommandDefinition> AplAttentionSystemExtension::getCommandDefinitions() { | ||
return std::list<apl::ExtensionCommandDefinition>(); | ||
} | ||
|
||
std::list<apl::ExtensionEventHandler> AplAttentionSystemExtension::getEventHandlers() { | ||
std::list<apl::ExtensionEventHandler> extensionEventHandlers( | ||
{ | ||
apl::ExtensionEventHandler(URI, EVENTHANDLER_ON_ATTENTION_STATE_CHANGED) | ||
} | ||
); | ||
return extensionEventHandlers; | ||
} | ||
|
||
std::unordered_map<std::string, apl::LiveObjectPtr> AplAttentionSystemExtension::getLiveDataObjects() { | ||
auto liveObjects = std::unordered_map<std::string, apl::LiveObjectPtr>(); | ||
if (!m_attentionSystemStateName.empty()) { | ||
liveObjects.emplace(m_attentionSystemStateName, m_attentionSystemState); | ||
} | ||
return liveObjects; | ||
} | ||
|
||
void AplAttentionSystemExtension::applySettings(const apl::Object &settings) { | ||
// Reset to defaults | ||
m_attentionSystemStateName = ""; | ||
/// Apply @c apl::Content defined settings | ||
logMessage(apl::LogLevel::kInfo, TAG, __func__, settings.toDebugString()); | ||
if (settings.isMap()) { | ||
if (settings.has(SETTING_ATTENTION_SYSTEM_STATE_NAME)) { | ||
m_attentionSystemStateName = settings.get(SETTING_ATTENTION_SYSTEM_STATE_NAME).getString(); | ||
} | ||
} | ||
} | ||
|
||
void AplAttentionSystemExtension::onExtensionEvent( | ||
const std::string& uri, | ||
const std::string& name, | ||
const apl::Object& source, | ||
const apl::Object& params, | ||
unsigned int event, | ||
std::shared_ptr<AplCoreExtensionEventCallbackResultInterface> resultCallback) { | ||
} | ||
|
||
void AplAttentionSystemExtension::updateAttentionSystemState(const AttentionState& state) { | ||
m_attentionSystemState->set(PROPERTY_ATTENTION_STATE, attentionStateMapping.at(state)); | ||
|
||
if (!m_eventHandler) { | ||
logMessage(apl::LogLevel::kWarn, TAG, __func__, "No Event Handler"); | ||
return; | ||
} | ||
|
||
auto attentionState = apl::ObjectMap({{ | ||
PROPERTY_ATTENTION_STATE, | ||
attentionStateMapping.at(state) | ||
}}); | ||
|
||
m_eventHandler->invokeExtensionEventHandler( | ||
URI, | ||
EVENTHANDLER_ON_ATTENTION_STATE_CHANGED, | ||
attentionState, | ||
true | ||
); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.