6#include <QMetaClassInfo>
22 const QString& MethodsToHide)
31 static QString s_defaultHide = {
"destroyed,deleteLater,objectNameChanged,RegisterCustomTypes" };
34 auto index = Meta.indexOfClassInfo(
"Version");
36 m_version = Meta.classInfo(index).value();
38 LOG(VB_GENERAL, LOG_WARNING, QStringLiteral(
"Service '%1' is missing version information").arg(
Name));
41 QList<const QMetaObject*> metas;
43 const QMetaObject* super = Meta.superClass();
47 super = super->superClass();
50 QString hide = s_defaultHide + MethodsToHide;
53 for (
const auto * meta : metas)
55 for (
int i = 0; i < meta->methodCount(); ++i)
57 QMetaMethod method = meta->method(i);
60 if (QMetaMethod::Public != method.access())
64 QString name(method.methodSignature());
65 name = name.section(
'(', 0, 0);
66 if (hide.contains(name))
71 for (
const auto & [_name, _method] : Methods)
73 if ((_name ==
Search) && (_method->m_method.methodSignature() == Method->m_method.methodSignature()) &&
74 (_method->m_method.returnType() == Method->m_method.returnType()))
83 if (QMetaMethod::Signal == method.methodType())
88 RemoveExisting(
m_signals, newmethod, name);
93 else if (QMetaMethod::Slot == method.methodType())
103 RemoveExisting(
m_slots, newmethod, name);
104 m_slots.emplace(name, newmethod);
111 int constpropertyindex = -1;
112 for (
const auto * meta : metas)
114 for (
int i = meta->propertyOffset(); i < meta->propertyCount(); ++i)
116 QMetaProperty
property = meta->property(i);
117 QString propertyname(property.name());
119 if (propertyname != QString(
"objectName") && property.isReadable() &&
120 ((property.hasNotifySignal() && property.notifySignalIndex() > -1) || property.isConstant()))
123 if (property.notifySignalIndex() > -1)
124 m_properties.emplace(property.notifySignalIndex(), property.propertyIndex());
126 m_properties.emplace(constpropertyindex--, property.propertyIndex());
130 LOG(VB_GENERAL, LOG_INFO, QString(
"Service '%1' introspection complete").arg(
Name));
136 int index = Meta.indexOfClassInfo(Method.toLatin1().constData());
139 QStringList infos = QString(Meta.classInfo(index).value()).split(
';', Qt::SkipEmptyParts);
140 for (
const QString &
info : std::as_const(infos))
142 if (
info.startsWith(QStringLiteral(
"methods=")))
144 if (
info.startsWith(QStringLiteral(
"name=")))
145 ReturnName =
info.mid(5).trimmed();
155 else if (Method.startsWith(QStringLiteral(
"Get"), Qt::CaseInsensitive))
159 else if (Method.startsWith(QStringLiteral(
"Set"), Qt::CaseInsensitive))
166 LOG(VB_GENERAL, LOG_ERR, QString(
"Failed to get request types for method '%1'- ignoring").arg(Method));
174 int index = Meta.indexOfClassInfo(Method.toLatin1().constData());
177 QStringList infos = QString(Meta.classInfo(index).value()).split(
';', Qt::SkipEmptyParts);
178 auto isAuth = [](
const QString&
info)
179 {
return info.startsWith(QStringLiteral(
"AuthRequired=")); };
180 return std::ranges::any_of(std::as_const(infos), isAuth);
#define RegisterCallback(a, b, c)
static int RequestsFromString(const QString &Requests)
static const struct wl_interface * types[]
std::function< void()> HTTPRegisterTypes
#define LOG(_MASK_, _LEVEL_, _QSTRING_)