| 1 |
/* |
| 2 |
* Copyright (C) 2013-2015, 2019 by the Konclude Developer Team. |
| 3 |
* |
| 4 |
* This file is part of the reasoning system Konclude. |
| 5 |
* For details and support, see <http://konclude.com/>. |
| 6 |
* |
| 7 |
* Konclude is free software: you can redistribute it and/or modify |
| 8 |
* it under the terms of version 3 of the GNU Lesser General Public |
| 9 |
* License (LGPLv3) as published by the Free Software Foundation. |
| 10 |
* |
| 11 |
* Konclude is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
* GNU (Lesser) General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU (Lesser) General Public |
| 17 |
* License along with Konclude. If not, see <http://www.gnu.org/licenses/>. |
| 18 |
* |
| 19 |
*/ |
| 20 |
|
| 21 |
#ifndef KONCLUDE_CONTROL_INTERFACE_OWLLINK_COWLLINKHTTPCONNECTIONHANDLERPROCESSOR_H |
| 22 |
#define KONCLUDE_CONTROL_INTERFACE_OWLLINK_COWLLINKHTTPCONNECTIONHANDLERPROCESSOR_H |
| 23 |
|
| 24 |
// Libraries includes |
| 25 |
#include <QTcpSocket> |
| 26 |
#include <QHostAddress> |
| 27 |
|
| 28 |
// Namespace includes |
| 29 |
#include "OWLlinkSettings.h" |
| 30 |
#include "COWLlinkProcessor.h" |
| 31 |
#include "COWLLinkRecordInterpreter.h" |
| 32 |
|
| 33 |
// Other includes |
| 34 |
#include "Network/HTTP/CQtHttpPooledConnectionHandler.h" |
| 35 |
#include "Network/HTTP/CQtHttpRequestBodyOnlyParser.h" |
| 36 |
#include "Network/HTTP/CQtHttpConnectionHandlerReleaser.h" |
| 37 |
|
| 38 |
#include "Network/HTTP/Events/CHandleIncomingHttpConnectionEvent.h" |
| 39 |
#include "Network/HTTP/Events/CConnectionReadyReadEvent.h" |
| 40 |
#include "Network/HTTP/Events/CConnectionDisconnectedEvent.h" |
| 41 |
|
| 42 |
#include "Control/Command/CConfigManagerReader.h" |
| 43 |
|
| 44 |
// Logger includes |
| 45 |
#include "Logger/CLogger.h" |
| 46 |
#include "Logger/CLogIdentifier.h" |
| 47 |
|
| 48 |
|
| 49 |
namespace Konclude { |
| 50 |
|
| 51 |
using namespace Network::HTTP; |
| 52 |
using namespace Network::HTTP::Events; |
| 53 |
|
| 54 |
namespace Control { |
| 55 |
|
| 56 |
using namespace Command; |
| 57 |
|
| 58 |
namespace Interface { |
| 59 |
|
| 60 |
namespace OWLlink { |
| 61 |
|
| 62 |
/*! |
| 63 |
* |
| 64 |
* \class COWLlinkHttpConnectionHandlerProcessor |
| 65 |
* \author Andreas Steigmiller |
| 66 |
* \version 0.1 |
| 67 |
* \brief TODO |
| 68 |
* |
| 69 |
*/ |
| 70 |
class COWLlinkHttpConnectionHandlerProcessor : public COWLlinkProcessor, public CQtHttpPooledConnectionHandler { |
| 71 |
Q_OBJECT |
| 72 |
|
| 73 |
// public methods |
| 74 |
public: |
| 75 |
//! Constructor |
| 76 |
COWLlinkHttpConnectionHandlerProcessor(CConfiguration* loaderConfig, CQtHttpConnectionHandlerReleaser* releaser); |
| 77 |
|
| 78 |
//! Destructor |
| 79 |
virtual ~COWLlinkHttpConnectionHandlerProcessor(); |
| 80 |
|
| 81 |
virtual bool handleIncomingConnection(int socketDescriptor); |
| 82 |
|
| 83 |
|
| 84 |
bool isHandlerQueued(); |
| 85 |
COWLlinkHttpConnectionHandlerProcessor* setHandlerQueued(bool queued); |
| 86 |
|
| 87 |
// protected methods |
| 88 |
protected: |
| 89 |
virtual void threadStarted(); |
| 90 |
virtual void threadStopped(); |
| 91 |
|
| 92 |
bool processCustomsEvents(QEvent::Type type, CCustomEvent *event); |
| 93 |
|
| 94 |
virtual COWLlinkProcessor* initializeOWLlinkContent(); |
| 95 |
virtual COWLlinkProcessor* concludeOWLlinkContent(); |
| 96 |
|
| 97 |
|
| 98 |
virtual COWLlinkProcessor* sendData(const QByteArray& dataString); |
| 99 |
|
| 100 |
virtual CConfiguration *getConfiguration(); |
| 101 |
|
| 102 |
// protected variables |
| 103 |
protected: |
| 104 |
|
| 105 |
|
| 106 |
// private methods |
| 107 |
private: |
| 108 |
QTcpSocket* mSocket; |
| 109 |
CQtHttpRequestBodyOnlyParser* mParser; |
| 110 |
|
| 111 |
bool mProcessingRequest; |
| 112 |
bool mProcessMoreRead; |
| 113 |
QByteArray* mProcessingByteArray; |
| 114 |
|
| 115 |
COWLLinkRecordInterpreter* mOwllinkInterpreter; |
| 116 |
CCommand* mProcessingCommand; |
| 117 |
|
| 118 |
CConfiguration* mLoaderConfig; |
| 119 |
QSemaphore mThreadStartedSemaphore; |
| 120 |
|
| 121 |
CQtHttpConnectionHandlerReleaser* mReleaser; |
| 122 |
bool mQueued; |
| 123 |
bool mForceDisconnect; |
| 124 |
|
| 125 |
// private slots |
| 126 |
private slots: |
| 127 |
void connectionRead(); |
| 128 |
void connectionDisconnect(); |
| 129 |
|
| 130 |
// private variables |
| 131 |
private: |
| 132 |
|
| 133 |
}; |
| 134 |
|
| 135 |
}; // end namespace OWLlink |
| 136 |
|
| 137 |
}; // end namespace Interface |
| 138 |
|
| 139 |
}; // end namespace Control |
| 140 |
|
| 141 |
}; // end namespace Konclude |
| 142 |
|
| 143 |
#endif // KONCLUDE_CONTROL_INTERFACE_OWLLINK_COWLLINKHTTPCONNECTIONHANDLERPROCESSOR_H |