LicenseSystem.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 "../Net/CurlManager.h"
  8. using namespace Atomic;
  9. namespace ToolCore
  10. {
  11. class LicenseSystem : public Object
  12. {
  13. OBJECT(LicenseSystem);
  14. public:
  15. struct LicenseParse
  16. {
  17. bool licenseWindows_;
  18. bool licenseMac_;
  19. bool licenseAndroid_;
  20. bool licenseIOS_;
  21. bool licenseHTML5_;
  22. bool licenseModule3D_;
  23. LicenseParse()
  24. {
  25. licenseWindows_ = false;
  26. licenseMac_ = false;
  27. licenseAndroid_ = false;
  28. licenseIOS_ = false;
  29. licenseHTML5_ = false;
  30. licenseModule3D_ = false;
  31. }
  32. };
  33. /// Construct.
  34. LicenseSystem(Context* context);
  35. /// Destruct.
  36. virtual ~LicenseSystem();
  37. void Initialize();
  38. bool LicenseWindows() { return licenseWindows_; }
  39. bool LicenseMac() { return licenseMac_; }
  40. bool LicenseAndroid() { return licenseAndroid_; }
  41. bool LicenseIOS() { return licenseIOS_; }
  42. bool LicenseHTML5() { return licenseHTML5_; }
  43. bool LicenseModule3D() { return licenseModule3D_; }
  44. /// Returns whether there are any platform licenses available
  45. bool IsStandardLicense();
  46. void Activate(const String& key, const LicenseParse& parse);
  47. SharedPtr<CurlRequest>& Deactivate();
  48. void ResetLicense();
  49. /// Basic key validation
  50. bool ValidateKey(const String &key);
  51. const String& GetKey() { return key_; }
  52. String GenerateMachineID();
  53. String GetEmail() { return email_;}
  54. void LicenseAgreementConfirmed();
  55. int ParseResponse(const String& response, LicenseParse &parse);
  56. private:
  57. void RequestServerVerification(const String& key);
  58. bool LoadLicense();
  59. void SaveLicense();
  60. void RemoveLicense();
  61. void HandleVerification(StringHash eventType, VariantMap& eventData);
  62. void HandleDeactivate(StringHash eventType, VariantMap& eventData);
  63. void HandleEditorShutdown(StringHash eventType, VariantMap& eventData);
  64. bool eulaAgreementConfirmed_;
  65. String key_;
  66. String email_;
  67. bool licenseWindows_;
  68. bool licenseMac_;
  69. bool licenseAndroid_;
  70. bool licenseIOS_;
  71. bool licenseHTML5_;
  72. bool licenseModule3D_;
  73. SharedPtr<CurlRequest> serverVerification_;
  74. SharedPtr<CurlRequest> deactivate_;
  75. };
  76. }
  77. // END LICENSE MANAGEMENT