|
1 /* |
|
2 * Copyright (c) 2006 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: CNcdInstallInfo implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <s32strm.h> |
|
20 |
|
21 #include "ncdinstallinfo.h" |
|
22 #include "ncdfileinfo.h" |
|
23 #include "catalogsdebug.h" |
|
24 #include "catalogsutils.h" |
|
25 #include "ncdpanics.h" |
|
26 |
|
27 |
|
28 // --------------------------------------------------------------------------- |
|
29 // |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 CNcdInstallInfo* CNcdInstallInfo::NewL( CNcdFileInfo* aInfo, |
|
33 TNcdInstallType aType ) |
|
34 { |
|
35 CNcdInstallInfo* self = NewLC( aInfo, aType ); |
|
36 CleanupStack::Pop( self ); |
|
37 return self; |
|
38 } |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 // --------------------------------------------------------------------------- |
|
43 // |
|
44 CNcdInstallInfo* CNcdInstallInfo::NewLC( CNcdFileInfo* aInfo, |
|
45 TNcdInstallType aType ) |
|
46 { |
|
47 CNcdInstallInfo* self = new(ELeave) CNcdInstallInfo( aType ); |
|
48 CleanupStack::PushL( self ); |
|
49 self->ConstructL( aInfo ); |
|
50 return self; |
|
51 } |
|
52 |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 CNcdInstallInfo* CNcdInstallInfo::NewLC( RReadStream& aStream ) |
|
59 { |
|
60 CNcdInstallInfo* self = new(ELeave) CNcdInstallInfo( ENcdInstallNormal ); |
|
61 CleanupStack::PushL( self ); |
|
62 self->InternalizeL( aStream ); |
|
63 return self; |
|
64 } |
|
65 |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 CNcdInstallInfo::~CNcdInstallInfo() |
|
72 { |
|
73 iFiles.ResetAndDestroy(); |
|
74 } |
|
75 |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 void CNcdInstallInfo::AddFileInfoL( CNcdFileInfo* aInfo ) |
|
82 { |
|
83 DLTRACEIN(("")); |
|
84 NCD_ASSERT_ALWAYS( aInfo, ENcdPanicInvalidArgument ); |
|
85 iFiles.AppendL( aInfo ); |
|
86 DLTRACEOUT(("")); |
|
87 } |
|
88 |
|
89 |
|
90 // --------------------------------------------------------------------------- |
|
91 // |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 TInt CNcdInstallInfo::FileInfoCount() const |
|
95 { |
|
96 return iFiles.Count(); |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 CNcdFileInfo& CNcdInstallInfo::FileInfo( TInt aIndex ) |
|
104 { |
|
105 NCD_ASSERT( aIndex >= 0 && aIndex < FileInfoCount(), |
|
106 ENcdPanicIndexOutOfRange ); |
|
107 return *iFiles[aIndex]; |
|
108 } |
|
109 |
|
110 |
|
111 // --------------------------------------------------------------------------- |
|
112 // |
|
113 // --------------------------------------------------------------------------- |
|
114 // |
|
115 const CNcdFileInfo& CNcdInstallInfo::FileInfo( TInt aIndex ) const |
|
116 { |
|
117 NCD_ASSERT( aIndex >= 0 && aIndex < FileInfoCount(), |
|
118 ENcdPanicIndexOutOfRange ); |
|
119 return *iFiles[aIndex]; |
|
120 } |
|
121 |
|
122 |
|
123 // --------------------------------------------------------------------------- |
|
124 // |
|
125 // --------------------------------------------------------------------------- |
|
126 // |
|
127 CNcdInstallInfo::TNcdInstallType CNcdInstallInfo::InstallType() const |
|
128 { |
|
129 return iType; |
|
130 } |
|
131 |
|
132 |
|
133 // --------------------------------------------------------------------------- |
|
134 // |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 TInt32 CNcdInstallInfo::Index() const |
|
138 { |
|
139 DLTRACEIN(("Index: %d", iIndex )); |
|
140 return iIndex; |
|
141 } |
|
142 |
|
143 |
|
144 // --------------------------------------------------------------------------- |
|
145 // |
|
146 // --------------------------------------------------------------------------- |
|
147 // |
|
148 void CNcdInstallInfo::SetIndex( TInt32 aIndex ) |
|
149 { |
|
150 DLTRACEIN(("index: %d", aIndex)); |
|
151 iIndex = aIndex; |
|
152 } |
|
153 |
|
154 // --------------------------------------------------------------------------- |
|
155 // |
|
156 // --------------------------------------------------------------------------- |
|
157 // |
|
158 void CNcdInstallInfo::InternalizeL( RReadStream& aStream ) |
|
159 { |
|
160 DLTRACEIN(("")); |
|
161 |
|
162 // read type |
|
163 iType = static_cast<TNcdInstallType>( aStream.ReadInt32L() ); |
|
164 iIndex = aStream.ReadInt32L(); |
|
165 TInt count = aStream.ReadInt32L(); |
|
166 iFiles.ResetAndDestroy(); |
|
167 iFiles.ReserveL( count ); |
|
168 DLINFO(( "File count: %d", count )); |
|
169 while ( count ) |
|
170 { |
|
171 DLTRACE(("Internalizing fileinfo")); |
|
172 CNcdFileInfo* info = CNcdFileInfo::NewLC( aStream ); |
|
173 iFiles.AppendL( info ); |
|
174 CleanupStack::Pop( info ); |
|
175 --count; |
|
176 } |
|
177 DLTRACEOUT(("")); |
|
178 } |
|
179 |
|
180 // --------------------------------------------------------------------------- |
|
181 // |
|
182 // --------------------------------------------------------------------------- |
|
183 // |
|
184 void CNcdInstallInfo::ExternalizeL( RWriteStream& aStream ) const |
|
185 { |
|
186 DLTRACEIN(("")); |
|
187 // write type |
|
188 aStream.WriteInt32L( iType ); |
|
189 aStream.WriteInt32L( iIndex ); |
|
190 |
|
191 TInt count = FileInfoCount(); |
|
192 DLINFO(( "File count: %d", count )); |
|
193 // write file infos |
|
194 aStream.WriteInt32L( count ); |
|
195 |
|
196 for ( TInt i = 0; i < count; ++i ) |
|
197 { |
|
198 iFiles[i]->ExternalizeL( aStream ); |
|
199 } |
|
200 |
|
201 DLTRACEOUT(("")); |
|
202 } |
|
203 |
|
204 |
|
205 |
|
206 // --------------------------------------------------------------------------- |
|
207 // |
|
208 // --------------------------------------------------------------------------- |
|
209 // |
|
210 void CNcdInstallInfo::ExternalizeWithoutFilenamesL( |
|
211 RWriteStream& aStream ) const |
|
212 { |
|
213 DLTRACEIN(("")); |
|
214 // write type |
|
215 aStream.WriteInt32L( iType ); |
|
216 aStream.WriteInt32L( iIndex ); |
|
217 |
|
218 TInt count = FileInfoCount(); |
|
219 DLINFO(( "File count: %d", count )); |
|
220 // write file infos |
|
221 aStream.WriteInt32L( count ); |
|
222 |
|
223 for ( TInt i = 0; i < count; ++i ) |
|
224 { |
|
225 iFiles[i]->ExternalizeWithoutFilenamesL( aStream ); |
|
226 } |
|
227 |
|
228 DLTRACEOUT(("")); |
|
229 |
|
230 } |
|
231 |
|
232 |
|
233 // --------------------------------------------------------------------------- |
|
234 // |
|
235 // --------------------------------------------------------------------------- |
|
236 // |
|
237 CNcdInstallInfo::CNcdInstallInfo( TNcdInstallType aType ) : iType( aType ) |
|
238 { |
|
239 } |
|
240 |
|
241 |
|
242 // --------------------------------------------------------------------------- |
|
243 // |
|
244 // --------------------------------------------------------------------------- |
|
245 // |
|
246 void CNcdInstallInfo::ConstructL( CNcdFileInfo* aInfo ) |
|
247 { |
|
248 if ( aInfo ) |
|
249 { |
|
250 AddFileInfoL( aInfo ); |
|
251 } |
|
252 } |
|
253 |
|
254 |