summaryrefslogtreecommitdiff
path: root/sap/capabilitypeer.h
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2016-01-01 22:05:42 +0100
committerJavier <dev.git@javispedro.com>2016-01-01 22:05:42 +0100
commita45977185a485624095bff1a15024e9199eee676 (patch)
tree6cc57d085bdd01e493477c870dbe0548137998e1 /sap/capabilitypeer.h
parenta24034bdfea259cdc09c74217be75d4f9de0dce5 (diff)
downloadsapd-a45977185a485624095bff1a15024e9199eee676.tar.gz
sapd-a45977185a485624095bff1a15024e9199eee676.zip
reorganize source files into SAP and agents
Diffstat (limited to 'sap/capabilitypeer.h')
-rw-r--r--sap/capabilitypeer.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/sap/capabilitypeer.h b/sap/capabilitypeer.h
new file mode 100644
index 0000000..0ad6fc6
--- /dev/null
+++ b/sap/capabilitypeer.h
@@ -0,0 +1,49 @@
+#ifndef CAPABILITYPEER_H
+#define CAPABILITYPEER_H
+
+#include <QtCore/QObject>
+#include <QtCore/QHash>
+#include <QtCore/QMap>
+
+#include "sapserviceinfo.h"
+
+class SAPPeer;
+class SAPConnection;
+class SAPConnectionRequest;
+class SAPSocket;
+
+class CapabilityPeer : public QObject
+{
+ Q_OBJECT
+public:
+ CapabilityPeer(SAPPeer *peer, QObject *parent = 0);
+
+ void requestConnection(SAPConnectionRequest *request);
+
+ int remoteAgentId(const QString &profile, SAPServiceInfo::Role role);
+ SAPServiceInfo remoteServiceInfo(int agentId) const;
+
+private:
+ QHash<QString, int>* profilesByRole(SAPServiceInfo::Role role);
+
+private slots:
+ void handleConnected();
+ void handleMessageReceived();
+
+private:
+ SAPPeer *_peer;
+ SAPConnection *_conn;
+ SAPSocket *_socket;
+
+ struct RemoteAgent {
+ int agentId;
+ SAPServiceInfo info;
+ };
+
+ QMap<int, RemoteAgent> _remoteAgents;
+
+ QHash<QString, int> _consumerProfiles;
+ QHash<QString, int> _providerProfiles;
+};
+
+#endif // CAPABILITYPEER_H