license mechanism and MFnPlugin

license mechanism and MFnPlugin

stuzzz
Collaborator Collaborator
870 Views
4 Replies
Message 1 of 5

license mechanism and MFnPlugin

stuzzz
Collaborator
Collaborator

Hi there,

 

I've built my own license mechanism for a C++ plugin, the algorithm works fine. Now I need to block the plugin registration if the user failed to provide a valid license key.

 

For now I have this:

MStatus initializePlugin(MObject obj) {
    MStatus stat;
      if (licenseIsNotValid()){
        // logically I thought that the plug wouldn't be loaded
        return stat;
    }

	MFnPlugin plugin(obj, "me", "1.4", "2020");
	stat = plugin.registerContextCommand(blablabla);
	return stat;
}

 

I would have make sense if Maya would just skip the plug-in loading process but it doesn't. The plugin manager show the plugin as "loaded' and when I try to tick this off, nothing happens. The unloadPlugin command says it's not loaded. To make it short, Maya is confused.

 

The question is fairly simple:

How can we prevent a plug-in to load after checking some conditions?

 

 

 

Accepted solutions (1)
871 Views
4 Replies
Replies (4)
Message 2 of 5

stuzzz
Collaborator
Collaborator
Accepted solution

I fixed the issue, the returned value has to be explicitly set as failure.

Message 3 of 5

talk2rene
Contributor
Contributor

Hi, great that you managed to solve the issue! Could I ask you a question perhaps about your licensing mechanism? I have written a Maya plugin that I would like to protect through a licensing mechanism but I am new to that subject. Would you be willing to share the concept that you have been using? Any pointers would be welcome too.

 

Hope that work goes well for you!

 

Many thanks, kind regards, -Rene

0 Likes
Message 4 of 5

negow
Advocate
Advocate

I use LimeLM for my Maya plug-in.

https://wyday.com/limelm/

 

Handles floating and node-locked, automatic 30 day trial activation, offline activation and runs on every platform including Raspberry Pi. I would not recommend rolling your own mechanism in this day and age, spend your time making great software.

0 Likes
Message 5 of 5

ZachGray
Enthusiast
Enthusiast

Is there any way to do this with a scripted plugin? I'd like to abort load if a few checks aren't satisfied, and I'd rather not do it with a `mc.loadPlugin` wrapper. 

 

So far, `raise Exception()` and `return False` still allow the scripted plugin to register.

 

Thanks!

0 Likes