Changeset 561 for trunk/src/dbus


Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
1 deleted
60 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/dbus/dbus.pro

    r2 r561  
    1 TARGET          = QtDBus
    2 QPRO_PWD        = $$PWD
    3 QT              = core xml
    4 CONFIG         += link_pkgconfig
    5 DEFINES        += QDBUS_MAKEDLL DBUS_API_SUBJECT_TO_CHANGE
     1TARGET = QtDBus
     2QPRO_PWD = $$PWD
     3QT = core \
     4    xml
     5CONFIG += link_pkgconfig
     6DEFINES += QDBUS_MAKEDLL \
     7    DBUS_API_SUBJECT_TO_CHANGE
    68QMAKE_CXXFLAGS += $$QT_CFLAGS_DBUS
    7 
    8 contains(QT_CONFIG, dbus-linked) {
    9     LIBS       += $$QT_LIBS_DBUS
    10     DEFINES    += QT_LINKED_LIBDBUS
     9contains(QT_CONFIG, dbus-linked) {
     10    LIBS_PRIVATE += $$QT_LIBS_DBUS
     11    DEFINES += QT_LINKED_LIBDBUS
    1112}
    1213
    13 #INCLUDEPATH += .
    14 
    15 unix {
    16    QMAKE_PKGCONFIG_DESCRIPTION = Qt DBus module
    17    QMAKE_PKGCONFIG_REQUIRES = QtCore QtXml
     14# INCLUDEPATH += .
     15unix {
     16    QMAKE_PKGCONFIG_DESCRIPTION = Qt \
     17        DBus \
     18        module
     19    QMAKE_PKGCONFIG_REQUIRES = QtCore \
     20        QtXml
    1821}
    19 
    20 win32 {
    21    LIBS += -lws2_32 -ladvapi32 -lnetapi32 -luser32
    22    CONFIG(debug, debug|release):LIBS += -ldbus-1d
    23    else:LIBS += -ldbus-1
     22win32 {
     23    LIBS_PRIVATE += -lws2_32 \
     24        -ladvapi32 \
     25        -lnetapi32 \
     26        -luser32
     27    CONFIG(debug, debug|release):LIBS_PRIVATE += -ldbus-1d
     28    else:LIBS_PRIVATE += -ldbus-1
    2429}
    25 
    2630include(../qbase.pri)
    27 
    28 PUB_HEADERS =  qdbusargument.h \
    29                qdbusconnectioninterface.h \
    30                qdbusmacros.h \
    31                qdbuserror.h \
    32                qdbusextratypes.h \
    33                qdbusmessage.h \
    34                qdbusserver.h \
    35                qdbusconnection.h \
    36                qdbusabstractinterface.h \
    37                qdbusinterface.h \
    38                qdbusabstractadaptor.h \
    39                qdbusreply.h \
    40                qdbusmetatype.h \
    41                qdbuspendingcall.h \
    42                qdbuspendingreply.h \
    43                qdbuscontext.h
    44 
     31PUB_HEADERS = qdbusargument.h \
     32    qdbusconnectioninterface.h \
     33    qdbusmacros.h \
     34    qdbuserror.h \
     35    qdbusextratypes.h \
     36    qdbusmessage.h \
     37    qdbusserver.h \
     38    qdbusconnection.h \
     39    qdbusabstractinterface.h \
     40    qdbusinterface.h \
     41    qdbusabstractadaptor.h \
     42    qdbusreply.h \
     43    qdbusmetatype.h \
     44    qdbuspendingcall.h \
     45    qdbuspendingreply.h \
     46    qdbuscontext.h
    4547HEADERS += $$PUB_HEADERS \
    46            qdbusconnection_p.h qdbusmessage_p.h \
    47            qdbusinterface_p.h qdbusxmlparser_p.h qdbusabstractadaptor_p.h \
    48            qdbusargument_p.h qdbusutil_p.h qdbusabstractinterface_p.h \
    49            qdbuscontext_p.h qdbusthreaddebug_p.h qdbusintegrator_p.h \
    50            qdbuspendingcall_p.h qdbus_symbols_p.h
    51 
    52 SOURCES += qdbusconnection.cpp  \
    53         qdbusconnectioninterface.cpp \
    54         qdbuserror.cpp          \
    55         qdbusintegrator.cpp     \
    56         qdbusmessage.cpp        \
    57         qdbusserver.cpp         \
    58         qdbusabstractinterface.cpp \
    59         qdbusinterface.cpp      \
    60         qdbusxmlparser.cpp      \
    61         qdbusutil.cpp           \
    62         qdbusintrospection.cpp  \
    63         qdbusabstractadaptor.cpp \
    64         qdbusthread.cpp \
    65         qdbusinternalfilters.cpp \
    66         qdbusmetaobject.cpp     \
    67         qdbusxmlgenerator.cpp   \
    68         qdbusmisc.cpp           \
    69         qdbusargument.cpp       \
    70         qdbusreply.cpp          \
    71         qdbusmetatype.cpp       \
    72         qdbusextratypes.cpp     \
    73         qdbusmarshaller.cpp     \
    74         qdbuscontext.cpp        \
    75         qdbuspendingcall.cpp    \
    76         qdbuspendingreply.cpp   \
    77         qdbus_symbols.cpp
    78 
     48    qdbusconnection_p.h \
     49    qdbusmessage_p.h \
     50    qdbusinterface_p.h \
     51    qdbusxmlparser_p.h \
     52    qdbusabstractadaptor_p.h \
     53    qdbusargument_p.h \
     54    qdbusutil_p.h \
     55    qdbusabstractinterface_p.h \
     56    qdbuscontext_p.h \
     57    qdbusthreaddebug_p.h \
     58    qdbusintegrator_p.h \
     59    qdbuspendingcall_p.h \
     60    qdbus_symbols_p.h \
     61    qdbusservicewatcher.h
     62SOURCES += qdbusconnection.cpp \
     63    qdbusconnectioninterface.cpp \
     64    qdbuserror.cpp \
     65    qdbusintegrator.cpp \
     66    qdbusmessage.cpp \
     67    qdbusserver.cpp \
     68    qdbusabstractinterface.cpp \
     69    qdbusinterface.cpp \
     70    qdbusxmlparser.cpp \
     71    qdbusutil.cpp \
     72    qdbusintrospection.cpp \
     73    qdbusabstractadaptor.cpp \
     74    qdbusinternalfilters.cpp \
     75    qdbusmetaobject.cpp \
     76    qdbusxmlgenerator.cpp \
     77    qdbusmisc.cpp \
     78    qdbusargument.cpp \
     79    qdbusreply.cpp \
     80    qdbusmetatype.cpp \
     81    qdbusextratypes.cpp \
     82    qdbusmarshaller.cpp \
     83    qdbuscontext.cpp \
     84    qdbuspendingcall.cpp \
     85    qdbuspendingreply.cpp \
     86    qdbus_symbols.cpp \
     87    qdbusservicewatcher.cpp
  • trunk/src/dbus/qdbus_symbols.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/dbus/qdbus_symbols_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    354354           (signature, error), return)
    355355DEFINEFUNC(dbus_bool_t     , dbus_type_is_basic, (int            typecode),
    356            (typecode), return);
     356           (typecode), return)
    357357DEFINEFUNC(dbus_bool_t     , dbus_type_is_fixed, (int            typecode),
    358358           (typecode), return)
    359359
     360/* dbus-thread.h */
     361DEFINEFUNC(dbus_bool_t     , dbus_threads_init_default, (), (), return)
     362
    360363QT_END_NAMESPACE
    361364
  • trunk/src/dbus/qdbusabstractadaptor.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    265265void QDBusAdaptorConnector::relaySlot(void **argv)
    266266{
    267     QObjectPrivate *d = static_cast<QObjectPrivate *>(d_ptr);
     267    QObjectPrivate *d = static_cast<QObjectPrivate *>(d_ptr.data());
    268268    relay(d->currentSender->sender, d->currentSender->signal, argv);
    269269}
  • trunk/src/dbus/qdbusabstractadaptor.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/dbus/qdbusabstractadaptor_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/dbus/qdbusabstractinterface.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4545#include "qdbusargument.h"
    4646#include "qdbuspendingcall.h"
     47#include "qdbusmessage_p.h"
    4748#include "qdbusmetaobject_p.h"
    4849#include "qdbusmetatype_p.h"
     
    5253
    5354QT_BEGIN_NAMESPACE
     55
     56static QDBusError checkIfValid(const QString &service, const QString &path,
     57                               const QString &interface, bool isDynamic)
     58{
     59    // We should be throwing exceptions here... oh well
     60    QDBusError error;
     61
     62    // dynamic interfaces (QDBusInterface) can have empty interfaces, but not service and object paths
     63    // non-dynamic is the opposite: service and object paths can be empty, but not the interface
     64    if (!isDynamic) {
     65        // use assertion here because this should never happen, at all
     66        Q_ASSERT_X(!interface.isEmpty(), "QDBusAbstractInterface", "Interface name cannot be empty");
     67    }
     68    if (!QDBusUtil::checkBusName(service, isDynamic ? QDBusUtil::EmptyNotAllowed : QDBusUtil::EmptyAllowed, &error))
     69        return error;
     70    if (!QDBusUtil::checkObjectPath(path, isDynamic ? QDBusUtil::EmptyNotAllowed : QDBusUtil::EmptyAllowed, &error))
     71        return error;
     72    if (!QDBusUtil::checkInterfaceName(interface, QDBusUtil::EmptyAllowed, &error))
     73        return error;
     74
     75    // no error
     76    return QDBusError();
     77}
    5478
    5579QDBusAbstractInterfacePrivate::QDBusAbstractInterfacePrivate(const QString &serv,
     
    5882                                                             const QDBusConnection& con,
    5983                                                             bool isDynamic)
    60     : connection(con), service(serv), path(p), interface(iface), isValid(true)
    61 {
    62     if (isDynamic) {
    63         // QDBusInterface: service and object path can't be empty, but interface can
    64 #if 0
    65         Q_ASSERT_X(QDBusUtil::isValidBusName(service),
    66                    "QDBusInterface::QDBusInterface", "Invalid service name");
    67         Q_ASSERT_X(QDBusUtil::isValidObjectPath(path),
    68                    "QDBusInterface::QDBusInterface", "Invalid object path given");
    69         Q_ASSERT_X(interface.isEmpty() || QDBusUtil::isValidInterfaceName(interface),
    70                    "QDBusInterface::QDBusInterface", "Invalid interface name");
    71 #else
    72         if (!QDBusUtil::isValidBusName(service)) {
    73             lastError = QDBusError(QDBusError::Disconnected,
    74                                    QLatin1String("Invalid service name"));
    75             isValid = false;
    76         } else if (!QDBusUtil::isValidObjectPath(path)) {
    77             lastError = QDBusError(QDBusError::Disconnected,
    78                                    QLatin1String("Invalid object name given"));
    79             isValid = false;
    80         } else if (!interface.isEmpty() && !QDBusUtil::isValidInterfaceName(interface)) {
    81             lastError = QDBusError(QDBusError::Disconnected,
    82                                    QLatin1String("Invalid interface name"));
    83             isValid = false;
    84         }
    85 #endif
    86     } else {
    87         // all others: service and path can be empty here, but interface can't
    88 #if 0
    89         Q_ASSERT_X(service.isEmpty() || QDBusUtil::isValidBusName(service),
    90                    "QDBusAbstractInterface::QDBusAbstractInterface", "Invalid service name");
    91         Q_ASSERT_X(path.isEmpty() || QDBusUtil::isValidObjectPath(path),
    92                    "QDBusAbstractInterface::QDBusAbstractInterface", "Invalid object path given");
    93         Q_ASSERT_X(QDBusUtil::isValidInterfaceName(interface),
    94                    "QDBusAbstractInterface::QDBusAbstractInterface", "Invalid interface class!");
    95 #else
    96         if (!service.isEmpty() && !QDBusUtil::isValidBusName(service)) {
    97             lastError = QDBusError(QDBusError::Disconnected,
    98                                    QLatin1String("Invalid service name"));
    99             isValid = false;
    100         } else if (!path.isEmpty() && !QDBusUtil::isValidObjectPath(path)) {
    101             lastError = QDBusError(QDBusError::Disconnected,
    102                                    QLatin1String("Invalid object path given"));
    103             isValid = false;
    104         } else if (!QDBusUtil::isValidInterfaceName(interface)) {
    105             lastError = QDBusError(QDBusError::Disconnected,
    106                                    QLatin1String("Invalid interface class"));
    107             isValid = false;
    108         }
    109 #endif
    110     }
    111 
     84    : connection(con), service(serv), path(p), interface(iface),
     85      lastError(checkIfValid(serv, p, iface, isDynamic)),
     86      isValid(!lastError.isValid())
     87{
    11288    if (!isValid)
    11389        return;
     
    11692        lastError = QDBusError(QDBusError::Disconnected,
    11793                               QLatin1String("Not connected to D-Bus server"));
    118         isValid = false;
    11994    } else if (!service.isEmpty()) {
    12095        currentOwner = connectionPrivate()->getNameOwner(service); // verify the name owner
    12196        if (currentOwner.isEmpty()) {
    122             isValid = false;
    12397            lastError = connectionPrivate()->lastError;
    12498        }
     
    126100}
    127101
    128 QVariant QDBusAbstractInterfacePrivate::property(const QMetaProperty &mp) const
    129 {
    130     if (!connection.isConnected())    // not connected
    131         return QVariant();
     102bool QDBusAbstractInterfacePrivate::canMakeCalls() const
     103{
     104    // recheck only if we have a wildcard (i.e. empty) service or path
     105    // if any are empty, set the error message according to QDBusUtil
     106    if (service.isEmpty())
     107        return QDBusUtil::checkBusName(service, QDBusUtil::EmptyNotAllowed, &lastError);
     108    if (path.isEmpty())
     109        return QDBusUtil::checkObjectPath(path, QDBusUtil::EmptyNotAllowed, &lastError);
     110    return true;
     111}
     112
     113void QDBusAbstractInterfacePrivate::property(const QMetaProperty &mp, QVariant &where) const
     114{
     115    if (!isValid || !canMakeCalls()) {   // can't make calls
     116        where.clear();
     117        return;
     118    }
    132119
    133120    // is this metatype registered?
    134     int mid;
    135     const char *expectedSignature;
    136     if (mp.type() == QVariant::LastType) {
    137         // We're asking to read a QVariant
    138         mid = qMetaTypeId<QDBusVariant>();
    139         expectedSignature = "v";
    140     } else {
    141         mid = QMetaType::type(mp.typeName());
    142         expectedSignature = QDBusMetaType::typeToSignature(mid);
     121    const char *expectedSignature = "";
     122    if (mp.type() != 0xff) {
     123        expectedSignature = QDBusMetaType::typeToSignature(where.userType());
    143124        if (expectedSignature == 0) {
    144125            qWarning("QDBusAbstractInterface: type %s must be registered with QtDBus before it can be "
    145126                     "used to read property %s.%s",
    146127                     mp.typeName(), qPrintable(interface), mp.name());
    147             return QVariant();
     128            lastError = QDBusError(QDBusError::Failed,
     129                                   QString::fromLatin1("Unregistered type %1 cannot be handled")
     130                                   .arg(QLatin1String(mp.typeName())));
     131            where.clear();
     132            return;
    148133        }
    149134    }
     
    153138                                                      QLatin1String(DBUS_INTERFACE_PROPERTIES),
    154139                                                      QLatin1String("Get"));
     140    QDBusMessagePrivate::setParametersValidated(msg, true);
    155141    msg << interface << QString::fromUtf8(mp.name());
    156142    QDBusMessage reply = connection.call(msg, QDBus::Block);
     
    158144    if (reply.type() != QDBusMessage::ReplyMessage) {
    159145        lastError = reply;
    160         return QVariant();
     146        where.clear();
     147        return;
    161148    }
    162149    if (reply.signature() != QLatin1String("v")) {
     
    164151                                       DBUS_INTERFACE_PROPERTIES);
    165152        lastError = QDBusError(QDBusError::InvalidSignature, errmsg.arg(reply.signature()));
    166         return QVariant();
     153        where.clear();
     154        return;
    167155    }
    168156
     
    171159    QVariant value = qvariant_cast<QDBusVariant>(reply.arguments().at(0)).variant();
    172160
    173     if (value.userType() == mid)
    174         return value;       // simple match
     161    if (value.userType() == where.userType() || mp.type() == 0xff
     162        || (expectedSignature[0] == 'v' && expectedSignature[1] == '\0')) {
     163        // simple match
     164        where = value;
     165        return;
     166    }
    175167
    176168    if (value.userType() == qMetaTypeId<QDBusArgument>()) {
     
    180172        foundSignature = arg.currentSignature().toLatin1();
    181173        if (foundSignature == expectedSignature) {
    182             void *null = 0;
    183             QVariant result(mid, null);
    184             QDBusMetaType::demarshall(arg, mid, result.data());
    185 
    186             if (mp.type() == QVariant::LastType)
    187                 // special case: QVariant
    188                 return qvariant_cast<QDBusVariant>(result).variant();
    189             return result;
     174            // signatures match, we can demarshall
     175            QDBusMetaType::demarshall(arg, where.userType(), where.data());
     176            return;
    190177        }
    191178    } else {
     
    204191                                      QString::fromLatin1(mp.typeName()),
    205192                                      QString::fromLatin1(expectedSignature)));
    206     return QVariant();
    207 }
    208 
    209 void QDBusAbstractInterfacePrivate::setProperty(const QMetaProperty &mp, const QVariant &value)
    210 {
    211     if (!connection.isConnected())    // not connected
    212         return;
     193    where.clear();
     194    return;
     195}
     196
     197bool QDBusAbstractInterfacePrivate::setProperty(const QMetaProperty &mp, const QVariant &value)
     198{
     199    if (!isValid || !canMakeCalls())    // can't make calls
     200        return false;
    213201
    214202    // send the value
     
    216204                                                QLatin1String(DBUS_INTERFACE_PROPERTIES),
    217205                                                QLatin1String("Set"));
     206    QDBusMessagePrivate::setParametersValidated(msg, true);
    218207    msg << interface << QString::fromUtf8(mp.name()) << qVariantFromValue(QDBusVariant(value));
    219208    QDBusMessage reply = connection.call(msg, QDBus::Block);
    220209
    221     if (reply.type() != QDBusMessage::ReplyMessage)
     210    if (reply.type() != QDBusMessage::ReplyMessage) {
    222211        lastError = reply;
     212        return false;
     213    }
     214    return true;
    223215}
    224216
     
    231223    if (name == service) {
    232224        currentOwner = newOwner;
    233         isValid = !newOwner.isEmpty();
    234     }
    235 }
    236 
     225    }
     226}
     227
     228QDBusAbstractInterfaceBase::QDBusAbstractInterfaceBase(QDBusAbstractInterfacePrivate &d, QObject *parent)
     229    : QObject(d, parent)
     230{
     231}
     232
     233int QDBusAbstractInterfaceBase::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
     234{
     235    int saved_id = _id;
     236    _id = QObject::qt_metacall(_c, _id, _a);
     237    if (_id < 0)
     238        return _id;
     239
     240    if (_c == QMetaObject::ReadProperty || _c == QMetaObject::WriteProperty) {
     241        QMetaProperty mp = metaObject()->property(saved_id);
     242        int &status = *reinterpret_cast<int *>(_a[2]);
     243        QVariant &variant = *reinterpret_cast<QVariant *>(_a[1]);
     244
     245        if (_c == QMetaObject::WriteProperty) {
     246            status = d_func()->setProperty(mp, variant) ? 1 : 0;
     247        } else {
     248            d_func()->property(mp, variant);
     249            status = variant.isValid() ? 1 : 0;
     250        }
     251        _id = -1;
     252    }
     253    return _id;
     254}
    237255
    238256/*!
     
    259277*/
    260278QDBusAbstractInterface::QDBusAbstractInterface(QDBusAbstractInterfacePrivate &d, QObject *parent)
    261     : QObject(d, parent)
     279    : QDBusAbstractInterfaceBase(d, parent)
    262280{
    263281    // keep track of the service owner
    264     if (d_func()->isValid)
    265         QObject::connect(d_func()->connectionPrivate(), SIGNAL(serviceOwnerChanged(QString,QString,QString)),
    266                          this, SLOT(_q_serviceOwnerChanged(QString,QString,QString)));
     282    if (d.isValid &&
     283        d.connection.isConnected()
     284        && !d.service.isEmpty()
     285        && !d.service.startsWith(QLatin1Char(':')))
     286        d_func()->connection.connect(QLatin1String(DBUS_SERVICE_DBUS), // service
     287                                     QString(), // path
     288                                     QLatin1String(DBUS_INTERFACE_DBUS), // interface
     289                                     QLatin1String("NameOwnerChanged"),
     290                                     QStringList() << d.service,
     291                                     QString(), // signature
     292                                     this, SLOT(_q_serviceOwnerChanged(QString,QString,QString)));
    267293}
    268294
     
    275301                                               const char *interface, const QDBusConnection &con,
    276302                                               QObject *parent)
    277     : QObject(*new QDBusAbstractInterfacePrivate(service, path, QString::fromLatin1(interface),
     303    : QDBusAbstractInterfaceBase(*new QDBusAbstractInterfacePrivate(service, path, QString::fromLatin1(interface),
    278304                                                 con, false), parent)
    279305{
    280306    // keep track of the service owner
    281     if (d_func()->connection.isConnected())
    282         QObject::connect(d_func()->connectionPrivate(), SIGNAL(serviceOwnerChanged(QString,QString,QString)),
    283                          this, SLOT(_q_serviceOwnerChanged(QString,QString,QString)));
     307    if (d_func()->isValid &&
     308        d_func()->connection.isConnected()
     309        && !service.isEmpty()
     310        && !service.startsWith(QLatin1Char(':')))
     311        d_func()->connection.connect(QLatin1String(DBUS_SERVICE_DBUS), // service
     312                                     QString(), // path
     313                                     QLatin1String(DBUS_INTERFACE_DBUS), // interface
     314                                     QLatin1String("NameOwnerChanged"),
     315                                     QStringList() << service,
     316                                     QString(), //signature
     317                                     this, SLOT(_q_serviceOwnerChanged(QString,QString,QString)));
    284318}
    285319
     
    301335bool QDBusAbstractInterface::isValid() const
    302336{
    303     return d_func()->isValid;
     337    return !d_func()->currentOwner.isEmpty();
    304338}
    305339
     
    367401{
    368402    Q_D(QDBusAbstractInterface);
     403
     404    if (!d->isValid || !d->canMakeCalls())
     405        return QDBusMessage::createError(d->lastError);
    369406
    370407    QString m = method;
     
    398435//    qDebug() << "QDBusAbstractInterface" << "Service" << service() << "Path:" << path();
    399436    QDBusMessage msg = QDBusMessage::createMethodCall(service(), path(), interface(), m);
     437    QDBusMessagePrivate::setParametersValidated(msg, true);
    400438    msg.setArguments(args);
    401439
     
    426464    Q_D(QDBusAbstractInterface);
    427465
     466    if (!d->isValid || !d->canMakeCalls())
     467        return QDBusPendingCall::fromError(d->lastError);
     468
    428469    QDBusMessage msg = QDBusMessage::createMethodCall(service(), path(), interface(), method);
     470    QDBusMessagePrivate::setParametersValidated(msg, true);
    429471    msg.setArguments(args);
    430472    return d->connection.asyncCall(msg);
     
    441483    This function returns true if the queueing succeeds. It does
    442484    not indicate that the executed call succeeded. If it fails,
    443     the \a errorMethod is called.
     485    the \a errorMethod is called. If the queueing failed, this
     486    function returns false and no slot will be called.
    444487 
    445488    The \a returnMethod must have as its parameters the types returned
     
    454497                                              const QList<QVariant> &args,
    455498                                              QObject *receiver,
    456                                               const char *returnMethod,
     499                                              const char *returnMethod,
    457500                                              const char *errorMethod)
    458501{
    459502    Q_D(QDBusAbstractInterface);
    460503
     504    if (!d->isValid || !d->canMakeCalls())
     505        return false;
     506
    461507    QDBusMessage msg = QDBusMessage::createMethodCall(service(),
    462                                                       path(),
    463                                                       interface(),
    464                                                       method);
     508                                                      path(),
     509                                                      interface(),
     510                                                      method);
     511    QDBusMessagePrivate::setParametersValidated(msg, true);
    465512    msg.setArguments(args);
    466513
    467514    d->lastError = 0;
    468515    return d->connection.callWithCallback(msg,
    469                                           receiver,
    470                                           returnMethod,
    471                                           errorMethod);
     516                                          receiver,
     517                                          returnMethod,
     518                                          errorMethod);
    472519}
    473520
     
    493540                                              const QList<QVariant> &args,
    494541                                              QObject *receiver,
    495                                               const char *slot)
     542                                              const char *slot)
    496543{
    497544    return callWithCallback(method, args, receiver, slot, 0);
     
    504551void QDBusAbstractInterface::connectNotify(const char *signal)
    505552{
     553    // someone connecting to one of our signals
     554    Q_D(QDBusAbstractInterface);
     555    if (!d->isValid)
     556        return;
     557
    506558    // we end up recursing here, so optimise away
    507559    if (qstrcmp(signal + 1, "destroyed(QObject*)") == 0)
    508560        return;
    509561
    510     // someone connecting to one of our signals
     562    QDBusConnectionPrivate *conn = d->connectionPrivate();
     563    if (conn) {
     564        conn->connectRelay(d->service, d->path, d->interface,
     565                           this, signal);
     566    }
     567}
     568
     569/*!
     570    \internal
     571    Catch signal disconnections.
     572*/
     573void QDBusAbstractInterface::disconnectNotify(const char *signal)
     574{
     575    // someone disconnecting from one of our signals
    511576    Q_D(QDBusAbstractInterface);
     577    if (!d->isValid)
     578        return;
    512579
    513580    QDBusConnectionPrivate *conn = d->connectionPrivate();
    514581    if (conn)
    515         conn->connectRelay(d->service, d->currentOwner, d->path, d->interface,
    516                            this, signal);
    517 }
    518 
    519 /*!
    520     \internal
    521     Catch signal disconnections.
    522 */
    523 void QDBusAbstractInterface::disconnectNotify(const char *signal)
    524 {
    525     // someone disconnecting from one of our signals
    526     Q_D(QDBusAbstractInterface);
    527 
    528     QDBusConnectionPrivate *conn = d->connectionPrivate();
    529     if (conn)
    530         conn->disconnectRelay(d->service, d->currentOwner, d->path, d->interface,
     582        conn->disconnectRelay(d->service, d->path, d->interface,
    531583                              this, signal);
    532584}
     
    541593    // we're only called from generated code anyways
    542594
    543     int idx = metaObject()->indexOfProperty(propname);
    544     if (idx != -1)
    545         return d_func()->property(metaObject()->property(idx));
    546     qWarning("QDBusAbstractInterface::internalPropGet called with unknown property '%s'", propname);
    547     return QVariant();          // error
     595    return property(propname);
    548596}
    549597
     
    554602void QDBusAbstractInterface::internalPropSet(const char *propname, const QVariant &value)
    555603{
    556     Q_D(QDBusAbstractInterface);
    557 
    558     // assume this property exists and is writeable
    559     // we're only called from generated code anyways
    560 
    561     int idx = metaObject()->indexOfProperty(propname);
    562     if (idx != -1)
    563         d->setProperty(metaObject()->property(idx), value);
    564     else
    565         qWarning("QDBusAbstractInterface::internalPropGet called with unknown property '%s'", propname);
     604    setProperty(propname, value);
    566605}
    567606
  • trunk/src/dbus/qdbusabstractinterface.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    6262
    6363class QDBusAbstractInterfacePrivate;
    64 class QDBUS_EXPORT QDBusAbstractInterface: public QObject
     64
     65class QDBUS_EXPORT QDBusAbstractInterfaceBase: public QObject
     66{
     67public:
     68    int qt_metacall(QMetaObject::Call, int, void**);
     69protected:
     70    QDBusAbstractInterfaceBase(QDBusAbstractInterfacePrivate &dd, QObject *parent);
     71private:
     72    Q_DECLARE_PRIVATE(QDBusAbstractInterface)
     73};
     74
     75class QDBUS_EXPORT QDBusAbstractInterface:
     76#ifdef Q_QDOC
     77        public QObject
     78#else
     79        public QDBusAbstractInterfaceBase
     80#endif
    6581{
    6682    Q_OBJECT
  • trunk/src/dbus/qdbusabstractinterface_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    7676    QString interface;
    7777    mutable QDBusError lastError;
     78
     79    // this is set during creation and never changed
     80    // it can't be const because QDBusInterfacePrivate has one more check
    7881    bool isValid;
    7982
     
    8184                                  const QString &iface, const QDBusConnection& con, bool dynamic);
    8285    virtual ~QDBusAbstractInterfacePrivate() { }
     86    bool canMakeCalls() const;
    8387
    8488    // these functions do not check if the property is valid
    85     QVariant property(const QMetaProperty &mp) const;
    86     void setProperty(const QMetaProperty &mp, const QVariant &value);
     89    void property(const QMetaProperty &mp, QVariant &where) const;
     90    bool setProperty(const QMetaProperty &mp, const QVariant &value);
    8791
    8892    // return conn's d pointer
  • trunk/src/dbus/qdbusargument.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/dbus/qdbusargument.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/dbus/qdbusargument_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5555
    5656#include <qdbusargument.h>
    57 #include <qdbus_symbols_p.h>
     57#include "qdbus_symbols_p.h"
    5858
    5959QT_BEGIN_NAMESPACE
     
    131131    void open(QDBusMarshaller &sub, int code, const char *signature);
    132132    void close();
    133     void error();
     133    void error(const QString &message);
    134134
    135135    bool appendVariantInternal(const QVariant &arg);
     
    141141    QDBusMarshaller *parent;
    142142    QByteArray *ba;
     143    QString errorString;
    143144    char closeCode;
    144145    bool ok;
  • trunk/src/dbus/qdbusconnection.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    558558                              const QString &name, QObject *receiver, const char *slot)
    559559{
    560     return connect(service, path, interface, name, QString(), receiver, slot);
    561 }
    562 
    563 /*!
    564     Disconnects the signal specified by the \a service, \a path, \a interface and \a name parameters from
    565     the slot \a slot in object \a receiver. The arguments \a service and \a path can be empty,
    566     denoting a disconnection from all signals of the (\a interface, \a name) pair, from all remote
    567     applications.
    568 
    569     Returns true if the disconnection was successful.
    570 */
    571 bool QDBusConnection::disconnect(const QString &service, const QString &path, const QString &interface,
    572                                  const QString &name, QObject *receiver, const char *slot)
    573 {
    574     return disconnect(service, path, interface, name, QString(), receiver, slot);
     560    return connect(service, path, interface, name, QStringList(), QString(), receiver, slot);
    575561}
    576562
     
    579565
    580566    Connects the signal to the slot \a slot in object \a
    581     receiver. Unlike the other connect() overload, this function
     567    receiver. Unlike the previous connect() overload, this function
    582568    allows one to specify the parameter signature to be connected
    583569    using the \a signature variable. The function will then verify
     
    585571    slot and return false otherwise.
    586572
     573    Returns true if the connection was successful.
     574
    587575    \note This function verifies that the signal signature matches the
    588576          slot's parameters, but it does not verify that the actual
     
    594582                              QObject *receiver, const char *slot)
    595583{
     584    return connect(service, path, interface, name, QStringList(), signature, receiver, slot);
     585}
     586
     587/*!
     588    \overload
     589    \since 4.6
     590
     591    Connects the signal to the slot \a slot in object \a
     592    receiver. Unlike the previous connect() overload, this function
     593    allows one to specify the parameter signature to be connected
     594    using the \a signature variable. The function will then verify
     595    that this signature can be delivered to the slot specified by \a
     596    slot and return false otherwise.
     597
     598    The \a argumentMatch parameter lists the string parameters to be matched,
     599    in sequential order. Note that, to match an empty string, you need to
     600    pass a QString that is empty but not null (i.e., QString("")). A null
     601    QString skips matching at that position.
     602
     603    Returns true if the connection was successful.
     604
     605    \note This function verifies that the signal signature matches the
     606          slot's parameters, but it does not verify that the actual
     607          signal exists with the given signature in the remote
     608          service.
     609*/
     610bool QDBusConnection::connect(const QString &service, const QString &path, const QString& interface,
     611                              const QString &name, const QStringList &argumentMatch, const QString &signature,
     612                              QObject *receiver, const char *slot)
     613{
     614
    596615    if (!receiver || !slot || !d || !d->connection)
    597616        return false;
     
    601620        return false;
    602621
    603     // check the slot
    604     QDBusConnectionPrivate::SignalHook hook;
    605     QString key;
    606     QString name2 = name;
    607     if (name2.isNull())
    608         name2.detach();
    609 
    610     QString owner = d->getNameOwner(service); // we don't care if the owner is empty
    611     hook.signature = signature;               // it might get started later
    612     if (!d->prepareHook(hook, key, service, owner, path, interface, name, receiver, slot, 0, false))
    613         return false;           // don't connect
    614 
    615     // avoid duplicating:
    616622    QDBusWriteLocker locker(ConnectAction, d);
    617     QDBusConnectionPrivate::SignalHookHash::ConstIterator it = d->signalHooks.find(key);
    618     QDBusConnectionPrivate::SignalHookHash::ConstIterator end = d->signalHooks.constEnd();
    619     for ( ; it != end && it.key() == key; ++it) {
    620         const QDBusConnectionPrivate::SignalHook &entry = it.value();
    621         if (entry.service == hook.service &&
    622             entry.owner == hook.owner &&
    623             entry.path == hook.path &&
    624             entry.signature == hook.signature &&
    625             entry.obj == hook.obj &&
    626             entry.midx == hook.midx) {
    627             // no need to compare the parameters if it's the same slot
    628             return true;        // already there
    629         }
    630     }
    631 
    632     d->connectSignal(key, hook);
    633     return true;
     623    return d->connectSignal(service, path, interface, name, argumentMatch, signature, receiver, slot);
     624}
     625
     626/*!
     627    Disconnects the signal specified by the \a service, \a path, \a interface
     628    and \a name parameters from the slot \a slot in object \a receiver. The
     629    arguments must be the same as passed to the connect() function.
     630
     631    Returns true if the disconnection was successful.
     632*/
     633bool QDBusConnection::disconnect(const QString &service, const QString &path, const QString &interface,
     634                                 const QString &name, QObject *receiver, const char *slot)
     635{
     636    return disconnect(service, path, interface, name, QStringList(), QString(), receiver, slot);
    634637}
    635638
     
    637640    \overload
    638641
    639     Disconnects the signal from the slot \a slot in object \a
    640     receiver. Unlike the other disconnect() overload, this function
    641     allows one to specify the parameter signature to be disconnected
    642     using the \a signature variable. The function will then verify
    643     that this signature is connected to the slot specified by \a slot
    644     and return false otherwise.
     642    Disconnects the signal specified by the \a service, \a path, \a
     643    interface, \a name, and \a signature parameters from the slot \a slot in
     644    object \a receiver. The arguments must be the same as passed to the
     645    connect() function.
     646
     647    Returns true if the disconnection was successful.
    645648*/
    646649bool QDBusConnection::disconnect(const QString &service, const QString &path, const QString& interface,
    647650                                 const QString &name, const QString &signature,
     651                                 QObject *receiver, const char *slot)
     652{
     653    return disconnect(service, path, interface, name, QStringList(), signature, receiver, slot);
     654}
     655
     656/*!
     657    \overload
     658    \since 4.6
     659
     660    Disconnects the signal specified by the \a service, \a path, \a
     661    interface, \a name, \a argumentMatch, and \a signature parameters from
     662    the slot \a slot in object \a receiver. The arguments must be the same as
     663    passed to the connect() function.
     664
     665    Returns true if the disconnection was successful.
     666*/
     667bool QDBusConnection::disconnect(const QString &service, const QString &path, const QString& interface,
     668                                 const QString &name, const QStringList &argumentMatch, const QString &signature,
    648669                                 QObject *receiver, const char *slot)
    649670{
     
    655676        return false;
    656677
    657     // check the slot
    658     QDBusConnectionPrivate::SignalHook hook;
    659     QString key;
    660     QString name2 = name;
    661     if (name2.isNull())
    662         name2.detach();
    663 
    664     QString owner = d->getNameOwner(service); // we don't care of owner is empty
    665     hook.signature = signature;
    666     if (!d->prepareHook(hook, key, service, owner, path, interface, name, receiver, slot, 0, false))
    667         return false;           // don't disconnect
    668 
    669     // avoid duplicating:
    670678    QDBusWriteLocker locker(DisconnectAction, d);
    671     QDBusConnectionPrivate::SignalHookHash::Iterator it = d->signalHooks.find(key);
    672     QDBusConnectionPrivate::SignalHookHash::Iterator end = d->signalHooks.end();
    673     for ( ; it != end && it.key() == key; ++it) {
    674         const QDBusConnectionPrivate::SignalHook &entry = it.value();
    675         if (entry.service == hook.service &&
    676             entry.owner == hook.owner &&
    677             entry.path == hook.path &&
    678             entry.signature == hook.signature &&
    679             entry.obj == hook.obj &&
    680             entry.midx == hook.midx) {
    681             // no need to compare the parameters if it's the same slot
    682             d->disconnectSignal(it);
    683             return true;        // it was there
    684         }
    685     }
    686 
    687     // the slot was not found
    688     return false;
     679    return d->disconnectSignal(service, path, interface, name, argumentMatch, signature, receiver, slot);
    689680}
    690681
     
    974965
    975966/*!
     967  \nonreentrant
     968
    976969  Returns the connection that sent the signal, if called in a slot activated
    977970  by QDBus; otherwise it returns 0.
     971
     972  \note Please avoid this function. This function is not thread-safe, so if
     973  there's any other thread delivering a D-Bus call, this function may return
     974  the wrong connection. In new code, please use QDBusContext::connection()
     975  (see that class for a description on how to use it).
    978976*/
    979977QDBusConnection QDBusConnection::sender()
     
    10061004    ref.deref(); // busService has increased the refcounting to us
    10071005                 // avoid cyclic refcounting
    1008 //    if (mode != PeerMode)
    1009     QObject::connect(busService, SIGNAL(serviceOwnerChanged(QString,QString,QString)),
    1010                      this, SIGNAL(serviceOwnerChanged(QString,QString,QString)));
    10111006
    10121007    QObject::connect(this, SIGNAL(callWithCallbackFailed(QDBusError,QDBusMessage)),
    10131008                     busService, SIGNAL(callWithCallbackFailed(QDBusError,QDBusMessage)),
    10141009                     Qt::QueuedConnection);
    1015 
    10161010}
    10171011
  • trunk/src/dbus/qdbusconnection.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    133133    bool connect(const QString &service, const QString &path, const QString &interface,
    134134                 const QString &name, QObject *receiver, const char *slot);
    135     bool disconnect(const QString &service, const QString &path, const QString &interface,
    136                     const QString &name, QObject *receiver, const char *slot);
    137 
    138135    bool connect(const QString &service, const QString &path, const QString &interface,
    139136                 const QString &name, const QString& signature,
    140137                 QObject *receiver, const char *slot);
     138    bool connect(const QString &service, const QString &path, const QString &interface,
     139                 const QString &name, const QStringList &argumentMatch, const QString& signature,
     140                 QObject *receiver, const char *slot);
     141
     142    bool disconnect(const QString &service, const QString &path, const QString &interface,
     143                    const QString &name, QObject *receiver, const char *slot);
    141144    bool disconnect(const QString &service, const QString &path, const QString &interface,
    142145                    const QString &name, const QString& signature,
     146                    QObject *receiver, const char *slot);
     147    bool disconnect(const QString &service, const QString &path, const QString &interface,
     148                    const QString &name, const QStringList &argumentMatch, const QString& signature,
    143149                    QObject *receiver, const char *slot);
    144150
  • trunk/src/dbus/qdbusconnection_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    6868#include <QtCore/qvector.h>
    6969
    70 #include <qdbus_symbols_p.h>
     70#include "qdbus_symbols_p.h"
    7171
    7272#include <qdbusmessage.h>
     
    120120    {
    121121        inline SignalHook() : obj(0), midx(-1) { }
    122         QString owner, service, path, signature;
     122        QString service, path, signature;
    123123        QObject* obj;
    124124        int midx;
    125125        QList<int> params;
     126        QStringList argumentMatch;
    126127        QByteArray matchRule;
    127128    };
     
    156157    typedef QHash<QByteArray, int> MatchRefCountHash;
    157158
     159    struct WatchedServiceData {
     160        WatchedServiceData() : refcount(0) {}
     161        QString owner;
     162        int refcount;
     163    };
     164    typedef QHash<QString, WatchedServiceData> WatchedServicesHash;
     165
    158166public:
    159167    // public methods are entry points from other objects
     
    176184    int sendWithReplyAsync(const QDBusMessage &message, QObject *receiver,
    177185                           const char *returnMethod, const char *errorMethod, int timeout = -1);
     186    bool connectSignal(const QString &service, const QString &path, const QString& interface,
     187                       const QString &name, const QStringList &argumentMatch, const QString &signature,
     188                       QObject *receiver, const char *slot);
    178189    void connectSignal(const QString &key, const SignalHook &hook);
    179190    SignalHookHash::Iterator disconnectSignal(SignalHookHash::Iterator &it);
     191    bool disconnectSignal(const QString &service, const QString &path, const QString& interface,
     192                          const QString &name, const QStringList &argumentMatch, const QString &signature,
     193                          QObject *receiver, const char *slot);
    180194    void registerObject(const ObjectTreeNode *node);
    181     void connectRelay(const QString &service, const QString &currentOwner,
     195    void connectRelay(const QString &service,
    182196                      const QString &path, const QString &interface,
    183197                      QDBusAbstractInterface *receiver, const char *signal);
    184     void disconnectRelay(const QString &service, const QString &currentOwner,
     198    void disconnectRelay(const QString &service,
    185199                         const QString &path, const QString &interface,
    186200                         QDBusAbstractInterface *receiver, const char *signal);
     
    191205    QDBusMetaObject *findMetaObject(const QString &service, const QString &path,
    192206                                    const QString &interface, QDBusError &error);
    193 
    194     void registerService(const QString &serviceName);
    195     void unregisterService(const QString &serviceName);
    196207
    197208    void postEventToThread(int action, QObject *target, QEvent *event);
     
    218229
    219230    bool isServiceRegisteredByThread(const QString &serviceName) const;
     231
     232    QString getNameOwnerNoCache(const QString &service);
    220233
    221234protected:
     
    231244    void relaySignal(QObject *obj, const QMetaObject *, int signalId, const QVariantList &args);
    232245    void _q_serviceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner);
     246    void registerService(const QString &serviceName);
     247    void unregisterService(const QString &serviceName);
    233248
    234249signals:
     
    265280
    266281    QStringList serviceNames;
     282    WatchedServicesHash watchedServices;
    267283    SignalHookHash signalHooks;
    268284    MatchRefCountHash matchRefCounts;
     
    277293    static int findSlot(QObject *obj, const QByteArray &normalizedName, QList<int>& params);
    278294    static bool prepareHook(QDBusConnectionPrivate::SignalHook &hook, QString &key,
    279                             const QString &service, const QString &owner,
     295                            const QString &service,
    280296                            const QString &path, const QString &interface, const QString &name,
     297                            const QStringList &argMatch,
    281298                            QObject *receiver, const char *signal, int minMIdx,
    282299                            bool buildSignature);
     
    301318extern int qDBusNameToTypeId(const char *name);
    302319extern bool qDBusCheckAsyncTag(const char *tag);
     320extern bool qDBusInterfaceInObject(QObject *obj, const QString &interface_name);
     321extern QString qDBusInterfaceFromMetaObject(const QMetaObject *mo);
    303322
    304323// in qdbusinternalfilters.cpp
     
    311330                                        const QDBusMessage &msg);
    312331
    313 // in qdbusxmlgenerator.cpp
    314 extern QString qDBusInterfaceFromMetaObject(const QMetaObject *mo);
    315 
    316332QT_END_NAMESPACE
    317333
  • trunk/src/dbus/qdbusconnectioninterface.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5050#include <QtCore/QDebug>
    5151
    52 #include <qdbus_symbols_p.h>          // for the DBUS_* constants
     52#include "qdbus_symbols_p.h"          // for the DBUS_* constants
    5353
    5454QT_BEGIN_NAMESPACE
     
    337337        QDBusAbstractInterface::connectNotify(SIGNAL(NameLost(QString)));
    338338
    339     else if (qstrcmp(signalName, SIGNAL(serviceOwnerChanged(QString,QString,QString))) == 0)
     339    else if (qstrcmp(signalName, SIGNAL(serviceOwnerChanged(QString,QString,QString))) == 0) {
     340        static bool warningPrinted = false;
     341        if (!warningPrinted) {
     342            qWarning("Connecting to deprecated signal QDBusConnectionInterface::serviceOwnerChanged(QString,QString,QString)");
     343            warningPrinted = true;
     344        }
    340345        QDBusAbstractInterface::connectNotify(SIGNAL(NameOwnerChanged(QString,QString,QString)));
     346    }
    341347}
    342348
     
    389395    \a newOwner is empty, the name \a name has no current owner and is
    390396    no longer available.
     397
     398    \note connecting to this signal will make the application listen for and
     399    receive every single service ownership change on the bus. Depending on
     400    how many services are running, this make the application be activated to
     401    receive more signals than it needs. To avoid this problem, use the
     402    QDBusServiceWatcher class, which can listen for specific changes.
    391403*/
    392404
  • trunk/src/dbus/qdbusconnectioninterface.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/dbus/qdbuscontext.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/dbus/qdbuscontext.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    7575private:
    7676    QDBusContextPrivate *d_ptr;
    77     Q_DECLARE_PRIVATE(QDBusContext)
     77    friend class QDBusContextPrivate;
    7878};
    7979
  • trunk/src/dbus/qdbuscontext_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/dbus/qdbusdemarshaller.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/dbus/qdbuserror.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4545#include <qvarlengtharray.h>
    4646
    47 #include <qdbus_symbols_p.h>
     47#include "qdbus_symbols_p.h"
    4848#include "qdbusmessage.h"
    4949#include "qdbusmessage_p.h"
     
    9292com.trolltech.QtDBus.Error.InternalError
    9393org.freedesktop.DBus.Error.UnknownObject
     94com.trolltech.QtDBus.Error.InvalidService
     95com.trolltech.QtDBus.Error.InvalidObjectPath
     96com.trolltech.QtDBus.Error.InvalidInterface
     97com.trolltech.QtDBus.Error.InvalidMember
    9498*/
    9599
     
    117121    "com.trolltech.QtDBus.Error.InternalError\0"
    118122    "org.freedesktop.DBus.Error.UnknownObject\0"
     123    "com.trolltech.QtDBus.Error.InvalidService\0"
     124    "com.trolltech.QtDBus.Error.InvalidObjectPath\0"
     125    "com.trolltech.QtDBus.Error.InvalidInterface\0"
     126    "com.trolltech.QtDBus.Error.InvalidMember\0"
    119127    "\0";
    120128
     
    122130       0,    6,   40,   76,  118,  153,  191,  231,
    123131     273,  313,  349,  384,  421,  461,  501,  540,
    124      581,  617,  661,  705,  746,    0
     132     581,  617,  661,  705,  746,  787,  829,  874,
     133     918,    0
    125134};
    126135
     
    217226    \value InternalError        An internal error occurred
    218227                                (\c com.trolltech.QtDBus.Error.InternalError)
     228
     229    \value InvalidObjectPath    The object path provided is invalid.
     230
     231    \value InvalidService       The service requested is invalid.
     232
     233    \value InvalidMember        The member is invalid.
     234
     235    \value InvalidInterface     The interface is invalid.
     236
    219237    \value UnknownObject        The remote object could not be found.
    220 
    221238*/
    222239
     
    340357QDebug operator<<(QDebug dbg, const QDBusError &msg)
    341358{
    342     dbg.nospace() << "QDBusError(" << msg.name() << ", " << msg.message() << ")";
     359    dbg.nospace() << "QDBusError(" << msg.name() << ", " << msg.message() << ')';
    343360    return dbg.space();
    344361}
  • trunk/src/dbus/qdbuserror.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    8282        InternalError,
    8383        UnknownObject,
     84        InvalidService,
     85        InvalidObjectPath,
     86        InvalidInterface,
     87        InvalidMember,
    8488
    8589#ifndef Q_QDOC
    8690        // don't use this one!
    87         LastErrorType = UnknownObject
     91        LastErrorType = InvalidMember
    8892#endif
    8993    };
  • trunk/src/dbus/qdbusextratypes.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/dbus/qdbusextratypes.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    175175{ QVariant::operator=(dBusVariant); }
    176176
     177inline bool operator==(const QDBusVariant &v1, const QDBusVariant &v2)
     178{ return v1.variant() == v2.variant(); }
     179
    177180QT_END_NAMESPACE
    178181
  • trunk/src/dbus/qdbusintegrator.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    7575    if (th && !th->objectName().isEmpty())
    7676        dbg.nospace() << ", name=" << th->objectName();
    77     dbg.nospace() << ")";
     77    dbg.nospace() << ')';
    7878    return dbg.space();
    7979}
     
    9191    else
    9292        dbg.nospace() << conn->thread();
    93     dbg.nospace() << ")";
     93    dbg.nospace() << ')';
    9494    return dbg.space();
    9595}
     
    391391} // extern "C"
    392392
    393 static QByteArray buildMatchRule(const QString &service, const QString & /*owner*/,
     393static QByteArray buildMatchRule(const QString &service,
    394394                                 const QString &objectPath, const QString &interface,
    395                                  const QString &member, const QString & /*signature*/)
     395                                 const QString &member, const QStringList &argMatch, const QString & /*signature*/)
    396396{
    397397    QString result = QLatin1String("type='signal',");
     
    406406    if (!member.isEmpty())
    407407        result += keyValue.arg(QLatin1String("member"), member);
     408
     409    // add the argument string-matching now
     410    if (!argMatch.isEmpty()) {
     411        keyValue = QLatin1String("arg%1='%2',");
     412        for (int i = 0; i < argMatch.count(); ++i)
     413            if (!argMatch.at(i).isNull())
     414                result += keyValue.arg(i).arg(argMatch.at(i));
     415    }
    408416
    409417    result.chop(1);             // remove ending comma
     
    492500    // object not found
    493501    return 0;
     502}
     503
     504static bool shouldWatchService(const QString &service)
     505{
     506    return !service.isEmpty() && !service.startsWith(QLatin1Char(':'));
    494507}
    495508
     
    566579    QDBusConnectionPrivate::ObjectTreeNode::DataList::ConstIterator end = haystack.children.constEnd();
    567580    for ( ; it != end; ++it)
    568         huntAndEmit(connection, msg, needle, *it, isScriptable, isAdaptor, path + QLatin1String("/") + it->name);
     581        huntAndEmit(connection, msg, needle, *it, isScriptable, isAdaptor, path + QLatin1Char('/') + it->name);
    569582
    570583    if (needle == haystack.obj) {
     
    921934      rootNode(QString(QLatin1Char('/')))
    922935{
    923     static const bool threads = qDBusInitThreads();
    924     static const int debugging = ::isDebugging = qgetenv("QDBUS_DEBUG").toInt();
     936    static const bool threads = q_dbus_threads_init_default();
     937    static const int debugging = qgetenv("QDBUS_DEBUG").toInt();
     938    ::isDebugging = debugging;
    925939    Q_UNUSED(threads)
     940    Q_UNUSED(debugging)
    926941
    927942#ifdef QDBUS_THREAD_DEBUG
     
    933948
    934949    rootNode.flags = 0;
    935 
    936     connect(this, SIGNAL(serviceOwnerChanged(QString,QString,QString)),
    937             this, SLOT(_q_serviceOwnerChanged(QString,QString,QString)));
    938950}
    939951
     
    11031115
    11041116    for (int i = 0; i < pendingWatches.size(); ++i)
    1105         if (!q_dbus_watch_handle(pendingWatches[i], DBUS_WATCH_READABLE))
     1117        if (!q_dbus_watch_handle(pendingWatches[i], DBUS_WATCH_WRITABLE))
    11061118            qDebug("OUT OF MEM");
    11071119}
     
    11261138                                         const QVariantList &args)
    11271139{
    1128     int mciid = mo->indexOfClassInfo(QCLASSINFO_DBUS_INTERFACE);
    1129     Q_ASSERT(mciid != -1);
    1130 
    1131     QMetaClassInfo mci = mo->classInfo(mciid);
    1132     Q_ASSERT(mci.value());
    1133     const char *interface = mci.value();
     1140    QString interface = qDBusInterfaceFromMetaObject(mo);
    11341141
    11351142    QMetaMethod mm = mo->method(signalId);
     
    11471154
    11481155    QDBusReadLocker locker(RelaySignalAction, this);
    1149     QDBusMessage message = QDBusMessage::createSignal(QLatin1String("/"), QLatin1String(interface),
     1156    QDBusMessage message = QDBusMessage::createSignal(QLatin1String("/"), interface,
    11501157                                                      QLatin1String(memberName));
     1158    QDBusMessagePrivate::setParametersValidated(message, true);
    11511159    message.setArguments(args);
    1152     DBusMessage *msg = QDBusMessagePrivate::toDBusMessage(message);
     1160    QDBusError error;
     1161    DBusMessage *msg = QDBusMessagePrivate::toDBusMessage(message, &error);
    11531162    if (!msg) {
    1154         qWarning("QDBusConnection: Could not emit signal %s.%s", interface, memberName.constData());
     1163        qWarning("QDBusConnection: Could not emit signal %s.%s: %s", qPrintable(interface), memberName.constData(),
     1164                 qPrintable(error.message()));
     1165        lastError = error;
    11551166        return;
    11561167    }
     
    11661177                                                    const QString &oldOwner, const QString &newOwner)
    11671178{
    1168     if (oldOwner == baseService)
    1169         unregisterService(name);
    1170     if (newOwner == baseService)
    1171         registerService(name);
    1172 
     1179    Q_UNUSED(oldOwner);
    11731180    QDBusWriteLocker locker(UpdateSignalHookOwnerAction, this);
    1174     QMutableHashIterator<QString, SignalHook> it(signalHooks);
    1175     it.toFront();
    1176     while (it.hasNext())
    1177         if (it.next().value().service == name)
    1178             it.value().owner = newOwner;
     1181    WatchedServicesHash::Iterator it = watchedServices.find(name);
     1182    if (it == watchedServices.end())
     1183        return;
     1184    if (oldOwner != it->owner)
     1185        qWarning("QDBusConnection: name '%s' had owner '%s' but we thought it was '%s'",
     1186                 qPrintable(name), qPrintable(oldOwner), qPrintable(it->owner));
     1187
     1188    qDBusDebug() << this << "Updating name" << name << "from" << oldOwner << "to" << newOwner;
     1189    it->owner = newOwner;
    11791190}
    11801191
     
    11941205
    11951206bool QDBusConnectionPrivate::prepareHook(QDBusConnectionPrivate::SignalHook &hook, QString &key,
    1196                                          const QString &service, const QString &owner,
     1207                                         const QString &service,
    11971208                                         const QString &path, const QString &interface, const QString &name,
     1209                                         const QStringList &argMatch,
    11981210                                         QObject *receiver, const char *signal, int minMIdx,
    11991211                                         bool buildSignature)
     
    12121224
    12131225    hook.service = service;
    1214     hook.owner = owner; // we don't care if the service has an owner yet
    12151226    hook.path = path;
    12161227    hook.obj = receiver;
     1228    hook.argumentMatch = argMatch;
    12171229
    12181230    // build the D-Bus signal name and signature
     
    12361248    }
    12371249
    1238     hook.matchRule = buildMatchRule(service, owner, path, interface, mname, hook.signature);
     1250    hook.matchRule = buildMatchRule(service, path, interface, mname, argMatch, hook.signature);
    12391251    return true;                // connect to this signal
    12401252}
     
    13651377    if (node.flags & (QDBusConnection::ExportScriptableSlots|QDBusConnection::ExportNonScriptableSlots)) {
    13661378        bool interfaceFound = true;
    1367         if (!msg.interface().isEmpty()) {
    1368             // check if the interface name matches anything in the class hierarchy
    1369             const QMetaObject *mo = node.obj->metaObject();
    1370             for ( ; !interfaceFound && mo != &QObject::staticMetaObject; mo = mo->superClass())
    1371                 interfaceFound = msg.interface() == qDBusInterfaceFromMetaObject(mo);
    1372         }
     1379        if (!msg.interface().isEmpty())
     1380            interfaceFound = qDBusInterfaceInObject(node.obj, msg.interface());
    13731381
    13741382        if (interfaceFound) {
     
    14831491    for ( ; it != end && it.key() == key; ++it) {
    14841492        const SignalHook &hook = it.value();
    1485         if (!hook.owner.isEmpty() && hook.owner != msg.service())
    1486             continue;
     1493        if (!hook.service.isEmpty()) {
     1494            const QString owner =
     1495                    shouldWatchService(hook.service) ?
     1496                    watchedServices.value(hook.service).owner :
     1497                    hook.service;
     1498            if (owner != msg.service())
     1499                continue;
     1500        }
    14871501        if (!hook.path.isEmpty() && hook.path != msg.path())
    14881502            continue;
     
    14911505        if (hook.signature.isEmpty() && !hook.signature.isNull() && !msg.signature().isEmpty())
    14921506            continue;
     1507        if (!hook.argumentMatch.isEmpty()) {
     1508            const QVariantList arguments = msg.arguments();
     1509            if (hook.argumentMatch.size() > arguments.size())
     1510                continue;
     1511
     1512            bool matched = true;
     1513            for (int i = 0; i < hook.argumentMatch.size(); ++i) {
     1514                const QString &param = hook.argumentMatch.at(i);
     1515                if (param.isNull())
     1516                    continue;   // don't try to match against this
     1517                if (param == arguments.at(i).toString())
     1518                    continue;   // matched
     1519                matched = false;
     1520                break;
     1521            }
     1522            if (!matched)
     1523                continue;
     1524        }
    14931525
    14941526        activateSignal(hook, msg);
     
    16251657        baseService = QString::fromUtf8(service);
    16261658    } else {
    1627         qWarning("QDBusConnectionPrivate::SetConnection: Unable to get base service");
    1628     }
     1659        qWarning("QDBusConnectionPrivate::setConnection: Unable to get base service");
     1660    }
     1661
     1662    QString busService = QLatin1String(DBUS_SERVICE_DBUS);
     1663    WatchedServicesHash::mapped_type &bus = watchedServices[busService];
     1664    bus.refcount = 1;
     1665    bus.owner = getNameOwnerNoCache(busService);
     1666    connectSignal(busService, QString(), QString(), QLatin1String("NameAcquired"), QStringList(), QString(),
     1667                  this, SLOT(registerService(QString)));
     1668    connectSignal(busService, QString(), QString(), QLatin1String("NameLost"), QStringList(), QString(),
     1669                  this, SLOT(unregisterService(QString)));
     1670
    16291671
    16301672    q_dbus_connection_add_filter(connection, qDBusSignalFilter, this, 0);
     
    17081750                                // through the d_ptr->localReply link
    17091751
    1710     DBusMessage *msg = QDBusMessagePrivate::toDBusMessage(message);
     1752    QDBusError error;
     1753    DBusMessage *msg = QDBusMessagePrivate::toDBusMessage(message, &error);
    17111754    if (!msg) {
    17121755        if (message.type() == QDBusMessage::MethodCallMessage)
    1713             qWarning("QDBusConnection: error: could not send message to service \"%s\" path \"%s\" interface \"%s\" member \"%s\"",
     1756            qWarning("QDBusConnection: error: could not send message to service \"%s\" path \"%s\" interface \"%s\" member \"%s\": %s",
    17141757                     qPrintable(message.service()), qPrintable(message.path()),
    1715                      qPrintable(message.interface()), qPrintable(message.member()));
     1758                     qPrintable(message.interface()), qPrintable(message.member()),
     1759                     qPrintable(error.message()));
    17161760        else if (message.type() == QDBusMessage::SignalMessage)
    1717             qWarning("QDBusConnection: error: could not send signal path \"%s\" interface \"%s\" member \"%s\"",
     1761            qWarning("QDBusConnection: error: could not send signal path \"%s\" interface \"%s\" member \"%s\": %s",
    17181762                     qPrintable(message.path()), qPrintable(message.interface()),
    1719                      qPrintable(message.member()));
     1763                     qPrintable(message.member()),
     1764                     qPrintable(error.message()));
    17201765        else
    1721             qWarning("QDBusConnection: error: could not send %s message to service \"%s\"",
     1766            qWarning("QDBusConnection: error: could not send %s message to service \"%s\": %s",
    17221767                     message.type() == QDBusMessage::ReplyMessage ? "reply" :
    17231768                     message.type() == QDBusMessage::ErrorMessage ? "error" :
    1724                      "invalid", qPrintable(message.service()));
     1769                     "invalid", qPrintable(message.service()),
     1770                     qPrintable(error.message()));
     1771        lastError = error;
    17251772        return 0;
    17261773    }
     
    17491796
    17501797    if (!QCoreApplication::instance() || sendMode == QDBus::Block) {
    1751         DBusMessage *msg = QDBusMessagePrivate::toDBusMessage(message);
     1798        QDBusError err;
     1799        DBusMessage *msg = QDBusMessagePrivate::toDBusMessage(message, &err);
    17521800        if (!msg) {
    1753             qWarning("QDBusConnection: error: could not send message to service \"%s\" path \"%s\" interface \"%s\" member \"%s\"",
     1801            qWarning("QDBusConnection: error: could not send message to service \"%s\" path \"%s\" interface \"%s\" member \"%s\": %s",
    17541802                     qPrintable(message.service()), qPrintable(message.path()),
    1755                      qPrintable(message.interface()), qPrintable(message.member()));
    1756             return QDBusMessage();
     1803                     qPrintable(message.interface()), qPrintable(message.member()),
     1804                     qPrintable(err.message()));
     1805            lastError = err;
     1806            return QDBusMessage::createError(err);
    17571807        }
    17581808
     
    17641814
    17651815        if (!!error) {
    1766             QDBusError qe = error;
    1767             lastError = qe;
    1768             return QDBusMessage::createError(qe);
     1816            lastError = err = error;
     1817            return QDBusMessage::createError(err);
    17691818        }
    17701819
     
    17761825    } else { // use the event loop
    17771826        QDBusPendingCallPrivate *pcall = sendWithReplyAsync(message, timeout);
    1778         if (!pcall)
    1779             return QDBusMessage();
    1780 
    1781         pcall->watcherHelper = new QDBusPendingCallWatcherHelper;
    1782         QEventLoop loop;
    1783         loop.connect(pcall->watcherHelper, SIGNAL(reply(QDBusMessage)), SLOT(quit()));
    1784         loop.connect(pcall->watcherHelper, SIGNAL(error(QDBusError,QDBusMessage)), SLOT(quit()));
    1785 
    1786         // enter the event loop and wait for a reply
    1787         loop.exec(QEventLoop::ExcludeUserInputEvents | QEventLoop::WaitForMoreEvents);
     1827        Q_ASSERT(pcall);
     1828
     1829        if (pcall->replyMessage.type() != QDBusMessage::InvalidMessage) {
     1830            pcall->watcherHelper = new QDBusPendingCallWatcherHelper;
     1831            QEventLoop loop;
     1832            loop.connect(pcall->watcherHelper, SIGNAL(reply(QDBusMessage)), SLOT(quit()));
     1833            loop.connect(pcall->watcherHelper, SIGNAL(error(QDBusError,QDBusMessage)), SLOT(quit()));
     1834
     1835            // enter the event loop and wait for a reply
     1836            loop.exec(QEventLoop::ExcludeUserInputEvents | QEventLoop::WaitForMoreEvents);
     1837        }
    17881838
    17891839        QDBusMessage reply = pcall->replyMessage;
     
    18411891    }
    18421892
    1843     DBusMessage *msg = QDBusMessagePrivate::toDBusMessage(message);
    1844     if (!msg) {
    1845         qWarning("QDBusConnection: error: could not send message to service \"%s\" path \"%s\" interface \"%s\" member \"%s\"",
    1846                  qPrintable(message.service()), qPrintable(message.path()),
    1847                  qPrintable(message.interface()), qPrintable(message.member()));
    1848         return 0;
    1849     }
    1850 
    18511893    checkThread();
    1852     qDBusDebug() << QThread::currentThread() << "sending message (async):" << message;
    1853     DBusPendingCall *pending = 0;
    18541894    QDBusPendingCallPrivate *pcall = new QDBusPendingCallPrivate;
    18551895    pcall->sentMessage = message;
    18561896    pcall->ref = 0;
     1897
     1898    QDBusError error;
     1899    DBusMessage *msg = QDBusMessagePrivate::toDBusMessage(message, &error);
     1900    if (!msg) {
     1901        qWarning("QDBusConnection: error: could not send message to service \"%s\" path \"%s\" interface \"%s\" member \"%s\": %s",
     1902                 qPrintable(message.service()), qPrintable(message.path()),
     1903                 qPrintable(message.interface()), qPrintable(message.member()),
     1904                 qPrintable(error.message()));
     1905        pcall->replyMessage = QDBusMessage::createError(error);
     1906        lastError = error;
     1907        return pcall;
     1908    }
     1909
     1910    qDBusDebug() << QThread::currentThread() << "sending message (async):" << message;
     1911    DBusPendingCall *pending = 0;
    18571912
    18581913    QDBusDispatchLocker locker(SendWithReplyAsyncAction, this);
     
    18681923        } else {
    18691924            // we're probably disconnected at this point
    1870             lastError = QDBusError(QDBusError::Disconnected, QLatin1String("Not connected to server"));
     1925            lastError = error = QDBusError(QDBusError::Disconnected, QLatin1String("Not connected to server"));
    18711926        }
    18721927    } else {
    1873         lastError = QDBusError(QDBusError::NoMemory, QLatin1String("Out of memory"));
     1928        lastError = error = QDBusError(QDBusError::NoMemory, QLatin1String("Out of memory"));
    18741929    }
    18751930
    18761931    q_dbus_message_unref(msg);
    1877     pcall->replyMessage = QDBusMessage::createError(lastError);
     1932    pcall->replyMessage = QDBusMessage::createError(error);
    18781933    return pcall;
    18791934}
     
    18841939{
    18851940    QDBusPendingCallPrivate *pcall = sendWithReplyAsync(message, timeout);
    1886     if (!pcall)
    1887         return 0;
     1941    Q_ASSERT(pcall);
    18881942
    18891943    // has it already finished (dispatched locally)?
     
    19261980}
    19271981
     1982bool QDBusConnectionPrivate::connectSignal(const QString &service,
     1983                                           const QString &path, const QString &interface, const QString &name,
     1984                                           const QStringList &argumentMatch, const QString &signature,
     1985                                           QObject *receiver, const char *slot)
     1986{
     1987    // check the slot
     1988    QDBusConnectionPrivate::SignalHook hook;
     1989    QString key;
     1990    QString name2 = name;
     1991    if (name2.isNull())
     1992        name2.detach();
     1993
     1994    hook.signature = signature;
     1995    if (!prepareHook(hook, key, service, path, interface, name, argumentMatch, receiver, slot, 0, false))
     1996        return false;           // don't connect
     1997
     1998    // avoid duplicating:
     1999    QDBusConnectionPrivate::SignalHookHash::ConstIterator it = signalHooks.find(key);
     2000    QDBusConnectionPrivate::SignalHookHash::ConstIterator end = signalHooks.constEnd();
     2001    for ( ; it != end && it.key() == key; ++it) {
     2002        const QDBusConnectionPrivate::SignalHook &entry = it.value();
     2003        if (entry.service == hook.service &&
     2004            entry.path == hook.path &&
     2005            entry.signature == hook.signature &&
     2006            entry.obj == hook.obj &&
     2007            entry.midx == hook.midx) {
     2008            // no need to compare the parameters if it's the same slot
     2009            return true;        // already there
     2010        }
     2011    }
     2012
     2013    connectSignal(key, hook);
     2014    return true;
     2015}
     2016
    19282017void QDBusConnectionPrivate::connectSignal(const QString &key, const SignalHook &hook)
    19292018{
    19302019    signalHooks.insertMulti(key, hook);
    19312020    connect(hook.obj, SIGNAL(destroyed(QObject*)), SLOT(objectDestroyed(QObject*)),
    1932             Qt::DirectConnection);
     2021            Qt::ConnectionType(Qt::DirectConnection | Qt::UniqueConnection));
    19332022
    19342023    MatchRefCountHash::iterator it = matchRefCounts.find(hook.matchRule);
     
    19532042                     qPrintable(qerror.name()), qPrintable(qerror.message()));
    19542043            Q_ASSERT(false);
    1955         }
    1956     }
     2044        } else {
     2045            // Successfully connected the signal
     2046            // Do we need to watch for this name?
     2047            if (shouldWatchService(hook.service)) {
     2048                WatchedServicesHash::mapped_type &data = watchedServices[hook.service];
     2049                if (data.refcount) {
     2050                    // already watching
     2051                    ++data.refcount;
     2052                } else {
     2053                    // we need to watch for this service changing
     2054                    QString dbusServerService = QLatin1String(DBUS_SERVICE_DBUS);
     2055                    connectSignal(dbusServerService, QString(), QLatin1String(DBUS_INTERFACE_DBUS),
     2056                                  QLatin1String("NameOwnerChanged"), QStringList() << hook.service, QString(),
     2057                                  this, SLOT(_q_serviceOwnerChanged(QString,QString,QString)));
     2058                    data.owner = getNameOwnerNoCache(hook.service);
     2059                    qDBusDebug() << this << "Watching service" << hook.service << "for owner changes (current owner:"
     2060                            << data.owner << ")";
     2061                }
     2062            }
     2063        }
     2064    }
     2065}
     2066
     2067bool QDBusConnectionPrivate::disconnectSignal(const QString &service,
     2068                                              const QString &path, const QString &interface, const QString &name,
     2069                                              const QStringList &argumentMatch, const QString &signature,
     2070                                              QObject *receiver, const char *slot)
     2071{
     2072    // check the slot
     2073    QDBusConnectionPrivate::SignalHook hook;
     2074    QString key;
     2075    QString name2 = name;
     2076    if (name2.isNull())
     2077        name2.detach();
     2078
     2079    hook.signature = signature;
     2080    if (!prepareHook(hook, key, service, path, interface, name, argumentMatch, receiver, slot, 0, false))
     2081        return false;           // don't disconnect
     2082
     2083    // avoid duplicating:
     2084    QDBusConnectionPrivate::SignalHookHash::Iterator it = signalHooks.find(key);
     2085    QDBusConnectionPrivate::SignalHookHash::Iterator end = signalHooks.end();
     2086    for ( ; it != end && it.key() == key; ++it) {
     2087        const QDBusConnectionPrivate::SignalHook &entry = it.value();
     2088        if (entry.service == hook.service &&
     2089            entry.path == hook.path &&
     2090            entry.signature == hook.signature &&
     2091            entry.obj == hook.obj &&
     2092            entry.midx == hook.midx) {
     2093            // no need to compare the parameters if it's the same slot
     2094            disconnectSignal(it);
     2095            return true;        // it was there
     2096        }
     2097    }
     2098
     2099    // the slot was not found
     2100    return false;
    19572101}
    19582102
     
    19612105{
    19622106    const SignalHook &hook = it.value();
     2107
     2108    WatchedServicesHash::Iterator sit = watchedServices.find(hook.service);
     2109    if (sit != watchedServices.end()) {
     2110        if (sit.value().refcount == 1) {
     2111            watchedServices.erase(sit);
     2112            QString dbusServerService = QLatin1String(DBUS_SERVICE_DBUS);
     2113            disconnectSignal(dbusServerService, QString(), QLatin1String(DBUS_INTERFACE_DBUS),
     2114                          QLatin1String("NameOwnerChanged"), QStringList() << hook.service, QString(),
     2115                          this, SLOT(_q_serviceOwnerChanged(QString,QString,QString)));
     2116        } else {
     2117            --sit.value().refcount;
     2118        }
     2119    }
    19632120
    19642121    bool erase = false;
     
    20102167}
    20112168
    2012 void QDBusConnectionPrivate::connectRelay(const QString &service, const QString &owner,
     2169void QDBusConnectionPrivate::connectRelay(const QString &service,
    20132170                                          const QString &path, const QString &interface,
    20142171                                          QDBusAbstractInterface *receiver,
     
    20202177    QString key;
    20212178
    2022     if (!prepareHook(hook, key, service, owner, path, interface, QString(), receiver, signal,
     2179    if (!prepareHook(hook, key, service, path, interface, QString(), QStringList(), receiver, signal,
    20232180                     QDBusAbstractInterface::staticMetaObject.methodCount(), true))
    20242181        return;                 // don't connect
     
    20312188        const SignalHook &entry = it.value();
    20322189        if (entry.service == hook.service &&
    2033             entry.owner == hook.owner &&
    20342190            entry.path == hook.path &&
    20352191            entry.signature == hook.signature &&
     
    20422198}
    20432199
    2044 void QDBusConnectionPrivate::disconnectRelay(const QString &service, const QString &owner,
     2200void QDBusConnectionPrivate::disconnectRelay(const QString &service,
    20452201                                             const QString &path, const QString &interface,
    20462202                                             QDBusAbstractInterface *receiver,
     
    20522208    QString key;
    20532209
    2054     if (!prepareHook(hook, key, service, owner, path, interface, QString(), receiver, signal,
     2210    if (!prepareHook(hook, key, service, path, interface, QString(), QStringList(), receiver, signal,
    20552211                     QDBusAbstractInterface::staticMetaObject.methodCount(), true))
    20562212        return;                 // don't connect
     
    20632219        const SignalHook &entry = it.value();
    20642220        if (entry.service == hook.service &&
    2065             entry.owner == hook.owner &&
    20662221            entry.path == hook.path &&
    20672222            entry.signature == hook.signature &&
     
    20812236    if (QDBusUtil::isValidUniqueConnectionName(serviceName))
    20822237        return serviceName;
    2083     if (!connection || !QDBusUtil::isValidBusName(serviceName))
     2238    if (!connection)
    20842239        return QString();
    20852240
     2241    {
     2242        // acquire a read lock for the cache
     2243        QReadLocker locker(&lock);
     2244        WatchedServicesHash::ConstIterator it = watchedServices.constFind(serviceName);
     2245        if (it != watchedServices.constEnd())
     2246            return it->owner;
     2247    }
     2248
     2249    // not cached
     2250    return getNameOwnerNoCache(serviceName);
     2251}
     2252
     2253QString QDBusConnectionPrivate::getNameOwnerNoCache(const QString &serviceName)
     2254{
    20862255    QDBusMessage msg = QDBusMessage::createMethodCall(QLatin1String(DBUS_SERVICE_DBUS),
    20872256            QLatin1String(DBUS_PATH_DBUS), QLatin1String(DBUS_INTERFACE_DBUS),
    20882257            QLatin1String("GetNameOwner"));
     2258    QDBusMessagePrivate::setParametersValidated(msg, true);
    20892259    msg << serviceName;
    20902260    QDBusMessage reply = sendWithReply(msg, QDBus::Block);
     
    21102280                                                QLatin1String(DBUS_INTERFACE_INTROSPECTABLE),
    21112281                                                QLatin1String("Introspect"));
     2282    QDBusMessagePrivate::setParametersValidated(msg, true);
    21122283
    21132284    QDBusMessage reply = sendWithReply(msg, QDBus::Block);
  • trunk/src/dbus/qdbusintegrator_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5555#define QDBUSINTEGRATOR_P_H
    5656
    57 #include <qdbus_symbols_p.h>
     57#include "qdbus_symbols_p.h"
    5858
    5959#include "qcoreevent.h"
  • trunk/src/dbus/qdbusinterface.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4242#include "qdbusinterface.h"
    4343
    44 #include <qdbus_symbols_p.h>
     44#include "qdbus_symbols_p.h"
    4545#include <QtCore/qpointer.h>
    4646#include <QtCore/qstringlist.h>
     
    5252QT_BEGIN_NAMESPACE
    5353
     54static void copyArgument(void *to, int id, const QVariant &arg)
     55{
     56    if (id == arg.userType()) {
     57        switch (id) {
     58        case QVariant::Bool:
     59            *reinterpret_cast<bool *>(to) = arg.toBool();
     60            return;
     61
     62        case QMetaType::UChar:
     63            *reinterpret_cast<uchar *>(to) = arg.value<uchar>();
     64            return;
     65
     66        case QMetaType::Short:
     67            *reinterpret_cast<short *>(to) = arg.value<short>();
     68            return;
     69
     70        case QMetaType::UShort:
     71            *reinterpret_cast<ushort *>(to) = arg.value<ushort>();
     72            return;
     73
     74        case QVariant::Int:
     75            *reinterpret_cast<int *>(to) = arg.toInt();
     76            return;
     77
     78        case QVariant::UInt:
     79            *reinterpret_cast<uint *>(to) = arg.toUInt();
     80            return;
     81
     82        case QVariant::LongLong:
     83            *reinterpret_cast<qlonglong *>(to) = arg.toLongLong();
     84            return;
     85
     86        case QVariant::ULongLong:
     87            *reinterpret_cast<qulonglong *>(to) = arg.toULongLong();
     88            return;
     89
     90        case QVariant::Double:
     91            *reinterpret_cast<double *>(to) = arg.toDouble();
     92            return;
     93
     94        case QVariant::String:
     95            *reinterpret_cast<QString *>(to) = arg.toString();
     96            return;
     97
     98        case QVariant::ByteArray:
     99            *reinterpret_cast<QByteArray *>(to) = arg.toByteArray();
     100            return;
     101
     102        case QVariant::StringList:
     103            *reinterpret_cast<QStringList *>(to) = arg.toStringList();
     104            return;
     105        }
     106
     107        if (id == QDBusMetaTypeId::variant) {
     108            *reinterpret_cast<QDBusVariant *>(to) = arg.value<QDBusVariant>();
     109            return;
     110        } else if (id == QDBusMetaTypeId::objectpath) {
     111            *reinterpret_cast<QDBusObjectPath *>(to) = arg.value<QDBusObjectPath>();
     112            return;
     113        } else if (id == QDBusMetaTypeId::signature) {
     114            *reinterpret_cast<QDBusSignature *>(to) = arg.value<QDBusSignature>();
     115            return;
     116        }
     117
     118        // those above are the only types possible
     119        // the demarshaller code doesn't demarshall anything else
     120        qFatal("Found a decoded basic type in a D-Bus reply that shouldn't be there");
     121    }
     122
     123    // if we got here, it's either an un-dermarshalled type or a mismatch
     124    if (arg.userType() != QDBusMetaTypeId::argument) {
     125        // it's a mismatch
     126        //qWarning?
     127        return;
     128    }
     129
     130    // is this type registered?
     131    const char *userSignature = QDBusMetaType::typeToSignature(id);
     132    if (!userSignature || !*userSignature) {
     133        // type not registered
     134        //qWarning?
     135        return;
     136    }
     137
     138    // is it the same signature?
     139    QDBusArgument dbarg = arg.value<QDBusArgument>();
     140    if (dbarg.currentSignature() != QLatin1String(userSignature)) {
     141        // not the same signature, another mismatch
     142        //qWarning?
     143        return;
     144    }
     145
     146    // we can demarshall
     147    QDBusMetaType::demarshall(dbarg, id, to);
     148}
     149
    54150QDBusInterfacePrivate::QDBusInterfacePrivate(const QString &serv, const QString &p,
    55151                                             const QString &iface, const QDBusConnection &con)
     
    62158        if (!metaObject) {
    63159            // creation failed, somehow
    64             isValid = false;
     160            // most common causes are that the service doesn't exist or doesn't support introspection
     161            // those are not fatal errors, so we continue working
     162
    65163            if (!lastError.isValid())
    66164                lastError = QDBusError(QDBusError::InternalError, QLatin1String("Unknown error"));
     
    137235const QMetaObject *QDBusInterface::metaObject() const
    138236{
    139     return d_func()->isValid ? d_func()->metaObject : &QDBusAbstractInterface::staticMetaObject;
     237    return d_func()->metaObject ? d_func()->metaObject : &QDBusAbstractInterface::staticMetaObject;
    140238}
    141239
     
    187285            // we will assume that the input arguments were passed correctly
    188286            QVariantList args;
    189             for (int i = 1; i <= inputTypesCount; ++i)
     287            int i = 1;
     288            for ( ; i <= inputTypesCount; ++i)
    190289                args << QVariant(inputTypes[i], argv[i]);
    191290
    192291            // make the call
    193             QPointer<QDBusInterface> qq = q;
    194292            QDBusMessage reply = q->callWithArgumentList(QDBus::Block, methodName, args);
    195             args.clear();
    196 
    197             // we ignore return values
    198 
    199             // access to "this" or to "q" below this point must check for "qq"
    200             // we may have been deleted!
    201 
    202             if (!qq.isNull())
    203                 lastError = reply;
     293
     294            if (reply.type() == QDBusMessage::ReplyMessage) {
     295                // attempt to demarshall the return values
     296                args = reply.arguments();
     297                QVariantList::ConstIterator it = args.constBegin();
     298                const int *outputTypes = metaObject->outputTypesForMethod(id);
     299                int outputTypesCount = *outputTypes++;
     300
     301                if (*mm.typeName()) {
     302                    // this method has a return type
     303                    if (argv[0] && it != args.constEnd())
     304                        copyArgument(argv[0], *outputTypes++, *it);
     305
     306                    // skip this argument even if we didn't copy it
     307                    --outputTypesCount;
     308                    ++it;
     309                }
     310
     311                for (int j = 0; j < outputTypesCount && it != args.constEnd(); ++i, ++j, ++it) {
     312                    copyArgument(argv[i], outputTypes[j], *it);
     313                }
     314            }
    204315
    205316            // done
     317            lastError = reply;
    206318            return -1;
    207319        }
    208     } else if (c == QMetaObject::ReadProperty) {
    209         // Qt doesn't support non-readable properties
    210         // we have to re-check
    211         QMetaProperty mp = metaObject->property(id + metaObject->propertyOffset());
    212         if (!mp.isReadable())
    213             return -1;          // don't read
    214 
    215         QVariant *value = reinterpret_cast<QVariant*>(argv[1]);
    216         argv[1] = 0;
    217         *value = property(mp);
    218 
    219         return -1;              // handled, error or not
    220     } else if (c == QMetaObject::WriteProperty) {
    221         // QMetaProperty::write has already checked that we're writable
    222         // it has also checked that the type is right
    223         QVariant *value = reinterpret_cast<QVariant *>(argv[1]);
    224         QMetaProperty mp = metaObject->property(id + metaObject->propertyOffset());
    225 
    226         setProperty(mp, *value);
    227         return -1;
    228320    }
    229321    return id;
  • trunk/src/dbus/qdbusinterface.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/dbus/qdbusinterface_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5555#define QDBUSINTERFACEPRIVATE_H
    5656
    57 #include <qdbusabstractinterface_p.h>
    58 #include <qdbusmetaobject_p.h>
     57#include "qdbusabstractinterface_p.h"
     58#include "qdbusmetaobject_p.h"
    5959#include <qdbusinterface.h>
    6060
  • trunk/src/dbus/qdbusinternalfilters.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4242#include "qdbusconnection_p.h"
    4343
    44 #include <qdbus_symbols_p.h>
     44#include "qdbus_symbols_p.h"
    4545#include <QtCore/qcoreapplication.h>
    4646#include <QtCore/qmetaobject.h>
     
    5454#include "qdbusmessage.h"
    5555#include "qdbusmetatype.h"
     56#include "qdbusmetatype_p.h"
    5657#include "qdbusmessage_p.h"
    5758#include "qdbusutil_p.h"
     
    178179// implement the D-Bus interface org.freedesktop.DBus.Properties
    179180
    180 static QDBusMessage qDBusPropertyError(const QDBusMessage &msg, const QString &interface_name)
    181 {
    182     return msg.createErrorReply(QLatin1String(DBUS_ERROR_INVALID_ARGS),
     181static inline QDBusMessage interfaceNotFoundError(const QDBusMessage &msg, const QString &interface_name)
     182{
     183    return msg.createErrorReply(QDBusError::UnknownInterface,
    183184                                QString::fromLatin1("Interface %1 was not found in object %2")
    184185                                .arg(interface_name)
    185186                                .arg(msg.path()));
     187}
     188
     189static inline QDBusMessage
     190propertyNotFoundError(const QDBusMessage &msg, const QString &interface_name, const QByteArray &property_name)
     191{
     192    return msg.createErrorReply(QDBusError::InvalidArgs,
     193                                QString::fromLatin1("Property %1%2%3 was not found in object %4")
     194                                .arg(interface_name,
     195                                     QString::fromLatin1(interface_name.isEmpty() ? "" : "."),
     196                                     QString::fromLatin1(property_name),
     197                                     msg.path()));
    186198}
    187199
     
    199211    QDBusAdaptorConnector *connector;
    200212    QVariant value;
     213    bool interfaceFound = false;
    201214    if (node.flags & QDBusConnection::ExportAdaptors &&
    202215        (connector = qDBusFindAdaptorConnector(node.obj))) {
     
    218231            it = qLowerBound(connector->adaptors.constBegin(), connector->adaptors.constEnd(),
    219232                             interface_name);
    220             if (it != connector->adaptors.constEnd() && interface_name == QLatin1String(it->interface))
     233            if (it != connector->adaptors.constEnd() && interface_name == QLatin1String(it->interface)) {
     234                interfaceFound = true;
    221235                value = it->adaptor->property(property_name);
    222         }
    223     }
    224 
    225     if (!value.isValid() && node.flags & (QDBusConnection::ExportAllProperties |
    226                                           QDBusConnection::ExportNonScriptableProperties)) {
     236            }
     237        }
     238    }
     239
     240    if (!interfaceFound && !value.isValid()
     241        && node.flags & (QDBusConnection::ExportAllProperties |
     242                         QDBusConnection::ExportNonScriptableProperties)) {
    227243        // try the object itself
    228         int pidx = node.obj->metaObject()->indexOfProperty(property_name);
    229         if (pidx != -1) {
    230             QMetaProperty mp = node.obj->metaObject()->property(pidx);
    231             if ((mp.isScriptable() && (node.flags & QDBusConnection::ExportScriptableProperties)) ||
    232                 (!mp.isScriptable() && (node.flags & QDBusConnection::ExportNonScriptableProperties)))
    233                 value = mp.read(node.obj);
     244        if (!interface_name.isEmpty())
     245            interfaceFound = qDBusInterfaceInObject(node.obj, interface_name);
     246
     247        if (interfaceFound) {
     248            int pidx = node.obj->metaObject()->indexOfProperty(property_name);
     249            if (pidx != -1) {
     250                QMetaProperty mp = node.obj->metaObject()->property(pidx);
     251                if ((mp.isScriptable() && (node.flags & QDBusConnection::ExportScriptableProperties)) ||
     252                    (!mp.isScriptable() && (node.flags & QDBusConnection::ExportNonScriptableProperties)))
     253                    value = mp.read(node.obj);
     254            }
    234255        }
    235256    }
     
    237258    if (!value.isValid()) {
    238259        // the property was not found
    239         return qDBusPropertyError(msg, interface_name);
     260        if (!interfaceFound)
     261            return interfaceNotFoundError(msg, interface_name);
     262        return propertyNotFoundError(msg, interface_name, property_name);
    240263    }
    241264
    242265    return msg.createReply(qVariantFromValue(QDBusVariant(value)));
     266}
     267
     268enum PropertyWriteResult {
     269    PropertyWriteSuccess = 0,
     270    PropertyNotFound,
     271    PropertyTypeMismatch,
     272    PropertyWriteFailed
     273};
     274
     275static QDBusMessage propertyWriteReply(const QDBusMessage &msg, const QString &interface_name,
     276                                       const QByteArray &property_name, int status)
     277{
     278    switch (status) {
     279    case PropertyNotFound:
     280        return propertyNotFoundError(msg, interface_name, property_name);
     281    case PropertyTypeMismatch:
     282        return msg.createErrorReply(QDBusError::InvalidArgs,
     283                                    QString::fromLatin1("Invalid arguments for writing to property %1%2%3")
     284                                    .arg(interface_name,
     285                                         QString::fromLatin1(interface_name.isEmpty() ? "" : "."),
     286                                         QString::fromLatin1(property_name)));
     287    case PropertyWriteFailed:
     288        return msg.createErrorReply(QDBusError::InternalError,
     289                                    QString::fromLatin1("Internal error"));
     290
     291    case PropertyWriteSuccess:
     292        return msg.createReply();
     293    }
     294    Q_ASSERT_X(false, "", "Should not be reached");
     295    return QDBusMessage();
     296}
     297
     298static int writeProperty(QObject *obj, const QByteArray &property_name, QVariant value,
     299                         int propFlags = QDBusConnection::ExportAllProperties)
     300{
     301    const QMetaObject *mo = obj->metaObject();
     302    int pidx = mo->indexOfProperty(property_name);
     303    if (pidx == -1) {
     304        // this object has no property by that name
     305        return PropertyNotFound;
     306    }
     307
     308    QMetaProperty mp = mo->property(pidx);
     309
     310    // check if this property is exported
     311    bool isScriptable = mp.isScriptable();
     312    if (!(propFlags & QDBusConnection::ExportScriptableProperties) && isScriptable)
     313        return PropertyNotFound;
     314    if (!(propFlags & QDBusConnection::ExportNonScriptableProperties) && !isScriptable)
     315        return PropertyNotFound;
     316
     317    // we found our property
     318    // do we have the right type?
     319    int id = mp.type();
     320    if (id == QVariant::UserType) {
     321        // dynamic type
     322        id = qDBusNameToTypeId(mp.typeName());
     323        if (id == -1) {
     324            // type not registered?
     325            qWarning("QDBusConnection: Unable to handle unregistered datatype '%s' for property '%s::%s'",
     326                     mp.typeName(), mo->className(), property_name.constData());
     327            return PropertyWriteFailed;
     328        }
     329    }
     330
     331    if (id != 0xff && value.userType() == QDBusMetaTypeId::argument) {
     332        // we have to demarshall before writing
     333        void *null = 0;
     334        QVariant other(id, null);
     335        if (!QDBusMetaType::demarshall(qVariantValue<QDBusArgument>(value), id, other.data())) {
     336            qWarning("QDBusConnection: type `%s' (%d) is not registered with QtDBus. "
     337                     "Use qDBusRegisterMetaType to register it",
     338                     mp.typeName(), id);
     339            return PropertyWriteFailed;
     340        }
     341
     342        value = other;
     343    }
     344
     345    // the property type here should match
     346    return mp.write(obj, value) ? PropertyWriteSuccess : PropertyWriteFailed;
    243347}
    244348
     
    264368            for (QDBusAdaptorConnector::AdaptorMap::ConstIterator it = connector->adaptors.constBegin(),
    265369                 end = connector->adaptors.constEnd(); it != end; ++it) {
    266                 const QMetaObject *mo = it->adaptor->metaObject();
    267                 int pidx = mo->indexOfProperty(property_name);
    268                 if (pidx != -1) {
    269                     mo->property(pidx).write(it->adaptor, value);
    270                     return msg.createReply();
    271                 }
     370                int status = writeProperty(it->adaptor, property_name, value);
     371                if (status == PropertyNotFound)
     372                    continue;
     373                return propertyWriteReply(msg, interface_name, property_name, status);
    272374            }
    273375        } else {
     
    275377            it = qLowerBound(connector->adaptors.constBegin(), connector->adaptors.constEnd(),
    276378                             interface_name);
    277             if (it != connector->adaptors.end() && interface_name == QLatin1String(it->interface))
    278                 if (it->adaptor->setProperty(property_name, value))
    279                     return msg.createReply();
     379            if (it != connector->adaptors.end() && interface_name == QLatin1String(it->interface)) {
     380                return propertyWriteReply(msg, interface_name, property_name,
     381                                          writeProperty(it->adaptor, property_name, value));
     382            }
    280383        }
    281384    }
     
    284387                      QDBusConnection::ExportNonScriptableProperties)) {
    285388        // try the object itself
    286         int pidx = node.obj->metaObject()->indexOfProperty(property_name);
    287         if (pidx != -1) {
    288             QMetaProperty mp = node.obj->metaObject()->property(pidx);
    289             if ((mp.isScriptable() && (node.flags & QDBusConnection::ExportScriptableProperties)) ||
    290                 (!mp.isScriptable() && (node.flags & QDBusConnection::ExportNonScriptableProperties)))
    291                 if (mp.write(node.obj, value))
    292                     return msg.createReply();
    293         }
    294     }
    295 
    296     // the property was not found or not written to
    297     return qDBusPropertyError(msg, interface_name);
     389        bool interfaceFound = true;
     390        if (!interface_name.isEmpty())
     391            interfaceFound = qDBusInterfaceInObject(node.obj, interface_name);
     392
     393        if (interfaceFound) {
     394            return propertyWriteReply(msg, interface_name, property_name,
     395                                      writeProperty(node.obj, property_name, value, node.flags));
     396        }
     397    }
     398
     399    // the property was not found
     400    if (!interface_name.isEmpty())
     401        return interfaceNotFoundError(msg, interface_name);
     402    return propertyWriteReply(msg, interface_name, property_name, PropertyNotFound);
    298403}
    299404
     
    386491    if (!interfaceFound && !interface_name.isEmpty()) {
    387492        // the interface was not found
    388         return qDBusPropertyError(msg, interface_name);
     493        return interfaceNotFoundError(msg, interface_name);
    389494    }
    390495
  • trunk/src/dbus/qdbusintrospection.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/dbus/qdbusintrospection_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/dbus/qdbusmacros.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/dbus/qdbusmarshaller.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    122122    QByteArray data = arg.path().toUtf8();
    123123    if (!ba && data.isEmpty())
    124         error();
     124        error(QLatin1String("Invalid object path passed in arguments"));
    125125    const char *cdata = data.constData();
    126126    qIterAppend(&iterator, ba, DBUS_TYPE_OBJECT_PATH, &cdata);
     
    131131    QByteArray data = arg.signature().toUtf8();
    132132    if (!ba && data.isEmpty())
    133         error();
     133        error(QLatin1String("Invalid signature passed in arguments"));
    134134    const char *cdata = data.constData();
    135135    qIterAppend(&iterator, ba, DBUS_TYPE_SIGNATURE, &cdata);
     
    162162    if (id == QVariant::Invalid) {
    163163        qWarning("QDBusMarshaller: cannot add a null QDBusVariant");
    164         error();
     164        error(QLatin1String("Variant containing QVariant::Invalid passed in arguments"));
    165165        return false;
    166166    }
     
    181181                 "Use qDBusRegisterMetaType to register it",
    182182                 QVariant::typeToName( id ), id);
    183         error();
     183        error(QString::fromLatin1("Unregistered type %1 passed in arguments")
     184              .arg(QLatin1String(QVariant::typeToName(id))));
    184185        return false;
    185186    }
     
    221222                 "Use qDBusRegisterMetaType to register it",
    222223                 QVariant::typeToName( QVariant::Type(id) ), id);
    223         error();
     224        error(QString::fromLatin1("Unregistered type %1 passed in arguments")
     225              .arg(QLatin1String(QVariant::typeToName(QVariant::Type(id)))));
    224226        return this;
    225227    }
     
    235237                 "Use qDBusRegisterMetaType to register it",
    236238                 QVariant::typeToName( QVariant::Type(kid) ), kid);
    237         error();
     239        error(QString::fromLatin1("Unregistered type %1 passed in arguments")
     240              .arg(QLatin1String(QVariant::typeToName(QVariant::Type(kid)))));
    238241        return this;
    239242    }
     
    241244        qWarning("QDBusMarshaller: type '%s' (%d) cannot be used as the key type in a D-BUS map.",
    242245                 QVariant::typeToName( QVariant::Type(kid) ), kid);
    243         error();
     246        error(QString::fromLatin1("Type %1 passed in arguments cannot be used as a key in a map")
     247              .arg(QLatin1String(QVariant::typeToName(QVariant::Type(kid)))));
    244248        return this;
    245249    }
     
    247251    const char *vsignature = QDBusMetaType::typeToSignature( QVariant::Type(vid) );
    248252    if (!vsignature) {
     253        const char *typeName = QVariant::typeToName(QVariant::Type(vid));
    249254        qWarning("QDBusMarshaller: type `%s' (%d) is not registered with D-BUS. "
    250255                 "Use qDBusRegisterMetaType to register it",
    251                  QVariant::typeToName( QVariant::Type(vid) ), vid);
    252         error();
     256                 typeName, vid);
     257        error(QString::fromLatin1("Unregistered type %1 passed in arguments")
     258              .arg(QLatin1String(typeName)));
    253259        return this;
    254260    }
     
    329335}
    330336
    331 void QDBusMarshaller::error()
     337void QDBusMarshaller::error(const QString &msg)
    332338{
    333339    ok = false;
    334340    if (parent)
    335         parent->error();
     341        parent->error(msg);
     342    else
     343        errorString = msg;
    336344}
    337345
     
    341349    if (id == QVariant::Invalid) {
    342350        qWarning("QDBusMarshaller: cannot add an invalid QVariant");
    343         error();
     351        error(QLatin1String("Variant containing QVariant::Invalid passed in arguments"));
    344352        return false;
    345353    }
     
    372380                 "Use qDBusRegisterMetaType to register it",
    373381                 QVariant::typeToName( QVariant::Type(id) ), id);
    374         error();
     382        error(QString::fromLatin1("Unregistered type %1 passed in arguments")
     383              .arg(QLatin1String(QVariant::typeToName(QVariant::Type(id)))));
    375384        return false;
    376385    }
     
    379388#ifdef __OPTIMIZE__
    380389    case DBUS_TYPE_BYTE:
    381     case DBUS_TYPE_BOOLEAN:
    382390    case DBUS_TYPE_INT16:
    383391    case DBUS_TYPE_UINT16:
     
    389397        qIterAppend(&iterator, ba, *signature, arg.constData());
    390398        return true;
    391 
    392     case DBUS_TYPE_STRING:
    393     case DBUS_TYPE_OBJECT_PATH:
    394     case DBUS_TYPE_SIGNATURE: {
    395         const QByteArray data =
    396             reinterpret_cast<const QString *>(arg.constData())->toUtf8();
    397         const char *rawData = data.constData();
    398         qIterAppend(&iterator, ba, *signature, &rawData);
    399         return true;
    400     }
     399    case DBUS_TYPE_BOOLEAN:
     400        append( arg.toBool() );
     401        return true;
    401402#else
    402403    case DBUS_TYPE_BYTE:
     
    427428        append( arg.toDouble() );
    428429        return true;
     430#endif
     431
    429432    case DBUS_TYPE_STRING:
    430433        append( arg.toString() );
     
    436439        append( qvariant_cast<QDBusSignature>(arg) );
    437440        return true;
    438 #endif
    439441
    440442    // compound types:
  • trunk/src/dbus/qdbusmessage.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4545#include <qstringlist.h>
    4646
    47 #include <qdbus_symbols_p.h>
     47#include "qdbus_symbols_p.h"
    4848
    4949#include "qdbusargument_p.h"
     
    6363QDBusMessagePrivate::QDBusMessagePrivate()
    6464    : msg(0), reply(0), type(DBUS_MESSAGE_TYPE_INVALID),
    65       timeout(-1), localReply(0), ref(1), delayedReply(false), localMessage(false)
     65      timeout(-1), localReply(0), ref(1), delayedReply(false), localMessage(false),
     66      parametersValidated(false)
    6667{
    6768}
     
    9596    Constructs a DBusMessage object from this object. The returned value must be de-referenced
    9697    with q_dbus_message_unref.
    97 */
    98 DBusMessage *QDBusMessagePrivate::toDBusMessage(const QDBusMessage &message)
    99 {
    100     if (!qdbus_loadLibDBus())
     98
     99    The \a error object is set to indicate the error if anything went wrong with the
     100    marshalling. Usually, this error message will be placed in the reply, as if the call failed.
     101    The \a error pointer must not be null.
     102*/
     103DBusMessage *QDBusMessagePrivate::toDBusMessage(const QDBusMessage &message, QDBusError *error)
     104{
     105    if (!qdbus_loadLibDBus()) {
     106        *error = QDBusError(QDBusError::Failed, QLatin1String("Could not open lidbus-1 library"));
    101107        return 0;
     108    }
    102109
    103110    DBusMessage *msg = 0;
     
    109116        break;
    110117    case DBUS_MESSAGE_TYPE_METHOD_CALL:
    111         msg = q_dbus_message_new_method_call(data(d_ptr->service.toUtf8()), data(d_ptr->path.toUtf8()),
    112                                            data(d_ptr->interface.toUtf8()), data(d_ptr->name.toUtf8()));
     118        // only service and interface can be empty -> path and name must not be empty
     119        if (!d_ptr->parametersValidated) {
     120            if (!QDBusUtil::checkBusName(d_ptr->service, QDBusUtil::EmptyAllowed, error))
     121                return 0;
     122            if (!QDBusUtil::checkObjectPath(d_ptr->path, QDBusUtil::EmptyNotAllowed, error))
     123                return 0;
     124            if (!QDBusUtil::checkInterfaceName(d_ptr->interface, QDBusUtil::EmptyAllowed, error))
     125                return 0;
     126            if (!QDBusUtil::checkMemberName(d_ptr->name, QDBusUtil::EmptyNotAllowed, error, "method"))
     127                return 0;
     128        }
     129
     130        msg = q_dbus_message_new_method_call(data(d_ptr->service.toUtf8()), d_ptr->path.toUtf8(),
     131                                             data(d_ptr->interface.toUtf8()), d_ptr->name.toUtf8());
    113132        break;
    114133    case DBUS_MESSAGE_TYPE_METHOD_RETURN:
     
    120139        break;
    121140    case DBUS_MESSAGE_TYPE_ERROR:
     141        // error name can't be empty
     142        if (!d_ptr->parametersValidated
     143            && !QDBusUtil::checkErrorName(d_ptr->name, QDBusUtil::EmptyNotAllowed, error))
     144            return 0;
     145
    122146        msg = q_dbus_message_new(DBUS_MESSAGE_TYPE_ERROR);
    123         q_dbus_message_set_error_name(msg, data(d_ptr->name.toUtf8()));
     147        q_dbus_message_set_error_name(msg, d_ptr->name.toUtf8());
    124148        if (!d_ptr->localMessage) {
    125149            q_dbus_message_set_destination(msg, q_dbus_message_get_sender(d_ptr->reply));
     
    128152        break;
    129153    case DBUS_MESSAGE_TYPE_SIGNAL:
    130         msg = q_dbus_message_new_signal(data(d_ptr->path.toUtf8()), data(d_ptr->interface.toUtf8()),
    131                                       data(d_ptr->name.toUtf8()));
     154        // nothing can be empty here
     155        if (!d_ptr->parametersValidated) {
     156            if (!QDBusUtil::checkObjectPath(d_ptr->path, QDBusUtil::EmptyNotAllowed, error))
     157                return 0;
     158            if (!QDBusUtil::checkInterfaceName(d_ptr->interface, QDBusUtil::EmptyAllowed, error))
     159                return 0;
     160            if (!QDBusUtil::checkMemberName(d_ptr->name, QDBusUtil::EmptyNotAllowed, error, "method"))
     161                return 0;
     162        }
     163
     164        msg = q_dbus_message_new_signal(d_ptr->path.toUtf8(), d_ptr->interface.toUtf8(),
     165                                        d_ptr->name.toUtf8());
    132166        break;
    133167    default:
     
    135169        break;
    136170    }
    137 #if 0
    138     DBusError err;
    139     q_dbus_error_init(&err);
    140     if (q_dbus_error_is_set(&err)) {
    141         QDBusError qe(&err);
    142         qDebug() << "QDBusMessagePrivate::toDBusMessage" << qe;
    143     }
    144 #endif
    145     if (!msg)
    146         return 0;
     171
     172    // if we got here, the parameters validated
     173    // and since the message parameters cannot be changed once the message is created
     174    // we can record this fact
     175    d_ptr->parametersValidated = true;
    147176
    148177    QDBusMarshaller marshaller;
     
    162191    // not ok;
    163192    q_dbus_message_unref(msg);
    164     Q_ASSERT(false);
     193    *error = QDBusError(QDBusError::Failed, QLatin1String("Marshalling failed: ") + marshaller.errorString);
    165194    return 0;
    166195}
     
    240269            // we must marshall and demarshall again so as to create QDBusArgument
    241270            // entries for the complex types
    242             DBusMessage *message = toDBusMessage(asSent);
     271            QDBusError error;
     272            DBusMessage *message = toDBusMessage(asSent, &error);
     273            if (!message) {
     274                // failed to marshall, so it's a call error
     275                return QDBusMessage::createError(error);
     276            }
     277
    243278            q_dbus_message_set_sender(message, conn.baseService.toUtf8());
    244279
     
    459494  the message \a msg. Returns the DBus message.
    460495*/
     496QDBusMessage QDBusMessage::createErrorReply(QDBusError::ErrorType atype, const QString &amsg) const
     497{
     498    QDBusMessage msg = createErrorReply(QDBusError::errorString(atype), amsg);
     499    msg.d_ptr->parametersValidated = true;
     500    return msg;
     501}
     502
    461503
    462504/*!
     
    666708*/
    667709#ifndef QT_NO_DEBUG_STREAM
    668 QDebug operator<<(QDebug dbg, QDBusMessage::MessageType t)
     710static QDebug operator<<(QDebug dbg, QDBusMessage::MessageType t)
    669711{
    670712    switch (t)
  • trunk/src/dbus/qdbusmessage.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    8888    inline QDBusMessage createErrorReply(const QDBusError &err) const
    8989    { return createErrorReply(err.name(), err.message()); }
    90     inline QDBusMessage createErrorReply(QDBusError::ErrorType type, const QString &msg) const;
     90    QDBusMessage createErrorReply(QDBusError::ErrorType type, const QString &msg) const;
    9191
     92    // there are no setters; if this changes, see qdbusmessage_p.h
    9293    QString service() const;
    9394    QString path() const;
     
    114115};
    115116
    116 inline QDBusMessage QDBusMessage::createErrorReply(QDBusError::ErrorType atype, const QString &amsg) const
    117 { return createErrorReply(QDBusError::errorString(atype), amsg); }
    118 
    119117#ifndef QT_NO_DEBUG_STREAM
    120118QDBUS_EXPORT QDebug operator<<(QDebug, const QDBusMessage &);
  • trunk/src/dbus/qdbusmessage_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5656#include <qatomic.h>
    5757#include <qstring.h>
     58#include <qdbusmessage.h>
    5859
    5960struct DBusMessage;
     
    7071
    7172    QList<QVariant> arguments;
     73
     74    // the following parameters are "const": they are not changed after the constructors
     75    // the parametersValidated member below controls whether they've been validated already
    7276    QString service, path, interface, name, message, signature;
     77
    7378    DBusMessage *msg;
    7479    DBusMessage *reply;
     
    8085    mutable uint delayedReply : 1;
    8186    uint localMessage : 1;
     87    mutable uint parametersValidated : 1;
    8288
    83     static DBusMessage *toDBusMessage(const QDBusMessage &message);
     89    static void setParametersValidated(QDBusMessage &msg, bool enable)
     90    { msg.d_ptr->parametersValidated = enable; }
     91
     92    static DBusMessage *toDBusMessage(const QDBusMessage &message, QDBusError *error);
    8493    static QDBusMessage fromDBusMessage(DBusMessage *dmsg);
    8594
  • trunk/src/dbus/qdbusmetaobject.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    602602    // mark as an error
    603603    error = QDBusError(QDBusError::UnknownInterface,
    604                        QString( QLatin1String("Interface '%1' was not found") )
     604        QString::fromLatin1("Interface '%1' was not found")
    605605                       .arg(interface));
    606606    return 0;
  • trunk/src/dbus/qdbusmetaobject_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/dbus/qdbusmetatype.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4343
    4444#include <string.h>
    45 #include <qdbus_symbols_p.h>
     45#include "qdbus_symbols_p.h"
    4646
    4747#include <qbytearray.h>
  • trunk/src/dbus/qdbusmetatype.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/dbus/qdbusmetatype_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/dbus/qdbusmisc.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4242#include <string.h>
    4343
     44#include <QtCore/qcoreapplication.h>
    4445#include <QtCore/qvariant.h>
    4546#include <QtCore/qmetaobject.h>
     
    4849#include "qdbusconnection_p.h"
    4950#include "qdbusmetatype_p.h"
     51#include "qdbusabstractadaptor_p.h" // for QCLASSINFO_DBUS_*
    5052
    5153QT_BEGIN_NAMESPACE
     
    7274        id = QMetaType::type(name);
    7375    return id;
     76}
     77
     78QString qDBusInterfaceFromMetaObject(const QMetaObject *mo)
     79{
     80    QString interface;
     81
     82    int idx = mo->indexOfClassInfo(QCLASSINFO_DBUS_INTERFACE);
     83    if (idx >= mo->classInfoOffset()) {
     84        interface = QLatin1String(mo->classInfo(idx).value());
     85    } else {
     86        interface = QLatin1String(mo->className());
     87        interface.replace(QLatin1String("::"), QLatin1String("."));
     88
     89        if (interface.startsWith(QLatin1String("QDBus"))) {
     90            interface.prepend(QLatin1String("com.trolltech.QtDBus."));
     91        } else if (interface.startsWith(QLatin1Char('Q')) &&
     92                   interface.length() >= 2 && interface.at(1).isUpper()) {
     93            // assume it's Qt
     94            interface.prepend(QLatin1String("com.trolltech.Qt."));
     95        } else if (!QCoreApplication::instance()||
     96                   QCoreApplication::instance()->applicationName().isEmpty()) {
     97            interface.prepend(QLatin1String("local."));
     98         } else {
     99            interface.prepend(QLatin1Char('.')).prepend(QCoreApplication::instance()->applicationName());
     100            QStringList domainName =
     101                QCoreApplication::instance()->organizationDomain().split(QLatin1Char('.'),
     102                                                                         QString::SkipEmptyParts);
     103            if (domainName.isEmpty())
     104                 interface.prepend(QLatin1String("local."));
     105            else
     106                for (int i = 0; i < domainName.count(); ++i)
     107                    interface.prepend(QLatin1Char('.')).prepend(domainName.at(i));
     108         }
     109     }
     110
     111    return interface;
     112}
     113
     114bool qDBusInterfaceInObject(QObject *obj, const QString &interface_name)
     115{
     116    const QMetaObject *mo = obj->metaObject();
     117    for ( ; mo != &QObject::staticMetaObject; mo = mo->superClass())
     118        if (interface_name == qDBusInterfaceFromMetaObject(mo))
     119            return true;
     120    return false;
    74121}
    75122
  • trunk/src/dbus/qdbuspendingcall.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    311311bool QDBusPendingCall::isFinished() const
    312312{
    313     return d && (d->replyMessage.type() != QDBusMessage::InvalidMessage);
     313    return !d || (d->replyMessage.type() != QDBusMessage::InvalidMessage);
    314314}
    315315
     
    410410#endif
    411411
     412/*!
     413    \since 4.6
     414    Creates a QDBusPendingCall object based on the error condition
     415    \a error. The resulting pending call object will be in the
     416    "finished" state and QDBusPendingReply::isError() will return true.
     417
     418    \sa fromCompletedCall()
     419*/
     420QDBusPendingCall QDBusPendingCall::fromError(const QDBusError &error)
     421{
     422    return fromCompletedCall(QDBusMessage::createError(error));
     423}
     424
     425/*!
     426    \since 4.6
     427    Creates a QDBusPendingCall object based on the message \a msg.
     428    The message must be of type QDBusMessage::ErrorMessage or
     429    QDBusMessage::ReplyMessage (that is, a message that is typical
     430    of a completed call).
     431
     432    This function is useful for code that requires simulating a pending
     433    call, but that has already finished.
     434
     435    \sa fromError()
     436*/
     437QDBusPendingCall QDBusPendingCall::fromCompletedCall(const QDBusMessage &msg)
     438{
     439    QDBusPendingCallPrivate *d = 0;
     440    if (msg.type() == QDBusMessage::ErrorMessage ||
     441        msg.type() == QDBusMessage::ReplyMessage) {
     442        d = new QDBusPendingCallPrivate;
     443        d->replyMessage = msg;
     444        d->connection = 0;
     445    }
     446
     447    return QDBusPendingCall(d);
     448}
     449
    412450
    413451class QDBusPendingCallWatcherPrivate: public QObjectPrivate
     
    433471    : QObject(*new QDBusPendingCallWatcherPrivate, parent), QDBusPendingCall(call)
    434472{
    435     if (d) {
    436         if (!d->watcherHelper)
     473    if (d) {                    // QDBusPendingCall::d
     474        if (!d->watcherHelper) {
    437475            d->watcherHelper = new QDBusPendingCallWatcherHelper;
     476            if (isFinished()) {
     477                // cause a signal emission anyways
     478                QMetaObject::invokeMethod(d->watcherHelper, "finished", Qt::QueuedConnection);
     479            }
     480        }
    438481        d->watcherHelper->add(this);
    439482    }
     
    465508
    466509        // our signals were queued, so deliver them
     510        QCoreApplication::sendPostedEvents(d->watcherHelper, QEvent::MetaCall);
    467511        QCoreApplication::sendPostedEvents(this, QEvent::MetaCall);
    468512    }
  • trunk/src/dbus/qdbuspendingcall.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    7979#endif
    8080
     81    static QDBusPendingCall fromError(const QDBusError &error);
     82    static QDBusPendingCall fromCompletedCall(const QDBusMessage &message);
     83
    8184protected:
    8285    QExplicitlySharedDataPointer<QDBusPendingCallPrivate> d;
  • trunk/src/dbus/qdbuspendingcall_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    6464QT_BEGIN_NAMESPACE
    6565
     66class QDBusPendingCall;
    6667class QDBusPendingCallWatcher;
    6768class QDBusPendingCallWatcherHelper;
     
    9596    void setMetaTypes(int count, const int *types);
    9697    void checkReceivedSignature();
     98
     99    static QDBusPendingCall fromMessage(const QDBusMessage &msg);
    97100};
    98101
  • trunk/src/dbus/qdbuspendingreply.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/dbus/qdbuspendingreply.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    189189    inline void calculateMetaTypes()
    190190    {
     191        if (!d) return;
    191192        int typeIds[Count > 0 ? Count : 1]; // use at least one since zero-sized arrays aren't valid
    192193        ForEach::fillMetaTypes(typeIds);
  • trunk/src/dbus/qdbusreply.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/dbus/qdbusreply.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/dbus/qdbusserver.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    7070        return;
    7171
    72     QObject::connect(d, SIGNAL(newServerConnection(const QDBusConnection &)),
    73                      this, SIGNAL(newConnection(const QDBusConnection &)));
     72    QObject::connect(d, SIGNAL(newServerConnection(QDBusConnection)),
     73                     this, SIGNAL(newConnection(QDBusConnection)));
    7474
    7575    // server = q_dbus_server_listen( "unix:tmpdir=/tmp", &error);
  • trunk/src/dbus/qdbusserver.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/dbus/qdbusthreaddebug_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    101101    ToggleWatchAction = 62,
    102102    SocketReadAction = 63,
    103     SocketWriteAction = 64,
     103    SocketWriteAction = 64
    104104};
    105105
  • trunk/src/dbus/qdbusutil.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    4242#include "qdbusutil_p.h"
    4343
    44 #include <qdbus_symbols_p.h>
     44#include "qdbus_symbols_p.h"
    4545
    4646#include <QtCore/qstringlist.h>
     
    8181
    8282    if (argType == QVariant::StringList) {
    83         out += QLatin1String("{");
     83        out += QLatin1Char('{');
    8484        QStringList list = arg.toStringList();
    8585        foreach (QString item, list)
     
    8787        if (!list.isEmpty())
    8888            out.chop(2);
    89         out += QLatin1String("}");
     89        out += QLatin1Char('}');
    9090    } else if (argType == QVariant::ByteArray) {
    91         out += QLatin1String("{");
     91        out += QLatin1Char('{');
    9292        QByteArray list = arg.toByteArray();
    9393        for (int i = 0; i < list.count(); ++i) {
     
    9797        if (!list.isEmpty())
    9898            out.chop(2);
    99         out += QLatin1String("}");
     99        out += QLatin1Char('}');
    100100    } else if (argType == QVariant::List) {
    101         out += QLatin1String("{");
     101        out += QLatin1Char('{');
    102102        QList<QVariant> list = arg.toList();
    103103        foreach (QVariant item, list) {
     
    108108        if (!list.isEmpty())
    109109            out.chop(2);
    110         out += QLatin1String("}");
     110        out += QLatin1Char('}');
    111111    } else if (argType == QMetaType::Char || argType == QMetaType::Short || argType == QMetaType::Int
    112112               || argType == QMetaType::Long || argType == QMetaType::LongLong) {
     
    143143        out += QLatin1Char(']');
    144144    } else if (arg.canConvert(QVariant::String)) {
    145         out += QLatin1String("\"") + arg.toString() + QLatin1String("\"");
     145        out += QLatin1Char('\"') + arg.toString() + QLatin1Char('\"');
    146146    } else {
    147147        out += QLatin1Char('[');
     
    227227    if (elementType != QDBusArgument::BasicType && elementType != QDBusArgument::VariantType
    228228            && elementType != QDBusArgument::MapEntryType)
    229         out += QLatin1String("]");
     229        out += QLatin1Char(']');
    230230
    231231    return true;
  • trunk/src/dbus/qdbusutil_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5858
    5959#include <QtDBus/qdbusmacros.h>
     60#include <QtDBus/qdbuserror.h>
    6061
    6162QT_BEGIN_HEADER
     
    8485
    8586    QDBUS_EXPORT QString argumentToString(const QVariant &variant);
     87
     88    enum AllowEmptyFlag {
     89        EmptyAllowed,
     90        EmptyNotAllowed
     91    };
     92
     93    inline bool checkInterfaceName(const QString &name, AllowEmptyFlag empty, QDBusError *error)
     94    {
     95        if (name.isEmpty()) {
     96            if (empty == EmptyAllowed) return true;
     97            *error = QDBusError(QDBusError::InvalidInterface, QLatin1String("Interface name cannot be empty"));
     98            return false;
     99        }
     100        if (isValidInterfaceName(name)) return true;
     101        *error = QDBusError(QDBusError::InvalidInterface, QString::fromLatin1("Invalid interface class: %1").arg(name));
     102        return false;
     103    }
     104
     105    inline bool checkBusName(const QString &name, AllowEmptyFlag empty, QDBusError *error)
     106    {
     107        if (name.isEmpty()) {
     108            if (empty == EmptyAllowed) return true;
     109            *error = QDBusError(QDBusError::InvalidService, QLatin1String("Service name cannot be empty"));
     110            return false;
     111        }
     112        if (isValidBusName(name)) return true;
     113        *error = QDBusError(QDBusError::InvalidService, QString::fromLatin1("Invalid service name: %1").arg(name));
     114        return false;
     115    }
     116
     117    inline bool checkObjectPath(const QString &path, AllowEmptyFlag empty, QDBusError *error)
     118    {
     119        if (path.isEmpty()) {
     120            if (empty == EmptyAllowed) return true;
     121            *error = QDBusError(QDBusError::InvalidObjectPath, QLatin1String("Object path cannot be empty"));
     122            return false;
     123        }
     124        if (isValidObjectPath(path)) return true;
     125        *error = QDBusError(QDBusError::InvalidObjectPath, QString::fromLatin1("Invalid object path: %1").arg(path));
     126        return false;
     127    }
     128
     129    inline bool checkMemberName(const QString &name, AllowEmptyFlag empty, QDBusError *error, const char *nameType = 0)
     130    {
     131        if (!nameType) nameType = "member";
     132        if (name.isEmpty()) {
     133            if (empty == EmptyAllowed) return true;
     134            *error = QDBusError(QDBusError::InvalidMember, QLatin1String(nameType) + QLatin1String(" name cannot be empty"));
     135            return false;
     136        }
     137        if (isValidMemberName(name)) return true;
     138        *error = QDBusError(QDBusError::InvalidMember, QString::fromLatin1("Invalid %1 name: %2")
     139                            .arg(QString::fromLatin1(nameType), name));
     140        return false;
     141    }
     142
     143    inline bool checkErrorName(const QString &name, AllowEmptyFlag empty, QDBusError *error)
     144    {
     145        if (name.isEmpty()) {
     146            if (empty == EmptyAllowed) return true;
     147            *error = QDBusError(QDBusError::InvalidInterface, QLatin1String("Error name cannot be empty"));
     148            return false;
     149        }
     150        if (isValidErrorName(name)) return true;
     151        *error = QDBusError(QDBusError::InvalidInterface, QString::fromLatin1("Invalid error name: %1").arg(name));
     152        return false;
     153    }
    86154}
    87155
  • trunk/src/dbus/qdbusxmlgenerator.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
    4040****************************************************************************/
    4141
    42 #include <QtCore/qcoreapplication.h>
    4342#include <QtCore/qmetaobject.h>
    4443#include <QtCore/qstringlist.h>
     
    205204                xml += QString::fromLatin1("      <annotation name=\"com.trolltech.QtDBus.QtTypeName.%1%2\" value=\"%3\"/>\n")
    206205                       .arg(isOutput ? QLatin1String("Out") : QLatin1String("In"))
    207                        .arg(isOutput ? j - inputCount : j - 1)
     206                       .arg(isOutput && !isSignal ? j - inputCount : j - 1)
    208207                       .arg(typeNameToXml(typeName));
    209208            }
     
    232231    return retval;
    233232}
    234 
    235 QString qDBusInterfaceFromMetaObject(const QMetaObject *mo)
    236 {
    237     QString interface;
    238 
    239     int idx = mo->indexOfClassInfo(QCLASSINFO_DBUS_INTERFACE);
    240     if (idx >= mo->classInfoOffset()) {
    241         interface = QLatin1String(mo->classInfo(idx).value());
    242     } else {
    243         interface = QLatin1String(mo->className());
    244         interface.replace(QLatin1String("::"), QLatin1String("."));
    245 
    246         if (interface.startsWith(QLatin1String("QDBus"))) {
    247             interface.prepend(QLatin1String("com.trolltech.QtDBus."));
    248         } else if (interface.startsWith(QLatin1Char('Q')) &&
    249                    interface.length() >= 2 && interface.at(1).isUpper()) {
    250             // assume it's Qt
    251             interface.prepend(QLatin1String("com.trolltech.Qt."));
    252         } else if (!QCoreApplication::instance()||
    253                    QCoreApplication::instance()->applicationName().isEmpty()) {
    254             interface.prepend(QLatin1String("local."));
    255          } else {
    256             interface.prepend(QLatin1Char('.')).prepend(QCoreApplication::instance()->applicationName());
    257             QStringList domainName =
    258                 QCoreApplication::instance()->organizationDomain().split(QLatin1Char('.'),
    259                                                                          QString::SkipEmptyParts);
    260             if (domainName.isEmpty())
    261                  interface.prepend(QLatin1String("local."));
    262             else
    263                 for (int i = 0; i < domainName.count(); ++i)
    264                     interface.prepend(QLatin1Char('.')).prepend(domainName.at(i));
    265          }
    266      }
    267  
    268     return interface;
    269  }
    270233
    271234QString qDBusGenerateMetaObjectXml(QString interface, const QMetaObject *mo,
  • trunk/src/dbus/qdbusxmlparser.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
  • trunk/src/dbus/qdbusxmlparser_p.h

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtDBus module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5757#include <QtXml/qdom.h>
    5858#include <qdbusmacros.h>
    59 #include <qdbusintrospection_p.h>
     59#include "qdbusintrospection_p.h"
    6060
    6161QT_BEGIN_NAMESPACE
Note: See TracChangeset for help on using the changeset viewer.