| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- // Copyright (c) 2014-2015, THUNDERBEAST GAMES LLC All rights reserved
- // Please see LICENSE.md in repository root for license information
- // https://github.com/AtomicGameEngine/AtomicGameEngine
- // BEGIN LICENSE MANAGEMENT
- #pragma once
- #include <Atomic/Core/Object.h>
- #include "../Net/CurlManager.h"
- using namespace Atomic;
- namespace ToolCore
- {
- class LicenseSystem : public Object
- {
- OBJECT(LicenseSystem);
- public:
- struct LicenseParse
- {
- bool licenseWindows_;
- bool licenseMac_;
- bool licenseAndroid_;
- bool licenseIOS_;
- bool licenseHTML5_;
- bool licenseModule3D_;
- LicenseParse()
- {
- licenseWindows_ = false;
- licenseMac_ = false;
- licenseAndroid_ = false;
- licenseIOS_ = false;
- licenseHTML5_ = false;
- licenseModule3D_ = false;
- }
- };
- /// Construct.
- LicenseSystem(Context* context);
- /// Destruct.
- virtual ~LicenseSystem();
- void Initialize();
- bool GetSourceBuild();
- bool LicenseWindows() { return licenseWindows_; }
- bool LicenseMac() { return licenseMac_; }
- bool LicenseAndroid() { return licenseAndroid_; }
- bool LicenseIOS() { return licenseIOS_; }
- bool LicenseHTML5() { return licenseHTML5_; }
- bool LicenseModule3D() { return licenseModule3D_; }
- /// Returns whether there are any platform licenses available
- bool IsStandardLicense();
- void Activate(const String& key, const LicenseParse& parse);
- /// Returns true if request to deactivate is made
- bool Deactivate();
- void ResetLicense();
- bool LoadLicense();
- /// Basic key validation
- bool ValidateKey(const String &key);
- /// Activate on server
- void RequestServerActivation(const String& key);
- const String& GetKey() { return key_; }
- String GenerateMachineID();
- String GetEmail() { return email_;}
- void LicenseAgreementConfirmed();
- int ParseResponse(const String& response, LicenseParse &parse);
- private:
- void RequestServerVerification(const String& key);
- void SaveLicense();
- void RemoveLicense();
- void CreateOrUpdateLicenseCache();
- void HandleVerification(StringHash eventType, VariantMap& eventData);
- void HandleDeactivate(StringHash eventType, VariantMap& eventData);
- void HandleEditorShutdown(StringHash eventType, VariantMap& eventData);
- void HandleActivationResult(StringHash eventType, VariantMap& eventData);
- bool eulaAgreementConfirmed_;
- String licenseFilePath_;
- String licenseCachePath_;
- String eulaAgreementPath_;
- String key_;
- String email_;
- bool licenseWindows_;
- bool licenseMac_;
- bool licenseAndroid_;
- bool licenseIOS_;
- bool licenseHTML5_;
- bool licenseModule3D_;
- SharedPtr<CurlRequest> serverActivation_;
- SharedPtr<CurlRequest> serverVerification_;
- SharedPtr<CurlRequest> deactivate_;
- };
- }
- // END LICENSE MANAGEMENT
|