add methods to dbus interface

This commit is contained in:
2016-10-22 00:43:16 +03:00
parent c103986f37
commit 77a94aa0c1
3 changed files with 65 additions and 4 deletions

View File

@ -35,7 +35,58 @@ AWDBusAdaptor::~AWDBusAdaptor()
}
qlonglong AWDBusAdaptor::whoAmI() const
QString AWDBusAdaptor::Info(const QString key) const
{
return m_plugin->infoByKey(key);
}
QStringList AWDBusAdaptor::Keys(const QString regexp) const
{
return m_plugin->dictKeys(true, regexp);
}
QString AWDBusAdaptor::Value(const QString key) const
{
return m_plugin->valueByKey(key);
}
qlonglong AWDBusAdaptor::WhoAmI() const
{
return reinterpret_cast<qlonglong>(m_plugin);
}
void AWDBusAdaptor::SetLogLevel(const QString what, const int level)
{
qCDebug(LOG_DBUS) << "Set log level" << level << "for" << what;
if (level >= m_logLevels.count()) {
qCDebug(LOG_DBUS) << "Invalid logging level" << level
<< "should be less than" << m_logLevels.count();
return;
}
for (auto lev : m_logLevels)
SetLogLevel(what, lev, m_logLevels.indexOf(lev) >= level);
}
void AWDBusAdaptor::SetLogLevel(const QString what, const QString level,
const bool enabled)
{
qCDebug(LOG_DBUS) << "Set log level" << level << "enabled" << enabled
<< "for" << what;
if (!m_logLevels.contains(level)) {
qCDebug(LOG_DBUS) << "Invalid logging level" << level << "should be in"
<< m_logLevels;
return;
}
QString state = enabled ? QString("true") : QString("false");
QLoggingCategory::setFilterRules(
QString("%1.%2=%3").arg(what).arg(level).arg(state));
}