src/dbus/qdbusmarshaller.cpp
changeset 18 2f34d5167611
parent 0 1918ee327afb
child 30 5dc02b23752f
equal deleted inserted replaced
3:41300fa6a67c 18:2f34d5167611
     1 /****************************************************************************
     1 /****************************************************************************
     2 **
     2 **
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     4 ** All rights reserved.
     4 ** All rights reserved.
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     6 **
     6 **
     7 ** This file is part of the QtDBus module of the Qt Toolkit.
     7 ** This file is part of the QtDBus module of the Qt Toolkit.
     8 **
     8 **
    38 ** $QT_END_LICENSE$
    38 ** $QT_END_LICENSE$
    39 **
    39 **
    40 ****************************************************************************/
    40 ****************************************************************************/
    41 
    41 
    42 #include "qdbusargument_p.h"
    42 #include "qdbusargument_p.h"
       
    43 #include "qdbusmetatype_p.h"
    43 #include "qdbusutil_p.h"
    44 #include "qdbusutil_p.h"
    44 
    45 
    45 QT_BEGIN_NAMESPACE
    46 QT_BEGIN_NAMESPACE
    46 
    47 
    47 static void qIterAppend(DBusMessageIter *it, QByteArray *ba, int type, const void *arg)
    48 static void qIterAppend(DBusMessageIter *it, QByteArray *ba, int type, const void *arg)
   165         return false;
   166         return false;
   166     }
   167     }
   167 
   168 
   168     QByteArray tmpSignature;
   169     QByteArray tmpSignature;
   169     const char *signature = 0;
   170     const char *signature = 0;
   170     if (int(id) == qMetaTypeId<QDBusArgument>()) {
   171     if (int(id) == QDBusMetaTypeId::argument) {
   171         // take the signature from the QDBusArgument object we're marshalling
   172         // take the signature from the QDBusArgument object we're marshalling
   172         tmpSignature =
   173         tmpSignature =
   173             qvariant_cast<QDBusArgument>(value).currentSignature().toLatin1();
   174             qvariant_cast<QDBusArgument>(value).currentSignature().toLatin1();
   174         signature = tmpSignature.constData();
   175         signature = tmpSignature.constData();
   175     } else {
   176     } else {
   351         error(QLatin1String("Variant containing QVariant::Invalid passed in arguments"));
   352         error(QLatin1String("Variant containing QVariant::Invalid passed in arguments"));
   352         return false;
   353         return false;
   353     }
   354     }
   354 
   355 
   355     // intercept QDBusArgument parameters here
   356     // intercept QDBusArgument parameters here
   356     if (id == qMetaTypeId<QDBusArgument>()) {
   357     if (id == QDBusMetaTypeId::argument) {
   357         QDBusArgument dbusargument = qvariant_cast<QDBusArgument>(arg);
   358         QDBusArgument dbusargument = qvariant_cast<QDBusArgument>(arg);
   358         QDBusArgumentPrivate *d = QDBusArgumentPrivate::d(dbusargument);
   359         QDBusArgumentPrivate *d = QDBusArgumentPrivate::d(dbusargument);
   359         if (!d->message)
   360         if (!d->message)
   360             return false;       // can't append this one...
   361             return false;       // can't append this one...
   361 
   362 
   385     }
   386     }
   386 
   387 
   387     switch (*signature) {
   388     switch (*signature) {
   388 #ifdef __OPTIMIZE__
   389 #ifdef __OPTIMIZE__
   389     case DBUS_TYPE_BYTE:
   390     case DBUS_TYPE_BYTE:
   390     case DBUS_TYPE_BOOLEAN:
       
   391     case DBUS_TYPE_INT16:
   391     case DBUS_TYPE_INT16:
   392     case DBUS_TYPE_UINT16:
   392     case DBUS_TYPE_UINT16:
   393     case DBUS_TYPE_INT32:
   393     case DBUS_TYPE_INT32:
   394     case DBUS_TYPE_UINT32:
   394     case DBUS_TYPE_UINT32:
   395     case DBUS_TYPE_INT64:
   395     case DBUS_TYPE_INT64:
   396     case DBUS_TYPE_UINT64:
   396     case DBUS_TYPE_UINT64:
   397     case DBUS_TYPE_DOUBLE:
   397     case DBUS_TYPE_DOUBLE:
   398         qIterAppend(&iterator, ba, *signature, arg.constData());
   398         qIterAppend(&iterator, ba, *signature, arg.constData());
       
   399         return true;
       
   400     case DBUS_TYPE_BOOLEAN:
       
   401         append( arg.toBool() );
   399         return true;
   402         return true;
   400 #else
   403 #else
   401     case DBUS_TYPE_BYTE:
   404     case DBUS_TYPE_BYTE:
   402         append( qvariant_cast<uchar>(arg) );
   405         append( qvariant_cast<uchar>(arg) );
   403         return true;
   406         return true;