|
1 /* |
|
2 * Copyright (c) 2008 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 // INCLUDE FILES |
|
20 |
|
21 #include "cstsfile.h" |
|
22 |
|
23 namespace java |
|
24 { |
|
25 namespace satsa |
|
26 { |
|
27 |
|
28 // CONSTANTS |
|
29 const TUint8 KSTSSequenceTag = 0x30; |
|
30 //sequence byte + 3 bytes for long form length |
|
31 const TInt KSTSTLVHeaderLength = 4; |
|
32 const TInt KSTSFirstOctet = 8; |
|
33 const TUint8 KSTSInitialLengthOctet = 0x82; |
|
34 |
|
35 // ============================ MEMBER FUNCTIONS =============================== |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CSTSFile::CSTSFile |
|
39 // C++ default constructor can NOT contain any code, that |
|
40 // might leave. |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 CSTSFile::CSTSFile() |
|
44 { |
|
45 } |
|
46 |
|
47 // Destructor |
|
48 CSTSFile::~CSTSFile() |
|
49 { |
|
50 delete iDataBuf; |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CSTSFile::ReadL |
|
55 // Reads and decodes file data |
|
56 // (other items were commented in a header). |
|
57 // ----------------------------------------------------------------------------- |
|
58 void CSTSFile::ReadL(TInt aMaxValidDataAmount) |
|
59 { |
|
60 ResetData(); |
|
61 |
|
62 TPtrC8 fileData; |
|
63 fileData.Set(RetrieveContentL()); |
|
64 iFileSize = fileData.Length(); |
|
65 iMaxValidDataAmount = aMaxValidDataAmount; |
|
66 //allocate buffer for file data |
|
67 HBufC8* tmp = HBufC8::NewL(iFileSize + KSTSTLVHeaderLength); |
|
68 delete iDataBuf; |
|
69 iDataBuf = tmp; |
|
70 |
|
71 //append sequence tag and size bytes |
|
72 iDataBuf->Des().Append(KSTSSequenceTag); |
|
73 iDataBuf->Des().Append(KSTSInitialLengthOctet); |
|
74 iDataBuf->Des().Append(iFileSize >> KSTSFirstOctet);//first octet=high byte of length |
|
75 iDataBuf->Des().Append(iFileSize); //second octet=low byte of length |
|
76 |
|
77 TPtr8 wholeData(iDataBuf->Des()); |
|
78 wholeData.Append(fileData); |
|
79 |
|
80 DecodeL(wholeData); |
|
81 } |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // CSTSFile::FoundRecords |
|
85 // |
|
86 // (other items were commented in a header). |
|
87 // ----------------------------------------------------------------------------- |
|
88 TInt CSTSFile::FoundRecords() const |
|
89 { |
|
90 return iFoundRecords; |
|
91 } |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // CSTSFile::DecodeL |
|
95 // |
|
96 // (other items were commented in a header). |
|
97 // ----------------------------------------------------------------------------- |
|
98 void CSTSFile::DecodeL(const TDesC8& aRawData) |
|
99 { |
|
100 CArrayPtr<TASN1DecGeneric>* itemsData = DecodeSequenceLC(EFalse, //must be sequence |
|
101 aRawData); |
|
102 |
|
103 TInt count = itemsData->Count(); |
|
104 TBool validDataFound = EFalse; |
|
105 |
|
106 for (TInt i = 0; (i < count) && !validDataFound; i++) |
|
107 { |
|
108 validDataFound = DecodeAndAppendRowL(itemsData->At(i)->Encoding(), |
|
109 iMaxValidDataAmount); |
|
110 } |
|
111 CleanupStack::PopAndDestroy(itemsData); |
|
112 |
|
113 } |
|
114 |
|
115 } // namespace satsa |
|
116 } // namespace java |
|
117 // End of File |