diff options
m--------- | libwatchfish | 0 | ||||
-rw-r--r-- | main.cc | 2 | ||||
-rw-r--r-- | musicagent.cc | 55 | ||||
-rw-r--r-- | musicagent.h | 26 | ||||
-rw-r--r-- | musicconn.cc | 30 | ||||
-rw-r--r-- | musicconn.h | 26 | ||||
-rw-r--r-- | sapd.pro | 8 | ||||
-rw-r--r-- | webproxyagent.cc | 1 |
8 files changed, 145 insertions, 3 deletions
diff --git a/libwatchfish b/libwatchfish -Subproject b91c2c3aff5c91d6afb2b9fa2f3ceceaf0642d2 +Subproject ffeca2b8740fba10e916fe04e89ef2fd5c606a9 @@ -9,6 +9,7 @@ #include "hostmanageragent.h" #include "webproxyagent.h" #include "notificationagent.h" +#include "musicagent.h" using std::cerr; using std::endl; @@ -47,6 +48,7 @@ int main(int argc, char *argv[]) HostManagerAgent::registerServices(manager); WebProxyAgent::registerServices(manager); NotificationAgent::registerServices(manager); + MusicAgent::registerServices(manager); QScopedPointer<SAPBTListener> sap_listener(new SAPBTListener); 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()); +} diff --git a/musicagent.h b/musicagent.h new file mode 100644 index 0000000..32121d4 --- /dev/null +++ b/musicagent.h @@ -0,0 +1,26 @@ +#ifndef MUSICAGENT_H +#define MUSICAGENT_H + +#include <QtCore/QObject> +#include "sappeer.h" +#include "sapmanager.h" +#include "sapagent.h" + +class MusicAgent : public QObject, public SAPAgent +{ +public: + explicit MusicAgent(QObject *parent = 0); + +public: + static MusicAgent * instance(); + static void registerServices(SAPManager *manager); + + void peerFound(SAPPeer *peer); + void requestConnection(SAPConnectionRequest *request); + +private: + SAPPeer *_peer; + SAPSocket *_socket; +}; + +#endif // MUSICAGENT_H diff --git a/musicconn.cc b/musicconn.cc new file mode 100644 index 0000000..256e6a8 --- /dev/null +++ b/musicconn.cc @@ -0,0 +1,30 @@ +#include <QtCore/QDebug> + +#include "sappeer.h" +#include "musicconn.h" + +#if SAILFISH +#include "libwatchfish/musiccontroller.h" + +static watchfish::MusicController *controller = 0; +#endif + +MusicConn::MusicConn(SAPConnection *conn, QObject *parent) + : QObject(parent), _conn(conn), _socket(conn->getSocket(100)) +{ + connect(_conn, SIGNAL(disconnected()), SLOT(deleteLater())); + connect(_conn, SIGNAL(destroyed()), SLOT(deleteLater())); + Q_ASSERT(_socket); + connect(_socket, SIGNAL(connected()), SLOT(handleConnected())); + connect(_socket, SIGNAL(messageReceived()), SLOT(handleMessageReceived())); +} + +void MusicConn::handleConnected() +{ + +} + +void MusicConn::handleMessageReceived() +{ + +} diff --git a/musicconn.h b/musicconn.h new file mode 100644 index 0000000..a38bf94 --- /dev/null +++ b/musicconn.h @@ -0,0 +1,26 @@ +#ifndef MUSICCONN_H +#define MUSICCONN_H + +#include <QtCore/QObject> +#include "sapconnection.h" +#include "sapsocket.h" + +class MusicConn : public QObject +{ + Q_OBJECT + +public: + MusicConn(SAPConnection *conn, QObject *parent = 0); + +protected: + +private slots: + void handleConnected(); + void handleMessageReceived(); + +private: + SAPConnection *_conn; + SAPSocket *_socket; +}; + +#endif // MUSICCONN_H @@ -59,7 +59,9 @@ SOURCES += main.cc \ notificationconn.cc \ webproxyagent.cc \ webproxyconn.cc \ - webproxytrans.cc + webproxytrans.cc \ + musicagent.cc \ + musicconn.cc HEADERS += \ sapbtlistener.h \ @@ -86,7 +88,9 @@ HEADERS += \ endianhelpers.h \ webproxyagent.h \ webproxyconn.h \ - webproxytrans.h + webproxytrans.h \ + musicagent.h \ + musicconn.h OTHER_FILES += \ rpm/sapd.yaml \ diff --git a/webproxyagent.cc b/webproxyagent.cc index 126cd75..0b1a753 100644 --- a/webproxyagent.cc +++ b/webproxyagent.cc @@ -23,7 +23,6 @@ WebProxyAgent* WebProxyAgent::instance() void WebProxyAgent::peerFound(SAPPeer *peer) { - qDebug() << "WebProxy peer found" << peer->peerName(); } void WebProxyAgent::requestConnection(SAPConnectionRequest *request) |