summaryrefslogtreecommitdiff
path: root/agents/notificationagent.cc
diff options
context:
space:
mode:
Diffstat (limited to 'agents/notificationagent.cc')
-rw-r--r--agents/notificationagent.cc57
1 files changed, 57 insertions, 0 deletions
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());
+}