mirror of
https://github.com/arcan1s/queued.git
synced 2025-04-25 07:57:18 +00:00
fix merge conflicts
This commit is contained in:
commit
505c1e2b93
@ -54,6 +54,14 @@ public:
|
|||||||
* @remark plugin settings will be stored as "plugin.name.Key"
|
* @remark plugin settings will be stored as "plugin.name.Key"
|
||||||
*/
|
*/
|
||||||
virtual void init(const QVariantHash &_settings) = 0;
|
virtual void init(const QVariantHash &_settings) = 0;
|
||||||
|
/**
|
||||||
|
* @brief set plugin token
|
||||||
|
* @remark this method may be safety ignored if plugin does not use methods
|
||||||
|
* require auth
|
||||||
|
* @param _token
|
||||||
|
* new token ID
|
||||||
|
*/
|
||||||
|
virtual void setToken(const QString &_token) = 0;
|
||||||
/**
|
/**
|
||||||
* @brief method which will be called on option update
|
* @brief method which will be called on option update
|
||||||
* @param _key
|
* @param _key
|
||||||
@ -61,7 +69,8 @@ public:
|
|||||||
* @param _value
|
* @param _value
|
||||||
* option value
|
* option value
|
||||||
*/
|
*/
|
||||||
virtual void updateSettings(const QString &_key, const QVariant &_value);
|
virtual void updateSettings(const QString &_key, const QVariant &_value)
|
||||||
|
= 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_INTERFACE(QueuedPluginInterface, PLUGIN_INTERFACE_NAME)
|
Q_DECLARE_INTERFACE(QueuedPluginInterface, PLUGIN_INTERFACE_NAME)
|
||||||
|
@ -50,8 +50,10 @@ public:
|
|||||||
* @brief QueuedPluginManager class constructor
|
* @brief QueuedPluginManager class constructor
|
||||||
* @param parent
|
* @param parent
|
||||||
* pointer to parent item
|
* pointer to parent item
|
||||||
|
* @param token
|
||||||
|
* plugin auth token
|
||||||
*/
|
*/
|
||||||
explicit QueuedPluginManager(QObject *parent);
|
explicit QueuedPluginManager(QObject *parent, const QString &token);
|
||||||
/**
|
/**
|
||||||
* @brief QueuedPluginManager class destructor
|
* @brief QueuedPluginManager class destructor
|
||||||
*/
|
*/
|
||||||
@ -101,14 +103,18 @@ public slots:
|
|||||||
void optionChanged(const QString &_key, const QVariant &_value);
|
void optionChanged(const QString &_key, const QVariant &_value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/**
|
||||||
|
* @brief pointer to database object
|
||||||
|
*/
|
||||||
|
QueuedPluginManagerInterface *m_interface = nullptr;
|
||||||
/**
|
/**
|
||||||
* @brief loaded plugins
|
* @brief loaded plugins
|
||||||
*/
|
*/
|
||||||
QueuedPluginMap m_plugins;
|
QueuedPluginMap m_plugins;
|
||||||
/**
|
/**
|
||||||
* @brief pointer to database object
|
* @brief plugin auth token
|
||||||
*/
|
*/
|
||||||
QueuedPluginManagerInterface *m_interface = nullptr;
|
QString m_token;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,6 +72,14 @@ public:
|
|||||||
*/
|
*/
|
||||||
QueuedUser *add(const QueuedUser::QueuedUserDefinitions &_definitions,
|
QueuedUser *add(const QueuedUser::QueuedUserDefinitions &_definitions,
|
||||||
const long long _id);
|
const long long _id);
|
||||||
|
/**
|
||||||
|
* @brief authorize user manually
|
||||||
|
* @remark it ignores password input and creates unlimited token
|
||||||
|
* @param _user
|
||||||
|
* user name
|
||||||
|
* @return generated token
|
||||||
|
*/
|
||||||
|
QString authorize(const QString &_user);
|
||||||
/**
|
/**
|
||||||
* @brief authorize user
|
* @brief authorize user
|
||||||
* @param _user
|
* @param _user
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <QDBusMessage>
|
#include <QDBusMessage>
|
||||||
|
|
||||||
#include <queued/QueuedDatabaseSchema.h>
|
#include <queued/QueuedDatabaseSchema.h>
|
||||||
|
#include <queued/QueuedStaticConfig.h>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -786,8 +787,9 @@ void QueuedCore::initPlugins()
|
|||||||
= m_advancedSettings->get(QueuedConfig::QueuedSettings::Plugins)
|
= m_advancedSettings->get(QueuedConfig::QueuedSettings::Plugins)
|
||||||
.toString()
|
.toString()
|
||||||
.split('\n');
|
.split('\n');
|
||||||
|
QString token = m_users->authorize(m_settings->admin().name);
|
||||||
|
|
||||||
m_plugins = new QueuedPluginManager(this);
|
m_plugins = new QueuedPluginManager(this, token);
|
||||||
for (auto &plugin : pluginList)
|
for (auto &plugin : pluginList)
|
||||||
m_plugins->loadPlugin(plugin, pluginSettings(plugin));
|
m_plugins->loadPlugin(plugin, pluginSettings(plugin));
|
||||||
}
|
}
|
||||||
@ -998,11 +1000,16 @@ bool QueuedCore::editOptionPrivate(const QString &_key, const QVariant &_value)
|
|||||||
// add to child object
|
// add to child object
|
||||||
if (status) {
|
if (status) {
|
||||||
m_advancedSettings->set(_key, _value);
|
m_advancedSettings->set(_key, _value);
|
||||||
// TODO notify plugin if required
|
// notify plugins if required
|
||||||
|
if (m_plugins) {
|
||||||
|
auto tryPluginOption = m_plugins->convertOptionName(_key);
|
||||||
|
if ((!tryPluginOption.first.isEmpty())
|
||||||
|
&& (!tryPluginOption.second.isEmpty()))
|
||||||
|
m_plugins->optionChanged(_key, _value);
|
||||||
// notify plugins
|
// notify plugins
|
||||||
if (m_plugins)
|
|
||||||
emit(m_plugins->interface()->onEditOption(_key, _value));
|
emit(m_plugins->interface()->onEditOption(_key, _value));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@ -1037,12 +1044,13 @@ bool QueuedCore::editPluginPrivate(const QString &_plugin, const bool _add)
|
|||||||
QueuedConfig::QueuedSettings::Plugins),
|
QueuedConfig::QueuedSettings::Plugins),
|
||||||
pluginList.join('\n'));
|
pluginList.join('\n'));
|
||||||
// notify plugins
|
// notify plugins
|
||||||
|
if (m_plugins) {
|
||||||
if (_add)
|
if (_add)
|
||||||
if (m_plugins)
|
|
||||||
emit(m_plugins->interface()->onAddPlugin(_plugin));
|
emit(m_plugins->interface()->onAddPlugin(_plugin));
|
||||||
else if (m_plugins)
|
else
|
||||||
emit(m_plugins->interface()->onRemovePlugin(_plugin));
|
emit(m_plugins->interface()->onRemovePlugin(_plugin));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -34,8 +34,9 @@
|
|||||||
/**
|
/**
|
||||||
* @fn QueuedPluginManager
|
* @fn QueuedPluginManager
|
||||||
*/
|
*/
|
||||||
QueuedPluginManager::QueuedPluginManager(QObject *parent)
|
QueuedPluginManager::QueuedPluginManager(QObject *parent, const QString &token)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
|
, m_token(token)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_PL) << __PRETTY_FUNCTION__;
|
qCDebug(LOG_PL) << __PRETTY_FUNCTION__;
|
||||||
|
|
||||||
@ -121,6 +122,7 @@ bool QueuedPluginManager::loadPlugin(const QString &_name,
|
|||||||
if (item) {
|
if (item) {
|
||||||
m_plugins[_name] = item;
|
m_plugins[_name] = item;
|
||||||
item->init(pluginSettings);
|
item->init(pluginSettings);
|
||||||
|
item->setToken(m_token);
|
||||||
item->connect(interface());
|
item->connect(interface());
|
||||||
} else {
|
} else {
|
||||||
qCCritical(LOG_PL) << "Could not cast plugin" << _name;
|
qCCritical(LOG_PL) << "Could not cast plugin" << _name;
|
||||||
|
@ -93,6 +93,20 @@ QueuedUserManager::add(const QueuedUser::QueuedUserDefinitions &_definitions,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @fn authorize
|
||||||
|
*/
|
||||||
|
QString QueuedUserManager::authorize(const QString &_user)
|
||||||
|
{
|
||||||
|
qCDebug(LOG_LIB) << "Authorize user manually" << _user;
|
||||||
|
|
||||||
|
auto time = QDateTime::currentDateTimeUtc();
|
||||||
|
time = time.addDays(9999);
|
||||||
|
|
||||||
|
return m_tokens->registerToken(_user, time);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn authorize
|
* @fn authorize
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user