1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 14:16:32 +02:00

* Moved more debug output to LOGVERBOSE level.

This commit is contained in:
Christian Muehlhaeuser
2011-09-12 07:58:15 +02:00
parent f48c2c9b5c
commit 5121d060db
6 changed files with 123 additions and 109 deletions

View File

@@ -213,7 +213,7 @@ AudioEngine::next()
bool bool
AudioEngine::canGoNext() AudioEngine::canGoNext()
{ {
tDebug( LOGEXTRA ) << Q_FUNC_INFO; tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
if ( m_queue && m_queue->trackCount() ) if ( m_queue && m_queue->trackCount() )
return true; return true;
@@ -267,13 +267,13 @@ AudioEngine::canSeek()
void void
AudioEngine::seek( qint64 ms ) AudioEngine::seek( qint64 ms )
{ {
if( !canSeek() ) if ( !canSeek() )
{ {
qDebug() << "Could not seek!"; tDebug( LOGEXTRA ) << "Could not seek!";
return; return;
} }
if( isPlaying() || isPaused() ) if ( isPlaying() || isPaused() )
{ {
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << ms; tDebug( LOGVERBOSE ) << Q_FUNC_INFO << ms;
m_mediaObject->seek( ms ); m_mediaObject->seek( ms );

View File

@@ -540,7 +540,6 @@ DatabaseImpl::resultFromHint( const Tomahawk::query_ptr& origquery )
else else
{ {
// Q_ASSERT( false ); // Q_ASSERT( false );
tDebug() << "We don't support non-servent / non-file result-hints yet.";
/* res = Tomahawk::result_ptr( new Tomahawk::Result() ); /* res = Tomahawk::result_ptr( new Tomahawk::Result() );
s = SourceList::instance()->webSource(); s = SourceList::instance()->webSource();
res->setUrl( url ); res->setUrl( url );

View File

@@ -100,38 +100,31 @@ Servent::startListening( QHostAddress ha, bool upnp, int port )
{ {
m_port = port; m_port = port;
int defPort = TomahawkSettings::instance()->defaultPort(); int defPort = TomahawkSettings::instance()->defaultPort();
// Listen on both the selected port and, if not the same, the default port -- the latter sometimes necessary for zeroconf // Listen on both the selected port and, if not the same, the default port -- the latter sometimes necessary for zeroconf
// TODO: only listen on both when zeroconf sip is enabled // TODO: only listen on both when zeroconf sip is enabled
// TODO: use a real zeroconf system instead of a simple UDP broadcast? // TODO: use a real zeroconf system instead of a simple UDP broadcast?
if( !listen( ha, m_port ) ) if ( !listen( ha, m_port ) )
{ {
bool defPortAlso = false; if ( m_port != defPort )
if( m_port != defPort ) {
defPortAlso = listen( ha, defPort ); if ( !listen( ha, defPort ) )
if( !defPortAlso )
{ {
tLog() << "Failed to listen on both port" << m_port << "and port" << defPort; tLog() << "Failed to listen on both port" << m_port << "and port" << defPort;
tLog() << "Error string is" << errorString(); tLog() << "Error string is:" << errorString();
return false; return false;
} }
else else
tLog() << "Servent listening on port" << defPort << "servent thread:" << thread(); m_port = defPort;
} }
else
{
bool defPortAlso = listen( ha, defPort );
tLog() << "Servent listening on port" << m_port << "servent thread:" << thread();
if( defPortAlso )
tLog() << "Servent also listening on port" << defPort << "servent thread:" << thread();
} }
// --lanhack means to advertise your LAN IP over jabber as if it were externallyVisible tLog() << "Servent listening on port" << m_port << "- servent thread:" << thread()
tLog() << "Address mode =" << (int)(TomahawkSettings::instance()->externalAddressMode()); << "- address mode:" << (int)( TomahawkSettings::instance()->externalAddressMode() );
tLog() << "Static host/port preferred =" << ( TomahawkSettings::instance()->preferStaticHostPort() ? "true" : "false" );
if( TomahawkSettings::instance()->preferStaticHostPort() ) // --lanhack means to advertise your LAN IP as if it were externally visible
if ( TomahawkSettings::instance()->preferStaticHostPort() )
{ {
tLog() << "Forcing static preferred host and port";
m_externalHostname = TomahawkSettings::instance()->externalHostname(); m_externalHostname = TomahawkSettings::instance()->externalHostname();
m_externalPort = TomahawkSettings::instance()->externalPort(); m_externalPort = TomahawkSettings::instance()->externalPort();
m_ready = true; m_ready = true;
@@ -181,7 +174,6 @@ Servent::startListening( QHostAddress ha, bool upnp, int port )
QString QString
Servent::createConnectionKey( const QString& name, const QString &nodeid, const QString &key, bool onceOnly ) Servent::createConnectionKey( const QString& name, const QString &nodeid, const QString &key, bool onceOnly )
{ {
// qDebug() << Q_FUNC_INFO;
Q_ASSERT( this->thread() == QThread::currentThread() ); Q_ASSERT( this->thread() == QThread::currentThread() );
QString _key = ( key.isEmpty() ? uuid() : key ); QString _key = ( key.isEmpty() ? uuid() : key );
@@ -191,7 +183,7 @@ Servent::createConnectionKey( const QString& name, const QString &nodeid, const
cc->setId( nodeid ); cc->setId( nodeid );
cc->setOnceOnly( onceOnly ); cc->setOnceOnly( onceOnly );
qDebug() << "Creating connection key with name of" << cc->name() << "and id of" << cc->id() << "and key of" << _key << "; key is once only? :" << (onceOnly ? "true" : "false"); tDebug( LOGVERBOSE ) << "Creating connection key with name of" << cc->name() << "and id of" << cc->id() << "and key of" << _key << "; key is once only? :" << (onceOnly ? "true" : "false");
registerOffer( _key, cc ); registerOffer( _key, cc );
return _key; return _key;
} }
@@ -205,7 +197,7 @@ Servent::setExternalAddress( QHostAddress ha, unsigned int port )
{ {
if ( ip.startsWith( "10." ) || ip.startsWith( "172.16." ) || ip.startsWith( "192.168." ) ) if ( ip.startsWith( "10." ) || ip.startsWith( "172.16." ) || ip.startsWith( "192.168." ) )
{ {
qDebug() << Q_FUNC_INFO << "Tried to set an invalid ip as external address!"; tDebug() << Q_FUNC_INFO << "Tried to set an invalid ip as external address!";
return; return;
} }
@@ -223,10 +215,9 @@ Servent::setExternalAddress( QHostAddress ha, unsigned int port )
if ( !TomahawkSettings::instance()->externalHostname().isEmpty() && if ( !TomahawkSettings::instance()->externalHostname().isEmpty() &&
!TomahawkSettings::instance()->externalPort() == 0 ) !TomahawkSettings::instance()->externalPort() == 0 )
{ {
qDebug() << "UPnP failed, have external address/port -- falling back";
m_externalHostname = TomahawkSettings::instance()->externalHostname(); m_externalHostname = TomahawkSettings::instance()->externalHostname();
m_externalPort = TomahawkSettings::instance()->externalPort(); m_externalPort = TomahawkSettings::instance()->externalPort();
qDebug() << m_externalHostname << m_externalPort; tDebug() << "UPnP failed, have external address/port - falling back" << m_externalHostname << m_externalPort << m_externalAddress;
} }
else else
tLog() << "No external access, LAN and outbound connections only!"; tLog() << "No external access, LAN and outbound connections only!";
@@ -247,7 +238,6 @@ Servent::registerOffer( const QString& key, Connection* conn )
void void
Servent::registerControlConnection( ControlConnection* conn ) Servent::registerControlConnection( ControlConnection* conn )
{ {
// qDebug() << Q_FUNC_INFO << conn->id();
m_controlconnections.append( conn ); m_controlconnections.append( conn );
} }
@@ -281,21 +271,19 @@ Servent::incomingConnection( int sd )
Q_ASSERT( this->thread() == QThread::currentThread() ); Q_ASSERT( this->thread() == QThread::currentThread() );
QTcpSocketExtra* sock = new QTcpSocketExtra; QTcpSocketExtra* sock = new QTcpSocketExtra;
qDebug() << Q_FUNC_INFO << "Accepting connection, sock" << sock; tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Accepting connection, sock" << sock;
sock->moveToThread( thread() ); sock->moveToThread( thread() );
sock->_disowned = false; sock->_disowned = false;
sock->_outbound = false; sock->_outbound = false;
if( !sock->setSocketDescriptor( sd ) ) if( !sock->setSocketDescriptor( sd ) )
{ {
qDebug() << "Out of system resources for new ports?";
Q_ASSERT( false ); Q_ASSERT( false );
return; return;
} }
connect( sock, SIGNAL( readyRead() ), SLOT( readyRead() ) ); connect( sock, SIGNAL( readyRead() ), SLOT( readyRead() ) );
connect( sock, SIGNAL( disconnected() ), sock, SLOT( deleteLater() ) ); connect( sock, SIGNAL( disconnected() ), sock, SLOT( deleteLater() ) );
// qDebug() << "connection accepted.";
} }
@@ -304,12 +292,10 @@ Servent::readyRead()
{ {
Q_ASSERT( this->thread() == QThread::currentThread() ); Q_ASSERT( this->thread() == QThread::currentThread() );
QTcpSocketExtra* sock = (QTcpSocketExtra*)sender(); QTcpSocketExtra* sock = (QTcpSocketExtra*)sender();
//qDebug() << Q_FUNC_INFO << thread() << sock;
if( sock->_disowned ) if( sock->_disowned )
{ {
//qDebug() << "Socket already disowned"; return;
return ;
} }
if( sock->_msg.isNull() ) if( sock->_msg.isNull() )
@@ -336,7 +322,7 @@ Servent::readyRead()
QVariantMap m = parser.parse( sock->_msg->payload(), &ok ).toMap(); QVariantMap m = parser.parse( sock->_msg->payload(), &ok ).toMap();
if( !ok ) if( !ok )
{ {
qDebug() << "Invalid JSON on new conection, aborting"; tDebug() << "Invalid JSON on new connection, aborting";
goto closeconnection; goto closeconnection;
} }
conntype = m.value( "conntype" ).toString(); conntype = m.value( "conntype" ).toString();
@@ -345,13 +331,12 @@ Servent::readyRead()
nodeid = m.value( "nodeid" ).toString(); nodeid = m.value( "nodeid" ).toString();
controlid = m.value( "controlid" ).toString(); controlid = m.value( "controlid" ).toString();
qDebug() << "Incoming connection details:" << m; tDebug( LOGVERBOSE ) << "Incoming connection details:" << m;
if( !nodeid.isEmpty() ) // only control connections send nodeid if( !nodeid.isEmpty() ) // only control connections send nodeid
{ {
foreach( ControlConnection* con, m_controlconnections ) foreach( ControlConnection* con, m_controlconnections )
{ {
// qDebug() << con->socket() << sock;
if( con->id() == nodeid ) if( con->id() == nodeid )
{ {
tLog() << "Duplicate control connection detected, dropping:" << nodeid << conntype; tLog() << "Duplicate control connection detected, dropping:" << nodeid << conntype;
@@ -362,8 +347,6 @@ Servent::readyRead()
foreach( ControlConnection* con, m_controlconnections ) foreach( ControlConnection* con, m_controlconnections )
{ {
// qDebug() << "conid:" << con->id();
if ( con->id() == controlid ) if ( con->id() == controlid )
{ {
cc = con; cc = con;
@@ -381,7 +364,7 @@ Servent::readyRead()
tLog() << "claimOffer FAILED, key:" << key; tLog() << "claimOffer FAILED, key:" << key;
goto closeconnection; goto closeconnection;
} }
qDebug() << "claimOffer OK:" << key; tDebug( LOGVERBOSE ) << "claimOffer OK:" << key;
if( !nodeid.isEmpty() ) if( !nodeid.isEmpty() )
conn->setId( nodeid ); conn->setId( nodeid );
@@ -391,7 +374,7 @@ Servent::readyRead()
} }
else else
{ {
qDebug() << "Invalid or unhandled conntype"; tLog() << "Invalid or unhandled conntype";
} }
// fallthru to cleanup: // fallthru to cleanup:
@@ -407,11 +390,10 @@ closeconnection:
void void
Servent::createParallelConnection( Connection* orig_conn, Connection* new_conn, const QString& key ) Servent::createParallelConnection( Connection* orig_conn, Connection* new_conn, const QString& key )
{ {
qDebug() << "Servent::createParallelConnection, key:" << key << thread() << orig_conn; tDebug( LOGVERBOSE ) << "Servent::createParallelConnection, key:" << key << thread() << orig_conn;
// if we can connect to them directly: // if we can connect to them directly:
if( orig_conn && orig_conn->outbound() ) if( orig_conn && orig_conn->outbound() )
{ {
tLog() << "Connecting directly";
connectToPeer( orig_conn->socket()->peerAddress().toString(), connectToPeer( orig_conn->socket()->peerAddress().toString(),
orig_conn->peerPort(), orig_conn->peerPort(),
key, key,
@@ -441,7 +423,7 @@ Servent::socketConnected()
{ {
QTcpSocketExtra* sock = (QTcpSocketExtra*)sender(); QTcpSocketExtra* sock = (QTcpSocketExtra*)sender();
tDebug() << "Servent::SocketConnected" << thread() << "socket:" << sock; tDebug( LOGVERBOSE ) << "Servent::SocketConnected" << thread() << "socket:" << sock;
Connection* conn = sock->_conn.data(); Connection* conn = sock->_conn.data();
handoverSocket( conn, sock ); handoverSocket( conn, sock );
@@ -503,7 +485,6 @@ Servent::socketError( QAbstractSocket::SocketError e )
void void
Servent::connectToPeer( const QString& ha, int port, const QString &key, const QString& name, const QString& id ) Servent::connectToPeer( const QString& ha, int port, const QString &key, const QString& name, const QString& id )
{ {
qDebug() << Q_FUNC_INFO << ha << port << key << name << id;
Q_ASSERT( this->thread() == QThread::currentThread() ); Q_ASSERT( this->thread() == QThread::currentThread() );
ControlConnection* conn = new ControlConnection( this ); ControlConnection* conn = new ControlConnection( this );
@@ -526,12 +507,11 @@ Servent::connectToPeer( const QString& ha, int port, const QString &key, const Q
void void
Servent::connectToPeer( const QString& ha, int port, const QString &key, Connection* conn ) Servent::connectToPeer( const QString& ha, int port, const QString &key, Connection* conn )
{ {
qDebug() << "Servent::connectToPeer:" << ha << ":" << port tDebug( LOGVERBOSE ) << "Servent::connectToPeer:" << ha << ":" << port
<< thread() << QThread::currentThread(); << thread() << QThread::currentThread();
Q_ASSERT( port > 0 ); Q_ASSERT( port > 0 );
Q_ASSERT( conn ); Q_ASSERT( conn );
// Q_ASSERT( this->thread() == QThread::currentThread() );
if ( ( ha == m_externalAddress.toString() || ha == m_externalHostname ) && if ( ( ha == m_externalAddress.toString() || ha == m_externalHostname ) &&
( port == m_externalPort ) ) ( port == m_externalPort ) )
@@ -554,16 +534,13 @@ Servent::connectToPeer( const QString& ha, int port, const QString &key, Connect
sock->_disowned = false; sock->_disowned = false;
sock->_conn = conn; sock->_conn = conn;
sock->_outbound = true; sock->_outbound = true;
//qDebug() << "connectToPeer, sock:" << sock->thread();
connect( sock, SIGNAL( connected() ), SLOT( socketConnected() ) ); connect( sock, SIGNAL( connected() ), SLOT( socketConnected() ) );
connect( sock, SIGNAL( error( QAbstractSocket::SocketError ) ), connect( sock, SIGNAL( error( QAbstractSocket::SocketError ) ),
SLOT( socketError( QAbstractSocket::SocketError ) ) ); SLOT( socketError( QAbstractSocket::SocketError ) ) );
//qDebug() << "About to connectToHost...";
sock->connectToHost( ha, port, QTcpSocket::ReadWrite ); sock->connectToHost( ha, port, QTcpSocket::ReadWrite );
sock->moveToThread( thread() ); sock->moveToThread( thread() );
//qDebug() << "tried to connectToHost (waiting on a connected signal)";
} }
@@ -572,11 +549,11 @@ Servent::reverseOfferRequest( ControlConnection* orig_conn, const QString& their
{ {
Q_ASSERT( this->thread() == QThread::currentThread() ); Q_ASSERT( this->thread() == QThread::currentThread() );
qDebug() << "Servent::reverseOfferRequest received for" << key; tDebug( LOGVERBOSE ) << "Servent::reverseOfferRequest received for" << key;
Connection* new_conn = claimOffer( orig_conn, theirdbid, key ); Connection* new_conn = claimOffer( orig_conn, theirdbid, key );
if ( !new_conn ) if ( !new_conn )
{ {
qDebug() << "claimOffer failed, killing requesting connection out of spite"; tDebug() << "claimOffer failed, killing requesting connection out of spite";
orig_conn->shutdown(); orig_conn->shutdown();
return; return;
} }
@@ -595,8 +572,6 @@ Servent::reverseOfferRequest( ControlConnection* orig_conn, const QString& their
Connection* Connection*
Servent::claimOffer( ControlConnection* cc, const QString &nodeid, const QString &key, const QHostAddress peer ) Servent::claimOffer( ControlConnection* cc, const QString &nodeid, const QString &key, const QHostAddress peer )
{ {
// qDebug() << Q_FUNC_INFO;
bool noauth = qApp->arguments().contains( "--noauth" ); bool noauth = qApp->arguments().contains( "--noauth" );
// magic key for stream connections: // magic key for stream connections:
@@ -630,14 +605,14 @@ Servent::claimOffer( ControlConnection* cc, const QString &nodeid, const QString
{ {
if( isIPWhitelisted( peer ) ) if( isIPWhitelisted( peer ) )
{ {
qDebug() << "Connection is from whitelisted IP range (LAN)"; tDebug() << "Connection is from whitelisted IP range (LAN)";
Connection* conn = new ControlConnection( this ); Connection* conn = new ControlConnection( this );
conn->setName( peer.toString() ); conn->setName( peer.toString() );
return conn; return conn;
} }
else else
{ {
qDebug() << "Connection claimed to be whitelisted, but wasn't."; tDebug() << "Connection claimed to be whitelisted, but wasn't.";
return NULL; return NULL;
} }
} }
@@ -664,8 +639,6 @@ Servent::claimOffer( ControlConnection* cc, const QString &nodeid, const QString
} }
} }
tLog() << "ACL has allowed the connection";
if( conn->onceOnly() ) if( conn->onceOnly() )
{ {
m_offers.remove( key ); m_offers.remove( key );
@@ -694,7 +667,7 @@ Servent::claimOffer( ControlConnection* cc, const QString &nodeid, const QString
bool bool
Servent::checkACL( const Connection* conn, const QString &nodeid, bool showDialog ) const Servent::checkACL( const Connection* conn, const QString &nodeid, bool showDialog ) const
{ {
qDebug() << "Checking ACLs"; tDebug( LOGVERBOSE ) << "Checking ACLs";
ACLSystem* aclSystem = ACLSystem::instance(); ACLSystem* aclSystem = ACLSystem::instance();
ACLSystem::ACL peerStatus = aclSystem->isAuthorizedUser( nodeid ); ACLSystem::ACL peerStatus = aclSystem->isAuthorizedUser( nodeid );
@@ -709,7 +682,6 @@ Servent::checkACL( const Connection* conn, const QString &nodeid, bool showDialo
if( !showDialog ) if( !showDialog )
return false; return false;
qDebug() << "ACL for this node not found";
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setIcon( QMessageBox::Question ); msgBox.setIcon( QMessageBox::Question );
msgBox.setText( tr( "Incoming Connection Attempt" ) ); msgBox.setText( tr( "Incoming Connection Attempt" ) );
@@ -740,7 +712,7 @@ Servent::checkACL( const Connection* conn, const QString &nodeid, bool showDialo
return true; return true;
//How could we get here? //How could we get here?
qDebug() << "Somehow no button matched"; Q_ASSERT( false );
return false; return false;
} }
#endif #endif
@@ -752,7 +724,6 @@ Servent::checkACL( const Connection* conn, const QString &nodeid, bool showDialo
QSharedPointer<QIODevice> QSharedPointer<QIODevice>
Servent::remoteIODeviceFactory( const result_ptr& result ) Servent::remoteIODeviceFactory( const result_ptr& result )
{ {
// qDebug() << Q_FUNC_INFO << thread();
QSharedPointer<QIODevice> sp; QSharedPointer<QIODevice> sp;
QStringList parts = result->url().mid( QString( "servent://" ).length() ).split( "\t" ); QStringList parts = result->url().mid( QString( "servent://" ).length() ).split( "\t" );
@@ -773,7 +744,7 @@ void
Servent::registerStreamConnection( StreamConnection* sc ) Servent::registerStreamConnection( StreamConnection* sc )
{ {
Q_ASSERT( !m_scsessions.contains( sc ) ); Q_ASSERT( !m_scsessions.contains( sc ) );
qDebug() << "Registering Stream" << m_scsessions.length() + 1; tDebug( LOGVERBOSE ) << "Registering Stream" << m_scsessions.length() + 1;
QMutexLocker lock( &m_ftsession_mut ); QMutexLocker lock( &m_ftsession_mut );
m_scsessions.append( sc ); m_scsessions.append( sc );
@@ -787,7 +758,7 @@ void
Servent::onStreamFinished( StreamConnection* sc ) Servent::onStreamFinished( StreamConnection* sc )
{ {
Q_ASSERT( sc ); Q_ASSERT( sc );
qDebug() << "Stream Finished, unregistering" << sc->id(); tDebug( LOGVERBOSE ) << "Stream Finished, unregistering" << sc->id();
QMutexLocker lock( &m_ftsession_mut ); QMutexLocker lock( &m_ftsession_mut );
m_scsessions.removeAll( sc ); m_scsessions.removeAll( sc );
@@ -824,7 +795,7 @@ Servent::isIPWhitelisted( QHostAddress ip )
<< range( QHostAddress( "169.254.0.0" ), 16 ) << range( QHostAddress( "169.254.0.0" ), 16 )
<< range( QHostAddress( "127.0.0.0" ), 24 ); << range( QHostAddress( "127.0.0.0" ), 24 );
// qDebug() << "Loaded whitelist IP range:" << whitelist; // tDebug( LOGVERBOSE ) << "Loaded whitelist IP range:" << whitelist;
} }
foreach( const range& r, whitelist ) foreach( const range& r, whitelist )
@@ -838,10 +809,8 @@ Servent::isIPWhitelisted( QHostAddress ip )
bool bool
Servent::connectedToSession( const QString& session ) Servent::connectedToSession( const QString& session )
{ {
// qDebug() << "Checking against" << session;
foreach( ControlConnection* cc, m_controlconnections ) foreach( ControlConnection* cc, m_controlconnections )
{ {
// qDebug() << "Checking session" << cc->id();
if( cc->id() == session ) if( cc->id() == session )
return true; return true;
} }
@@ -871,7 +840,6 @@ void
Servent::registerIODeviceFactory( const QString &proto, boost::function<QSharedPointer<QIODevice>(Tomahawk::result_ptr)> fac ) Servent::registerIODeviceFactory( const QString &proto, boost::function<QSharedPointer<QIODevice>(Tomahawk::result_ptr)> fac )
{ {
m_iofactories.insert( proto, fac ); m_iofactories.insert( proto, fac );
qDebug() << "Registered IODevice Factory for" << proto;
} }
@@ -885,10 +853,9 @@ Servent::getIODeviceForUrl( const Tomahawk::result_ptr& result )
return sp; return sp;
const QString proto = rx.cap( 1 ); const QString proto = rx.cap( 1 );
//const QString urlpart = rx.cap( 2 );
// qDebug() << "Getting IODevice for URL:" << proto << m_iofactories.contains( proto );
if ( !m_iofactories.contains( proto ) ) if ( !m_iofactories.contains( proto ) )
return sp; return sp;
return m_iofactories.value( proto )( result ); return m_iofactories.value( proto )( result );
} }

View File

@@ -337,7 +337,7 @@ Pipeline::shunt( const query_ptr& q )
if ( r ) if ( r )
{ {
tLog( LOGEXTRA ) << "Dispatching to resolver" << r->name() << q->toString() << q->solved() << q->id(); tLog( LOGVERBOSE ) << "Dispatching to resolver" << r->name() << q->toString() << q->solved() << q->id();
q->setCurrentResolver( r ); q->setCurrentResolver( r );
r->resolve( q ); r->resolve( q );

View File

@@ -31,6 +31,7 @@
#include "utils/logger.h" #include "utils/logger.h"
BreadcrumbBar::BreadcrumbBar(BreadcrumbButtonFactory *buttonFactory, QWidget *parent) BreadcrumbBar::BreadcrumbBar(BreadcrumbButtonFactory *buttonFactory, QWidget *parent)
: QWidget(parent) : QWidget(parent)
, m_model(0) , m_model(0)
@@ -53,6 +54,7 @@ BreadcrumbBar::BreadcrumbBar(BreadcrumbButtonFactory *buttonFactory, QWidget *pa
show(); show();
} }
BreadcrumbBar::BreadcrumbBar(QWidget *parent) BreadcrumbBar::BreadcrumbBar(QWidget *parent)
: QWidget(parent) : QWidget(parent)
, m_model(0) , m_model(0)
@@ -75,20 +77,25 @@ BreadcrumbBar::BreadcrumbBar(QWidget *parent)
show(); show();
} }
BreadcrumbBar::~BreadcrumbBar() BreadcrumbBar::~BreadcrumbBar()
{ {
} }
void BreadcrumbBar::setButtonFactory(BreadcrumbButtonFactory *buttonFactory) void BreadcrumbBar::setButtonFactory(BreadcrumbButtonFactory *buttonFactory)
{ {
tDebug() << "Breadcrumbbar:: got me some button factory!"; tDebug( LOGVERBOSE ) << "Breadcrumbbar:: got me some button factory!";
m_buttonFactory = buttonFactory; m_buttonFactory = buttonFactory;
} }
BreadcrumbButtonFactory* BreadcrumbBar::buttonFactory() const BreadcrumbButtonFactory* BreadcrumbBar::buttonFactory() const
{ {
return m_buttonFactory; return m_buttonFactory;
} }
void BreadcrumbBar::appendButton(BreadcrumbButtonBase *widget, int stretch) void BreadcrumbBar::appendButton(BreadcrumbButtonBase *widget, int stretch)
{ {
m_layout->insertWidget(m_layout->count(), widget, stretch); m_layout->insertWidget(m_layout->count(), widget, stretch);
@@ -110,6 +117,7 @@ void BreadcrumbBar::appendButton(BreadcrumbButtonBase *widget, int stretch)
} }
} }
void BreadcrumbBar::deleteAnimationFinished() void BreadcrumbBar::deleteAnimationFinished()
{ {
QPropertyAnimation *anim = qobject_cast<QPropertyAnimation*>(sender()); QPropertyAnimation *anim = qobject_cast<QPropertyAnimation*>(sender());
@@ -121,6 +129,7 @@ void BreadcrumbBar::deleteAnimationFinished()
anim->deleteLater(); anim->deleteLater();
} }
void BreadcrumbBar::deleteButton(BreadcrumbButtonBase *widget) void BreadcrumbBar::deleteButton(BreadcrumbButtonBase *widget)
{ {
if( !m_useAnimation ) { if( !m_useAnimation ) {
@@ -144,13 +153,16 @@ void BreadcrumbBar::deleteButton(BreadcrumbButtonBase *widget)
widget->deleteLater(); widget->deleteLater();
} }
} }
void BreadcrumbBar::updateButtons() void BreadcrumbBar::updateButtons()
{ {
tDebug() << "Breadcrumbbar:: updateButtons" << m_buttonFactory << m_selectionModel ; tDebug( LOGVERBOSE ) << "Breadcrumbbar:: updateButtons" << m_buttonFactory << m_selectionModel ;
if(m_selectionModel ) if ( m_selectionModel )
tDebug() <<"Breadcrumbbar:: update buttoms current index"<< m_selectionModel->currentIndex().isValid(); tDebug( LOGVERBOSE ) <<"Breadcrumbbar:: update buttoms current index"<< m_selectionModel->currentIndex().isValid();
if (!m_buttonFactory || !m_selectionModel || !m_selectionModel->currentIndex().isValid()) { if ( !m_buttonFactory || !m_selectionModel || !m_selectionModel->currentIndex().isValid() )
tDebug() << "Breadcrumb:: updatebuttons failed!"; {
tDebug( LOGVERBOSE ) << "Breadcrumb:: updatebuttons failed!";
return; return;
} }
@@ -165,7 +177,7 @@ void BreadcrumbBar::updateButtons()
indexes.prepend(index); indexes.prepend(index);
index = index.parent(); index = index.parent();
} }
tDebug() << "BreadcrumbBar::updateButtons:: " << index.data().toString(); tDebug( LOGVERBOSE ) << "BreadcrumbBar::updateButtons:: " << index.data().toString();
indexes.prepend(index); indexes.prepend(index);
int count = indexes.size(), i = 0; int count = indexes.size(), i = 0;
@@ -205,6 +217,7 @@ void BreadcrumbBar::updateButtons()
adjustSize(); adjustSize();
} }
void BreadcrumbBar::collapseButtons() void BreadcrumbBar::collapseButtons()
{ {
foreach (BreadcrumbButtonBase *button, m_navButtons) { foreach (BreadcrumbButtonBase *button, m_navButtons) {
@@ -224,6 +237,7 @@ void BreadcrumbBar::collapseButtons()
} }
} }
void BreadcrumbBar::clearButtons() void BreadcrumbBar::clearButtons()
{ {
foreach (BreadcrumbButtonBase *button, m_navButtons) foreach (BreadcrumbButtonBase *button, m_navButtons)
@@ -234,11 +248,13 @@ void BreadcrumbBar::clearButtons()
m_navButtons.clear(); m_navButtons.clear();
} }
void BreadcrumbBar::currentIndexChanged() void BreadcrumbBar::currentIndexChanged()
{ {
updateButtons(); updateButtons();
} }
void BreadcrumbBar::setRootIcon(const QIcon &icon) void BreadcrumbBar::setRootIcon(const QIcon &icon)
{ {
@@ -252,6 +268,7 @@ void BreadcrumbBar::setRootIcon(const QIcon &icon)
connect(button, SIGNAL(clicked()), this, SIGNAL(rootClicked())); connect(button, SIGNAL(clicked()), this, SIGNAL(rootClicked()));
} }
void BreadcrumbBar::setRootText(const QString &text) void BreadcrumbBar::setRootText(const QString &text)
{ {
//TODO: implement this //TODO: implement this
@@ -263,27 +280,32 @@ void BreadcrumbBar::setRootText(const QString &text)
m_layout->insertSpacing(2,5);*/ m_layout->insertSpacing(2,5);*/
} }
void BreadcrumbBar::setUseAnimation(bool use) void BreadcrumbBar::setUseAnimation(bool use)
{ {
m_useAnimation = use; m_useAnimation = use;
} }
bool BreadcrumbBar::useAnimation() const bool BreadcrumbBar::useAnimation() const
{ {
return m_useAnimation; return m_useAnimation;
} }
void BreadcrumbBar::setModel(QAbstractItemModel *model) void BreadcrumbBar::setModel(QAbstractItemModel *model)
{ {
m_model = model; m_model = model;
updateButtons(); updateButtons();
} }
QAbstractItemModel* BreadcrumbBar::model() QAbstractItemModel* BreadcrumbBar::model()
{ {
return m_model; return m_model;
} }
void BreadcrumbBar::setSelectionModel(QItemSelectionModel *selectionModel) void BreadcrumbBar::setSelectionModel(QItemSelectionModel *selectionModel)
{ {
m_selectionModel = selectionModel; m_selectionModel = selectionModel;
@@ -294,16 +316,19 @@ void BreadcrumbBar::setSelectionModel(QItemSelectionModel *selectionModel)
updateButtons(); updateButtons();
} }
QItemSelectionModel* BreadcrumbBar::selectionModel() QItemSelectionModel* BreadcrumbBar::selectionModel()
{ {
return m_selectionModel; return m_selectionModel;
} }
QModelIndex BreadcrumbBar::currentIndex() QModelIndex BreadcrumbBar::currentIndex()
{ {
return m_selectionModel->currentIndex(); return m_selectionModel->currentIndex();
} }
void BreadcrumbBar::currentChangedTriggered(QModelIndex const& index) void BreadcrumbBar::currentChangedTriggered(QModelIndex const& index)
{ {
Q_ASSERT(m_selectionModel); Q_ASSERT(m_selectionModel);
@@ -311,6 +336,7 @@ void BreadcrumbBar::currentChangedTriggered(QModelIndex const& index)
emit currentIndexChanged(index); emit currentIndexChanged(index);
} }
void BreadcrumbBar::resizeEvent ( QResizeEvent * event ) void BreadcrumbBar::resizeEvent ( QResizeEvent * event )
{ {
collapseButtons(); collapseButtons();

View File

@@ -46,6 +46,7 @@ using namespace Tomahawk;
static QString s_whatsHotIdentifier = QString( "WhatsHotWidget" ); static QString s_whatsHotIdentifier = QString( "WhatsHotWidget" );
WhatsHotWidget::WhatsHotWidget( QWidget* parent ) WhatsHotWidget::WhatsHotWidget( QWidget* parent )
: QWidget( parent ) : QWidget( parent )
, ui( new Ui::WhatsHotWidget ) , ui( new Ui::WhatsHotWidget )
@@ -127,6 +128,7 @@ WhatsHotWidget::~WhatsHotWidget()
delete ui; delete ui;
} }
void void
WhatsHotWidget::fetchData() WhatsHotWidget::fetchData()
{ {
@@ -140,7 +142,7 @@ WhatsHotWidget::fetchData()
requestData.type = Tomahawk::InfoSystem::InfoChartCapabilities; requestData.type = Tomahawk::InfoSystem::InfoChartCapabilities;
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData ); Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
tDebug() << "WhatsHot: requested InfoChartCapabilities"; tDebug( LOGVERBOSE ) << "WhatsHot: requested InfoChartCapabilities";
} }
@@ -160,20 +162,21 @@ WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDat
return; return;
} }
tDebug() << "WhatsHot: got something..."; tDebug( LOGVERBOSE ) << "WhatsHot: got something...";
QVariantMap returnedData = output.toMap(); QVariantMap returnedData = output.toMap();
switch ( requestData.type ) switch ( requestData.type )
{ {
case InfoSystem::InfoChartCapabilities: case InfoSystem::InfoChartCapabilities:
{ {
tDebug() << "WhatsHot:: info chart capabilities"; tDebug( LOGVERBOSE ) << "WhatsHot:: info chart capabilities";
QStandardItem *rootItem= m_crumbModelLeft->invisibleRootItem(); QStandardItem *rootItem= m_crumbModelLeft->invisibleRootItem();
tDebug() << "WhatsHot:: " << returnedData.keys(); tDebug( LOGVERBOSE ) << "WhatsHot:: " << returnedData.keys();
foreach(const QString label, returnedData.keys()) { foreach( const QString label, returnedData.keys() )
tDebug() << "WhatsHot:: parsing " << label; {
tDebug( LOGVERBOSE ) << "WhatsHot:: parsing " << label;
QStandardItem *childItem = parseNode( rootItem, label, returnedData[label] ); QStandardItem *childItem = parseNode( rootItem, label, returnedData[label] );
tDebug() << "WhatsHot:: appending" << childItem->text(); tDebug( LOGVERBOSE ) << "WhatsHot:: appending" << childItem->text();
rootItem->appendRow(childItem); rootItem->appendRow(childItem);
} }
KBreadcrumbSelectionModel *selectionModelLeft = new KBreadcrumbSelectionModel(new QItemSelectionModel(m_crumbModelLeft, this), this); KBreadcrumbSelectionModel *selectionModelLeft = new KBreadcrumbSelectionModel(new QItemSelectionModel(m_crumbModelLeft, this), this);
@@ -192,28 +195,36 @@ WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDat
if( !returnedData.contains(type) ) if( !returnedData.contains(type) )
break; break;
const QString side = requestData.customData["whatshot_side"].toString(); const QString side = requestData.customData["whatshot_side"].toString();
tDebug() << "WhatsHot: got chart! " << type << " on " << side;
if( type == "artists" ) { tDebug( LOGVERBOSE ) << "WhatsHot: got chart! " << type << " on " << side;
if( type == "artists" )
{
setLeftViewArtists(); setLeftViewArtists();
const QStringList artists = returnedData["artists"].toStringList(); const QStringList artists = returnedData["artists"].toStringList();
tDebug() << "WhatsHot: got artists! " << artists.size(); tDebug( LOGVERBOSE ) << "WhatsHot: got artists! " << artists.size();
m_artistsModel->clear(); m_artistsModel->clear();
foreach ( const QString& artist, artists ) foreach ( const QString& artist, artists )
m_artistsModel->addArtists( Artist::get( artist ) ); m_artistsModel->addArtists( Artist::get( artist ) );
} else if( type == "tracks" ) { }
else if( type == "tracks" )
{
setLeftViewTracks(); setLeftViewTracks();
const QList<Tomahawk::InfoSystem::ArtistTrackPair> tracks = returnedData["tracks"].value<QList<Tomahawk::InfoSystem::ArtistTrackPair> >(); const QList<Tomahawk::InfoSystem::ArtistTrackPair> tracks = returnedData["tracks"].value<QList<Tomahawk::InfoSystem::ArtistTrackPair> >();
tDebug() << "WhatsHot: got tracks! " << tracks.size(); tDebug( LOGVERBOSE ) << "WhatsHot: got tracks! " << tracks.size();
m_tracksModel->clear(); m_tracksModel->clear();
foreach ( const Tomahawk::InfoSystem::ArtistTrackPair& track, tracks ) { foreach ( const Tomahawk::InfoSystem::ArtistTrackPair& track, tracks )
{
query_ptr query = Query::get( track.artist, track.track, QString(), uuid() ); query_ptr query = Query::get( track.artist, track.track, QString(), uuid() );
m_tracksModel->append( query ); m_tracksModel->append( query );
} }
} else { }
tDebug() << "WhatsHot: got unknown chart type" << type; else
{
tDebug( LOGVERBOSE ) << "WhatsHot: got unknown chart type" << type;
} }
break; break;
} }
default: default:
return; return;
} }
@@ -230,7 +241,7 @@ WhatsHotWidget::infoSystemFinished( QString target )
void void
WhatsHotWidget::leftCrumbIndexChanged( QModelIndex index ) WhatsHotWidget::leftCrumbIndexChanged( QModelIndex index )
{ {
qDebug() << "WhatsHot:: left crumb changed" << index.data(); tDebug( LOGVERBOSE ) << "WhatsHot:: left crumb changed" << index.data();
QStandardItem* item = m_crumbModelLeft->itemFromIndex(index); QStandardItem* item = m_crumbModelLeft->itemFromIndex(index);
if( !item ) if( !item )
return; return;
@@ -254,6 +265,7 @@ WhatsHotWidget::leftCrumbIndexChanged( QModelIndex index )
Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData ); Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData );
} }
void void
WhatsHotWidget::changeEvent( QEvent* e ) WhatsHotWidget::changeEvent( QEvent* e )
{ {
@@ -273,42 +285,52 @@ WhatsHotWidget::changeEvent( QEvent* e )
QStandardItem* QStandardItem*
WhatsHotWidget::parseNode(QStandardItem* parentItem, const QString &label, const QVariant &data) WhatsHotWidget::parseNode(QStandardItem* parentItem, const QString &label, const QVariant &data)
{ {
tDebug() << "WhatsHot:: parsing " << label; tDebug( LOGVERBOSE ) << "WhatsHot:: parsing " << label;
QStandardItem *sourceItem = new QStandardItem(label); QStandardItem *sourceItem = new QStandardItem(label);
if( data.canConvert<QList<Tomahawk::InfoSystem::Chart> >() ) { if( data.canConvert<QList<Tomahawk::InfoSystem::Chart> >() )
{
QList<Tomahawk::InfoSystem::Chart> charts = data.value<QList<Tomahawk::InfoSystem::Chart> >(); QList<Tomahawk::InfoSystem::Chart> charts = data.value<QList<Tomahawk::InfoSystem::Chart> >();
foreach( Tomahawk::InfoSystem::Chart chart, charts) { foreach( Tomahawk::InfoSystem::Chart chart, charts)
{
QStandardItem *childItem= new QStandardItem(chart.label); QStandardItem *childItem= new QStandardItem(chart.label);
childItem->setData(chart.id); childItem->setData(chart.id);
sourceItem->appendRow(childItem); sourceItem->appendRow(childItem);
} }
} else if( data.canConvert<QVariantMap>() ) { } else if( data.canConvert<QVariantMap>() )
{
QVariantMap dataMap = data.toMap(); QVariantMap dataMap = data.toMap();
foreach(const QString childLabel,dataMap.keys()) { foreach(const QString childLabel,dataMap.keys())
{
QStandardItem *childItem = parseNode( sourceItem, childLabel, dataMap[childLabel] ); QStandardItem *childItem = parseNode( sourceItem, childLabel, dataMap[childLabel] );
sourceItem->appendRow(childItem); sourceItem->appendRow(childItem);
} }
} else if ( data.canConvert<QVariantList>() ) { } else if ( data.canConvert<QVariantList>() )
{
QVariantList dataList = data.toList(); QVariantList dataList = data.toList();
foreach(const QVariant value, dataList) { foreach(const QVariant value, dataList)
{
QStandardItem *childItem= new QStandardItem(value.toString()); QStandardItem *childItem= new QStandardItem(value.toString());
sourceItem->appendRow(childItem); sourceItem->appendRow(childItem);
} }
} else { }
else
{
QStandardItem *childItem= new QStandardItem(data.toString()); QStandardItem *childItem= new QStandardItem(data.toString());
sourceItem->appendRow(childItem); sourceItem->appendRow(childItem);
} }
return sourceItem; return sourceItem;
} }
void void
WhatsHotWidget::setLeftViewArtists() WhatsHotWidget::setLeftViewArtists()
{ {
ui->stackLeft->setCurrentIndex(1); ui->stackLeft->setCurrentIndex(1);
} }
void void
WhatsHotWidget::setLeftViewTracks() WhatsHotWidget::setLeftViewTracks()
{ {