mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-11 16:44:05 +02:00
* Remote-control Tomahawk via the XMPPBot: e.g. 'play Beatles - Yesterday'
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "tomahawk/tomahawkapp.h"
|
#include "tomahawk/tomahawkapp.h"
|
||||||
#include "tomahawk/infosystem.h"
|
#include "tomahawk/infosystem.h"
|
||||||
|
#include "tomahawk/typedefs.h"
|
||||||
#include <tomahawksettings.h>
|
#include <tomahawksettings.h>
|
||||||
#include <audio/audioengine.h>
|
#include <audio/audioengine.h>
|
||||||
|
|
||||||
@@ -131,8 +132,28 @@ void XMPPBot::handleMessage(const Message& msg, MessageSession* session)
|
|||||||
|
|
||||||
QString body = QString::fromStdString( msg.body() );
|
QString body = QString::fromStdString( msg.body() );
|
||||||
QString originatingJid = QString::fromStdString( msg.from().full() );
|
QString originatingJid = QString::fromStdString( msg.from().full() );
|
||||||
QStringList tokens(body.split(QString(" and "), QString::SkipEmptyParts));
|
|
||||||
|
|
||||||
|
if ( body.toLower().startsWith( "play" ) )
|
||||||
|
{
|
||||||
|
QStringList tokens = body.right( body.length() - 5 ).split( QString( "-" ), QString::SkipEmptyParts );
|
||||||
|
|
||||||
|
qDebug() << tokens;
|
||||||
|
|
||||||
|
QVariantMap qv;
|
||||||
|
qv["artist"] = tokens.first().trimmed();
|
||||||
|
qv["track"] = tokens.last().trimmed();
|
||||||
|
Tomahawk::query_ptr q( new Tomahawk::Query( qv ) );
|
||||||
|
connect( q.data(), SIGNAL( resultsAdded( QList<Tomahawk::result_ptr> ) ),
|
||||||
|
SLOT( onResultsAdded( QList<Tomahawk::result_ptr> ) ) );
|
||||||
|
|
||||||
|
QList<Tomahawk::query_ptr> ql;
|
||||||
|
ql.append( q );
|
||||||
|
|
||||||
|
APP->pipeline()->add( ql );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList tokens( body.toLower().split( QString( " and " ), QString::SkipEmptyParts ) );
|
||||||
if ( tokens.isEmpty() )
|
if ( tokens.isEmpty() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -355,6 +376,12 @@ void XMPPBot::infoFinishedSlot(QString caller)
|
|||||||
m_currReturnJid.clear();
|
m_currReturnJid.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void XMPPBot::onResultsAdded( const QList<Tomahawk::result_ptr>& result )
|
||||||
|
{
|
||||||
|
APP->audioEngine()->playItem( 0, result.first() );
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
XMPPBotClient::XMPPBotClient(QObject *parent, JID &jid, std::string password, int port)
|
XMPPBotClient::XMPPBotClient(QObject *parent, JID &jid, std::string password, int port)
|
||||||
|
@@ -63,6 +63,9 @@ protected:
|
|||||||
// MessageHandler
|
// MessageHandler
|
||||||
virtual void handleMessage(const gloox::Message &msg, gloox::MessageSession *session = 0);
|
virtual void handleMessage(const gloox::Message &msg, gloox::MessageSession *session = 0);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void onResultsAdded( const QList<Tomahawk::result_ptr>& result );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QWeakPointer<XMPPBotClient> m_client;
|
QWeakPointer<XMPPBotClient> m_client;
|
||||||
Tomahawk::result_ptr m_currTrack;
|
Tomahawk::result_ptr m_currTrack;
|
||||||
|
Reference in New Issue
Block a user