mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-20 04:41:36 +02:00
* Show RX transfers in TransferView, too.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "databasecommand_loadfile.h"
|
||||
|
||||
#include "databaseimpl.h"
|
||||
#include "tomahawk/collection.h"
|
||||
|
||||
|
||||
DatabaseCommand_LoadFile::DatabaseCommand_LoadFile( const QString& id, QObject* parent )
|
||||
@@ -11,7 +12,7 @@ DatabaseCommand_LoadFile::DatabaseCommand_LoadFile( const QString& id, QObject*
|
||||
|
||||
|
||||
void
|
||||
DatabaseCommand_LoadFile::exec(DatabaseImpl* dbi)
|
||||
DatabaseCommand_LoadFile::exec( DatabaseImpl* dbi )
|
||||
{
|
||||
QVariantMap r;
|
||||
// file ids internally are really ints, at least for now:
|
||||
@@ -25,5 +26,5 @@ DatabaseCommand_LoadFile::exec(DatabaseImpl* dbi)
|
||||
r = dbi->file( fid );
|
||||
} while( false );
|
||||
|
||||
emit result( r );
|
||||
emit result( Tomahawk::result_ptr( new Tomahawk::Result( r, Tomahawk::collection_ptr() ) ) );
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@ public:
|
||||
virtual QString commandname() const { return "loadfile"; }
|
||||
|
||||
signals:
|
||||
void result( QVariantMap );
|
||||
void result( const Tomahawk::result_ptr result );
|
||||
|
||||
private:
|
||||
QString m_id;
|
||||
|
@@ -233,6 +233,7 @@ ControlConnection::onPingTimer()
|
||||
{
|
||||
if ( m_pingtimer_mark.elapsed() >= TCP_TIMEOUT * 1000 )
|
||||
{
|
||||
qDebug() << "Timeout reached! Shutting down connection to" << m_source->friendlyName();
|
||||
shutdown( false );
|
||||
}
|
||||
|
||||
|
@@ -16,7 +16,7 @@
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
FileTransferConnection::FileTransferConnection( Servent* s, ControlConnection* cc, QString fid, unsigned int size )
|
||||
FileTransferConnection::FileTransferConnection( Servent* s, ControlConnection* cc, QString fid, const Tomahawk::result_ptr& result )
|
||||
: Connection( s )
|
||||
, m_cc( cc )
|
||||
, m_fid( fid )
|
||||
@@ -24,11 +24,12 @@ FileTransferConnection::FileTransferConnection( Servent* s, ControlConnection* c
|
||||
, m_badded( 0 )
|
||||
, m_bsent( 0 )
|
||||
, m_allok( false )
|
||||
, m_result( result )
|
||||
, m_transferRate( 0 )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
BufferIODevice* bio = new BufferIODevice( size );
|
||||
BufferIODevice* bio = new BufferIODevice( result->size() );
|
||||
m_iodev = QSharedPointer<QIODevice>( bio ); // device audio data gets written to
|
||||
m_iodev->open( QIODevice::ReadWrite );
|
||||
|
||||
@@ -126,21 +127,22 @@ FileTransferConnection::setup()
|
||||
if( m_type == RECEIVING )
|
||||
{
|
||||
qDebug() << "in RX mode";
|
||||
emit updated();
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "in TX mode, fid:" << m_fid;
|
||||
|
||||
DatabaseCommand_LoadFile* cmd = new DatabaseCommand_LoadFile( m_fid );
|
||||
connect( cmd, SIGNAL( result( QVariantMap ) ), SLOT( startSending( QVariantMap ) ) );
|
||||
connect( cmd, SIGNAL( result( Tomahawk::result_ptr ) ), SLOT( startSending( Tomahawk::result_ptr ) ) );
|
||||
TomahawkApp::instance()->database()->enqueue( QSharedPointer<DatabaseCommand>( cmd ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FileTransferConnection::startSending( const QVariantMap& f )
|
||||
FileTransferConnection::startSending( const Tomahawk::result_ptr& result )
|
||||
{
|
||||
m_result = Tomahawk::result_ptr( new Tomahawk::Result( f, collection_ptr() ) );
|
||||
m_result = result;
|
||||
qDebug() << "Starting to transmit" << m_result->url();
|
||||
|
||||
QSharedPointer<QIODevice> io = TomahawkApp::instance()->getIODeviceForUrl( m_result );
|
||||
|
@@ -23,7 +23,7 @@ public:
|
||||
};
|
||||
|
||||
// RX:
|
||||
explicit FileTransferConnection( Servent* s, ControlConnection* cc, QString fid, unsigned int size );
|
||||
explicit FileTransferConnection( Servent* s, ControlConnection* cc, QString fid, const Tomahawk::result_ptr& result );
|
||||
// TX:
|
||||
explicit FileTransferConnection( Servent* s, ControlConnection* cc, QString fid );
|
||||
|
||||
@@ -50,9 +50,9 @@ protected slots:
|
||||
virtual void handleMsg( msg_ptr msg );
|
||||
|
||||
private slots:
|
||||
void startSending( const QVariantMap& );
|
||||
void startSending( const Tomahawk::result_ptr& );
|
||||
void sendSome();
|
||||
void showStats(qint64 tx, qint64 rx);
|
||||
void showStats( qint64 tx, qint64 rx );
|
||||
|
||||
private:
|
||||
QSharedPointer<QIODevice> m_iodev;
|
||||
|
@@ -575,7 +575,7 @@ Servent::remoteIODeviceFactory( const result_ptr& result )
|
||||
return sp;
|
||||
|
||||
ControlConnection* cc = s->controlConnection();
|
||||
FileTransferConnection* ftc = new FileTransferConnection( this, cc, fileId, result->size() );
|
||||
FileTransferConnection* ftc = new FileTransferConnection( this, cc, fileId, result );
|
||||
createParallelConnection( cc, ftc, QString( "FILE_REQUEST_KEY:%1" ).arg( fileId ) );
|
||||
return ftc->iodevice();
|
||||
}
|
||||
|
Reference in New Issue
Block a user