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:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • 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:
Note: See TracChangeset for help on using the changeset viewer.