Mike Lockwood | 3743365 | 2010-05-19 15:12:14 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Mike Lockwood | 90f4873 | 2010-06-05 22:45:01 -0400 | [diff] [blame] | 17 | #define LOG_TAG "MtpObjectInfo" |
Mike Lockwood | 3743365 | 2010-05-19 15:12:14 -0400 | [diff] [blame] | 18 | |
Mike Lockwood | 3e6616d | 2010-06-29 18:11:52 -0400 | [diff] [blame] | 19 | #include "MtpDebug.h" |
Mike Lockwood | 3743365 | 2010-05-19 15:12:14 -0400 | [diff] [blame] | 20 | #include "MtpDataPacket.h" |
| 21 | #include "MtpObjectInfo.h" |
| 22 | #include "MtpStringBuffer.h" |
| 23 | #include "MtpUtils.h" |
| 24 | |
| 25 | namespace android { |
| 26 | |
| 27 | MtpObjectInfo::MtpObjectInfo(MtpObjectHandle handle) |
| 28 | : mHandle(handle), |
| 29 | mStorageID(0), |
| 30 | mFormat(0), |
| 31 | mProtectionStatus(0), |
| 32 | mCompressedSize(0), |
| 33 | mThumbFormat(0), |
| 34 | mThumbCompressedSize(0), |
| 35 | mThumbPixWidth(0), |
| 36 | mThumbPixHeight(0), |
| 37 | mImagePixWidth(0), |
| 38 | mImagePixHeight(0), |
| 39 | mImagePixDepth(0), |
| 40 | mParent(0), |
| 41 | mAssociationType(0), |
| 42 | mAssociationDesc(0), |
| 43 | mSequenceNumber(0), |
| 44 | mName(NULL), |
| 45 | mDateCreated(0), |
| 46 | mDateModified(0), |
| 47 | mKeywords(NULL) |
| 48 | { |
| 49 | } |
| 50 | |
| 51 | MtpObjectInfo::~MtpObjectInfo() { |
| 52 | if (mName) |
| 53 | free(mName); |
| 54 | if (mKeywords) |
| 55 | free(mKeywords); |
| 56 | } |
| 57 | |
| 58 | void MtpObjectInfo::read(MtpDataPacket& packet) { |
| 59 | MtpStringBuffer string; |
| 60 | time_t time; |
| 61 | |
| 62 | mStorageID = packet.getUInt32(); |
| 63 | mFormat = packet.getUInt16(); |
| 64 | mProtectionStatus = packet.getUInt16(); |
| 65 | mCompressedSize = packet.getUInt32(); |
| 66 | mThumbFormat = packet.getUInt16(); |
Mike Lockwood | f724eed | 2010-06-08 07:33:14 -0400 | [diff] [blame] | 67 | mThumbCompressedSize = packet.getUInt32(); |
Mike Lockwood | 3743365 | 2010-05-19 15:12:14 -0400 | [diff] [blame] | 68 | mThumbPixWidth = packet.getUInt32(); |
| 69 | mThumbPixHeight = packet.getUInt32(); |
| 70 | mImagePixWidth = packet.getUInt32(); |
| 71 | mImagePixHeight = packet.getUInt32(); |
| 72 | mImagePixDepth = packet.getUInt32(); |
| 73 | mParent = packet.getUInt32(); |
| 74 | mAssociationType = packet.getUInt16(); |
| 75 | mAssociationDesc = packet.getUInt32(); |
| 76 | mSequenceNumber = packet.getUInt32(); |
| 77 | |
| 78 | packet.getString(string); |
| 79 | mName = strdup((const char *)string); |
| 80 | |
| 81 | packet.getString(string); |
| 82 | if (parseDateTime((const char*)string, time)) |
| 83 | mDateCreated = time; |
| 84 | |
| 85 | packet.getString(string); |
| 86 | if (parseDateTime((const char*)string, time)) |
| 87 | mDateModified = time; |
| 88 | |
| 89 | packet.getString(string); |
| 90 | mKeywords = strdup((const char *)string); |
| 91 | } |
| 92 | |
| 93 | void MtpObjectInfo::print() { |
Mike Lockwood | 90f4873 | 2010-06-05 22:45:01 -0400 | [diff] [blame] | 94 | LOGD("MtpObject Info %08X: %s\n", mHandle, mName); |
Mike Lockwood | f724eed | 2010-06-08 07:33:14 -0400 | [diff] [blame] | 95 | LOGD(" mStorageID: %08X mFormat: %04X mProtectionStatus: %d\n", |
| 96 | mStorageID, mFormat, mProtectionStatus); |
| 97 | LOGD(" mCompressedSize: %d mThumbFormat: %04X mThumbCompressedSize: %d\n", |
| 98 | mCompressedSize, mFormat, mThumbCompressedSize); |
| 99 | LOGD(" mThumbPixWidth: %d mThumbPixHeight: %d\n", mThumbPixWidth, mThumbPixHeight); |
| 100 | LOGD(" mImagePixWidth: %d mImagePixHeight: %d mImagePixDepth: %d\n", |
| 101 | mImagePixWidth, mImagePixHeight, mImagePixDepth); |
| 102 | LOGD(" mParent: %08X mAssociationType: %04X mAssociationDesc: %04X\n", |
| 103 | mParent, mAssociationType, mAssociationDesc); |
Mike Lockwood | ac745c1 | 2010-09-25 21:38:13 -0400 | [diff] [blame] | 104 | LOGD(" mSequenceNumber: %d mDateCreated: %ld mDateModified: %ld mKeywords: %s\n", |
Mike Lockwood | f724eed | 2010-06-08 07:33:14 -0400 | [diff] [blame] | 105 | mSequenceNumber, mDateCreated, mDateModified, mKeywords); |
Mike Lockwood | 3743365 | 2010-05-19 15:12:14 -0400 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | } // namespace android |