OnlineUnlockStatus not unlocking when applying a valid expiry time

Hey Guys,

I have just started looking into using the onlineUnlockStatus class. It works very nicely for a permanent unlock. However, I am finding that it is not working so well once I add an expiry time. It seems that the isUnlocked() method is never returning true even with a valid expiry time.

I have done my best to look through and understand the JUCE code and I think that there may be a problem in the following.

bool OnlineUnlockStatus::applyKeyFile (String keyFileContent)
    KeyFileUtils::KeyFileData data;
    data = KeyFileUtils::getDataFromKeyFile (KeyFileUtils::getXmlFromKeyFile (keyFileContent, getPublicKey()));

    if (data.licensee.isNotEmpty() && && doesProductIDMatch (data.appID))
        setUserEmail (;
        status.setProperty (keyfileDataProp, keyFileContent, nullptr);
        status.removeProperty (data.keyFileExpires ? expiryTimeProp : unlockedProp, nullptr);

        var actualResult (0), dummyResult (1.0);
        var v (machineNumberAllowed (data.machineNumbers, getLocalMachineIDs()));
        actualResult.swapWith (v);
        v = machineNumberAllowed (StringArray ("01"), getLocalMachineIDs());
        dummyResult.swapWith (v);
        jassert (! dummyResult);

        if (data.keyFileExpires)
            if ((! dummyResult) && actualResult)
                status.setProperty (expiryTimeProp, data.expiryTime.toMilliseconds(), nullptr);

            return getExpiryTime().toMilliseconds() > 0;

        if ((! dummyResult) && actualResult)
            status.setProperty (unlockedProp, actualResult, nullptr);

        return isUnlocked();

    return false;

the expiry time is stored when data.keyFileExpires is true. However, it seems strange to return true here if the expiry time is greater than zero. Although, technically a valid key file has been received at this point, wouldn’t it be preferable to return true here only when the expiry time is greater than the current time?

Also, the expiry time does not seem to be checked as part of the OnlineUnlockStatus::isUnlocked() function and I can’t see any code that updates unlockedProp based on the expiry time either.

inline var isUnlocked() const { return status[unlockedProp]; }

Hopefully I am not missing something obvious. Let me know what you think!



Yeah, it’s done like that deliberately so you can disambiguate between a “full” authorisation and an “expiring demo” authorisation.

In Waveform her have something that looks like this:

bool enableAllFeatures()
    if (unlocker.isUnlocked())
        return true;

    if (unlocker.hasDemoExpired())
        return false;

    if (unlocker.isInDemoMode())
        return true;

    return false;

(N.B. this is a big paraphrase and not what our code is in reality, in reality this logic gives a description to the user of their “authorisation status” which is why we need to know if they have started a demo period but it has since expired).

TL;DR: use isUnlocked in combination with getExpiryTime to determine what functionality to enable and what messages to show the user.

Ah, that makes so much more sense now!

Thanks Dave :sunglasses: