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