コード例 #1
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;
    }

}
コード例 #2
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;
    }

}