2 #include <QMetaClassInfo>
18 const QString& MethodsToHide)
27 static QString s_defaultHide = {
"destroyed,deleteLater,objectNameChanged,RegisterCustomTypes" };
30 auto index = Meta.indexOfClassInfo(
"Version");
32 m_version = Meta.classInfo(index).value();
34 LOG(VB_GENERAL, LOG_WARNING, QStringLiteral(
"Service '%1' is missing version information").arg(
Name));
37 QList<const QMetaObject*> metas;
39 const QMetaObject* super = Meta.superClass();
43 super = super->superClass();
46 QString hide = s_defaultHide + MethodsToHide;
49 for (
const auto * meta : metas)
51 for (
int i = 0; i < meta->methodCount(); ++i)
53 QMetaMethod method = meta->method(i);
56 if (QMetaMethod::Public != method.access())
60 QString name(method.methodSignature());
61 name = name.section(
'(', 0, 0);
62 if (hide.contains(name))
67 for (
const auto & [_name, _method] : Methods)
69 if ((_name ==
Search) && (_method->m_method.methodSignature() == Method->m_method.methodSignature()) &&
70 (_method->m_method.returnType() == Method->m_method.returnType()))
79 if (QMetaMethod::Signal == method.methodType())
84 RemoveExisting(
m_signals, newmethod, name);
89 else if (QMetaMethod::Slot == method.methodType())
99 RemoveExisting(
m_slots, newmethod, name);
100 m_slots.emplace(name, newmethod);
107 int constpropertyindex = -1;
108 for (
const auto * meta : metas)
110 for (
int i = meta->propertyOffset(); i < meta->propertyCount(); ++i)
112 QMetaProperty
property = meta->property(i);
113 QString propertyname(property.name());
115 if (propertyname != QString(
"objectName") && property.isReadable() &&
116 ((property.hasNotifySignal() && property.notifySignalIndex() > -1) || property.isConstant()))
119 if (property.notifySignalIndex() > -1)
120 m_properties.emplace(property.notifySignalIndex(), property.propertyIndex());
122 m_properties.emplace(constpropertyindex--, property.propertyIndex());
126 LOG(VB_GENERAL, LOG_INFO, QString(
"Service '%1' introspection complete").arg(
Name));
132 int index = Meta.indexOfClassInfo(Method.toLatin1());
135 QStringList infos = QString(Meta.classInfo(index).value()).split(
';', Qt::SkipEmptyParts);
136 foreach (
const QString &
info, infos)
138 if (
info.startsWith(QStringLiteral(
"methods=")))
140 if (
info.startsWith(QStringLiteral(
"name=")))
141 ReturnName =
info.mid(5).trimmed();
151 else if (Method.startsWith(QStringLiteral(
"Get"), Qt::CaseInsensitive))
155 else if (Method.startsWith(QStringLiteral(
"Set"), Qt::CaseInsensitive))
162 LOG(VB_GENERAL, LOG_ERR, QString(
"Failed to get request types for method '%1'- ignoring").arg(Method));
170 int index = Meta.indexOfClassInfo(Method.toLatin1());
173 QStringList infos = QString(Meta.classInfo(index).value()).split(
';', Qt::SkipEmptyParts);
174 auto isAuth = [](
const QString&
info)
175 {
return info.startsWith(QStringLiteral(
"AuthRequired=")); };
176 return std::any_of(infos.cbegin(), infos.cend(), isAuth);