From: <mar...@us...> - 2006-05-27 08:41:11
|
Revision: 8820 Author: marcusmeissner Date: 2006-05-27 01:40:54 -0700 (Sat, 27 May 2006) ViewCVS: http://svn.sourceforge.net/gphoto/?rev=8820&view=rev Log Message: ----------- added mtp_setobjectreferences, mtp_getobjectrefernces, based on patch by dave kelly. Modified Paths: -------------- trunk/libgphoto2/camlibs/ptp2/ptp-pack.c trunk/libgphoto2/camlibs/ptp2/ptp.c trunk/libgphoto2/camlibs/ptp2/ptp.h Modified: trunk/libgphoto2/camlibs/ptp2/ptp-pack.c =================================================================== --- trunk/libgphoto2/camlibs/ptp2/ptp-pack.c 2006-05-26 09:35:10 UTC (rev 8819) +++ trunk/libgphoto2/camlibs/ptp2/ptp-pack.c 2006-05-27 08:40:54 UTC (rev 8820) @@ -131,6 +131,18 @@ } static inline uint32_t +ptp_pack_uint32_t_array(PTPParams *params, uint32_t *array, uint32_t arraylen, unsigned char **data ) +{ + uint32_t i=0; + + *data = malloc ((arraylen+1)*sizeof(uint32_t)); + htod32a(&(*data)[0],arraylen); + for (i=0;i<arraylen;i++) + htod32a(&(*data)[sizeof(uint32_t)*(i+1)], array[i]); + return (arraylen+1)*sizeof(uint32_t); +} + +static inline uint32_t ptp_unpack_uint16_t_array(PTPParams *params, unsigned char* data, uint16_t offset, uint16_t **array) { uint32_t n, i=0; Modified: trunk/libgphoto2/camlibs/ptp2/ptp.c =================================================================== --- trunk/libgphoto2/camlibs/ptp2/ptp.c 2006-05-26 09:35:10 UTC (rev 8819) +++ trunk/libgphoto2/camlibs/ptp2/ptp.c 2006-05-27 08:40:54 UTC (rev 8820) @@ -1920,6 +1920,41 @@ return ret; } +uint16_t +ptp_mtp_getobjectreferences (PTPParams* params, uint32_t handle, uint32_t** ohArray, uint32_t* arraylen) +{ + PTPContainer ptp; + uint16_t ret; + unsigned char* dpv=NULL; + + PTP_CNT_INIT(ptp); + ptp.Code=PTP_OC_MTP_GetObjectReferences; + ptp.Param1=handle; + ptp.Nparam=1; + ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &dpv, NULL); + if (ret == PTP_RC_OK) *arraylen = ptp_unpack_uint32_t_array(params, dpv, 0, ohArray); + free(dpv); + return ret; +} + +uint16_t +ptp_mtp_setobjectreferences (PTPParams* params, uint32_t handle, uint32_t* ohArray, uint32_t arraylen) +{ + PTPContainer ptp; + uint16_t ret; + uint32_t size; + unsigned char* dpv=NULL; + + PTP_CNT_INIT(ptp); + ptp.Code = PTP_OC_MTP_SetObjectReferences; + ptp.Param1 = handle; + ptp.Nparam = 1; + size = ptp_pack_uint32_t_array(params, ohArray, arraylen, &dpv); + ret = ptp_transaction(params, &ptp, PTP_DP_SENDDATA, size, (unsigned char **)&dpv, NULL); + free(dpv); + return ret; +} + /* Non PTP protocol functions */ /* devinfo testing functions */ Modified: trunk/libgphoto2/camlibs/ptp2/ptp.h =================================================================== --- trunk/libgphoto2/camlibs/ptp2/ptp.h 2006-05-26 09:35:10 UTC (rev 8819) +++ trunk/libgphoto2/camlibs/ptp2/ptp.h 2006-05-27 08:40:54 UTC (rev 8820) @@ -1134,7 +1134,10 @@ PTPPropertyValue *value, uint16_t datatype); uint16_t ptp_mtp_setobjectpropvalue (PTPParams* params, uint32_t oid, uint16_t opc, PTPPropertyValue *value, uint16_t datatype); +uint16_t ptp_mtp_getobjectreferences (PTPParams* params, uint32_t handle, uint32_t** ohArray, uint32_t* arraylen); +uint16_t ptp_mtp_setobjectreferences (PTPParams* params, uint32_t handle, uint32_t* ohArray, uint32_t arraylen); + /* Eastman Kodak extensions */ uint16_t ptp_ek_9007 (PTPParams* params, unsigned char **serial, unsigned int *size); uint16_t ptp_ek_9009 (PTPParams* params, uint32_t*, uint32_t*); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |