void LicenseSystem::HandleActivationResult(StringHash eventType, VariantMap& eventData) { VariantMap eventDataOut; if (serverActivation_->GetError().Length()) { String errorMessage; errorMessage.AppendWithFormat("There was an error contacting the activation server\n\n%s", serverActivation_->GetError().CString()); eventDataOut[LicenseActivationError::P_MESSAGE] = errorMessage; SendEvent(E_LICENSE_ACTIVATIONERROR, eventDataOut); return; } else { LicenseParse parse; int code = ParseResponse(serverActivation_->GetResponse(), parse); if (code == 0) { Activate(key_, parse); SendEvent(E_LICENSE_ACTIVATIONSUCCESS); } else if (code == 1) { // TODO: check for CLI and prompt to use CLI command to return license String message = "Activations Exceeded:\nThis key has 2 activations in use.\n\nPlease return a license from Atomic Editor - Manage License menu on one of these active computers.\n\nIf you are unable to do so, please contact [email protected] providing the key to reset it"; eventDataOut[LicenseActivationError::P_MESSAGE] = message; SendEvent(E_LICENSE_ACTIVATIONERROR, eventDataOut); } else if (code == 2) { String message = "License Error:\nThere was a problem with the license key.\n\nPlease check the key and try again.\n\nIf the problem persists please contact [email protected]"; eventDataOut[LicenseActivationError::P_MESSAGE] = message; SendEvent(E_LICENSE_ACTIVATIONERROR, eventDataOut); } else if (code == 3) { String message ="Activation Server Error:\nThere was an error on the activation server\n\nIf the problem persists please contact [email protected]"; eventDataOut[LicenseActivationError::P_MESSAGE] = message; SendEvent(E_LICENSE_ACTIVATIONERROR, eventDataOut); } } UnsubscribeFromEvents(serverActivation_); serverActivation_ = 0; }
void LicenseSystem::HandleDeactivate(StringHash eventType, VariantMap& eventData) { Editor* editor = GetSubsystem<Editor>(); CurlRequest* request = (CurlRequest*) (eventData[CurlComplete::P_CURLREQUEST].GetPtr()); if (deactivate_.NotNull()) { assert(request == deactivate_); if (deactivate_->GetError().Length()) { String msg; msg.AppendWithFormat("Unable to deactivate with server: %s", deactivate_->GetError().CString()); editor->PostModalError("Deactivation Error", msg); LOGERROR(msg); } else { String response = request->GetResponse(); if (response.StartsWith("AC_FAILED")) { String msg; msg.AppendWithFormat("Unable to deactivate with server: %s", response.CString()); editor->PostModalError("Deactivation Error", msg); LOGERROR(msg); } else if (response.StartsWith("AC_NOTACTIVATED") || response.StartsWith("AC_SUCCESS")) { ResetLicense(); RemoveLicense(); UIModalOps* ops = GetSubsystem<UIModalOps>(); ops->Hide(); ops->ShowActivation(); } } UnsubscribeFromEvents(deactivate_); deactivate_ = 0; } }
void LicenseSystem::HandleDeactivate(StringHash eventType, VariantMap& eventData) { CurlRequest* request = (CurlRequest*) (eventData[CurlComplete::P_CURLREQUEST].GetPtr()); VariantMap eventDataOut; if (deactivate_.NotNull()) { assert(request == deactivate_); if (deactivate_->GetError().Length()) { String msg = "Deactivation Error:\n"; msg.AppendWithFormat("Unable to deactivate with server: %s", deactivate_->GetError().CString()); eventDataOut[LicenseDeactivationError::P_MESSAGE] = msg; SendEvent(E_LICENSE_DEACTIVATIONERROR, eventDataOut); } else { String response = request->GetResponse(); if (response.StartsWith("AC_FAILED")) { String msg = "Deactivation Error:\n"; msg.AppendWithFormat("Unable to deactivate with server: %s", response.CString()); eventDataOut[LicenseDeactivationError::P_MESSAGE] = msg; SendEvent(E_LICENSE_DEACTIVATIONERROR, eventDataOut); } else if (response.StartsWith("AC_NOTACTIVATED") || response.StartsWith("AC_SUCCESS")) { ResetLicense(); RemoveLicense(); SendEvent(E_LICENSE_DEACTIVATIONSUCCESS); } } UnsubscribeFromEvents(deactivate_); deactivate_ = 0; } }
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; } }