Hi there,
I am trying to understand the process of installing Rhino plugIns on the user’s PC.
I need the user to agree/disagree on the plugin license, and to store the answer, how can we store the answer in the setting/ the rhp or dll file?
Most typical usage of license agreement check is to make it in your own plugin installer. Not the one provided by .rhi file or by yak package.
If you would like to use Rhino plugin installers, in theory you could provide such check in plugin OnLoad and store result in plugin settings Settings.SetString() or Settings.SetBool(), but be aware that this would require user to already have plugin downloaded/installed to initialize its loading. It is up to you to decide will it be ok with your plugin license agreement.
According to topic below McNeel will not provide a tool to accept plugin EULA before it is downloaded from yak server, since it is responsibility of plugin developer.
thanks @mlukasz87 for answering, yes, that is what I am doing. but I wasn’t sure how to check if the user agreed on the license before, how to check the answer in the setting?
for the situation of “agree/disagree” do we also need to build a path to the user’s staged RUI file.
var sb = new StringBuilder();
sb.Append(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData));
sb.Append(@"\McNeel\Rhinoceros\6.0\UI\Plug-ins\");
sb.AppendFormat("{0}.rui", Assembly.GetName().Name);
as I understood, I only need to store in the settings and that is all?
hey @mlukasz87, I have another question.
I open a form to ask the user to agree/disagree on the license, and apparently, the Setting.SetBool() doesn’t set the “true” value immediately, but when I close the file and reopen it, it does work. but I need to set in the settings the changes while the file is still running, on a different discussion in the form they used rhinoscriptsyntax .sleep(4000) but there is no rhinoscriptsyntax, in c#, I also tried PlugIn.SavePluginSettings(AvocadoPlugIn.Instance.Id) then Rhino.RhinoApp.Wait();
didn’t help, how can wait for it to save/ change the value? thanks again!
@dale thank you for info. I am aware that for public distribution package manager is a way to go. I find sometimes obsolete .rhi suitable for limited internal check.
protected override LoadReturnCode OnLoad(ref string errorMessage)
{
//check for previously used version
string plugin_version = Settings.GetString("PlugInVersion", null);
if (string.IsNullOrEmpty(plugin_version))
{
plugin_version = "0.0.0.0";
}
//make action when new version of plugin is loaded
if (0 != string.Compare(Version, plugin_version, StringComparison.OrdinalIgnoreCase))
{
Settings.SetString("PlugInVersion", Version);
Settings.SetBool("AcceptedEULA", false);
}
//ask user to accept EULA during plugin load if not asked before for this version
bool plugin_EULA_accepted = Settings.GetBool("AcceptedEULA", false);
if (!plugin_EULA_accepted)
{
var form = new Views.MyEULADialog(); //my dialog returns bool value of EULA check
Dialogs.KillSplash();
bool result = form.ShowModal(RhinoEtoApp.MainWindow);
if (result == true)
{
plugin_EULA_accepted = true;
Settings.SetBool("AcceptedEULA", plugin_EULA_accepted);
}
else
{
Dialogs.ShowMessage(
"You did not accept EULA so bye, plugin will not load. Restart Rhino to try again.",
"My Plugin Name",
ShowMessageButton.OK,
ShowMessageIcon.Error
);
return LoadReturnCode.ErrorNoDialog;
}
}
return LoadReturnCode.Success;
}
@dale@mlukasz87 I have a small question, once we store the answer in the plugin settings, does it mean that different Rhino users (with different license agreement answers) can access the plugin from the same computer? does it store the answer in the rhino license?
As far as I know, plugin settings are stored in .xml file, which is stored inside folder “settings” next to folder with .rhp file. All those folders are stored in user app data folder in Windows.
This would mean that each user use seperate plugin settings .xml file, however it would be better if @dale could confirm this. I am not aware if there are any other locations where plugin settings could be stored.
What @mlukasz87 says is correct. Settings are a per-user configuration and not shared with other Rhino users. If you want your EULA answered only once per system, then you’ll need to come up with another method than the sample posted above.