LicenseSystem.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. //
  2. // Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
  3. // LICENSE: Atomic Game Engine Editor and Tools EULA
  4. // Please see LICENSE_ATOMIC_EDITOR_AND_TOOLS.md in repository root for
  5. // license information: https://github.com/AtomicGameEngine/AtomicGameEngine
  6. //
  7. // BEGIN LICENSE MANAGEMENT
  8. #pragma once
  9. #include <Atomic/Core/Object.h>
  10. #include "../Net/CurlManager.h"
  11. using namespace Atomic;
  12. namespace ToolCore
  13. {
  14. class LicenseSystem : public Object
  15. {
  16. OBJECT(LicenseSystem);
  17. public:
  18. struct LicenseParse
  19. {
  20. bool licenseWindows_;
  21. bool licenseMac_;
  22. bool licenseAndroid_;
  23. bool licenseIOS_;
  24. bool licenseHTML5_;
  25. bool licenseModule3D_;
  26. LicenseParse()
  27. {
  28. licenseWindows_ = false;
  29. licenseMac_ = false;
  30. licenseAndroid_ = false;
  31. licenseIOS_ = false;
  32. licenseHTML5_ = false;
  33. licenseModule3D_ = false;
  34. }
  35. };
  36. /// Construct.
  37. LicenseSystem(Context* context);
  38. /// Destruct.
  39. virtual ~LicenseSystem();
  40. void Initialize();
  41. bool GetSourceBuild();
  42. bool GetLicenseWindows() { return licenseWindows_; }
  43. bool GetLicenseMac() { return licenseMac_; }
  44. bool GetLicenseAndroid() { return licenseAndroid_; }
  45. bool GetLicenseIOS() { return licenseIOS_; }
  46. bool GetLicenseHTML5() { return licenseHTML5_; }
  47. bool GetLicenseModule3D() { return licenseModule3D_; }
  48. /// Returns whether there are any platform licenses available
  49. bool IsStandardLicense();
  50. void Activate(const String& key, const LicenseParse& parse);
  51. /// Returns true if request to deactivate is made
  52. bool Deactivate();
  53. void ResetLicense();
  54. bool LoadLicense();
  55. /// Basic key validation
  56. bool ValidateKey(const String &key);
  57. /// Activate on server
  58. void RequestServerActivation(const String& key);
  59. const String& GetKey() { return key_; }
  60. String GenerateMachineID();
  61. String GetEmail() { return email_;}
  62. void LicenseAgreementConfirmed();
  63. int ParseResponse(const String& response, LicenseParse &parse);
  64. private:
  65. void RequestServerVerification(const String& key);
  66. void SaveLicense();
  67. void RemoveLicense();
  68. void CreateOrUpdateLicenseCache();
  69. void HandleVerification(StringHash eventType, VariantMap& eventData);
  70. void HandleDeactivate(StringHash eventType, VariantMap& eventData);
  71. void HandleEditorShutdown(StringHash eventType, VariantMap& eventData);
  72. void HandleActivationResult(StringHash eventType, VariantMap& eventData);
  73. bool eulaAgreementConfirmed_;
  74. String licenseFilePath_;
  75. String licenseCachePath_;
  76. String eulaAgreementPath_;
  77. String key_;
  78. String email_;
  79. bool licenseWindows_;
  80. bool licenseMac_;
  81. bool licenseAndroid_;
  82. bool licenseIOS_;
  83. bool licenseHTML5_;
  84. bool licenseModule3D_;
  85. SharedPtr<CurlRequest> serverActivation_;
  86. SharedPtr<CurlRequest> serverVerification_;
  87. SharedPtr<CurlRequest> deactivate_;
  88. };
  89. }
  90. // END LICENSE MANAGEMENT