Пример #1
0
bool LicenseSystem::Deactivate()
{
    if (deactivate_.NotNull())
    {
        VariantMap eventData;
        eventData[LicenseDeactivationError::P_MESSAGE] = "LicenseSystem::Deactivate - request already exists";
        SendEvent(E_LICENSE_DEACTIVATIONERROR, eventData);
        return false;
    }

    if (!key_.Length())
    {
        VariantMap eventData;
        eventData[LicenseDeactivationError::P_MESSAGE] = "LicenseSystem::Deactivate - zero length key";
        SendEvent(E_LICENSE_DEACTIVATIONERROR, eventData);
        return false;
    }

    CurlManager* cm = GetSubsystem<CurlManager>();
    String post;
    String id = GenerateMachineID();
    post.AppendWithFormat("key=%s&id=%s", key_.CString(), id.CString());

    deactivate_ = cm->MakeRequest("https://store.atomicgameengine.com/licenses/license_deactivate.php", post);

    SubscribeToEvent(deactivate_, E_CURLCOMPLETE, ATOMIC_HANDLER(LicenseSystem, HandleDeactivate));

    return true;

}
Пример #2
0
SharedPtr<CurlRequest>& LicenseSystem::Deactivate()
{
    if (deactivate_.NotNull())
    {
        LOGERROR("LicenseSystem::Deactivate - request already exists");
        return deactivate_;
    }

    if (!key_.Length())
    {
        LOGERROR("LicenseSystem::Deactivate - zero length key");
        return deactivate_;
    }

    CurlManager* cm = GetSubsystem<CurlManager>();
    String post;
    String id = GenerateMachineID();
    post.AppendWithFormat("key=%s&id=%s", key_.CString(), id.CString());

    deactivate_ = cm->MakeRequest("https://store.atomicgameengine.com/licenses/license_deactivate.php", post);

    SubscribeToEvent(deactivate_, E_CURLCOMPLETE, HANDLER(LicenseSystem, HandleDeactivate));

    return deactivate_;

}
Пример #3
0
void LicenseSystem::RequestServerActivation(const String& key)
{
    if (serverActivation_.NotNull())
    {
        ATOMIC_LOGERROR("UIActivation::RequestServerActivation - request already exists");
        return;
    }
    key_ = key;
    CurlManager* cm = GetSubsystem<CurlManager>();
    String post;
    String id = GenerateMachineID();
    post.AppendWithFormat("key=%s&id=%s", key.CString(), id.CString());

    // todo, this should be a verify url (shouldn't auto add id)
    serverActivation_ = cm->MakeRequest("https://store.atomicgameengine.com/licenses/license_activate.php", post);

    SubscribeToEvent(serverActivation_, E_CURLCOMPLETE, ATOMIC_HANDLER(LicenseSystem, HandleActivationResult));
}
Пример #4
0
void LicenseSystem::RequestServerVerification(const String& key)
{
    if (serverVerification_.NotNull())
    {
        LOGERROR("LicenseSystem::RequestServerLicense - request already exists");
        return;
    }

    key_ = key;
    CurlManager* cm = GetSubsystem<CurlManager>();
    String post;
    String id = GenerateMachineID();
    post.AppendWithFormat("key=%s&id=%s", key.CString(), id.CString());

    serverVerification_ = cm->MakeRequest("https://store.atomicgameengine.com/licenses/license_verify.php", post);

    SubscribeToEvent(serverVerification_, E_CURLCOMPLETE, HANDLER(LicenseSystem, HandleVerification));
}
Пример #5
0
void LicenseSystem::RequestServerVerification(const String& key)
{
    if (serverVerification_.NotNull())
    {
        ATOMIC_LOGERROR("LicenseSystem::RequestServerLicense - request already exists");
        return;
    }

    FileSystem* fileSystem = GetSubsystem<FileSystem>();

    if (fileSystem->FileExists(licenseCachePath_))
    {
        Time* time = GetSubsystem<Time>();
        unsigned currentTime = time->GetTimeSinceEpoch();
        unsigned fileTime = fileSystem->GetLastModifiedTime(licenseCachePath_);
        unsigned deltaMinutes = (currentTime - fileTime)/60;
        if (deltaMinutes < 1)
        {
            ATOMIC_LOGINFOF("%u minutes, using cached license", deltaMinutes);
            SendEvent(E_LICENSE_SUCCESS);
            return;
        }
    }

    ATOMIC_LOGINFO("LicenseSystem::RequestServerLicense - requesting verification");

    key_ = key;
    CurlManager* cm = GetSubsystem<CurlManager>();
    String post;
    String id = GenerateMachineID();
    post.AppendWithFormat("key=%s&id=%s", key.CString(), id.CString());

    serverVerification_ = cm->MakeRequest("https://store.atomicgameengine.com/licenses/license_verify.php", post);

    SubscribeToEvent(serverVerification_, E_CURLCOMPLETE, ATOMIC_HANDLER(LicenseSystem, HandleVerification));
}