1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-11 16:44:05 +02:00

Rename some classes/variables

This commit is contained in:
Jeff Mitchell
2011-03-28 17:59:33 -04:00
parent 40b202df74
commit 8d7f4a193b
10 changed files with 76 additions and 80 deletions

View File

@@ -123,7 +123,7 @@ set( libSources
network/bufferiodevice.cpp network/bufferiodevice.cpp
network/msgprocessor.cpp network/msgprocessor.cpp
network/filetransferconnection.cpp network/streamconnection.cpp
network/dbsyncconnection.cpp network/dbsyncconnection.cpp
network/remotecollection.cpp network/remotecollection.cpp
network/portfwdthread.cpp network/portfwdthread.cpp
@@ -218,7 +218,7 @@ set( libHeaders
network/bufferiodevice.h network/bufferiodevice.h
network/msgprocessor.h network/msgprocessor.h
network/remotecollection.h network/remotecollection.h
network/filetransferconnection.h network/streamconnection.h
network/dbsyncconnection.h network/dbsyncconnection.h
network/servent.h network/servent.h
network/connection.h network/connection.h

View File

@@ -18,7 +18,7 @@
#include "controlconnection.h" #include "controlconnection.h"
#include "filetransferconnection.h" #include "streamconnection.h"
#include "database/database.h" #include "database/database.h"
#include "database/databasecommand_collectionstats.h" #include "database/databasecommand_collectionstats.h"
#include "dbsyncconnection.h" #include "dbsyncconnection.h"

View File

@@ -33,8 +33,6 @@
#include "dllmacro.h" #include "dllmacro.h"
class FileTransferSession;
class DLLEXPORT ControlConnection : public Connection class DLLEXPORT ControlConnection : public Connection
{ {
Q_OBJECT Q_OBJECT

View File

@@ -33,7 +33,7 @@
#include "connection.h" #include "connection.h"
#include "controlconnection.h" #include "controlconnection.h"
#include "database/database.h" #include "database/database.h"
#include "filetransferconnection.h" #include "streamconnection.h"
#include "sourcelist.h" #include "sourcelist.h"
#include "portfwdthread.h" #include "portfwdthread.h"
@@ -581,8 +581,8 @@ Servent::claimOffer( ControlConnection* cc, const QString &key, const QHostAddre
} }
QString fid = key.right( key.length() - 17 ); QString fid = key.right( key.length() - 17 );
FileTransferConnection* ftc = new FileTransferConnection( this, cc, fid ); StreamConnection* sc = new StreamConnection( this, cc, fid );
return ftc; return sc;
} }
if( key == "whitelist" ) // LAN IP address, check source IP if( key == "whitelist" ) // LAN IP address, check source IP
@@ -606,7 +606,7 @@ Servent::claimOffer( ControlConnection* cc, const QString &key, const QHostAddre
QPointer<Connection> conn = m_offers.value( key ); QPointer<Connection> conn = m_offers.value( key );
if( conn.isNull() ) if( conn.isNull() )
{ {
// This can happen if it's a filetransferconnection, but the audioengine has // This can happen if it's a streamconnection, but the audioengine has
// already closed the iodevice, causing the connection to be deleted before // already closed the iodevice, causing the connection to be deleted before
// the peer connects and provides the first byte // the peer connects and provides the first byte
qDebug() << Q_FUNC_INFO << "invalid/expired offer:" << key; qDebug() << Q_FUNC_INFO << "invalid/expired offer:" << key;
@@ -652,37 +652,37 @@ Servent::remoteIODeviceFactory( const result_ptr& result )
return sp; return sp;
ControlConnection* cc = s->controlConnection(); ControlConnection* cc = s->controlConnection();
FileTransferConnection* ftc = new FileTransferConnection( this, cc, fileId, result ); StreamConnection* sc = new StreamConnection( this, cc, fileId, result );
createParallelConnection( cc, ftc, QString( "FILE_REQUEST_KEY:%1" ).arg( fileId ) ); createParallelConnection( cc, sc, QString( "FILE_REQUEST_KEY:%1" ).arg( fileId ) );
return ftc->iodevice(); return sc->iodevice();
} }
void void
Servent::registerFileTransferConnection( FileTransferConnection* ftc ) Servent::registerStreamConnection( StreamConnection* sc )
{ {
Q_ASSERT( !m_ftsessions.contains( ftc ) ); Q_ASSERT( !m_scsessions.contains( sc ) );
qDebug() << "Registering FileTransfer" << m_ftsessions.length() + 1; qDebug() << "Registering Stream" << m_scsessions.length() + 1;
QMutexLocker lock( &m_ftsession_mut ); QMutexLocker lock( &m_ftsession_mut );
m_ftsessions.append( ftc ); m_scsessions.append( sc );
printCurrentTransfers(); printCurrentTransfers();
emit fileTransferStarted( ftc ); emit streamStarted( sc );
} }
void void
Servent::onFileTransferFinished( FileTransferConnection* ftc ) Servent::onStreamFinished( StreamConnection* sc )
{ {
Q_ASSERT( ftc ); Q_ASSERT( sc );
qDebug() << "FileTransfer Finished, unregistering" << ftc->id(); qDebug() << "Stream Finished, unregistering" << sc->id();
QMutexLocker lock( &m_ftsession_mut ); QMutexLocker lock( &m_ftsession_mut );
m_ftsessions.removeAll( ftc ); m_scsessions.removeAll( sc );
printCurrentTransfers(); printCurrentTransfers();
emit fileTransferFinished( ftc ); emit streamFinished( sc );
} }
@@ -691,8 +691,8 @@ void
Servent::printCurrentTransfers() Servent::printCurrentTransfers()
{ {
int k = 1; int k = 1;
qDebug() << "~~~ Active file transfer connections:" << m_ftsessions.length(); qDebug() << "~~~ Active file transfer connections:" << m_scsessions.length();
foreach( FileTransferConnection* i, m_ftsessions ) foreach( StreamConnection* i, m_scsessions )
{ {
qDebug() << k << ") " << i->id(); qDebug() << k << ") " << i->id();
} }

View File

@@ -46,7 +46,7 @@
class Connection; class Connection;
class Connector; class Connector;
class ControlConnection; class ControlConnection;
class FileTransferConnection; class StreamConnection;
class ProxyConnection; class ProxyConnection;
class RemoteCollectionConnection; class RemoteCollectionConnection;
class PortFwdThread; class PortFwdThread;
@@ -116,7 +116,7 @@ public:
bool connectedToSession( const QString& session ); bool connectedToSession( const QString& session );
unsigned int numConnectedPeers() const { return m_controlconnections.length(); } unsigned int numConnectedPeers() const { return m_controlconnections.length(); }
QList< FileTransferConnection* > fileTransfers() const { return m_ftsessions; } QList< StreamConnection* > streams() const { return m_scsessions; }
QSharedPointer<QIODevice> getIODeviceForUrl( const Tomahawk::result_ptr& result ); QSharedPointer<QIODevice> getIODeviceForUrl( const Tomahawk::result_ptr& result );
void registerIODeviceFactory( const QString &proto, boost::function<QSharedPointer<QIODevice>(Tomahawk::result_ptr)> fac ); void registerIODeviceFactory( const QString &proto, boost::function<QSharedPointer<QIODevice>(Tomahawk::result_ptr)> fac );
@@ -124,8 +124,8 @@ public:
QSharedPointer<QIODevice> httpIODeviceFactory( const Tomahawk::result_ptr& result ); QSharedPointer<QIODevice> httpIODeviceFactory( const Tomahawk::result_ptr& result );
signals: signals:
void fileTransferStarted( FileTransferConnection* ); void streamStarted( StreamConnection* );
void fileTransferFinished( FileTransferConnection* ); void streamFinished( StreamConnection* );
void ready(); void ready();
protected: protected:
@@ -137,8 +137,8 @@ public slots:
void socketError( QAbstractSocket::SocketError ); void socketError( QAbstractSocket::SocketError );
void createParallelConnection( Connection* orig_conn, Connection* new_conn, const QString& key ); void createParallelConnection( Connection* orig_conn, Connection* new_conn, const QString& key );
void registerFileTransferConnection( FileTransferConnection* ); void registerStreamConnection( StreamConnection* );
void onFileTransferFinished( FileTransferConnection* ftc ); void onStreamFinished( StreamConnection* sc );
void socketConnected(); void socketConnected();
void triggerDBSync(); void triggerDBSync();
@@ -161,7 +161,7 @@ private:
QString m_externalHostname; QString m_externalHostname;
// currently active file transfers: // currently active file transfers:
QList< FileTransferConnection* > m_ftsessions; QList< StreamConnection* > m_scsessions;
QMutex m_ftsession_mut; QMutex m_ftsession_mut;
QMap< QString,boost::function<QSharedPointer<QIODevice>(Tomahawk::result_ptr)> > m_iofactories; QMap< QString,boost::function<QSharedPointer<QIODevice>(Tomahawk::result_ptr)> > m_iofactories;

View File

@@ -16,7 +16,7 @@
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>. * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "filetransferconnection.h" #include "streamconnection.h"
#include <QFile> #include <QFile>
@@ -31,7 +31,7 @@
using namespace Tomahawk; using namespace Tomahawk;
FileTransferConnection::FileTransferConnection( Servent* s, ControlConnection* cc, QString fid, const Tomahawk::result_ptr& result ) StreamConnection::StreamConnection( Servent* s, ControlConnection* cc, QString fid, const Tomahawk::result_ptr& result )
: Connection( s ) : Connection( s )
, m_cc( cc ) , m_cc( cc )
, m_fid( fid ) , m_fid( fid )
@@ -49,7 +49,7 @@ FileTransferConnection::FileTransferConnection( Servent* s, ControlConnection* c
m_iodev = QSharedPointer<QIODevice>( bio ); // device audio data gets written to m_iodev = QSharedPointer<QIODevice>( bio ); // device audio data gets written to
m_iodev->open( QIODevice::ReadWrite ); m_iodev->open( QIODevice::ReadWrite );
Servent::instance()->registerFileTransferConnection( this ); Servent::instance()->registerStreamConnection( this );
// if the audioengine closes the iodev (skip/stop/etc) then kill the connection // if the audioengine closes the iodev (skip/stop/etc) then kill the connection
// immediately to avoid unnecessary network transfer // immediately to avoid unnecessary network transfer
@@ -65,7 +65,7 @@ FileTransferConnection::FileTransferConnection( Servent* s, ControlConnection* c
} }
FileTransferConnection::FileTransferConnection( Servent* s, ControlConnection* cc, QString fid ) StreamConnection::StreamConnection( Servent* s, ControlConnection* cc, QString fid )
: Connection( s ) : Connection( s )
, m_cc( cc ) , m_cc( cc )
, m_fid( fid ) , m_fid( fid )
@@ -75,13 +75,13 @@ FileTransferConnection::FileTransferConnection( Servent* s, ControlConnection* c
, m_allok( false ) , m_allok( false )
, m_transferRate( 0 ) , m_transferRate( 0 )
{ {
Servent::instance()->registerFileTransferConnection( this ); Servent::instance()->registerStreamConnection( this );
// auto delete when connection closes: // auto delete when connection closes:
connect( this, SIGNAL( finished() ), SLOT( deleteLater() ), Qt::QueuedConnection ); connect( this, SIGNAL( finished() ), SLOT( deleteLater() ), Qt::QueuedConnection );
} }
FileTransferConnection::~FileTransferConnection() StreamConnection::~StreamConnection()
{ {
qDebug() << Q_FUNC_INFO << "TX/RX:" << bytesSent() << bytesReceived(); qDebug() << Q_FUNC_INFO << "TX/RX:" << bytesSent() << bytesReceived();
if( m_type == RECEIVING && !m_allok ) if( m_type == RECEIVING && !m_allok )
@@ -95,12 +95,12 @@ FileTransferConnection::~FileTransferConnection()
((BufferIODevice*)m_iodev.data())->inputComplete(); ((BufferIODevice*)m_iodev.data())->inputComplete();
} }
Servent::instance()->onFileTransferFinished( this ); Servent::instance()->onStreamFinished( this );
} }
QString QString
FileTransferConnection::id() const StreamConnection::id() const
{ {
return QString( "FTC[%1 %2]" ) return QString( "FTC[%1 %2]" )
.arg( m_type == SENDING ? "TX" : "RX" ) .arg( m_type == SENDING ? "TX" : "RX" )
@@ -109,13 +109,13 @@ FileTransferConnection::id() const
Tomahawk::source_ptr Tomahawk::source_ptr
FileTransferConnection::source() const StreamConnection::source() const
{ {
return m_source; return m_source;
} }
void void
FileTransferConnection::showStats( qint64 tx, qint64 rx ) StreamConnection::showStats( qint64 tx, qint64 rx )
{ {
if( tx > 0 || rx > 0 ) if( tx > 0 || rx > 0 )
{ {
@@ -130,7 +130,7 @@ FileTransferConnection::showStats( qint64 tx, qint64 rx )
void void
FileTransferConnection::setup() StreamConnection::setup()
{ {
QList<source_ptr> sources = SourceList::instance()->sources(); QList<source_ptr> sources = SourceList::instance()->sources();
foreach( const source_ptr& src, sources ) foreach( const source_ptr& src, sources )
@@ -163,7 +163,7 @@ FileTransferConnection::setup()
void void
FileTransferConnection::startSending( const Tomahawk::result_ptr& result ) StreamConnection::startSending( const Tomahawk::result_ptr& result )
{ {
if ( result.isNull() ) if ( result.isNull() )
{ {
@@ -191,7 +191,7 @@ FileTransferConnection::startSending( const Tomahawk::result_ptr& result )
void void
FileTransferConnection::handleMsg( msg_ptr msg ) StreamConnection::handleMsg( msg_ptr msg )
{ {
Q_ASSERT( msg->is( Msg::RAW ) ); Q_ASSERT( msg->is( Msg::RAW ) );
@@ -237,7 +237,7 @@ FileTransferConnection::handleMsg( msg_ptr msg )
Connection* Connection*
FileTransferConnection::clone() StreamConnection::clone()
{ {
Q_ASSERT( false ); Q_ASSERT( false );
return 0; return 0;
@@ -245,9 +245,9 @@ FileTransferConnection::clone()
void void
FileTransferConnection::sendSome() StreamConnection::sendSome()
{ {
Q_ASSERT( m_type == FileTransferConnection::SENDING ); Q_ASSERT( m_type == StreamConnection::SENDING );
QByteArray ba = "data"; QByteArray ba = "data";
ba.append( m_readdev->read( BufferIODevice::blockSize() ) ); ba.append( m_readdev->read( BufferIODevice::blockSize() ) );
@@ -271,7 +271,7 @@ FileTransferConnection::sendSome()
void void
FileTransferConnection::onBlockRequest( int block ) StreamConnection::onBlockRequest( int block )
{ {
qDebug() << Q_FUNC_INFO << block; qDebug() << Q_FUNC_INFO << block;

View File

@@ -16,8 +16,8 @@
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>. * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef FILETRANSFERCONNECTION_H #ifndef STREAMCONNECTION_H
#define FILETRANSFERCONNECTION_H #define STREAMCONNECTION_H
#include <QObject> #include <QObject>
#include <QSharedPointer> #include <QSharedPointer>
@@ -31,7 +31,7 @@
class ControlConnection; class ControlConnection;
class BufferIODevice; class BufferIODevice;
class DLLEXPORT FileTransferConnection : public Connection class DLLEXPORT StreamConnection : public Connection
{ {
Q_OBJECT Q_OBJECT
@@ -43,11 +43,11 @@ public:
}; };
// RX: // RX:
explicit FileTransferConnection( Servent* s, ControlConnection* cc, QString fid, const Tomahawk::result_ptr& result ); explicit StreamConnection( Servent* s, ControlConnection* cc, QString fid, const Tomahawk::result_ptr& result );
// TX: // TX:
explicit FileTransferConnection( Servent* s, ControlConnection* cc, QString fid ); explicit StreamConnection( Servent* s, ControlConnection* cc, QString fid );
virtual ~FileTransferConnection(); virtual ~StreamConnection();
QString id() const; QString id() const;
void setup(); void setup();
@@ -93,4 +93,4 @@ private:
qint64 m_transferRate; qint64 m_transferRate;
}; };
#endif // FILETRANSFERCONNECTION_H #endif // STREAMCONNECTION_H

View File

@@ -31,7 +31,6 @@
class DatabaseCommand_LogPlayback; class DatabaseCommand_LogPlayback;
class ControlConnection; class ControlConnection;
class FileTransferConnection;
namespace Tomahawk namespace Tomahawk
{ {
@@ -117,7 +116,6 @@ private:
QString m_textStatus; QString m_textStatus;
ControlConnection* m_cc; ControlConnection* m_cc;
FileTransferConnection* m_ftc;
}; };
}; };

View File

@@ -24,7 +24,7 @@
#include "tomahawk/tomahawkapp.h" #include "tomahawk/tomahawkapp.h"
#include "artist.h" #include "artist.h"
#include "source.h" #include "source.h"
#include "network/filetransferconnection.h" #include "network/streamconnection.h"
#include "network/servent.h" #include "network/servent.h"
@@ -39,8 +39,8 @@ TransferView::TransferView( AnimatedSplitter* parent )
layout()->setMargin( 0 ); layout()->setMargin( 0 );
layout()->addWidget( m_tree ); layout()->addWidget( m_tree );
connect( Servent::instance(), SIGNAL( fileTransferStarted( FileTransferConnection* ) ), SLOT( fileTransferRegistered( FileTransferConnection* ) ) ); connect( Servent::instance(), SIGNAL( streamStarted( StreamConnection* ) ), SLOT( streamRegistered( StreamConnection* ) ) );
connect( Servent::instance(), SIGNAL( fileTransferFinished( FileTransferConnection* ) ), SLOT( fileTransferFinished( FileTransferConnection* ) ) ); connect( Servent::instance(), SIGNAL( streamFinished( StreamConnection* ) ), SLOT( streamFinished( StreamConnection* ) ) );
QStringList headers; QStringList headers;
headers << tr( "Peer" ) << tr( "Rate" ) << tr( "Track" ); headers << tr( "Peer" ) << tr( "Rate" ) << tr( "Track" );
@@ -61,20 +61,20 @@ TransferView::TransferView( AnimatedSplitter* parent )
void void
TransferView::fileTransferRegistered( FileTransferConnection* ftc ) TransferView::streamRegistered( StreamConnection* sc )
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
connect( ftc, SIGNAL( updated() ), SLOT( onTransferUpdate() ) ); connect( sc, SIGNAL( updated() ), SLOT( onTransferUpdate() ) );
} }
void void
TransferView::fileTransferFinished( FileTransferConnection* ftc ) TransferView::streamFinished( StreamConnection* sc )
{ {
if ( !m_index.contains( ftc ) ) if ( !m_index.contains( sc ) )
return; return;
QPersistentModelIndex i = m_index.take( ftc ); QPersistentModelIndex i = m_index.take( sc );
delete m_tree->invisibleRootItem()->takeChild( i.row() ); delete m_tree->invisibleRootItem()->takeChild( i.row() );
if ( m_tree->invisibleRootItem()->childCount() > 0 ) if ( m_tree->invisibleRootItem()->childCount() > 0 )
@@ -82,9 +82,9 @@ TransferView::fileTransferFinished( FileTransferConnection* ftc )
else else
emit hideWidget(); emit hideWidget();
/* if ( m_index.contains( ftc ) ) /* if ( m_index.contains( sc ) )
{ {
int i = m_index.value( ftc ); int i = m_index.value( sc );
m_tree->invisibleRootItem()->child( i )->setText( 1, tr( "Finished" ) ); m_tree->invisibleRootItem()->child( i )->setText( 1, tr( "Finished" ) );
}*/ }*/
} }
@@ -93,32 +93,32 @@ TransferView::fileTransferFinished( FileTransferConnection* ftc )
void void
TransferView::onTransferUpdate() TransferView::onTransferUpdate()
{ {
FileTransferConnection* ftc = (FileTransferConnection*)sender(); StreamConnection* sc = (StreamConnection*)sender();
// qDebug() << Q_FUNC_INFO << ftc->track().isNull() << ftc->source().isNull(); // qDebug() << Q_FUNC_INFO << sc->track().isNull() << sc->source().isNull();
if ( ftc->track().isNull() || ftc->source().isNull() ) if ( sc->track().isNull() || sc->source().isNull() )
return; return;
QTreeWidgetItem* ti = 0; QTreeWidgetItem* ti = 0;
if ( m_index.contains( ftc ) ) if ( m_index.contains( sc ) )
{ {
QPersistentModelIndex i = m_index.value( ftc ); QPersistentModelIndex i = m_index.value( sc );
ti = m_tree->invisibleRootItem()->child( i.row() ); ti = m_tree->invisibleRootItem()->child( i.row() );
} }
else else
{ {
ti = new QTreeWidgetItem( m_tree ); ti = new QTreeWidgetItem( m_tree );
m_index.insert( ftc, QPersistentModelIndex( m_tree->model()->index( m_tree->invisibleRootItem()->childCount() - 1, 0 ) ) ); m_index.insert( sc, QPersistentModelIndex( m_tree->model()->index( m_tree->invisibleRootItem()->childCount() - 1, 0 ) ) );
emit showWidget(); emit showWidget();
} }
if ( !ti ) if ( !ti )
return; return;
ti->setText( 0, ftc->source()->friendlyName() ); ti->setText( 0, sc->source()->friendlyName() );
ti->setText( 1, QString( "%1 kb/s" ).arg( ftc->transferRate() / 1024 ) ); ti->setText( 1, QString( "%1 kb/s" ).arg( sc->transferRate() / 1024 ) );
ti->setText( 2, QString( "%1 - %2" ).arg( ftc->track()->artist()->name() ).arg( ftc->track()->track() ) ); ti->setText( 2, QString( "%1 - %2" ).arg( sc->track()->artist()->name() ).arg( sc->track()->track() ) );
if ( isHidden() ) if ( isHidden() )
emit showWidget(); emit showWidget();

View File

@@ -25,7 +25,7 @@
#include "typedefs.h" #include "typedefs.h"
#include "utils/animatedsplitter.h" #include "utils/animatedsplitter.h"
class FileTransferConnection; class StreamConnection;
class TransferView : public AnimatedWidget class TransferView : public AnimatedWidget
{ {
@@ -43,13 +43,13 @@ public:
signals: signals:
private slots: private slots:
void fileTransferRegistered( FileTransferConnection* ftc ); void streamRegistered( StreamConnection* sc );
void fileTransferFinished( FileTransferConnection* ftc ); void streamFinished( StreamConnection* sc );
void onTransferUpdate(); void onTransferUpdate();
private: private:
QHash< FileTransferConnection*, QPersistentModelIndex > m_index; QHash< StreamConnection*, QPersistentModelIndex > m_index;
QTreeWidget* m_tree; QTreeWidget* m_tree;
AnimatedSplitter* m_parent; AnimatedSplitter* m_parent;
}; };