|
1 /* |
|
2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef CNATFWUNSAFUNKNOWNATTRIBUTESATTRIBUTE_H |
|
22 #define CNATFWUNSAFUNKNOWNATTRIBUTESATTRIBUTE_H |
|
23 |
|
24 // INCLUDES |
|
25 #include "natfwunsafattribute.h" |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 |
|
29 // CLASS DECLARATION |
|
30 /** |
|
31 * Class for NATFWUNSAF UNKNOWN-ATTRIBUTES attribute. |
|
32 */ |
|
33 class CNATFWUNSAFUnknownAttributesAttribute : public CNATFWUNSAFAttribute |
|
34 { |
|
35 public: // Constructors and destructor |
|
36 |
|
37 /** |
|
38 * Creates a new instance of CNATFWUNSAFUnknownAttributesAttribute |
|
39 * @return A new instance of CNATFWUNSAFUnknownAttributesAttribute |
|
40 * ownership is transferred. |
|
41 */ |
|
42 IMPORT_C static CNATFWUNSAFUnknownAttributesAttribute* NewL(); |
|
43 |
|
44 /** |
|
45 * Creates a new instance of CNATFWUNSAFUnknownAttributesAttribute and |
|
46 * pushes it to the CleanupStack. |
|
47 * @return A new instance of CNATFWUNSAFUnknownAttributesAttribute, |
|
48 * ownership is transferred. |
|
49 */ |
|
50 IMPORT_C static CNATFWUNSAFUnknownAttributesAttribute* NewLC(); |
|
51 |
|
52 /** |
|
53 * Decodes a UNSAF attribute from a byte stream. |
|
54 * This version is for lookup table. |
|
55 * @param aByteStream Byte stream, containing attribute type, length and |
|
56 * value. |
|
57 * @return Decoded UNSAF attribute, ownership is transferred. |
|
58 */ |
|
59 static CNATFWUNSAFAttribute* DecodeAttributeL( |
|
60 const TDesC8& aByteStream); |
|
61 |
|
62 /** |
|
63 * Destructor, deletes the resources of |
|
64 * CNATFWUNSAFUnknownAttributesAttribute. |
|
65 */ |
|
66 IMPORT_C virtual ~CNATFWUNSAFUnknownAttributesAttribute(); |
|
67 |
|
68 public: // From CNATFWUNSAFAttribute |
|
69 |
|
70 CNATFWUNSAFAttribute::TType Type() const; |
|
71 |
|
72 HBufC8* EncodeValueL() const; |
|
73 |
|
74 public: // New functions |
|
75 |
|
76 /** |
|
77 * Adds an attribute type. |
|
78 * @leave KErrNoMemory If no memory to add the new attribute type |
|
79 * @leave KErrAlreadyExists If aAttributeType is already present. |
|
80 */ |
|
81 void AddContainedAttributeL(TUint16 aAttributeType); |
|
82 |
|
83 /** |
|
84 * Remove an attribute type. |
|
85 * @return KErrNone If attribute type was successfully removed |
|
86 * @return KErrNotFound If attribute type was not present. |
|
87 */ |
|
88 TInt RemoveContainedAttribute(TUint16 aAttributeType); |
|
89 |
|
90 /** |
|
91 * Gets an array containing all the attribute types contained in this |
|
92 * attribute. |
|
93 * @return Contained attribute types. Ownership of the |
|
94 * array or the items inside it is not transferred. |
|
95 */ |
|
96 IMPORT_C const RArray<TUint32>& ContainedAttributes() const; |
|
97 |
|
98 private: |
|
99 |
|
100 enum TEncodedValue |
|
101 { |
|
102 //Size in bytes of a single entry (attribute) in the encoded value |
|
103 //part of UNKNOWN-ATTRIBUTES |
|
104 EElementSize = 2, |
|
105 |
|
106 //The length of the encoded value has to be a multiple of 4 |
|
107 EGranularity = 4 |
|
108 }; |
|
109 |
|
110 private: // Constructors |
|
111 |
|
112 CNATFWUNSAFUnknownAttributesAttribute(); |
|
113 |
|
114 private: // New functions |
|
115 |
|
116 /** |
|
117 * Check the length of attribute's value part is valid |
|
118 * @param aLength Length of the attribute's value part |
|
119 * @leave KErrCorrupt If the length is invalid |
|
120 */ |
|
121 static void CheckLengthL(TInt aLength); |
|
122 |
|
123 void DecodeValueL(const TDesC8& aValue); |
|
124 |
|
125 private: // Data |
|
126 |
|
127 //Use 32bit values, since RArray stores objects in the array as 4 byte |
|
128 //aligned quantities. |
|
129 RArray<TUint32> iContainedAttributes; |
|
130 |
|
131 private: // For testing purposes |
|
132 |
|
133 __DECLARE_TEST; |
|
134 }; |
|
135 |
|
136 #endif // CNATFWUNSAFUNKNOWNATTRIBUTESATTRIBUTE_H |
|
137 |
|
138 |