All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ApiTokenValidator.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include <string>
6 
7 #include "Types.h"
8 #include "Web.h"
9 #include "WebLoadRequestCompletionCallback.h"
10 #include "NativeUIFactories.h"
11 #include "IEegeoErrorHandler.h"
12 #include "PendingWebRequestsContainer.h"
13 #include "CallbackCollection.h"
14 
15 namespace Eegeo
16 {
17  namespace Web
18  {
20  {
21  public:
23  (
24  Eegeo::Web::IWebLoadRequestFactory& webLoadRequestFactory,
25  Eegeo::UI::NativeUIFactories& nativeInputFactories,
26  Eegeo::IEegeoErrorHandler* m_pErrorHandler,
27  WebConnectivityValidator& webConnectivityValidator
28  );
30 
31  void PerformInitialOptimisticValidation(const std::string& apiToken);
32  bool IsWaitingForInitialOptimisticValidation() const;
33 
34  void Validate(const std::string& apiToken);
35  bool IsValid() const;
36 
37  void RegisterCallback(Helpers::ICallback1<const bool>& callback);
38  void UnregisterCallback(Helpers::ICallback1<const bool>& callback);
39 
40  private:
41  IWebLoadRequestFactory& m_webLoadRequestFactory;
42  Eegeo::UI::NativeUIFactories& m_nativeInputFactories;
43  WebConnectivityValidator& m_webConnectivityValidator;
44  Eegeo::IEegeoErrorHandler* m_pErrorHandler;
45  bool m_isValid;
47  Web::PendingWebRequestsContainer m_pendingWebRequestsContainer;
48  Eegeo::Helpers::CallbackCollection1<const bool> m_apiKeyValidatedCallbacks;
49  Eegeo::Helpers::TCallback0<ApiTokenValidator> m_onWebConnectivityChanged;
50  std::vector<Byte> m_initialResponse;
51  bool m_isInitialOptimisticCheckInFlight;
52  bool m_isWaitingForConnectivityResult;
53 
54  void ApiValidationHandler(Eegeo::Web::IWebResponse& webResponse);
55  void ValidateResponse(const std::vector<Byte>& responseData);
56  void OnWebConnectivityChanged();
57  };
58  }
59 }
60 
61