1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-05 05:37:29 +02:00

Display a helpful message when someone gives non-JSON data to the xmpp bot

This commit is contained in:
Jeff Mitchell
2011-03-26 16:49:26 -04:00
parent 8faa782650
commit f16812143f

View File

@@ -24,8 +24,10 @@
#include <QString> #include <QString>
#include <QRegExp> #include <QRegExp>
#include <QThread> #include <QThread>
#include <QVariant>
#include <utils/tomahawkutils.h> #include <utils/tomahawkutils.h>
#include <gloox/capabilities.h> #include <gloox/capabilities.h>
#include <qjson/parser.h>
using namespace gloox; using namespace gloox;
using namespace std; using namespace std;
@@ -428,6 +430,15 @@ Jabber_p::handleMessage( const Message& m, MessageSession * /*session*/ )
//sendMsg( from, QString("You said %1").arg(msg) ); //sendMsg( from, QString("You said %1").arg(msg) );
QJson::Parser parser;
bool ok;
QVariant v = parser.parse( msg.toAscii(), &ok );
if ( !ok || v.type() != QVariant::Map )
{
sendMsg( from, QString( "I'm sorry -- I'm just an automatic presence used by Tomahawk Player (http://gettomahawk.com). If you are getting this message, the person you are trying to reach is probably not signed on, so please try again later!" ) );
return;
}
emit msgReceived( from, msg ); emit msgReceived( from, msg );
} }