KD SOAP API Documentation  2.2
KDSoapClientThread_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** This file is part of the KD Soap project.
4 **
5 ** SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
6 **
7 ** SPDX-License-Identifier: MIT
8 **
9 ****************************************************************************/
10 
11 #ifndef KDSOAPCLIENTTHREAD_P_H
12 #define KDSOAPCLIENTTHREAD_P_H
13 
14 #include "KDSoapAuthentication.h"
15 #include "KDSoapMessage.h"
16 #include <QtCore/QMutex>
17 #include <QtCore/QQueue>
18 #include <QtCore/QSemaphore>
19 #include <QtCore/QThread>
20 #include <QtCore/QWaitCondition>
21 #include <QtNetwork/QNetworkAccessManager>
22 
25 QT_BEGIN_NAMESPACE
26 class QEventLoop;
27 QT_END_NAMESPACE
28 
30 {
31 public:
32  KDSoapThreadTaskData(KDSoapClientInterface *iface, const QString &method, const KDSoapMessage &message, const QString &action,
33  const KDSoapHeaders &headers)
34  : m_iface(iface)
35  , m_method(method)
36  , m_message(message)
37  , m_action(action)
38  , m_headers(headers)
39  {
40  }
41 
43  {
44  m_semaphore.acquire();
45  }
47  {
48  return m_response;
49  }
51  {
52  return m_responseHeaders;
53  }
54 
55  KDSoapClientInterface *m_iface; // used by KDSoapThreadTask::process()
57  QString m_method;
59  QString m_action;
60  QSemaphore m_semaphore;
64 };
65 
66 // clazy:excludeall=ctor-missing-parent-argument
67 class KDSoapThreadTask : public QObject
68 {
69  Q_OBJECT
70 public:
71  explicit KDSoapThreadTask(KDSoapThreadTaskData *data) // clazy:exclude=ctor-missing-parent-argument
72  : m_data(data)
73  {
74  }
75 
76  void process(QNetworkAccessManager &accessManager);
77  void slotAuthenticationRequired(QNetworkReply *reply, QAuthenticator *authenticator);
78 
79 signals:
80  void taskDone();
81 
82 private Q_SLOTS:
83  void slotFinished(KDSoapPendingCallWatcher *watcher);
84 
85 private:
86  KDSoapThreadTaskData *m_data;
87 };
88 
89 class KDSoapClientThread : public QThread
90 {
91  Q_OBJECT
92 public:
93  explicit KDSoapClientThread(QObject *parent = nullptr);
94 
95  void enqueue(KDSoapThreadTaskData *taskData);
96 
97  void stop();
98 
99 protected:
100  virtual void run() override;
101 
102 private:
103  QMutex m_mutex;
104  QQueue<KDSoapThreadTaskData *> m_queue;
105  QWaitCondition m_queueNotEmpty;
106  bool m_stopThread;
107 };
108 
109 #endif // KDSOAPCLIENTTHREAD_P_H
KDSoapClientThread(QObject *parent=nullptr)
virtual void run() override
void enqueue(KDSoapThreadTaskData *taskData)
KDSoapAuthentication m_authentication
KDSoapThreadTaskData(KDSoapClientInterface *iface, const QString &method, const KDSoapMessage &message, const QString &action, const KDSoapHeaders &headers)
KDSoapHeaders m_responseHeaders
KDSoapMessage response() const
KDSoapClientInterface * m_iface
KDSoapHeaders responseHeaders() const
KDSoapThreadTask(KDSoapThreadTaskData *data)
void slotAuthenticationRequired(QNetworkReply *reply, QAuthenticator *authenticator)
void process(QNetworkAccessManager &accessManager)

© 2010-2024 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 by doxygen 1.9.1