summaryrefslogtreecommitdiffstats
path: root/tools/qdbus
diff options
context:
space:
mode:
authorKimmo Kotajärvi <kimmo.kotajarvi@nomovok.com>2010-03-11 12:44:21 (GMT)
committerHarald Fernengel <harald.fernengel@nokia.com>2010-03-11 12:44:21 (GMT)
commit54c7d51c54e4387a070f5f565d01693d078a6d13 (patch)
tree45121891b15989306c1baec3925e73d66da0922e /tools/qdbus
parent18b31adab8ea288edc84c190dcad2c8552d1e206 (diff)
downloadQt-54c7d51c54e4387a070f5f565d01693d078a6d13.zip
Qt-54c7d51c54e4387a070f5f565d01693d078a6d13.tar.gz
Qt-54c7d51c54e4387a070f5f565d01693d078a6d13.tar.bz2
Changed Qdbusviewer to match D-Bus type signature in addition to method name when finding a method.
Merge-request: 435 Reviewed-by: Harald Fernengel <harald.fernengel@nokia.com>
Diffstat (limited to 'tools/qdbus')
-rw-r--r--tools/qdbus/qdbusviewer/qdbusmodel.cpp14
-rw-r--r--tools/qdbus/qdbusviewer/qdbusmodel.h1
-rw-r--r--tools/qdbus/qdbusviewer/qdbusviewer.cpp15
-rw-r--r--tools/qdbus/qdbusviewer/qdbusviewer.h1
4 files changed, 30 insertions, 1 deletions
diff --git a/tools/qdbus/qdbusviewer/qdbusmodel.cpp b/tools/qdbus/qdbusviewer/qdbusmodel.cpp
index befe4b4..f85e288 100644
--- a/tools/qdbus/qdbusviewer/qdbusmodel.cpp
+++ b/tools/qdbus/qdbusviewer/qdbusmodel.cpp
@@ -75,6 +75,7 @@ struct QDBusItem
bool isPrefetched;
QString name;
QString caption;
+ QString typeSignature;
};
QDomDocument QDBusModel::introspect(const QString &path)
@@ -118,6 +119,13 @@ void QDBusModel::addMethods(QDBusItem *parent, const QDomElement &iface)
item = new QDBusItem(QDBusModel::MethodItem,
child.attribute(QLatin1String("name")), parent);
item->caption = QLatin1String("Method: ") + item->name;
+ //get "type" from <arg> where "direction" is "in"
+ QDomElement n = child.firstChildElement();
+ while (!n.isNull()) {
+ if (n.attribute(QLatin1String("direction")) == QLatin1String("in"))
+ item->typeSignature += n.attribute(QLatin1String("type"));
+ n = n.nextSiblingElement();
+ }
} else if (child.tagName() == QLatin1String("signal")) {
item = new QDBusItem(QDBusModel::SignalItem,
child.attribute(QLatin1String("name")), parent);
@@ -298,6 +306,12 @@ QString QDBusModel::dBusMethodName(const QModelIndex &index) const
return item ? item->name : QString();
}
+QString QDBusModel::dBusTypeSignature(const QModelIndex &index) const
+{
+ QDBusItem *item = static_cast<QDBusItem *>(index.internalPointer());
+ return item ? item->typeSignature : QString();
+}
+
QModelIndex QDBusModel::findObject(const QDBusObjectPath &objectPath)
{
QStringList path = objectPath.path().split(QLatin1Char('/'), QString::SkipEmptyParts);
diff --git a/tools/qdbus/qdbusviewer/qdbusmodel.h b/tools/qdbus/qdbusviewer/qdbusmodel.h
index 1a3d8f0..e83c381 100644
--- a/tools/qdbus/qdbusviewer/qdbusmodel.h
+++ b/tools/qdbus/qdbusviewer/qdbusmodel.h
@@ -72,6 +72,7 @@ public:
QString dBusPath(const QModelIndex &index) const;
QString dBusInterface(const QModelIndex &index) const;
QString dBusMethodName(const QModelIndex &index) const;
+ QString dBusTypeSignature(const QModelIndex &index) const;
void refresh(const QModelIndex &index = QModelIndex());
diff --git a/tools/qdbus/qdbusviewer/qdbusviewer.cpp b/tools/qdbus/qdbusviewer/qdbusviewer.cpp
index e9695dc..337fdbc 100644
--- a/tools/qdbus/qdbusviewer/qdbusviewer.cpp
+++ b/tools/qdbus/qdbusviewer/qdbusviewer.cpp
@@ -207,6 +207,17 @@ void QDBusViewer::setProperty(const BusSignature &sig)
}
+static QString getDbusSignature(const QMetaMethod& method)
+{
+ // create a D-Bus type signature from QMetaMethod's parameters
+ QString sig;
+ for (int i = 0; i < method.parameterTypes().count(); ++i) {
+ QVariant::Type type = QVariant::nameToType(method.parameterTypes().at(i));
+ sig.append(QString::fromLatin1(QDBusMetaType::typeToSignature(type)));
+ }
+ return sig;
+}
+
void QDBusViewer::callMethod(const BusSignature &sig)
{
QDBusInterface iface(sig.mService, sig.mPath, sig.mInterface, c);
@@ -217,7 +228,8 @@ void QDBusViewer::callMethod(const BusSignature &sig)
for (int i = 0; i < mo->methodCount(); ++i) {
const QString signature = QString::fromLatin1(mo->method(i).signature());
if (signature.startsWith(sig.mName) && signature.at(sig.mName.length()) == QLatin1Char('('))
- method = mo->method(i);
+ if (getDbusSignature(mo->method(i)) == sig.mTypeSig)
+ method = mo->method(i);
}
if (!method.signature()) {
QMessageBox::warning(this, tr("Unable to find method"),
@@ -277,6 +289,7 @@ void QDBusViewer::showContextMenu(const QPoint &point)
sig.mPath = model->dBusPath(item);
sig.mInterface = model->dBusInterface(item);
sig.mName = model->dBusMethodName(item);
+ sig.mTypeSig = model->dBusTypeSignature(item);
QMenu menu;
menu.addAction(refreshAction);
diff --git a/tools/qdbus/qdbusviewer/qdbusviewer.h b/tools/qdbus/qdbusviewer/qdbusviewer.h
index 207f7a3..c9faab9 100644
--- a/tools/qdbus/qdbusviewer/qdbusviewer.h
+++ b/tools/qdbus/qdbusviewer/qdbusviewer.h
@@ -52,6 +52,7 @@ QT_FORWARD_DECLARE_CLASS(QDomElement);
struct BusSignature
{
QString mService, mPath, mInterface, mName;
+ QString mTypeSig;
};
class QDBusViewer: public QWidget