dbus/qt/tools Makefile.am, 1.1, 1.2 dbus.cpp, NONE,
1.1 dbuscpp2xml.cpp, 1.1, 1.2 dbusidl2cpp.cpp, 1.1, 1.2
Thiago J. Macieira
thiago at kemper.freedesktop.org
Mon Jun 5 11:13:10 PDT 2006
- Previous message: dbus/qt/examples Makefile.am, 1.3, 1.4 complexpong.cpp, 1.1,
1.2 dbus.cpp, 1.4, NONE pong.cpp, 1.1, 1.2
- Next message: dbus/qt/src qdbusabstractadaptor.cpp, 1.1,
1.2 qdbusabstractinterface.cpp, 1.1, 1.2 qdbusbus.cpp, 1.1,
1.2 qdbusbus.h, 1.1, 1.2 qdbusconnection.cpp, 1.1,
1.2 qdbusconnection.h, 1.1, 1.2 qdbuserror.cpp, 1.1,
1.2 qdbuserror.h, 1.1, 1.2 qdbusintegrator.cpp, 1.1,
1.2 qdbusinterface.cpp, 1.1, 1.2 qdbusinternalfilters.cpp, 1.1,
1.2 qdbusmessage.cpp, 1.1, 1.2 qdbusmessage.h, 1.1,
1.2 qdbusmetaobject.cpp, 1.1, 1.2 qdbusreply.h, 1.1,
1.2 qdbusserver.cpp, 1.1, 1.2 qdbusutil.cpp, 1.1,
1.2 qdbusxmlgenerator.cpp, 1.1, 1.2 qdbusxmlparser.cpp, 1.1, 1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvs/dbus/dbus/qt/tools
In directory kemper:/tmp/cvs-serv17133/qt/tools
Modified Files:
Makefile.am dbuscpp2xml.cpp dbusidl2cpp.cpp
Added Files:
dbus.cpp
Log Message:
* qt/dbus: Add directory. I had forgotten to add this
yesterday after the move...
* qt/examples/Makefile.am:
* qt/examples/dbus.cpp: Moved to qt/tools/dbus.cpp.
* qt/tools/Makefile.am:
* qt/tools/dbus.cpp: Moved from qt/examples/dbus.cpp.
Added feature to get and set properties.
Added validation of service, object path and interface names.
* qt/tools/dbusidl2cpp.cpp: Two new features:
1) Allow specifying both the header and the source file names,
by separating them with a colon.
2) Don't write an interface output if the -p switch wasn't
given, but the -a was.
* qt/src/*: Fix usage of Iterators and ConstIterators.
Fix shadowing of variables by other variables (-Wshadow).
Fix keyword-cleanliness in headers.
Fix ASCII-cast (QLatin1String, QLatin1Char).
Fix validation of member names.
Add extra checking of introspection data during XML parsing.
Various bug fixes.
Index: Makefile.am
===================================================================
RCS file: /cvs/dbus/dbus/qt/tools/Makefile.am,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Makefile.am 4 Jun 2006 15:52:05 -0000 1.1
+++ Makefile.am 5 Jun 2006 18:13:07 -0000 1.2
@@ -1,5 +1,5 @@
INCLUDES=-I$(top_srcdir)/qt $(DBUS_CLIENT_CFLAGS) $(DBUS_QT_CFLAGS) -DDBUS_COMPILATION
-bin_PROGRAMS = dbusidl2cpp dbuscpp2xml
+bin_PROGRAMS = dbusidl2cpp dbuscpp2xml dbus
dbusidl2cpp_SOURCES = dbusidl2cpp.cpp
dbusidl2cpp_LDFLAGS = -no-undefined
@@ -8,3 +8,6 @@
dbuscpp2xml_SOURCES = dbuscpp2xml.cpp
dbuscpp2xml_LDFLAGS = -no-undefined
dbuscpp2xml_LDADD = $(DBUS_QT_LIBS) ../src/libdbus-qt4-1.la
+
+dbus_SOURCES = dbus.cpp
+dbus_LDADD = $(DBUS_QT_LIBS) ../src/libdbus-qt4-1.la
--- NEW FILE: dbus.cpp ---
/* -*- C++ -*-
*
* Copyright (C) 2006 Trolltech AS. All rights reserved.
* Author: Thiago Macieira <thiago.macieira at trolltech.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <dbus/qdbus.h>
#include <QtCore/QCoreApplication>
#include <QtCore/QStringList>
#include <QtCore/qmetaobject.h>
#include <QtXml/QDomDocument>
#include <QtXml/QDomElement>
Q_DECLARE_METATYPE(QVariant)
QDBusConnection *connection;
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();
}
}
void listInterface(const QString &service, const QString &path, const QString &interface)
{
QDBusInterfacePtr iface(*connection, service, path, interface);
if (!iface->isValid()) {
QDBusError err(iface->lastError());
fprintf(stderr, "Interface '%s' not available in object %s at %s:\n%s (%s)\n",
qPrintable(interface), qPrintable(path), qPrintable(service),
qPrintable(err.name()), qPrintable(err.message()));
exit(1);
}
const QMetaObject *mo = iface->metaObject();
// properties
for (int i = mo->propertyOffset(); i < mo->propertyCount(); ++i) {
QMetaProperty mp = mo->property(i);
printf("property ");
if (mp.isReadable() && mp.isWritable())
printf("readwrite");
else if (mp.isReadable())
printf("read");
else
printf("write");
printf(" %s %s.%s\n", mp.typeName(), qPrintable(interface), mp.name());
}
// methods (signals and slots)
for (int i = mo->methodOffset(); i < mo->methodCount(); ++i) {
QMetaMethod mm = mo->method(i);
QByteArray signature = mm.signature();
signature.truncate(signature.indexOf('('));
printf("%s %s%s%s %s.%s(",
mm.methodType() == QMetaMethod::Signal ? "signal" : "method",
mm.tag(), *mm.tag() ? " " : "",
*mm.typeName() ? mm.typeName() : "void",
qPrintable(interface), signature.constData());
QList<QByteArray> types = mm.parameterTypes();
QList<QByteArray> names = mm.parameterNames();
bool first = true;
for (int i = 0; i < types.count(); ++i) {
printf("%s%s",
first ? "" : ", ",
types.at(i).constData());
if (!names.at(i).isEmpty())
printf(" %s", names.at(i).constData());
first = false;
}
printf(")\n");
}
}
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();
}
}
QStringList readList(int &argc, const char *const *&argv)
{
--argc;
++argv;
QStringList retval;
while (argc && QLatin1String(argv[0]) != ")")
retval += QString::fromLocal8Bit(argv[0]);
return retval;
}
void placeCall(const QString &service, const QString &path, const QString &interface,
const QString &member, int argc, const char *const *argv)
{
QDBusInterfacePtr iface(*connection, service, path, interface);
if (!iface->isValid()) {
QDBusError err(iface->lastError());
fprintf(stderr, "Interface '%s' not available in object %s at %s:\n%s (%s)\n",
qPrintable(interface), qPrintable(path), qPrintable(service),
qPrintable(err.name()), qPrintable(err.message()));
exit(1);
}
const QMetaObject *mo = iface->metaObject();
QByteArray match = member.toLatin1();
match += '(';
int midx = -1;
for (int i = mo->methodOffset(); i < mo->methodCount(); ++i) {
QMetaMethod mm = mo->method(i);
QByteArray signature = mm.signature();
if (signature.startsWith(match)) {
midx = i;
break;
}
}
if (midx == -1) {
fprintf(stderr, "Cannot find '%s.%s' in object %s at %s\n",
qPrintable(interface), qPrintable(member), qPrintable(path),
qPrintable(service));
exit(1);
}
QMetaMethod mm = mo->method(midx);
QList<QByteArray> types = mm.parameterTypes();
QVariantList params;
for (int i = 0; argc && i < types.count(); ++i) {
int id = QVariant::nameToType(types.at(i));
if ((id == QVariant::UserType || id == QVariant::Map) && types.at(i) != "QVariant") {
fprintf(stderr, "Sorry, can't pass arg of type %s yet\n",
types.at(i).constData());
exit(1);
}
if (id == QVariant::UserType)
id = QMetaType::type(types.at(i));
Q_ASSERT(id);
QVariant p;
if ((id == QVariant::List || id == QVariant::StringList) && QLatin1String("(") == argv[0])
p = readList(argc, argv);
else
p = QString::fromLocal8Bit(argv[0]);
if (id < int(QVariant::UserType)) {
// avoid calling it for QVariant
p.convert( QVariant::Type(id) );
if (p.type() == QVariant::Invalid) {
fprintf(stderr, "Could not convert '%s' to type '%s'.\n",
argv[0], types.at(i).constData());
exit(1);
}
} else if (types.at(i) == "QVariant") {
QVariant tmp(id, p.constData());
p = tmp;
}
params += p;
--argc;
++argv;
}
if (params.count() != types.count()) {
fprintf(stderr, "Invalid number of parameters\n");
exit(1);
}
QDBusMessage reply = iface->callWithArgs(member, params);
if (reply.type() == QDBusMessage::ErrorMessage) {
QDBusError err = reply;
printf("Error: %s\n%s\n", qPrintable(err.name()), qPrintable(err.message()));
exit(2);
} else if (reply.type() != QDBusMessage::ReplyMessage) {
fprintf(stderr, "Invalid reply type %d\n", int(reply.type()));
exit(1);
}
foreach (QVariant v, reply) {
if (v.userType() == QVariant::StringList) {
foreach (QString s, v.toStringList())
printf("%s\n", qPrintable(s));
} else {
if (v.userType() == qMetaTypeId<QVariant>())
v = qvariant_cast<QVariant>(v);
printf("%s\n", qPrintable(v.toString()));
}
}
exit(0);
}
bool splitInterfaceAndName(const QString &interfaceAndName, const char *type,
QString &interface, QString &member)
{
interface = interfaceAndName;
int pos = interface.lastIndexOf(QLatin1Char('.'));
if (pos != -1) {
member = interface.mid(pos + 1);
interface.truncate(pos);
}
if (!QDBusUtil::isValidInterfaceName(interface)) {
fprintf(stderr, "Interface '%s' is not a valid interface name.\n", qPrintable(interface));
return false;
} else if (!QDBusUtil::isValidMemberName(member)) {
fprintf(stderr, "%s name '%s' is not a valid member name.\n", type, qPrintable(member));
return false;
}
return true;
}
void getProperty(const QString &service, const QString &path, const QString &interfaceAndName)
{
QString property;
QString interface;
if (!splitInterfaceAndName(interfaceAndName, "Property", interface, property))
exit(1);
QDBusInterfacePtr iface(*connection, service, path, interface);
QVariant reply = iface->property(property.toLatin1());
if (reply.isNull()) {
QDBusError error = iface->lastError();
fprintf(stderr, "Could not get property '%s' on interface '%s': %s (%s)\n",
qPrintable(property), qPrintable(interface), qPrintable(error.name()),
qPrintable(error.message()));
exit(1);
}
printf("%s\n", qPrintable(reply.toString()));
}
void setProperty(const QString &service, const QString &path, const QString &interfaceAndName,
const QString &valueStr)
{
QString property;
QString interface;
if (!splitInterfaceAndName(interfaceAndName, "Property", interface, property))
exit(1);
QDBusInterfacePtr iface(*connection, service, path, interface);
iface->setProperty(property.toLatin1(), valueStr);
}
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
if (argc >= 1 && qstrcmp(argv[1], "--system") == 0) {
connection = &QDBus::systemBus();
--argc;
++argv;
} else
connection = &QDBus::sessionBus();
if (!connection->isConnected()) {
fprintf(stderr, "Could not connect to D-Bus server: %s: %s\n",
qPrintable(connection->lastError().name()),
qPrintable(connection->lastError().message()));
return 1;
}
QDBusBusService *bus = connection->busService();
if (argc == 1) {
QStringList names = bus->ListNames();
foreach (QString name, names)
printf("%s\n", qPrintable(name));
exit(0);
}
QString service = QLatin1String(argv[1]);
if (!QDBusUtil::isValidBusName(service)) {
fprintf(stderr, "Service '%s' is not a valid name.\n", qPrintable(service));
exit(1);
}
if (!bus->NameHasOwner(service)) {
fprintf(stderr, "Service '%s' does not exist.\n", qPrintable(service));
exit(1);
}
if (argc == 2) {
printf("/\n");
listObjects(service, QString());
exit(0);
}
QString path = QLatin1String(argv[2]);
if (!QDBusUtil::isValidObjectPath(path)) {
fprintf(stderr, "Path '%s' is not a valid path name.\n", qPrintable(path));
exit(1);
}
if (argc == 3) {
listAllInterfaces(service, path);
exit(0);
}
QString interface = QLatin1String(argv[3]);
QString member;
int pos = interface.lastIndexOf(QLatin1Char('.'));
if (pos == -1) {
member = interface;
interface.clear();
} else {
member = interface.mid(pos + 1);
interface.truncate(pos);
}
if (!interface.isEmpty() && !QDBusUtil::isValidInterfaceName(interface)) {
fprintf(stderr, "Interface '%s' is not a valid interface name.\n", qPrintable(interface));
exit(1);
}
if (!QDBusUtil::isValidMemberName(member)) {
fprintf(stderr, "Method name '%s' is not a valid member name.\n", qPrintable(member));
exit(1);
}
if (interface.isEmpty()) {
if (member.toLower() == QLatin1String("get") && argc == 5) {
getProperty(service, path, QLatin1String(argv[4]));
return 0;
} else if (member.toLower() == QLatin1String("set") && argc == 6) {
setProperty(service, path, QLatin1String(argv[4]), QLatin1String(argv[5]));
return 0;
}
}
placeCall(service, path, interface, member, argc - 4, argv + 4);
}
Index: dbuscpp2xml.cpp
===================================================================
RCS file: /cvs/dbus/dbus/qt/tools/dbuscpp2xml.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- dbuscpp2xml.cpp 4 Jun 2006 15:52:05 -0000 1.1
+++ dbuscpp2xml.cpp 5 Jun 2006 18:13:07 -0000 1.2
@@ -29,6 +29,7 @@
#include <QRegExp>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
@@ -76,7 +77,7 @@
QIODevice *input;
const char *filename;
- int line;
+ int lineNumber;
public:
~MocParser();
void parse(const char *filename, QIODevice *input, int lineNumber = 0);
@@ -86,13 +87,13 @@
void MocParser::parseError()
{
- fprintf(stderr, PROGRAMNAME ": error parsing input file '%s' line %d \n", filename, line);
+ fprintf(stderr, PROGRAMNAME ": error parsing input file '%s' line %d \n", filename, lineNumber);
exit(1);
}
QByteArray MocParser::readLine()
{
- ++line;
+ ++lineNumber;
return input->readLine();
}
@@ -100,15 +101,15 @@
{
data = 0; // initialise
QVarLengthArray<uint> array;
- QRegExp rx("(\\d+|0x[0-9abcdef]+)", Qt::CaseInsensitive);
+ QRegExp rx(QLatin1String("(\\d+|0x[0-9abcdef]+)"), Qt::CaseInsensitive);
while (!input->atEnd()) {
QString line = QLatin1String(readLine());
- int pos = line.indexOf("//");
+ int pos = line.indexOf(QLatin1String("//"));
if (pos != -1)
line.truncate(pos); // drop comments
- if (line == "};\n") {
+ if (line == QLatin1String("};\n")) {
// end of data
data = new uint[array.count()];
memcpy(data, array.data(), array.count() * sizeof(*data));
@@ -118,7 +119,7 @@
pos = 0;
while ((pos = rx.indexIn(line, pos)) != -1) {
QString num = rx.cap(1);
- if (num.startsWith("0x"))
+ if (num.startsWith(QLatin1String("0x")))
array.append(num.mid(2).toUInt(0, 16));
else
array.append(num.toUInt());
@@ -205,7 +206,7 @@
}
} else {
// octal
- QRegExp octal("([0-7]+)");
+ QRegExp octal(QLatin1String("([0-7]+)"));
if (octal.indexIn(QLatin1String(line), start) == -1)
parseError();
array.append(char(octal.cap(1).toInt(0, 8)));
@@ -218,11 +219,11 @@
parseError();
}
-void MocParser::parse(const char *fname, QIODevice *io, int lineNumber)
+void MocParser::parse(const char *fname, QIODevice *io, int lineNum)
{
filename = fname;
input = io;
- line = lineNumber;
+ lineNumber = lineNum;
while (!input->atEnd()) {
QByteArray line = readLine();
@@ -360,7 +361,7 @@
else {
// run moc on this file
QProcess proc;
- proc.start("moc", QStringList() << QFile::encodeName(argv[i]));
+ proc.start(QLatin1String("moc"), QStringList() << QFile::decodeName(argv[i]));
if (!proc.waitForStarted()) {
fprintf(stderr, PROGRAMNAME ": could not execute moc! Aborting.\n");
Index: dbusidl2cpp.cpp
===================================================================
RCS file: /cvs/dbus/dbus/qt/tools/dbusidl2cpp.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- dbusidl2cpp.cpp 4 Jun 2006 15:52:05 -0000 1.1
+++ dbusidl2cpp.cpp 5 Jun 2006 18:13:07 -0000 1.2
@@ -37,7 +37,7 @@
#include "../src/qdbusintrospection_p.h"
#define PROGRAMNAME "dbusidl2cpp"
-#define PROGRAMVERSION "0.4"
+#define PROGRAMVERSION "0.5"
#define PROGRAMCOPYRIGHT "Copyright (C) 2006 Trolltech AS. All rights reserved."
#define ANNOTATION_NO_WAIT "org.freedesktop.DBus.Method.NoReply"
@@ -68,7 +68,9 @@
" -V Show the program version and quit.\n"
"\n"
"If the file name given to the options -a and -p does not end in .cpp or .h, the\n"
- "program will automatically append the suffixes and produce both files.\n";
+ "program will automatically append the suffixes and produce both files.\n"
+ "You can also use a colon (:) to separate the header name from the source file\n"
+ "name, as in '-a filename_p.h:filename.cpp'.";
static const char includeList[] =
"#include <QtCore/QByteArray>\n"
@@ -154,7 +156,7 @@
static QDBusIntrospection::Interfaces readInput()
{
QFile input(QFile::decodeName(inputFile));
- if (inputFile && QLatin1String("-") != inputFile)
+ if (inputFile && qstrcmp(inputFile, "-") != 0)
input.open(QIODevice::ReadOnly);
else
input.open(stdin, QIODevice::ReadOnly);
@@ -190,9 +192,11 @@
if (!name || (name[0] == '-' && name[1] == '\0'))
return QString();
- QString retval = QFile::decodeName(name);
- if (!retval.endsWith(".h") && !retval.endsWith(".cpp") && !retval.endsWith(".cc"))
- retval.append(".h");
+ QStringList parts = QFile::decodeName(name).split(QLatin1Char(':'));
+ QString retval = parts.first();
+ if (!retval.endsWith(QLatin1String(".h")) && !retval.endsWith(QLatin1String(".cpp")) &&
+ !retval.endsWith(QLatin1String(".cc")))
+ retval.append(QLatin1String(".h"));
return retval;
}
@@ -203,9 +207,11 @@
if (!name || (name[0] == '-' && name[1] == '\0'))
return QString();
- QString retval = QFile::decodeName(name);
- if (!retval.endsWith(".h") && !retval.endsWith(".cpp") && !retval.endsWith(".cc"))
- retval.append(".cpp");
+ QStringList parts = QFile::decodeName(name).split(QLatin1Char(':'));
+ QString retval = parts.last();
+ if (!retval.endsWith(QLatin1String(".h")) && !retval.endsWith(QLatin1String(".cpp")) &&
+ !retval.endsWith(QLatin1String(".cc")))
+ retval.append(QLatin1String(".cpp"));
return retval;
}
@@ -235,7 +241,7 @@
if (globalClassName)
return QLatin1String(globalClassName);
- QStringList parts = interface.split('.');
+ QStringList parts = interface.split(QLatin1Char('.'));
QString retval;
if (classType == Proxy)
@@ -249,9 +255,9 @@
}
if (classType == Proxy)
- retval += "Interface";
+ retval += QLatin1String("Interface");
else
- retval += "Adaptor";
+ retval += QLatin1String("Adaptor");
return retval;
}
@@ -283,7 +289,7 @@
if (!arg.startsWith('Q'))
return QLatin1String(arg + ' ');
else
- return QString("const %1 &").arg( QLatin1String(arg) );
+ return QString( QLatin1String("const %1 &") ).arg( QLatin1String(arg) );
}
static QStringList makeArgNames(const QDBusIntrospection::Arguments &inputArgs,
@@ -295,18 +301,18 @@
const QDBusIntrospection::Argument &arg = inputArgs.at(i);
QString name = arg.name;
if (name.isEmpty())
- name = QString("in%1").arg(i);
+ name = QString( QLatin1String("in%1") ).arg(i);
while (retval.contains(name))
- name += "_";
+ name += QLatin1String("_");
retval << name;
}
for (int i = 0; i < outputArgs.count(); ++i) {
const QDBusIntrospection::Argument &arg = outputArgs.at(i);
QString name = arg.name;
if (name.isEmpty())
- name = QString("out%1").arg(i);
+ name = QString( QLatin1String("out%1") ).arg(i);
while (retval.contains(name))
- name += "_";
+ name += QLatin1String("_");
retval << name;
}
return retval;
@@ -346,7 +352,7 @@
static QString propertyGetter(const QDBusIntrospection::Property &property)
{
- QString getter = property.annotations.value("com.trolltech.QtDBus.propertyGetter");
+ QString getter = property.annotations.value(QLatin1String("com.trolltech.QtDBus.propertyGetter"));
if (getter.isEmpty()) {
getter = property.name;
getter[0] = getter[0].toLower();
@@ -356,9 +362,9 @@
static QString propertySetter(const QDBusIntrospection::Property &property)
{
- QString setter = property.annotations.value("com.trolltech.QtDBus.propertySetter");
+ QString setter = property.annotations.value(QLatin1String("com.trolltech.QtDBus.propertySetter"));
if (setter.isEmpty()) {
- setter = "set" + property.name;
+ setter = QLatin1String("set") + property.name;
setter[3] = setter[3].toUpper();
}
return setter;
@@ -369,21 +375,21 @@
QString retval;
int i;
for (i = 0; i < data.length(); ++i) {
- retval += '\"';
- for ( ; i < data.length() && data[i] != QChar('\n'); ++i)
- if (data[i] == '\"')
- retval += "\\\"";
+ retval += QLatin1Char('\"');
+ for ( ; i < data.length() && data[i] != QLatin1Char('\n'); ++i)
+ if (data[i] == QLatin1Char('\"'))
+ retval += QLatin1String("\\\"");
else
retval += data[i];
- retval += "\\n\"\n";
+ retval += QLatin1String("\\n\"\n");
}
return retval;
}
-static void writeProxy(const char *proxyFile, const QDBusIntrospection::Interfaces &interfaces)
+static void writeProxy(const char *filename, const QDBusIntrospection::Interfaces &interfaces)
{
// open the file
- QString headerName = header(proxyFile);
+ QString headerName = header(filename);
QFile file(headerName);
if (!headerName.isEmpty())
file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text);
@@ -391,7 +397,7 @@
file.open(stdout, QIODevice::WriteOnly | QIODevice::Text);
QTextStream hs(&file);
- QString cppName = cpp(proxyFile);
+ QString cppName = cpp(filename);
QByteArray cppData;
QTextStream cs(&cppData);
@@ -401,14 +407,14 @@
// include guards:
QString includeGuard;
if (!headerName.isEmpty()) {
- includeGuard = headerName.toUpper().replace(QChar('.'), QChar('_'));
- int pos = includeGuard.lastIndexOf('/');
+ includeGuard = headerName.toUpper().replace(QLatin1Char('.'), QLatin1Char('_'));
+ int pos = includeGuard.lastIndexOf(QLatin1Char('/'));
if (pos != -1)
includeGuard = includeGuard.mid(pos + 1);
} else {
- includeGuard = QString("QDBUSIDL2CPP_PROXY");
+ includeGuard = QLatin1String("QDBUSIDL2CPP_PROXY");
}
- includeGuard = QString("%1_%2%3")
+ includeGuard = QString(QLatin1String("%1_%2%3"))
.arg(includeGuard)
.arg(getpid())
.arg(QDateTime::currentDateTime().toTime_t());
@@ -512,7 +518,8 @@
// methods:
hs << "public Q_SLOTS: // METHODS" << endl;
foreach (const QDBusIntrospection::Method &method, interface->methods) {
- bool isAsync = method.annotations.value(ANNOTATION_NO_WAIT) == "true";
+ bool isAsync =
+ method.annotations.value(QLatin1String(ANNOTATION_NO_WAIT)) == QLatin1String("true");
if (isAsync && !method.outputArgs.isEmpty()) {
fprintf(stderr, "warning: method %s in interface %s is marked 'async' but has output arguments.\n",
qPrintable(method.name), qPrintable(interface->name));
@@ -521,7 +528,7 @@
hs << " inline ";
- if (method.annotations.value("org.freedesktop.DBus.Deprecated") == "true")
+ if (method.annotations.value(QLatin1String("org.freedesktop.DBus.Deprecated")) == QLatin1String("true"))
hs << "Q_DECL_DEPRECATED ";
if (isAsync)
@@ -548,7 +555,7 @@
hs << " call(NoWaitForReply, QLatin1String(\"";
// rebuild the method input signature:
- QString signature = QChar('.');
+ QString signature = QLatin1String(".");
foreach (const QDBusIntrospection::Argument &arg, method.inputArgs)
signature += arg.type;
if (signature.length() == 1)
@@ -583,7 +590,8 @@
hs << "Q_SIGNALS: // SIGNALS" << endl;
foreach (const QDBusIntrospection::Signal &signal, interface->signals_) {
hs << " ";
- if (signal.annotations.value("org.freedesktop.DBus.Deprecated") == "true")
+ if (signal.annotations.value(QLatin1String("org.freedesktop.DBus.Deprecated")) ==
+ QLatin1String("true"))
hs << "Q_DECL_DEPRECATED ";
hs << "void " << signal.name << "(";
@@ -607,7 +615,7 @@
QStringList current;
QString name;
if (it != interfaces.constEnd()) {
- current = it->constData()->name.split('.');
+ current = it->constData()->name.split(QLatin1Char('.'));
name = current.takeLast();
}
@@ -618,15 +626,15 @@
// i parts matched
// close last.count() - i namespaces:
for (int j = i; j < last.count(); ++j)
- hs << QString((last.count() - j - 1 + i) * 2, ' ') << "}" << endl;
+ hs << QString((last.count() - j - 1 + i) * 2, QLatin1Char(' ')) << "}" << endl;
// open current.count() - i namespaces
for (int j = i; j < current.count(); ++j)
- hs << QString(j * 2, ' ') << "namespace " << current.at(j) << " {" << endl;
+ hs << QString(j * 2, QLatin1Char(' ')) << "namespace " << current.at(j) << " {" << endl;
// add this class:
if (!name.isEmpty()) {
- hs << QString(current.count() * 2, ' ')
+ hs << QString(current.count() * 2, QLatin1Char(' '))
<< "typedef ::" << classNameForInterface(it->constData()->name, Proxy)
<< " " << name << ";" << endl;
}
@@ -643,7 +651,7 @@
if (includeMocs)
cs << endl
- << "#include \"" << proxyFile << ".moc\"" << endl;
+ << "#include \"" << filename << ".moc\"" << endl;
cs.flush();
hs.flush();
@@ -657,10 +665,10 @@
}
}
-static void writeAdaptor(const char *adaptorFile, const QDBusIntrospection::Interfaces &interfaces)
+static void writeAdaptor(const char *filename, const QDBusIntrospection::Interfaces &interfaces)
{
// open the file
- QString headerName = header(adaptorFile);
+ QString headerName = header(filename);
QFile file(headerName);
if (!headerName.isEmpty())
file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text);
@@ -668,7 +676,7 @@
file.open(stdout, QIODevice::WriteOnly | QIODevice::Text);
QTextStream hs(&file);
- QString cppName = cpp(adaptorFile);
+ QString cppName = cpp(filename);
QByteArray cppData;
QTextStream cs(&cppData);
@@ -678,14 +686,14 @@
// include guards:
QString includeGuard;
if (!headerName.isEmpty()) {
- includeGuard = headerName.toUpper().replace(QChar('.'), QChar('_'));
- int pos = includeGuard.lastIndexOf('/');
+ includeGuard = headerName.toUpper().replace(QLatin1Char('.'), QLatin1Char('_'));
+ int pos = includeGuard.lastIndexOf(QLatin1Char('/'));
if (pos != -1)
includeGuard = includeGuard.mid(pos + 1);
} else {
- includeGuard = QString("QDBUSIDL2CPP_ADAPTOR");
+ includeGuard = QLatin1String("QDBUSIDL2CPP_ADAPTOR");
}
- includeGuard = QString("%1_%2%3")
+ includeGuard = QString(QLatin1String("%1_%2%3"))
.arg(includeGuard)
.arg(getpid())
.arg(QDateTime::currentDateTime().toTime_t());
@@ -794,7 +802,8 @@
hs << "public Q_SLOTS: // METHODS" << endl;
foreach (const QDBusIntrospection::Method &method, interface->methods) {
- bool isAsync = method.annotations.value(ANNOTATION_NO_WAIT) == "true";
+ bool isAsync =
+ method.annotations.value(QLatin1String(ANNOTATION_NO_WAIT)) == QLatin1String("true");
if (isAsync && !method.outputArgs.isEmpty()) {
fprintf(stderr, "warning: method %s in interface %s is marked 'async' but has output arguments.\n",
qPrintable(method.name), qPrintable(interface->name));
@@ -802,7 +811,8 @@
}
hs << " ";
- if (method.annotations.value("org.freedesktop.DBus.Deprecated") == "true")
+ if (method.annotations.value(QLatin1String("org.freedesktop.DBus.Deprecated")) ==
+ QLatin1String("true"))
hs << "Q_DECL_DEPRECATED ";
QByteArray returnType;
@@ -888,7 +898,8 @@
hs << "Q_SIGNALS: // SIGNALS" << endl;
foreach (const QDBusIntrospection::Signal &signal, interface->signals_) {
hs << " ";
- if (signal.annotations.value("org.freedesktop.DBus.Deprecated") == "true")
+ if (signal.annotations.value(QLatin1String("org.freedesktop.DBus.Deprecated")) ==
+ QLatin1String("true"))
hs << "Q_DECL_DEPRECATED ";
hs << "void " << signal.name << "(";
@@ -909,7 +920,7 @@
if (includeMocs)
cs << endl
- << "#include \"" << adaptorFile << ".moc\"" << endl;
+ << "#include \"" << filename << ".moc\"" << endl;
cs.flush();
hs.flush();
@@ -930,7 +941,8 @@
QDBusIntrospection::Interfaces interfaces = readInput();
cleanInterfaces(interfaces);
- writeProxy(proxyFile, interfaces);
+ if (proxyFile || (!proxyFile && !adaptorFile))
+ writeProxy(proxyFile, interfaces);
if (adaptorFile)
writeAdaptor(adaptorFile, interfaces);
- Previous message: dbus/qt/examples Makefile.am, 1.3, 1.4 complexpong.cpp, 1.1,
1.2 dbus.cpp, 1.4, NONE pong.cpp, 1.1, 1.2
- Next message: dbus/qt/src qdbusabstractadaptor.cpp, 1.1,
1.2 qdbusabstractinterface.cpp, 1.1, 1.2 qdbusbus.cpp, 1.1,
1.2 qdbusbus.h, 1.1, 1.2 qdbusconnection.cpp, 1.1,
1.2 qdbusconnection.h, 1.1, 1.2 qdbuserror.cpp, 1.1,
1.2 qdbuserror.h, 1.1, 1.2 qdbusintegrator.cpp, 1.1,
1.2 qdbusinterface.cpp, 1.1, 1.2 qdbusinternalfilters.cpp, 1.1,
1.2 qdbusmessage.cpp, 1.1, 1.2 qdbusmessage.h, 1.1,
1.2 qdbusmetaobject.cpp, 1.1, 1.2 qdbusreply.h, 1.1,
1.2 qdbusserver.cpp, 1.1, 1.2 qdbusutil.cpp, 1.1,
1.2 qdbusxmlgenerator.cpp, 1.1, 1.2 qdbusxmlparser.cpp, 1.1, 1.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dbus-commit
mailing list