From a45977185a485624095bff1a15024e9199eee676 Mon Sep 17 00:00:00 2001 From: Javier Date: Fri, 1 Jan 2016 22:05:42 +0100 Subject: reorganize source files into SAP and agents --- agents/webproxyagent.cc | 64 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 agents/webproxyagent.cc (limited to 'agents/webproxyagent.cc') diff --git a/agents/webproxyagent.cc b/agents/webproxyagent.cc new file mode 100644 index 0000000..c9d5580 --- /dev/null +++ b/agents/webproxyagent.cc @@ -0,0 +1,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) +{ + Q_UNUSED(peer); +} + +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()); +} -- cgit v1.2.3