From 51789f512051e6e812656b8ee5ccaa5a4e35b05b Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Fri, 29 Oct 2010 12:12:30 +0200 Subject: [PATCH] * Added stop/pause/prev/next commands to XMPPBot. --- src/xmppbot/xmppbot.cpp | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/xmppbot/xmppbot.cpp b/src/xmppbot/xmppbot.cpp index 36959b64c..251ef0e52 100644 --- a/src/xmppbot/xmppbot.cpp +++ b/src/xmppbot/xmppbot.cpp @@ -130,14 +130,14 @@ void XMPPBot::handleMessage(const Message& msg, MessageSession* session) if (msg.subtype() != Message::Chat || msg.from().full().empty() || msg.to().full().empty()) return; - QString body = QString::fromStdString( msg.body() ); + QString body = QString::fromStdString( msg.body() ).toLower().trimmed(); QString originatingJid = QString::fromStdString( msg.from().full() ); - if ( body.toLower().startsWith( "play" ) ) + if ( body.startsWith( "play" ) ) { QStringList tokens = body.right( body.length() - 5 ).split( QString( "-" ), QString::SkipEmptyParts ); - - qDebug() << tokens; + if ( tokens.count() < 2 ) + APP->audioEngine()->play(); QVariantMap qv; qv["artist"] = tokens.first().trimmed(); @@ -152,8 +152,28 @@ void XMPPBot::handleMessage(const Message& msg, MessageSession* session) APP->pipeline()->add( ql ); return; } + else if ( body.startsWith( "stop" ) ) + { + APP->audioEngine()->stop(); + return; + } + else if ( body.startsWith( "prev" ) ) + { + APP->audioEngine()->previous(); + return; + } + else if ( body.startsWith( "next" ) ) + { + APP->audioEngine()->next(); + return; + } + else if ( body.startsWith( "pause" ) ) + { + APP->audioEngine()->pause(); + return; + } - QStringList tokens( body.toLower().split( QString( " and " ), QString::SkipEmptyParts ) ); + QStringList tokens( body.split( QString( " and " ), QString::SkipEmptyParts ) ); if ( tokens.isEmpty() ) return;