From ceafe544919a35f674684c2e71593b9fb35747a5 Mon Sep 17 00:00:00 2001 From: Javier Date: Sat, 26 Dec 2015 20:02:47 +0100 Subject: prepare new agent for music controller --- musicagent.cc | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 musicagent.cc (limited to 'musicagent.cc') diff --git a/musicagent.cc b/musicagent.cc new file mode 100644 index 0000000..5d7836a --- /dev/null +++ b/musicagent.cc @@ -0,0 +1,55 @@ +#include "sapsocket.h" +#include "sapconnectionrequest.h" +#include "sapserviceinfo.h" +#include "sapchannelinfo.h" +#include "musicconn.h" +#include "musicagent.h" + +static MusicAgent *agent = 0; +static const QLatin1String music_profile("/system/music"); + +MusicAgent::MusicAgent(QObject *parent) + : QObject(parent), _peer(0), _socket(0) +{ +} + +MusicAgent* MusicAgent::instance() +{ + if (!agent) { + agent = new MusicAgent; + } + return agent; +} + +void MusicAgent::peerFound(SAPPeer *peer) +{ +} + +void MusicAgent::requestConnection(SAPConnectionRequest *request) +{ + qDebug() << "MusicAgent request connection from" << request->peer()->peerName(); + SAPConnection *conn = request->connection(); + new MusicConn(conn, this); + request->accept(); +} + +void MusicAgent::registerServices(SAPManager *manager) +{ + SAPServiceInfo service; + SAPChannelInfo channel; + + service.setProfile(music_profile); + service.setFriendlyName("Media controller"); + service.setRole(SAPServiceInfo::RoleConsumer); + service.setVersion(1, 0); + service.setConnectionTimeout(0); + + channel.setChannelId(100); + channel.setPayloadType(SAPChannelInfo::PayloadJson); + channel.setQoSType(SAPChannelInfo::QoSReliabilityDisable); + channel.setQoSDataRate(SAPChannelInfo::QoSDataRateLow); + channel.setQoSPriority(SAPChannelInfo::QoSPriorityLow); + service.addChannel(channel); + + manager->registerServiceAgent(service, instance()); +} -- cgit v1.2.3