Alexa Auto SDK  2.0.0
CBL.h
1 /*
2  * Copyright 2017-2019 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 AACE_CBL_CBL_H
17 #define AACE_CBL_CBL_H
18 
19 #include <iostream>
20 #include "CBLEngineInterface.h"
21 #include "AACE/Core/PlatformInterface.h"
22 
23 namespace aace {
24 namespace cbl {
25 
30 protected:
31  CBL() = default;
32 
33 public:
37  enum class CBLState {
38 
42  STARTING,
43 
48 
53 
58 
63 
67  STOPPING
68  };
69 
73  enum class CBLStateChangedReason {
74 
78  SUCCESS,
79 
83  ERROR,
84 
88  TIMEOUT,
89 
93  CODE_PAIR_EXPIRED,
94 
98  NONE
99  };
100 
101  virtual ~CBL();
102 
106  virtual void cblStateChanged( CBLState state, CBLStateChangedReason reason, const std::string& url, const std::string& code ) = 0;
107 
111  virtual void clearRefreshToken() = 0;
112 
116  virtual void setRefreshToken( const std::string& refreshToken ) = 0;
117 
121  virtual std::string getRefreshToken() = 0;
122 
127  virtual void setUserProfile( const std::string& name, const std::string& email ) = 0;
128 
132  void start();
133 
137  void cancel();
138 
142  void reset();
143 
150  void setEngineInterface( std::shared_ptr<CBLEngineInterface> cblEngineInterface );
151 
152 private:
153  std::shared_ptr<CBLEngineInterface> m_cblEngineInterface;
154 };
155 
156 inline std::ostream& operator<<(std::ostream& stream, const CBL::CBLState& state) {
157  switch ( state ) {
159  stream << "STARTING";
160  break;
162  stream << "REQUESTING_CODE_PAIR";
163  break;
165  stream << "CODE_PAIR_RECEIVED";
166  break;
168  stream << "REFRESHING_TOKEN";
169  break;
171  stream << "REQUESTING_TOKEN";
172  break;
174  stream << "STOPPING";
175  break;
176  }
177  return stream;
178 }
179 
180 inline std::ostream& operator<<(std::ostream& stream, const CBL::CBLStateChangedReason& reason) {
181  switch ( reason ) {
183  stream << "SUCCESS";
184  break;
186  stream << "ERROR";
187  break;
189  stream << "TIMEOUT";
190  break;
192  stream << "CODE_PAIR_EXPIRED";
193  break;
195  stream << "NONE";
196  break;
197  }
198  return stream;
199 }
200 
201 } // aace::cbl
202 } // aace
203 
204 #endif
virtual std::string getRefreshToken()=0
void cancel()
Definition: CBL.cpp:33
CBLStateChangedReason
Definition: CBL.h:73
virtual void cblStateChanged(CBLState state, CBLStateChangedReason reason, const std::string &url, const std::string &code)=0
Definition: PlatformInterface.h:29
virtual void clearRefreshToken()=0
virtual void setRefreshToken(const std::string &refreshToken)=0
Definition: AddressBook.h:26
virtual void setUserProfile(const std::string &name, const std::string &email)=0
CBLState
Definition: CBL.h:37
void reset()
Definition: CBL.cpp:39
void start()
Definition: CBL.cpp:27
Definition: CBL.h:29

Alexa Auto SDK 2.0.0 - Copyright 2017-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0