mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-20 07:52:30 +02:00
Rename some classes/variables
This commit is contained in:
parent
40b202df74
commit
8d7f4a193b
@ -123,7 +123,7 @@ set( libSources
|
||||
|
||||
network/bufferiodevice.cpp
|
||||
network/msgprocessor.cpp
|
||||
network/filetransferconnection.cpp
|
||||
network/streamconnection.cpp
|
||||
network/dbsyncconnection.cpp
|
||||
network/remotecollection.cpp
|
||||
network/portfwdthread.cpp
|
||||
@ -218,7 +218,7 @@ set( libHeaders
|
||||
network/bufferiodevice.h
|
||||
network/msgprocessor.h
|
||||
network/remotecollection.h
|
||||
network/filetransferconnection.h
|
||||
network/streamconnection.h
|
||||
network/dbsyncconnection.h
|
||||
network/servent.h
|
||||
network/connection.h
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
#include "controlconnection.h"
|
||||
|
||||
#include "filetransferconnection.h"
|
||||
#include "streamconnection.h"
|
||||
#include "database/database.h"
|
||||
#include "database/databasecommand_collectionstats.h"
|
||||
#include "dbsyncconnection.h"
|
||||
|
@ -33,8 +33,6 @@
|
||||
|
||||
#include "dllmacro.h"
|
||||
|
||||
class FileTransferSession;
|
||||
|
||||
class DLLEXPORT ControlConnection : public Connection
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "connection.h"
|
||||
#include "controlconnection.h"
|
||||
#include "database/database.h"
|
||||
#include "filetransferconnection.h"
|
||||
#include "streamconnection.h"
|
||||
#include "sourcelist.h"
|
||||
|
||||
#include "portfwdthread.h"
|
||||
@ -581,8 +581,8 @@ Servent::claimOffer( ControlConnection* cc, const QString &key, const QHostAddre
|
||||
}
|
||||
|
||||
QString fid = key.right( key.length() - 17 );
|
||||
FileTransferConnection* ftc = new FileTransferConnection( this, cc, fid );
|
||||
return ftc;
|
||||
StreamConnection* sc = new StreamConnection( this, cc, fid );
|
||||
return sc;
|
||||
}
|
||||
|
||||
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 );
|
||||
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
|
||||
// the peer connects and provides the first byte
|
||||
qDebug() << Q_FUNC_INFO << "invalid/expired offer:" << key;
|
||||
@ -652,37 +652,37 @@ Servent::remoteIODeviceFactory( const result_ptr& result )
|
||||
return sp;
|
||||
|
||||
ControlConnection* cc = s->controlConnection();
|
||||
FileTransferConnection* ftc = new FileTransferConnection( this, cc, fileId, result );
|
||||
createParallelConnection( cc, ftc, QString( "FILE_REQUEST_KEY:%1" ).arg( fileId ) );
|
||||
return ftc->iodevice();
|
||||
StreamConnection* sc = new StreamConnection( this, cc, fileId, result );
|
||||
createParallelConnection( cc, sc, QString( "FILE_REQUEST_KEY:%1" ).arg( fileId ) );
|
||||
return sc->iodevice();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Servent::registerFileTransferConnection( FileTransferConnection* ftc )
|
||||
Servent::registerStreamConnection( StreamConnection* sc )
|
||||
{
|
||||
Q_ASSERT( !m_ftsessions.contains( ftc ) );
|
||||
qDebug() << "Registering FileTransfer" << m_ftsessions.length() + 1;
|
||||
Q_ASSERT( !m_scsessions.contains( sc ) );
|
||||
qDebug() << "Registering Stream" << m_scsessions.length() + 1;
|
||||
|
||||
QMutexLocker lock( &m_ftsession_mut );
|
||||
m_ftsessions.append( ftc );
|
||||
m_scsessions.append( sc );
|
||||
|
||||
printCurrentTransfers();
|
||||
emit fileTransferStarted( ftc );
|
||||
emit streamStarted( sc );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Servent::onFileTransferFinished( FileTransferConnection* ftc )
|
||||
Servent::onStreamFinished( StreamConnection* sc )
|
||||
{
|
||||
Q_ASSERT( ftc );
|
||||
qDebug() << "FileTransfer Finished, unregistering" << ftc->id();
|
||||
Q_ASSERT( sc );
|
||||
qDebug() << "Stream Finished, unregistering" << sc->id();
|
||||
|
||||
QMutexLocker lock( &m_ftsession_mut );
|
||||
m_ftsessions.removeAll( ftc );
|
||||
m_scsessions.removeAll( sc );
|
||||
|
||||
printCurrentTransfers();
|
||||
emit fileTransferFinished( ftc );
|
||||
emit streamFinished( sc );
|
||||
}
|
||||
|
||||
|
||||
@ -691,8 +691,8 @@ void
|
||||
Servent::printCurrentTransfers()
|
||||
{
|
||||
int k = 1;
|
||||
qDebug() << "~~~ Active file transfer connections:" << m_ftsessions.length();
|
||||
foreach( FileTransferConnection* i, m_ftsessions )
|
||||
qDebug() << "~~~ Active file transfer connections:" << m_scsessions.length();
|
||||
foreach( StreamConnection* i, m_scsessions )
|
||||
{
|
||||
qDebug() << k << ") " << i->id();
|
||||
}
|
||||
|
@ -46,7 +46,7 @@
|
||||
class Connection;
|
||||
class Connector;
|
||||
class ControlConnection;
|
||||
class FileTransferConnection;
|
||||
class StreamConnection;
|
||||
class ProxyConnection;
|
||||
class RemoteCollectionConnection;
|
||||
class PortFwdThread;
|
||||
@ -116,7 +116,7 @@ public:
|
||||
bool connectedToSession( const QString& session );
|
||||
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 );
|
||||
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 );
|
||||
|
||||
signals:
|
||||
void fileTransferStarted( FileTransferConnection* );
|
||||
void fileTransferFinished( FileTransferConnection* );
|
||||
void streamStarted( StreamConnection* );
|
||||
void streamFinished( StreamConnection* );
|
||||
void ready();
|
||||
|
||||
protected:
|
||||
@ -137,8 +137,8 @@ public slots:
|
||||
void socketError( QAbstractSocket::SocketError );
|
||||
void createParallelConnection( Connection* orig_conn, Connection* new_conn, const QString& key );
|
||||
|
||||
void registerFileTransferConnection( FileTransferConnection* );
|
||||
void onFileTransferFinished( FileTransferConnection* ftc );
|
||||
void registerStreamConnection( StreamConnection* );
|
||||
void onStreamFinished( StreamConnection* sc );
|
||||
|
||||
void socketConnected();
|
||||
void triggerDBSync();
|
||||
@ -161,7 +161,7 @@ private:
|
||||
QString m_externalHostname;
|
||||
|
||||
// currently active file transfers:
|
||||
QList< FileTransferConnection* > m_ftsessions;
|
||||
QList< StreamConnection* > m_scsessions;
|
||||
QMutex m_ftsession_mut;
|
||||
|
||||
QMap< QString,boost::function<QSharedPointer<QIODevice>(Tomahawk::result_ptr)> > m_iofactories;
|
||||
|
@ -16,7 +16,7 @@
|
||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "filetransferconnection.h"
|
||||
#include "streamconnection.h"
|
||||
|
||||
#include <QFile>
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
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 )
|
||||
, m_cc( cc )
|
||||
, 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->open( QIODevice::ReadWrite );
|
||||
|
||||
Servent::instance()->registerFileTransferConnection( this );
|
||||
Servent::instance()->registerStreamConnection( this );
|
||||
|
||||
// if the audioengine closes the iodev (skip/stop/etc) then kill the connection
|
||||
// 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 )
|
||||
, m_cc( cc )
|
||||
, m_fid( fid )
|
||||
@ -75,13 +75,13 @@ FileTransferConnection::FileTransferConnection( Servent* s, ControlConnection* c
|
||||
, m_allok( false )
|
||||
, m_transferRate( 0 )
|
||||
{
|
||||
Servent::instance()->registerFileTransferConnection( this );
|
||||
Servent::instance()->registerStreamConnection( this );
|
||||
// auto delete when connection closes:
|
||||
connect( this, SIGNAL( finished() ), SLOT( deleteLater() ), Qt::QueuedConnection );
|
||||
}
|
||||
|
||||
|
||||
FileTransferConnection::~FileTransferConnection()
|
||||
StreamConnection::~StreamConnection()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << "TX/RX:" << bytesSent() << bytesReceived();
|
||||
if( m_type == RECEIVING && !m_allok )
|
||||
@ -95,12 +95,12 @@ FileTransferConnection::~FileTransferConnection()
|
||||
((BufferIODevice*)m_iodev.data())->inputComplete();
|
||||
}
|
||||
|
||||
Servent::instance()->onFileTransferFinished( this );
|
||||
Servent::instance()->onStreamFinished( this );
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
FileTransferConnection::id() const
|
||||
StreamConnection::id() const
|
||||
{
|
||||
return QString( "FTC[%1 %2]" )
|
||||
.arg( m_type == SENDING ? "TX" : "RX" )
|
||||
@ -109,13 +109,13 @@ FileTransferConnection::id() const
|
||||
|
||||
|
||||
Tomahawk::source_ptr
|
||||
FileTransferConnection::source() const
|
||||
StreamConnection::source() const
|
||||
{
|
||||
return m_source;
|
||||
}
|
||||
|
||||
void
|
||||
FileTransferConnection::showStats( qint64 tx, qint64 rx )
|
||||
StreamConnection::showStats( qint64 tx, qint64 rx )
|
||||
{
|
||||
if( tx > 0 || rx > 0 )
|
||||
{
|
||||
@ -130,7 +130,7 @@ FileTransferConnection::showStats( qint64 tx, qint64 rx )
|
||||
|
||||
|
||||
void
|
||||
FileTransferConnection::setup()
|
||||
StreamConnection::setup()
|
||||
{
|
||||
QList<source_ptr> sources = SourceList::instance()->sources();
|
||||
foreach( const source_ptr& src, sources )
|
||||
@ -163,7 +163,7 @@ FileTransferConnection::setup()
|
||||
|
||||
|
||||
void
|
||||
FileTransferConnection::startSending( const Tomahawk::result_ptr& result )
|
||||
StreamConnection::startSending( const Tomahawk::result_ptr& result )
|
||||
{
|
||||
if ( result.isNull() )
|
||||
{
|
||||
@ -191,7 +191,7 @@ FileTransferConnection::startSending( const Tomahawk::result_ptr& result )
|
||||
|
||||
|
||||
void
|
||||
FileTransferConnection::handleMsg( msg_ptr msg )
|
||||
StreamConnection::handleMsg( msg_ptr msg )
|
||||
{
|
||||
Q_ASSERT( msg->is( Msg::RAW ) );
|
||||
|
||||
@ -237,7 +237,7 @@ FileTransferConnection::handleMsg( msg_ptr msg )
|
||||
|
||||
|
||||
Connection*
|
||||
FileTransferConnection::clone()
|
||||
StreamConnection::clone()
|
||||
{
|
||||
Q_ASSERT( false );
|
||||
return 0;
|
||||
@ -245,9 +245,9 @@ FileTransferConnection::clone()
|
||||
|
||||
|
||||
void
|
||||
FileTransferConnection::sendSome()
|
||||
StreamConnection::sendSome()
|
||||
{
|
||||
Q_ASSERT( m_type == FileTransferConnection::SENDING );
|
||||
Q_ASSERT( m_type == StreamConnection::SENDING );
|
||||
|
||||
QByteArray ba = "data";
|
||||
ba.append( m_readdev->read( BufferIODevice::blockSize() ) );
|
||||
@ -271,7 +271,7 @@ FileTransferConnection::sendSome()
|
||||
|
||||
|
||||
void
|
||||
FileTransferConnection::onBlockRequest( int block )
|
||||
StreamConnection::onBlockRequest( int block )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << block;
|
||||
|
@ -16,8 +16,8 @@
|
||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef FILETRANSFERCONNECTION_H
|
||||
#define FILETRANSFERCONNECTION_H
|
||||
#ifndef STREAMCONNECTION_H
|
||||
#define STREAMCONNECTION_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QSharedPointer>
|
||||
@ -31,7 +31,7 @@
|
||||
class ControlConnection;
|
||||
class BufferIODevice;
|
||||
|
||||
class DLLEXPORT FileTransferConnection : public Connection
|
||||
class DLLEXPORT StreamConnection : public Connection
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -43,11 +43,11 @@ public:
|
||||
};
|
||||
|
||||
// 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:
|
||||
explicit FileTransferConnection( Servent* s, ControlConnection* cc, QString fid );
|
||||
explicit StreamConnection( Servent* s, ControlConnection* cc, QString fid );
|
||||
|
||||
virtual ~FileTransferConnection();
|
||||
virtual ~StreamConnection();
|
||||
|
||||
QString id() const;
|
||||
void setup();
|
||||
@ -93,4 +93,4 @@ private:
|
||||
qint64 m_transferRate;
|
||||
};
|
||||
|
||||
#endif // FILETRANSFERCONNECTION_H
|
||||
#endif // STREAMCONNECTION_H
|
@ -31,7 +31,6 @@
|
||||
|
||||
class DatabaseCommand_LogPlayback;
|
||||
class ControlConnection;
|
||||
class FileTransferConnection;
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
@ -117,7 +116,6 @@ private:
|
||||
QString m_textStatus;
|
||||
|
||||
ControlConnection* m_cc;
|
||||
FileTransferConnection* m_ftc;
|
||||
};
|
||||
|
||||
};
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "tomahawk/tomahawkapp.h"
|
||||
#include "artist.h"
|
||||
#include "source.h"
|
||||
#include "network/filetransferconnection.h"
|
||||
#include "network/streamconnection.h"
|
||||
#include "network/servent.h"
|
||||
|
||||
|
||||
@ -39,8 +39,8 @@ TransferView::TransferView( AnimatedSplitter* parent )
|
||||
layout()->setMargin( 0 );
|
||||
layout()->addWidget( m_tree );
|
||||
|
||||
connect( Servent::instance(), SIGNAL( fileTransferStarted( FileTransferConnection* ) ), SLOT( fileTransferRegistered( FileTransferConnection* ) ) );
|
||||
connect( Servent::instance(), SIGNAL( fileTransferFinished( FileTransferConnection* ) ), SLOT( fileTransferFinished( FileTransferConnection* ) ) );
|
||||
connect( Servent::instance(), SIGNAL( streamStarted( StreamConnection* ) ), SLOT( streamRegistered( StreamConnection* ) ) );
|
||||
connect( Servent::instance(), SIGNAL( streamFinished( StreamConnection* ) ), SLOT( streamFinished( StreamConnection* ) ) );
|
||||
|
||||
QStringList headers;
|
||||
headers << tr( "Peer" ) << tr( "Rate" ) << tr( "Track" );
|
||||
@ -61,20 +61,20 @@ TransferView::TransferView( AnimatedSplitter* parent )
|
||||
|
||||
|
||||
void
|
||||
TransferView::fileTransferRegistered( FileTransferConnection* ftc )
|
||||
TransferView::streamRegistered( StreamConnection* sc )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
connect( ftc, SIGNAL( updated() ), SLOT( onTransferUpdate() ) );
|
||||
connect( sc, SIGNAL( updated() ), SLOT( onTransferUpdate() ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TransferView::fileTransferFinished( FileTransferConnection* ftc )
|
||||
TransferView::streamFinished( StreamConnection* sc )
|
||||
{
|
||||
if ( !m_index.contains( ftc ) )
|
||||
if ( !m_index.contains( sc ) )
|
||||
return;
|
||||
|
||||
QPersistentModelIndex i = m_index.take( ftc );
|
||||
QPersistentModelIndex i = m_index.take( sc );
|
||||
delete m_tree->invisibleRootItem()->takeChild( i.row() );
|
||||
|
||||
if ( m_tree->invisibleRootItem()->childCount() > 0 )
|
||||
@ -82,9 +82,9 @@ TransferView::fileTransferFinished( FileTransferConnection* ftc )
|
||||
else
|
||||
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" ) );
|
||||
}*/
|
||||
}
|
||||
@ -93,32 +93,32 @@ TransferView::fileTransferFinished( FileTransferConnection* ftc )
|
||||
void
|
||||
TransferView::onTransferUpdate()
|
||||
{
|
||||
FileTransferConnection* ftc = (FileTransferConnection*)sender();
|
||||
// qDebug() << Q_FUNC_INFO << ftc->track().isNull() << ftc->source().isNull();
|
||||
StreamConnection* sc = (StreamConnection*)sender();
|
||||
// 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;
|
||||
|
||||
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() );
|
||||
}
|
||||
else
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
if ( !ti )
|
||||
return;
|
||||
|
||||
ti->setText( 0, ftc->source()->friendlyName() );
|
||||
ti->setText( 1, QString( "%1 kb/s" ).arg( ftc->transferRate() / 1024 ) );
|
||||
ti->setText( 2, QString( "%1 - %2" ).arg( ftc->track()->artist()->name() ).arg( ftc->track()->track() ) );
|
||||
ti->setText( 0, sc->source()->friendlyName() );
|
||||
ti->setText( 1, QString( "%1 kb/s" ).arg( sc->transferRate() / 1024 ) );
|
||||
ti->setText( 2, QString( "%1 - %2" ).arg( sc->track()->artist()->name() ).arg( sc->track()->track() ) );
|
||||
|
||||
if ( isHidden() )
|
||||
emit showWidget();
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "typedefs.h"
|
||||
#include "utils/animatedsplitter.h"
|
||||
|
||||
class FileTransferConnection;
|
||||
class StreamConnection;
|
||||
|
||||
class TransferView : public AnimatedWidget
|
||||
{
|
||||
@ -43,13 +43,13 @@ public:
|
||||
signals:
|
||||
|
||||
private slots:
|
||||
void fileTransferRegistered( FileTransferConnection* ftc );
|
||||
void fileTransferFinished( FileTransferConnection* ftc );
|
||||
void streamRegistered( StreamConnection* sc );
|
||||
void streamFinished( StreamConnection* sc );
|
||||
|
||||
void onTransferUpdate();
|
||||
|
||||
private:
|
||||
QHash< FileTransferConnection*, QPersistentModelIndex > m_index;
|
||||
QHash< StreamConnection*, QPersistentModelIndex > m_index;
|
||||
QTreeWidget* m_tree;
|
||||
AnimatedSplitter* m_parent;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user