Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b6da06e9 authored by Mike Lockwood's avatar Mike Lockwood Committed by Mike Lockwood
Browse files

MTP: Partial implementation of the GetObjectPropList command



In this initial implementation we only support fetching one property at a time.
Support depth = 0 (single object) or depth = 1 (all objects in a directory)
Reimplemented GetObjectPropValue on top of GetObjectPropList, since the former
is a special case of the latter.

Change-Id: Ia76ee61741d6ee3902b5c5d9fc094cf86dfaf650
Signed-off-by: default avatarMike Lockwood <lockwood@google.com>
parent 2d71233d
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -75,6 +75,12 @@ public:


    virtual MtpResponseCode         resetDeviceProperty(MtpDeviceProperty property) = 0;
    virtual MtpResponseCode         resetDeviceProperty(MtpDeviceProperty property) = 0;


    virtual MtpResponseCode         getObjectPropertyList(MtpObjectHandle handle,
                                            MtpObjectFormat format,
                                            MtpObjectProperty property,
                                            int groupCode, int depth,
                                            MtpDataPacket& packet) = 0;

    virtual MtpResponseCode         getObjectInfo(MtpObjectHandle handle,
    virtual MtpResponseCode         getObjectInfo(MtpObjectHandle handle,
                                            MtpDataPacket& packet) = 0;
                                            MtpDataPacket& packet) = 0;


+11 −1
Original line number Original line Diff line number Diff line
@@ -56,6 +56,10 @@ static const CodeEntry sOperationCodes[] = {
    { "MTP_OPERATION_GET_OBJECT_PROP_DESC",         0x9802 },
    { "MTP_OPERATION_GET_OBJECT_PROP_DESC",         0x9802 },
    { "MTP_OPERATION_GET_OBJECT_PROP_VALUE",        0x9803 },
    { "MTP_OPERATION_GET_OBJECT_PROP_VALUE",        0x9803 },
    { "MTP_OPERATION_SET_OBJECT_PROP_VALUE",        0x9804 },
    { "MTP_OPERATION_SET_OBJECT_PROP_VALUE",        0x9804 },
    { "MTP_OPERATION_GET_OBJECT_PROP_LIST",         0x9805 },
    { "MTP_OPERATION_SET_OBJECT_PROP_LIST",         0x9806 },
    { "MTP_OPERATION_GET_INTERDEPENDENT_PROP_DESC", 0x9807 },
    { "MTP_OPERATION_SEND_OBJECT_PROP_LIST",        0x9808 },
    { "MTP_OPERATION_GET_OBJECT_REFERENCES",        0x9810 },
    { "MTP_OPERATION_GET_OBJECT_REFERENCES",        0x9810 },
    { "MTP_OPERATION_SET_OBJECT_REFERENCES",        0x9811 },
    { "MTP_OPERATION_SET_OBJECT_REFERENCES",        0x9811 },
    { "MTP_OPERATION_SKIP",                         0x9820 },
    { "MTP_OPERATION_SKIP",                         0x9820 },
@@ -371,15 +375,21 @@ const char* MtpDebug::getOperationCodeName(MtpOperationCode code) {
    return getCodeName(code, sOperationCodes);
    return getCodeName(code, sOperationCodes);
}
}


const char* MtpDebug::getFormatCodeName(MtpOperationCode code) {
const char* MtpDebug::getFormatCodeName(MtpObjectFormat code) {
    if (code == 0)
        return "NONE";
    return getCodeName(code, sFormatCodes);
    return getCodeName(code, sFormatCodes);
}
}


const char* MtpDebug::getObjectPropCodeName(MtpPropertyCode code) {
const char* MtpDebug::getObjectPropCodeName(MtpPropertyCode code) {
    if (code == 0)
        return "NONE";
    return getCodeName(code, sObjectPropCodes);
    return getCodeName(code, sObjectPropCodes);
}
}


const char* MtpDebug::getDevicePropCodeName(MtpPropertyCode code) {
const char* MtpDebug::getDevicePropCodeName(MtpPropertyCode code) {
    if (code == 0)
        return "NONE";
    return getCodeName(code, sDevicePropCodes);
    return getCodeName(code, sDevicePropCodes);
}
}


+1 −1
Original line number Original line Diff line number Diff line
@@ -53,7 +53,7 @@ MtpProperty::MtpProperty(MtpPropertyCode propCode,
        mDefaultArrayValues(NULL),
        mDefaultArrayValues(NULL),
        mCurrentArrayLength(0),
        mCurrentArrayLength(0),
        mCurrentArrayValues(NULL),
        mCurrentArrayValues(NULL),
        mGroupCode(0),
        mGroupCode(-1), // disable multiple properties in GetObjectPropList for now
        mFormFlag(kFormNone),
        mFormFlag(kFormNone),
        mEnumLength(0),
        mEnumLength(0),
        mEnumValues(NULL)
        mEnumValues(NULL)
+21 −0
Original line number Original line Diff line number Diff line
@@ -72,6 +72,10 @@ static const MtpOperationCode kSupportedOperationCodes[] = {
    MTP_OPERATION_GET_OBJECT_PROP_DESC,
    MTP_OPERATION_GET_OBJECT_PROP_DESC,
    MTP_OPERATION_GET_OBJECT_PROP_VALUE,
    MTP_OPERATION_GET_OBJECT_PROP_VALUE,
    MTP_OPERATION_SET_OBJECT_PROP_VALUE,
    MTP_OPERATION_SET_OBJECT_PROP_VALUE,
    MTP_OPERATION_GET_OBJECT_PROP_LIST,
//    MTP_OPERATION_SET_OBJECT_PROP_LIST,
//    MTP_OPERATION_GET_INTERDEPENDENT_PROP_DESC,
//    MTP_OPERATION_SEND_OBJECT_PROP_LIST,
    MTP_OPERATION_GET_OBJECT_REFERENCES,
    MTP_OPERATION_GET_OBJECT_REFERENCES,
    MTP_OPERATION_SET_OBJECT_REFERENCES,
    MTP_OPERATION_SET_OBJECT_REFERENCES,
//    MTP_OPERATION_SKIP,
//    MTP_OPERATION_SKIP,
@@ -276,6 +280,9 @@ bool MtpServer::handleRequest() {
        case MTP_OPERATION_RESET_DEVICE_PROP_VALUE:
        case MTP_OPERATION_RESET_DEVICE_PROP_VALUE:
            response = doResetDevicePropValue();
            response = doResetDevicePropValue();
            break;
            break;
        case MTP_OPERATION_GET_OBJECT_PROP_LIST:
            response = doGetObjectPropList();
            break;
        case MTP_OPERATION_GET_OBJECT_INFO:
        case MTP_OPERATION_GET_OBJECT_INFO:
            response = doGetObjectInfo();
            response = doGetObjectInfo();
            break;
            break;
@@ -523,6 +530,20 @@ MtpResponseCode MtpServer::doResetDevicePropValue() {
    return mDatabase->resetDeviceProperty(property);
    return mDatabase->resetDeviceProperty(property);
}
}


MtpResponseCode MtpServer::doGetObjectPropList() {

    MtpObjectHandle handle = mRequest.getParameter(1);
    MtpObjectFormat format = mRequest.getParameter(2);
    MtpDeviceProperty property = mRequest.getParameter(3);
    int groupCode = mRequest.getParameter(4);
    int depth = mRequest.getParameter(4);
   LOGD("GetObjectPropList %d format: %s property: %s group: %d depth: %d\n",
            handle, MtpDebug::getFormatCodeName(format),
            MtpDebug::getObjectPropCodeName(property), groupCode, depth);

    return mDatabase->getObjectPropertyList(handle, format, property, groupCode, depth, mData);
}

MtpResponseCode MtpServer::doGetObjectInfo() {
MtpResponseCode MtpServer::doGetObjectInfo() {
    MtpObjectHandle handle = mRequest.getParameter(1);
    MtpObjectHandle handle = mRequest.getParameter(1);
    return mDatabase->getObjectInfo(handle, mData);
    return mDatabase->getObjectInfo(handle, mData);
+1 −0
Original line number Original line Diff line number Diff line
@@ -93,6 +93,7 @@ private:
    MtpResponseCode     doGetDevicePropValue();
    MtpResponseCode     doGetDevicePropValue();
    MtpResponseCode     doSetDevicePropValue();
    MtpResponseCode     doSetDevicePropValue();
    MtpResponseCode     doResetDevicePropValue();
    MtpResponseCode     doResetDevicePropValue();
    MtpResponseCode     doGetObjectPropList();
    MtpResponseCode     doGetObjectInfo();
    MtpResponseCode     doGetObjectInfo();
    MtpResponseCode     doGetObject();
    MtpResponseCode     doGetObject();
    MtpResponseCode     doSendObjectInfo();
    MtpResponseCode     doSendObjectInfo();
Loading