|
1 /* |
|
2 * Copyright (c) 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 "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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <ncdnodemetadata.h> |
|
19 #include <ncdutils.h> |
|
20 |
|
21 #include "iaupdatenodedetails.h" |
|
22 #include "iaupdatenodedependencyimpl.h" |
|
23 #include "iaupdateplatformdependency.h" |
|
24 #include "iaupdateutils.h" |
|
25 #include "iaupdatedependencyxmlparser.h" |
|
26 #include "iaupdateprotocolconsts.h" |
|
27 |
|
28 #include "iaupdatedebug.h" |
|
29 |
|
30 |
|
31 CIAUpdateNodeDetails* CIAUpdateNodeDetails::NewL( const MNcdNodeMetadata* aData ) |
|
32 { |
|
33 CIAUpdateNodeDetails* self = |
|
34 CIAUpdateNodeDetails::NewLC( aData ); |
|
35 CleanupStack::Pop( self ); |
|
36 return self; |
|
37 } |
|
38 |
|
39 CIAUpdateNodeDetails* CIAUpdateNodeDetails::NewLC( const MNcdNodeMetadata* aData ) |
|
40 { |
|
41 CIAUpdateNodeDetails* self = |
|
42 new( ELeave ) CIAUpdateNodeDetails(); |
|
43 CleanupStack::PushL( self ); |
|
44 self->ConstructL( aData ); |
|
45 return self; |
|
46 } |
|
47 |
|
48 |
|
49 CIAUpdateNodeDetails::~CIAUpdateNodeDetails() |
|
50 { |
|
51 ClearAll(); |
|
52 delete iPlatformDependency; |
|
53 } |
|
54 |
|
55 |
|
56 CIAUpdateNodeDetails::CIAUpdateNodeDetails() |
|
57 : CBase(), |
|
58 iType( MIAUpdateNode::EPackageTypeSA ), |
|
59 iImportance( MIAUpdateBaseNode::ENormal ) |
|
60 { |
|
61 |
|
62 } |
|
63 |
|
64 void CIAUpdateNodeDetails::ConstructL( const MNcdNodeMetadata* aData ) |
|
65 { |
|
66 iPlatformDependency = |
|
67 CIAUpdatePlatformDependency::NewL(); |
|
68 SetDetailsL( aData ); |
|
69 } |
|
70 |
|
71 |
|
72 void CIAUpdateNodeDetails::SetDetailsL( const MNcdNodeMetadata* aData ) |
|
73 { |
|
74 ClearAll(); |
|
75 |
|
76 // Get information from metadata. |
|
77 // Notice, ownership of the aData is not transferred here. |
|
78 if( aData ) |
|
79 { |
|
80 // Get the reference to the key value pair array |
|
81 // that contains all the details of the metadata. |
|
82 const RPointerArray< CNcdKeyValuePair >& details( aData->Details() ); |
|
83 |
|
84 for( TInt i = 0; i < details.Count(); ++i ) |
|
85 { |
|
86 // Get the first key value pair from the list. |
|
87 CNcdKeyValuePair* pair( details[ i ] ); |
|
88 |
|
89 if( pair->Key() == IAUpdateProtocolConsts::KImportanceKey() ) |
|
90 { |
|
91 // The pair describes the importance of the node. |
|
92 // Check and set the correct importance. |
|
93 if( pair->Value().CompareF( |
|
94 IAUpdateProtocolConsts::KImportanceMandatory() ) == 0 ) |
|
95 { |
|
96 iImportance = MIAUpdateBaseNode::EMandatory; |
|
97 } |
|
98 else if( pair->Value().CompareF( |
|
99 IAUpdateProtocolConsts::KImportanceCritical() ) == 0 ) |
|
100 { |
|
101 iImportance = MIAUpdateBaseNode::ECritical; |
|
102 } |
|
103 else if( pair->Value().CompareF( |
|
104 IAUpdateProtocolConsts::KImportanceRecommended() ) == 0 ) |
|
105 { |
|
106 iImportance = MIAUpdateBaseNode::ERecommended; |
|
107 } |
|
108 else if( pair->Value().CompareF( |
|
109 IAUpdateProtocolConsts::KImportanceHidden() ) == 0 ) |
|
110 { |
|
111 iImportance = MIAUpdateBaseNode::EHidden; |
|
112 } |
|
113 else |
|
114 { |
|
115 iImportance = MIAUpdateBaseNode::ENormal; |
|
116 } |
|
117 } |
|
118 else if( pair->Key() == IAUpdateProtocolConsts::KPackageTypeKey() ) |
|
119 { |
|
120 // The pair describes the content package type. |
|
121 // Check and set the correct type. |
|
122 if( pair->Value().CompareF( IAUpdateProtocolConsts::KPackageTypeSP() ) == 0 ) |
|
123 { |
|
124 iType = MIAUpdateNode::EPackageTypeSP; |
|
125 } |
|
126 else if( pair->Value().CompareF( |
|
127 IAUpdateProtocolConsts::KPackageTypePU() ) == 0 ) |
|
128 { |
|
129 iType = MIAUpdateNode::EPackageTypePU; |
|
130 } |
|
131 else |
|
132 { |
|
133 iType = MIAUpdateNode::EPackageTypeSA; |
|
134 } |
|
135 } |
|
136 else if ( pair->Key() == IAUpdateProtocolConsts::KSearchCriteriaKey() ) |
|
137 { |
|
138 // The pair describes the search criteria. |
|
139 // Get the criteria. |
|
140 delete iSearchCriteria; |
|
141 iSearchCriteria = NULL; |
|
142 iSearchCriteria = pair->Value().AllocL(); |
|
143 } |
|
144 else if ( pair->Key() == IAUpdateProtocolConsts::KDependencyKey() ) |
|
145 { |
|
146 // Create the descriptor for the dependencies data. |
|
147 // In order to make the data to be inside one root XML element, |
|
148 // insert required XML element tags to the beginning and to the end. |
|
149 const TDesC& dependenciesXmlData( pair->Value() ); |
|
150 HBufC* data( HBufC::NewLC( |
|
151 IAUpdateProtocolConsts::KDependenciesPrefix().Length() |
|
152 + dependenciesXmlData.Length() |
|
153 + IAUpdateProtocolConsts::KDependenciesPostfix().Length() ) ); |
|
154 TPtr ptrData( data->Des() ); |
|
155 ptrData.Copy( IAUpdateProtocolConsts::KDependenciesPrefix() ); |
|
156 ptrData.Append( dependenciesXmlData ); |
|
157 ptrData.Append( IAUpdateProtocolConsts::KDependenciesPostfix() ); |
|
158 |
|
159 // Create parser that will insert dependency information to the |
|
160 // given parameter objects. |
|
161 // Notice, that ClearAll() was called in the beginning of this function. |
|
162 // So, now dependency array and platform dependency contain their defaults. |
|
163 CIAUpdateDependencyXmlParser* parser( |
|
164 CIAUpdateDependencyXmlParser::NewLC( iDependencies, |
|
165 *iPlatformDependency ) ); |
|
166 parser->ParseL( ptrData ); |
|
167 CleanupStack::PopAndDestroy( parser ); |
|
168 |
|
169 CleanupStack::PopAndDestroy( data ); |
|
170 } |
|
171 else if ( pair->Key() == IAUpdateProtocolConsts::KFirmwareVersion1Key ) |
|
172 { |
|
173 // The pair describes the firmware version 1. |
|
174 // Get the value. |
|
175 delete iFwVersion1; |
|
176 iFwVersion1 = NULL; |
|
177 iFwVersion1 = pair->Value().AllocL(); |
|
178 } |
|
179 else if ( pair->Key() == IAUpdateProtocolConsts::KFirmwareVersion2Key ) |
|
180 { |
|
181 // The pair describes the firmware version 2. |
|
182 // Get the value. |
|
183 delete iFwVersion2; |
|
184 iFwVersion2 = NULL; |
|
185 iFwVersion2 = pair->Value().AllocL(); |
|
186 } |
|
187 else if ( pair->Key() == IAUpdateProtocolConsts::KFirmwareVersion3Key ) |
|
188 { |
|
189 // The pair describes the firmware version 3. |
|
190 // Get the value. |
|
191 delete iFwVersion3; |
|
192 iFwVersion3 = NULL; |
|
193 iFwVersion3 = pair->Value().AllocL(); |
|
194 } |
|
195 else if ( pair->Key ()== IAUpdateProtocolConsts::KRebootAfterInstallKey ) |
|
196 { |
|
197 if( pair->Value() == IAUpdateProtocolConsts::KRebootAfterInstallNeeded ) |
|
198 { |
|
199 iRebootAfterInstall = ETrue; |
|
200 } |
|
201 } |
|
202 } |
|
203 } |
|
204 } |
|
205 |
|
206 |
|
207 MIAUpdateNode::TPackageType CIAUpdateNodeDetails::ContentType() const |
|
208 { |
|
209 return iType; |
|
210 } |
|
211 |
|
212 |
|
213 MIAUpdateBaseNode::TImportance CIAUpdateNodeDetails::Importance() const |
|
214 { |
|
215 return iImportance; |
|
216 } |
|
217 |
|
218 void CIAUpdateNodeDetails::SetImportance( MIAUpdateBaseNode::TImportance aImportance ) |
|
219 { |
|
220 iImportance = aImportance; |
|
221 } |
|
222 |
|
223 const TDesC& CIAUpdateNodeDetails::SearchCriteria() const |
|
224 { |
|
225 if ( iSearchCriteria ) |
|
226 { |
|
227 return *iSearchCriteria; |
|
228 } |
|
229 else |
|
230 { |
|
231 return KNullDesC(); |
|
232 } |
|
233 } |
|
234 |
|
235 |
|
236 TBool CIAUpdateNodeDetails::EmbededDegrades() const |
|
237 { |
|
238 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeDetails::EmbededDegrades() begin"); |
|
239 |
|
240 for ( TInt i = 0; i < iDependencies.Count(); ++i ) |
|
241 { |
|
242 CIAUpdateNodeDependency* dependency( iDependencies[ i ] ); |
|
243 if ( dependency->IsEmbedded() ) |
|
244 { |
|
245 // Because the dependency is embedded |
|
246 // we have to make sure that embedding does not |
|
247 // create downgrading. |
|
248 TBool installed( EFalse ); |
|
249 TIAUpdateVersion installedVersion; |
|
250 TRAP_IGNORE( |
|
251 installed = |
|
252 IAUpdateUtils::IsAppInstalledL( dependency->Uid(), |
|
253 installedVersion ) ); |
|
254 if ( installed && installedVersion > dependency->VersionRoof() ) |
|
255 { |
|
256 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeDetails::EmbededDegrades() end: ETrue"); |
|
257 return ETrue; |
|
258 } |
|
259 } |
|
260 } |
|
261 |
|
262 IAUPDATE_TRACE("[IAUPDATE] CIAUpdateNodeDetails::EmbededDegrades() end: EFalse"); |
|
263 |
|
264 return EFalse; |
|
265 } |
|
266 |
|
267 |
|
268 void CIAUpdateNodeDetails::GetDependenciesL( |
|
269 RPointerArray< CIAUpdateNodeDependency >& aDependencies ) const |
|
270 { |
|
271 aDependencies.ReserveL( iDependencies.Count() ); |
|
272 for( TInt i = 0; i < iDependencies.Count(); ++i ) |
|
273 { |
|
274 aDependencies.AppendL( iDependencies[ i ] ); |
|
275 } |
|
276 } |
|
277 |
|
278 |
|
279 CIAUpdatePlatformDependency& CIAUpdateNodeDetails::PlatformDependency() const |
|
280 { |
|
281 return *iPlatformDependency; |
|
282 } |
|
283 |
|
284 |
|
285 const TDesC& CIAUpdateNodeDetails::FwVersion1() const |
|
286 { |
|
287 if ( iFwVersion1 ) |
|
288 { |
|
289 return *iFwVersion1; |
|
290 } |
|
291 else |
|
292 { |
|
293 return KNullDesC(); |
|
294 } |
|
295 } |
|
296 |
|
297 |
|
298 const TDesC& CIAUpdateNodeDetails::FwVersion2() const |
|
299 { |
|
300 if ( iFwVersion2 ) |
|
301 { |
|
302 return *iFwVersion2; |
|
303 } |
|
304 else |
|
305 { |
|
306 return KNullDesC(); |
|
307 } |
|
308 } |
|
309 |
|
310 |
|
311 const TDesC& CIAUpdateNodeDetails::FwVersion3() const |
|
312 { |
|
313 if ( iFwVersion3 ) |
|
314 { |
|
315 return *iFwVersion3; |
|
316 } |
|
317 else |
|
318 { |
|
319 return KNullDesC(); |
|
320 } |
|
321 } |
|
322 |
|
323 |
|
324 TBool CIAUpdateNodeDetails::RebootAfterInstall() const |
|
325 { |
|
326 return iRebootAfterInstall; |
|
327 } |
|
328 |
|
329 |
|
330 void CIAUpdateNodeDetails::ClearAll() |
|
331 { |
|
332 delete iSearchCriteria; |
|
333 iSearchCriteria = NULL; |
|
334 |
|
335 delete iFwVersion1; |
|
336 iFwVersion1 = NULL; |
|
337 |
|
338 delete iFwVersion2; |
|
339 iFwVersion2 = NULL; |
|
340 |
|
341 delete iFwVersion3; |
|
342 iFwVersion3 = NULL; |
|
343 |
|
344 iDependencies.ResetAndDestroy(); |
|
345 |
|
346 iPlatformDependency->Reset(); |
|
347 |
|
348 iRebootAfterInstall = EFalse; |
|
349 } |