Message on "Quit and Free License"
-
Is there some way to receive a message, and run a function, when a users presses "Quit and Free License"?
-
Hey @kbar,
Thank you for reaching out to us. In the public API there is only what you can find in Plugin Licensing Manual. The natural solution for this would be an observable to which you can attach, but there is none in the public API.
What you could do is try workarounds:
- Register a
MessageData
plugin and check periodically yourself. This might work okay for certain license change events, but when the license change induces a shutdown of Cinema 4D (a user released a license for example), you might get event starved. So, this is not great. - Hook into the shutdown of Cinema 4D itself. When we want to specifically target the event that a license is being released, we can build upon the fact that Cinema 4D will then shut down.
MAXON_INITIALIZATION
: This is a bad choice in this case, because when the shutdown delegate ofMAXON_INITIALIZATION
is running, most registries already have been shut down. So, I would not be surprised, if all the license stuff is not working anymore at this point (I have not checked though). The advantage is here thatMAXON_INITIALIZATION
often makes for nicer looking code thanPluginMessage
.PluginMessage
: Hook into the shutdown sequence of Cinema 4D, and check the license state there.C4DPL_ENDACTIVITY
is the best event to start with.
The problem is here that I do not know how licenses behave when a user releases a license. The idea would be to check for example on shutdown, if there is still a commercial license bound to this instance:
// Create the ID for a commercial Cinema 4D license. maxon::InternedId feature; feature.Init("net.maxon.license.app.cinema4d-release~commercial"_s) iferr_return; // Check if the given #feature is active in the current license of this instance. if (!CheckLicenseFeature(feature)) ReleasePluginLicense(userId);
But it could very well be that it takes some time before a released license 'kicks in' in a shutdown process and that you must go further into no-mans-land than
C4DPL_ENDACTIVITY
(where more and more services will be shut down). Internally, we have a licensing API which has observables which communicate such events. I will bring up the subject internally if we can make the framework fully or partially public.Cheers,
Ferdinand - Register a