KD SOAP  2.0.0
KDSoapClientThread_p.h
1 /****************************************************************************
2 **
3 ** This file is part of the KD Soap library.
4 **
5 ** SPDX-FileCopyrightText: 2010-2022 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 
31 QT_BEGIN_NAMESPACE
32 class QEventLoop;
33 QT_END_NAMESPACE
34 
35 class KDSoapThreadTaskData
36 {
37 public:
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 
72 class KDSoapThreadTask : public QObject
73 {
74  Q_OBJECT
75 public:
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 
84 signals:
85  void taskDone();
86 
87 private Q_SLOTS:
88  void slotFinished(KDSoapPendingCallWatcher *watcher);
89 
90 private:
91  KDSoapThreadTaskData *m_data;
92 };
93 
94 class KDSoapClientThread : public QThread
95 {
96  Q_OBJECT
97 public:
98  explicit KDSoapClientThread(QObject *parent = nullptr);
99 
100  void enqueue(KDSoapThreadTaskData *taskData);
101 
102  void stop();
103 
104 protected:
105  virtual void run() override;
106 
107 private:
108  QMutex m_mutex;
110  QWaitCondition m_queueNotEmpty;
111  bool m_stopThread;
112 };
113 
114 #endif // KDSOAPCLIENTTHREAD_P_H
QObject::Q_OBJECT
Q_OBJECTQ_OBJECT
QMutex
KDSoapHeaders
Definition: KDSoapMessage.h:192
QObject::Q_SLOTS
Q_SLOTSQ_SLOTS
QThread
KDSoapPendingCallWatcher
Definition: KDSoapPendingCallWatcher.h:42
KDSoapAuthentication
Definition: KDSoapAuthentication.h:37
KDSoapClientInterface
Definition: KDSoapClientInterface.h:57
KDSoapMessage
Definition: KDSoapMessage.h:35
QObject
QThread::run
virtual void run()
QString
QQueue< KDSoapThreadTaskData * >
QSemaphore
QEventLoop
QWaitCondition

© 2010-2022 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 Jul 22 2022 15:57:43 for KD SOAP by doxygen 1.8.20