AELicenseSystem.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
  2. // Please see LICENSE.md in repository root for license information
  3. // https://github.com/AtomicGameEngine/AtomicGameEngine
  4. // BEGIN LICENSE MANAGEMENT
  5. #pragma once
  6. #include <Atomic/Core/Object.h>
  7. #include "../AETypes.h"
  8. #include "Net/CurlManager.h"
  9. using namespace Atomic;
  10. namespace AtomicEditor
  11. {
  12. class LicenseSystem : public Object
  13. {
  14. OBJECT(LicenseSystem);
  15. public:
  16. struct LicenseParse
  17. {
  18. bool licenseWindows_;
  19. bool licenseMac_;
  20. bool licenseAndroid_;
  21. bool licenseIOS_;
  22. bool licenseHTML5_;
  23. bool licenseModule3D_;
  24. LicenseParse()
  25. {
  26. licenseWindows_ = false;
  27. licenseMac_ = false;
  28. licenseAndroid_ = false;
  29. licenseIOS_ = false;
  30. licenseHTML5_ = false;
  31. licenseModule3D_ = false;
  32. }
  33. };
  34. /// Construct.
  35. LicenseSystem(Context* context);
  36. /// Destruct.
  37. virtual ~LicenseSystem();
  38. void Initialize();
  39. bool LicenseWindows() { return licenseWindows_; }
  40. bool LicenseMac() { return licenseMac_; }
  41. bool LicenseAndroid() { return licenseAndroid_; }
  42. bool LicenseIOS() { return licenseIOS_; }
  43. bool LicenseHTML5() { return licenseHTML5_; }
  44. bool LicenseModule3D() { return licenseModule3D_; }
  45. /// Returns whether there are any platform licenses available
  46. bool IsStandardLicense();
  47. bool RequestPlatformChange(AEEditorPlatform platform);
  48. void Activate(const String& key, const LicenseParse& parse);
  49. SharedPtr<CurlRequest>& Deactivate();
  50. void ResetLicense();
  51. /// Basic key validation
  52. bool ValidateKey(const String &key);
  53. const String& GetKey() { return key_; }
  54. String GenerateMachineID();
  55. String GetEmail() { return email_;}
  56. void LicenseAgreementConfirmed();
  57. int ParseResponse(const String& response, LicenseParse &parse);
  58. private:
  59. void RequestServerVerification(const String& key);
  60. bool LoadLicense();
  61. void SaveLicense();
  62. void RemoveLicense();
  63. void HandleVerification(StringHash eventType, VariantMap& eventData);
  64. void HandleDeactivate(StringHash eventType, VariantMap& eventData);
  65. void HandleEditorShutdown(StringHash eventType, VariantMap& eventData);
  66. bool eulaAgreementConfirmed_;
  67. String key_;
  68. String email_;
  69. bool licenseWindows_;
  70. bool licenseMac_;
  71. bool licenseAndroid_;
  72. bool licenseIOS_;
  73. bool licenseHTML5_;
  74. bool licenseModule3D_;
  75. SharedPtr<CurlRequest> serverVerification_;
  76. SharedPtr<CurlRequest> deactivate_;
  77. };
  78. }
  79. // END LICENSE MANAGEMENT