From f82b81e001807d40957d33714a44ac0a41ac8186 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Fri, 9 Nov 2012 05:59:22 +0100 Subject: [PATCH] * Style and logging clean-ups. --- src/AclRegistryImpl.cpp | 26 +++--- .../generic/newreleases/NewReleasesPlugin.cpp | 65 ++++++++++---- src/libtomahawk/database/Database.cpp | 12 +-- src/libtomahawk/network/Connection.cpp | 90 +++++++++---------- src/libtomahawk/network/DbSyncConnection.cpp | 2 +- src/libtomahawk/utils/TomahawkUtils.cpp | 40 ++++----- src/libtomahawk/widgets/FadingPixmap.cpp | 2 +- src/libtomahawk/widgets/NewReleasesWidget.cpp | 10 +-- 8 files changed, 137 insertions(+), 110 deletions(-) diff --git a/src/AclRegistryImpl.cpp b/src/AclRegistryImpl.cpp index 3c2ba2f7b..0ecde655d 100644 --- a/src/AclRegistryImpl.cpp +++ b/src/AclRegistryImpl.cpp @@ -56,7 +56,6 @@ ACLRegistryImpl::~ACLRegistryImpl() ACLRegistry::ACL ACLRegistryImpl::isAuthorizedUser( const QString& dbid, const QString &username, ACLRegistry::ACL globalType, bool skipEmission ) { - tLog() << Q_FUNC_INFO; if ( QThread::currentThread() != TOMAHAWK_APPLICATION::instance()->thread() ) { if ( !skipEmission ) @@ -153,7 +152,7 @@ ACLRegistryImpl::getUserDecision( ACLRegistry::User user, const QString &usernam if ( TomahawkUtils::headless() ) return; - tLog() << Q_FUNC_INFO; + tDebug( LOGVERBOSE ) << Q_FUNC_INFO; ACLJobItem* job = new ACLJobItem( user, username ); m_jobQueue.enqueue( job ); QTimer::singleShot( 0, this, SLOT( queueNextJob() ) ); @@ -166,7 +165,7 @@ ACLRegistryImpl::userDecision( ACLRegistry::User user ) if ( TomahawkUtils::headless() ) return; - tLog() << Q_FUNC_INFO; + tDebug( LOGVERBOSE ) << Q_FUNC_INFO; m_cache.append( user ); save(); emit aclResult( user.knownDbids.first(), user.knownAccountIds.first(), user.acl ); @@ -188,8 +187,9 @@ ACLRegistryImpl::queueNextJob() QMetaObject::invokeMethod( this, "queueNextJob", Qt::QueuedConnection ); return; } - tLog() << Q_FUNC_INFO << "jobCount =" << m_jobCount; - tLog() << Q_FUNC_INFO << "jobQueue size =" << m_jobQueue.length(); + + tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "jobCount =" << m_jobCount; + tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "jobQueue size =" << m_jobQueue.length(); if ( m_jobCount != 0 ) return; @@ -203,21 +203,21 @@ ACLRegistryImpl::queueNextJob() ACLRegistry::ACL acl = isAuthorizedUser( dbid, job->username(), ACLRegistry::NotFound, true ); if ( acl != ACLRegistry::NotFound ) { - tLog() << Q_FUNC_INFO << "Found existing acl entry for =" << user.knownAccountIds.first(); + tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Found existing acl entry for =" << user.knownAccountIds.first(); found = true; break; } } if ( found ) { - tLog() << Q_FUNC_INFO << "deleting job, already have ACL for" << user.knownAccountIds.first(); + tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "deleting job, already have ACL for" << user.knownAccountIds.first(); delete job; QTimer::singleShot( 0, this, SLOT( queueNextJob() ) ); return; } else { - tLog() << Q_FUNC_INFO << "activating job for user" << user.knownAccountIds.first(); + tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "activating job for user" << user.knownAccountIds.first(); m_jobCount++; JobStatusView::instance()->model()->addJob( job ); connect( job, SIGNAL( userDecision( ACLRegistry::User ) ), this, SLOT( userDecision( ACLRegistry::User ) ) ); @@ -238,19 +238,19 @@ ACLRegistryImpl::wipeEntries() void ACLRegistryImpl::load() { - tLog() << Q_FUNC_INFO; + tDebug( LOGVERBOSE ) << Q_FUNC_INFO; QVariantList entryList = TomahawkSettings::instance()->aclEntries(); foreach ( QVariant entry, entryList ) { if ( !entry.isValid() || !entry.canConvert< ACLRegistry::User >() ) { - tLog() << Q_FUNC_INFO << "entry is invalid"; + tDebug() << Q_FUNC_INFO << "entry is invalid"; continue; } ACLRegistry::User entryUser = entry.value< ACLRegistry::User >(); if ( entryUser.knownAccountIds.empty() || entryUser.knownDbids.empty() ) { - tLog() << Q_FUNC_INFO << "user known account/dbids is empty"; + tDebug() << Q_FUNC_INFO << "user known account/dbids is empty"; continue; } m_cache.append( entryUser ); @@ -261,11 +261,11 @@ ACLRegistryImpl::load() void ACLRegistryImpl::save() { - tLog() << Q_FUNC_INFO; + tDebug( LOGVERBOSE ) << Q_FUNC_INFO; QVariantList entryList; foreach ( ACLRegistry::User user, m_cache ) { - tLog() << Q_FUNC_INFO << "user is" << user.uuid << "with known name" << user.knownAccountIds.first(); + tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "user is" << user.uuid << "with known name" << user.knownAccountIds.first(); QVariant val = QVariant::fromValue< ACLRegistry::User >( user ); if ( val.isValid() ) entryList.append( val ); diff --git a/src/infoplugins/generic/newreleases/NewReleasesPlugin.cpp b/src/infoplugins/generic/newreleases/NewReleasesPlugin.cpp index 82a0d05e8..d5d56a452 100644 --- a/src/infoplugins/generic/newreleases/NewReleasesPlugin.cpp +++ b/src/infoplugins/generic/newreleases/NewReleasesPlugin.cpp @@ -24,7 +24,9 @@ using namespace Tomahawk::InfoSystem; -bool newReleaseSort( const InfoStringHash& left, const InfoStringHash& right ) + +bool +newReleaseSort( const InfoStringHash& left, const InfoStringHash& right ) { if ( !left.contains( "date" ) || !right.contains( "date" ) ) { @@ -46,15 +48,16 @@ NewReleasesPlugin::NewReleasesPlugin() m_supportedGetTypes << InfoNewReleaseCapabilities << InfoNewRelease; } + NewReleasesPlugin::~NewReleasesPlugin() { tDebug ( LOGVERBOSE ) << Q_FUNC_INFO; } + void NewReleasesPlugin::init() { - QVariantList source_qvarlist = TomahawkUtils::Cache::instance()->getData( "NewReleasesPlugin", "nr_sources" ).toList(); foreach( const QVariant & source, source_qvarlist ) { @@ -67,15 +70,19 @@ NewReleasesPlugin::init() fetchNRSourcesList( true ); } -void NewReleasesPlugin::dataError ( InfoRequestData requestData ) + +void +NewReleasesPlugin::dataError( InfoRequestData requestData ) { emit info ( requestData, QVariant() ); return; } -void NewReleasesPlugin::getInfo ( InfoRequestData requestData ) + +void +NewReleasesPlugin::getInfo( InfoRequestData requestData ) { -//qDebug() << Q_FUNC_INFO << requestData.caller; + //qDebug() << Q_FUNC_INFO << requestData.caller; //qDebug() << Q_FUNC_INFO << requestData.customData; InfoStringHash hash = requestData.input.value< Tomahawk::InfoSystem::InfoStringHash >(); @@ -114,12 +121,15 @@ void NewReleasesPlugin::getInfo ( InfoRequestData requestData ) case InfoNewReleaseCapabilities: fetchNRCapabilitiesFromCache ( requestData ); break; + default: dataError ( requestData ); } } -void NewReleasesPlugin::fetchNRFromCache ( InfoRequestData requestData ) + +void +NewReleasesPlugin::fetchNRFromCache( InfoRequestData requestData ) { if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() ) { @@ -145,7 +155,9 @@ void NewReleasesPlugin::fetchNRFromCache ( InfoRequestData requestData ) emit getCachedInfo ( criteria, 86400000, requestData ); } -void NewReleasesPlugin::fetchNRCapabilitiesFromCache ( InfoRequestData requestData ) + +void +NewReleasesPlugin::fetchNRCapabilitiesFromCache( InfoRequestData requestData ) { if ( !requestData.input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() ) { @@ -160,7 +172,9 @@ void NewReleasesPlugin::fetchNRCapabilitiesFromCache ( InfoRequestData requestDa emit getCachedInfo ( criteria, 864000000, requestData ); } -void NewReleasesPlugin::notInCacheSlot ( InfoStringHash criteria, InfoRequestData requestData ) + +void +NewReleasesPlugin::notInCacheSlot( InfoStringHash criteria, InfoRequestData requestData ) { switch ( requestData.type ) { @@ -190,7 +204,9 @@ void NewReleasesPlugin::notInCacheSlot ( InfoStringHash criteria, InfoRequestDat } } -void NewReleasesPlugin::fetchNRSourcesList( bool fetchOnlySourcesList ) + +void +NewReleasesPlugin::fetchNRSourcesList( bool fetchOnlySourcesList ) { QUrl url = QUrl ( QString ( CHART_URL "newreleases" ) ); @@ -203,9 +219,11 @@ void NewReleasesPlugin::fetchNRSourcesList( bool fetchOnlySourcesList ) } -void NewReleasesPlugin::nrSourcesList() + +void +NewReleasesPlugin::nrSourcesList() { - tDebug ( LOGVERBOSE ) << "Got newreleases sources list"; + tDebug ( LOGVERBOSE ) << "Got newreleases sources list"; QNetworkReply* reply = qobject_cast ( sender() ); if ( reply->error() == QNetworkReply::NoError ) @@ -232,7 +250,9 @@ void NewReleasesPlugin::nrSourcesList() } } -void NewReleasesPlugin::fetchAllNRSources() + +void +NewReleasesPlugin::fetchAllNRSources() { if ( !m_nrSources.isEmpty() && m_allNRsMap.isEmpty() ) { @@ -251,7 +271,9 @@ void NewReleasesPlugin::fetchAllNRSources() } } -void NewReleasesPlugin::fetchNR ( InfoRequestData requestData, const QString& source, const QString& nr_id ) + +void +NewReleasesPlugin::fetchNR( InfoRequestData requestData, const QString& source, const QString& nr_id ) { /// Fetch the chart, we need source and id QUrl url = QUrl ( QString ( CHART_URL "newreleases/%1/%2" ).arg ( source ).arg ( nr_id ) ); @@ -263,9 +285,11 @@ void NewReleasesPlugin::fetchNR ( InfoRequestData requestData, const QString& so connect ( reply, SIGNAL ( finished() ), SLOT ( nrReturned() ) ); } -void NewReleasesPlugin::nrList() + +void +NewReleasesPlugin::nrList() { - tDebug ( LOGVERBOSE ) << "Got newreleases list result"; + tDebug ( LOGVERBOSE ) << "Got newreleases list result"; QNetworkReply* reply = qobject_cast ( sender() ); if ( reply->error() == QNetworkReply::NoError ) @@ -347,7 +371,9 @@ void NewReleasesPlugin::nrList() QVariantMap defaultMap = m_allNRsMap.value ( "defaults" ).value< QVariantMap >(); m_allNRsMap.insert ( nrName, QVariant::fromValue< QVariantMap > ( newreleases ) ); - } else { + } + else + { tLog() << "Error fetching charts:" << reply->errorString(); } @@ -367,7 +393,9 @@ void NewReleasesPlugin::nrList() } } -void NewReleasesPlugin::nrReturned() + +void +NewReleasesPlugin::nrReturned() { /// Chart request returned something! Woho QNetworkReply* reply = qobject_cast ( sender() ); @@ -420,7 +448,8 @@ void NewReleasesPlugin::nrReturned() criteria[ "nr_id" ] = origData[ "nr_id" ]; criteria[ "nr_source" ] = origData[ "nr_source" ]; emit updateCache( criteria, 86400000, requestData.type, returnedData ); - } else + } + else tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Network error in fetching newrelease:" << reply->url().toString(); } diff --git a/src/libtomahawk/database/Database.cpp b/src/libtomahawk/database/Database.cpp index 5d6ce5a21..a73072473 100644 --- a/src/libtomahawk/database/Database.cpp +++ b/src/libtomahawk/database/Database.cpp @@ -53,7 +53,7 @@ Database::Database( const QString& dbname, QObject* parent ) else m_maxConcurrentThreads = qBound( DEFAULT_WORKER_THREADS, QThread::idealThreadCount(), MAX_WORKER_THREADS ); - tDebug() << Q_FUNC_INFO << "Using" << m_maxConcurrentThreads << "database worker threads; current (GUI) thread is " << QThread::currentThread(); + tDebug() << Q_FUNC_INFO << "Using" << m_maxConcurrentThreads << "database worker threads"; connect( m_impl, SIGNAL( indexReady() ), SIGNAL( indexReady() ) ); connect( m_impl, SIGNAL( indexReady() ), SIGNAL( ready() ) ); @@ -75,7 +75,7 @@ Database::Database( const QString& dbname, QObject* parent ) Database::~Database() { - qDebug() << Q_FUNC_INFO; + tDebug( LOGVERBOSE ) << Q_FUNC_INFO; m_idWorker->stop(); delete m_idWorker; @@ -120,7 +120,7 @@ void Database::enqueue( const QList< QSharedPointer >& lc ) { Q_ASSERT( m_ready ); - qDebug() << "Enqueueing" << lc.count() << "commands to rw thread"; + tDebug( LOGVERBOSE ) << "Enqueueing" << lc.count() << "commands to rw thread"; if ( m_workerRW && m_workerRW.data()->worker() ) m_workerRW.data()->worker().data()->enqueue( lc ); } @@ -132,7 +132,7 @@ Database::enqueue( const QSharedPointer& lc ) Q_ASSERT( m_ready ); if ( lc->doesMutates() ) { - qDebug() << "Enqueueing command to rw thread:" << lc->commandname(); + tDebug( LOGVERBOSE ) << "Enqueueing command to rw thread:" << lc->commandname(); if ( m_workerRW && m_workerRW.data()->worker() ) m_workerRW.data()->worker().data()->enqueue( lc ); } @@ -158,7 +158,7 @@ Database::enqueue( const QSharedPointer& lc ) happyWorker = workerThread.data()->worker(); } -// qDebug() << "Enqueueing command to thread:" << happyThread << busyThreads << lc->commandname(); +// tDebug( LOGVERBOSE ) << "Enqueueing command to thread:" << happyThread << busyThreads << lc->commandname(); Q_ASSERT( happyWorker ); happyWorker.data()->enqueue( lc ); } @@ -173,7 +173,7 @@ Database::impl() QThread* thread = QThread::currentThread(); if ( !m_implHash.contains( thread ) ) { - tDebug() << Q_FUNC_INFO << "Creating database impl for thread" << QThread::currentThread(); + tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Creating database impl for thread" << QThread::currentThread(); DatabaseImpl* impl = m_impl->clone(); m_implHash.insert( thread, impl ); } diff --git a/src/libtomahawk/network/Connection.cpp b/src/libtomahawk/network/Connection.cpp index 84defad29..511bcaa3c 100644 --- a/src/libtomahawk/network/Connection.cpp +++ b/src/libtomahawk/network/Connection.cpp @@ -50,7 +50,7 @@ Connection::Connection( Servent* parent ) , m_tx_bytes_last( 0 ) { moveToThread( m_servent->thread() ); - qDebug() << "CTOR Connection (super)" << thread(); + tDebug( LOGVERBOSE ) << "CTOR Connection (super)" << thread(); connect( &m_msgprocessor_out, SIGNAL( ready( msg_ptr ) ), SLOT( sendMsg_now( msg_ptr ) ), Qt::QueuedConnection ); @@ -65,10 +65,9 @@ Connection::Connection( Servent* parent ) Connection::~Connection() { - tDebug() << "DTOR connection (super)" << id() << thread() << m_sock.isNull(); - if( !m_sock.isNull() ) + tDebug( LOGVERBOSE ) << "DTOR connection (super)" << id() << thread() << m_sock.isNull(); + if ( !m_sock.isNull() ) { -// qDebug() << "deleteLatering sock" << m_sock; m_sock->deleteLater(); } @@ -84,11 +83,11 @@ Connection::handleIncomingQueueEmpty() // << "m_peer_disconnected" << m_peer_disconnected // << "bytes rx" << bytesReceived(); - if( !m_sock.isNull() && m_sock->bytesAvailable() == 0 && m_peer_disconnected ) + if ( !m_sock.isNull() && m_sock->bytesAvailable() == 0 && m_peer_disconnected ) { - qDebug() << "No more data to read, peer disconnected. shutting down connection." - << "bytesavail" << m_sock->bytesAvailable() - << "bytesrx" << m_rx_bytes; + tDebug( LOGVERBOSE ) << "No more data to read, peer disconnected. shutting down connection." + << "bytesavail" << m_sock->bytesAvailable() + << "bytesrx" << m_rx_bytes; shutdown(); } } @@ -117,7 +116,7 @@ Connection::setFirstMessage( msg_ptr m ) void Connection::shutdown( bool waitUntilSentAll ) { - qDebug() << Q_FUNC_INFO << waitUntilSentAll << id(); + tDebug( LOGVERBOSE ) << Q_FUNC_INFO << waitUntilSentAll << id(); if ( m_do_shutdown ) { //qDebug() << id() << " already shutting down"; @@ -132,8 +131,8 @@ Connection::shutdown( bool waitUntilSentAll ) } else { - qDebug() << "Shutting down after transfer complete " << id() - << "Actual/Desired" << m_tx_bytes << m_tx_bytes_requested; + tDebug( LOGVERBOSE ) << "Shutting down after transfer complete " << id() + << "Actual/Desired" << m_tx_bytes << m_tx_bytes_requested; bytesWritten( 0 ); // trigger shutdown if we've already sent everything // otherwise the bytesWritten slot will call actualShutdown() @@ -145,7 +144,7 @@ Connection::shutdown( bool waitUntilSentAll ) void Connection::actualShutdown() { - qDebug() << Q_FUNC_INFO << m_actually_shutting_down << id(); + tDebug( LOGVERBOSE ) << Q_FUNC_INFO << m_actually_shutting_down << id(); if ( m_actually_shutting_down ) { return; @@ -165,7 +164,7 @@ Connection::actualShutdown() void Connection::markAsFailed() { - qDebug() << "Connection" << id() << "FAILED ***************" << thread(); + tDebug( LOGVERBOSE ) << "Connection" << id() << "FAILED ***************" << thread(); emit failed(); shutdown(); } @@ -180,7 +179,7 @@ Connection::start( QTcpSocket* sock ) m_sock = sock; - if( m_name.isEmpty() ) + if ( m_name.isEmpty() ) { m_name = QString( "peer[%1]" ).arg( m_sock->peerAddress().toString() ); } @@ -194,7 +193,7 @@ Connection::checkACL() { if ( !property( "nodeid" ).isValid() ) { - tLog() << Q_FUNC_INFO << "Not checking ACL, nodeid is empty"; + tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Not checking ACL, nodeid is empty"; QTimer::singleShot( 0, this, SLOT( doSetup() ) ); return; } @@ -219,7 +218,7 @@ Connection::checkACLResult( const QString &nodeid, const QString &username, ACLR QString bareName = name().contains( '/' ) ? name().left( name().indexOf( "/" ) ) : name(); if ( nodeid != property( "nodeid" ).toString() || username != bareName ) { - tLog() << Q_FUNC_INFO << "nodeid not ours, or username not our barename"; + tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "nodeid not ours, or username not our barename"; return; } @@ -238,10 +237,10 @@ Connection::checkACLResult( const QString &nodeid, const QString &username, ACLR void Connection::authCheckTimeout() { - if( m_ready ) + if ( m_ready ) return; - qDebug() << "Closing connection, not authed in time."; + tDebug( LOGVERBOSE ) << "Closing connection, not authed in time."; shutdown(); } @@ -249,7 +248,7 @@ Connection::authCheckTimeout() void Connection::doSetup() { - qDebug() << Q_FUNC_INFO << thread(); + tDebug( LOGVERBOSE ) << Q_FUNC_INFO << thread(); /* New connections can be created from other thread contexts, such as when AudioEngine calls getIODevice.. - we need to ensure that connections @@ -257,10 +256,9 @@ Connection::doSetup() HINT: export QT_FATAL_WARNINGS=1 helps to catch these kind of errors. */ - if( QThread::currentThread() != m_servent->thread() ) + if ( QThread::currentThread() != m_servent->thread() ) { // Connections should always be in the same thread as the servent. - qDebug() << "Fixing thead affinity..."; moveToThread( m_servent->thread() ); } @@ -289,7 +287,7 @@ Connection::doSetup() // if connection not authed/setup fast enough, kill it: QTimer::singleShot( AUTH_TIMEOUT, this, SLOT( authCheckTimeout() ) ); - if( outbound() ) + if ( outbound() ) { Q_ASSERT( !m_firstmsg.isNull() ); sendMsg( m_firstmsg ); @@ -308,15 +306,15 @@ Connection::doSetup() void Connection::socketDisconnected() { - tDebug() << "SOCKET DISCONNECTED" << this->name() << id() - << "shutdown will happen after incoming queue empties." - << "bytesavail:" << m_sock->bytesAvailable() - << "bytesRecvd" << bytesReceived(); + tDebug( LOGVERBOSE ) << "SOCKET DISCONNECTED" << this->name() << id() + << "shutdown will happen after incoming queue empties." + << "bytesavail:" << m_sock->bytesAvailable() + << "bytesRecvd" << bytesReceived(); m_peer_disconnected = true; emit socketClosed(); - if( m_msgprocessor_in.length() == 0 && m_sock->bytesAvailable() == 0 ) + if ( m_msgprocessor_in.length() == 0 && m_sock->bytesAvailable() == 0 ) { handleIncomingQueueEmpty(); actualShutdown(); @@ -327,7 +325,7 @@ Connection::socketDisconnected() void Connection::socketDisconnectedError( QAbstractSocket::SocketError e ) { - qDebug() << "SOCKET ERROR CODE" << e << this->name() << "CALLING Connection::shutdown(false)"; + tDebug() << "SOCKET ERROR CODE" << e << this->name() << "CALLING Connection::shutdown(false)"; if ( e == QAbstractSocket::RemoteHostClosedError ) return; @@ -360,15 +358,15 @@ Connection::readyRead() { // qDebug() << "readyRead, bytesavail:" << m_sock->bytesAvailable(); - if( m_msg.isNull() ) + if ( m_msg.isNull() ) { - if( m_sock->bytesAvailable() < Msg::headerSize() ) + if ( m_sock->bytesAvailable() < Msg::headerSize() ) return; char msgheader[ Msg::headerSize() ]; - if( m_sock->read( (char*) &msgheader, Msg::headerSize() ) != Msg::headerSize() ) + if ( m_sock->read( (char*) &msgheader, Msg::headerSize() ) != Msg::headerSize() ) { - qDebug() << "Failed reading msg header"; + tDebug() << "Failed reading msg header"; this->markAsFailed(); return; } @@ -377,13 +375,13 @@ Connection::readyRead() m_rx_bytes += Msg::headerSize(); } - if( m_sock->bytesAvailable() < m_msg->length() ) + if ( m_sock->bytesAvailable() < m_msg->length() ) return; QByteArray ba = m_sock->read( m_msg->length() ); - if( ba.length() != (qint32)m_msg->length() ) + if ( ba.length() != (qint32)m_msg->length() ) { - qDebug() << "Failed to read full msg payload"; + tDebug() << "Failed to read full msg payload"; this->markAsFailed(); return; } @@ -393,7 +391,7 @@ Connection::readyRead() handleReadMsg(); // process m_msg and clear() it // since there is no explicit threading, use the event loop to schedule this: - if( m_sock->bytesAvailable() ) + if ( m_sock->bytesAvailable() ) { QTimer::singleShot( 0, this, SLOT( readyRead() ) ); } @@ -403,24 +401,24 @@ Connection::readyRead() void Connection::handleReadMsg() { - if( outbound() == false && + if ( outbound() == false && m_msg->is( Msg::SETUP ) && m_msg->payload() == "ok" ) { m_ready = true; - qDebug() << "Connection" << id() << "READY"; + tDebug( LOGVERBOSE ) << "Connection" << id() << "READY"; setup(); emit ready(); } - else if( !m_ready && + else if ( !m_ready && outbound() && m_msg->is( Msg::SETUP ) ) { - if( m_msg->payload() == PROTOVER ) + if ( m_msg->payload() == PROTOVER ) { sendMsg( Msg::factory( "ok", Msg::SETUP ) ); m_ready = true; - qDebug() << "Connection" << id() << "READY"; + tDebug( LOGVERBOSE ) << "Connection" << id() << "READY"; setup(); emit ready(); } @@ -442,7 +440,7 @@ Connection::handleReadMsg() void Connection::sendMsg( QVariant j ) { - if( m_do_shutdown ) + if ( m_do_shutdown ) return; QJson::Serializer serializer; @@ -455,10 +453,10 @@ Connection::sendMsg( QVariant j ) void Connection::sendMsg( msg_ptr msg ) { - if( m_do_shutdown ) + if ( m_do_shutdown ) { - qDebug() << Q_FUNC_INFO << "SHUTTING DOWN, NOT SENDING msg flags:" - << (int)msg->flags() << "length:" << msg->length() << id(); + tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "SHUTTING DOWN, NOT SENDING msg flags:" + << (int)msg->flags() << "length:" << msg->length() << id(); return; } @@ -475,7 +473,7 @@ Connection::sendMsg_now( msg_ptr msg ) if ( m_sock.isNull() || !m_sock->isOpen() || !m_sock->isWritable() ) { - qDebug() << "***** Socket problem, whilst in sendMsg(). Cleaning up. *****"; + tDebug() << "***** Socket problem, whilst in sendMsg(). Cleaning up. *****"; shutdown( false ); return; } diff --git a/src/libtomahawk/network/DbSyncConnection.cpp b/src/libtomahawk/network/DbSyncConnection.cpp index bd04dc26f..0f0d96d14 100644 --- a/src/libtomahawk/network/DbSyncConnection.cpp +++ b/src/libtomahawk/network/DbSyncConnection.cpp @@ -124,7 +124,7 @@ DBSyncConnection::check() if ( m_source->lastCmdGuid().isEmpty() ) { - tDebug() << "Fetching lastCmdGuid from database!"; + tDebug( LOGVERBOSE ) << "Fetching lastCmdGuid from database!"; DatabaseCommand_CollectionStats* cmd_them = new DatabaseCommand_CollectionStats( m_source ); connect( cmd_them, SIGNAL( done( QVariantMap ) ), SLOT( gotThem( QVariantMap ) ) ); Database::instance()->enqueue( QSharedPointer(cmd_them) ); diff --git a/src/libtomahawk/utils/TomahawkUtils.cpp b/src/libtomahawk/utils/TomahawkUtils.cpp index 4adf2aa68..4c720b2ce 100644 --- a/src/libtomahawk/utils/TomahawkUtils.cpp +++ b/src/libtomahawk/utils/TomahawkUtils.cpp @@ -115,7 +115,7 @@ appConfigDir() } else { - qDebug() << "Error, $HOME not set."; + tDebug() << "Error, $HOME not set."; throw "$HOME not set"; return QDir( "/tmp" ); } @@ -135,7 +135,7 @@ appConfigDir() } else { - qDebug() << "Error, $HOME or $XDG_CONFIG_HOME not set."; + tDebug() << "Error, $HOME or $XDG_CONFIG_HOME not set."; throw "Error, $HOME or $XDG_CONFIG_HOME not set."; ret = QDir( "/tmp" ); } @@ -449,7 +449,7 @@ void NetworkProxyFactory::setNoProxyHosts( const QStringList& hosts ) { QStringList newList; - tDebug() << Q_FUNC_INFO << "No-proxy hosts:" << hosts; + tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "No-proxy hosts:" << hosts; foreach ( const QString& host, hosts ) { QString munge = host.simplified(); @@ -457,7 +457,7 @@ NetworkProxyFactory::setNoProxyHosts( const QStringList& hosts ) //TODO: wildcard support } - tDebug() << Q_FUNC_INFO << "New no-proxy hosts:" << newList; + tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "New no-proxy hosts:" << newList; s_noProxyHostsMutex.lock(); s_noProxyHosts = newList; @@ -468,10 +468,9 @@ NetworkProxyFactory::setNoProxyHosts( const QStringList& hosts ) void NetworkProxyFactory::setProxy( const QNetworkProxy& proxy ) { - m_proxyChanged = false; - if( m_proxy != proxy ) - m_proxyChanged = true; + if ( m_proxy != proxy ) + m_proxyChanged = true; m_proxy = proxy; QFlags< QNetworkProxy::Capability > proxyCaps; @@ -479,16 +478,17 @@ NetworkProxyFactory::setProxy( const QNetworkProxy& proxy ) proxyCaps |= QNetworkProxy::ListeningCapability; if ( TomahawkSettings::instance()->proxyDns() ) proxyCaps |= QNetworkProxy::HostNameLookupCapability; + m_proxy.setCapabilities( proxyCaps ); - tDebug() << Q_FUNC_INFO << "Proxy using host" << proxy.hostName() << "and port" << proxy.port(); - tDebug() << Q_FUNC_INFO << "setting proxy to use proxy DNS?" << (TomahawkSettings::instance()->proxyDns() ? "true" : "false"); + tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Proxy using host" << proxy.hostName() << "and port" << proxy.port(); + tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "setting proxy to use proxy DNS?" << (TomahawkSettings::instance()->proxyDns() ? "true" : "false"); } NetworkProxyFactory& NetworkProxyFactory::operator=( const NetworkProxyFactory& rhs ) { - tDebug() << Q_FUNC_INFO; + tDebug( LOGVERBOSE ) << Q_FUNC_INFO; if ( this != &rhs ) { m_proxy = QNetworkProxy( rhs.m_proxy ); @@ -500,7 +500,7 @@ NetworkProxyFactory::operator=( const NetworkProxyFactory& rhs ) bool NetworkProxyFactory::operator==( const NetworkProxyFactory& other ) const { - tDebug() << Q_FUNC_INFO; + tDebug( LOGVERBOSE ) << Q_FUNC_INFO; if ( m_proxy != other.m_proxy ) return false; @@ -515,7 +515,7 @@ NetworkProxyFactory* proxyFactory( bool makeClone, bool noMutexLocker ) { // Don't lock if being called from nam() - tDebug() << Q_FUNC_INFO; + tDebug( LOGVERBOSE ) << Q_FUNC_INFO; QMutex otherMutex; QMutexLocker locker( noMutexLocker ? &otherMutex : &s_namAccessMutex ); @@ -543,7 +543,7 @@ proxyFactory( bool makeClone, bool noMutexLocker ) void setProxyFactory( NetworkProxyFactory* factory, bool noMutexLocker ) { - tDebug() << Q_FUNC_INFO; + tDebug( LOGVERBOSE ) << Q_FUNC_INFO; Q_ASSERT( factory ); // Don't lock if being called from setNam() QMutex otherMutex; @@ -589,7 +589,7 @@ nam() else return 0; } - tDebug() << Q_FUNC_INFO << "Found gui thread in nam hash"; + tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Found gui thread in nam hash"; // Create a nam for this thread based on the main thread's settings but with its own proxyfactory QNetworkAccessManager *mainNam = s_threadNamHash[ TOMAHAWK_APPLICATION::instance()->thread() ]; @@ -601,7 +601,7 @@ nam() s_threadNamHash[ QThread::currentThread() ] = newNam; - tDebug( LOGEXTRA ) << Q_FUNC_INFO << "created new nam for thread" << QThread::currentThread(); + tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "created new nam for thread" << QThread::currentThread(); //QNetworkProxy proxy = dynamic_cast< TomahawkUtils::NetworkProxyFactory* >( newNam->proxyFactory() )->proxy(); //tDebug() << Q_FUNC_INFO << "reply proxy properties:" << proxy.type() << proxy.hostName() << proxy.port(); @@ -619,13 +619,13 @@ setNam( QNetworkAccessManager* nam, bool noMutexLocker ) if ( !s_threadNamHash.contains( TOMAHAWK_APPLICATION::instance()->thread() ) && QThread::currentThread() == TOMAHAWK_APPLICATION::instance()->thread() ) { - tDebug( LOGEXTRA ) << "creating initial gui thread (" << TOMAHAWK_APPLICATION::instance()->thread() << ") nam"; + tDebug( LOGVERBOSE ) << "creating initial gui thread (" << TOMAHAWK_APPLICATION::instance()->thread() << ") nam"; // Should only get here on first initialization of the nam TomahawkSettings *s = TomahawkSettings::instance(); TomahawkUtils::NetworkProxyFactory* proxyFactory = new TomahawkUtils::NetworkProxyFactory(); if ( s->proxyType() != QNetworkProxy::NoProxy && !s->proxyHost().isEmpty() ) { - tDebug( LOGEXTRA ) << "Setting proxy to saved values"; + tDebug( LOGVERBOSE ) << "Setting proxy to saved values"; QNetworkProxy proxy( s->proxyType(), s->proxyHost(), s->proxyPort(), s->proxyUsername(), s->proxyPassword() ); proxyFactory->setProxy( proxy ); //FIXME: Jreen is broke without this @@ -843,7 +843,7 @@ verifyFile( const QString& filePath, const QString& signature ) return false; } - qDebug() << "Successfully verified signature of downloaded file:" << filePath; + tDebug( LOGVERBOSE ) << "Successfully verified signature of downloaded file:" << filePath; return true; } @@ -890,7 +890,7 @@ unzipFileInFolder( const QString& zipFileName, const QDir& folder ) return false; } - tDebug() << "Unzipping files to:" << folder.absolutePath(); + tDebug( LOGVERBOSE ) << "Unzipping files to:" << folder.absolutePath(); QuaZipFile fileInZip( &zipFile ); do @@ -915,7 +915,7 @@ unzipFileInFolder( const QString& zipFileName, const QDir& folder ) folder.mkpath( dirPath ); } - tDebug() << "Writing to output file..." << out.fileName(); + tDebug( LOGVERBOSE ) << "Writing to output file..." << out.fileName(); if ( !out.open( QIODevice::WriteOnly ) ) { tLog() << "Failed to open zip extract file:" << out.errorString() << info.name; diff --git a/src/libtomahawk/widgets/FadingPixmap.cpp b/src/libtomahawk/widgets/FadingPixmap.cpp index 4a4b6b991..362cbba7e 100644 --- a/src/libtomahawk/widgets/FadingPixmap.cpp +++ b/src/libtomahawk/widgets/FadingPixmap.cpp @@ -72,7 +72,7 @@ FadingPixmap::onAnimationStep( int frame ) void FadingPixmap::onAnimationFinished() { - tDebug() << Q_FUNC_INFO; + tDebug( LOGVERBOSE ) << Q_FUNC_INFO; m_oldPixmap = QPixmap(); repaint(); diff --git a/src/libtomahawk/widgets/NewReleasesWidget.cpp b/src/libtomahawk/widgets/NewReleasesWidget.cpp index 58f031608..4e3d99b67 100644 --- a/src/libtomahawk/widgets/NewReleasesWidget.cpp +++ b/src/libtomahawk/widgets/NewReleasesWidget.cpp @@ -130,7 +130,7 @@ NewReleasesWidget::fetchData() requestData.allSources = true; Tomahawk::InfoSystem::InfoSystem::instance()->getInfo( requestData ); - tDebug( LOGVERBOSE ) << "NewReleases: requested InfoNewReleaseCapabilities"; + tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Requested InfoNewReleaseCapabilities"; } @@ -142,7 +142,7 @@ NewReleasesWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData request if ( !output.canConvert< QVariantMap >() ) { - tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "NewReleases: Could not parse output"; + tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Could not parse output"; return; } @@ -151,14 +151,14 @@ NewReleasesWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData request { case InfoSystem::InfoNewReleaseCapabilities: { - tLog() << "NewReleases: got InfoNewReleaseCapabilities"; + tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Got InfoNewReleaseCapabilities"; QStandardItem *rootItem= m_crumbModelLeft->invisibleRootItem(); foreach ( const QString label, returnedData.keys() ) { QStandardItem *childItem = parseNode( rootItem, label, returnedData[label] ); rootItem->appendRow(childItem); - tLog() << "NewReleases: " << label; + tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "NewReleases:" << label; } m_sortedProxy->setSourceModel( m_crumbModelLeft ); @@ -267,7 +267,7 @@ NewReleasesWidget::leftCrumbIndexChanged( QModelIndex index ) requestData.timeoutMillis = 20000; requestData.allSources = true; - qDebug() << "Making infosystem request for chart of type:" <getInfo( requestData ); m_queuedFetches.insert( nrId );