/*
 * This file contains D-Bus client proxy classes generated by qt4-client-gen.py.
 *
 * This file can be distributed under the same terms as the specification from
 * which it was generated.
 */

#ifndef IN_TELEPATHY_QT4_HEADER
#error IN_TELEPATHY_QT4_HEADER
#endif

#include <TelepathyQt4/Types>

#include <QtGlobal>

#include <QString>
#include <QObject>
#include <QVariant>

#include <QDBusPendingReply>

#include <TelepathyQt4/AbstractInterface>
#include <TelepathyQt4/DBusProxy>
#include <TelepathyQt4/Global>

// basically the same as GLib's G_GNUC_DEPRECATED
#ifndef TELEPATHY_GNUC_DEPRECATED
#   if defined(Q_CC_GNUC) && __GNUC__ >= 4
#       define TELEPATHY_GNUC_DEPRECATED __attribute__((__deprecated__))
#   else
#       define TELEPATHY_GNUC_DEPRECATED
#   endif
#endif
namespace Tp
{
namespace Client
{

/**
 * \class ChannelRequestInterface
 * \headerfile TelepathyQt4/channel-request.h <TelepathyQt4/ChannelRequest>
 * \ingroup clientchannelrequest
 *
 * Proxy class providing a 1:1 mapping of the D-Bus interface "org.freedesktop.Telepathy.ChannelRequest."
 */
class TELEPATHY_QT4_EXPORT ChannelRequestInterface : public Tp::AbstractInterface
{
    Q_OBJECT

public:
    /**
     * Returns the name of the interface "org.freedesktop.Telepathy.ChannelRequest", which this class
     * represents.
     *
     * \return The D-Bus interface name.
     */
    static inline const char *staticInterfaceName()
    {
        return "org.freedesktop.Telepathy.ChannelRequest";
    }

    /**
     * Creates a ChannelRequestInterface associated with the given object on the session bus.
     *
     * \param busName Name of the service the object is on.
     * \param objectPath Path to the object on the service.
     * \param parent Passed to the parent class constructor.
     */
    ChannelRequestInterface(
        const QString& busName,
        const QString& objectPath,
        QObject* parent = 0
    );

    /**
     * Creates a ChannelRequestInterface associated with the given object on the given bus.
     *
     * \param connection The bus via which the object can be reached.
     * \param busName Name of the service the object is on.
     * \param objectPath Path to the object on the service.
     * \param parent Passed to the parent class constructor.
     */
    ChannelRequestInterface(
        const QDBusConnection& connection,
        const QString& busName,
        const QString& objectPath,
        QObject* parent = 0
    );

    /**
     * Creates a ChannelRequestInterface associated with the same object as the given proxy.
     *
     * \param proxy The proxy to use. It will also be the QObject::parent()
     *               for this object.
     */
    ChannelRequestInterface(Tp::DBusProxy *proxy);

    /**
     * Represents property "Account" on the remote object.
     * 
     * The Account on which this request was made. This property cannot change.
     */
    Q_PROPERTY(QDBusObjectPath Account READ Account)

    /**
     * Getter for the remote object property "Account".
     *
     * Don't use this: it blocks the main loop.
     *
     * \return The value of the property, or a default-constructed value
     *          if the property is not readable.
     */
    inline QDBusObjectPath Account() const TELEPATHY_GNUC_DEPRECATED
    {
        return qvariant_cast<QDBusObjectPath>(internalPropGet("Account"));
    }

    /**
     * Represents property "UserActionTime" on the remote object.
     * 
     * <p>The time at which user action occurred, or 0 if this channel
     *   request is for some reason not involving user action.</p>
     * 
     * <p>This corresponds to the _NET_WM_USER_TIME property in
     *   <a href="http://standards.freedesktop.org/wm-spec/wm-spec-latest.html">EWMH</a>.</p>
     * 
     * <p>This property is set when the channel request is created,
     *   and can never change.</p>
     */
    Q_PROPERTY(qlonglong UserActionTime READ UserActionTime)

    /**
     * Getter for the remote object property "UserActionTime".
     *
     * Don't use this: it blocks the main loop.
     *
     * \return The value of the property, or a default-constructed value
     *          if the property is not readable.
     */
    inline qlonglong UserActionTime() const TELEPATHY_GNUC_DEPRECATED
    {
        return qvariant_cast<qlonglong>(internalPropGet("UserActionTime"));
    }

    /**
     * Represents property "PreferredHandler" on the remote object.
     * 
     *   <p>Either the well-known bus name (starting with
     *     <code>org.freedesktop.Telepathy.Client.</code>)
     *     of the preferred handler for this
     *     channel, or an empty string to indicate that any handler would be
     *     acceptable.</p>
     * 
     * <p>This property is set when the channel request is created,
     *   and can never change.</p>
     */
    Q_PROPERTY(QString PreferredHandler READ PreferredHandler)

    /**
     * Getter for the remote object property "PreferredHandler".
     *
     * Don't use this: it blocks the main loop.
     *
     * \return The value of the property, or a default-constructed value
     *          if the property is not readable.
     */
    inline QString PreferredHandler() const TELEPATHY_GNUC_DEPRECATED
    {
        return qvariant_cast<QString>(internalPropGet("PreferredHandler"));
    }

    /**
     * Represents property "Requests" on the remote object.
     * 
     * <p>An array of dictionaries containing desirable properties for
     *   the channel or channels to be created.</p>
     * 
     * <tp:rationale>
     *   <p>This is an array so that we could add a CreateChannels method in
     *     future without redefining the API of ChannelRequest.</p>
     * </tp:rationale>
     * 
     * <p>This property is set when the channel request is created,
     *   and can never change.</p>
     */
    Q_PROPERTY(Tp::QualifiedPropertyValueMapList Requests READ Requests)

    /**
     * Getter for the remote object property "Requests".
     *
     * Don't use this: it blocks the main loop.
     *
     * \return The value of the property, or a default-constructed value
     *          if the property is not readable.
     */
    inline Tp::QualifiedPropertyValueMapList Requests() const TELEPATHY_GNUC_DEPRECATED
    {
        return qvariant_cast<Tp::QualifiedPropertyValueMapList>(internalPropGet("Requests"));
    }

    /**
     * Represents property "Interfaces" on the remote object.
     * 
     * A list of the extra interfaces provided by this channel request. This 
     * property cannot change.
     */
    Q_PROPERTY(QStringList Interfaces READ Interfaces)

    /**
     * Getter for the remote object property "Interfaces".
     *
     * Don't use this: it blocks the main loop.
     *
     * \return The value of the property, or a default-constructed value
     *          if the property is not readable.
     */
    inline QStringList Interfaces() const TELEPATHY_GNUC_DEPRECATED
    {
        return qvariant_cast<QStringList>(internalPropGet("Interfaces"));
    }

public Q_SLOTS:
    /**
     * Begins a call to the D-Bus method "Proceed" on the remote object.
     * 
     * <p>Proceed with the channel request.</p>
     * 
     * <tp:rationale>
     *   <p>The client that created this object calls this method
     *     when it has connected signal handlers for
     *     <tp:member-ref>Succeeded</tp:member-ref> and
     *     <tp:member-ref>Failed</tp:member-ref>.</p>
     * </tp:rationale>
     * 
     * <p>Clients other than the client which created the ChannelRequest
     *   MUST NOT call this method.</p>
     * 
     * <p>This method SHOULD return immediately; on success, the request
     *   might still fail, but this will be indicated asynchronously
     *   by the <tp:member-ref>Failed</tp:member-ref> signal.</p>
     * 
     * <p>Proceed cannot fail, unless clients have got the life-cycle
     *   of a ChannelRequest seriously wrong (e.g. a client calls this
     *   method twice, or a client that did not create the ChannelRequest
     *   calls this method). If it fails, clients SHOULD assume that the
     *   whole ChannelRequest has become useless.</p>
     */
    inline QDBusPendingReply<> Proceed()
    {
        if (!invalidationReason().isEmpty()) {
            return QDBusPendingReply<>(QDBusMessage::createError(
                invalidationReason(),
                invalidationMessage()
            ));
        }


        return asyncCall(QLatin1String("Proceed"));
    }

    /**
     * Begins a call to the D-Bus method "Cancel" on the remote object.
     * 
     * <p>Cancel the channel request. The precise effect depends on the
     *   current progress of the request.</p>
     * 
     * <p>If the connection manager has not already been asked to create
     *   a channel, then <tp:member-ref>Failed</tp:member-ref> is emitted
     *   immediately, and the channel request is removed.</p>
     * 
     * <p>If the connection manager has already been asked to create a
     *   channel but has not produced one yet (e.g. if <tp:dbus-ref namespace="org.freedesktop.Telepathy">Connection.Interface.Requests.CreateChannel</tp:dbus-ref>
     *   has been called, but has not yet returned), then the
     *   ChannelDispatcher will remember that the request has been cancelled.
     *   When the channel appears, it will be closed (if it was newly
     *   created and can be closed), and will not be dispatched to a
     *   handler.</p>
     * 
     * <p>If the connection manager has already returned a channel, but the
     *   channel has not yet been dispatched to a handler
     *   then the channel dispatcher will not dispatch that
     *   channel to a handler. If the channel was newly created for this
     *   request, the channel dispatcher will close it with <tp:dbus-ref namespace="org.freedesktop.Telepathy.Channel">Close</tp:dbus-ref>;
     *   otherwise, the channel dispatcher will ignore it. In either case,
     *   <tp:member-ref>Failed</tp:member-ref> will be emitted when processing
     *   has been completed.</p>
     * 
     * <p>If <tp:member-ref>Failed</tp:member-ref> is emitted in response to
     *   this method, the error SHOULD be
     *   <code>org.freedesktop.Telepathy.Error.Cancelled</code>.</p>
     * 
     * <p>If the channel has already been dispatched to a handler, then
     *   it's too late to call this method, and the channel request will
     *   no longer exist.</p>
     */
    inline QDBusPendingReply<> Cancel()
    {
        if (!invalidationReason().isEmpty()) {
            return QDBusPendingReply<>(QDBusMessage::createError(
                invalidationReason(),
                invalidationMessage()
            ));
        }


        return asyncCall(QLatin1String("Cancel"));
    }

Q_SIGNALS:
    /**
     * Represents the signal "Failed" on the remote object.
     * 
     * <p>The channel request has failed. It is no longer present,
     *   and further methods must not be called on it.</p>
     *
     * \param error
     *     
     *     <p>The name of a D-Bus error. This can come from various sources,
     *       including the error raised by <tp:dbus-ref namespace="org.freedesktop.Telepathy.Connection.Interface.Requests">CreateChannel</tp:dbus-ref>,
     *       or an error generated
     *       to represent failure to establish the <tp:dbus-ref namespace="org.freedesktop.Telepathy">Connection</tp:dbus-ref>.</p>
     *
     * \param message
     *     
     *     If the first argument of the D-Bus error message was a string, that 
     *     string. Otherwise, an empty string.
     */
    void Failed(const QString& error, const QString& message);

    /**
     * Represents the signal "Succeeded" on the remote object.
     * 
     * <p>The channel request has succeeded. It is no longer present,
     *   and further methods must not be called on it.</p>
     */
    void Succeeded();

protected:
    virtual void invalidate(Tp::DBusProxy *, const QString &, const QString &);
};
}
}
