Permalink
Browse files

* Style and logging clean-ups.

  • Loading branch information...
1 parent 6ceb13d commit f82b81e001807d40957d33714a44ac0a41ac8186 @muesli muesli committed Nov 9, 2012
View
@@ -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 );
@@ -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<QNetworkReply*> ( 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<QNetworkReply*> ( 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<QNetworkReply*> ( 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();
}
@@ -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<DatabaseCommand> >& 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<DatabaseCommand>& 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<DatabaseCommand>& 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 );
}
Oops, something went wrong.

0 comments on commit f82b81e

Please sign in to comment.