void LicenseSystem::Activate(const String& key, const LicenseParse& parse) { key_ = key; licenseWindows_ = parse.licenseWindows_; licenseMac_ = parse.licenseMac_; licenseAndroid_ = parse.licenseAndroid_; licenseIOS_= parse.licenseIOS_; licenseHTML5_= parse.licenseHTML5_; licenseModule3D_= parse.licenseModule3D_; SaveLicense(); }
void LicenseSystem::HandleVerification(StringHash eventType, VariantMap& eventData) { CurlRequest* request = (CurlRequest*) (eventData[CurlComplete::P_CURLREQUEST].GetPtr()); bool licenseError = false; bool resetLicense = false; if (serverVerification_.NotNull()) { assert(request == serverVerification_); if (serverVerification_->GetError().Length()) { ATOMIC_LOGERRORF("Unable to verify with server: %s", serverVerification_->GetError().CString()); } else { LicenseParse parse; int code = ParseResponse(serverVerification_->GetResponse(), parse); if (code == 4) { // not activated resetLicense = true; licenseError = true; } else if (code == 2) { // something is wrong with the key resetLicense = true; licenseError = true; } else if (code == 3) { // something is wrong on the activation server licenseError = true; } else if (code == 1) { // exceeded code, should not happen here as we aren't activating resetLicense = true; licenseError = true; } else if (code == 0) { // we should raise an error if there is a mismatch between local and server keys // when the local says there are more enabled than server? // otherwise, they could be being added bool mismatch = false; if (parse.licenseWindows_ != licenseWindows_) mismatch = true; if (parse.licenseMac_ != licenseMac_) mismatch = true; if (parse.licenseWindows_ != licenseWindows_) mismatch = true; if (parse.licenseAndroid_ != licenseAndroid_) mismatch = true; if (parse.licenseIOS_ != licenseIOS_) mismatch = true; if (parse.licenseHTML5_ != licenseHTML5_) mismatch = true; if (parse.licenseModule3D_ != licenseModule3D_) mismatch = true; if (mismatch) { ATOMIC_LOGERROR("License Mismatch, reseting"); licenseWindows_ = parse.licenseWindows_; licenseMac_ = parse.licenseMac_; licenseAndroid_ = parse.licenseAndroid_; licenseIOS_= parse.licenseIOS_; licenseHTML5_= parse.licenseHTML5_; licenseModule3D_= parse.licenseModule3D_; SaveLicense(); } CreateOrUpdateLicenseCache(); SendEvent(E_LICENSE_SUCCESS); } } UnsubscribeFromEvents(serverVerification_); serverVerification_ = 0; } if (resetLicense) { RemoveLicense(); ResetLicense(); } if (licenseError) { ATOMIC_LOGINFO("There was an issue with the atomic-cli activation. Please reactivate or contact [email protected] if this problem persists"); SendEvent(E_LICENSE_ERROR); } }
void LicenseSystem::HandleVerification(StringHash eventType, VariantMap& eventData) { CurlRequest* request = (CurlRequest*) (eventData[CurlComplete::P_CURLREQUEST].GetPtr()); if (serverVerification_.NotNull()) { assert(request == serverVerification_); if (serverVerification_->GetError().Length()) { LOGERRORF("Unable to verify with server: %s", serverVerification_->GetError().CString()); } else { LicenseParse parse; int code = ParseResponse(serverVerification_->GetResponse(), parse); // Not activated if (code == 4) { } else if (code == 2) { // something is wrong with the key LOGERRORF("Error with product key"); RemoveLicense(); ResetLicense(); UIModalOps* ops = GetSubsystem<UIModalOps>(); ops->Hide(); ops->ShowActivation(); } else if (code == 3) { // something is wrong on the activation server key_ = ""; } else if (code == 1) { // exceeded code, should not happen here as we aren't activating key_ = ""; } else if (code == 0) { // we should raise an error if there is a mismatch between local and server keys // when the local says there are more enabled than server? // otherwise, they could be being added bool mismatch = false; if (parse.licenseWindows_ != licenseWindows_) mismatch = true; if (parse.licenseMac_ != licenseMac_) mismatch = true; if (parse.licenseWindows_ != licenseWindows_) mismatch = true; if (parse.licenseAndroid_ != licenseAndroid_) mismatch = true; if (parse.licenseIOS_ != licenseIOS_) mismatch = true; if (parse.licenseHTML5_ != licenseHTML5_) mismatch = true; if (parse.licenseModule3D_ != licenseModule3D_) mismatch = true; if (mismatch) { LOGERROR("License Mismatch, reseting"); licenseWindows_ = parse.licenseWindows_; licenseMac_ = parse.licenseMac_; licenseAndroid_ = parse.licenseAndroid_; licenseIOS_= parse.licenseIOS_; licenseHTML5_= parse.licenseHTML5_; licenseModule3D_= parse.licenseModule3D_; SaveLicense(); } //if (!HasPlatformLicense()) //{ // UIModalOps* ops = GetSubsystem<UIModalOps>(); // if (!ops->ModalActive()) // ops->ShowPlatformsInfo(); // } } } UnsubscribeFromEvents(serverVerification_); serverVerification_ = 0; } }