2#include <QMetaClassInfo>
19 const QString& MethodsToHide)
28 static QString s_defaultHide = {
"destroyed,deleteLater,objectNameChanged,RegisterCustomTypes" };
31 auto index = Meta.indexOfClassInfo(
"Version");
33 m_version = Meta.classInfo(index).value();
35 LOG(VB_GENERAL, LOG_WARNING, QStringLiteral(
"Service '%1' is missing version information").arg(
Name));
38 QList<const QMetaObject*> metas;
40 const QMetaObject* super = Meta.superClass();
44 super = super->superClass();
47 QString hide = s_defaultHide + MethodsToHide;
50 for (
const auto * meta : metas)
52 for (
int i = 0; i < meta->methodCount(); ++i)
54 QMetaMethod method = meta->method(i);
57 if (QMetaMethod::Public != method.access())
61 QString name(method.methodSignature());
62 name = name.section(
'(', 0, 0);
63 if (hide.contains(name))
68 for (
const auto & [_name, _method] : Methods)
70 if ((_name ==
Search) && (_method->m_method.methodSignature() == Method->m_method.methodSignature()) &&
71 (_method->m_method.returnType() == Method->m_method.returnType()))
80 if (QMetaMethod::Signal == method.methodType())
85 RemoveExisting(
m_signals, newmethod, name);
90 else if (QMetaMethod::Slot == method.methodType())
100 RemoveExisting(
m_slots, newmethod, name);
101 m_slots.emplace(name, newmethod);
108 int constpropertyindex = -1;
109 for (
const auto * meta : metas)
111 for (
int i = meta->propertyOffset(); i < meta->propertyCount(); ++i)
113 QMetaProperty
property = meta->property(i);
114 QString propertyname(property.name());
116 if (propertyname != QString(
"objectName") && property.isReadable() &&
117 ((property.hasNotifySignal() && property.notifySignalIndex() > -1) || property.isConstant()))
120 if (property.notifySignalIndex() > -1)
121 m_properties.emplace(property.notifySignalIndex(), property.propertyIndex());
123 m_properties.emplace(constpropertyindex--, property.propertyIndex());
127 LOG(VB_GENERAL, LOG_INFO, QString(
"Service '%1' introspection complete").arg(
Name));
133 int index = Meta.indexOfClassInfo(Method.toLatin1().constData());
136 QStringList infos = QString(Meta.classInfo(index).value()).split(
';', Qt::SkipEmptyParts);
137 for (
const QString &
info : std::as_const(infos))
139 if (
info.startsWith(QStringLiteral(
"methods=")))
141 if (
info.startsWith(QStringLiteral(
"name=")))
142 ReturnName =
info.mid(5).trimmed();
152 else if (Method.startsWith(QStringLiteral(
"Get"), Qt::CaseInsensitive))
156 else if (Method.startsWith(QStringLiteral(
"Set"), Qt::CaseInsensitive))
163 LOG(VB_GENERAL, LOG_ERR, QString(
"Failed to get request types for method '%1'- ignoring").arg(Method));
171 int index = Meta.indexOfClassInfo(Method.toLatin1().constData());
174 QStringList infos = QString(Meta.classInfo(index).value()).split(
';', Qt::SkipEmptyParts);
175 auto isAuth = [](
const QString&
info)
176 {
return info.startsWith(QStringLiteral(
"AuthRequired=")); };
177 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_)