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