summaryrefslogtreecommitdiff
path: root/agents/webproxyagent.cc
diff options
context:
space:
mode:
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());
+}