mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 15:37:23 +00:00
make tests great again!
Also dbus adaptor has been renamed, because it does not allow to register one service for several applications (like plasmashell and plasmawindowed)
This commit is contained in:
parent
5e08434835
commit
5c56f813d2
@ -17,6 +17,9 @@
|
||||
|
||||
#include "awdbusadaptor.h"
|
||||
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusConnectionInterface>
|
||||
|
||||
#include "awdebug.h"
|
||||
#include "awkeys.h"
|
||||
|
||||
@ -35,6 +38,25 @@ AWDBusAdaptor::~AWDBusAdaptor()
|
||||
}
|
||||
|
||||
|
||||
QStringList AWDBusAdaptor::ActiveServices() const
|
||||
{
|
||||
QDBusMessage listServices = QDBusConnection::sessionBus().interface()->call(
|
||||
QDBus::BlockWithGui, "ListNames");
|
||||
if (listServices.arguments().isEmpty()) {
|
||||
qCWarning(LOG_DBUS) << "Could not find any DBus service";
|
||||
return {};
|
||||
}
|
||||
QStringList arguments = listServices.arguments().first().toStringList();
|
||||
|
||||
return std::accumulate(arguments.cbegin(), arguments.cend(), QStringList(),
|
||||
[](QStringList &source, QString service) {
|
||||
if (service.startsWith(AWDBUS_SERVICE))
|
||||
source.append(service);
|
||||
return source;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
QString AWDBusAdaptor::Info(const QString &key) const
|
||||
{
|
||||
return m_plugin->infoByKey(key);
|
||||
|
@ -37,6 +37,7 @@ public:
|
||||
|
||||
public slots:
|
||||
// get methods
|
||||
QStringList ActiveServices() const;
|
||||
QString Info(const QString &key) const;
|
||||
QStringList Keys(const QString ®exp) const;
|
||||
QString Value(const QString &key) const;
|
||||
|
@ -147,9 +147,8 @@ QStringList AWKeyCache::getRequiredKeys(const QStringList &_keys,
|
||||
used << "swapgb"
|
||||
<< "swapfreegb";
|
||||
// network keys
|
||||
QStringList netKeys({"up", "upkb", "uptot", "uptotkb", "upunits",
|
||||
"down", "downkb", "downtot", "downtotkb",
|
||||
"downunits"});
|
||||
QStringList netKeys({"up", "upkb", "uptot", "uptotkb", "upunits", "down",
|
||||
"downkb", "downtot", "downtotkb", "downunits"});
|
||||
for (auto &key : netKeys) {
|
||||
if (!used.contains(key))
|
||||
continue;
|
||||
|
@ -327,10 +327,12 @@ void AWKeys::createDBusInterface()
|
||||
|
||||
// create session
|
||||
QDBusConnection bus = QDBusConnection::sessionBus();
|
||||
if (!bus.registerService(AWDBUS_SERVICE))
|
||||
// HACK we are going to use different services because it binds to
|
||||
// application
|
||||
if (!bus.registerService(QString("%1.i%2").arg(AWDBUS_SERVICE).arg(id)))
|
||||
qCWarning(LOG_AW) << "Could not register DBus service, last error"
|
||||
<< bus.lastError().message();
|
||||
if (!bus.registerObject(QString("/%1").arg(id), new AWDBusAdaptor(this),
|
||||
if (!bus.registerObject(AWDBUS_PATH, new AWDBusAdaptor(this),
|
||||
QDBusConnection::ExportAllContents))
|
||||
qCWarning(LOG_AW) << "Could not register DBus object, last error"
|
||||
<< bus.lastError().message();
|
||||
|
@ -174,7 +174,8 @@ void TestAWKeys::test_dbus()
|
||||
// create connection and message
|
||||
QDBusConnection bus = QDBusConnection::sessionBus();
|
||||
QDBusMessage request = QDBusMessage::createMethodCall(
|
||||
AWDBUS_SERVICE, QString("/%1").arg(id), AWDBUS_SERVICE, "WhoAmI");
|
||||
QString("%1.i%2").arg(AWDBUS_SERVICE).arg(id), AWDBUS_PATH,
|
||||
AWDBUS_SERVICE, "WhoAmI");
|
||||
// send message to dbus
|
||||
QDBusMessage response = bus.call(request, QDBus::BlockWithGui);
|
||||
|
||||
|
@ -44,6 +44,7 @@ const int AW_TELEMETRY_API = 1;
|
||||
// use define here instead of normal const definition for moc
|
||||
#define AWDBUS_SERVICE_NAME "org.kde.plasma.awesomewidget"
|
||||
const char AWDBUS_SERVICE[] = AWDBUS_SERVICE_NAME;
|
||||
const char AWDBUS_PATH[] = "/awesomewidgets";
|
||||
// network requests timeout, ms
|
||||
const int REQUEST_TIMEOUT = 3000;
|
||||
// available time keys
|
||||
|
Loading…
Reference in New Issue
Block a user