| 1 | /***************************************************************************** |
| 2 | ** QNapi |
| 3 | ** Copyright (C) 2008-2017 Piotr KrzemiĆski <[email protected]> |
| 4 | ** |
| 5 | ** This program is free software; you can redistribute it and/or modify |
| 6 | ** it under the terms of the GNU General Public License as published by |
| 7 | ** the Free Software Foundation; either version 2 of the License, or |
| 8 | ** (at your option) any later version. |
| 9 | ** |
| 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
| 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
| 12 | ** |
| 13 | *****************************************************************************/ |
| 14 | |
| 15 | #ifndef SYNCXMLRPC_H |
| 16 | #define SYNCXMLRPC_H |
| 17 | |
| 18 | #include <QEventLoop> |
| 19 | #include <QNetworkAccessManager> |
| 20 | #include <QNetworkRequest> |
| 21 | #include <QObject> |
| 22 | #include "maiaXmlRpcClient.h" |
| 23 | |
| 24 | class SyncXmlRpc : public QObject { |
| 25 | Q_OBJECT |
| 26 | public: |
| 27 | SyncXmlRpc(const QUrl& endPoint); |
| 28 | |
| 29 | bool request(const QString& method, const QVariantList& args); |
| 30 | QVariant getResponse() const; |
| 31 | QVariant getError() const; |
| 32 | |
| 33 | private slots: |
| 34 | |
| 35 | void whenResponse(QVariant& response); |
| 36 | |
| 37 | void whenFault(int err, const QString& msg); |
| 38 | |
| 39 | private: |
| 40 | bool result; |
| 41 | int error; |
| 42 | QString message; |
| 43 | QVariant resp; |
| 44 | QEventLoop loop; |
| 45 | MaiaXmlRpcClient rpc; |
| 46 | }; |
| 47 | |
| 48 | #endif |