blob: 4923d40276fc8162e19642a7cc67b84c747142f8 [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();
Mike Lockwood21ef7d02010-06-30 17:00:35 -040058 MtpProperty(MtpPropertyCode propCode,
59 MtpDataType type,
60 bool writeable = false,
61 int defaultValue = 0);
Mike Lockwooda6c490b2010-06-05 22:45:01 -040062 virtual ~MtpProperty();
63
Mike Lockwood21ef7d02010-06-30 17:00:35 -040064 inline MtpPropertyCode getPropertyCode() const { return mCode; }
65
66 void read(MtpDataPacket& packet, bool deviceProp);
67 void write(MtpDataPacket& packet);
Mike Lockwooda6c490b2010-06-05 22:45:01 -040068
69 void print();
70
71private:
72 void readValue(MtpDataPacket& packet, MtpPropertyValue& value);
Mike Lockwood21ef7d02010-06-30 17:00:35 -040073 void writeValue(MtpDataPacket& packet, MtpPropertyValue& value);
Mike Lockwooda6c490b2010-06-05 22:45:01 -040074 MtpPropertyValue* readArrayValues(MtpDataPacket& packet, int& length);
Mike Lockwood21ef7d02010-06-30 17:00:35 -040075 void writeArrayValues(MtpDataPacket& packet, MtpPropertyValue* values, int length);
Mike Lockwooda6c490b2010-06-05 22:45:01 -040076};
77
78}; // namespace android
79
80#endif // _MTP_PROPERTY_H