mirror of
https://github.com/arcan1s/queued.git
synced 2025-04-25 07:57:18 +00:00
implement support of new commands to clients
This commit is contained in:
parent
5f229b8ade
commit
4f9e3d6639
@ -84,6 +84,8 @@ QueuedTcpServerResponseHelper::pathToEnum(const QString &_path)
|
|||||||
return RequestPath::Option;
|
return RequestPath::Option;
|
||||||
else if (_path == "permissions")
|
else if (_path == "permissions")
|
||||||
return RequestPath::Permissions;
|
return RequestPath::Permissions;
|
||||||
|
else if (_path == "plugin")
|
||||||
|
return RequestPath::Plugin;
|
||||||
else if (_path == "plugins")
|
else if (_path == "plugins")
|
||||||
return RequestPath::Plugins;
|
return RequestPath::Plugins;
|
||||||
else if (_path == "reports")
|
else if (_path == "reports")
|
||||||
|
@ -27,6 +27,7 @@ enum class RequestPath {
|
|||||||
Auth,
|
Auth,
|
||||||
Option,
|
Option,
|
||||||
Permissions,
|
Permissions,
|
||||||
|
Plugin,
|
||||||
Plugins,
|
Plugins,
|
||||||
Reports,
|
Reports,
|
||||||
Status,
|
Status,
|
||||||
|
@ -68,6 +68,13 @@ QVariantHash QueuedTcpServerResponseHelperApi1::getData(
|
|||||||
else
|
else
|
||||||
output = {{"code", 405}};
|
output = {{"code", 405}};
|
||||||
break;
|
break;
|
||||||
|
case QueuedTcpServerResponseHelper::RequestPath::Plugin:
|
||||||
|
if (_type == "GET")
|
||||||
|
output
|
||||||
|
= QueuedTcpServerResponseHelperPlugins::getPlugin(_arg, _token);
|
||||||
|
else
|
||||||
|
output = {{"code", 405}};
|
||||||
|
break;
|
||||||
case QueuedTcpServerResponseHelper::RequestPath::Plugins:
|
case QueuedTcpServerResponseHelper::RequestPath::Plugins:
|
||||||
if (_type == "DELETE")
|
if (_type == "DELETE")
|
||||||
output = QueuedTcpServerResponseHelperPlugins::removePlugin(_arg,
|
output = QueuedTcpServerResponseHelperPlugins::removePlugin(_arg,
|
||||||
|
@ -30,7 +30,8 @@ QueuedTcpServerResponseHelperOption::getOption(const QString &_option,
|
|||||||
QVariantHash output;
|
QVariantHash output;
|
||||||
res.match(
|
res.match(
|
||||||
[&output](const QVariant &val) {
|
[&output](const QVariant &val) {
|
||||||
output = {{"code", 200}, {"token", val}};
|
QVariantHash opt = {{"_option", val}};
|
||||||
|
output = {{"code", 200}, {"properties", opt}};
|
||||||
},
|
},
|
||||||
[&output](const QueuedError &) {
|
[&output](const QueuedError &) {
|
||||||
output = {{"code", 404}, {"message", "Option not found"}};
|
output = {{"code", 404}, {"message", "Option not found"}};
|
||||||
|
@ -40,6 +40,29 @@ QueuedTcpServerResponseHelperPlugins::addPlugin(const QString &_name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariantHash
|
||||||
|
QueuedTcpServerResponseHelperPlugins::getPlugin(const QString &_name,
|
||||||
|
const QString &_token)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_SERV) << "Get plugin" << _name;
|
||||||
|
|
||||||
|
auto res = QueuedCoreAdaptor::getPlugin(_name, _token);
|
||||||
|
|
||||||
|
QVariantHash output;
|
||||||
|
res.match(
|
||||||
|
[&output](const QueuedPluginSpecification::Plugin &val) {
|
||||||
|
auto dump = QueuedPluginSpecification::dumpSpecification(val);
|
||||||
|
QVariantList plugins = {dump};
|
||||||
|
output = {{"code", 200}, {"plugins", plugins}};
|
||||||
|
},
|
||||||
|
[&output](const QueuedError &err) {
|
||||||
|
output = {{"code", 500}, {"message", err.message().c_str()}};
|
||||||
|
});
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QVariantHash QueuedTcpServerResponseHelperPlugins::listPlugins()
|
QVariantHash QueuedTcpServerResponseHelperPlugins::listPlugins()
|
||||||
{
|
{
|
||||||
auto res = QueuedCoreAdaptor::getOption(
|
auto res = QueuedCoreAdaptor::getOption(
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
namespace QueuedTcpServerResponseHelperPlugins
|
namespace QueuedTcpServerResponseHelperPlugins
|
||||||
{
|
{
|
||||||
QVariantHash addPlugin(const QString &_name, const QString &_token);
|
QVariantHash addPlugin(const QString &_name, const QString &_token);
|
||||||
|
QVariantHash getPlugin(const QString &_name, const QString &_token);
|
||||||
QVariantHash listPlugins();
|
QVariantHash listPlugins();
|
||||||
QVariantHash removePlugin(const QString &_name, const QString &_token);
|
QVariantHash removePlugin(const QString &_name, const QString &_token);
|
||||||
};
|
};
|
||||||
|
@ -40,6 +40,10 @@ namespace QueuedLimits
|
|||||||
{
|
{
|
||||||
struct Limits;
|
struct Limits;
|
||||||
}
|
}
|
||||||
|
namespace QueuedPluginSpecification
|
||||||
|
{
|
||||||
|
struct Plugin;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief aggregator of queued classes
|
* @brief aggregator of queued classes
|
||||||
@ -228,8 +232,8 @@ public:
|
|||||||
* user auth token
|
* user auth token
|
||||||
* @return dictionary of PluginSpecification representation
|
* @return dictionary of PluginSpecification representation
|
||||||
*/
|
*/
|
||||||
QueuedResult<QVariantHash> plugin(const QString &_plugin,
|
QueuedResult<QueuedPluginSpecification::Plugin>
|
||||||
const QString &_token);
|
plugin(const QString &_plugin, const QString &_token);
|
||||||
/**
|
/**
|
||||||
* @brief get plugin settings
|
* @brief get plugin settings
|
||||||
* @param _plugin
|
* @param _plugin
|
||||||
|
@ -204,6 +204,16 @@ sendUserPermissionRemove(const long long _id,
|
|||||||
*/
|
*/
|
||||||
QueuedResult<QueuedPluginSpecification::Plugin>
|
QueuedResult<QueuedPluginSpecification::Plugin>
|
||||||
getPlugin(const QString &_plugin, const QString &_token);
|
getPlugin(const QString &_plugin, const QString &_token);
|
||||||
|
/**
|
||||||
|
* @brief get plugin options
|
||||||
|
* @param _plugin
|
||||||
|
* plugin name
|
||||||
|
* @param _token
|
||||||
|
* user auth token
|
||||||
|
* @return plugin options dictionary
|
||||||
|
*/
|
||||||
|
QueuedResult<QVariantHash> getPluginOptions(const QString &_plugin,
|
||||||
|
const QString &_token);
|
||||||
/**
|
/**
|
||||||
* @brief get option
|
* @brief get option
|
||||||
* @param _property
|
* @param _property
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#ifndef QUEUEDPLUGINSPECIFICATION_H
|
#ifndef QUEUEDPLUGINSPECIFICATION_H
|
||||||
#define QUEUEDPLUGINSPECIFICATION_H
|
#define QUEUEDPLUGINSPECIFICATION_H
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
|
||||||
@ -51,6 +52,50 @@ struct PluginOption {
|
|||||||
QString name;
|
QString name;
|
||||||
QString type;
|
QString type;
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* @brief DBus marshalling method
|
||||||
|
* @param _argument
|
||||||
|
* output DBus argument
|
||||||
|
* @param _arg
|
||||||
|
* input variant object
|
||||||
|
* @return appended argument body
|
||||||
|
*/
|
||||||
|
inline QDBusArgument &operator<<(QDBusArgument &_argument,
|
||||||
|
const PluginOption &_arg)
|
||||||
|
{
|
||||||
|
_argument.beginStructure();
|
||||||
|
_argument << QDBusVariant(_arg.defaultValue.isValid() ? _arg.defaultValue
|
||||||
|
: "");
|
||||||
|
_argument << _arg.description;
|
||||||
|
_argument << _arg.name;
|
||||||
|
_argument << _arg.type;
|
||||||
|
_argument.endStructure();
|
||||||
|
|
||||||
|
return _argument;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* @brief DBus un-marshalling method
|
||||||
|
* @param _argument
|
||||||
|
* input DBus argument
|
||||||
|
* @param _arg
|
||||||
|
* output variant object
|
||||||
|
* @return source DBus argument
|
||||||
|
*/
|
||||||
|
inline const QDBusArgument &operator>>(const QDBusArgument &_argument,
|
||||||
|
PluginOption &_arg)
|
||||||
|
{
|
||||||
|
QDBusVariant variant;
|
||||||
|
|
||||||
|
_argument.beginStructure();
|
||||||
|
_argument >> variant;
|
||||||
|
_arg.defaultValue = variant.variant();
|
||||||
|
_argument >> _arg.description;
|
||||||
|
_argument >> _arg.name;
|
||||||
|
_argument >> _arg.type;
|
||||||
|
_argument.endStructure();
|
||||||
|
|
||||||
|
return _argument;
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* @struct Plugin
|
* @struct Plugin
|
||||||
* @brief plugin specification structure
|
* @brief plugin specification structure
|
||||||
@ -72,6 +117,47 @@ struct Plugin {
|
|||||||
QString license;
|
QString license;
|
||||||
QList<PluginOption> options;
|
QList<PluginOption> options;
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* @brief DBus marshalling method
|
||||||
|
* @param _argument
|
||||||
|
* output DBus argument
|
||||||
|
* @param _arg
|
||||||
|
* input variant object
|
||||||
|
* @return appended argument body
|
||||||
|
*/
|
||||||
|
inline QDBusArgument &operator<<(QDBusArgument &_argument, const Plugin &_arg)
|
||||||
|
{
|
||||||
|
_argument.beginStructure();
|
||||||
|
_argument << _arg.author;
|
||||||
|
_argument << _arg.description;
|
||||||
|
_argument << _arg.homepage;
|
||||||
|
_argument << _arg.license;
|
||||||
|
_argument << _arg.options;
|
||||||
|
_argument.endStructure();
|
||||||
|
|
||||||
|
return _argument;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* @brief DBus un-marshalling method
|
||||||
|
* @param _argument
|
||||||
|
* input DBus argument
|
||||||
|
* @param _arg
|
||||||
|
* output variant object
|
||||||
|
* @return source DBus argument
|
||||||
|
*/
|
||||||
|
inline const QDBusArgument &operator>>(const QDBusArgument &_argument,
|
||||||
|
Plugin &_arg)
|
||||||
|
{
|
||||||
|
_argument.beginStructure();
|
||||||
|
_argument >> _arg.author;
|
||||||
|
_argument >> _arg.description;
|
||||||
|
_argument >> _arg.homepage;
|
||||||
|
_argument >> _arg.license;
|
||||||
|
_argument >> _arg.options;
|
||||||
|
_argument.endStructure();
|
||||||
|
|
||||||
|
return _argument;
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* @brief dump specification to map
|
* @brief dump specification to map
|
||||||
* @param _plugin
|
* @param _plugin
|
||||||
|
@ -62,6 +62,15 @@ public slots:
|
|||||||
* @return plugin properties
|
* @return plugin properties
|
||||||
*/
|
*/
|
||||||
QDBusVariant Plugin(const QString &plugin, const QString &token);
|
QDBusVariant Plugin(const QString &plugin, const QString &token);
|
||||||
|
/**
|
||||||
|
* @brief get plugin options
|
||||||
|
* @param plugin
|
||||||
|
* plugin name
|
||||||
|
* @param token
|
||||||
|
* user auth token
|
||||||
|
* @return list of plugin options and their values
|
||||||
|
*/
|
||||||
|
QDBusVariant PluginOptions(const QString &plugin, const QString &token);
|
||||||
/**
|
/**
|
||||||
* @brief get advanced option
|
* @brief get advanced option
|
||||||
* @param property
|
* @param property
|
||||||
|
@ -28,12 +28,15 @@
|
|||||||
|
|
||||||
#include <result/result.hpp>
|
#include <result/result.hpp>
|
||||||
|
|
||||||
|
#include "QueuedPluginSpecification.h"
|
||||||
|
|
||||||
|
|
||||||
namespace QueuedEnums
|
namespace QueuedEnums
|
||||||
{
|
{
|
||||||
enum class ReturnStatus;
|
enum class ReturnStatus;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef QueuedError
|
* @typedef QueuedError
|
||||||
* custom result error implementation
|
* custom result error implementation
|
||||||
@ -100,7 +103,11 @@ Q_DECLARE_METATYPE(QueuedResult<QStringList>)
|
|||||||
Q_DECLARE_METATYPE(QueuedResult<QVariant>)
|
Q_DECLARE_METATYPE(QueuedResult<QVariant>)
|
||||||
Q_DECLARE_METATYPE(QueuedResult<QList<QVariantHash>>)
|
Q_DECLARE_METATYPE(QueuedResult<QList<QVariantHash>>)
|
||||||
Q_DECLARE_METATYPE(QueuedResult<QVariantHash>)
|
Q_DECLARE_METATYPE(QueuedResult<QVariantHash>)
|
||||||
|
Q_DECLARE_METATYPE(QueuedResult<QueuedPluginSpecification::Plugin>)
|
||||||
|
Q_DECLARE_METATYPE(QueuedResult<QueuedPluginSpecification::PluginOption>)
|
||||||
Q_DECLARE_METATYPE(QueuedResult<QueuedStatusMap>)
|
Q_DECLARE_METATYPE(QueuedResult<QueuedStatusMap>)
|
||||||
|
Q_DECLARE_METATYPE(QueuedPluginSpecification::Plugin)
|
||||||
|
Q_DECLARE_METATYPE(QueuedPluginSpecification::PluginOption)
|
||||||
/**
|
/**
|
||||||
* @brief DBus marshalling method
|
* @brief DBus marshalling method
|
||||||
* @param _argument
|
* @param _argument
|
||||||
|
@ -231,8 +231,8 @@ public:
|
|||||||
* user auth token
|
* user auth token
|
||||||
* @return dictionary of PluginSpecification representation
|
* @return dictionary of PluginSpecification representation
|
||||||
*/
|
*/
|
||||||
QueuedResult<QVariantHash> plugin(const QString &_plugin,
|
QueuedResult<QueuedPluginSpecification::Plugin>
|
||||||
const QString &_token);
|
plugin(const QString &_plugin, const QString &_token);
|
||||||
/**
|
/**
|
||||||
* @brief get plugin settings
|
* @brief get plugin settings
|
||||||
* @param _plugin
|
* @param _plugin
|
||||||
|
@ -211,8 +211,8 @@ QueuedCore::performanceReport(const QDateTime &_from, const QDateTime &_to,
|
|||||||
/**
|
/**
|
||||||
* @fn plugin
|
* @fn plugin
|
||||||
*/
|
*/
|
||||||
QueuedResult<QVariantHash> QueuedCore::plugin(const QString &_plugin,
|
QueuedResult<QueuedPluginSpecification::Plugin>
|
||||||
const QString &_token)
|
QueuedCore::plugin(const QString &_plugin, const QString &_token)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_LIB) << "Get data for plugin" << _plugin;
|
qCDebug(LOG_LIB) << "Get data for plugin" << _plugin;
|
||||||
|
|
||||||
|
@ -297,18 +297,26 @@ QueuedCoreAdaptor::getPlugin(const QString &_plugin, const QString &_token)
|
|||||||
|
|
||||||
QVariantList args = {_plugin, _token};
|
QVariantList args = {_plugin, _token};
|
||||||
|
|
||||||
auto result = sendRequest<QVariantHash>(
|
return sendRequest<QueuedPluginSpecification::Plugin>(
|
||||||
QueuedConfig::DBUS_SERVICE, QueuedConfig::DBUS_PROPERTY_PATH,
|
QueuedConfig::DBUS_SERVICE, QueuedConfig::DBUS_PROPERTY_PATH,
|
||||||
QueuedConfig::DBUS_SERVICE, "Plugin", args);
|
QueuedConfig::DBUS_SERVICE, "Plugin", args);
|
||||||
|
}
|
||||||
|
|
||||||
QueuedResult<QueuedPluginSpecification::Plugin> output;
|
|
||||||
result.match(
|
|
||||||
[&output](const QVariantHash &res) {
|
|
||||||
output = QueuedPluginSpecification::readSpecification(res);
|
|
||||||
},
|
|
||||||
[&output](const QueuedError &err) { output = err; });
|
|
||||||
|
|
||||||
return output;
|
/**
|
||||||
|
* @fn getPluginOptions
|
||||||
|
*/
|
||||||
|
QueuedResult<QVariantHash>
|
||||||
|
QueuedCoreAdaptor::getPluginOptions(const QString &_plugin,
|
||||||
|
const QString &_token)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_DBUS) << "Get options for plugin" << _plugin;
|
||||||
|
|
||||||
|
QVariantList args = {_plugin, _token};
|
||||||
|
|
||||||
|
return sendRequest<QVariantHash>(
|
||||||
|
QueuedConfig::DBUS_SERVICE, QueuedConfig::DBUS_PROPERTY_PATH,
|
||||||
|
QueuedConfig::DBUS_SERVICE, "PluginOptions", args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -386,19 +386,15 @@ QueuedResult<QList<QVariantHash>> QueuedCorePrivate::performanceReport(
|
|||||||
/**
|
/**
|
||||||
* @fn plugin
|
* @fn plugin
|
||||||
*/
|
*/
|
||||||
QueuedResult<QVariantHash> QueuedCorePrivate::plugin(const QString &_plugin,
|
QueuedResult<QueuedPluginSpecification::Plugin>
|
||||||
const QString &_token)
|
QueuedCorePrivate::plugin(const QString &_plugin, const QString &_token)
|
||||||
{
|
{
|
||||||
bool isAdmin = m_users->authorize(_token, QueuedEnums::Permission::Admin);
|
bool isAdmin = m_users->authorize(_token, QueuedEnums::Permission::Admin);
|
||||||
if (!isAdmin)
|
if (!isAdmin)
|
||||||
return QueuedError("Not allowed",
|
return QueuedError("Not allowed",
|
||||||
QueuedEnums::ReturnStatus::InsufficientPermissions);
|
QueuedEnums::ReturnStatus::InsufficientPermissions);
|
||||||
|
|
||||||
auto spec = m_plugins->loadSpecification(_plugin);
|
return m_plugins->loadSpecification(_plugin);
|
||||||
auto map = QueuedPluginSpecification::dumpSpecification(spec);
|
|
||||||
// do something if we need
|
|
||||||
|
|
||||||
return map;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,6 +44,18 @@ QueuedPropertyInterface::QueuedPropertyInterface(QueuedCore *parent)
|
|||||||
|
|
||||||
qRegisterMetaType<QueuedResult<QVariantHash>>("QueuedResult<QVariantHash>");
|
qRegisterMetaType<QueuedResult<QVariantHash>>("QueuedResult<QVariantHash>");
|
||||||
qDBusRegisterMetaType<QueuedResult<QVariantHash>>();
|
qDBusRegisterMetaType<QueuedResult<QVariantHash>>();
|
||||||
|
|
||||||
|
qRegisterMetaType<QueuedPluginSpecification::PluginOption>(
|
||||||
|
"QueuedPluginSpecification::PluginOption");
|
||||||
|
qDBusRegisterMetaType<QueuedPluginSpecification::PluginOption>();
|
||||||
|
|
||||||
|
qRegisterMetaType<QueuedPluginSpecification::Plugin>(
|
||||||
|
"QueuedPluginSpecification::Plugin");
|
||||||
|
qDBusRegisterMetaType<QueuedPluginSpecification::Plugin>();
|
||||||
|
|
||||||
|
qRegisterMetaType<QueuedResult<QueuedPluginSpecification::Plugin>>(
|
||||||
|
"QueuedResult<QueuedPluginSpecification::Plugin>");
|
||||||
|
qDBusRegisterMetaType<QueuedResult<QueuedPluginSpecification::Plugin>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -68,6 +80,19 @@ QDBusVariant QueuedPropertyInterface::Plugin(const QString &plugin,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @fn PluginOptions
|
||||||
|
*/
|
||||||
|
QDBusVariant QueuedPropertyInterface::PluginOptions(const QString &plugin,
|
||||||
|
const QString &token)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_DBUS) << "Get plugin options" << plugin;
|
||||||
|
|
||||||
|
return QueuedCoreAdaptor::toDBusVariant(
|
||||||
|
m_core->pluginSettings(plugin, token));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn Option
|
* @fn Option
|
||||||
*/
|
*/
|
||||||
|
@ -149,7 +149,9 @@ void QueuedctlCommon::preprocess(const QStringList &_args,
|
|||||||
QueuedctlPermissions::parser(_parser);
|
QueuedctlPermissions::parser(_parser);
|
||||||
break;
|
break;
|
||||||
case QueuedctlArgument::PluginAdd:
|
case QueuedctlArgument::PluginAdd:
|
||||||
|
case QueuedctlArgument::PluginOptions:
|
||||||
case QueuedctlArgument::PluginRemove:
|
case QueuedctlArgument::PluginRemove:
|
||||||
|
case QueuedctlArgument::PluginSpecification:
|
||||||
QueuedctlPlugins::parser(_parser);
|
QueuedctlPlugins::parser(_parser);
|
||||||
break;
|
break;
|
||||||
case QueuedctlArgument::PluginList:
|
case QueuedctlArgument::PluginList:
|
||||||
@ -269,10 +271,18 @@ QueuedctlCommon::process(QCommandLineParser &_parser, const QString &_cache,
|
|||||||
result = QueuedctlPlugins::listPlugins();
|
result = QueuedctlPlugins::listPlugins();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case QueuedctlArgument::PluginOptions: {
|
||||||
|
result = QueuedctlPlugins::getPluginOptions(args.at(1), token);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case QueuedctlArgument::PluginRemove: {
|
case QueuedctlArgument::PluginRemove: {
|
||||||
result = QueuedctlPlugins::removePlugin(args.at(1), token);
|
result = QueuedctlPlugins::removePlugin(args.at(1), token);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case QueuedctlArgument::PluginSpecification: {
|
||||||
|
result = QueuedctlPlugins::getPlugin(args.at(1), token);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case QueuedctlArgument::Report: {
|
case QueuedctlArgument::Report: {
|
||||||
result = QueuedctlUser::getReport(_parser, token);
|
result = QueuedctlUser::getReport(_parser, token);
|
||||||
break;
|
break;
|
||||||
|
@ -32,7 +32,9 @@ enum class QueuedctlArgument {
|
|||||||
PermissionRemove,
|
PermissionRemove,
|
||||||
PluginAdd,
|
PluginAdd,
|
||||||
PluginList,
|
PluginList,
|
||||||
|
PluginOptions,
|
||||||
PluginRemove,
|
PluginRemove,
|
||||||
|
PluginSpecification,
|
||||||
Report,
|
Report,
|
||||||
Status,
|
Status,
|
||||||
TaskAdd,
|
TaskAdd,
|
||||||
@ -63,9 +65,13 @@ const QHash<QString, QueuedctlArgumentInfo> QueuedctlArguments = {
|
|||||||
{QueuedctlArgument::PermissionAdd, "Sets user permission.", 3}},
|
{QueuedctlArgument::PermissionAdd, "Sets user permission.", 3}},
|
||||||
{"perm-remove",
|
{"perm-remove",
|
||||||
{QueuedctlArgument::PermissionRemove, "Removes user permission.", 3}},
|
{QueuedctlArgument::PermissionRemove, "Removes user permission.", 3}},
|
||||||
|
{"plugin",
|
||||||
|
{QueuedctlArgument::PluginSpecification, "Get plugin description.", 2}},
|
||||||
{"plugin-add", {QueuedctlArgument::PluginAdd, "Adds plugin to load.", 2}},
|
{"plugin-add", {QueuedctlArgument::PluginAdd, "Adds plugin to load.", 2}},
|
||||||
{"plugin-list",
|
{"plugin-list",
|
||||||
{QueuedctlArgument::PluginList, "Shows enabled plugins.", 1}},
|
{QueuedctlArgument::PluginList, "Shows enabled plugins.", 1}},
|
||||||
|
{"plugin-options",
|
||||||
|
{QueuedctlArgument::PluginOptions, "Get plugin options.", 2}},
|
||||||
{"plugin-remove",
|
{"plugin-remove",
|
||||||
{QueuedctlArgument::PluginRemove, "Removes plugin to load.", 2}},
|
{QueuedctlArgument::PluginRemove, "Removes plugin to load.", 2}},
|
||||||
{"report", {QueuedctlArgument::Report, "Shows usage report.", 1}},
|
{"report", {QueuedctlArgument::Report, "Shows usage report.", 1}},
|
||||||
|
@ -45,9 +45,9 @@ QueuedctlOption::getOption(const QString &_option, const QString &_token)
|
|||||||
QueuedctlCommon::QueuedctlResult output;
|
QueuedctlCommon::QueuedctlResult output;
|
||||||
auto res = QueuedCoreAdaptor::getOption(_option, _token);
|
auto res = QueuedCoreAdaptor::getOption(_option, _token);
|
||||||
res.match(
|
res.match(
|
||||||
[&output](const QVariant &val) {
|
[&output, &_option](const QVariant &val) {
|
||||||
output.status = val.isValid();
|
output.status = val.isValid();
|
||||||
output.output = val.toString();
|
output.output = QString("%1: %2").arg(_option, val.toString());
|
||||||
},
|
},
|
||||||
[&output](const QueuedError &err) {
|
[&output](const QueuedError &err) {
|
||||||
output.output = err.message().c_str();
|
output.output = err.message().c_str();
|
||||||
|
@ -37,6 +37,63 @@ QueuedctlPlugins::addPlugin(const QString &_plugin, const QString &_token)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QueuedctlCommon::QueuedctlResult
|
||||||
|
QueuedctlPlugins::getPlugin(const QString &_plugin, const QString &_token)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_APP) << "Get plugin" << _plugin;
|
||||||
|
|
||||||
|
auto res = QueuedCoreAdaptor::getPlugin(_plugin, _token);
|
||||||
|
|
||||||
|
QueuedctlCommon::QueuedctlResult output;
|
||||||
|
res.match(
|
||||||
|
[&output](const QueuedPluginSpecification::Plugin &val) {
|
||||||
|
QStringList text;
|
||||||
|
text += QString("Author: %1").arg(val.author);
|
||||||
|
text += QString("Description: %1").arg(val.description);
|
||||||
|
text += QString("Homepage: %1").arg(val.homepage);
|
||||||
|
text += QString("License: %1").arg(val.license);
|
||||||
|
text += QString("Options:");
|
||||||
|
for (auto &opt : val.options) {
|
||||||
|
text += QString(" %1").arg(opt.name);
|
||||||
|
text += QString(" description: %1").arg(opt.description);
|
||||||
|
text += QString(" type: %1").arg(opt.type);
|
||||||
|
text += QString(" default: %1")
|
||||||
|
.arg(opt.defaultValue.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
output.status = true;
|
||||||
|
output.output = text.join('\n');
|
||||||
|
},
|
||||||
|
[&output](const QueuedError &err) {
|
||||||
|
output.output = err.message().c_str();
|
||||||
|
});
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QueuedctlCommon::QueuedctlResult
|
||||||
|
QueuedctlPlugins::getPluginOptions(const QString &_plugin,
|
||||||
|
const QString &_token)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_APP) << "Get plugin options" << _plugin;
|
||||||
|
|
||||||
|
auto res = QueuedCoreAdaptor::getPluginOptions(_plugin, _token);
|
||||||
|
|
||||||
|
QueuedctlCommon::QueuedctlResult output;
|
||||||
|
res.match(
|
||||||
|
[&output](const QVariantHash &val) {
|
||||||
|
output.status = true;
|
||||||
|
output.output = QueuedctlCommon::hashToString(val);
|
||||||
|
},
|
||||||
|
[&output](const QueuedError &err) {
|
||||||
|
output.output = err.message().c_str();
|
||||||
|
});
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QueuedctlCommon::QueuedctlResult QueuedctlPlugins::listPlugins()
|
QueuedctlCommon::QueuedctlResult QueuedctlPlugins::listPlugins()
|
||||||
{
|
{
|
||||||
auto res = QueuedCoreAdaptor::getOption(
|
auto res = QueuedCoreAdaptor::getOption(
|
||||||
|
@ -26,6 +26,10 @@ namespace QueuedctlPlugins
|
|||||||
{
|
{
|
||||||
QueuedctlCommon::QueuedctlResult addPlugin(const QString &_plugin,
|
QueuedctlCommon::QueuedctlResult addPlugin(const QString &_plugin,
|
||||||
const QString &_token);
|
const QString &_token);
|
||||||
|
QueuedctlCommon::QueuedctlResult getPlugin(const QString &_plugin,
|
||||||
|
const QString &_token);
|
||||||
|
QueuedctlCommon::QueuedctlResult getPluginOptions(const QString &_plugin,
|
||||||
|
const QString &_token);
|
||||||
QueuedctlCommon::QueuedctlResult listPlugins();
|
QueuedctlCommon::QueuedctlResult listPlugins();
|
||||||
QueuedctlCommon::QueuedctlResult removePlugin(const QString &_plugin,
|
QueuedctlCommon::QueuedctlResult removePlugin(const QString &_plugin,
|
||||||
const QString &_token);
|
const QString &_token);
|
||||||
|
Loading…
Reference in New Issue
Block a user