blob: 126cd75a9ac70a2ebac305ae93967c11485212bf (
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#include "sapsocket.h"
#include "sapconnectionrequest.h"
#include "sapserviceinfo.h"
#include "sapchannelinfo.h"
#include "webproxyconn.h"
#include "webproxyagent.h"
static WebProxyAgent *agent = 0;
static const QLatin1String webproxy_profile("/system/webproxy");
WebProxyAgent::WebProxyAgent(QObject *parent)
: QObject(parent), _peer(0), _socket(0)
{
}
WebProxyAgent* WebProxyAgent::instance()
{
if (!agent) {
agent = new WebProxyAgent;
}
return agent;
}
void WebProxyAgent::peerFound(SAPPeer *peer)
{
qDebug() << "WebProxy peer found" << peer->peerName();
}
void WebProxyAgent::requestConnection(SAPConnectionRequest *request)
{
qDebug() << "WebProxy request connection from" << request->peer()->peerName();
SAPConnection *conn = request->connection();
new WebProxyConn(conn, this);
request->accept();
}
void WebProxyAgent::registerServices(SAPManager *manager)
{
SAPServiceInfo service;
SAPChannelInfo channel;
service.setProfile(webproxy_profile);
service.setFriendlyName("WebProxy");
service.setRole(SAPServiceInfo::RoleProvider);
service.setVersion(2, 0);
service.setConnectionTimeout(0);
channel.setChannelId(501);
channel.setPayloadType(SAPChannelInfo::PayloadBinary);
channel.setQoSType(SAPChannelInfo::QoSReliabilityEnable);
channel.setQoSDataRate(SAPChannelInfo::QoSDataRateLow);
channel.setQoSPriority(SAPChannelInfo::QoSPriorityLow);
service.addChannel(channel);
channel.setChannelId(502);
channel.setPayloadType(SAPChannelInfo::PayloadBinary);
channel.setQoSType(SAPChannelInfo::QoSReliabilityEnable);
channel.setQoSDataRate(SAPChannelInfo::QoSDataRateLow);
channel.setQoSPriority(SAPChannelInfo::QoSPriorityLow);
service.addChannel(channel);
manager->registerServiceAgent(service, instance());
}
|