From 102633803a326b8f2c41f9cdc44365061af7a92f Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Fri, 5 Apr 2013 15:53:33 +0200 Subject: [PATCH] * Use result and added comment as to why we require this parameter. --- src/libtomahawk/network/StreamConnection.cpp | 21 +++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/libtomahawk/network/StreamConnection.cpp b/src/libtomahawk/network/StreamConnection.cpp index fe6d24362..52d4c1f55 100644 --- a/src/libtomahawk/network/StreamConnection.cpp +++ b/src/libtomahawk/network/StreamConnection.cpp @@ -89,7 +89,7 @@ StreamConnection::StreamConnection( Servent* s, ControlConnection* cc, QString f StreamConnection::~StreamConnection() { qDebug() << Q_FUNC_INFO << "TX/RX:" << bytesSent() << bytesReceived(); - if( m_type == RECEIVING && !m_allok ) + if ( m_type == RECEIVING && !m_allok ) { qDebug() << "FTConnection closing before last data msg received, shame."; //TODO log the fact that our peer was bad-mannered enough to not finish the upload @@ -117,13 +117,14 @@ StreamConnection::id() const Tomahawk::source_ptr StreamConnection::source() const { - return m_source; + return m_source; } + void StreamConnection::showStats( qint64 tx, qint64 rx ) { - if( tx > 0 || rx > 0 ) + if ( tx > 0 || rx > 0 ) { qDebug() << id() << QString( "Down: %L1 bytes/sec," ).arg( rx ) @@ -139,10 +140,10 @@ void StreamConnection::setup() { QList sources = SourceList::instance()->sources(); - foreach( const source_ptr& src, sources ) + foreach ( const source_ptr& src, sources ) { // local src doesnt have a control connection, skip it: - if( src.isNull() || src->isLocal() ) + if ( src.isNull() || src->isLocal() ) continue; if ( src->controlConnection() == m_cc ) @@ -153,7 +154,7 @@ StreamConnection::setup() } connect( this, SIGNAL( statsTick( qint64, qint64 ) ), SLOT( showStats( qint64, qint64 ) ) ); - if( m_type == RECEIVING ) + if ( m_type == RECEIVING ) { qDebug() << "in RX mode"; emit updated(); @@ -190,9 +191,11 @@ StreamConnection::startSending( const Tomahawk::result_ptr& result ) void StreamConnection::reallyStartSending( const Tomahawk::result_ptr& result, QSharedPointer< QIODevice >& io ) { - if( !io || io.isNull() ) + // Note: We don't really need to pass in 'result' here, since we already have it stored + // as a member variable. The callback-signature of getIODeviceForUrl requires it, though. + if ( !io || io.isNull() ) { - qDebug() << "Couldn't read from source:" << m_result->url(); + qDebug() << "Couldn't read from source:" << result->url(); shutdown(); return; } @@ -269,7 +272,7 @@ StreamConnection::sendSome() ba.append( m_readdev->read( BufferIODevice::blockSize() ) ); m_bsent += ba.length() - 4; - if( m_readdev->atEnd() ) + if ( m_readdev->atEnd() ) { sendMsg( Msg::factory( ba, Msg::RAW ) ); return;