summaryrefslogtreecommitdiff
path: root/capabilitypeer.h
blob: 0ad6fc666834f84477d71f2dc587de873919d8bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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