Added StorageInfo transaction support

git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@4269 67ed7778-7388-44ab-90cf-0a291f65f57c
This commit is contained in:
Mariusz Woloszyn
2002-03-13 15:52:06 +00:00
parent 4dba93782d
commit 778237c522
4 changed files with 76 additions and 4 deletions

View File

@@ -115,7 +115,7 @@ ptp_unpack_uint32_t_array(PTPParams *params, PTPReq *req, uint16_t offset, uint3
#define PTP_di_VendorExtensionVersion 6
#define PTP_di_VendorExtensionDesc 8
// ObjectHandles pack/unpack
// ObjectHandles array pack/unpack
#define PTP_oh 0
@@ -125,7 +125,7 @@ ptp_unpack_OH (PTPParams *params, PTPReq *req, PTPObjectHandles *oh)
oh->n = ptp_unpack_uint32_t_array(params, req, PTP_oh, oh->handler);
}
// StoreIDs pack/unpack
// StoreIDs array pack/unpack
#define PTP_sids 0
@@ -136,6 +136,33 @@ ptp_unpack_SIDs (PTPParams *params, PTPReq *req, PTPStorageIDs *sids)
sids->storage);
}
// StorageInfo pack/unpack
#define PTP_si_StorageType 0
#define PTP_si_FilesystemType 2
#define PTP_si_AccessCapability 4
#define PTP_si_MaxCapability 6
#define PTP_si_FreeSpaceInBytes 14
#define PTP_si_FreeSpaceInImages 22
#define PTP_si_StorageDescription 26
static inline void
ptp_unpack_SI (PTPParams *params, PTPReq *req, PTPStorageInfo *si)
{
uint8_t storagedescriptionlen;
si->StorageType=dtoh16a(&req->data[PTP_si_StorageType]);
si->FilesystemType=dtoh16a(&req->data[PTP_si_FilesystemType]);
si->AccessCapability=dtoh16a(&req->data[PTP_si_AccessCapability]);
// XXX no dtoh64a !!! skiping next two
si->FreeSpaceInImages=dtoh32a(&req->data[PTP_si_FreeSpaceInImages]);
si->StorageDescription=ptp_unpack_string(params, req,
PTP_si_StorageDescription, &storagedescriptionlen);
si->VolumeLabel=ptp_unpack_string(params, req,
PTP_si_StorageDescription+storagedescriptionlen*2+1,
&storagedescriptionlen);
}
// ObjectInfo pack/unpack
#define PTP_oi_StorageID 0

View File

@@ -312,6 +312,30 @@ ptp_getstorageids (PTPParams* params, PTPStorageIDs* storageids)
return ret;
}
/**
* ptp_getststorageinfo:
* params: PTPParams*
* storageid - StorageID
*
* Gets StorageInfo dataset of desired storage and fills storageinfo
* structure.
*
* Return values: Some PTP_RC_* code.
**/
uint16_t
ptp_getstorageinfo (PTPParams* params, uint32_t storageid,
PTPStorageInfo* storageinfo)
{
uint16_t ret;
PTPReq si;
PTPReq req;
ret=ptp_transaction(params, &req, PTP_OC_GetStorageInfo,
PTP_DP_GETDATA | PTP_RQ_PARAM1, PTP_REQ_DATALEN, &si);
ptp_unpack_SI(params, &si, storageinfo);
return ret;
}
/**
* ptp_getobjecthandles:
* params: PTPParams*

View File

@@ -268,6 +268,27 @@ typedef struct _PTPObjectInfo PTPObjectInfo;
#define PTP_PS_NoProtection 0x0000
#define PTP_PS_ReadOnly 0x0001
// PTP Storage Types
#define PTP_ST_Undefined 0x0000
#define PTP_ST_FixedROM 0x0001
#define PTP_ST_RemovableROM 0x0002
#define PTP_ST_FixedRAM 0x0003
#define PTP_ST_RemovableRAM 0x0004
// PTP FilesystemType Values
#define PTP_FST_Undefined 0x0000
#define PTP_FST_GenericFlat 0x0001
#define PTP_FST_GenericHierarchical 0x0002
#define PTP_FST_DCF 0x0003
// PTP StorageInfo AccessCapability Values
#define PTP_AC_ReadWrite 0x0000
#define PTP_AC_ReadOnly 0x0001
#define PTP_AC_ReadOnly_with_Object_Deletion 0x0002
// Glue stuff
typedef short (* PTPIOReadFunc) (unsigned char *bytes, unsigned int size,

View File

@@ -68,9 +68,9 @@ PTPParams* ptp_params;
ptp_opensession (ptp_params, 1);
sleep(4);
sleep(3);
printf("Checking event ep\n");
ret=usb_bulk_read(device_handle, eventep, buf, 16384, 100);
ret=usb_bulk_read(device_handle, eventep, buf, 16384, 5000);
if (ret<=0) {
perror ("bulk_read():");
} else {