void server::processPendingDatagrams() { QByteArray datagram; QHostAddress host; quint16 port; do { datagram.resize(udpSocket.pendingDatagramSize()); udpSocket.readDatagram(datagram.data(), datagram.size(),&host,&port); } while (udpSocket.hasPendingDatagrams()); QDataStream in(&datagram, QIODevice::ReadOnly); in.setVersion(QDataStream::Qt_4_1); QString messageType; in >> messageType; if(messageType == "NEW_PLAYER") { QString nick; in >> nick; qDebug() << "New player connected NICKNAME : " << nick << host << port; sendPlayerList(host,port); player *p = new player(&host,&port,&nick); registerPlayer(p); } else if (messageType == "POS_UPDATE") {
void MprisControlPlugin::addPlayer(const QString& service) { QDBusInterface mprisInterface(service, "/org/mpris/MediaPlayer2", "org.mpris.MediaPlayer2"); //FIXME: This call hangs and returns an empty string if KDED is still starting! const QString identity = mprisInterface.property("Identity").toString(); playerList[identity] = service; qCDebug(KDECONNECT_PLUGIN_MPRIS) << "Mpris addPlayer" << service << "->" << identity; sendPlayerList(); OrgFreedesktopDBusPropertiesInterface* freedesktopInterface = new OrgFreedesktopDBusPropertiesInterface(service, "/org/mpris/MediaPlayer2", QDBusConnection::sessionBus(), this); connect(freedesktopInterface, SIGNAL(PropertiesChanged(QString, QVariantMap, QStringList)), this, SLOT(propertiesChanged(QString, QVariantMap))); OrgMprisMediaPlayer2PlayerInterface* mprisInterface0 = new OrgMprisMediaPlayer2PlayerInterface(service, "/org/mpris/MediaPlayer2", QDBusConnection::sessionBus()); connect(mprisInterface0, SIGNAL(Seeked(qlonglong)), this, SLOT(seeked(qlonglong))); }