diff options
Diffstat (limited to 'media/mtp/MtpClient.cpp')
-rw-r--r-- | media/mtp/MtpClient.cpp | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/media/mtp/MtpClient.cpp b/media/mtp/MtpClient.cpp index 73234b1..de3c199 100644 --- a/media/mtp/MtpClient.cpp +++ b/media/mtp/MtpClient.cpp @@ -27,6 +27,7 @@ #include "MtpClient.h" #include "MtpDebug.h" #include "MtpDeviceInfo.h" +#include "MtpObjectInfo.h" #include "MtpStorageInfo.h" #include "MtpStringBuffer.h" @@ -46,7 +47,6 @@ MtpClient::MtpClient(struct usb_endpoint *ep_in, struct usb_endpoint *ep_out, MtpClient::~MtpClient() { } - bool MtpClient::openSession() { printf("openSession\n"); mSessionID = 0; @@ -118,6 +118,41 @@ printf("getStorageInfo returned %04X\n", ret); return NULL; } +MtpObjectHandleList* MtpClient::getObjectHandles(MtpStorageID storageID, + MtpObjectFormat format, MtpObjectHandle parent) { + mRequest.reset(); + mRequest.setParameter(1, storageID); + mRequest.setParameter(2, format); + mRequest.setParameter(3, parent); + if (!sendRequest(MTP_OPERATION_GET_OBJECT_HANDLES)) + return NULL; + if (!readData()) + return NULL; + MtpResponseCode ret = readResponse(); +printf("getObjectHandles returned %04X\n", ret); + if (ret == MTP_RESPONSE_OK) { + return mData.getAUInt32(); + } + return NULL; +} + +MtpObjectInfo* MtpClient::getObjectInfo(MtpObjectHandle handle) { + mRequest.reset(); + mRequest.setParameter(1, handle); + if (!sendRequest(MTP_OPERATION_GET_OBJECT_INFO)) + return NULL; + if (!readData()) + return NULL; + MtpResponseCode ret = readResponse(); +printf("getObjectInfo returned %04X\n", ret); + if (ret == MTP_RESPONSE_OK) { + MtpObjectInfo* info = new MtpObjectInfo(handle); + info->read(mData); + return info; + } + return NULL; +} + bool MtpClient::sendRequest(MtpOperationCode operation) { printf("sendRequest: %s\n", MtpDebug::getOperationCodeName(operation)); mRequest.setOperationCode(operation); |