diff options
author | Thiago Macieira <thiago@kde.org> | 2006-06-04 15:52:05 +0000 |
---|---|---|
committer | Thiago Macieira <thiago@kde.org> | 2006-06-04 15:52:05 +0000 |
commit | edbf2bfc109ce94b2604ea20328fda25542e4383 (patch) | |
tree | 3281d191fa9dde9f1f26b947b145d02373f031b0 /qt/qdbusreply.h | |
parent | 435c7af9b605c3ffc8641142b6d7add18bf7080b (diff) |
* qt/: Update to Subversion r548032.
This includes a big reorganisation of the files inside the
subdir.
We really need a version control system that supports moving of
files. I'm not bothering with history anyways anymore, since the
bindings will be moved out to git. The history should be restored from
Subversion when that happens.
Diffstat (limited to 'qt/qdbusreply.h')
-rw-r--r-- | qt/qdbusreply.h | 132 |
1 files changed, 0 insertions, 132 deletions
diff --git a/qt/qdbusreply.h b/qt/qdbusreply.h deleted file mode 100644 index ff0d5d5d..00000000 --- a/qt/qdbusreply.h +++ /dev/null @@ -1,132 +0,0 @@ -/* qdbusreply.h QDBusReply object - a reply from D-Bus - * - * Copyright (C) 2006 Trolltech AS. All rights reserved. - * Author: Thiago Macieira <thiago.macieira@trolltech.com> - * - * Licensed under the Academic Free License version 2.1 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef QDBUSREPLY_H -#define QDBUSREPLY_H - -#include <QtCore/qglobal.h> -#include <QtCore/qvariant.h> - -#include "qdbusmacros.h" -#include "qdbusmessage.h" -#include "qdbuserror.h" - -#include "qdbustypehelper_p.h" - -template<typename T> -class QDBUS_EXPORT QDBusReply -{ - typedef T Type; -public: - inline QDBusReply(const QDBusMessage &reply) - : m_data(Type()) - { - *this = reply; - } - inline QDBusReply& operator=(const QDBusMessage& reply) - { - m_error = reply; - if (isSuccess()) - m_data = QDBusTypeHelper<Type>::fromVariant(reply.at(0)); - else - m_data = Type(); - return *this; - } - - inline QDBusReply(const QDBusError &error = QDBusError()) - : m_error(error), m_data(Type()) - { - } - inline QDBusReply& operator=(const QDBusError& error) - { - m_error = error; - m_data = Type(); - return *this; - } - - inline QDBusReply& operator=(const QDBusReply& other) - { - m_error = other.m_error; - m_data = other.m_data; - return *this; - } - - inline bool isError() const { return m_error.isValid(); } - inline bool isSuccess() const { return !m_error.isValid(); } - - inline const QDBusError& error() { return m_error; } - - inline Type value() - { - return m_data; - } - - inline operator Type () - { - return m_data; - } - - static QDBusReply<T> fromVariant(const QDBusReply<QVariant> &variantReply) - { - QDBusReply<T> retval; - retval.m_error = variantReply.m_error; - if (retval.isSuccess()) { - retval.m_data = qvariant_cast<Type>(variantReply.m_data); - if (!qVariantCanConvert<Type>(variantReply.m_data)) - retval.m_error = QDBusError(QDBusError::InvalidSignature, - QLatin1String("Unexpected reply signature")); - } - return retval; - } - -private: - QDBusError m_error; - Type m_data; -}; - -# ifndef Q_QDOC -// specialize for void: -template<> -class QDBUS_EXPORT QDBusReply<void> -{ -public: - inline QDBusReply(const QDBusMessage &reply) - : m_error(reply) - { - } - inline QDBusReply(const QDBusError &error) - : m_error(error) - { - } - - inline bool isError() const { return m_error.isValid(); } - inline bool isSuccess() const { return !m_error.isValid(); } - - inline const QDBusError& error() { return m_error; } - -private: - QDBusError m_error; -}; -# endif - -#endif |