diff --git a/src/Device.cpp b/src/Device.cpp index 77d7889f5..546db5559 100644 --- a/src/Device.cpp +++ b/src/Device.cpp @@ -39,7 +39,7 @@ Device::~Device() } bool -Device::preview( StatusCallback statusCallback, QString &err ) +Device::preview( QString &err ) { (void) statusCallback; (void) err; diff --git a/src/Device.h b/src/Device.h index 331ce227b..a67d8f05d 100644 --- a/src/Device.h +++ b/src/Device.h @@ -44,20 +44,21 @@ typedef boost::shared_ptr DevicePtr; struct Device { - Device( CommPortPtr dev ) : dev( dev ) {}; - virtual ~Device(); - typedef boost::function CancelCallback; typedef boost::function StatusCallback; typedef boost::function ProgressCallback; - virtual bool preview( StatusCallback statusCallback, QString &err ); + Device( CommPortPtr dev, StatusCallback cb ) + : dev( dev ), statusCallback( cb ) + {}; + virtual ~Device(); + + virtual bool preview( QString &err ); virtual QList &rides(); virtual bool download( const QDir &tmpdir, QList &files, CancelCallback cancelCallback, - StatusCallback statusCallback, ProgressCallback progressCallback, QString &err) = 0; @@ -66,7 +67,7 @@ struct Device protected: QList rideList; CommPortPtr dev; - + StatusCallback statusCallback; }; struct Devices; @@ -74,7 +75,7 @@ typedef boost::shared_ptr DevicesPtr; struct Devices { - virtual DevicePtr newDevice( CommPortPtr ) = 0; + virtual DevicePtr newDevice( CommPortPtr, Device::StatusCallback ) = 0; // port *might* be supported by this device type implementation: virtual bool supportsPort( CommPortPtr dev ) { (void)dev; return true; }; diff --git a/src/DownloadRideDialog.cpp b/src/DownloadRideDialog.cpp index 483c4e366..cc63b91e0 100644 --- a/src/DownloadRideDialog.cpp +++ b/src/DownloadRideDialog.cpp @@ -266,11 +266,10 @@ DownloadRideDialog::downloadClicked() QList files; DevicesPtr devtype = Devices::getType(deviceCombo->currentText()); - DevicePtr device = devtype->newDevice( dev ); + DevicePtr device = devtype->newDevice( dev, + boost::bind(&DownloadRideDialog::updateStatus, this, _1) ); - if( ! device->preview( - boost::bind(&DownloadRideDialog::updateStatus, this, _1), - err ) ){ + if( ! device->preview( err ) ){ QMessageBox::information(this, tr("Preview failed"), err); updateAction( actionIdle ); @@ -287,7 +286,6 @@ DownloadRideDialog::downloadClicked() if (!device->download( home, files, boost::bind(&DownloadRideDialog::isCancelled, this), - boost::bind(&DownloadRideDialog::updateStatus, this, _1), boost::bind(&DownloadRideDialog::updateProgress, this, _1), err)) { @@ -398,7 +396,8 @@ DownloadRideDialog::eraseClicked() } assert(dev); DevicesPtr devtype = Devices::getType(deviceCombo->currentText()); - DevicePtr device = devtype->newDevice( dev ); + DevicePtr device = devtype->newDevice( dev, + boost::bind(&DownloadRideDialog::updateStatus, this, _1) ); QString err; if( device->cleanup( err) ) diff --git a/src/MacroDevice.cpp b/src/MacroDevice.cpp index 89153feb6..2d583840b 100644 --- a/src/MacroDevice.cpp +++ b/src/MacroDevice.cpp @@ -51,9 +51,9 @@ MacroDevices::downloadInstructions() const } DevicePtr -MacroDevices::newDevice( CommPortPtr dev ) +MacroDevices::newDevice( CommPortPtr dev, Device::StatusCallback cb ) { - return DevicePtr( new MacroDevice( dev )); + return DevicePtr( new MacroDevice( dev, cb )); } static QString @@ -94,7 +94,6 @@ bool MacroDevice::download( const QDir &tmpdir, QList &files, CancelCallback cancelCallback, - StatusCallback statusCallback, ProgressCallback progressCallback, QString &err) { diff --git a/src/MacroDevice.h b/src/MacroDevice.h index 4f0babdd4..dc7dc134e 100644 --- a/src/MacroDevice.h +++ b/src/MacroDevice.h @@ -8,20 +8,19 @@ class DeviceFileInfo; struct MacroDevices : public Devices { - virtual DevicePtr newDevice( CommPortPtr dev ); + virtual DevicePtr newDevice( CommPortPtr dev, Device::StatusCallback cb ); virtual QString downloadInstructions() const; virtual bool canCleanup( void ) {return true; }; }; struct MacroDevice : public Device { - MacroDevice( CommPortPtr dev ) : - Device( dev ) {}; + MacroDevice( CommPortPtr dev, StatusCallback cb ) : + Device( dev, cb ) {}; virtual bool download( const QDir &tmpdir, QList &files, CancelCallback cancelCallback, - StatusCallback statusCallback, ProgressCallback progressCallback, QString &err); diff --git a/src/PowerTapDevice.cpp b/src/PowerTapDevice.cpp index 488de9621..43d3a8973 100644 --- a/src/PowerTapDevice.cpp +++ b/src/PowerTapDevice.cpp @@ -26,9 +26,9 @@ static bool powerTapRegistered = Devices::addType("PowerTap", DevicesPtr(new PowerTapDevices()) ); DevicePtr -PowerTapDevices::newDevice( CommPortPtr dev ) +PowerTapDevices::newDevice( CommPortPtr dev, Device::StatusCallback cb) { - return DevicePtr( new PowerTapDevice( dev )); + return DevicePtr( new PowerTapDevice( dev, cb )); } QString @@ -123,7 +123,6 @@ bool PowerTapDevice::download( const QDir &tmpdir, QList &files, CancelCallback cancelCallback, - StatusCallback statusCallback, ProgressCallback progressCallback, QString &err) { diff --git a/src/PowerTapDevice.h b/src/PowerTapDevice.h index f67810cef..9966122bf 100644 --- a/src/PowerTapDevice.h +++ b/src/PowerTapDevice.h @@ -24,19 +24,18 @@ struct PowerTapDevices : public Devices { - virtual DevicePtr newDevice( CommPortPtr dev ); + virtual DevicePtr newDevice( CommPortPtr dev, Device::StatusCallback cb ); virtual QString downloadInstructions() const; }; struct PowerTapDevice : public Device { - PowerTapDevice( CommPortPtr dev ) : - Device( dev ) {}; + PowerTapDevice( CommPortPtr dev, StatusCallback cb ) : + Device( dev, cb ) {}; virtual bool download( const QDir &tmpdir, QList &files, CancelCallback cancelCallback, - StatusCallback statusCallback, ProgressCallback progressCallback, QString &err); }; diff --git a/src/SrmDevice.cpp b/src/SrmDevice.cpp index f07f8f87b..e5ec369b0 100644 --- a/src/SrmDevice.cpp +++ b/src/SrmDevice.cpp @@ -32,9 +32,9 @@ static bool srm7Registered = Devices::addType("SRM PCVI/7", DevicesPtr(new SrmDevices( 7 ))); DevicePtr -SrmDevices::newDevice( CommPortPtr dev ) +SrmDevices::newDevice( CommPortPtr dev, Device::StatusCallback cb ) { - return DevicePtr( new SrmDevice( dev, protoVersion)); + return DevicePtr( new SrmDevice( dev, cb, protoVersion)); } bool @@ -228,7 +228,7 @@ SrmDevice::close( void ) } bool -SrmDevice::preview( StatusCallback statusCallback, QString &err ) +SrmDevice::preview( QString &err ) { srmio_error_t serr; struct _srmio_pc_xfer_block_t block; @@ -284,7 +284,6 @@ bool SrmDevice::download( const QDir &tmpdir, QList &files, CancelCallback cancelCallback, - StatusCallback statusCallback, ProgressCallback progressCallback, QString &err) { @@ -331,7 +330,7 @@ SrmDevice::download( const QDir &tmpdir, // fetch preview in case user didn't if( srmio_pc_can_preview(pc) && rideList.size() == 0 ){ - if( ! preview( statusCallback, err ) ) + if( ! preview( err ) ) return false; } diff --git a/src/SrmDevice.h b/src/SrmDevice.h index 5e6c94345..8faecdc3b 100644 --- a/src/SrmDevice.h +++ b/src/SrmDevice.h @@ -27,7 +27,7 @@ struct SrmDevices : public Devices { SrmDevices( int protoVersion ) : protoVersion( protoVersion ) {} - virtual DevicePtr newDevice( CommPortPtr dev ); + virtual DevicePtr newDevice( CommPortPtr dev, Device::StatusCallback cb ); virtual bool canCleanup( void ) {return true; }; virtual bool supportsPort( CommPortPtr dev ); virtual bool exclusivePort( CommPortPtr dev ); @@ -38,19 +38,18 @@ private: struct SrmDevice : public Device { - SrmDevice( CommPortPtr dev, int protoVersion ) : - Device( dev ), + SrmDevice( CommPortPtr dev, StatusCallback cb, int protoVersion ) : + Device( dev, cb ), protoVersion( protoVersion ), is_open( false ), io( NULL ), pc( NULL ) { }; ~SrmDevice(); - virtual bool preview( StatusCallback statusCallback, QString &err ); + virtual bool preview( QString &err ); virtual bool download( const QDir &tmpdir, QList &files, CancelCallback cancelCallback, - StatusCallback statusCallback, ProgressCallback progressCallback, QString &err);