QtDBus: use _L1 for for creating Latin-1 string literals
Task-number: QTBUG-98434 Change-Id: I99d9a82c77d00124ea8953b98406959f1bf9413a Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
parent
6e77d2a10c
commit
e9e43bff29
@ -53,6 +53,8 @@
|
||||
#include <QDBusReply>
|
||||
#include <QDBusInterface>
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
class Abstract_DBus_Interface : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -81,11 +83,11 @@ void Abstract_DBus_Interface::interfaceMain()
|
||||
QString value = retrieveValue();
|
||||
QDBusMessage reply;
|
||||
|
||||
QDBusReply<int> api = interface->call(QLatin1String("GetAPIVersion"));
|
||||
QDBusReply<int> api = interface->call("GetAPIVersion"_L1);
|
||||
if (api >= 14)
|
||||
reply = interface->call(QLatin1String("ProcessWorkUnicode"), value);
|
||||
reply = interface->call("ProcessWorkUnicode"_L1, value);
|
||||
else
|
||||
reply = interface->call(QLatin1String("ProcessWork"), QLatin1String("UTF-8"), value.toUtf8());
|
||||
reply = interface->call("ProcessWork"_L1, "UTF-8"_L1, value.toUtf8());
|
||||
//! [0]
|
||||
}
|
||||
|
||||
@ -93,7 +95,7 @@ void Abstract_DBus_Interface::asyncCall()
|
||||
{
|
||||
//! [1]
|
||||
QString value = retrieveValue();
|
||||
QDBusPendingCall pcall = interface->asyncCall(QLatin1String("Process"), value);
|
||||
QDBusPendingCall pcall = interface->asyncCall("Process"_L1, value);
|
||||
|
||||
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pcall);
|
||||
|
||||
|
@ -51,6 +51,8 @@ extern "C" void dbus_shutdown();
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
void (*qdbus_resolve_me(const char *name))();
|
||||
|
||||
#if !defined QT_LINKED_LIBDBUS
|
||||
@ -94,9 +96,9 @@ bool qdbus_loadLibDBus()
|
||||
static int majorversions[] = { 3, 2, -1 };
|
||||
const QString baseNames[] = {
|
||||
#ifdef Q_OS_WIN
|
||||
QLatin1String("dbus-1"),
|
||||
"dbus-1"_L1,
|
||||
#endif
|
||||
QLatin1String("libdbus-1")
|
||||
"libdbus-1"_L1
|
||||
};
|
||||
|
||||
lib->unload();
|
||||
|
@ -58,6 +58,8 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
namespace {
|
||||
// ### Qt6: change to a regular QEvent (customEvent)
|
||||
// We need to use a QMetaCallEvent here because we can't override customEvent() in
|
||||
@ -163,8 +165,7 @@ bool QDBusAbstractInterfacePrivate::property(const QMetaProperty &mp, void *retu
|
||||
qWarning("QDBusAbstractInterface: type %s must be registered with Qt D-Bus before it can be "
|
||||
"used to read property %s.%s",
|
||||
mp.typeName(), qPrintable(interface), mp.name());
|
||||
lastError = QDBusError(QDBusError::Failed,
|
||||
QLatin1String("Unregistered type %1 cannot be handled")
|
||||
lastError = QDBusError(QDBusError::Failed, "Unregistered type %1 cannot be handled"_L1
|
||||
.arg(QLatin1String(mp.typeName())));
|
||||
return false;
|
||||
}
|
||||
@ -182,9 +183,9 @@ bool QDBusAbstractInterfacePrivate::property(const QMetaProperty &mp, void *retu
|
||||
lastError = QDBusError(reply);
|
||||
return false;
|
||||
}
|
||||
if (reply.signature() != QLatin1String("v")) {
|
||||
QString errmsg = QLatin1String("Invalid signature `%1' in return from call to "
|
||||
DBUS_INTERFACE_PROPERTIES);
|
||||
if (reply.signature() != "v"_L1) {
|
||||
QString errmsg = "Invalid signature `%1' in return from call to "
|
||||
DBUS_INTERFACE_PROPERTIES ""_L1;
|
||||
lastError = QDBusError(QDBusError::InvalidSignature, std::move(errmsg).arg(reply.signature()));
|
||||
return false;
|
||||
}
|
||||
@ -220,8 +221,8 @@ bool QDBusAbstractInterfacePrivate::property(const QMetaProperty &mp, void *retu
|
||||
}
|
||||
|
||||
// there was an error...
|
||||
const auto errmsg = QLatin1String("Unexpected `%1' (%2) when retrieving property `%3.%4' "
|
||||
"(expected type `%5' (%6))");
|
||||
const auto errmsg = "Unexpected `%1' (%2) when retrieving property `%3.%4' "
|
||||
"(expected type `%5' (%6))"_L1;
|
||||
lastError = QDBusError(QDBusError::InvalidSignature,
|
||||
errmsg.arg(QLatin1String(foundType),
|
||||
QLatin1String(foundSignature),
|
||||
|
@ -54,6 +54,8 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
/*
|
||||
* Implementation of interface class QDBusConnectionInterface
|
||||
*/
|
||||
@ -184,7 +186,7 @@ QDBusConnectionInterface::~QDBusConnectionInterface()
|
||||
*/
|
||||
QDBusReply<QString> QDBusConnectionInterface::serviceOwner(const QString &name) const
|
||||
{
|
||||
return internalConstCall(QDBus::AutoDetect, QLatin1String("GetNameOwner"), QList<QVariant>() << name);
|
||||
return internalConstCall(QDBus::AutoDetect, "GetNameOwner"_L1, QList<QVariant>() << name);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -195,7 +197,7 @@ QDBusReply<QString> QDBusConnectionInterface::serviceOwner(const QString &name)
|
||||
*/
|
||||
QDBusReply<QStringList> QDBusConnectionInterface::registeredServiceNames() const
|
||||
{
|
||||
return internalConstCall(QDBus::AutoDetect, QLatin1String("ListNames"));
|
||||
return internalConstCall(QDBus::AutoDetect, "ListNames"_L1);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -207,7 +209,7 @@ QDBusReply<QStringList> QDBusConnectionInterface::registeredServiceNames() const
|
||||
*/
|
||||
QDBusReply<QStringList> QDBusConnectionInterface::activatableServiceNames() const
|
||||
{
|
||||
return internalConstCall(QDBus::AutoDetect, QLatin1String("ListActivatableNames"));
|
||||
return internalConstCall(QDBus::AutoDetect, "ListActivatableNames"_L1);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -216,7 +218,7 @@ QDBusReply<QStringList> QDBusConnectionInterface::activatableServiceNames() cons
|
||||
*/
|
||||
QDBusReply<bool> QDBusConnectionInterface::isServiceRegistered(const QString &serviceName) const
|
||||
{
|
||||
return internalConstCall(QDBus::AutoDetect, QLatin1String("NameHasOwner"),
|
||||
return internalConstCall(QDBus::AutoDetect, "NameHasOwner"_L1,
|
||||
QList<QVariant>() << serviceName);
|
||||
}
|
||||
|
||||
@ -226,7 +228,7 @@ QDBusReply<bool> QDBusConnectionInterface::isServiceRegistered(const QString &se
|
||||
*/
|
||||
QDBusReply<uint> QDBusConnectionInterface::servicePid(const QString &serviceName) const
|
||||
{
|
||||
return internalConstCall(QDBus::AutoDetect, QLatin1String("GetConnectionUnixProcessID"),
|
||||
return internalConstCall(QDBus::AutoDetect, "GetConnectionUnixProcessID"_L1,
|
||||
QList<QVariant>() << serviceName);
|
||||
}
|
||||
|
||||
@ -236,7 +238,7 @@ QDBusReply<uint> QDBusConnectionInterface::servicePid(const QString &serviceName
|
||||
*/
|
||||
QDBusReply<uint> QDBusConnectionInterface::serviceUid(const QString &serviceName) const
|
||||
{
|
||||
return internalConstCall(QDBus::AutoDetect, QLatin1String("GetConnectionUnixUser"),
|
||||
return internalConstCall(QDBus::AutoDetect, "GetConnectionUnixUser"_L1,
|
||||
QList<QVariant>() << serviceName);
|
||||
}
|
||||
|
||||
@ -245,7 +247,7 @@ QDBusReply<uint> QDBusConnectionInterface::serviceUid(const QString &serviceName
|
||||
*/
|
||||
QDBusReply<void> QDBusConnectionInterface::startService(const QString &name)
|
||||
{
|
||||
return call(QLatin1String("StartServiceByName"), name, uint(0));
|
||||
return call("StartServiceByName"_L1, name, uint(0));
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -290,7 +292,7 @@ QDBusConnectionInterface::registerService(const QString &serviceName,
|
||||
break;
|
||||
}
|
||||
|
||||
QDBusMessage reply = call(QLatin1String("RequestName"), serviceName, flags);
|
||||
QDBusMessage reply = call("RequestName"_L1, serviceName, flags);
|
||||
// qDebug() << "QDBusConnectionInterface::registerService" << serviceName << "Reply:" << reply;
|
||||
|
||||
// convert the low-level flags to something that we can use
|
||||
@ -328,7 +330,7 @@ QDBusConnectionInterface::registerService(const QString &serviceName,
|
||||
QDBusReply<bool>
|
||||
QDBusConnectionInterface::unregisterService(const QString &serviceName)
|
||||
{
|
||||
QDBusMessage reply = call(QLatin1String("ReleaseName"), serviceName);
|
||||
QDBusMessage reply = call("ReleaseName"_L1, serviceName);
|
||||
if (reply.type() == QDBusMessage::ReplyMessage) {
|
||||
bool success = reply.arguments().at(0).toUInt() == DBUS_RELEASE_NAME_REPLY_RELEASED;
|
||||
reply.setArguments(QVariantList() << success);
|
||||
|
@ -79,6 +79,8 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
QT_IMPL_METATYPE_EXTERN(QDBusSlotCache)
|
||||
|
||||
// used with dbus_server_allocate_data_slot
|
||||
@ -310,7 +312,7 @@ static void qDBusNewConnection(DBusServer *server, DBusConnection *connection, v
|
||||
|
||||
QDBusConnectionPrivate *newConnection = new QDBusConnectionPrivate(serverConnection->parent());
|
||||
const auto locker = qt_scoped_lock(QDBusConnectionManager::instance()->mutex);
|
||||
QDBusConnectionManager::instance()->setConnection(QLatin1String("QDBusServer-") + QString::number(reinterpret_cast<qulonglong>(newConnection), 16), newConnection);
|
||||
QDBusConnectionManager::instance()->setConnection("QDBusServer-"_L1 + QString::number(reinterpret_cast<qulonglong>(newConnection), 16), newConnection);
|
||||
serverConnection->serverConnectionNames << newConnection->name;
|
||||
|
||||
// setPeer does the error handling for us
|
||||
@ -346,27 +348,27 @@ static QByteArray buildMatchRule(const QString &service,
|
||||
const QString &member, const QDBusConnectionPrivate::ArgMatchRules &argMatch, const QString & /*signature*/)
|
||||
{
|
||||
QString result;
|
||||
result += QLatin1String("type='signal',");
|
||||
const auto keyValue = QLatin1String("%1='%2',");
|
||||
result += "type='signal',"_L1;
|
||||
const auto keyValue = "%1='%2',"_L1;
|
||||
|
||||
if (!service.isEmpty())
|
||||
result += keyValue.arg(QLatin1String("sender"), service);
|
||||
result += keyValue.arg("sender"_L1, service);
|
||||
if (!objectPath.isEmpty())
|
||||
result += keyValue.arg(QLatin1String("path"), objectPath);
|
||||
result += keyValue.arg("path"_L1, objectPath);
|
||||
if (!interface.isEmpty())
|
||||
result += keyValue.arg(QLatin1String("interface"), interface);
|
||||
result += keyValue.arg("interface"_L1, interface);
|
||||
if (!member.isEmpty())
|
||||
result += keyValue.arg(QLatin1String("member"), member);
|
||||
result += keyValue.arg("member"_L1, member);
|
||||
|
||||
// add the argument string-matching now
|
||||
if (!argMatch.args.isEmpty()) {
|
||||
const QString keyValue = QLatin1String("arg%1='%2',");
|
||||
const QString keyValue = "arg%1='%2',"_L1;
|
||||
for (int i = 0; i < argMatch.args.count(); ++i)
|
||||
if (!argMatch.args.at(i).isNull())
|
||||
result += keyValue.arg(i).arg(argMatch.args.at(i));
|
||||
}
|
||||
if (!argMatch.arg0namespace.isEmpty()) {
|
||||
result += QLatin1String("arg0namespace='%1',").arg(argMatch.arg0namespace);
|
||||
result += "arg0namespace='%1',"_L1.arg(argMatch.arg0namespace);
|
||||
}
|
||||
|
||||
result.chop(1); // remove ending comma
|
||||
@ -377,7 +379,7 @@ static bool findObject(const QDBusConnectionPrivate::ObjectTreeNode *root,
|
||||
const QString &fullpath, int &usedLength,
|
||||
QDBusConnectionPrivate::ObjectTreeNode &result)
|
||||
{
|
||||
if (!fullpath.compare(QLatin1String("/")) && root->obj) {
|
||||
if (!fullpath.compare("/"_L1) && root->obj) {
|
||||
usedLength = 1;
|
||||
result = *root;
|
||||
return root;
|
||||
@ -1017,8 +1019,7 @@ void QDBusConnectionPrivate::deliverCall(QObject *object, int /*flags*/, const Q
|
||||
} else {
|
||||
// generate internal error
|
||||
qWarning("Internal error: Failed to deliver message");
|
||||
send(msg.createErrorReply(QDBusError::InternalError,
|
||||
QLatin1String("Failed to deliver message")));
|
||||
send(msg.createErrorReply(QDBusError::InternalError, "Failed to deliver message"_L1));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1279,7 +1280,7 @@ void QDBusConnectionPrivate::relaySignal(QObject *obj, const QMetaObject *mo, in
|
||||
|
||||
checkThread();
|
||||
QDBusReadLocker locker(RelaySignalAction, this);
|
||||
QDBusMessage message = QDBusMessage::createSignal(QLatin1String("/"), interface,
|
||||
QDBusMessage message = QDBusMessage::createSignal("/"_L1, interface,
|
||||
QLatin1String(memberName));
|
||||
QDBusMessagePrivate::setParametersValidated(message, true);
|
||||
message.setArguments(args);
|
||||
@ -1382,21 +1383,20 @@ void QDBusConnectionPrivate::sendError(const QDBusMessage &msg, QDBusError::Erro
|
||||
if (code == QDBusError::UnknownMethod) {
|
||||
QString interfaceMsg;
|
||||
if (msg.interface().isEmpty())
|
||||
interfaceMsg = QLatin1String("any interface");
|
||||
interfaceMsg = "any interface"_L1;
|
||||
else
|
||||
interfaceMsg = QLatin1String("interface '%1'").arg(msg.interface());
|
||||
interfaceMsg = "interface '%1'"_L1.arg(msg.interface());
|
||||
|
||||
send(msg.createErrorReply(code,
|
||||
QLatin1String("No such method '%1' in %2 at object path '%3' "
|
||||
"(signature '%4')")
|
||||
send(msg.createErrorReply(code, "No such method '%1' in %2 at object path '%3' "
|
||||
"(signature '%4')"_L1
|
||||
.arg(msg.member(), interfaceMsg, msg.path(), msg.signature())));
|
||||
} else if (code == QDBusError::UnknownInterface) {
|
||||
send(msg.createErrorReply(QDBusError::UnknownInterface,
|
||||
QLatin1String("No such interface '%1' at object path '%2'")
|
||||
"No such interface '%1' at object path '%2'"_L1
|
||||
.arg(msg.interface(), msg.path())));
|
||||
} else if (code == QDBusError::UnknownObject) {
|
||||
send(msg.createErrorReply(QDBusError::UnknownObject,
|
||||
QLatin1String("No such object path '%1'").arg(msg.path())));
|
||||
"No such object path '%1'"_L1.arg(msg.path())));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1407,7 +1407,7 @@ bool QDBusConnectionPrivate::activateInternalFilters(const ObjectTreeNode &node,
|
||||
const QString interface = msg.interface();
|
||||
|
||||
if (interface.isEmpty() || interface == QDBusUtil::dbusInterfaceIntrospectable()) {
|
||||
if (msg.member() == QLatin1String("Introspect") && msg.signature().isEmpty()) {
|
||||
if (msg.member() == "Introspect"_L1 && msg.signature().isEmpty()) {
|
||||
//qDebug() << "QDBusConnectionPrivate::activateInternalFilters introspect" << msg.d_ptr->msg;
|
||||
QDBusMessage reply = msg.createReply(qDBusIntrospectObject(node, msg.path()));
|
||||
send(reply);
|
||||
@ -1423,15 +1423,15 @@ bool QDBusConnectionPrivate::activateInternalFilters(const ObjectTreeNode &node,
|
||||
if (node.obj && (interface.isEmpty() ||
|
||||
interface == QDBusUtil::dbusInterfaceProperties())) {
|
||||
//qDebug() << "QDBusConnectionPrivate::activateInternalFilters properties" << msg.d_ptr->msg;
|
||||
if (msg.member() == QLatin1String("Get") && msg.signature() == QLatin1String("ss")) {
|
||||
if (msg.member() == "Get"_L1 && msg.signature() == "ss"_L1) {
|
||||
QDBusMessage reply = qDBusPropertyGet(node, msg);
|
||||
send(reply);
|
||||
return true;
|
||||
} else if (msg.member() == QLatin1String("Set") && msg.signature() == QLatin1String("ssv")) {
|
||||
} else if (msg.member() == "Set"_L1 && msg.signature() == "ssv"_L1) {
|
||||
QDBusMessage reply = qDBusPropertySet(node, msg);
|
||||
send(reply);
|
||||
return true;
|
||||
} else if (msg.member() == QLatin1String("GetAll") && msg.signature() == QLatin1String("s")) {
|
||||
} else if (msg.member() == "GetAll"_L1 && msg.signature() == "s"_L1) {
|
||||
QDBusMessage reply = qDBusPropertyGetAll(node, msg);
|
||||
send(reply);
|
||||
return true;
|
||||
@ -1566,8 +1566,8 @@ void QDBusConnectionPrivate::handleObjectCall(const QDBusMessage &msg)
|
||||
objThread = result.obj->thread();
|
||||
if (!objThread) {
|
||||
send(msg.createErrorReply(QDBusError::InternalError,
|
||||
QLatin1String("Object '%1' (at path '%2')"
|
||||
" has no thread. Cannot deliver message.")
|
||||
"Object '%1' (at path '%2')"
|
||||
" has no thread. Cannot deliver message."_L1
|
||||
.arg(result.obj->objectName(), msg.path())));
|
||||
return;
|
||||
}
|
||||
@ -1708,7 +1708,7 @@ void QDBusConnectionPrivate::watchForDBusDisconnection()
|
||||
hook.params << QMetaType(QMetaType::Void);
|
||||
hook.midx = staticMetaObject.indexOfSlot("handleDBusDisconnection()");
|
||||
Q_ASSERT(hook.midx != -1);
|
||||
signalHooks.insert(QLatin1String("Disconnected:" DBUS_INTERFACE_LOCAL), hook);
|
||||
signalHooks.insert("Disconnected:" DBUS_INTERFACE_LOCAL ""_L1, hook);
|
||||
}
|
||||
|
||||
void QDBusConnectionPrivate::setServer(QDBusServer *object, DBusServer *s, const QDBusErrorInternal &error)
|
||||
@ -1846,11 +1846,11 @@ void QDBusConnectionPrivate::setConnection(DBusConnection *dbc, const QDBusError
|
||||
|
||||
hook.midx = staticMetaObject.indexOfSlot("registerServiceNoLock(QString)");
|
||||
Q_ASSERT(hook.midx != -1);
|
||||
signalHooks.insert(QLatin1String("NameAcquired:" DBUS_INTERFACE_DBUS), hook);
|
||||
signalHooks.insert("NameAcquired:" DBUS_INTERFACE_DBUS ""_L1, hook);
|
||||
|
||||
hook.midx = staticMetaObject.indexOfSlot("unregisterServiceNoLock(QString)");
|
||||
Q_ASSERT(hook.midx != -1);
|
||||
signalHooks.insert(QLatin1String("NameLost:" DBUS_INTERFACE_DBUS), hook);
|
||||
signalHooks.insert("NameLost:" DBUS_INTERFACE_DBUS ""_L1, hook);
|
||||
|
||||
// And initialize the hook for the NameOwnerChanged signal;
|
||||
// we don't use connectSignal here because the rules are added by connectSignal on a per-need basis
|
||||
@ -1859,7 +1859,7 @@ void QDBusConnectionPrivate::setConnection(DBusConnection *dbc, const QDBusError
|
||||
hook.params << QMetaType(QMetaType::Void) << QMetaType(QMetaType::QString) << QMetaType(QMetaType::QString) << QMetaType(QMetaType::QString);
|
||||
hook.midx = staticMetaObject.indexOfSlot("serviceOwnerChangedNoLock(QString,QString,QString)");
|
||||
Q_ASSERT(hook.midx != -1);
|
||||
signalHooks.insert(QLatin1String("NameOwnerChanged:" DBUS_INTERFACE_DBUS), hook);
|
||||
signalHooks.insert("NameOwnerChanged:" DBUS_INTERFACE_DBUS ""_L1, hook);
|
||||
|
||||
watchForDBusDisconnection();
|
||||
|
||||
@ -2103,9 +2103,9 @@ QDBusMessage QDBusConnectionPrivate::sendWithReplyLocal(const QDBusMessage &mess
|
||||
if (!handled) {
|
||||
QString interface = message.interface();
|
||||
if (interface.isEmpty())
|
||||
interface = QLatin1String("<no-interface>");
|
||||
interface = "<no-interface>"_L1;
|
||||
return QDBusMessage::createError(QDBusError::InternalError,
|
||||
QLatin1String("Internal error trying to call %1.%2 at %3 (signature '%4'")
|
||||
"Internal error trying to call %1.%2 at %3 (signature '%4'"_L1
|
||||
.arg(interface, message.member(),
|
||||
message.path(), message.signature()));
|
||||
}
|
||||
@ -2118,7 +2118,7 @@ QDBusMessage QDBusConnectionPrivate::sendWithReplyLocal(const QDBusMessage &mess
|
||||
qPrintable(message.signature()));
|
||||
return QDBusMessage::createError(
|
||||
QDBusError(QDBusError::InternalError,
|
||||
QLatin1String("local-loop message cannot have delayed replies")));
|
||||
"local-loop message cannot have delayed replies"_L1));
|
||||
}
|
||||
|
||||
// there is a reply
|
||||
@ -2434,7 +2434,7 @@ void QDBusConnectionPrivate::unregisterObject(const QString &path, QDBusConnecti
|
||||
QDBusConnectionPrivate::ObjectTreeNode *node = &rootNode;
|
||||
QList<QStringView> pathComponents;
|
||||
int i;
|
||||
if (path == QLatin1String("/")) {
|
||||
if (path == "/"_L1) {
|
||||
i = 0;
|
||||
} else {
|
||||
pathComponents = QStringView{path}.split(u'/');
|
||||
@ -2606,7 +2606,7 @@ QDBusConnectionPrivate::findMetaObject(const QString &service, const QString &pa
|
||||
|
||||
QString xml;
|
||||
if (reply.type() == QDBusMessage::ReplyMessage) {
|
||||
if (reply.signature() == QLatin1String("s"))
|
||||
if (reply.signature() == "s"_L1)
|
||||
// fetch the XML description
|
||||
xml = reply.arguments().at(0).toString();
|
||||
} else {
|
||||
|
@ -51,6 +51,8 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
static void copyArgument(void *to, int id, const QVariant &arg)
|
||||
{
|
||||
if (id == arg.metaType().id()) {
|
||||
@ -161,7 +163,7 @@ QDBusInterfacePrivate::QDBusInterfacePrivate(const QString &serv, const QString
|
||||
// those are not fatal errors, so we continue working
|
||||
|
||||
if (!lastError.isValid())
|
||||
lastError = QDBusError(QDBusError::InternalError, QLatin1String("Unknown error"));
|
||||
lastError = QDBusError(QDBusError::InternalError, "Unknown error"_L1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -63,6 +63,8 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
// defined in qdbusxmlgenerator.cpp
|
||||
extern QString qDBusGenerateMetaObjectXml(QString interface, const QMetaObject *mo,
|
||||
const QMetaObject *base, int flags);
|
||||
@ -116,7 +118,7 @@ static QString generateSubObjectXml(QObject *object)
|
||||
for ( ; it != end; ++it) {
|
||||
QString name = (*it)->objectName();
|
||||
if (!name.isEmpty() && QDBusUtil::isValidPartOfObjectPath(name))
|
||||
retval += QLatin1String(" <node name=\"") + name + QLatin1String("\"/>\n");
|
||||
retval += " <node name=\""_L1 + name + "\"/>\n"_L1;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
@ -127,8 +129,8 @@ QString qDBusIntrospectObject(const QDBusConnectionPrivate::ObjectTreeNode &node
|
||||
{
|
||||
// object may be null
|
||||
|
||||
QString xml_data(QLatin1String(DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE));
|
||||
xml_data += QLatin1String("<node>\n");
|
||||
QString xml_data(DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE ""_L1);
|
||||
xml_data += "<node>\n"_L1;
|
||||
|
||||
if (node.obj) {
|
||||
Q_ASSERT_X(QThread::currentThread() == node.obj->thread(),
|
||||
@ -191,10 +193,10 @@ QString qDBusIntrospectObject(const QDBusConnectionPrivate::ObjectTreeNode &node
|
||||
node.children.constEnd();
|
||||
for ( ; it != end; ++it)
|
||||
if (it->obj || !it->children.isEmpty())
|
||||
xml_data += QLatin1String(" <node name=\"") + it->name + QLatin1String("\"/>\n");
|
||||
xml_data += " <node name=\""_L1 + it->name + "\"/>\n"_L1;
|
||||
}
|
||||
|
||||
xml_data += QLatin1String("</node>\n");
|
||||
xml_data += "</node>\n"_L1;
|
||||
return xml_data;
|
||||
}
|
||||
|
||||
@ -203,7 +205,7 @@ QString qDBusIntrospectObject(const QDBusConnectionPrivate::ObjectTreeNode &node
|
||||
static inline QDBusMessage interfaceNotFoundError(const QDBusMessage &msg, const QString &interface_name)
|
||||
{
|
||||
return msg.createErrorReply(QDBusError::UnknownInterface,
|
||||
QLatin1String("Interface %1 was not found in object %2")
|
||||
"Interface %1 was not found in object %2"_L1
|
||||
.arg(interface_name, msg.path()));
|
||||
}
|
||||
|
||||
@ -211,9 +213,9 @@ static inline QDBusMessage
|
||||
propertyNotFoundError(const QDBusMessage &msg, const QString &interface_name, const QByteArray &property_name)
|
||||
{
|
||||
return msg.createErrorReply(QDBusError::UnknownProperty,
|
||||
QLatin1String("Property %1%2%3 was not found in object %4")
|
||||
"Property %1%2%3 was not found in object %4"_L1
|
||||
.arg(interface_name,
|
||||
QLatin1String(interface_name.isEmpty() ? "" : "."),
|
||||
interface_name.isEmpty() ? ""_L1 : "."_L1,
|
||||
QLatin1String(property_name),
|
||||
msg.path()));
|
||||
}
|
||||
@ -302,15 +304,15 @@ static QDBusMessage propertyWriteReply(const QDBusMessage &msg, const QString &i
|
||||
return propertyNotFoundError(msg, interface_name, property_name);
|
||||
case PropertyTypeMismatch:
|
||||
return msg.createErrorReply(QDBusError::InvalidArgs,
|
||||
QLatin1String("Invalid arguments for writing to property %1%2%3")
|
||||
"Invalid arguments for writing to property %1%2%3"_L1
|
||||
.arg(interface_name,
|
||||
QLatin1String(interface_name.isEmpty() ? "" : "."),
|
||||
interface_name.isEmpty() ? ""_L1 : "."_L1,
|
||||
QLatin1String(property_name)));
|
||||
case PropertyReadOnly:
|
||||
return msg.createErrorReply(QDBusError::PropertyReadOnly,
|
||||
QLatin1String("Property %1%2%3 is read-only")
|
||||
"Property %1%2%3 is read-only"_L1
|
||||
.arg(interface_name,
|
||||
QLatin1String(interface_name.isEmpty() ? "" : "."),
|
||||
interface_name.isEmpty() ? ""_L1 : "."_L1,
|
||||
QLatin1String(property_name)));
|
||||
case PropertyWriteFailed:
|
||||
return msg.createErrorReply(QDBusError::InternalError,
|
||||
|
@ -46,6 +46,8 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
static void qIterAppend(DBusMessageIter *it, QByteArray *ba, int type, const void *arg)
|
||||
{
|
||||
if (ba)
|
||||
@ -65,7 +67,7 @@ void QDBusMarshaller::unregisteredTypeError(QMetaType id)
|
||||
qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. "
|
||||
"Use qDBusRegisterMetaType to register it",
|
||||
name ? name : "", id.id());
|
||||
error(QLatin1String("Unregistered type %1 passed in arguments")
|
||||
error("Unregistered type %1 passed in arguments"_L1
|
||||
.arg(QLatin1String(id.name())));
|
||||
}
|
||||
|
||||
@ -143,7 +145,7 @@ inline void QDBusMarshaller::append(const QDBusObjectPath &arg)
|
||||
{
|
||||
QByteArray data = arg.path().toUtf8();
|
||||
if (!ba && data.isEmpty()) {
|
||||
error(QLatin1String("Invalid object path passed in arguments"));
|
||||
error("Invalid object path passed in arguments"_L1);
|
||||
} else {
|
||||
const char *cdata = data.constData();
|
||||
if (!skipSignature)
|
||||
@ -155,7 +157,7 @@ inline void QDBusMarshaller::append(const QDBusSignature &arg)
|
||||
{
|
||||
QByteArray data = arg.signature().toUtf8();
|
||||
if (!ba && data.isEmpty()) {
|
||||
error(QLatin1String("Invalid signature passed in arguments"));
|
||||
error("Invalid signature passed in arguments"_L1);
|
||||
} else {
|
||||
const char *cdata = data.constData();
|
||||
if (!skipSignature)
|
||||
@ -167,7 +169,7 @@ inline void QDBusMarshaller::append(const QDBusUnixFileDescriptor &arg)
|
||||
{
|
||||
int fd = arg.fileDescriptor();
|
||||
if (!ba && fd == -1) {
|
||||
error(QLatin1String("Invalid file descriptor passed in arguments"));
|
||||
error("Invalid file descriptor passed in arguments"_L1);
|
||||
} else {
|
||||
if (!skipSignature)
|
||||
qIterAppend(&iterator, ba, DBUS_TYPE_UNIX_FD, &fd);
|
||||
@ -202,7 +204,7 @@ inline bool QDBusMarshaller::append(const QDBusVariant &arg)
|
||||
QMetaType id = value.metaType();
|
||||
if (!id.isValid()) {
|
||||
qWarning("QDBusMarshaller: cannot add a null QDBusVariant");
|
||||
error(QLatin1String("Invalid QVariant passed in arguments"));
|
||||
error("Invalid QVariant passed in arguments"_L1);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -273,7 +275,7 @@ inline QDBusMarshaller *QDBusMarshaller::beginMap(QMetaType kid, QMetaType vid)
|
||||
if (ksignature[1] != 0 || !QDBusUtil::isValidBasicType(*ksignature)) {
|
||||
qWarning("QDBusMarshaller: type '%s' (%d) cannot be used as the key type in a D-BUS map.",
|
||||
kid.name(), kid.id());
|
||||
error(QLatin1String("Type %1 passed in arguments cannot be used as a key in a map")
|
||||
error("Type %1 passed in arguments cannot be used as a key in a map"_L1
|
||||
.arg(QLatin1String(kid.name())));
|
||||
return this;
|
||||
}
|
||||
@ -379,7 +381,7 @@ bool QDBusMarshaller::appendVariantInternal(const QVariant &arg)
|
||||
QMetaType id = arg.metaType();
|
||||
if (!id.isValid()) {
|
||||
qWarning("QDBusMarshaller: cannot add an invalid QVariant");
|
||||
error(QLatin1String("Invalid QVariant passed in arguments"));
|
||||
error("Invalid QVariant passed in arguments"_L1);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -56,6 +56,8 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
QT_IMPL_METATYPE_EXTERN(QDBusMessage)
|
||||
|
||||
static_assert(QDBusMessage::InvalidMessage == DBUS_MESSAGE_TYPE_INVALID);
|
||||
@ -114,7 +116,7 @@ DBusMessage *QDBusMessagePrivate::toDBusMessage(const QDBusMessage &message, QDB
|
||||
QDBusError *error)
|
||||
{
|
||||
if (!qdbus_loadLibDBus()) {
|
||||
*error = QDBusError(QDBusError::Failed, QLatin1String("Could not open lidbus-1 library"));
|
||||
*error = QDBusError(QDBusError::Failed, "Could not open lidbus-1 library"_L1);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -204,7 +206,7 @@ DBusMessage *QDBusMessagePrivate::toDBusMessage(const QDBusMessage &message, QDB
|
||||
|
||||
// not ok;
|
||||
q_dbus_message_unref(msg);
|
||||
*error = QDBusError(QDBusError::Failed, QLatin1String("Marshalling failed: ") + marshaller.errorString);
|
||||
*error = QDBusError(QDBusError::Failed, "Marshalling failed: "_L1 + marshaller.errorString);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -59,6 +59,8 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
class QDBusMetaObjectGenerator
|
||||
{
|
||||
public:
|
||||
@ -305,7 +307,7 @@ void QDBusMetaObjectGenerator::parseMethods()
|
||||
prototype.append(')');
|
||||
|
||||
// check the async tag
|
||||
if (m.annotations.value(QLatin1String(ANNOTATION_NO_WAIT)) == QLatin1String("true"))
|
||||
if (m.annotations.value(ANNOTATION_NO_WAIT ""_L1) == "true"_L1)
|
||||
mm.tag = "Q_NOREPLY";
|
||||
|
||||
// meta method flags
|
||||
@ -411,9 +413,9 @@ void QDBusMetaObjectGenerator::write(QDBusMetaObject *obj)
|
||||
// with a few modifications to make it cleaner
|
||||
|
||||
QString className = interface;
|
||||
className.replace(u'.', QLatin1String("::"));
|
||||
className.replace(u'.', "::"_L1);
|
||||
if (className.isEmpty())
|
||||
className = QLatin1String("QDBusInterface");
|
||||
className = "QDBusInterface"_L1;
|
||||
|
||||
QVarLengthArray<int> idata;
|
||||
idata.resize(sizeof(QDBusMetaObjectPrivate) / sizeof(int));
|
||||
@ -589,7 +591,7 @@ void QDBusMetaObjectGenerator::writeWithoutXml(const QString &interface)
|
||||
{
|
||||
// no XML definition
|
||||
QString tmp(interface);
|
||||
tmp.replace(u'.', QLatin1String("::"));
|
||||
tmp.replace(u'.', "::"_L1);
|
||||
QByteArray name(tmp.toLatin1());
|
||||
|
||||
QDBusMetaObjectPrivate *header = new QDBusMetaObjectPrivate;
|
||||
@ -628,13 +630,13 @@ QDBusMetaObject *QDBusMetaObject::createMetaObject(const QString &interface, con
|
||||
bool us = it.key() == interface;
|
||||
|
||||
QDBusMetaObject *obj = cache.value(it.key(), 0);
|
||||
if ( !obj && ( us || !interface.startsWith( QLatin1String("local.") ) ) ) {
|
||||
if (!obj && (us || !interface.startsWith("local."_L1 ))) {
|
||||
// not in cache; create
|
||||
obj = new QDBusMetaObject;
|
||||
QDBusMetaObjectGenerator generator(it.key(), it.value().constData());
|
||||
generator.write(obj);
|
||||
|
||||
if ( (obj->cached = !it.key().startsWith( QLatin1String("local.") )) )
|
||||
if ((obj->cached = !it.key().startsWith("local."_L1)))
|
||||
// cache it
|
||||
cache.insert(it.key(), obj);
|
||||
else if (!us)
|
||||
@ -670,7 +672,7 @@ QDBusMetaObject *QDBusMetaObject::createMetaObject(const QString &interface, con
|
||||
merged.properties.insert(it.value()->properties);
|
||||
}
|
||||
|
||||
merged.name = QLatin1String("local.Merged");
|
||||
merged.name = "local.Merged"_L1;
|
||||
merged.introspection.clear();
|
||||
|
||||
we = new QDBusMetaObject;
|
||||
@ -682,8 +684,7 @@ QDBusMetaObject *QDBusMetaObject::createMetaObject(const QString &interface, con
|
||||
|
||||
// mark as an error
|
||||
error = QDBusError(QDBusError::UnknownInterface,
|
||||
QLatin1String("Interface '%1' was not found")
|
||||
.arg(interface));
|
||||
"Interface '%1' was not found"_L1.arg(interface));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,8 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
bool qDBusCheckAsyncTag(const char *tag)
|
||||
{
|
||||
static const char noReplyTag[] = "Q_NOREPLY";
|
||||
@ -81,23 +83,23 @@ QString qDBusInterfaceFromMetaObject(const QMetaObject *mo)
|
||||
interface = QLatin1String(mo->classInfo(idx).value());
|
||||
} else {
|
||||
interface = QLatin1String(mo->className());
|
||||
interface.replace(QLatin1String("::"), QLatin1String("."));
|
||||
interface.replace("::"_L1, "."_L1);
|
||||
|
||||
if (interface.startsWith(QLatin1String("QDBus"))) {
|
||||
interface.prepend(QLatin1String("org.qtproject.QtDBus."));
|
||||
if (interface.startsWith("QDBus"_L1)) {
|
||||
interface.prepend("org.qtproject.QtDBus."_L1);
|
||||
} else if (interface.startsWith(u'Q') &&
|
||||
interface.length() >= 2 && interface.at(1).isUpper()) {
|
||||
// assume it's Qt
|
||||
interface.prepend(QLatin1String("org.qtproject.Qt."));
|
||||
interface.prepend("org.qtproject.Qt."_L1);
|
||||
} else if (!QCoreApplication::instance()||
|
||||
QCoreApplication::instance()->applicationName().isEmpty()) {
|
||||
interface.prepend(QLatin1String("local."));
|
||||
interface.prepend("local."_L1);
|
||||
} else {
|
||||
interface.prepend(u'.').prepend(QCoreApplication::instance()->applicationName());
|
||||
const QString organizationDomain = QCoreApplication::instance()->organizationDomain();
|
||||
const auto domainName = QStringView{organizationDomain}.split(u'.', Qt::SkipEmptyParts);
|
||||
if (domainName.isEmpty()) {
|
||||
interface.prepend(QLatin1String("local."));
|
||||
interface.prepend("local."_L1);
|
||||
} else {
|
||||
QString composedDomain;
|
||||
// + 1 for additional dot, e.g. organizationDomain equals "example.com",
|
||||
@ -156,7 +158,7 @@ int qDBusParametersForMethod(const QList<QByteArray> ¶meterTypes, QList<QMet
|
||||
for ( ; it != end; ++it) {
|
||||
QByteArray type = *it;
|
||||
if (type.endsWith('*')) {
|
||||
errorMsg = QLatin1String("Pointers are not supported: ") + QLatin1String(type);
|
||||
errorMsg = "Pointers are not supported: "_L1 + QLatin1String(type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -166,7 +168,7 @@ int qDBusParametersForMethod(const QList<QByteArray> ¶meterTypes, QList<QMet
|
||||
|
||||
QMetaType id = QMetaType::fromName(basictype);
|
||||
if (!id.isValid()) {
|
||||
errorMsg = QLatin1String("Unregistered output type in parameter list: ") + QLatin1String(type);
|
||||
errorMsg = "Unregistered output type in parameter list: "_L1 + QLatin1String(type);
|
||||
return -1;
|
||||
} else if (QDBusMetaType::typeToSignature(id) == nullptr)
|
||||
return -1;
|
||||
@ -177,7 +179,7 @@ int qDBusParametersForMethod(const QList<QByteArray> ¶meterTypes, QList<QMet
|
||||
}
|
||||
|
||||
if (seenMessage) { // && !type.endsWith('&')
|
||||
errorMsg = QLatin1String("Invalid method, non-output parameters after message or after output parameters: ") + QLatin1String(type);
|
||||
errorMsg = "Invalid method, non-output parameters after message or after output parameters: "_L1 + QLatin1String(type);
|
||||
return -1; // not allowed
|
||||
}
|
||||
|
||||
@ -193,14 +195,14 @@ int qDBusParametersForMethod(const QList<QByteArray> ¶meterTypes, QList<QMet
|
||||
#endif
|
||||
|
||||
if (!id.isValid()) {
|
||||
errorMsg = QLatin1String("Unregistered input type in parameter list: ") + QLatin1String(type);
|
||||
errorMsg = "Unregistered input type in parameter list: "_L1 + QLatin1String(type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (id == QDBusMetaTypeId::message())
|
||||
seenMessage = true;
|
||||
else if (QDBusMetaType::typeToSignature(id) == nullptr) {
|
||||
errorMsg = QLatin1String("Type not registered with QtDBus in parameter list: ") + QLatin1String(type);
|
||||
errorMsg = "Type not registered with QtDBus in parameter list: "_L1 + QLatin1String(type);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -53,6 +53,8 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
/*!
|
||||
\class QDBusPendingCall
|
||||
\inmodule QtDBus
|
||||
@ -188,7 +190,7 @@ bool QDBusPendingCallPrivate::setReplyCallback(QObject *target, const char *memb
|
||||
void QDBusPendingCallPrivate::setMetaTypes(int count, const QMetaType *types)
|
||||
{
|
||||
if (count == 0) {
|
||||
expectedReplySignature = QLatin1String(""); // not null
|
||||
expectedReplySignature = ""_L1; // not null
|
||||
return;
|
||||
}
|
||||
|
||||
@ -219,8 +221,7 @@ void QDBusPendingCallPrivate::checkReceivedSignature()
|
||||
|
||||
// can't use startsWith here because a null string doesn't start or end with an empty string
|
||||
if (replyMessage.signature().indexOf(expectedReplySignature) != 0) {
|
||||
const auto errorMsg = QLatin1String("Unexpected reply signature: got \"%1\", "
|
||||
"expected \"%2\"");
|
||||
const auto errorMsg = "Unexpected reply signature: got \"%1\", expected \"%2\""_L1;
|
||||
replyMessage = QDBusMessage::createError(
|
||||
QDBusError::InvalidSignature,
|
||||
errorMsg.arg(replyMessage.signature(), expectedReplySignature));
|
||||
|
@ -46,6 +46,8 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
/*!
|
||||
\class QDBusReply
|
||||
\inmodule QtDBus
|
||||
@ -235,15 +237,13 @@ void qDBusReplyFill(const QDBusMessage &reply, QDBusError &error, QVariant &data
|
||||
receivedSignature = "<empty signature>";
|
||||
QString errorMsg;
|
||||
if (receivedType) {
|
||||
errorMsg = QLatin1String("Unexpected reply signature: got \"%1\" (%4), "
|
||||
"expected \"%2\" (%3)")
|
||||
errorMsg = "Unexpected reply signature: got \"%1\" (%4), expected \"%2\" (%3)"_L1
|
||||
.arg(QLatin1String(receivedSignature),
|
||||
QLatin1String(expectedSignature),
|
||||
QLatin1String(data.typeName()),
|
||||
QLatin1String(receivedType));
|
||||
} else {
|
||||
errorMsg = QLatin1String("Unexpected reply signature: got \"%1\", "
|
||||
"expected \"%2\" (%3)")
|
||||
errorMsg = "Unexpected reply signature: got \"%1\", expected \"%2\" (%3)"_L1
|
||||
.arg(QLatin1String(receivedSignature),
|
||||
QLatin1String(expectedSignature),
|
||||
QLatin1String(data.typeName()));
|
||||
|
@ -51,6 +51,8 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
static inline bool isValidCharacterNoDash(QChar c)
|
||||
{
|
||||
ushort u = c.unicode();
|
||||
@ -86,7 +88,7 @@ static bool variantToString(const QVariant &arg, QString &out)
|
||||
out += u'{';
|
||||
const QStringList list = arg.toStringList();
|
||||
for (const QString &item : list)
|
||||
out += u'\"' + item + QLatin1String("\", ");
|
||||
out += u'\"' + item + "\", "_L1;
|
||||
if (!list.isEmpty())
|
||||
out.chop(2);
|
||||
out += u'}';
|
||||
@ -95,7 +97,7 @@ static bool variantToString(const QVariant &arg, QString &out)
|
||||
QByteArray list = arg.toByteArray();
|
||||
for (int i = 0; i < list.length(); ++i) {
|
||||
out += QString::number(list.at(i));
|
||||
out += QLatin1String(", ");
|
||||
out += ", "_L1;
|
||||
}
|
||||
if (!list.isEmpty())
|
||||
out.chop(2);
|
||||
@ -106,7 +108,7 @@ static bool variantToString(const QVariant &arg, QString &out)
|
||||
for (const QVariant &item : list) {
|
||||
if (!variantToString(item, out))
|
||||
return false;
|
||||
out += QLatin1String(", ");
|
||||
out += ", "_L1;
|
||||
}
|
||||
if (!list.isEmpty())
|
||||
out.chop(2);
|
||||
@ -120,31 +122,31 @@ static bool variantToString(const QVariant &arg, QString &out)
|
||||
} else if (argType == QMetaType::Double) {
|
||||
out += QString::number(arg.toDouble());
|
||||
} else if (argType == QMetaType::Bool) {
|
||||
out += QLatin1String(arg.toBool() ? "true" : "false");
|
||||
out += arg.toBool() ? "true"_L1 : "false"_L1;
|
||||
} else if (argType == qMetaTypeId<QDBusArgument>()) {
|
||||
argToString(qvariant_cast<QDBusArgument>(arg), out);
|
||||
} else if (argType == qMetaTypeId<QDBusObjectPath>()) {
|
||||
const QString path = qvariant_cast<QDBusObjectPath>(arg).path();
|
||||
out += QLatin1String("[ObjectPath: ");
|
||||
out += "[ObjectPath: "_L1;
|
||||
out += path;
|
||||
out += u']';
|
||||
} else if (argType == qMetaTypeId<QDBusSignature>()) {
|
||||
out += QLatin1String("[Signature: ") + qvariant_cast<QDBusSignature>(arg).signature();
|
||||
out += "[Signature: "_L1 + qvariant_cast<QDBusSignature>(arg).signature();
|
||||
out += u']';
|
||||
} else if (argType == qMetaTypeId<QDBusUnixFileDescriptor>()) {
|
||||
out += QLatin1String("[Unix FD: ");
|
||||
out += QLatin1String(qvariant_cast<QDBusUnixFileDescriptor>(arg).isValid() ? "valid" : "not valid");
|
||||
out += "[Unix FD: "_L1;
|
||||
out += qvariant_cast<QDBusUnixFileDescriptor>(arg).isValid() ? "valid"_L1 : "not valid"_L1;
|
||||
out += u']';
|
||||
} else if (argType == qMetaTypeId<QDBusVariant>()) {
|
||||
const QVariant v = qvariant_cast<QDBusVariant>(arg).variant();
|
||||
out += QLatin1String("[Variant");
|
||||
out += "[Variant"_L1;
|
||||
QMetaType vUserType = v.metaType();
|
||||
if (vUserType != QMetaType::fromType<QDBusVariant>()
|
||||
&& vUserType != QMetaType::fromType<QDBusSignature>()
|
||||
&& vUserType != QMetaType::fromType<QDBusObjectPath>()
|
||||
&& vUserType != QMetaType::fromType<QDBusArgument>())
|
||||
out += u'(' + QLatin1String(v.typeName()) + u')';
|
||||
out += QLatin1String(": ");
|
||||
out += ": "_L1;
|
||||
if (!variantToString(v, out))
|
||||
return false;
|
||||
out += u']';
|
||||
@ -167,7 +169,7 @@ bool argToString(const QDBusArgument &busArg, QString &out)
|
||||
|
||||
if (elementType != QDBusArgument::BasicType && elementType != QDBusArgument::VariantType
|
||||
&& elementType != QDBusArgument::MapEntryType)
|
||||
out += QLatin1String("[Argument: ") + busSig + u' ';
|
||||
out += "[Argument: "_L1 + busSig + u' ';
|
||||
|
||||
switch (elementType) {
|
||||
case QDBusArgument::BasicType:
|
||||
@ -193,21 +195,21 @@ bool argToString(const QDBusArgument &busArg, QString &out)
|
||||
busArg.beginMapEntry();
|
||||
if (!variantToString(busArg.asVariant(), out))
|
||||
return false;
|
||||
out += QLatin1String(" = ");
|
||||
out += " = "_L1;
|
||||
if (!argToString(busArg, out))
|
||||
return false;
|
||||
busArg.endMapEntry();
|
||||
break;
|
||||
case QDBusArgument::UnknownType:
|
||||
default:
|
||||
out += QLatin1String("<ERROR - Unknown Type>");
|
||||
out += "<ERROR - Unknown Type>"_L1;
|
||||
return false;
|
||||
}
|
||||
if (doIterate && !busArg.atEnd()) {
|
||||
while (!busArg.atEnd()) {
|
||||
if (!argToString(busArg, out))
|
||||
return false;
|
||||
out += QLatin1String(", ");
|
||||
out += ", "_L1;
|
||||
}
|
||||
out.chop(2);
|
||||
}
|
||||
@ -512,10 +514,10 @@ namespace QDBusUtil
|
||||
*/
|
||||
bool isValidObjectPath(const QString &path)
|
||||
{
|
||||
if (path == QLatin1String("/"))
|
||||
if (path == "/"_L1)
|
||||
return true;
|
||||
|
||||
if (!path.startsWith(u'/') || path.indexOf(QLatin1String("//")) != -1 ||
|
||||
if (!path.startsWith(u'/') || path.indexOf("//"_L1) != -1 ||
|
||||
path.endsWith(u'/'))
|
||||
return false;
|
||||
|
||||
|
@ -52,6 +52,8 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
extern Q_DBUS_EXPORT QString qDBusGenerateMetaObjectXml(QString interface, const QMetaObject *mo,
|
||||
const QMetaObject *base, int flags);
|
||||
|
||||
@ -64,11 +66,11 @@ static inline QString typeNameToXml(const char *typeName)
|
||||
rich.reserve(int(plain.size() * 1.1));
|
||||
for (int i = 0; i < plain.size(); ++i) {
|
||||
if (plain.at(i) == u'<')
|
||||
rich += QLatin1String("<");
|
||||
rich += "<"_L1;
|
||||
else if (plain.at(i) == u'>')
|
||||
rich += QLatin1String(">");
|
||||
rich += ">"_L1;
|
||||
else if (plain.at(i) == u'&')
|
||||
rich += QLatin1String("&");
|
||||
rich += "&"_L1;
|
||||
else
|
||||
rich += plain.at(i);
|
||||
}
|
||||
@ -78,9 +80,9 @@ static inline QString typeNameToXml(const char *typeName)
|
||||
static inline QLatin1String accessAsString(bool read, bool write)
|
||||
{
|
||||
if (read)
|
||||
return write ? QLatin1String("readwrite") : QLatin1String("read") ;
|
||||
return write ? "readwrite"_L1 : "read"_L1 ;
|
||||
else
|
||||
return write ? QLatin1String("write") : QLatin1String("") ;
|
||||
return write ? "write"_L1 : ""_L1 ;
|
||||
}
|
||||
|
||||
// implement the D-Bus org.freedesktop.DBus.Introspectable interface
|
||||
@ -108,17 +110,17 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method
|
||||
if (!signature)
|
||||
continue;
|
||||
|
||||
retval += QLatin1String(" <property name=\"%1\" type=\"%2\" access=\"%3\"")
|
||||
retval += " <property name=\"%1\" type=\"%2\" access=\"%3\""_L1
|
||||
.arg(QLatin1String(mp.name()),
|
||||
QLatin1String(signature),
|
||||
accessAsString(mp.isReadable(), mp.isWritable()));
|
||||
|
||||
if (!QDBusMetaType::signatureToMetaType(signature).isValid()) {
|
||||
const char *typeName = type.name();
|
||||
retval += QLatin1String(">\n <annotation name=\"org.qtproject.QtDBus.QtTypeName\" value=\"%3\"/>\n </property>\n")
|
||||
retval += ">\n <annotation name=\"org.qtproject.QtDBus.QtTypeName\" value=\"%3\"/>\n </property>\n"_L1
|
||||
.arg(typeNameToXml(typeName));
|
||||
} else {
|
||||
retval += QLatin1String("/>\n");
|
||||
retval += "/>\n"_L1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -160,12 +162,12 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method
|
||||
if (typeId.isValid() && typeId.id() != QMetaType::Void) {
|
||||
const char *typeName = QDBusMetaType::typeToSignature(typeId);
|
||||
if (typeName) {
|
||||
xml += QLatin1String(" <arg type=\"%1\" direction=\"out\"/>\n")
|
||||
xml += " <arg type=\"%1\" direction=\"out\"/>\n"_L1
|
||||
.arg(typeNameToXml(typeName));
|
||||
|
||||
// do we need to describe this argument?
|
||||
if (!QDBusMetaType::signatureToMetaType(typeName).isValid())
|
||||
xml += QLatin1String(" <annotation name=\"org.qtproject.QtDBus.QtTypeName.Out0\" value=\"%1\"/>\n")
|
||||
xml += " <annotation name=\"org.qtproject.QtDBus.QtTypeName.Out0\" value=\"%1\"/>\n"_L1
|
||||
.arg(typeNameToXml(QMetaType(typeId).name()));
|
||||
} else {
|
||||
qWarning() << "Unsupported return type" << typeId.id() << typeId.name() << "in method" << mm.name();
|
||||
@ -202,7 +204,7 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method
|
||||
|
||||
QString name;
|
||||
if (!names.at(j - 1).isEmpty())
|
||||
name = QLatin1String("name=\"%1\" ").arg(QLatin1String(names.at(j - 1)));
|
||||
name = "name=\"%1\" "_L1.arg(QLatin1String(names.at(j - 1)));
|
||||
|
||||
bool isOutput = isSignal || j > inputCount;
|
||||
|
||||
@ -214,7 +216,7 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method
|
||||
if (!QDBusMetaType::signatureToMetaType(signature).isValid()) {
|
||||
const char *typeName = QMetaType(types.at(j)).name();
|
||||
xml += QString::fromLatin1(" <annotation name=\"org.qtproject.QtDBus.QtTypeName.%1%2\" value=\"%3\"/>\n")
|
||||
.arg(isOutput ? QLatin1String("Out") : QLatin1String("In"))
|
||||
.arg(isOutput ? "Out"_L1 : "In"_L1)
|
||||
.arg(isOutput && !isSignal ? j - inputCount : j - 1)
|
||||
.arg(typeNameToXml(typeName));
|
||||
}
|
||||
@ -234,12 +236,10 @@ static QString generateInterfaceXml(const QMetaObject *mo, int flags, int method
|
||||
|
||||
if (qDBusCheckAsyncTag(mm.tag()))
|
||||
// add the no-reply annotation
|
||||
xml += QLatin1String(" <annotation name=\"" ANNOTATION_NO_WAIT "\""
|
||||
" value=\"true\"/>\n");
|
||||
xml += " <annotation name=\"" ANNOTATION_NO_WAIT "\" value=\"true\"/>\n"_L1;
|
||||
|
||||
retval += xml;
|
||||
retval += QLatin1String(" </%1>\n")
|
||||
.arg(isSignal ? QLatin1String("signal") : QLatin1String("method"));
|
||||
retval += " </%1>\n"_L1.arg(isSignal ? "signal"_L1 : "method"_L1);
|
||||
}
|
||||
|
||||
return retval;
|
||||
@ -261,7 +261,7 @@ QString qDBusGenerateMetaObjectXml(QString interface, const QMetaObject *mo,
|
||||
|
||||
if (xml.isEmpty())
|
||||
return QString(); // don't add an empty interface
|
||||
return QLatin1String(" <interface name=\"%1\">\n%2 </interface>\n")
|
||||
return " <interface name=\"%1\">\n%2 </interface>\n"_L1
|
||||
.arg(interface, xml);
|
||||
}
|
||||
#if 0
|
||||
@ -275,24 +275,24 @@ QString qDBusGenerateMetaObjectXml(QString interface, const QMetaObject *mo, con
|
||||
interface = QLatin1String(mo->classInfo(idx).value());
|
||||
} else {
|
||||
interface = QLatin1String(mo->className());
|
||||
interface.replace(QLatin1String("::"), QLatin1String("."));
|
||||
interface.replace("::"_L1, "."_L1);
|
||||
|
||||
if (interface.startsWith(QLatin1String("QDBus"))) {
|
||||
interface.prepend(QLatin1String("org.qtproject.QtDBus."));
|
||||
if (interface.startsWith("QDBus"_L1)) {
|
||||
interface.prepend("org.qtproject.QtDBus."_L1);
|
||||
} else if (interface.startsWith(u'Q') &&
|
||||
interface.length() >= 2 && interface.at(1).isUpper()) {
|
||||
// assume it's Qt
|
||||
interface.prepend(QLatin1String("org.qtproject.Qt."));
|
||||
interface.prepend("org.qtproject.Qt."_L1);
|
||||
} else if (!QCoreApplication::instance()||
|
||||
QCoreApplication::instance()->applicationName().isEmpty()) {
|
||||
interface.prepend(QLatin1String("local."));
|
||||
interface.prepend("local."_L1);
|
||||
} else {
|
||||
interface.prepend(u'.').prepend(QCoreApplication::instance()->applicationName());
|
||||
QStringList domainName =
|
||||
QCoreApplication::instance()->organizationDomain().split(u'.',
|
||||
Qt::SkipEmptyParts);
|
||||
if (domainName.isEmpty())
|
||||
interface.prepend(QLatin1String("local."));
|
||||
interface.prepend("local."_L1);
|
||||
else
|
||||
for (int i = 0; i < domainName.count(); ++i)
|
||||
interface.prepend(u'.').prepend(domainName.at(i));
|
||||
|
@ -50,6 +50,8 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
Q_LOGGING_CATEGORY(dbusParser, "dbus.parser", QtWarningMsg)
|
||||
|
||||
#define qDBusParserError(...) qCDebug(dbusParser, ##__VA_ARGS__)
|
||||
@ -57,7 +59,7 @@ Q_LOGGING_CATEGORY(dbusParser, "dbus.parser", QtWarningMsg)
|
||||
static bool parseArg(const QXmlStreamAttributes &attributes, QDBusIntrospection::Argument &argData,
|
||||
QDBusIntrospection::Interface *ifaceData)
|
||||
{
|
||||
const QString argType = attributes.value(QLatin1String("type")).toString();
|
||||
const QString argType = attributes.value("type"_L1).toString();
|
||||
|
||||
bool ok = QDBusUtil::isValidSingleSignature(argType);
|
||||
if (!ok) {
|
||||
@ -65,18 +67,18 @@ static bool parseArg(const QXmlStreamAttributes &attributes, QDBusIntrospection:
|
||||
qPrintable(argType));
|
||||
}
|
||||
|
||||
argData.name = attributes.value(QLatin1String("name")).toString();
|
||||
argData.name = attributes.value("name"_L1).toString();
|
||||
argData.type = argType;
|
||||
|
||||
ifaceData->introspection += QLatin1String(" <arg");
|
||||
if (attributes.hasAttribute(QLatin1String("direction"))) {
|
||||
const QString direction = attributes.value(QLatin1String("direction")).toString();
|
||||
ifaceData->introspection += QLatin1String(" direction=\"") + direction + QLatin1String("\"");
|
||||
ifaceData->introspection += " <arg"_L1;
|
||||
if (attributes.hasAttribute("direction"_L1)) {
|
||||
const QString direction = attributes.value("direction"_L1).toString();
|
||||
ifaceData->introspection += " direction=\""_L1 + direction + u'"';
|
||||
}
|
||||
ifaceData->introspection += QLatin1String(" type=\"") + argData.type + QLatin1String("\"");
|
||||
ifaceData->introspection += " type=\""_L1 + argData.type + u'"';
|
||||
if (!argData.name.isEmpty())
|
||||
ifaceData->introspection += QLatin1String(" name=\"") + argData.name + QLatin1String("\"");
|
||||
ifaceData->introspection += QLatin1String("/>\n");
|
||||
ifaceData->introspection += " name=\""_L1 + argData.name + u'"';
|
||||
ifaceData->introspection += "/>\n"_L1;
|
||||
|
||||
return ok;
|
||||
}
|
||||
@ -84,31 +86,31 @@ static bool parseArg(const QXmlStreamAttributes &attributes, QDBusIntrospection:
|
||||
static bool parseAnnotation(const QXmlStreamReader &xml, QDBusIntrospection::Annotations &annotations,
|
||||
QDBusIntrospection::Interface *ifaceData, bool interfaceAnnotation = false)
|
||||
{
|
||||
Q_ASSERT(xml.isStartElement() && xml.name() == QLatin1String("annotation"));
|
||||
Q_ASSERT(xml.isStartElement() && xml.name() == "annotation"_L1);
|
||||
|
||||
const QXmlStreamAttributes attributes = xml.attributes();
|
||||
const QString name = attributes.value(QLatin1String("name")).toString();
|
||||
const QString name = attributes.value("name"_L1).toString();
|
||||
|
||||
if (!QDBusUtil::isValidInterfaceName(name)) {
|
||||
qDBusParserError("Invalid D-BUS annotation '%s' found while parsing introspection",
|
||||
qPrintable(name));
|
||||
return false;
|
||||
}
|
||||
const QString value = attributes.value(QLatin1String("value")).toString();
|
||||
const QString value = attributes.value("value"_L1).toString();
|
||||
annotations.insert(name, value);
|
||||
if (!interfaceAnnotation)
|
||||
ifaceData->introspection += QLatin1String(" ");
|
||||
ifaceData->introspection += QLatin1String(" <annotation value=\"") + value.toHtmlEscaped() + QLatin1String("\" name=\"") + name + QLatin1String("\"/>\n");
|
||||
ifaceData->introspection += " "_L1;
|
||||
ifaceData->introspection += " <annotation value=\""_L1 + value.toHtmlEscaped() + "\" name=\""_L1 + name + "\"/>\n"_L1;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool parseProperty(QXmlStreamReader &xml, QDBusIntrospection::Property &propertyData,
|
||||
QDBusIntrospection::Interface *ifaceData)
|
||||
{
|
||||
Q_ASSERT(xml.isStartElement() && xml.name() == QLatin1String("property"));
|
||||
Q_ASSERT(xml.isStartElement() && xml.name() == "property"_L1);
|
||||
|
||||
QXmlStreamAttributes attributes = xml.attributes();
|
||||
const QString propertyName = attributes.value(QLatin1String("name")).toString();
|
||||
const QString propertyName = attributes.value("name"_L1).toString();
|
||||
if (!QDBusUtil::isValidMemberName(propertyName)) {
|
||||
qDBusParserError("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection",
|
||||
qPrintable(propertyName), qPrintable(ifaceData->name));
|
||||
@ -118,7 +120,7 @@ static bool parseProperty(QXmlStreamReader &xml, QDBusIntrospection::Property &p
|
||||
|
||||
// parse data
|
||||
propertyData.name = propertyName;
|
||||
propertyData.type = attributes.value(QLatin1String("type")).toString();
|
||||
propertyData.type = attributes.value("type"_L1).toString();
|
||||
|
||||
if (!QDBusUtil::isValidSingleSignature(propertyData.type)) {
|
||||
// cannot be!
|
||||
@ -127,12 +129,12 @@ static bool parseProperty(QXmlStreamReader &xml, QDBusIntrospection::Property &p
|
||||
qPrintable(propertyName));
|
||||
}
|
||||
|
||||
const QString access = attributes.value(QLatin1String("access")).toString();
|
||||
if (access == QLatin1String("read"))
|
||||
const QString access = attributes.value("access"_L1).toString();
|
||||
if (access == "read"_L1)
|
||||
propertyData.access = QDBusIntrospection::Property::Read;
|
||||
else if (access == QLatin1String("write"))
|
||||
else if (access == "write"_L1)
|
||||
propertyData.access = QDBusIntrospection::Property::Write;
|
||||
else if (access == QLatin1String("readwrite"))
|
||||
else if (access == "readwrite"_L1)
|
||||
propertyData.access = QDBusIntrospection::Property::ReadWrite;
|
||||
else {
|
||||
qDBusParserError("Invalid D-BUS property access '%s' found in property '%s.%s' while parsing introspection",
|
||||
@ -141,15 +143,15 @@ static bool parseProperty(QXmlStreamReader &xml, QDBusIntrospection::Property &p
|
||||
return false; // invalid one!
|
||||
}
|
||||
|
||||
ifaceData->introspection += QLatin1String(" <property access=\"") + access + QLatin1String("\" type=\"") + propertyData.type + QLatin1String("\" name=\"") + propertyName + QLatin1String("\"");
|
||||
ifaceData->introspection += " <property access=\""_L1 + access + "\" type=\""_L1 + propertyData.type + "\" name=\""_L1 + propertyName + u'"';
|
||||
|
||||
if (!xml.readNextStartElement()) {
|
||||
ifaceData->introspection += QLatin1String("/>\n");
|
||||
ifaceData->introspection += "/>\n"_L1;
|
||||
} else {
|
||||
ifaceData->introspection += QLatin1String(">\n");
|
||||
ifaceData->introspection += ">\n"_L1;
|
||||
|
||||
do {
|
||||
if (xml.name() == QLatin1String("annotation")) {
|
||||
if (xml.name() == "annotation"_L1) {
|
||||
parseAnnotation(xml, propertyData.annotations, ifaceData);
|
||||
} else if (xml.prefix().isEmpty()) {
|
||||
qDBusParserError() << "Unknown element" << xml.name() << "while checking for annotations";
|
||||
@ -157,10 +159,10 @@ static bool parseProperty(QXmlStreamReader &xml, QDBusIntrospection::Property &p
|
||||
xml.skipCurrentElement();
|
||||
} while (xml.readNextStartElement());
|
||||
|
||||
ifaceData->introspection += QLatin1String(" </property>\n");
|
||||
ifaceData->introspection += " </property>\n"_L1;
|
||||
}
|
||||
|
||||
if (!xml.isEndElement() || xml.name() != QLatin1String("property")) {
|
||||
if (!xml.isEndElement() || xml.name() != "property"_L1) {
|
||||
qDBusParserError() << "Invalid property specification" << xml.tokenString() << xml.name();
|
||||
return false;
|
||||
}
|
||||
@ -171,10 +173,10 @@ static bool parseProperty(QXmlStreamReader &xml, QDBusIntrospection::Property &p
|
||||
static bool parseMethod(QXmlStreamReader &xml, QDBusIntrospection::Method &methodData,
|
||||
QDBusIntrospection::Interface *ifaceData)
|
||||
{
|
||||
Q_ASSERT(xml.isStartElement() && xml.name() == QLatin1String("method"));
|
||||
Q_ASSERT(xml.isStartElement() && xml.name() == "method"_L1);
|
||||
|
||||
const QXmlStreamAttributes attributes = xml.attributes();
|
||||
const QString methodName = attributes.value(QLatin1String("name")).toString();
|
||||
const QString methodName = attributes.value("name"_L1).toString();
|
||||
if (!QDBusUtil::isValidMemberName(methodName)) {
|
||||
qDBusParserError("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection",
|
||||
qPrintable(methodName), qPrintable(ifaceData->name));
|
||||
@ -182,29 +184,28 @@ static bool parseMethod(QXmlStreamReader &xml, QDBusIntrospection::Method &metho
|
||||
}
|
||||
|
||||
methodData.name = methodName;
|
||||
ifaceData->introspection += QLatin1String(" <method name=\"") + methodName + QLatin1String("\"");
|
||||
ifaceData->introspection += " <method name=\""_L1 + methodName + u'"';
|
||||
|
||||
QDBusIntrospection::Arguments outArguments;
|
||||
QDBusIntrospection::Arguments inArguments;
|
||||
QDBusIntrospection::Annotations annotations;
|
||||
|
||||
if (!xml.readNextStartElement()) {
|
||||
ifaceData->introspection += QLatin1String("/>\n");
|
||||
ifaceData->introspection += "/>\n"_L1;
|
||||
} else {
|
||||
ifaceData->introspection += QLatin1String(">\n");
|
||||
ifaceData->introspection += ">\n"_L1;
|
||||
|
||||
do {
|
||||
if (xml.name() == QLatin1String("annotation")) {
|
||||
if (xml.name() == "annotation"_L1) {
|
||||
parseAnnotation(xml, annotations, ifaceData);
|
||||
} else if (xml.name() == QLatin1String("arg")) {
|
||||
} else if (xml.name() == "arg"_L1) {
|
||||
const QXmlStreamAttributes attributes = xml.attributes();
|
||||
const QString direction = attributes.value(QLatin1String("direction")).toString();
|
||||
const QString direction = attributes.value("direction"_L1).toString();
|
||||
QDBusIntrospection::Argument argument;
|
||||
if (!attributes.hasAttribute(QLatin1String("direction"))
|
||||
|| direction == QLatin1String("in")) {
|
||||
if (!attributes.hasAttribute("direction"_L1) || direction == "in"_L1) {
|
||||
parseArg(attributes, argument, ifaceData);
|
||||
inArguments << argument;
|
||||
} else if (direction == QLatin1String("out")) {
|
||||
} else if (direction == "out"_L1) {
|
||||
parseArg(attributes, argument, ifaceData);
|
||||
outArguments << argument;
|
||||
}
|
||||
@ -214,7 +215,7 @@ static bool parseMethod(QXmlStreamReader &xml, QDBusIntrospection::Method &metho
|
||||
xml.skipCurrentElement();
|
||||
} while (xml.readNextStartElement());
|
||||
|
||||
ifaceData->introspection += QLatin1String(" </method>\n");
|
||||
ifaceData->introspection += " </method>\n"_L1;
|
||||
}
|
||||
|
||||
methodData.inputArgs = inArguments;
|
||||
@ -228,10 +229,10 @@ static bool parseMethod(QXmlStreamReader &xml, QDBusIntrospection::Method &metho
|
||||
static bool parseSignal(QXmlStreamReader &xml, QDBusIntrospection::Signal &signalData,
|
||||
QDBusIntrospection::Interface *ifaceData)
|
||||
{
|
||||
Q_ASSERT(xml.isStartElement() && xml.name() == QLatin1String("signal"));
|
||||
Q_ASSERT(xml.isStartElement() && xml.name() == "signal"_L1);
|
||||
|
||||
const QXmlStreamAttributes attributes = xml.attributes();
|
||||
const QString signalName = attributes.value(QLatin1String("name")).toString();
|
||||
const QString signalName = attributes.value("name"_L1).toString();
|
||||
|
||||
if (!QDBusUtil::isValidMemberName(signalName)) {
|
||||
qDBusParserError("Invalid D-BUS member name '%s' found in interface '%s' while parsing introspection",
|
||||
@ -240,24 +241,24 @@ static bool parseSignal(QXmlStreamReader &xml, QDBusIntrospection::Signal &signa
|
||||
}
|
||||
|
||||
signalData.name = signalName;
|
||||
ifaceData->introspection += QLatin1String(" <signal name=\"") + signalName + QLatin1String("\"");
|
||||
ifaceData->introspection += " <signal name=\""_L1 + signalName + u'"';
|
||||
|
||||
QDBusIntrospection::Arguments arguments;
|
||||
QDBusIntrospection::Annotations annotations;
|
||||
|
||||
if (!xml.readNextStartElement()) {
|
||||
ifaceData->introspection += QLatin1String("/>\n");
|
||||
ifaceData->introspection += "/>\n"_L1;
|
||||
} else {
|
||||
ifaceData->introspection += QLatin1String(">\n");
|
||||
ifaceData->introspection += ">\n"_L1;
|
||||
|
||||
do {
|
||||
if (xml.name() == QLatin1String("annotation")) {
|
||||
if (xml.name() == "annotation"_L1) {
|
||||
parseAnnotation(xml, annotations, ifaceData);
|
||||
} else if (xml.name() == QLatin1String("arg")) {
|
||||
} else if (xml.name() == "arg"_L1) {
|
||||
const QXmlStreamAttributes attributes = xml.attributes();
|
||||
QDBusIntrospection::Argument argument;
|
||||
if (!attributes.hasAttribute(QLatin1String("direction")) ||
|
||||
attributes.value(QLatin1String("direction")) == QLatin1String("out")) {
|
||||
if (!attributes.hasAttribute("direction"_L1) ||
|
||||
attributes.value("direction"_L1) == "out"_L1) {
|
||||
parseArg(attributes, argument, ifaceData);
|
||||
arguments << argument;
|
||||
}
|
||||
@ -267,7 +268,7 @@ static bool parseSignal(QXmlStreamReader &xml, QDBusIntrospection::Signal &signa
|
||||
xml.skipCurrentElement();
|
||||
} while (xml.readNextStartElement());
|
||||
|
||||
ifaceData->introspection += QLatin1String(" </signal>\n");
|
||||
ifaceData->introspection += " </signal>\n"_L1;
|
||||
}
|
||||
|
||||
signalData.outputArgs = arguments;
|
||||
@ -279,7 +280,7 @@ static bool parseSignal(QXmlStreamReader &xml, QDBusIntrospection::Signal &signa
|
||||
static void readInterface(QXmlStreamReader &xml, QDBusIntrospection::Object *objData,
|
||||
QDBusIntrospection::Interfaces *interfaces)
|
||||
{
|
||||
const QString ifaceName = xml.attributes().value(QLatin1String("name")).toString();
|
||||
const QString ifaceName = xml.attributes().value("name"_L1).toString();
|
||||
if (!QDBusUtil::isValidInterfaceName(ifaceName)) {
|
||||
qDBusParserError("Invalid D-BUS interface name '%s' found while parsing introspection",
|
||||
qPrintable(ifaceName));
|
||||
@ -290,22 +291,22 @@ static void readInterface(QXmlStreamReader &xml, QDBusIntrospection::Object *obj
|
||||
|
||||
QDBusIntrospection::Interface *ifaceData = new QDBusIntrospection::Interface;
|
||||
ifaceData->name = ifaceName;
|
||||
ifaceData->introspection += QLatin1String(" <interface name=\"") + ifaceName + QLatin1String("\">\n");
|
||||
ifaceData->introspection += " <interface name=\""_L1 + ifaceName + "\">\n"_L1;
|
||||
|
||||
while (xml.readNextStartElement()) {
|
||||
if (xml.name() == QLatin1String("method")) {
|
||||
if (xml.name() == "method"_L1) {
|
||||
QDBusIntrospection::Method methodData;
|
||||
if (parseMethod(xml, methodData, ifaceData))
|
||||
ifaceData->methods.insert(methodData.name, methodData);
|
||||
} else if (xml.name() == QLatin1String("signal")) {
|
||||
} else if (xml.name() == "signal"_L1) {
|
||||
QDBusIntrospection::Signal signalData;
|
||||
if (parseSignal(xml, signalData, ifaceData))
|
||||
ifaceData->signals_.insert(signalData.name, signalData);
|
||||
} else if (xml.name() == QLatin1String("property")) {
|
||||
} else if (xml.name() == "property"_L1) {
|
||||
QDBusIntrospection::Property propertyData;
|
||||
if (parseProperty(xml, propertyData, ifaceData))
|
||||
ifaceData->properties.insert(propertyData.name, propertyData);
|
||||
} else if (xml.name() == QLatin1String("annotation")) {
|
||||
} else if (xml.name() == "annotation"_L1) {
|
||||
parseAnnotation(xml, ifaceData->annotations, ifaceData, true);
|
||||
xml.skipCurrentElement(); // skip over annotation object
|
||||
} else {
|
||||
@ -316,18 +317,18 @@ static void readInterface(QXmlStreamReader &xml, QDBusIntrospection::Object *obj
|
||||
}
|
||||
}
|
||||
|
||||
ifaceData->introspection += QLatin1String(" </interface>");
|
||||
ifaceData->introspection += " </interface>"_L1;
|
||||
|
||||
interfaces->insert(ifaceName, QSharedDataPointer<QDBusIntrospection::Interface>(ifaceData));
|
||||
|
||||
if (!xml.isEndElement() || xml.name() != QLatin1String("interface")) {
|
||||
if (!xml.isEndElement() || xml.name() != "interface"_L1) {
|
||||
qDBusParserError() << "Invalid Interface specification";
|
||||
}
|
||||
}
|
||||
|
||||
static void readNode(const QXmlStreamReader &xml, QDBusIntrospection::Object *objData, int nodeLevel)
|
||||
{
|
||||
const QString objName = xml.attributes().value(QLatin1String("name")).toString();
|
||||
const QString objName = xml.attributes().value("name"_L1).toString();
|
||||
const QString fullName = objData->path.endsWith(u'/')
|
||||
? (objData->path + objName)
|
||||
: QString(objData->path + u'/' + objName);
|
||||
@ -359,9 +360,9 @@ QDBusXmlParser::QDBusXmlParser(const QString& service, const QString& path,
|
||||
|
||||
switch (xml.tokenType()) {
|
||||
case QXmlStreamReader::StartElement:
|
||||
if (xml.name() == QLatin1String("node")) {
|
||||
if (xml.name() == "node"_L1) {
|
||||
readNode(xml, m_object, ++nodeLevel);
|
||||
} else if (xml.name() == QLatin1String("interface")) {
|
||||
} else if (xml.name() == "interface"_L1) {
|
||||
readInterface(xml, m_object, &m_interfaces);
|
||||
} else {
|
||||
if (xml.prefix().isEmpty()) {
|
||||
@ -371,7 +372,7 @@ QDBusXmlParser::QDBusXmlParser(const QString& service, const QString& path,
|
||||
}
|
||||
break;
|
||||
case QXmlStreamReader::EndElement:
|
||||
if (xml.name() == QLatin1String("node")) {
|
||||
if (xml.name() == "node"_L1) {
|
||||
--nodeLevel;
|
||||
} else {
|
||||
qDBusParserError() << "Invalid Node declaration" << xml.name();
|
||||
|
Loading…
Reference in New Issue
Block a user