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/notificationagent.cc | 57 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 agents/notificationagent.cc (limited to 'agents/notificationagent.cc') diff --git a/agents/notificationagent.cc b/agents/notificationagent.cc new file mode 100644 index 0000000..58d27d4 --- /dev/null +++ b/agents/notificationagent.cc @@ -0,0 +1,57 @@ +#include "sapsocket.h" +#include "sapconnectionrequest.h" +#include "sapserviceinfo.h" +#include "sapchannelinfo.h" +#include "notificationconn.h" +#include "notificationagent.h" + +static NotificationAgent *agent = 0; +static const QLatin1String notification_profile("/system/NotificationService"); + +NotificationAgent::NotificationAgent(QObject *parent) + : QObject(parent), _peer(0), _socket(0) +{ +} + +NotificationAgent* NotificationAgent::instance() +{ + if (!agent) { + agent = new NotificationAgent; + } + return agent; +} + +void NotificationAgent::peerFound(SAPPeer *peer) +{ + Q_UNUSED(peer); +} + +void NotificationAgent::requestConnection(SAPConnectionRequest *request) +{ + qDebug() << "Notification request connection from" << request->peer()->peerName(); + SAPConnection *conn = request->connection(); + new NotificationConn(conn, this); + + request->accept(); +} + +void NotificationAgent::registerServices(SAPManager *manager) +{ + SAPServiceInfo service; + SAPChannelInfo channel; + + service.setProfile(notification_profile); + service.setFriendlyName("Notification"); + service.setRole(SAPServiceInfo::RoleProvider); + service.setVersion(1, 0); + service.setConnectionTimeout(0); + + channel.setChannelId(104); + channel.setPayloadType(SAPChannelInfo::PayloadBinary); + channel.setQoSType(SAPChannelInfo::QoSReliabilityDisable); + channel.setQoSDataRate(SAPChannelInfo::QoSDataRateLow); + channel.setQoSPriority(SAPChannelInfo::QoSPriorityLow); + service.addChannel(channel); + + manager->registerServiceAgent(service, instance()); +} -- cgit v1.2.3