mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 23:47:20 +00:00
add methods to dbus interface
This commit is contained in:
parent
c103986f37
commit
77a94aa0c1
@ -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);
|
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));
|
||||||
|
}
|
||||||
|
@ -33,13 +33,24 @@ class AWDBusAdaptor : public QDBusAbstractAdaptor
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit AWDBusAdaptor(AWKeys *parent = nullptr);
|
explicit AWDBusAdaptor(AWKeys *parent = nullptr);
|
||||||
~AWDBusAdaptor();
|
virtual ~AWDBusAdaptor();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
qlonglong whoAmI() const;
|
// get methods
|
||||||
|
QString Info(const QString key) const;
|
||||||
|
QStringList Keys(const QString regexp) const;
|
||||||
|
QString Value(const QString key) const;
|
||||||
|
qlonglong WhoAmI() const;
|
||||||
|
// set methods
|
||||||
|
void SetLogLevel(const QString what, const int level);
|
||||||
|
void SetLogLevel(const QString what, const QString level,
|
||||||
|
const bool enabled);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AWKeys *m_plugin = nullptr;
|
AWKeys *m_plugin = nullptr;
|
||||||
|
QStringList m_logLevels = QStringList()
|
||||||
|
<< QString("debug") << QString("info")
|
||||||
|
<< QString("warning") << QString("critical");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -81,7 +81,6 @@ AWKeys::~AWKeys()
|
|||||||
// delete dbus session
|
// delete dbus session
|
||||||
long id = reinterpret_cast<long>(this);
|
long id = reinterpret_cast<long>(this);
|
||||||
QDBusConnection::sessionBus().unregisterObject(QString("/%1").arg(id));
|
QDBusConnection::sessionBus().unregisterObject(QString("/%1").arg(id));
|
||||||
QDBusConnection::sessionBus().unregisterService(AWDBUS_SERVICE);
|
|
||||||
|
|
||||||
// core
|
// core
|
||||||
delete m_dataEngineAggregator;
|
delete m_dataEngineAggregator;
|
||||||
|
Loading…
Reference in New Issue
Block a user