From bfd5690af716c265d1d7edb1e2bcb6d37332d5df Mon Sep 17 00:00:00 2001 From: "Uwe L. Korn" Date: Sun, 16 Jun 2013 10:52:16 +0200 Subject: [PATCH] Move outbound, ready, onceonly into ConnectionPrivate --- src/libtomahawk/network/Connection.cpp | 34 ++++++++++++------- src/libtomahawk/network/Connection.h | 1 - src/libtomahawk/network/Connection_p.h | 7 +++- src/libtomahawk/network/ControlConnection.cpp | 2 +- 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/src/libtomahawk/network/Connection.cpp b/src/libtomahawk/network/Connection.cpp index 3366d6640..a447440e6 100644 --- a/src/libtomahawk/network/Connection.cpp +++ b/src/libtomahawk/network/Connection.cpp @@ -35,8 +35,6 @@ Connection::Connection( Servent* parent ) : QObject() , m_sock( 0 ) , m_servent( parent ) - , m_ready( false ) - , m_onceonly( true ) , d_ptr( new ConnectionPrivate( this ) ) { moveToThread( m_servent->thread() ); @@ -120,15 +118,19 @@ Connection::socket() } void -Connection::setOutbound(bool o) +Connection::setOutbound( bool o ) { - m_outbound = o; + Q_D( Connection ); + + d->outbound = o; } bool Connection::outbound() const { - return m_outbound; + Q_D( const Connection ); + + return d->outbound; } Servent* @@ -229,19 +231,25 @@ Connection::name() const void Connection::setOnceOnly( bool b ) { - m_onceonly = b; + Q_D( Connection ); + + d->onceonly = b; } bool Connection::onceOnly() const { - return m_onceonly; + Q_D( const Connection ); + + return d->onceonly; } bool Connection::isReady() const { - return m_ready; + Q_D( const Connection ); + + return d->ready; } bool @@ -359,7 +367,9 @@ Connection::checkACLResult( const QString &nodeid, const QString &username, Toma void Connection::authCheckTimeout() { - if ( m_ready ) + Q_D( Connection ); + + if ( d->ready ) return; tDebug( LOGVERBOSE ) << "Closing connection, not authed in time."; @@ -549,19 +559,19 @@ Connection::handleReadMsg() d->msg->is( Msg::SETUP ) && d->msg->payload() == "ok" ) { - m_ready = true; + d->ready = true; tDebug( LOGVERBOSE ) << "Connection" << id() << "READY"; setup(); emit ready(); } - else if ( !m_ready && + else if ( !d->ready && outbound() && d->msg->is( Msg::SETUP ) ) { if ( d->msg->payload() == PROTOVER ) { sendMsg( Msg::factory( "ok", Msg::SETUP ) ); - m_ready = true; + d->ready = true; tDebug( LOGVERBOSE ) << "Connection" << id() << "READY"; setup(); emit ready(); diff --git a/src/libtomahawk/network/Connection.h b/src/libtomahawk/network/Connection.h index de9bb155e..e3c7b1436 100644 --- a/src/libtomahawk/network/Connection.h +++ b/src/libtomahawk/network/Connection.h @@ -123,7 +123,6 @@ private slots: protected: QPointer m_sock; Servent* m_servent; - bool m_outbound, m_ready, m_onceonly; private: Q_DECLARE_PRIVATE( Connection ) diff --git a/src/libtomahawk/network/Connection_p.h b/src/libtomahawk/network/Connection_p.h index 4682bcfe4..6f64d944f 100644 --- a/src/libtomahawk/network/Connection_p.h +++ b/src/libtomahawk/network/Connection_p.h @@ -36,11 +36,13 @@ public: , do_shutdown( false ) , actually_shutting_down( false ) , peer_disconnected( false ) - , peerport( 0 ) + , ready( false ) + , onceonly( true ) , tx_bytes( 0 ) , tx_bytes_requested( 0 ) , rx_bytes( 0 ) , id( "Connection()" ) + , peerport( 0 ) , statstimer( 0 ) , stats_tx_bytes_per_sec( 0 ) , stats_rx_bytes_per_sec( 0 ) @@ -56,6 +58,9 @@ private: bool do_shutdown; bool actually_shutting_down; bool peer_disconnected; + bool outbound; + bool ready; + bool onceonly; qint64 tx_bytes; qint64 tx_bytes_requested; qint64 rx_bytes; diff --git a/src/libtomahawk/network/ControlConnection.cpp b/src/libtomahawk/network/ControlConnection.cpp index 1de34b025..2a749d50d 100644 --- a/src/libtomahawk/network/ControlConnection.cpp +++ b/src/libtomahawk/network/ControlConnection.cpp @@ -277,7 +277,7 @@ ControlConnection::handleMsg( msg_ptr msg ) void ControlConnection::authCheckTimeout() { - if ( m_ready ) + if ( isReady() ) return; Servent::instance()->queueForAclResult( bareName(), m_peerInfos );