fix merge conflicts

This commit is contained in:
Evgenii Alekseev 2017-03-24 19:03:51 +03:00
commit 505c1e2b93
6 changed files with 59 additions and 12 deletions

View File

@ -54,6 +54,14 @@ public:
* @remark plugin settings will be stored as "plugin.name.Key"
*/
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
* @param _key
@ -61,7 +69,8 @@ public:
* @param _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)

View File

@ -50,8 +50,10 @@ public:
* @brief QueuedPluginManager class constructor
* @param parent
* pointer to parent item
* @param token
* plugin auth token
*/
explicit QueuedPluginManager(QObject *parent);
explicit QueuedPluginManager(QObject *parent, const QString &token);
/**
* @brief QueuedPluginManager class destructor
*/
@ -101,14 +103,18 @@ public slots:
void optionChanged(const QString &_key, const QVariant &_value);
private:
/**
* @brief pointer to database object
*/
QueuedPluginManagerInterface *m_interface = nullptr;
/**
* @brief loaded plugins
*/
QueuedPluginMap m_plugins;
/**
* @brief pointer to database object
* @brief plugin auth token
*/
QueuedPluginManagerInterface *m_interface = nullptr;
QString m_token;
};

View File

@ -72,6 +72,14 @@ public:
*/
QueuedUser *add(const QueuedUser::QueuedUserDefinitions &_definitions,
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
* @param _user

View File

@ -27,6 +27,7 @@
#include <QDBusMessage>
#include <queued/QueuedDatabaseSchema.h>
#include <queued/QueuedStaticConfig.h>
/**
@ -786,8 +787,9 @@ void QueuedCore::initPlugins()
= m_advancedSettings->get(QueuedConfig::QueuedSettings::Plugins)
.toString()
.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)
m_plugins->loadPlugin(plugin, pluginSettings(plugin));
}
@ -998,10 +1000,15 @@ bool QueuedCore::editOptionPrivate(const QString &_key, const QVariant &_value)
// add to child object
if (status) {
m_advancedSettings->set(_key, _value);
// TODO notify plugin if required
// notify plugins
if (m_plugins)
// 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
emit(m_plugins->interface()->onEditOption(_key, _value));
}
}
return status;
@ -1037,11 +1044,12 @@ bool QueuedCore::editPluginPrivate(const QString &_plugin, const bool _add)
QueuedConfig::QueuedSettings::Plugins),
pluginList.join('\n'));
// notify plugins
if (_add)
if (m_plugins)
if (m_plugins) {
if (_add)
emit(m_plugins->interface()->onAddPlugin(_plugin));
else if (m_plugins)
else
emit(m_plugins->interface()->onRemovePlugin(_plugin));
}
}
return status;

View File

@ -34,8 +34,9 @@
/**
* @fn QueuedPluginManager
*/
QueuedPluginManager::QueuedPluginManager(QObject *parent)
QueuedPluginManager::QueuedPluginManager(QObject *parent, const QString &token)
: QObject(parent)
, m_token(token)
{
qCDebug(LOG_PL) << __PRETTY_FUNCTION__;
@ -121,6 +122,7 @@ bool QueuedPluginManager::loadPlugin(const QString &_name,
if (item) {
m_plugins[_name] = item;
item->init(pluginSettings);
item->setToken(m_token);
item->connect(interface());
} else {
qCCritical(LOG_PL) << "Could not cast plugin" << _name;

View File

@ -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
*/