summaryrefslogtreecommitdiff
path: root/webproxyagent.cc
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2015-12-13 03:18:09 +0100
committerJavier <dev.git@javispedro.com>2015-12-13 03:18:09 +0100
commit3340aa0ef68eb735c36185959c8dbd11178575bf (patch)
treecf424e206eb60b7ca9f99bf135ed8dae54d25259 /webproxyagent.cc
parentf45294559f976258831821ada062c73965201150 (diff)
downloadsapd-3340aa0ef68eb735c36185959c8dbd11178575bf.tar.gz
sapd-3340aa0ef68eb735c36185959c8dbd11178575bf.zip
Bump min Qt requirement to 5.2, bump libwatchfish version
Diffstat (limited to 'webproxyagent.cc')
-rw-r--r--webproxyagent.cc57
1 files changed, 57 insertions, 0 deletions
diff --git a/webproxyagent.cc b/webproxyagent.cc
new file mode 100644
index 0000000..186912f
--- /dev/null
+++ b/webproxyagent.cc
@@ -0,0 +1,57 @@
+#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(502);
+ channel.setPayloadType(SAPChannelInfo::PayloadBinary);
+ channel.setQoSType(SAPChannelInfo::QoSRestricted);
+ channel.setQoSDataRate(SAPChannelInfo::QoSDataRateLow);
+ channel.setQoSPriority(SAPChannelInfo::QoSPriorityHigh);
+ service.addChannel(channel);
+
+ manager->registerServiceAgent(service, instance());
+}