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