summaryrefslogtreecommitdiff
path: root/agents/webproxyagent.cc
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 /agents/webproxyagent.cc
parenta24034bdfea259cdc09c74217be75d4f9de0dce5 (diff)
downloadsapd-a45977185a485624095bff1a15024e9199eee676.tar.gz
sapd-a45977185a485624095bff1a15024e9199eee676.zip
reorganize source files into SAP and agents
Diffstat (limited to 'agents/webproxyagent.cc')
-rw-r--r--agents/webproxyagent.cc64
1 files changed, 64 insertions, 0 deletions
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());
+}