diff options
author | Linus Walleij <triad@df.lth.se> | 2007-09-15 20:30:14 +0000 |
---|---|---|
committer | Linus Walleij <triad@df.lth.se> | 2007-09-15 20:30:14 +0000 |
commit | 3e418e20db3fa3ec60d069478314238b47e71354 (patch) | |
tree | da5882b884930c354158d57abc8c5e9f5556a347 /src | |
parent | 997d3ec628d61d52b526cd6a219525dc8629f6aa (diff) | |
download | libmtp-3e418e20db3fa3ec60d069478314238b47e71354.tar.gz |
Get cancellation working...
Diffstat (limited to 'src')
-rw-r--r-- | src/libmtp.c | 20 | ||||
-rw-r--r-- | src/libusb-glue.c | 11 | ||||
-rw-r--r-- | src/libusb-glue.h | 1 | ||||
-rw-r--r-- | src/ptp.c | 2 |
4 files changed, 19 insertions, 15 deletions
diff --git a/src/libmtp.c b/src/libmtp.c index 83a57cf..9c7ad88 100644 --- a/src/libmtp.c +++ b/src/libmtp.c @@ -425,7 +425,7 @@ static uint32_t adjust_u32(uint32_t val, PTPObjectPropDesc *opd) static MTPProperties * -_find_propvalue (PTPParams *params, uint32_t const oid, uint32_t const attrid) { +find_propvalue (PTPParams *params, uint32_t const oid, uint32_t const attrid) { int i; MTPProperties *prop = params->props; @@ -465,7 +465,7 @@ static char *get_string_from_object(LIBMTP_mtpdevice_t *device, uint32_t const o // This O(n) search should not be used so often, since code // using the cached properties don't usually call this function. if (params->props) { - MTPProperties *prop = _find_propvalue (params, object_id, attribute_id); + MTPProperties *prop = find_propvalue (params, object_id, attribute_id); if (prop) { if (prop->propval.str != NULL) return strdup(prop->propval.str); @@ -511,7 +511,7 @@ static uint64_t get_u64_from_object(LIBMTP_mtpdevice_t *device,uint32_t const ob // This O(n) search should not be used so often, since code // using the cached properties don't usually call this function. if (params->props) { - MTPProperties *prop = _find_propvalue (params, object_id, attribute_id); + MTPProperties *prop = find_propvalue (params, object_id, attribute_id); if (prop) return prop->propval.u64; } @@ -553,7 +553,7 @@ static uint32_t get_u32_from_object(LIBMTP_mtpdevice_t *device,uint32_t const ob // This O(n) search should not be used so often, since code // using the cached properties don't usually call this function. if (params->props) { - MTPProperties *prop = _find_propvalue (params, object_id, attribute_id); + MTPProperties *prop = find_propvalue (params, object_id, attribute_id); if (prop) return prop->propval.u32; } @@ -595,7 +595,7 @@ static uint16_t get_u16_from_object(LIBMTP_mtpdevice_t *device, uint32_t const o // This O(n) search should not be used so often, since code // using the cached properties don't usually call this function. if (params->props) { - MTPProperties *prop = _find_propvalue (params, object_id, attribute_id); + MTPProperties *prop = find_propvalue (params, object_id, attribute_id); if (prop) return prop->propval.u16; } @@ -637,7 +637,7 @@ static uint8_t get_u8_from_object(LIBMTP_mtpdevice_t *device, uint32_t const obj // This O(n) search should not be used so often, since code // using the cached properties don't usually call this function. if (params->props) { - MTPProperties *prop = _find_propvalue (params, object_id, attribute_id); + MTPProperties *prop = find_propvalue (params, object_id, attribute_id); if (prop) return prop->propval.u8; } @@ -3443,11 +3443,7 @@ int LIBMTP_Get_File_To_File_Descriptor(LIBMTP_mtpdevice_t *device, ptp_usb->current_transfer_callback_data = NULL; if (ret == PTP_ERROR_CANCEL) { - ret = ptp_usb_control_cancel_request(params, params->transaction_id); add_ptp_error_to_errorstack(device, ret, "LIBMTP_Get_File_To_File_Descriptor(): Cancelled transfer."); - if (ret != PTP_RC_OK) { - add_ptp_error_to_errorstack(device, ret, "LIBMTP_Get_File_To_File_Descriptor(): Failed to fulfill cancellation."); - } return -1; } if (ret != PTP_RC_OK) { @@ -4095,11 +4091,7 @@ int LIBMTP_Send_File_From_File_Descriptor(LIBMTP_mtpdevice_t *device, ptp_usb->current_transfer_callback_data = NULL; if (ret == PTP_ERROR_CANCEL) { - ret = ptp_usb_control_cancel_request(params, params->transaction_id); add_ptp_error_to_errorstack(device, ret, "LIBMTP_Send_File_From_File_Descriptor(): Cancelled transfer."); - if (ret != PTP_RC_OK) { - add_ptp_error_to_errorstack(device, ret, "LIBMTP_Send_File_From_File_Descriptor(): Failed to fulfill cancellation."); - } return -1; } if (ret != PTP_RC_OK) { diff --git a/src/libusb-glue.c b/src/libusb-glue.c index 92c9cfa..c4f118c 100644 --- a/src/libusb-glue.c +++ b/src/libusb-glue.c @@ -925,6 +925,10 @@ ptp_read_func ( ptp_usb->current_transfer_total, ptp_usb->current_transfer_callback_data); if (ret != 0) { + uint16_t sub_ret = ptp_usb_control_cancel_request (ptp_usb->params, ptp_usb->params->transaction_id); + if (sub_ret != PTP_RC_OK) { + return sub_ret; + } return PTP_ERROR_CANCEL; } } @@ -1013,6 +1017,10 @@ ptp_write_func ( ptp_usb->current_transfer_total, ptp_usb->current_transfer_callback_data); if (ret != 0) { + uint16_t sub_ret = ptp_usb_control_cancel_request (ptp_usb->params, ptp_usb->params->transaction_id); + if (sub_ret != PTP_RC_OK) { + return sub_ret; + } return PTP_ERROR_CANCEL; } } @@ -1747,6 +1755,9 @@ static LIBMTP_error_number_t configure_usb_devices(mtpdevice_list_t *devicelist) return LIBMTP_ERROR_MEMORY_ALLOCATION; } + /* Pointer back to params */ + tmplist->ptp_usb->params = tmplist->params; + /* TODO: Will this always be little endian? */ tmplist->params->byteorder = PTP_DL_LE; tmplist->params->cd_locale_to_ucs2 = iconv_open("UCS-2LE", "UTF-8"); diff --git a/src/libusb-glue.h b/src/libusb-glue.h index 8819d09..1ed39bb 100644 --- a/src/libusb-glue.h +++ b/src/libusb-glue.h @@ -115,6 +115,7 @@ */ typedef struct _PTP_USB PTP_USB; struct _PTP_USB { + PTPParams *params; usb_dev_handle* handle; uint8_t interface; int inep; @@ -49,7 +49,7 @@ # define N_(String) (String) #endif -#define CHECK_PTP_RC(result) {uint16_t r=(result); if (r!=PTP_RC_OK) return r;} +#define CHECK_PTP_RC(result) {uint16_t r=(result); if (r!=PTP_RC_OK && r!=PTP_ERROR_CANCEL) return r;} #define PTP_CNT_INIT(cnt) {memset(&cnt,0,sizeof(cnt));} |