Plugin configuration
AnsweredIs there currently some way to add button to plugin configuration that would call handler with custom logic or at least showing some kind of messagebox to user ?
Use case:
It would be nice to have "Test connection" button that will check whether integration or configuration is set properly and propagate result of this test to user, e.g. in form on messagebox ?
-
Hello Ivan Benovic ,
At the moment there is not special button in plugin configuration.
A plugin is notified about settings when "Ok" or "Apply" button is pressed in GUI.
Once received new settings values from the GUI, the Server passes these settings to a plugin.
The Sever calls setSettings method, which invokes the helper class virtual method ConsumingDeviceAgent::doSetSettings or Engine::doSetSettings which in turn invokes corresponding settingsRecieved virtual method.
settingsRecieved - is the best place for handling and analyzing new received settings.
This method should return const nx::sdk::IStringMap with error message (if any) per setting.
So, you could create a "Test connection" check box in plugin settings model.
Redefine settingsRecieved to analyze "Test connection" value, perform test and return an "error" with a message.
Here is an example.

If "Error text" is not empty a plugin returns an error with this text. GUI displays it on the right-hand panel.
Here is the settingsReceived code
Result<const IStringMap*> DeviceAgent::settingsReceived()
{
// parse settings and save to internal members.
// "Error text" value is saved into
// m_deviceAgentSettings.testErrorMessage member
// "Error text" setting name is statically defined in kTestErrorMessage
//
// see stub_analytics_plugin for example of how to parse settings.
parseSettings();
// check if "Error text" is empty
if (m_deviceAgentSettings.testErrorMessage.empty())
return nullptr;
// create countable smart pointer. See SDK documentation for details.
auto errorMap = makePtr<StringMap>();
// Create an error message to be returned.
errorMap->setItem(kTestErrorMessage, m_deviceAgentSettings.testErrorMessage);
// return a pointer to the StringMap
return errorMap.releasePtr();
}0
Please sign in to leave a comment.
Comments
1 comment