AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
AVSGatewayManager.h
Go to the documentation of this file.
1 /*
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License").
5  * You may not use this file except in compliance with the License.
6  * A copy of the License is located at
7  *
8  * http://aws.amazon.com/apache2.0/
9  *
10  * or in the "license" file accompanying this file. This file is distributed
11  * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12  * express or implied. See the License for the specific language governing
13  * permissions and limitations under the License.
14  */
15 
16 #ifndef ALEXA_CLIENT_SDK_AVSGATEWAYMANAGER_INCLUDE_AVSGATEWAYMANAGER_AVSGATEWAYMANAGER_H_
17 #define ALEXA_CLIENT_SDK_AVSGATEWAYMANAGER_INCLUDE_AVSGATEWAYMANAGER_AVSGATEWAYMANAGER_H_
18 
19 #include <memory>
20 #include <mutex>
21 #include <string>
22 #include <unordered_set>
23 
33 
34 namespace alexaClientSDK {
35 namespace avsGatewayManager {
36 
51 public:
63  static std::shared_ptr<avsCommon::sdkInterfaces::AVSGatewayManagerInterface> createAVSGatewayManagerInterface(
64  std::unique_ptr<storage::AVSGatewayManagerStorageInterface> avsGatewayManagerStorage,
65  const std::shared_ptr<avsCommon::sdkInterfaces::AuthDelegateInterface>& authDelegate,
66  const std::shared_ptr<registrationManager::CustomerDataManagerInterface>& customerDataManager,
67  const std::shared_ptr<avsCommon::utils::configuration::ConfigurationNode>& configurationRoot,
68  const std::shared_ptr<
70  providerRegistrar,
71  std::shared_ptr<avsCommon::utils::metrics::MetricRecorderInterface> metricRecorder);
72 
84  static std::shared_ptr<AVSGatewayManager> create(
85  std::shared_ptr<storage::AVSGatewayManagerStorageInterface> avsGatewayManagerStorage,
86  std::shared_ptr<registrationManager::CustomerDataManagerInterface> customerDataManager,
88  std::shared_ptr<avsCommon::sdkInterfaces::AuthDelegateInterface> authDelegate = nullptr,
89  std::shared_ptr<avsCommon::utils::metrics::MetricRecorderInterface> metricRecorder = nullptr);
90 
94  std::shared_ptr<avsCommon::sdkInterfaces::AVSGatewayAssignerInterface> avsGatewayAssigner) override;
95  std::string getGatewayURL() const override;
96  bool setGatewayURL(const std::string& avsGatewayURL) override;
97  void addObserver(std::shared_ptr<avsCommon::sdkInterfaces::AVSGatewayObserverInterface> observer) override;
98  void removeObserver(std::shared_ptr<avsCommon::sdkInterfaces::AVSGatewayObserverInterface> observer) override;
100 
103  std::shared_ptr<avsCommon::sdkInterfaces::PostConnectOperationInterface> createPostConnectOperation() override;
105 
108  void clearData() override;
110 
117  void onGatewayVerified(
118  const std::shared_ptr<avsCommon::sdkInterfaces::PostConnectOperationInterface>& verifyGatewaySender);
119 
124 
125 private:
135  std::shared_ptr<storage::AVSGatewayManagerStorageInterface> avsGatewayManagerStorage,
136  std::shared_ptr<registrationManager::CustomerDataManagerInterface> customerDataManager,
137  std::shared_ptr<avsCommon::sdkInterfaces::AuthDelegateInterface> authDelegate,
138  std::shared_ptr<avsCommon::utils::metrics::MetricRecorderInterface> metricRecorder,
139  const std::string& defaultGateway);
140 
146  bool init();
147 
154  bool saveStateLocked();
155 
157  std::shared_ptr<storage::AVSGatewayManagerStorageInterface> m_avsGatewayStorage;
158 
160  std::shared_ptr<avsCommon::sdkInterfaces::AVSGatewayAssignerInterface> m_avsGatewayAssigner;
161 
163  std::shared_ptr<avsCommon::utils::metrics::MetricRecorderInterface> m_metricRecorder;
164 
166  mutable std::mutex m_mutex;
167 
169  std::shared_ptr<avsCommon::sdkInterfaces::PostConnectOperationInterface> m_currentVerifyGatewaySender;
170 
172  const std::shared_ptr<avsCommon::sdkInterfaces::AuthDelegateInterface> m_authDelegate;
173 
175  GatewayVerifyState m_currentState;
176 
178  std::unordered_set<std::shared_ptr<avsCommon::sdkInterfaces::AVSGatewayObserverInterface>> m_observers;
179 };
180 
181 } // namespace avsGatewayManager
182 } // namespace alexaClientSDK
183 
184 #endif // ALEXA_CLIENT_SDK_AVSGATEWAYMANAGER_INCLUDE_AVSGATEWAYMANAGER_AVSGATEWAYMANAGER_H_
void addObserver(std::shared_ptr< avsCommon::sdkInterfaces::AVSGatewayObserverInterface > observer) override
bool setGatewayURL(const std::string &avsGatewayURL) override
::std::string string
Definition: gtest-port.h:1097
void removeObserver(std::shared_ptr< avsCommon::sdkInterfaces::AVSGatewayObserverInterface > observer) override
static std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface > metricRecorder
Metric recorder shared ptr.
Definition: BaseAPLCapabilityAgentTest.cpp:261
bool setAVSGatewayAssigner(std::shared_ptr< avsCommon::sdkInterfaces::AVSGatewayAssignerInterface > avsGatewayAssigner) override
static std::shared_ptr< avsCommon::sdkInterfaces::AVSGatewayManagerInterface > createAVSGatewayManagerInterface(std::unique_ptr< storage::AVSGatewayManagerStorageInterface > avsGatewayManagerStorage, const std::shared_ptr< avsCommon::sdkInterfaces::AuthDelegateInterface > &authDelegate, const std::shared_ptr< registrationManager::CustomerDataManagerInterface > &customerDataManager, const std::shared_ptr< avsCommon::utils::configuration::ConfigurationNode > &configurationRoot, const std::shared_ptr< acsdkPostConnectOperationProviderRegistrarInterfaces::PostConnectOperationProviderRegistrarInterface > &providerRegistrar, std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface > metricRecorder)
Whether or not curl logs should be emitted.
Definition: AVSConnectionManager.h:36
std::shared_ptr< avsCommon::sdkInterfaces::PostConnectOperationInterface > createPostConnectOperation() override
Definition: PostConnectOperationProviderInterface.h:30
Definition: PostConnectOperationProviderRegistrarInterface.h:32
void onGatewayVerified(const std::shared_ptr< avsCommon::sdkInterfaces::PostConnectOperationInterface > &verifyGatewaySender)
static std::shared_ptr< AVSGatewayManager > create(std::shared_ptr< storage::AVSGatewayManagerStorageInterface > avsGatewayManagerStorage, std::shared_ptr< registrationManager::CustomerDataManagerInterface > customerDataManager, const avsCommon::utils::configuration::ConfigurationNode &configurationRoot, std::shared_ptr< avsCommon::sdkInterfaces::AuthDelegateInterface > authDelegate=nullptr, std::shared_ptr< avsCommon::utils::metrics::MetricRecorderInterface > metricRecorder=nullptr)

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