From d8d8fc7a0d139e7b864eee3b573bd208f823ad4f Mon Sep 17 00:00:00 2001 From: Javier Date: Sun, 19 Oct 2014 18:45:03 +0200 Subject: initial import, no crypto --- sappeer.h | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 sappeer.h (limited to 'sappeer.h') diff --git a/sappeer.h b/sappeer.h new file mode 100644 index 0000000..5e565db --- /dev/null +++ b/sappeer.h @@ -0,0 +1,69 @@ +#ifndef SAPPEER_H +#define SAPPEER_H + +#include +#include + +#include "saprotocol.h" +#include "sapserviceinfo.h" + +class WMSPeer; +class CapabilityPeer; +class SAPConnection; +class SAPConnectionRequest; +class SAPSocket; +class SAPAgent; + +class SAPPeer : public QObject +{ + Q_OBJECT +public: + explicit SAPPeer(SAProtocol::Role role, const QString &localName, const QString &peerName, QObject *parent = 0); + + SAPConnection* createServiceConnection(const QString &profile, const QString &requesterProfile, SAPServiceInfo::Role requesterRole); + + SAProtocol::Role role() const; + QString localName() const; + QString peerName() const; + +signals: + void connected(); + void disconnected(); + +protected: + /** Transmits a frame to the underlying transport. */ + virtual void sendFrame(const QByteArray &data) = 0; + + CapabilityPeer *capabilityPeer(); + + /** Writes data to the remote. */ + bool writeToSession(int session, const QByteArray &data); + + void acceptServiceConnection(SAPConnectionRequest *connReq, int statusCode); + + /** Distributes data to the appropiate socket. */ + void handleSessionData(int session, const QByteArray &data); + + /** Perform service discovery once connected. */ + void handleConnected(); + void handleDisconnected(); + +private: + int findUnusedSessionId() const; + void handleDefaultSessionMessage(const QByteArray &message); + +protected: + WMSPeer *_wms; + +private: + const SAProtocol::Role _role; + const QString _localName; + const QString _peerName; + + QMap _sessions; + + friend class SAPSocket; + friend class SAPConnectionRequest; +}; + +#endif // SAPPEER_H -- cgit v1.2.3