bool MtpProperty::read(MtpDataPacket& packet) { uint8_t temp8; if (!packet.getUInt16(mCode)) return false; bool deviceProp = isDeviceProperty(); if (!packet.getUInt16(mType)) return false; if (!packet.getUInt8(temp8)) return false; mWriteable = (temp8 == 1); switch (mType) { case MTP_TYPE_AINT8: case MTP_TYPE_AUINT8: case MTP_TYPE_AINT16: case MTP_TYPE_AUINT16: case MTP_TYPE_AINT32: case MTP_TYPE_AUINT32: case MTP_TYPE_AINT64: case MTP_TYPE_AUINT64: case MTP_TYPE_AINT128: case MTP_TYPE_AUINT128: mDefaultArrayValues = readArrayValues(packet, mDefaultArrayLength); if (!mDefaultArrayValues) return false; if (deviceProp) { mCurrentArrayValues = readArrayValues(packet, mCurrentArrayLength); if (!mCurrentArrayValues) return false; } break; default: if (!readValue(packet, mDefaultValue)) return false; if (deviceProp) { if (!readValue(packet, mCurrentValue)) return false; } } if (!deviceProp) { if (!packet.getUInt32(mGroupCode)) return false; } if (!packet.getUInt8(mFormFlag)) return false; if (mFormFlag == kFormRange) { if (!readValue(packet, mMinimumValue)) return false; if (!readValue(packet, mMaximumValue)) return false; if (!readValue(packet, mStepSize)) return false; } else if (mFormFlag == kFormEnum) { if (!packet.getUInt16(mEnumLength)) return false; mEnumValues = new MtpPropertyValue[mEnumLength]; for (int i = 0; i < mEnumLength; i++) { if (!readValue(packet, mEnumValues[i])) return false; } } return true; }
void MtpProperty::read(MtpDataPacket& packet) { mCode = packet.getUInt16(); bool deviceProp = isDeviceProperty(); mType = packet.getUInt16(); mWriteable = (packet.getUInt8() == 1); switch (mType) { case MTP_TYPE_AINT8: case MTP_TYPE_AUINT8: case MTP_TYPE_AINT16: case MTP_TYPE_AUINT16: case MTP_TYPE_AINT32: case MTP_TYPE_AUINT32: case MTP_TYPE_AINT64: case MTP_TYPE_AUINT64: case MTP_TYPE_AINT128: case MTP_TYPE_AUINT128: mDefaultArrayValues = readArrayValues(packet, mDefaultArrayLength); if (deviceProp) mCurrentArrayValues = readArrayValues(packet, mCurrentArrayLength); break; default: readValue(packet, mDefaultValue); if (deviceProp) readValue(packet, mCurrentValue); } if (!deviceProp) mGroupCode = packet.getUInt32(); mFormFlag = packet.getUInt8(); if (mFormFlag == kFormRange) { readValue(packet, mMinimumValue); readValue(packet, mMaximumValue); readValue(packet, mStepSize); } else if (mFormFlag == kFormEnum) { mEnumLength = packet.getUInt16(); mEnumValues = new MtpPropertyValue[mEnumLength]; for (int i = 0; i < mEnumLength; i++) readValue(packet, mEnumValues[i]); } }
void MtpObjectInfo::read(MtpDataPacket& packet) { MtpStringBuffer string; time_t time; mStorageID = packet.getUInt32(); mFormat = packet.getUInt16(); mProtectionStatus = packet.getUInt16(); mCompressedSize = packet.getUInt32(); mThumbFormat = packet.getUInt16(); mThumbCompressedSize = packet.getUInt32(); mThumbPixWidth = packet.getUInt32(); mThumbPixHeight = packet.getUInt32(); mImagePixWidth = packet.getUInt32(); mImagePixHeight = packet.getUInt32(); mImagePixDepth = packet.getUInt32(); mParent = packet.getUInt32(); mAssociationType = packet.getUInt16(); mAssociationDesc = packet.getUInt32(); mSequenceNumber = packet.getUInt32(); packet.getString(string); mName = strdup((const char *)string); packet.getString(string); if (parseDateTime((const char*)string, time)) mDateCreated = time; packet.getString(string); if (parseDateTime((const char*)string, time)) mDateModified = time; packet.getString(string); mKeywords = strdup((const char *)string); }