Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Message on "Quit and Free License"

    Cinema 4D SDK
    c++
    2
    2
    542
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • kbarK
      kbar
      last edited by

      Is there some way to receive a message, and run a function, when a users presses "Quit and Free License"?

      https://www.gamelogicdesign.com
      https://www.plugins4d.com

      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand @kbar
        last edited by ferdinand

        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:

        1. 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.
        2. 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 of MAXON_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 that MAXON_INITIALIZATION often makes for nicer looking code than PluginMessage.
          • 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

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 1
        • First post
          Last post