本文整理汇总了C++中QDBusReply::isError方法的典型用法代码示例。如果您正苦于以下问题:C++ QDBusReply::isError方法的具体用法?C++ QDBusReply::isError怎么用?C++ QDBusReply::isError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDBusReply
的用法示例。
在下文中一共展示了QDBusReply::isError方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: listObjects
void listObjects(const QString &service, const QString &path)
{
QDBusInterfacePtr iface(*connection, service, path.isEmpty() ? "/" : path,
"org.freedesktop.DBus.Introspectable");
if (!iface->isValid()) {
QDBusError err(iface->lastError());
fprintf(stderr, "Cannot introspect object %s at %s:\n%s (%s)\n",
qPrintable(path.isEmpty() ? "/" : path), qPrintable(service),
qPrintable(err.name()), qPrintable(err.message()));
exit(1);
}
QDBusReply<QString> xml = iface->call("Introspect");
if (xml.isError())
return; // silently
QDomDocument doc;
doc.setContent(xml);
QDomElement node = doc.documentElement();
QDomElement child = node.firstChildElement();
while (!child.isNull()) {
if (child.tagName() == QLatin1String("node")) {
QString sub = path + '/' + child.attribute("name");
printf("%s\n", qPrintable(sub));
listObjects(service, sub);
}
child = child.nextSiblingElement();
}
}
示例2: listAllInterfaces
void listAllInterfaces(const QString &service, const QString &path)
{
QDBusInterfacePtr iface(*connection, service, path, "org.freedesktop.DBus.Introspectable");
if (!iface->isValid()) {
QDBusError err(iface->lastError());
fprintf(stderr, "Cannot introspect object %s at %s:\n%s (%s)\n",
qPrintable(path), qPrintable(service),
qPrintable(err.name()), qPrintable(err.message()));
exit(1);
}
QDBusReply<QString> xml = iface->call("Introspect");
if (xml.isError())
return; // silently
QDomDocument doc;
doc.setContent(xml);
QDomElement node = doc.documentElement();
QDomElement child = node.firstChildElement();
while (!child.isNull()) {
if (child.tagName() == QLatin1String("interface")) {
QString ifaceName = child.attribute("name");
if (QDBusUtil::isValidInterfaceName(ifaceName))
listInterface(service, path, ifaceName);
else {
qWarning("Invalid D-BUS interface name '%s' found while parsing introspection",
qPrintable(ifaceName));
}
}
child = child.nextSiblingElement();
}
}