|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // cmtpequestchecker.h |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @internalTechnology |
|
21 */ |
|
22 |
|
23 #ifndef __CMTPREQUESTCHECKER_H__ |
|
24 #define __CMTPREQUESTCHECKER_H__ |
|
25 |
|
26 #include <e32base.h> |
|
27 #include <mtp/mtpprotocolconstants.h> |
|
28 #include <mtp/tmtptyperequest.h> |
|
29 #include "mtpdebug.h" |
|
30 |
|
31 class CMTPObjectMetaData; |
|
32 class MMTPDataProviderFramework; |
|
33 class MMTPConnection; |
|
34 |
|
35 /** |
|
36 element type in the request |
|
37 @internalTechnology |
|
38 */ |
|
39 enum TMTPElementType |
|
40 { |
|
41 /** |
|
42 Session ID type |
|
43 */ |
|
44 EMTPElementTypeSessionID, |
|
45 |
|
46 /** |
|
47 Object Handle type |
|
48 */ |
|
49 EMTPElementTypeObjectHandle, |
|
50 |
|
51 /** |
|
52 Format code type |
|
53 */ |
|
54 EMTPElementTypeFormatCode, |
|
55 |
|
56 /** |
|
57 Storeage Id type |
|
58 */ |
|
59 EMTPElementTypeStorageId, |
|
60 }; |
|
61 |
|
62 /** |
|
63 element attribute to check in the reqeust |
|
64 @internalTechnology |
|
65 */ |
|
66 enum TMTPElementAttr |
|
67 { |
|
68 /** |
|
69 no attribute to check |
|
70 */ |
|
71 EMTPElementAttrNone = 0x0000, |
|
72 |
|
73 /** |
|
74 the object/storage should be readable |
|
75 */ |
|
76 EMTPElementAttrRead = 0x0001, |
|
77 |
|
78 /** |
|
79 the object/storage should be writable |
|
80 */ |
|
81 EMTPElementAttrWrite = 0x0002, |
|
82 |
|
83 /** |
|
84 the object should be a file |
|
85 */ |
|
86 EMTPElementAttrFile = 0x0004, |
|
87 |
|
88 /** |
|
89 the object should be a directory |
|
90 */ |
|
91 EMTPElementAttrDir = 0x0008, |
|
92 |
|
93 /** |
|
94 supported format array |
|
95 */ |
|
96 EMTPElementAttrFormatEnums = 0x0010, |
|
97 |
|
98 /** |
|
99 The object can be either a file or directory. |
|
100 */ |
|
101 EMTPElementAttrFileOrDir = 0x0020, |
|
102 }; |
|
103 |
|
104 /** |
|
105 defines the verification data structure |
|
106 @internalTechnology |
|
107 */ |
|
108 struct TMTPRequestElementInfo |
|
109 { |
|
110 TMTPTypeRequest::TElements iElementIndex; //which element in the request to check |
|
111 TMTPElementType iElementType; //the type of the element |
|
112 TInt iElementAttr; //the attribute of the element |
|
113 TInt iCount; //number of special values (0, 1, 2) |
|
114 TUint32 iValue1; //special value 1 |
|
115 TUint32 iValue2; //special value 2 |
|
116 }; |
|
117 |
|
118 /** |
|
119 defines a generic request verification class. It iterates through the verification data elements, |
|
120 and performs the check based on the element type/attribute. |
|
121 @internalTechnology |
|
122 */ |
|
123 class CMTPRequestChecker : public CBase |
|
124 { |
|
125 public: |
|
126 IMPORT_C static CMTPRequestChecker* NewL(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection); |
|
127 IMPORT_C ~CMTPRequestChecker(); |
|
128 |
|
129 IMPORT_C TMTPResponseCode VerifyRequestL(const TMTPTypeRequest& aRequest, TInt aCount, const TMTPRequestElementInfo* aElementInfo); |
|
130 IMPORT_C CMTPObjectMetaData* GetObjectInfo(TUint32 aHandle) const; |
|
131 |
|
132 private: |
|
133 TMTPResponseCode CheckRequestHeader(const TMTPTypeRequest& aRequest) const; |
|
134 TMTPResponseCode VerifySessionId(TUint32 aSessionId, const TMTPRequestElementInfo& aElementInfo) const; |
|
135 TMTPResponseCode VerifyObjectHandleL(TUint32 aHandle, const TMTPRequestElementInfo& aElementInfo); |
|
136 TMTPResponseCode VerifyStorageIdL(TUint32 aStorageId, const TMTPRequestElementInfo& aElementInfo) const; |
|
137 TMTPResponseCode VerifyFormatCode(TUint32 aFormatCode, const TMTPRequestElementInfo& aElementInfo) const; |
|
138 TBool IsSpecialValue(TUint32 aParameter, const TMTPRequestElementInfo& aElementInfo) const; |
|
139 private: |
|
140 CMTPRequestChecker(MMTPDataProviderFramework& aFramework, MMTPConnection& aConnection); |
|
141 |
|
142 private: |
|
143 MMTPDataProviderFramework& iFramework; |
|
144 MMTPConnection& iConnection; |
|
145 RArray<TUint32> iHandles; //these two arrays contain the mapping from the handle to objectinfo |
|
146 RPointerArray<CMTPObjectMetaData> iObjectArray; |
|
147 /** |
|
148 FLOGGER debug trace member variable. |
|
149 */ |
|
150 __FLOG_DECLARATION_MEMBER_MUTABLE; |
|
151 }; |
|
152 |
|
153 #endif |
|
154 |