2022-05-10 10:06:48 +00:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifndef SERVEROBJECT_H
|
|
|
|
#define SERVEROBJECT_H
|
|
|
|
|
|
|
|
#include <QObject>
|
2021-01-08 11:57:47 +00:00
|
|
|
#include <QDBusConnection>
|
|
|
|
#include <QDBusVariant>
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
class ServerObject: public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2012-04-20 12:34:15 +00:00
|
|
|
Q_CLASSINFO("D-Bus Interface", "org.qtproject.autotests.Performance")
|
2011-04-27 10:05:43 +00:00
|
|
|
public:
|
2020-10-07 11:05:48 +00:00
|
|
|
ServerObject(const QString &objectPath, QDBusConnection conn, QObject *parent = nullptr)
|
2011-04-27 10:05:43 +00:00
|
|
|
: QObject(parent)
|
|
|
|
{
|
|
|
|
conn.registerObject(objectPath, this, QDBusConnection::ExportAllSlots);
|
|
|
|
}
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
Q_NOREPLY void noReply(const QByteArray &)
|
|
|
|
{
|
|
|
|
// black hole
|
|
|
|
}
|
|
|
|
Q_NOREPLY void noReply(const QString &)
|
|
|
|
{
|
|
|
|
// black hole
|
|
|
|
}
|
|
|
|
Q_NOREPLY void noReply(const QDBusVariant &)
|
|
|
|
{
|
|
|
|
// black hole
|
|
|
|
}
|
|
|
|
|
|
|
|
int size(const QByteArray &data)
|
|
|
|
{
|
|
|
|
return data.size();
|
|
|
|
}
|
|
|
|
int size(const QString &data)
|
|
|
|
{
|
|
|
|
return data.size();
|
|
|
|
}
|
|
|
|
int size(const QDBusVariant &data)
|
|
|
|
{
|
|
|
|
QVariant v = data.variant();
|
2021-02-01 09:24:10 +00:00
|
|
|
switch (v.typeId()) {
|
|
|
|
case QMetaType::QByteArray:
|
2011-04-27 10:05:43 +00:00
|
|
|
return v.toByteArray().size();
|
2021-02-01 09:24:10 +00:00
|
|
|
case QMetaType::QStringList:
|
2011-04-27 10:05:43 +00:00
|
|
|
return v.toStringList().size();
|
2021-02-01 09:24:10 +00:00
|
|
|
case QMetaType::QString:
|
2011-04-27 10:05:43 +00:00
|
|
|
default:
|
|
|
|
return v.toString().size();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray echo(const QByteArray &data)
|
|
|
|
{
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
QString echo(const QString &data)
|
|
|
|
{
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
QDBusVariant echo(const QDBusVariant &data)
|
|
|
|
{
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nothing()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|