blob: 637229048ba52fe0810110fe811412a5cdd6606f [file] [log] [blame]
Mike Lockwooda6c490b2010-06-05 22:45:01 -04001/*
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
17#ifndef _MTP_PROPERTY_H
18#define _MTP_PROPERTY_H
19
20#include "MtpTypes.h"
21
22namespace android {
23
24class MtpDataPacket;
25
26class MtpProperty {
27public:
28 MtpPropertyCode mCode;
29 MtpDataType mType;
30 bool mWriteable;
31 MtpPropertyValue mDefaultValue;
32 MtpPropertyValue mCurrentValue;
33
34 // for array types
35 int mDefaultArrayLength;
36 MtpPropertyValue* mDefaultArrayValues;
37 int mCurrentArrayLength;
38 MtpPropertyValue* mCurrentArrayValues;
39
40 enum {
41 kFormNone = 0,
42 kFormRange = 1,
43 kFormEnum = 2,
44 };
45 uint8_t mFormFlag;
46
47 // for range form
48 MtpPropertyValue mMinimumValue;
49 MtpPropertyValue mMaximumValue;
50 MtpPropertyValue mStepSize;
51
52 // for enum form
53 int mEnumLength;
54 MtpPropertyValue* mEnumValues;
55
56public:
57 MtpProperty();
58 virtual ~MtpProperty();
59
60 void read(MtpDataPacket& packet);
61
62 void print();
63
64private:
65 void readValue(MtpDataPacket& packet, MtpPropertyValue& value);
66 MtpPropertyValue* readArrayValues(MtpDataPacket& packet, int& length);
67};
68
69}; // namespace android
70
71#endif // _MTP_PROPERTY_H