new command <version> to get plugin version

This commit is contained in:
theadib
2020-12-29 17:10:20 +01:00
parent 098650de63
commit fca29f8ce6
4 changed files with 38 additions and 4 deletions
+14
View File
@@ -87,8 +87,22 @@ interface
silent: bool, optional, if true, then filterdialog is suppressed
transformation: list of float (16values), optional, after import this transformation matrix is applied to the object,
- clear - clear all objects
- version - return version number of plugin
```
debugging
---------
I use QtCreator for developement.
In order to load the plugin during debugging it must placed in a folder that is looked up.
- /usr/lib/cloudcompare/plugins
- /home/username/.local/share/CCCorp/CloudCompare/plugins
- /usr/local/share/CCCorp/CloudCompare/plugins
- /usr/share/CCCorp/CloudCompare/plugins
- /var/lib/snapd/desktop/CCCorp/CloudCompare/plugins
I set a link in the .local/share folder to the recent compiled version:
ln -s build-CloudCompare-Desktop-Debug/plugins/core/Standard/qJSonRPCPlugin/libQJSON_RPC_PLUGINd.so ~/.local/share/CCCorp/CloudCompare/plugins/libQJSON_RPC_PLUGINd.so
contact
-------
+1
View File
@@ -42,6 +42,7 @@ public slots:
private:
//! Default action
QAction* m_action{nullptr};
const QString version{"1.0"};
protected:
/// server that emit the execute signals
JsonRPCServer rpc_server;
+9 -4
View File
@@ -154,20 +154,25 @@ JsonRPCResult JsonRPCPlugin::execute(QString method, QMap<QString, QVariant> par
result = JsonRPCResult::error(1, "cancelled by user");
}
}
else if (method == "clear")
{
else if (method == "clear")
{
// remove everything below root
auto root = m_app->dbRootObject();
ccHObject* child;
while ((child = root->getChild(0)) != nullptr)
{
{
m_app->removeFromDB(child, true);
}
need_redraw = true;
result = JsonRPCResult::success(0);
}
else if (method == "version")
{
// return version number of plugin
result = JsonRPCResult::success(version);
}
// redraw
if (need_redraw)
{
+14
View File
@@ -0,0 +1,14 @@
#!/usr/bin/env python3
import asyncio
import websockets
async def hello():
uri = "ws://localhost:6001"
async with websockets.connect(uri) as websocket:
await websocket.send('{"jsonrpc": "2.0", "method": "version", "id": 6}')
result = await websocket.recv()
print("result: ", result)
asyncio.get_event_loop().run_until_complete(hello())