KD SOAP 2.0.0
Loading...
Searching...
No Matches
KDSoapClientThread_p.h
1/****************************************************************************
2**
3** This file is part of the KD Soap library.
4**
5** SPDX-FileCopyrightText: 2010-2021 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
6**
7** SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDAB-KDSoap OR LicenseRef-KDAB-KDSoap-US
8**
9** Licensees holding valid commercial KD Soap licenses may use this file in
10** accordance with the KD Soap Commercial License Agreement provided with
11** the Software.
12**
13** Contact info@kdab.com if any conditions of this licensing are not clear to you.
14**
15****************************************************************************/
16
17#ifndef KDSOAPCLIENTTHREAD_P_H
18#define KDSOAPCLIENTTHREAD_P_H
19
20#include "KDSoapMessage.h"
21#include "KDSoapAuthentication.h"
22#include <QtCore/QWaitCondition>
23#include <QtCore/QQueue>
24#include <QtCore/QThread>
25#include <QtCore/QMutex>
26#include <QtCore/QSemaphore>
27#include <QtNetwork/QNetworkAccessManager>
28
31QT_BEGIN_NAMESPACE
32class QEventLoop;
33QT_END_NAMESPACE
34
35class KDSoapThreadTaskData
36{
37public:
38 KDSoapThreadTaskData(KDSoapClientInterface *iface, const QString &method, const KDSoapMessage &message, const QString &action,
39 const KDSoapHeaders &headers)
40 : m_iface(iface)
41 , m_method(method)
42 , m_message(message)
43 , m_action(action)
44 , m_headers(headers)
45 {
46 }
47
48 void waitForCompletion()
49 {
50 m_semaphore.acquire();
51 }
52 KDSoapMessage response() const
53 {
54 return m_response;
55 }
56 KDSoapHeaders responseHeaders() const
57 {
58 return m_responseHeaders;
59 }
60
61 KDSoapClientInterface *m_iface; // used by KDSoapThreadTask::process()
62 KDSoapAuthentication m_authentication;
63 QString m_method;
64 KDSoapMessage m_message;
65 QString m_action;
66 QSemaphore m_semaphore;
67 KDSoapMessage m_response;
68 KDSoapHeaders m_responseHeaders;
69 KDSoapHeaders m_headers;
70};
71
72class KDSoapThreadTask : public QObject
73{
74 Q_OBJECT
75public:
76 explicit KDSoapThreadTask(KDSoapThreadTaskData *data)
77 : m_data(data)
78 {
79 }
80
81 void process(QNetworkAccessManager &accessManager);
82 void slotAuthenticationRequired(QNetworkReply *reply, QAuthenticator *authenticator);
83
84signals:
85 void taskDone();
86
87private Q_SLOTS:
88 void slotFinished(KDSoapPendingCallWatcher *watcher);
89
90private:
91 KDSoapThreadTaskData *m_data;
92};
93
94class KDSoapClientThread : public QThread
95{
96 Q_OBJECT
97public:
98 explicit KDSoapClientThread(QObject *parent = nullptr);
99
100 void enqueue(KDSoapThreadTaskData *taskData);
101
102 void stop();
103
104protected:
105 virtual void run() override;
106
107private:
108 QMutex m_mutex;
109 QQueue<KDSoapThreadTaskData *> m_queue;
110 QWaitCondition m_queueNotEmpty;
111 bool m_stopThread;
112};
113
114#endif // KDSOAPCLIENTTHREAD_P_H
Definition: KDSoapAuthentication.h:37
Definition: KDSoapClientInterface.h:57
Definition: KDSoapMessage.h:192
Definition: KDSoapMessage.h:35
Definition: KDSoapPendingCallWatcher.h:42

© 2010-2021 Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
https://www.kdab.com/development-resources/qt-tools/kd-soap/
Generated on Fri May 1 2026 02:54:14 for KD SOAP by doxygen 1.9.6