diff --git a/src/hobbits-plugins/importerexporters/UsbDevice/usbdevice.cpp b/src/hobbits-plugins/importerexporters/UsbDevice/usbdevice.cpp index 5fd0b914..dc8c1445 100644 --- a/src/hobbits-plugins/importerexporters/UsbDevice/usbdevice.cpp +++ b/src/hobbits-plugins/importerexporters/UsbDevice/usbdevice.cpp @@ -266,7 +266,7 @@ QSharedPointer UsbDevice::importBits(const Parameters ¶meters, attach = false; } //throw an error if an error occured - return ImportResult::error("Transfer Error, Code: " + QString::number(transferReturn) + " " + libusb_error_name(transferReturn)); + return returnError(transferReturn); } else { @@ -333,7 +333,7 @@ QSharedPointer UsbDevice::importBits(const Parameters ¶meters, libusb_reset_device(params.handle); attach = false; } - return ImportResult::error("Transfer Error, Code: " + QString::number(transferReturn) + " " + libusb_error_name(transferReturn)); + return returnError(transferReturn); } else { diff --git a/src/hobbits-plugins/importerexporters/UsbDevice/usbdevice.h b/src/hobbits-plugins/importerexporters/UsbDevice/usbdevice.h index c16e65c7..0a330702 100644 --- a/src/hobbits-plugins/importerexporters/UsbDevice/usbdevice.h +++ b/src/hobbits-plugins/importerexporters/UsbDevice/usbdevice.h @@ -4,32 +4,6 @@ #include "parameterdelegate.h" #include -typedef struct UsbParams -{ - //the pointer to the libusb device selected - libusb_device *dev; - //the pointer to the device list generated - libusb_device **devs; - //the pointer to the configuration descriptor generated - libusb_config_descriptor *config; - // the pointer to the libusb context for the active libusb session - libusb_context *ctx; - //the handle of the device used for transfers and device interactions - libusb_device_handle *handle; - //the number of the device selected - int deviceNum; - //the number of the interface selected - int interfaceNum; - //the number of the alternate setting selected - int altSetNum; - //number of the endpoint selected - int endpointNum; - //the address of the endpoint selected - unsigned char endpoint; - //any possible error codes passed - int errorCode; -}StructName; - class UsbDevice : public QObject, ImporterExporterInterface { Q_OBJECT @@ -59,14 +33,42 @@ class UsbDevice : public QObject, ImporterExporterInterface const Parameters ¶meters, QSharedPointer progress) override; - void setupLibusb(UsbParams ¶ms); + QSharedPointer returnError(int errorCode); - void exitLibusb(bool closeDevice, UsbParams ¶ms); + private: QSharedPointer m_importDelegate; QSharedPointer m_exportDelegate; - + + typedef struct UsbParams + { + //the pointer to the libusb device selected + libusb_device *dev; + //the pointer to the device list generated + libusb_device **devs; + //the pointer to the configuration descriptor generated + libusb_config_descriptor *config; + // the pointer to the libusb context for the active libusb session + libusb_context *ctx; + //the handle of the device used for transfers and device interactions + libusb_device_handle *handle; + //the number of the device selected + int deviceNum; + //the number of the interface selected + int interfaceNum; + //the number of the alternate setting selected + int altSetNum; + //number of the endpoint selected + int endpointNum; + //the address of the endpoint selected + unsigned char endpoint; + //any possible error codes passed + int errorCode; + }UsbParams; + + void exitLibusb(bool closeDevice, UsbParams ¶ms); + void setupLibusb(UsbParams ¶ms); }; diff --git a/src/hobbits-plugins/importerexporters/UsbDevice/usbdeviceimporteditor.h b/src/hobbits-plugins/importerexporters/UsbDevice/usbdeviceimporteditor.h index e028e7b3..d3423f84 100644 --- a/src/hobbits-plugins/importerexporters/UsbDevice/usbdeviceimporteditor.h +++ b/src/hobbits-plugins/importerexporters/UsbDevice/usbdeviceimporteditor.h @@ -47,8 +47,6 @@ public slots: void initLibusb(); QStringList getUsbDevices(); void updateSelector(QComboBox *selector, QStringList items); - void clearSelectors(QComboBox *boxes[]); - QString addLeadingZeros(std::string str); QStringList getVendorAndProduct(QString idVendor, QString idProduct); Ui::UsbDeviceImportEditor *ui; QSharedPointer m_paramHelper;