File indexing completed on 2024-04-28 15:32:50

0001 /*
0002     SPDX-FileCopyrightText: 2003-2004 Frerich Raabe <raabe@kde.org>
0003     SPDX-FileCopyrightText: 2003-2004 Tobias Koenig <tokoe@kde.org>
0004     SPDX-FileCopyrightText: 2006 Narayan Newton <narayannewton@gmail.com>
0005 
0006     SPDX-License-Identifier: BSD-2-Clause
0007 */
0008 /**
0009   @file
0010 
0011   This file is part of KXmlRpc and defines our internal classes.
0012 
0013   @author Frerich Raabe <raabe@kde.org>
0014   @author Tobias Koenig <tokoe@kde.org>
0015   @author Narayan Newton <narayannewton@gmail.com>
0016 */
0017 
0018 #ifndef KXML_RPC_QUERY_H
0019 #define KXML_RPC_QUERY_H
0020 
0021 #include "kxmlrpcclient_export.h"
0022 
0023 #include <QList>
0024 #include <QMap>
0025 #include <QObject>
0026 #include <QUrl>
0027 #include <QVariant>
0028 
0029 namespace KIO
0030 {
0031 class Job;
0032 }
0033 class KJob;
0034 class QString;
0035 
0036 /** Namespace for XmlRpc related classes */
0037 namespace KXmlRpc
0038 {
0039 class QueryPrivate;
0040 /**
0041   @brief
0042   Query is a class that represents an individual XML-RPC call.
0043 
0044   This is an internal class and is only used by the KXmlRpc::Client class.
0045   @internal
0046   @since 5.8
0047  */
0048 class KXMLRPCCLIENT_EXPORT Query : public QObject
0049 {
0050     friend class Result;
0051     Q_OBJECT
0052 
0053 public:
0054     /**
0055       Constructs a query.
0056 
0057       @param id an optional id for the query.
0058       @param parent an optional parent for the query.
0059      */
0060     static Query *create(const QVariant &id = QVariant(), QObject *parent = nullptr);
0061 
0062 public Q_SLOTS:
0063     /**
0064       Calls the specified method on the specified server with
0065       the given argument list.
0066 
0067       @param server the server to contact.
0068       @param method the method to call.
0069       @param args an argument list to pass to said method.
0070       @param jobMetaData additional arguments to pass to the KIO::Job.
0071      */
0072     void call(const QUrl &server, const QString &method, const QList<QVariant> &args, const QMap<QString, QString> &jobMetaData);
0073 
0074 Q_SIGNALS:
0075     /**
0076       A signal sent when we receive a result from the server.
0077      */
0078     void message(const QList<QVariant> &result, const QVariant &id);
0079 
0080     /**
0081       A signal sent when we receive an error from the server.
0082      */
0083     void fault(int errCode, const QString &errString, const QVariant &id);
0084 
0085     /**
0086       A signal sent when a query finishes.
0087      */
0088     void finished(Query *query);
0089 
0090 private:
0091     explicit Query(const QVariant &id, QObject *parent = nullptr);
0092     ~Query() override;
0093 
0094     QueryPrivate *const d;
0095 
0096     Q_PRIVATE_SLOT(d, void slotData(KIO::Job *, const QByteArray &))
0097     Q_PRIVATE_SLOT(d, void slotResult(KJob *))
0098 };
0099 
0100 } // namespace XmlRpc
0101 
0102 #endif