61 if (flags & (QDBusConnection::ExportScriptableProperties |
62 QDBusConnection::ExportNonScriptableProperties)) {
63 for (
int i = propOffset; i < mo->propertyCount(); ++i) {
65 QMetaProperty mp = mo->property(i);
67 if (!((mp.isScriptable() && (flags & QDBusConnection::ExportScriptableProperties)) ||
68 (!mp.isScriptable() && (flags & QDBusConnection::ExportNonScriptableProperties))))
71 QMetaType type = mp.metaType();
74 const char *signature = QDBusMetaType::typeToSignature(type);
78 retval +=
" <property name=\"%1\" type=\"%2\" access=\"%3\""_L1
79 .arg(QLatin1StringView(mp.name()),
80 QLatin1StringView(signature),
81 accessAsString(mp.isReadable(), mp.isWritable()));
83 if (!QDBusMetaType::signatureToMetaType(signature).isValid()) {
84 const char *typeName = type.name();
85 retval +=
">\n <annotation name=\"org.qtproject.QtDBus.QtTypeName\" value=\"%3\"/>\n </property>\n"_L1
86 .arg(typeNameToXml(typeName));
94 for (
int i = methodOffset; i < mo->methodCount(); ++i) {
95 QMetaMethod mm = mo->method(i);
97 bool isSignal =
false;
99 if (mm.methodType() == QMetaMethod::Signal)
102 else if (mm.access() == QMetaMethod::Public && mm.methodType() == QMetaMethod::Slot)
104 else if (mm.access() == QMetaMethod::Public && mm.methodType() == QMetaMethod::Method)
109 if (isSignal && !(flags & (QDBusConnection::ExportScriptableSignals |
110 QDBusConnection::ExportNonScriptableSignals)))
112 if (!isSignal && (!(flags & (QDBusConnection::ExportScriptableSlots | QDBusConnection::ExportNonScriptableSlots)) &&
113 !(flags & (QDBusConnection::ExportScriptableInvokables | QDBusConnection::ExportNonScriptableInvokables))))
118 bool isScriptable = mm.attributes() & QMetaMethod::Scriptable;
119 if (!isScriptable && !(flags & (isSignal ? QDBusConnection::ExportNonScriptableSignals : QDBusConnection::ExportNonScriptableInvokables | QDBusConnection::ExportNonScriptableSlots)))
122 QString xml = QString::asprintf(
" <%s name=\"%s\">\n",
123 isSignal ?
"signal" :
"method", mm.name().constData());
126 QMetaType typeId = mm.returnMetaType();
127 const bool hasVoidReturn = typeId.id() == QMetaType::Void;
128 if (typeId.isValid() && !hasVoidReturn) {
129 const char *typeName = QDBusMetaType::typeToSignature(typeId);
131 xml +=
" <arg type=\"%1\" direction=\"out\"/>\n"_L1
132 .arg(typeNameToXml(typeName));
135 if (!QDBusMetaType::signatureToMetaType(typeName).isValid())
136 xml +=
" <annotation name=\"org.qtproject.QtDBus.QtTypeName.Out0\" value=\"%1\"/>\n"_L1
137 .arg(typeNameToXml(QMetaType(typeId).name()));
139 qWarning() <<
"Unsupported return type" << typeId.id() << typeId.name() <<
"in method" << mm.name();
142 }
else if (!typeId.isValid()) {
143 qWarning() <<
"Invalid return type in method" << mm.name();
147 QList<QByteArray> names = mm.parameterNames();
148 QList<QMetaType> types;
150 int inputCount = qDBusParametersForMethod(mm, types, errorMsg);
151 const int outputArgsStart = hasVoidReturn ? 0 : 1;
152 if (inputCount == -1) {
153 qWarning() <<
"Skipped method" << mm.name() <<
":" << qPrintable(errorMsg);
156 if (isSignal && inputCount + 1 != types.size())
158 if (isSignal && types.at(inputCount) == QDBusMetaTypeId::message())
160 if (isSignal && mm.attributes() & QMetaMethod::Cloned)
164 for (j = 1; j < types.size(); ++j) {
166 if (types.at(j) == QDBusMetaTypeId::message()) {
172 if (!names.at(j - 1).isEmpty())
173 name =
"name=\"%1\" "_L1.arg(QLatin1StringView(names.at(j - 1)));
175 bool isOutput = isSignal || j > inputCount;
177 const char *signature = QDBusMetaType::typeToSignature(types.at(j));
178 xml += QString::asprintf(
" <arg %lstype=\"%s\" direction=\"%s\"/>\n",
179 qUtf16Printable(name), signature, isOutput ?
"out" :
"in");
182 if (!QDBusMetaType::signatureToMetaType(signature).isValid()) {
183 const char *typeName = QMetaType(types.at(j)).name();
184 xml += QString::fromLatin1(
" <annotation name=\"org.qtproject.QtDBus.QtTypeName.%1%2\" value=\"%3\"/>\n")
185 .arg(isOutput ?
"Out"_L1 :
"In"_L1)
186 .arg(isOutput && !isSignal ? j - 1 - inputCount + outputArgsStart : j - 1)
187 .arg(typeNameToXml(typeName));
193 wantedMask = isSignal ? QDBusConnection::ExportScriptableSignals
194 : isSlot ? QDBusConnection::ExportScriptableSlots
195 : QDBusConnection::ExportScriptableInvokables;
197 wantedMask = isSignal ? QDBusConnection::ExportNonScriptableSignals
198 : isSlot ? QDBusConnection::ExportNonScriptableSlots
199 : QDBusConnection::ExportNonScriptableInvokables;
200 if ((flags & wantedMask) != wantedMask)
203 if (qDBusCheckAsyncTag(mm.tag()))
208 retval +=
" </%1>\n"_L1.arg(isSignal ?
"signal"_L1 :
"method"_L1);