Debian Codegraph @

libqnapi/src/utils/syncxmlrpc.cpp

raw symbols SCIP
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 #include "syncxmlrpc.h"
16
17 SyncXmlRpc::SyncXmlRpc(const QUrl &endPoint) : rpc(endPoint) {}
18
19 bool SyncXmlRpc::request(const QString &method, const QVariantList &args) {
20 rpc.call(method, args, this, SLOT(whenResponse(QVariant &)), this,
21 SLOT(whenFault(int, const QString &)));
22 loop.exec();
23 return result;
24 }
25
26 QVariant SyncXmlRpc::getResponse() const { return resp; }
27
28 QVariant SyncXmlRpc::getError() const {
29 return QString::number(error) + " " + message;
30 }
31
32 void SyncXmlRpc::whenResponse(QVariant &response) {
33 result = true;
34 resp = response;
35 loop.exit();
36 }
37
38 void SyncXmlRpc::whenFault(int err, const QString &msg) {
39 result = false;
40 error = err;
41 message = msg;
42 loop.exit();
43 }