Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
4 | ** Contact: http://www.qt-project.org/ | - |
5 | ** | - |
6 | ** This file is part of the QtDBus module of the Qt Toolkit. | - |
7 | ** | - |
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
9 | ** Commercial License Usage | - |
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
11 | ** accordance with the commercial license agreement provided with the | - |
12 | ** Software or, alternatively, in accordance with the terms contained in | - |
13 | ** a written agreement between you and Digia. For licensing terms and | - |
14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
16 | ** | - |
17 | ** GNU Lesser General Public License Usage | - |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
19 | ** General Public License version 2.1 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
24 | ** | - |
25 | ** In addition, as a special exception, Digia gives you certain additional | - |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
28 | ** | - |
29 | ** GNU General Public License Usage | - |
30 | ** Alternatively, this file may be used under the terms of the GNU | - |
31 | ** General Public License version 3.0 as published by the Free Software | - |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
33 | ** packaging of this file. Please review the following information to | - |
34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
36 | ** | - |
37 | ** | - |
38 | ** $QT_END_LICENSE$ | - |
39 | ** | - |
40 | ****************************************************************************/ | - |
41 | | - |
42 | #include <QtCore/qmetaobject.h> | - |
43 | #include <QtCore/qstringlist.h> | - |
44 | | - |
45 | #include "qdbusinterface_p.h" // for ANNOTATION_NO_WAIT | - |
46 | #include "qdbusabstractadaptor_p.h" // for QCLASSINFO_DBUS_* | - |
47 | #include "qdbusconnection_p.h" // for the flags | - |
48 | #include "qdbusmetatype_p.h" | - |
49 | #include "qdbusmetatype.h" | - |
50 | #include "qdbusutil_p.h" | - |
51 | | - |
52 | #ifndef QT_NO_DBUS | - |
53 | | - |
54 | QT_BEGIN_NAMESPACE | - |
55 | | - |
56 | extern Q_DBUS_EXPORT QString qDBusGenerateMetaObjectXml(QString interface, const QMetaObject *mo, | - |
57 | const QMetaObject *base, int flags); | - |
58 | | - |
59 | static inline QString typeNameToXml(const char *typeName) | - |
60 | { | - |
61 | // ### copied from qtextdocument.cpp | - |
62 | // ### move this into Qt Core at some point | - |
63 | QString plain = QLatin1String(typeName); executed (the execution status of this line is deduced): QString plain = QLatin1String(typeName); | - |
64 | QString rich; executed (the execution status of this line is deduced): QString rich; | - |
65 | rich.reserve(int(plain.length() * 1.1)); executed (the execution status of this line is deduced): rich.reserve(int(plain.length() * 1.1)); | - |
66 | for (int i = 0; i < plain.length(); ++i) { evaluated: i < plain.length() yes Evaluation Count:2738 | yes Evaluation Count:555 |
| 555-2738 |
67 | if (plain.at(i) == QLatin1Char('<')) partially evaluated: plain.at(i) == QLatin1Char('<') no Evaluation Count:0 | yes Evaluation Count:2738 |
| 0-2738 |
68 | rich += QLatin1String("<"); never executed: rich += QLatin1String("<"); | 0 |
69 | else if (plain.at(i) == QLatin1Char('>')) partially evaluated: plain.at(i) == QLatin1Char('>') no Evaluation Count:0 | yes Evaluation Count:2738 |
| 0-2738 |
70 | rich += QLatin1String(">"); never executed: rich += QLatin1String(">"); | 0 |
71 | else if (plain.at(i) == QLatin1Char('&')) partially evaluated: plain.at(i) == QLatin1Char('&') no Evaluation Count:0 | yes Evaluation Count:2738 |
| 0-2738 |
72 | rich += QLatin1String("&"); never executed: rich += QLatin1String("&"); | 0 |
73 | else | - |
74 | rich += plain.at(i); executed: rich += plain.at(i); Execution Count:2738 | 2738 |
75 | } | - |
76 | return rich; executed: return rich; Execution Count:555 | 555 |
77 | } | - |
78 | | - |
79 | // implement the D-Bus org.freedesktop.DBus.Introspectable interface | - |
80 | // we do that by analysing the metaObject of all the adaptor interfaces | - |
81 | | - |
82 | static QString generateInterfaceXml(const QMetaObject *mo, int flags, int methodOffset, int propOffset) | - |
83 | { | - |
84 | QString retval; executed (the execution status of this line is deduced): QString retval; | - |
85 | | - |
86 | // start with properties: | - |
87 | if (flags & (QDBusConnection::ExportScriptableProperties | evaluated: flags & (QDBusConnection::ExportScriptableProperties | QDBusConnection::ExportNonScriptableProperties) yes Evaluation Count:56 | yes Evaluation Count:4 |
| 4-56 |
88 | QDBusConnection::ExportNonScriptableProperties)) { evaluated: flags & (QDBusConnection::ExportScriptableProperties | QDBusConnection::ExportNonScriptableProperties) yes Evaluation Count:56 | yes Evaluation Count:4 |
| 4-56 |
89 | for (int i = propOffset; i < mo->propertyCount(); ++i) { evaluated: i < mo->propertyCount() yes Evaluation Count:42 | yes Evaluation Count:56 |
| 42-56 |
90 | static const char *accessvalues[] = {0, "read", "write", "readwrite"}; | - |
91 | | - |
92 | QMetaProperty mp = mo->property(i); executed (the execution status of this line is deduced): QMetaProperty mp = mo->property(i); | - |
93 | | - |
94 | if (!((mp.isScriptable() && (flags & QDBusConnection::ExportScriptableProperties)) || partially evaluated: mp.isScriptable() yes Evaluation Count:42 | no Evaluation Count:0 |
partially evaluated: (flags & QDBusConnection::ExportScriptableProperties) yes Evaluation Count:42 | no Evaluation Count:0 |
| 0-42 |
95 | (!mp.isScriptable() && (flags & QDBusConnection::ExportNonScriptableProperties)))) never evaluated: !mp.isScriptable() never evaluated: (flags & QDBusConnection::ExportNonScriptableProperties) | 0 |
96 | continue; never executed: continue; | 0 |
97 | | - |
98 | int access = 0; executed (the execution status of this line is deduced): int access = 0; | - |
99 | if (mp.isReadable()) partially evaluated: mp.isReadable() yes Evaluation Count:42 | no Evaluation Count:0 |
| 0-42 |
100 | access |= 1; executed: access |= 1; Execution Count:42 | 42 |
101 | if (mp.isWritable()) evaluated: mp.isWritable() yes Evaluation Count:16 | yes Evaluation Count:26 |
| 16-26 |
102 | access |= 2; executed: access |= 2; Execution Count:16 | 16 |
103 | | - |
104 | int typeId = mp.userType(); executed (the execution status of this line is deduced): int typeId = mp.userType(); | - |
105 | if (!typeId) partially evaluated: !typeId no Evaluation Count:0 | yes Evaluation Count:42 |
| 0-42 |
106 | continue; never executed: continue; | 0 |
107 | const char *signature = QDBusMetaType::typeToSignature(typeId); executed (the execution status of this line is deduced): const char *signature = QDBusMetaType::typeToSignature(typeId); | - |
108 | if (!signature) evaluated: !signature yes Evaluation Count:6 | yes Evaluation Count:36 |
| 6-36 |
109 | continue; executed: continue; Execution Count:6 | 6 |
110 | | - |
111 | retval += QString::fromLatin1(" <property name=\"%1\" type=\"%2\" access=\"%3\"") executed (the execution status of this line is deduced): retval += QString::fromLatin1(" <property name=\"%1\" type=\"%2\" access=\"%3\"") | - |
112 | .arg(QLatin1String(mp.name())) executed (the execution status of this line is deduced): .arg(QLatin1String(mp.name())) | - |
113 | .arg(QLatin1String(signature)) executed (the execution status of this line is deduced): .arg(QLatin1String(signature)) | - |
114 | .arg(QLatin1String(accessvalues[access])); executed (the execution status of this line is deduced): .arg(QLatin1String(accessvalues[access])); | - |
115 | | - |
116 | if (QDBusMetaType::signatureToType(signature) == QVariant::Invalid) { evaluated: QDBusMetaType::signatureToType(signature) == QVariant::Invalid yes Evaluation Count:1 | yes Evaluation Count:35 |
| 1-35 |
117 | const char *typeName = QMetaType::typeName(typeId); executed (the execution status of this line is deduced): const char *typeName = QMetaType::typeName(typeId); | - |
118 | retval += QString::fromLatin1(">\n <annotation name=\"org.qtproject.QtDBus.QtTypeName\" value=\"%3\"/>\n </property>\n") executed (the execution status of this line is deduced): retval += QString::fromLatin1(">\n <annotation name=\"org.qtproject.QtDBus.QtTypeName\" value=\"%3\"/>\n </property>\n") | - |
119 | .arg(typeNameToXml(typeName)); executed (the execution status of this line is deduced): .arg(typeNameToXml(typeName)); | - |
120 | } else { executed: } Execution Count:1 | 1 |
121 | retval += QLatin1String("/>\n"); executed (the execution status of this line is deduced): retval += QLatin1String("/>\n"); | - |
122 | } executed: } Execution Count:35 | 35 |
123 | } | - |
124 | } executed: } Execution Count:56 | 56 |
125 | | - |
126 | // now add methods: | - |
127 | for (int i = methodOffset; i < mo->methodCount(); ++i) { evaluated: i < mo->methodCount() yes Evaluation Count:849 | yes Evaluation Count:60 |
| 60-849 |
128 | QMetaMethod mm = mo->method(i); executed (the execution status of this line is deduced): QMetaMethod mm = mo->method(i); | - |
129 | | - |
130 | bool isSignal; executed (the execution status of this line is deduced): bool isSignal; | - |
131 | if (mm.methodType() == QMetaMethod::Signal) evaluated: mm.methodType() == QMetaMethod::Signal yes Evaluation Count:34 | yes Evaluation Count:815 |
| 34-815 |
132 | // adding a signal | - |
133 | isSignal = true; executed: isSignal = true; Execution Count:34 | 34 |
134 | else if (mm.access() == QMetaMethod::Public && (mm.methodType() == QMetaMethod::Slot || mm.methodType() == QMetaMethod::Method)) partially evaluated: mm.access() == QMetaMethod::Public yes Evaluation Count:815 | no Evaluation Count:0 |
partially evaluated: mm.methodType() == QMetaMethod::Slot yes Evaluation Count:815 | no Evaluation Count:0 |
never evaluated: mm.methodType() == QMetaMethod::Method | 0-815 |
135 | isSignal = false; executed: isSignal = false; Execution Count:815 | 815 |
136 | else | - |
137 | continue; // neither signal nor public slot never executed: continue; | 0 |
138 | | - |
139 | if (isSignal && !(flags & (QDBusConnection::ExportScriptableSignals | evaluated: isSignal yes Evaluation Count:34 | yes Evaluation Count:815 |
partially evaluated: !(flags & (QDBusConnection::ExportScriptableSignals | QDBusConnection::ExportNonScriptableSignals)) no Evaluation Count:0 | yes Evaluation Count:34 |
| 0-815 |
140 | QDBusConnection::ExportNonScriptableSignals))) partially evaluated: !(flags & (QDBusConnection::ExportScriptableSignals | QDBusConnection::ExportNonScriptableSignals)) no Evaluation Count:0 | yes Evaluation Count:34 |
| 0-34 |
141 | continue; // we're not exporting any signals never executed: continue; | 0 |
142 | if (!isSignal && (!(flags & (QDBusConnection::ExportScriptableSlots | QDBusConnection::ExportNonScriptableSlots)) && evaluated: !isSignal yes Evaluation Count:815 | yes Evaluation Count:34 |
partially evaluated: !(flags & (QDBusConnection::ExportScriptableSlots | QDBusConnection::ExportNonScriptableSlots)) no Evaluation Count:0 | yes Evaluation Count:815 |
| 0-815 |
143 | !(flags & (QDBusConnection::ExportScriptableInvokables | QDBusConnection::ExportNonScriptableInvokables)))) never evaluated: !(flags & (QDBusConnection::ExportScriptableInvokables | QDBusConnection::ExportNonScriptableInvokables)) | 0 |
144 | continue; // we're not exporting any slots or invokables never executed: continue; | 0 |
145 | | - |
146 | QString xml = QString::fromLatin1(" <%1 name=\"%2\">\n") executed (the execution status of this line is deduced): QString xml = QString::fromLatin1(" <%1 name=\"%2\">\n") | - |
147 | .arg(isSignal ? QLatin1String("signal") : QLatin1String("method")) executed (the execution status of this line is deduced): .arg(isSignal ? QLatin1String("signal") : QLatin1String("method")) | - |
148 | .arg(QString::fromLatin1(mm.name())); executed (the execution status of this line is deduced): .arg(QString::fromLatin1(mm.name())); | - |
149 | | - |
150 | // check the return type first | - |
151 | int typeId = mm.returnType(); executed (the execution status of this line is deduced): int typeId = mm.returnType(); | - |
152 | if (typeId != QMetaType::UnknownType && typeId != QMetaType::Void) { evaluated: typeId != QMetaType::UnknownType yes Evaluation Count:845 | yes Evaluation Count:4 |
evaluated: typeId != QMetaType::Void yes Evaluation Count:406 | yes Evaluation Count:439 |
| 4-845 |
153 | const char *typeName = QDBusMetaType::typeToSignature(typeId); executed (the execution status of this line is deduced): const char *typeName = QDBusMetaType::typeToSignature(typeId); | - |
154 | if (typeName) { partially evaluated: typeName yes Evaluation Count:406 | no Evaluation Count:0 |
| 0-406 |
155 | xml += QString::fromLatin1(" <arg type=\"%1\" direction=\"out\"/>\n") executed (the execution status of this line is deduced): xml += QString::fromLatin1(" <arg type=\"%1\" direction=\"out\"/>\n") | - |
156 | .arg(typeNameToXml(typeName)); executed (the execution status of this line is deduced): .arg(typeNameToXml(typeName)); | - |
157 | | - |
158 | // do we need to describe this argument? | - |
159 | if (QDBusMetaType::signatureToType(typeName) == QVariant::Invalid) evaluated: QDBusMetaType::signatureToType(typeName) == QVariant::Invalid yes Evaluation Count:75 | yes Evaluation Count:331 |
| 75-331 |
160 | xml += QString::fromLatin1(" <annotation name=\"org.qtproject.QtDBus.QtTypeName.Out0\" value=\"%1\"/>\n") executed: xml += QString::fromLatin1(" <annotation name=\"org.qtproject.QtDBus.QtTypeName.Out0\" value=\"%1\"/>\n") .arg(typeNameToXml(QMetaType::typeName(typeId))); Execution Count:75 | 75 |
161 | .arg(typeNameToXml(QMetaType::typeName(typeId))); executed: xml += QString::fromLatin1(" <annotation name=\"org.qtproject.QtDBus.QtTypeName.Out0\" value=\"%1\"/>\n") .arg(typeNameToXml(QMetaType::typeName(typeId))); Execution Count:75 | 75 |
162 | } else executed: } Execution Count:406 | 406 |
163 | continue; never executed: continue; | 0 |
164 | } | - |
165 | else if (typeId == QMetaType::UnknownType) evaluated: typeId == QMetaType::UnknownType yes Evaluation Count:4 | yes Evaluation Count:439 |
| 4-439 |
166 | continue; // wasn't a valid type executed: continue; Execution Count:4 | 4 |
167 | | - |
168 | QList<QByteArray> names = mm.parameterNames(); executed (the execution status of this line is deduced): QList<QByteArray> names = mm.parameterNames(); | - |
169 | QVector<int> types; executed (the execution status of this line is deduced): QVector<int> types; | - |
170 | int inputCount = qDBusParametersForMethod(mm, types); executed (the execution status of this line is deduced): int inputCount = qDBusParametersForMethod(mm, types); | - |
171 | if (inputCount == -1) partially evaluated: inputCount == -1 no Evaluation Count:0 | yes Evaluation Count:845 |
| 0-845 |
172 | continue; // invalid form never executed: continue; | 0 |
173 | if (isSignal && inputCount + 1 != types.count()) evaluated: isSignal yes Evaluation Count:34 | yes Evaluation Count:811 |
partially evaluated: inputCount + 1 != types.count() no Evaluation Count:0 | yes Evaluation Count:34 |
| 0-811 |
174 | continue; // signal with output arguments? never executed: continue; | 0 |
175 | if (isSignal && types.at(inputCount) == QDBusMetaTypeId::message()) evaluated: isSignal yes Evaluation Count:34 | yes Evaluation Count:811 |
partially evaluated: types.at(inputCount) == QDBusMetaTypeId::message() no Evaluation Count:0 | yes Evaluation Count:34 |
| 0-811 |
176 | continue; // signal with QDBusMessage argument? never executed: continue; | 0 |
177 | if (isSignal && mm.attributes() & QMetaMethod::Cloned) evaluated: isSignal yes Evaluation Count:34 | yes Evaluation Count:811 |
partially evaluated: mm.attributes() & QMetaMethod::Cloned no Evaluation Count:0 | yes Evaluation Count:34 |
| 0-811 |
178 | continue; // cloned signal? never executed: continue; | 0 |
179 | | - |
180 | int j; executed (the execution status of this line is deduced): int j; | - |
181 | bool isScriptable = mm.attributes() & QMetaMethod::Scriptable; executed (the execution status of this line is deduced): bool isScriptable = mm.attributes() & QMetaMethod::Scriptable; | - |
182 | for (j = 1; j < types.count(); ++j) { evaluated: j < types.count() yes Evaluation Count:406 | yes Evaluation Count:845 |
| 406-845 |
183 | // input parameter for a slot or output for a signal | - |
184 | if (types.at(j) == QDBusMetaTypeId::message()) { evaluated: types.at(j) == QDBusMetaTypeId::message() yes Evaluation Count:2 | yes Evaluation Count:404 |
| 2-404 |
185 | isScriptable = true; executed (the execution status of this line is deduced): isScriptable = true; | - |
186 | continue; executed: continue; Execution Count:2 | 2 |
187 | } | - |
188 | | - |
189 | QString name; executed (the execution status of this line is deduced): QString name; | - |
190 | if (!names.at(j - 1).isEmpty()) evaluated: !names.at(j - 1).isEmpty() yes Evaluation Count:373 | yes Evaluation Count:31 |
| 31-373 |
191 | name = QString::fromLatin1("name=\"%1\" ").arg(QLatin1String(names.at(j - 1))); executed: name = QString::fromLatin1("name=\"%1\" ").arg(QLatin1String(names.at(j - 1))); Execution Count:373 | 373 |
192 | | - |
193 | bool isOutput = isSignal || j > inputCount; evaluated: isSignal yes Evaluation Count:16 | yes Evaluation Count:388 |
evaluated: j > inputCount yes Evaluation Count:7 | yes Evaluation Count:381 |
| 7-388 |
194 | | - |
195 | const char *signature = QDBusMetaType::typeToSignature(types.at(j)); executed (the execution status of this line is deduced): const char *signature = QDBusMetaType::typeToSignature(types.at(j)); | - |
196 | xml += QString::fromLatin1(" <arg %1type=\"%2\" direction=\"%3\"/>\n") executed (the execution status of this line is deduced): xml += QString::fromLatin1(" <arg %1type=\"%2\" direction=\"%3\"/>\n") | - |
197 | .arg(name) executed (the execution status of this line is deduced): .arg(name) | - |
198 | .arg(QLatin1String(signature)) executed (the execution status of this line is deduced): .arg(QLatin1String(signature)) | - |
199 | .arg(isOutput ? QLatin1String("out") : QLatin1String("in")); executed (the execution status of this line is deduced): .arg(isOutput ? QLatin1String("out") : QLatin1String("in")); | - |
200 | | - |
201 | // do we need to describe this argument? | - |
202 | if (QDBusMetaType::signatureToType(signature) == QVariant::Invalid) { evaluated: QDBusMetaType::signatureToType(signature) == QVariant::Invalid yes Evaluation Count:73 | yes Evaluation Count:331 |
| 73-331 |
203 | const char *typeName = QMetaType::typeName(types.at(j)); executed (the execution status of this line is deduced): const char *typeName = QMetaType::typeName(types.at(j)); | - |
204 | xml += QString::fromLatin1(" <annotation name=\"org.qtproject.QtDBus.QtTypeName.%1%2\" value=\"%3\"/>\n") executed (the execution status of this line is deduced): xml += QString::fromLatin1(" <annotation name=\"org.qtproject.QtDBus.QtTypeName.%1%2\" value=\"%3\"/>\n") | - |
205 | .arg(isOutput ? QLatin1String("Out") : QLatin1String("In")) executed (the execution status of this line is deduced): .arg(isOutput ? QLatin1String("Out") : QLatin1String("In")) | - |
206 | .arg(isOutput && !isSignal ? j - inputCount : j - 1) executed (the execution status of this line is deduced): .arg(isOutput && !isSignal ? j - inputCount : j - 1) | - |
207 | .arg(typeNameToXml(typeName)); executed (the execution status of this line is deduced): .arg(typeNameToXml(typeName)); | - |
208 | } executed: } Execution Count:73 | 73 |
209 | } executed: } Execution Count:404 | 404 |
210 | | - |
211 | int wantedMask; executed (the execution status of this line is deduced): int wantedMask; | - |
212 | if (isScriptable) evaluated: isScriptable yes Evaluation Count:16 | yes Evaluation Count:829 |
| 16-829 |
213 | wantedMask = isSignal ? QDBusConnection::ExportScriptableSignals executed: wantedMask = isSignal ? QDBusConnection::ExportScriptableSignals : QDBusConnection::ExportScriptableSlots; Execution Count:16 evaluated: isSignal yes Evaluation Count:3 | yes Evaluation Count:13 |
| 3-16 |
214 | : QDBusConnection::ExportScriptableSlots; executed: wantedMask = isSignal ? QDBusConnection::ExportScriptableSignals : QDBusConnection::ExportScriptableSlots; Execution Count:16 | 16 |
215 | else | - |
216 | wantedMask = isSignal ? QDBusConnection::ExportNonScriptableSignals executed: wantedMask = isSignal ? QDBusConnection::ExportNonScriptableSignals : QDBusConnection::ExportNonScriptableSlots; Execution Count:829 evaluated: isSignal yes Evaluation Count:31 | yes Evaluation Count:798 |
| 31-829 |
217 | : QDBusConnection::ExportNonScriptableSlots; executed: wantedMask = isSignal ? QDBusConnection::ExportNonScriptableSignals : QDBusConnection::ExportNonScriptableSlots; Execution Count:829 | 829 |
218 | if ((flags & wantedMask) != wantedMask) partially evaluated: (flags & wantedMask) != wantedMask no Evaluation Count:0 | yes Evaluation Count:845 |
| 0-845 |
219 | continue; never executed: continue; | 0 |
220 | | - |
221 | if (qDBusCheckAsyncTag(mm.tag())) partially evaluated: qDBusCheckAsyncTag(mm.tag()) no Evaluation Count:0 | yes Evaluation Count:845 |
| 0-845 |
222 | // add the no-reply annotation | - |
223 | xml += QLatin1String(" <annotation name=\"" ANNOTATION_NO_WAIT "\"" never executed: xml += QLatin1String(" <annotation name=\"" "org.freedesktop.DBus.Method.NoReply" "\"" " value=\"true\"/>\n"); | 0 |
224 | " value=\"true\"/>\n"); never executed: xml += QLatin1String(" <annotation name=\"" "org.freedesktop.DBus.Method.NoReply" "\"" " value=\"true\"/>\n"); | 0 |
225 | | - |
226 | retval += xml; executed (the execution status of this line is deduced): retval += xml; | - |
227 | retval += QString::fromLatin1(" </%1>\n") executed (the execution status of this line is deduced): retval += QString::fromLatin1(" </%1>\n") | - |
228 | .arg(isSignal ? QLatin1String("signal") : QLatin1String("method")); executed (the execution status of this line is deduced): .arg(isSignal ? QLatin1String("signal") : QLatin1String("method")); | - |
229 | } executed: } Execution Count:845 | 845 |
230 | | - |
231 | return retval; executed: return retval; Execution Count:60 | 60 |
232 | } | - |
233 | | - |
234 | QString qDBusGenerateMetaObjectXml(QString interface, const QMetaObject *mo, | - |
235 | const QMetaObject *base, int flags) | - |
236 | { | - |
237 | if (interface.isEmpty()) evaluated: interface.isEmpty() yes Evaluation Count:9 | yes Evaluation Count:54 |
| 9-54 |
238 | // generate the interface name from the meta object | - |
239 | interface = qDBusInterfaceFromMetaObject(mo); executed: interface = qDBusInterfaceFromMetaObject(mo); Execution Count:9 | 9 |
240 | | - |
241 | QString xml; executed (the execution status of this line is deduced): QString xml; | - |
242 | int idx = mo->indexOfClassInfo(QCLASSINFO_DBUS_INTROSPECTION); executed (the execution status of this line is deduced): int idx = mo->indexOfClassInfo("D-Bus Introspection"); | - |
243 | if (idx >= mo->classInfoOffset()) evaluated: idx >= mo->classInfoOffset() yes Evaluation Count:3 | yes Evaluation Count:60 |
| 3-60 |
244 | return QString::fromUtf8(mo->classInfo(idx).value()); executed: return QString::fromUtf8(mo->classInfo(idx).value()); Execution Count:3 | 3 |
245 | else | - |
246 | xml = generateInterfaceXml(mo, flags, base->methodCount(), base->propertyCount()); executed: xml = generateInterfaceXml(mo, flags, base->methodCount(), base->propertyCount()); Execution Count:60 | 60 |
247 | | - |
248 | if (xml.isEmpty()) evaluated: xml.isEmpty() yes Evaluation Count:19 | yes Evaluation Count:41 |
| 19-41 |
249 | return QString(); // don't add an empty interface executed: return QString(); Execution Count:19 | 19 |
250 | return QString::fromLatin1(" <interface name=\"%1\">\n%2 </interface>\n") executed: return QString::fromLatin1(" <interface name=\"%1\">\n%2 </interface>\n") .arg(interface, xml); Execution Count:41 | 41 |
251 | .arg(interface, xml); executed: return QString::fromLatin1(" <interface name=\"%1\">\n%2 </interface>\n") .arg(interface, xml); Execution Count:41 | 41 |
252 | } | - |
253 | #if 0 | - |
254 | QString qDBusGenerateMetaObjectXml(QString interface, const QMetaObject *mo, const QMetaObject *base, | - |
255 | int flags) | - |
256 | { | - |
257 | if (interface.isEmpty()) { | - |
258 | // generate the interface name from the meta object | - |
259 | int idx = mo->indexOfClassInfo(QCLASSINFO_DBUS_INTERFACE); | - |
260 | if (idx >= mo->classInfoOffset()) { | - |
261 | interface = QLatin1String(mo->classInfo(idx).value()); | - |
262 | } else { | - |
263 | interface = QLatin1String(mo->className()); | - |
264 | interface.replace(QLatin1String("::"), QLatin1String(".")); | - |
265 | | - |
266 | if (interface.startsWith(QLatin1String("QDBus"))) { | - |
267 | interface.prepend(QLatin1String("org.qtproject.QtDBus.")); | - |
268 | } else if (interface.startsWith(QLatin1Char('Q')) && | - |
269 | interface.length() >= 2 && interface.at(1).isUpper()) { | - |
270 | // assume it's Qt | - |
271 | interface.prepend(QLatin1String("org.qtproject.Qt.")); | - |
272 | } else if (!QCoreApplication::instance()|| | - |
273 | QCoreApplication::instance()->applicationName().isEmpty()) { | - |
274 | interface.prepend(QLatin1String("local.")); | - |
275 | } else { | - |
276 | interface.prepend(QLatin1Char('.')).prepend(QCoreApplication::instance()->applicationName()); | - |
277 | QStringList domainName = | - |
278 | QCoreApplication::instance()->organizationDomain().split(QLatin1Char('.'), | - |
279 | QString::SkipEmptyParts); | - |
280 | if (domainName.isEmpty()) | - |
281 | interface.prepend(QLatin1String("local.")); | - |
282 | else | - |
283 | for (int i = 0; i < domainName.count(); ++i) | - |
284 | interface.prepend(QLatin1Char('.')).prepend(domainName.at(i)); | - |
285 | } | - |
286 | } | - |
287 | } | - |
288 | | - |
289 | QString xml; | - |
290 | int idx = mo->indexOfClassInfo(QCLASSINFO_DBUS_INTROSPECTION); | - |
291 | if (idx >= mo->classInfoOffset()) | - |
292 | return QString::fromUtf8(mo->classInfo(idx).value()); | - |
293 | else | - |
294 | xml = generateInterfaceXml(mo, flags, base->methodCount(), base->propertyCount()); | - |
295 | | - |
296 | if (xml.isEmpty()) | - |
297 | return QString(); // don't add an empty interface | - |
298 | return QString::fromLatin1(" <interface name=\"%1\">\n%2 </interface>\n") | - |
299 | .arg(interface, xml); | - |
300 | } | - |
301 | | - |
302 | #endif | - |
303 | | - |
304 | QT_END_NAMESPACE | - |
305 | | - |
306 | #endif // QT_NO_DBUS | - |
307 | | - |
| | |