1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtDBus module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
46 // This file is not part of the Qt API. It exists for the convenience
47 // of the QLibrary class. This header file may change from
48 // version to version without notice, or even be removed.
56 #include <QtCore/qstring.h>
57 #include <QtCore/qvariant.h>
59 #include <QtDBus/qdbusmacros.h>
60 #include <QtDBus/qdbuserror.h>
70 Q_DBUS_EXPORT bool isValidInterfaceName(const QString &ifaceName);
72 Q_DBUS_EXPORT bool isValidUniqueConnectionName(const QString &busName);
74 Q_DBUS_EXPORT bool isValidBusName(const QString &busName);
76 Q_DBUS_EXPORT bool isValidMemberName(const QString &memberName);
78 Q_DBUS_EXPORT bool isValidErrorName(const QString &errorName);
80 Q_DBUS_EXPORT bool isValidPartOfObjectPath(const QString &path);
82 Q_DBUS_EXPORT bool isValidObjectPath(const QString &path);
84 Q_DBUS_EXPORT bool isValidFixedType(int c);
86 Q_DBUS_EXPORT bool isValidBasicType(int c);
88 Q_DBUS_EXPORT bool isValidSignature(const QString &signature);
90 Q_DBUS_EXPORT bool isValidSingleSignature(const QString &signature);
92 Q_DBUS_EXPORT QString argumentToString(const QVariant &variant);
99 inline bool checkInterfaceName(const QString &name, AllowEmptyFlag empty, QDBusError *error)
101 if (name.isEmpty()) {
102 if (empty == EmptyAllowed) return true;
103 *error = QDBusError(QDBusError::InvalidInterface, QLatin1String("Interface name cannot be empty"));
106 if (isValidInterfaceName(name)) return true;
107 *error = QDBusError(QDBusError::InvalidInterface, QString::fromLatin1("Invalid interface class: %1").arg(name));
111 inline bool checkBusName(const QString &name, AllowEmptyFlag empty, QDBusError *error)
113 if (name.isEmpty()) {
114 if (empty == EmptyAllowed) return true;
115 *error = QDBusError(QDBusError::InvalidService, QLatin1String("Service name cannot be empty"));
118 if (isValidBusName(name)) return true;
119 *error = QDBusError(QDBusError::InvalidService, QString::fromLatin1("Invalid service name: %1").arg(name));
123 inline bool checkObjectPath(const QString &path, AllowEmptyFlag empty, QDBusError *error)
125 if (path.isEmpty()) {
126 if (empty == EmptyAllowed) return true;
127 *error = QDBusError(QDBusError::InvalidObjectPath, QLatin1String("Object path cannot be empty"));
130 if (isValidObjectPath(path)) return true;
131 *error = QDBusError(QDBusError::InvalidObjectPath, QString::fromLatin1("Invalid object path: %1").arg(path));
135 inline bool checkMemberName(const QString &name, AllowEmptyFlag empty, QDBusError *error, const char *nameType = 0)
137 if (!nameType) nameType = "member";
138 if (name.isEmpty()) {
139 if (empty == EmptyAllowed) return true;
140 *error = QDBusError(QDBusError::InvalidMember, QLatin1String(nameType) + QLatin1String(" name cannot be empty"));
143 if (isValidMemberName(name)) return true;
144 *error = QDBusError(QDBusError::InvalidMember, QString::fromLatin1("Invalid %1 name: %2")
145 .arg(QString::fromLatin1(nameType), name));
149 inline bool checkErrorName(const QString &name, AllowEmptyFlag empty, QDBusError *error)
151 if (name.isEmpty()) {
152 if (empty == EmptyAllowed) return true;
153 *error = QDBusError(QDBusError::InvalidInterface, QLatin1String("Error name cannot be empty"));
156 if (isValidErrorName(name)) return true;
157 *error = QDBusError(QDBusError::InvalidInterface, QString::fromLatin1("Invalid error name: %1").arg(name));