|
1 /* |
|
2 * Copyright (c) 2004-2009 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 the License "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 * Definition of the Swi::Sis::CCapabilities |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include <e32def.h> |
|
21 #include "siscapabilities.h" |
|
22 #include "sisfieldtypes.h" |
|
23 |
|
24 using namespace Swi::Sis; |
|
25 |
|
26 EXPORT_C /*static*/ CCapabilities* CCapabilities::NewLC(MSisDataProvider& aDataProvider, TInt64& aBytesRead, TReadTypeBehaviour aTypeReadBehaviour) |
|
27 { |
|
28 CCapabilities* self = new(ELeave) CCapabilities(); |
|
29 CleanupStack::PushL(self); |
|
30 self->ConstructL(aDataProvider, aBytesRead, aTypeReadBehaviour); |
|
31 return self; |
|
32 } |
|
33 |
|
34 EXPORT_C /*static*/ CCapabilities* CCapabilities::NewL(MSisDataProvider& aDataProvider, TInt64& aBytesRead, TReadTypeBehaviour aTypeReadBehaviour) |
|
35 { |
|
36 CCapabilities* self = NewLC(aDataProvider, aBytesRead, aTypeReadBehaviour); |
|
37 CleanupStack::Pop(self); |
|
38 return self; |
|
39 } |
|
40 |
|
41 EXPORT_C CCapabilities* CCapabilities::NewLC(TPtrProvider& aDataProvider, TInt64& aBytesRead, TReadTypeBehaviour aTypeReadBehaviour) |
|
42 { |
|
43 CCapabilities* self = new (ELeave) CCapabilities; |
|
44 CleanupStack::PushL(self); |
|
45 self->ConstructL(aDataProvider, aBytesRead, aTypeReadBehaviour); |
|
46 return self; |
|
47 } |
|
48 |
|
49 EXPORT_C CCapabilities* CCapabilities::NewL(TPtrProvider& aDataProvider, TInt64& aBytesRead, TReadTypeBehaviour aTypeReadBehaviour) |
|
50 { |
|
51 CCapabilities* self = CCapabilities::NewLC(aDataProvider, aBytesRead, aTypeReadBehaviour); |
|
52 CleanupStack::Pop(self); |
|
53 return self; |
|
54 } |
|
55 |
|
56 CCapabilities::CCapabilities() |
|
57 { |
|
58 } |
|
59 |
|
60 EXPORT_C CCapabilities::~CCapabilities() |
|
61 { |
|
62 delete iData; |
|
63 } |
|
64 |
|
65 void CCapabilities::ConstructL(MSisDataProvider& aDataProvider, TInt64& aBytesRead, TReadTypeBehaviour aTypeReadBehaviour) |
|
66 { |
|
67 TInt64 fieldOffset = aBytesRead; |
|
68 |
|
69 CField::ConstructL(aDataProvider, EFieldTypeCapabilities, aBytesRead, aTypeReadBehaviour); |
|
70 |
|
71 // Length has to be a multiple of four bytes |
|
72 if ((Length() >= KMaxTInt / 2)||(Length() < 0) || (I64LOW(Length()) & 0x3)) |
|
73 { |
|
74 User::Leave(KErrSISFieldLengthInvalid); |
|
75 } |
|
76 |
|
77 iData= HBufC8::NewMaxL(I64INT(Length())); |
|
78 |
|
79 TPtr8 p(iData->Des()); |
|
80 iDataPtr.Set(*iData); |
|
81 CField::CheckedReadL(aDataProvider, p, aBytesRead); |
|
82 |
|
83 CField::SkipUnknownFieldsL(aDataProvider, aBytesRead - fieldOffset, aBytesRead, aTypeReadBehaviour); |
|
84 CField::EnsureAlignedL(aDataProvider, aBytesRead - fieldOffset, aBytesRead, aTypeReadBehaviour); |
|
85 } |
|
86 |
|
87 void CCapabilities::ConstructL(TPtrProvider& aDataProvider, TInt64& aBytesRead, TReadTypeBehaviour aTypeReadBehaviour) |
|
88 { |
|
89 TInt64 fieldOffset = aBytesRead; |
|
90 |
|
91 CField::ConstructL(aDataProvider, EFieldTypeCapabilities, aBytesRead, aTypeReadBehaviour); |
|
92 |
|
93 // Length has to be a multiple of four bytes |
|
94 if ((Length() >= KMaxTInt / 2)||(Length() < 0) || (I64LOW(Length()) & 0x3)) |
|
95 { |
|
96 User::Leave(KErrSISFieldLengthInvalid); |
|
97 } |
|
98 |
|
99 iDataPtr.Set(aDataProvider.ReadL(I64LOW(Length()))); |
|
100 aBytesRead += I64LOW(Length()); |
|
101 |
|
102 CField::SkipUnknownFieldsL(aDataProvider, aBytesRead - fieldOffset, aBytesRead, aTypeReadBehaviour); |
|
103 CField::EnsureAlignedL(aDataProvider, aBytesRead - fieldOffset, aBytesRead, aTypeReadBehaviour); |
|
104 } |
|
105 |