summaryrefslogtreecommitdiffstats
path: root/tools/qdbus
diff options
context:
space:
mode:
authorCaio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>2009-09-13 07:50:46 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2009-09-13 07:50:46 (GMT)
commit3c99094f117a60ad39aa626af2af8fe6eb5d054f (patch)
tree0554b24e7b39186d5eb1512c712b1d0cb4996202 /tools/qdbus
parent17b946bd348c12decbf16c553805b0d6e97d1378 (diff)
downloadQt-3c99094f117a60ad39aa626af2af8fe6eb5d054f.zip
Qt-3c99094f117a60ad39aa626af2af8fe6eb5d054f.tar.gz
Qt-3c99094f117a60ad39aa626af2af8fe6eb5d054f.tar.bz2
qdbus tool: enable service activation when calling methods
When calling a method of a service, qdbus tool will not check whether the service exists nor if the interface is valid. This allows DBus try to activate the service when we call the method. Merge-request: 1472 Reviewed-by: Thiago Macieira <thiago.macieira@nokia.com>
Diffstat (limited to 'tools/qdbus')
-rw-r--r--tools/qdbus/qdbus/qdbus.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/tools/qdbus/qdbus/qdbus.cpp b/tools/qdbus/qdbus/qdbus.cpp
index ea31d2f..dd29d9f 100644
--- a/tools/qdbus/qdbus/qdbus.cpp
+++ b/tools/qdbus/qdbus/qdbus.cpp
@@ -241,13 +241,9 @@ static void placeCall(const QString &service, const QString &path, const QString
const QString &member, QStringList args)
{
QDBusInterface iface(service, path, interface, connection);
- 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);
- }
+
+ // Don't check whether the interface is valid to allow DBus try to
+ // activate the service if possible.
QVariantList params;
if (!args.isEmpty()) {
@@ -344,7 +340,10 @@ static void placeCall(const QString &service, const QString &path, const QString
QDBusMessage reply = iface.callWithArgumentList(QDBus::Block, member, params);
if (reply.type() == QDBusMessage::ErrorMessage) {
QDBusError err = reply;
- printf("Error: %s\n%s\n", qPrintable(err.name()), qPrintable(err.message()));
+ if (err.type() == QDBusError::ServiceUnknown)
+ fprintf(stderr, "Service '%s' does not exist.\n", qPrintable(service));
+ else
+ 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()));
@@ -438,12 +437,12 @@ int main(int argc, char **argv)
fprintf(stderr, "Service '%s' is not a valid name.\n", qPrintable(service));
exit(1);
}
- if (!bus->isServiceRegistered(service)) {
- fprintf(stderr, "Service '%s' does not exist.\n", qPrintable(service));
- exit(1);
- }
if (args.isEmpty()) {
+ if (!bus->isServiceRegistered(service)) {
+ fprintf(stderr, "Service '%s' does not exist.\n", qPrintable(service));
+ exit(1);
+ }
printf("/\n");
listObjects(service, QString());
exit(0);
@@ -455,6 +454,10 @@ int main(int argc, char **argv)
exit(1);
}
if (args.isEmpty()) {
+ if (!bus->isServiceRegistered(service)) {
+ fprintf(stderr, "Service '%s' does not exist.\n", qPrintable(service));
+ exit(1);
+ }
listAllInterfaces(service, path);
exit(0);
}