|
1 /* |
|
2 * Copyright (c) 2000 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: ApplicationManagementOptions implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <e32debug.h> |
|
21 #include <s32mem.h> |
|
22 #include "debug.h" |
|
23 #include "aminstalloptions.h" |
|
24 #include "aminstalloptionsint.h" |
|
25 |
|
26 |
|
27 namespace AMXml |
|
28 { |
|
29 |
|
30 struct TLangCodeMapping |
|
31 { |
|
32 //const TText8 *const iCode ; |
|
33 const TText8 * iCode ; |
|
34 TLanguage iLang ; |
|
35 }; |
|
36 |
|
37 // Language options |
|
38 const TLangCodeMapping KLangOptions[] = |
|
39 { |
|
40 {_S8("EN"), ELangEnglish}, |
|
41 {_S8("FR"), ELangFrench}, |
|
42 {_S8("GE"), ELangGerman}, |
|
43 {_S8("SP"), ELangSpanish}, |
|
44 {_S8("IT"), ELangItalian}, |
|
45 {_S8("SW"), ELangSwedish}, |
|
46 {_S8("DA"), ELangDanish}, |
|
47 {_S8("NO"), ELangNorwegian}, |
|
48 {_S8("FI"), ELangFinnish}, |
|
49 {_S8("AM"), ELangAmerican}, |
|
50 {_S8("SF"), ELangSwissFrench}, |
|
51 {_S8("SG"), ELangSwissGerman}, |
|
52 {_S8("PO"), ELangPortuguese}, |
|
53 {_S8("TU"), ELangTurkish}, |
|
54 {_S8("IC"), ELangIcelandic}, |
|
55 {_S8("RU"), ELangRussian}, |
|
56 {_S8("HU"), ELangHungarian}, |
|
57 {_S8("DU"), ELangDutch}, |
|
58 {_S8("BL"), ELangBelgianFlemish}, |
|
59 {_S8("AU"), ELangAustralian}, |
|
60 {_S8("BF"), ELangBelgianFrench}, |
|
61 {_S8("AS"), ELangAustrian}, |
|
62 {_S8("NZ"), ELangNewZealand}, |
|
63 {_S8("IF"), ELangInternationalFrench}, |
|
64 {_S8("CS"), ELangCzech}, |
|
65 {_S8("SK"), ELangSlovak}, |
|
66 {_S8("PL"), ELangPolish}, |
|
67 {_S8("SL"), ELangSlovenian}, |
|
68 {_S8("TC"), ELangTaiwanChinese}, |
|
69 {_S8("HK"), ELangHongKongChinese}, |
|
70 {_S8("ZH"), ELangPrcChinese}, |
|
71 {_S8("JA"), ELangJapanese}, |
|
72 {_S8("TH"), ELangThai}, |
|
73 {_S8("AF"), ELangAfrikaans }, |
|
74 {_S8("SQ"), ELangAlbanian }, |
|
75 {_S8("AH"), ELangAmharic }, |
|
76 {_S8("AR"), ELangArabic }, |
|
77 {_S8("HY"), ELangArmenian }, |
|
78 {_S8("TL"), ELangTagalog }, |
|
79 {_S8("BE"), ELangBelarussian }, |
|
80 {_S8("BN"), ELangBengali }, |
|
81 {_S8("BG"), ELangBulgarian }, |
|
82 {_S8("MY"), ELangBurmese }, |
|
83 {_S8("CA"), ELangCatalan }, |
|
84 {_S8("HR"), ELangCroatian }, |
|
85 {_S8("CE"), ELangCanadianEnglish }, |
|
86 {_S8("IE"), ELangInternationalEnglish }, |
|
87 {_S8("SF"), ELangSouthAfricanEnglish }, |
|
88 {_S8("ET"), ELangEstonian }, |
|
89 {_S8("FA"), ELangFarsi }, |
|
90 {_S8("CF"), ELangCanadianFrench }, |
|
91 {_S8("GD"), ELangScotsGaelic }, |
|
92 {_S8("KA"), ELangGeorgian }, |
|
93 {_S8("EL"), ELangGreek }, |
|
94 {_S8("CG"), ELangCyprusGreek }, |
|
95 {_S8("GU"), ELangGujarati }, |
|
96 {_S8("HE"), ELangHebrew }, |
|
97 {_S8("HI"), ELangHindi }, |
|
98 {_S8("IN"), ELangIndonesian }, |
|
99 {_S8("GA"), ELangIrish }, |
|
100 {_S8("SZ"), ELangSwissItalian }, |
|
101 {_S8("KN"), ELangKannada }, |
|
102 {_S8("KK"), ELangKazakh }, |
|
103 {_S8("KM"), ELangKhmer }, |
|
104 {_S8("KO"), ELangKorean }, |
|
105 {_S8("LO"), ELangLao }, |
|
106 {_S8("LV"), ELangLatvian }, |
|
107 {_S8("LT"), ELangLithuanian }, |
|
108 {_S8("MK"), ELangMacedonian }, |
|
109 {_S8("MS"), ELangMalay }, |
|
110 {_S8("ML"), ELangMalayalam }, |
|
111 {_S8("MR"), ELangMarathi }, |
|
112 {_S8("MO"), ELangMoldavian }, |
|
113 {_S8("MN"), ELangMongolian }, |
|
114 {_S8("NN"), ELangNorwegianNynorsk }, |
|
115 {_S8("BP"), ELangBrazilianPortuguese }, |
|
116 {_S8("PA"), ELangPunjabi }, |
|
117 {_S8("RO"), ELangRomanian }, |
|
118 {_S8("SR"), ELangSerbian }, |
|
119 {_S8("SI"), ELangSinhalese }, |
|
120 {_S8("SO"), ELangSomali }, |
|
121 {_S8("OS"), ELangInternationalSpanish }, |
|
122 {_S8("LS"), ELangLatinAmericanSpanish }, |
|
123 {_S8("SH"), ELangSwahili }, |
|
124 {_S8("FS"), ELangFinlandSwedish }, |
|
125 //{_S8("??"), ELangReserved1 }, |
|
126 {_S8("TA"), ELangTamil }, |
|
127 {_S8("TE"), ELangTelugu }, |
|
128 {_S8("BO"), ELangTibetan }, |
|
129 {_S8("TI"), ELangTigrinya }, |
|
130 {_S8("CT"), ELangCyprusTurkish }, |
|
131 {_S8("TK"), ELangTurkmen }, |
|
132 {_S8("UK"), ELangUkrainian }, |
|
133 {_S8("UR"), ELangUrdu }, |
|
134 //{_S8("??"), ELangReserved2 }, |
|
135 {_S8("VI"), ELangVietnamese }, |
|
136 {_S8("CY"), ELangWelsh }, |
|
137 {_S8("ZU"), ELangZulu }, |
|
138 //{_S8("??"), ELangOther }, |
|
139 //{_S8("??"), ELangNone } |
|
140 }; |
|
141 |
|
142 const TInt KNumLangOptions = (sizeof(KLangOptions)/sizeof(TLangCodeMapping)); |
|
143 |
|
144 // boolean "value" attribute values |
|
145 _LIT8( KIOValueTrue, "yes" ); |
|
146 _LIT8( KIOValueFalse, "no" ); |
|
147 // notimp _LIT8( KIOAsk, "askuser" ); |
|
148 |
|
149 _LIT8( KIODefaultLanguage, "*"); |
|
150 |
|
151 // notimp _LIT8( KIOMissingOptionPolicyValDefault, "usedefault" ); |
|
152 _LIT8( KIOMissingOptionPolicyValFail, "fail" ); |
|
153 // notimp _LIT8( KIOMissingOptionPolicyValAsk, "askuser" ); |
|
154 |
|
155 // "Name" attribute values |
|
156 _LIT8( KIODrive, "drive" ); |
|
157 _LIT8( KIOLanguage, "lang" ); |
|
158 _LIT8( KIOUpgrade, "upgrade" ); |
|
159 _LIT8( KIOKill, "kill" ); |
|
160 |
|
161 // sym specific |
|
162 _LIT8( KIOCapabilities, "capabilities" ); |
|
163 _LIT8( KIOUntrusted, "untrusted" ); |
|
164 _LIT8( KIOPkginfo, "pkginfo" ); |
|
165 _LIT8( KIOOptionalItems, "optionals" ); |
|
166 |
|
167 _LIT8 ( KIOOCSP, "ocsp" ); |
|
168 _LIT8 ( KIOOCSPWarning, "ignoreocspwarn" ); |
|
169 _LIT8 ( KIOOverwrite, "fileoverwrite" ); |
|
170 |
|
171 _LIT8 ( KIOUpgradeData, "upgradedata" ); // iUpgradeData |
|
172 |
|
173 _LIT8( KUIOBreakDependency, "allowdependencybreak" ); |
|
174 |
|
175 _LIT8( KIOAttrNameDefaultPolicy, "missingoptionpolicy" ); |
|
176 |
|
177 _LIT8( KIODownload, "download" ); |
|
178 _LIT8( KIOHttpUsername, "httpusername" ); |
|
179 _LIT8( KIOHttpPassword, "httppassword" ); |
|
180 _LIT8( KIOIAP, "conref" ); |
|
181 |
|
182 namespace Reader |
|
183 { |
|
184 // XML node names |
|
185 _LIT8( KIOStartElement, "InstOpts") ; |
|
186 _LIT8( KIOStdOpt, "StdOpt"); |
|
187 _LIT8( KIOStdSymOpt, "StdSymOpt" ); |
|
188 _LIT8( KIOCustSymOpts, "CustSymOpts" ); |
|
189 // notimp _LIT8( KIOOpt, "Opt" ); |
|
190 |
|
191 // Xml attribute names |
|
192 // notimp _LIT8( KIOOptAttrIndex, "index" ); |
|
193 _LIT8( KIOAttrName, "name" ); |
|
194 _LIT8( KIOAttrValue, "value" ); |
|
195 |
|
196 } |
|
197 |
|
198 namespace Writer |
|
199 { |
|
200 _LIT8( KIOStartElement, "<InstOpts>") ; |
|
201 _LIT8( KIOStdOptFormat, "<StdOpt name=\"%S\" value=\"%S\"/>" ); |
|
202 _LIT8( KIOStdSymOptFormat, "<StdSymOpt name=\"%S\" value=\"%S\"/>" ); |
|
203 // notimp _LIT8( KIOCustSymOptsStartFormat, "<CustSymOpts cnt=\"%d\">" ); |
|
204 // notimp _LIT8( KIOCustSymOptsEnd, "</CustSymOpts>" ); |
|
205 // notimp _LIT8( KIOOptFormat, "<Opt index=\"%d\" value=\"%S\"/>" ); |
|
206 _LIT8( KIOStartElementEnd, "</InstOpts>") ; |
|
207 |
|
208 _LIT8( KUIOStartElement, "<UninstOpts>" ); |
|
209 _LIT8( KUIOStartElementEnd, "</UninstOpts>" ); |
|
210 } |
|
211 } |
|
212 |
|
213 /////////////////////////////////////////////////// |
|
214 // |
|
215 // CAMInstOptsParserBase |
|
216 // |
|
217 /////////////////////////////////////////////////// |
|
218 |
|
219 |
|
220 CAMInstOptsParserBase::~CAMInstOptsParserBase() |
|
221 { |
|
222 delete iParser; |
|
223 iParser = NULL; |
|
224 } |
|
225 |
|
226 void CAMInstOptsParserBase::SetPolicyValue( SwiUI::TPolicy &aPolicy, const TDesC8& aValue ) const |
|
227 { |
|
228 using namespace AMXml; |
|
229 |
|
230 if ( aValue == KIOValueTrue ) |
|
231 { |
|
232 aPolicy = SwiUI::EPolicyAllowed ; |
|
233 } |
|
234 else if ( aValue == KIOValueFalse ) |
|
235 { |
|
236 aPolicy = SwiUI::EPolicyNotAllowed ; |
|
237 } |
|
238 else |
|
239 { |
|
240 aPolicy = iDefaultPolicy; |
|
241 } |
|
242 } |
|
243 void CAMInstOptsParserBase::ConstructL() |
|
244 { |
|
245 iParser = Xml::CParser::NewL( _L8( "text/xml"), *this ); |
|
246 |
|
247 } |
|
248 |
|
249 void CAMInstOptsParserBase::ParseL() |
|
250 { |
|
251 Xml::ParseL( *iParser, iBuffer ); |
|
252 } |
|
253 |
|
254 void CAMInstOptsParserBase::OnStartElementL(const Xml::RTagInfo& /*aElement*/, |
|
255 const Xml::RAttributeArray& /*aAttributes*/, TInt aErrorCode) |
|
256 { |
|
257 RDEBUG("CAMInstOptsParserBase::OnStartElementL"); |
|
258 if( aErrorCode != KErrNone ) |
|
259 { |
|
260 RDEBUG_2( " ->OnStartElementL (aErrorCode '%d')", aErrorCode ); |
|
261 } |
|
262 } |
|
263 |
|
264 void CAMInstOptsParserBase::OnEndDocumentL(TInt aErrorCode) |
|
265 { |
|
266 RDEBUG("CAMInstOptsParserBase::OnEndDocumentL"); |
|
267 if( aErrorCode != KErrNone ) |
|
268 { |
|
269 RDEBUG_2( " ->OnEndDocumentL (aErrorCode '%d')", aErrorCode ); |
|
270 } |
|
271 } |
|
272 |
|
273 void CAMInstOptsParserBase::OnStartDocumentL(const Xml::RDocumentParameters& aDocParam, TInt aErrorCode) |
|
274 { |
|
275 RDEBUG("CAMInstOptsParserBase::OnStartDocumentL"); |
|
276 if( aErrorCode != KErrNone ) |
|
277 { |
|
278 const TDesC8 &d = aDocParam.CharacterSetName().DesC(); |
|
279 RDEBUG8_3( " ->OnStartDocumentL (aDocParam '%S', aErrorCode %d)" , |
|
280 &d,aErrorCode ); |
|
281 } |
|
282 } |
|
283 |
|
284 void CAMInstOptsParserBase::OnEndElementL(const Xml::RTagInfo& aElement, TInt aErrorCode) |
|
285 { |
|
286 RDEBUG("CAMInstOptsParserBase::OnEndElementL"); |
|
287 if( aErrorCode != KErrNone ) |
|
288 { |
|
289 const TDesC8 &d = aElement.LocalName().DesC(); |
|
290 RDEBUG8_3( " ->OnEndElementL (LocalName '%S', aErrorCode %d)", |
|
291 &d,aErrorCode ); |
|
292 } |
|
293 } |
|
294 |
|
295 void CAMInstOptsParserBase::OnContentL( |
|
296 #ifdef _DEBUG |
|
297 const TDesC8& aBytes |
|
298 #else |
|
299 const TDesC8& /*aBytes*/ |
|
300 #endif |
|
301 ,TInt aErrorCode ) |
|
302 { |
|
303 RDEBUG("CAMInstOptsParserBase::OnContentL"); |
|
304 if( aErrorCode != KErrNone ) |
|
305 { |
|
306 #ifdef _DEBUG |
|
307 RDEBUG8_3( " ->OnContentL (abytes '%S', aErrorCode %d)", |
|
308 &aBytes, aErrorCode ); |
|
309 #else |
|
310 RDEBUG8_2( " ->OnContentL (aErrorCode %d)", aErrorCode ); |
|
311 #endif |
|
312 } |
|
313 |
|
314 } |
|
315 void CAMInstOptsParserBase::OnStartPrefixMappingL(const RString& /*aPrefix*/, |
|
316 const RString& /*aUri*/, TInt /*aErrorCode*/) |
|
317 { |
|
318 |
|
319 } |
|
320 void CAMInstOptsParserBase::OnEndPrefixMappingL(const RString& /*aPrefix*/, TInt /*aErrorCode*/) |
|
321 { |
|
322 |
|
323 } |
|
324 void CAMInstOptsParserBase::OnIgnorableWhiteSpaceL(const TDesC8& /*aBytes*/, TInt /*aErrorCode*/) |
|
325 { |
|
326 |
|
327 } |
|
328 void CAMInstOptsParserBase::OnSkippedEntityL(const RString& /*aName*/, TInt /*aErrorCode*/) |
|
329 { |
|
330 |
|
331 } |
|
332 void CAMInstOptsParserBase::OnProcessingInstructionL(const TDesC8& /*aTarget*/, |
|
333 const TDesC8& /*aData*/, TInt /*aErrorCode*/) |
|
334 { |
|
335 |
|
336 } |
|
337 void CAMInstOptsParserBase::OnError(TInt aErrorCode) |
|
338 { |
|
339 RDEBUG("CAMInstOptsParserBase::OnError"); |
|
340 if( aErrorCode != KErrNone ) |
|
341 { |
|
342 RDEBUG_2( " ->OnError ( aErrorCode %d)",aErrorCode ); |
|
343 } |
|
344 } |
|
345 |
|
346 |
|
347 |
|
348 TAny* CAMInstOptsParserBase::GetExtendedInterface(const TInt32 /*aUid*/) |
|
349 { |
|
350 |
|
351 return NULL; |
|
352 } |
|
353 |
|
354 |
|
355 /////////////////////////////////////////////////// |
|
356 // |
|
357 // CAMInstOptsParser |
|
358 // |
|
359 /////////////////////////////////////////////////// |
|
360 |
|
361 CAMInstOptsParser * CAMInstOptsParser::NewLC( const TDesC8 &aBuffer, NApplicationManagement::TAMInstallOptions &aResult ) |
|
362 { |
|
363 CAMInstOptsParser *self = new ( ELeave ) CAMInstOptsParser( aBuffer, aResult ); |
|
364 CleanupStack::PushL( self ); |
|
365 self->ConstructL() ; |
|
366 return self ; |
|
367 } |
|
368 |
|
369 CAMInstOptsParser *CAMInstOptsParser::NewL( const TDesC8 &aBuffer, |
|
370 NApplicationManagement::TAMInstallOptions &aResult ) |
|
371 { |
|
372 CAMInstOptsParser *self = NewLC ( aBuffer, aResult ); |
|
373 CleanupStack::Pop( self ); |
|
374 return self ; |
|
375 } |
|
376 |
|
377 CAMUninstOptsParser * CAMUninstOptsParser::NewLC( const TDesC8 &aBuffer, SwiUI::TUninstallOptions &aResult ) |
|
378 { |
|
379 CAMUninstOptsParser *self = new ( ELeave ) CAMUninstOptsParser( aBuffer, aResult ); |
|
380 CleanupStack::PushL( self ); |
|
381 self->ConstructL() ; |
|
382 return self ; |
|
383 } |
|
384 |
|
385 CAMUninstOptsParser *CAMUninstOptsParser::NewL( const TDesC8 &aBuffer, |
|
386 SwiUI::TUninstallOptions &aResult ) |
|
387 { |
|
388 CAMUninstOptsParser *self = NewLC ( aBuffer, aResult ); |
|
389 CleanupStack::Pop( self ); |
|
390 return self ; |
|
391 } |
|
392 |
|
393 |
|
394 CAMInstOptsParser::~CAMInstOptsParser() |
|
395 { |
|
396 |
|
397 } |
|
398 |
|
399 |
|
400 void CAMInstOptsParser::OnStartElementL(const Xml::RTagInfo& aElement, |
|
401 const Xml::RAttributeArray& aAttributes, |
|
402 #ifdef _DEBUG |
|
403 TInt aErrorCode |
|
404 #else |
|
405 TInt /*aErrorCode*/ |
|
406 #endif |
|
407 ) |
|
408 { |
|
409 |
|
410 #ifdef _DEBUG |
|
411 RDEBUG8_3( "CAMInstOptsParser::OnStartElementL (LocalName '%S', aErrorCode %d)", |
|
412 &aElement.LocalName().DesC(),aErrorCode ); |
|
413 TInt count2( aAttributes.Count() ); |
|
414 for( TInt i( 0 ); i < count2; i++ ) |
|
415 { |
|
416 RDEBUG8_5( " Attribute %d, type=%d, '%S'='%S' ",i,aAttributes[i].Type(), |
|
417 &aAttributes[i].Value().DesC(), &aAttributes[i].Attribute().LocalName().DesC() ); |
|
418 |
|
419 } |
|
420 #endif |
|
421 |
|
422 using namespace AMXml; |
|
423 |
|
424 |
|
425 const TPtrC8 name( aElement.LocalName().DesC() ); |
|
426 if ( name == Reader::KIOStartElement ) |
|
427 { |
|
428 |
|
429 if ( aAttributes.Count() == 1 ) |
|
430 { |
|
431 TPtrC8 attrname( aAttributes[0].Attribute().LocalName().DesC() ); |
|
432 if ( attrname == KIOAttrNameDefaultPolicy) |
|
433 { |
|
434 |
|
435 using namespace SwiUI; |
|
436 TPtrC8 attrval( aAttributes[0].Value().DesC() ); |
|
437 if ( attrval == KIOMissingOptionPolicyValFail) |
|
438 { |
|
439 iDefaultPolicy = EPolicyNotAllowed; |
|
440 } |
|
441 else |
|
442 { |
|
443 iDefaultPolicy = EPolicyUserConfirm; |
|
444 } |
|
445 } |
|
446 } |
|
447 } |
|
448 else if ( name != Reader::KIOCustSymOpts ) |
|
449 { |
|
450 RDEBUG8_2( " Processing element '%S'", &name ); |
|
451 TInt c( aAttributes.Count() ); |
|
452 if ( c == 2 ) |
|
453 { |
|
454 TPtrC8 attrname( aAttributes[0].Attribute().LocalName().DesC() ); |
|
455 TPtrC8 attrnameval( aAttributes[0].Value().DesC() ); |
|
456 TPtrC8 attrval( aAttributes[1].Attribute().LocalName().DesC() ); |
|
457 TPtrC8 attrvalval( aAttributes[1].Value().DesC() ); |
|
458 RDEBUG8_5( " Name '%S'='%S' Val '%S'='%S' ",&attrname, &attrnameval, |
|
459 &attrval, &attrvalval ); |
|
460 if ( attrname == Reader::KIOAttrName ) |
|
461 { |
|
462 if ( attrval == Reader::KIOAttrValue ) |
|
463 { |
|
464 if ( name == Reader::KIOStdOpt ) |
|
465 { |
|
466 if ( attrnameval == KIODrive ) |
|
467 { |
|
468 TInt len = attrvalval.Length(); |
|
469 if (len == 0) |
|
470 { |
|
471 TChar KDefaultDrive = 'c'; |
|
472 iResult.iOptions.iDrive = KDefaultDrive; |
|
473 //RDEBUG8_2( " Set drive to %c ", iResult.iOptions.iDrive ); |
|
474 } |
|
475 else |
|
476 { |
|
477 RDEBUG8_2( " Setting drive to %c ", attrvalval[0] ); |
|
478 iResult.iOptions.iDrive = attrvalval[0]; |
|
479 } |
|
480 } |
|
481 else if ( attrnameval == KIOLanguage ) |
|
482 { |
|
483 if ( attrvalval == KIODefaultLanguage ) |
|
484 { |
|
485 iResult.iOptions.iUsePhoneLang = ETrue; |
|
486 } |
|
487 else |
|
488 { |
|
489 for( TInt i( 0 ); i < KNumLangOptions; i++ ) |
|
490 { |
|
491 if ( attrvalval == TPtrC8( KLangOptions[i].iCode ) ) |
|
492 { |
|
493 #ifdef _DEBUG |
|
494 TPtrC8 code( KLangOptions[i].iCode ); |
|
495 RDEBUG8_2( " OnStartElementL : Found language %S", &code); |
|
496 #endif |
|
497 iResult.iOptions.iLang = KLangOptions[i].iLang; |
|
498 break; |
|
499 } |
|
500 } |
|
501 } |
|
502 |
|
503 } |
|
504 else if ( attrnameval == KIOUpgrade ) |
|
505 { |
|
506 RDEBUG8_2( " Setting Upgrade to %S ", &attrvalval ); |
|
507 SetPolicyValue( iResult.iOptions.iUpgrade, attrvalval ); |
|
508 } |
|
509 else if ( attrnameval == KIOKill ) |
|
510 { |
|
511 RDEBUG8_2( " Setting iKillApp to %S ", &attrvalval ); |
|
512 SetPolicyValue( iResult.iOptions.iKillApp, attrvalval ); |
|
513 } |
|
514 else if ( attrnameval == KIOHttpUsername ) |
|
515 { |
|
516 RDEBUG8_2( " Setting iLogin to %S ", &attrvalval ); |
|
517 iResult.iOptions.iLogin.Copy( attrvalval.Left( SwiUI::KSWInstMaxUserNameLength ) ); |
|
518 } |
|
519 else if ( attrnameval == KIOHttpPassword ) |
|
520 { |
|
521 RDEBUG8_2( " Setting iPassword to %S ", &attrvalval ); |
|
522 iResult.iOptions.iPassword.Copy( attrvalval.Left( SwiUI::KSWInstMaxPasswordLength ) ); |
|
523 } |
|
524 else if ( attrnameval == KIODownload ) |
|
525 { |
|
526 RDEBUG8_2( " Setting iDownload to %S ", &attrvalval ); |
|
527 SetPolicyValue( iResult.iOptions.iDownload, attrvalval ); |
|
528 } |
|
529 else if ( attrnameval == KIOIAP ) |
|
530 { |
|
531 RDEBUG8_2( " Setting iConRef to %S ", &attrvalval ); |
|
532 iResult.iConRef = attrvalval; |
|
533 |
|
534 |
|
535 } |
|
536 /* |
|
537 _LIT8( KIOIAP, "iap" ); |
|
538 */ |
|
539 |
|
540 else |
|
541 { |
|
542 RDEBUG8_3( " WARNING Unsupported name attribute value: '%S' for '%S' ", &attrnameval, &name ); |
|
543 } |
|
544 } |
|
545 else if ( name == Reader::KIOStdSymOpt ) |
|
546 { |
|
547 if ( attrnameval == KIOCapabilities ) |
|
548 { |
|
549 RDEBUG8_2( " Setting iCapabilities to %S ", &attrvalval ); |
|
550 SetPolicyValue( iResult.iOptions.iCapabilities, attrvalval ); |
|
551 } |
|
552 else if ( attrnameval == KIOUntrusted ) |
|
553 { |
|
554 RDEBUG8_2( " Setting iUntrusted to %S ", &attrvalval ); |
|
555 SetPolicyValue( iResult.iOptions.iUntrusted, attrvalval ); |
|
556 } |
|
557 else if ( attrnameval == KIOPkginfo ) |
|
558 { |
|
559 RDEBUG8_2( " Setting iPackageInfo to %S ", &attrvalval ); |
|
560 SetPolicyValue( iResult.iOptions.iPackageInfo, attrvalval ); |
|
561 } |
|
562 else if ( attrnameval == KIOOCSP ) |
|
563 { |
|
564 RDEBUG8_2( " Setting iOCSP to %S ", &attrvalval ); |
|
565 SetPolicyValue( iResult.iOptions.iOCSP, attrvalval ); |
|
566 } |
|
567 else if ( attrnameval == KIOOCSPWarning ) |
|
568 { |
|
569 RDEBUG8_2( " Setting iIgnoreOCSPWarnings to %S ", &attrvalval ); |
|
570 SetPolicyValue( iResult.iOptions.iIgnoreOCSPWarnings, attrvalval ); |
|
571 } |
|
572 else if ( attrnameval == KIOOptionalItems ) |
|
573 { |
|
574 RDEBUG8_2( " Setting iOptionalItems to %S ", &attrvalval ); |
|
575 SetPolicyValue( iResult.iOptions.iOptionalItems, attrvalval ); |
|
576 } |
|
577 else if ( attrnameval == KIOOverwrite ) |
|
578 { |
|
579 RDEBUG8_2( " Setting iOverwrite to %S ", &attrvalval ); |
|
580 SetPolicyValue( iResult.iOptions.iOverwrite, attrvalval ); |
|
581 } |
|
582 else if ( attrnameval == KIOUpgradeData ) |
|
583 { |
|
584 RDEBUG8_2( " Setting iUpgradeData to %S ", &attrvalval ); |
|
585 SetPolicyValue( iResult.iOptions.iUpgradeData, attrvalval ); |
|
586 } |
|
587 |
|
588 else |
|
589 { |
|
590 RDEBUG8_3( " WARNING Unsupported name sym attribute value: '%S' for '%S' ", &attrnameval, &name ); |
|
591 } |
|
592 } |
|
593 else |
|
594 { |
|
595 RDEBUG("WARNING, unsupported name attribute!"); |
|
596 } |
|
597 } |
|
598 else |
|
599 { |
|
600 RDEBUG8_3( " ERROR invalid second attribute!: '%S', expteced: '%S' ", &attrval, &Reader::KIOAttrValue() ); |
|
601 } |
|
602 } |
|
603 else |
|
604 { |
|
605 RDEBUG8_3( " ERROR invalid first attribute!: '%S', expteced: '%S' ", &attrname, &Reader::KIOAttrName() ); |
|
606 } |
|
607 } |
|
608 else |
|
609 { |
|
610 RDEBUG8_3( " ERROR unsupported count of attributes!!: '%d' for '%S' ", c, &name); |
|
611 } |
|
612 } |
|
613 else |
|
614 { |
|
615 RDEBUG( " ERROR custom options not implemented!!!!" ); |
|
616 |
|
617 } |
|
618 } |
|
619 |
|
620 |
|
621 /////////////////////////////////////////////////// |
|
622 // |
|
623 // CAMUninstOptsParser |
|
624 // |
|
625 /////////////////////////////////////////////////// |
|
626 |
|
627 CAMUninstOptsParser::~CAMUninstOptsParser() |
|
628 { |
|
629 |
|
630 } |
|
631 |
|
632 void CAMUninstOptsParser::OnStartElementL(const Xml::RTagInfo& aElement, |
|
633 const Xml::RAttributeArray& aAttributes, |
|
634 #ifdef _DEBUG |
|
635 TInt aErrorCode |
|
636 #else |
|
637 TInt /*aErrorCode*/ |
|
638 #endif |
|
639 ) |
|
640 { |
|
641 |
|
642 #ifdef _DEBUG |
|
643 RDEBUG8_3( "CAMUninstOptsParser::OnStartElementL (LocalName '%S', aErrorCode %d)", |
|
644 &aElement.LocalName().DesC(),aErrorCode ); |
|
645 TInt count2( aAttributes.Count() ); |
|
646 for( TInt i( 0 ); i < count2; i++ ) |
|
647 { |
|
648 RDEBUG8_5( " Attribute %d, type=%d, '%S'='%S' ",i,aAttributes[i].Type(), |
|
649 &aAttributes[i].Value().DesC(), &aAttributes[i].Attribute().LocalName().DesC() ); |
|
650 |
|
651 } |
|
652 #endif |
|
653 |
|
654 using namespace AMXml; |
|
655 |
|
656 |
|
657 const TPtrC8 name( aElement.LocalName().DesC() ); |
|
658 if ( name == Reader::KIOStartElement ) |
|
659 { |
|
660 |
|
661 } |
|
662 else if ( name != Reader::KIOCustSymOpts ) |
|
663 { |
|
664 RDEBUG8_2( " Processing element '%S'", &name ); |
|
665 TInt c( aAttributes.Count() ); |
|
666 if ( c == 2 ) |
|
667 { |
|
668 TPtrC8 attrname( aAttributes[0].Attribute().LocalName().DesC() ); |
|
669 TPtrC8 attrnameval( aAttributes[0].Value().DesC() ); |
|
670 TPtrC8 attrval( aAttributes[1].Attribute().LocalName().DesC() ); |
|
671 TPtrC8 attrvalval( aAttributes[1].Value().DesC() ); |
|
672 RDEBUG8_5( " Name '%S'='%S' Val '%S'='%S' ",&attrname, &attrnameval, |
|
673 &attrval, &attrvalval ); |
|
674 if ( attrname == Reader::KIOAttrName ) |
|
675 { |
|
676 if ( attrval == Reader::KIOAttrValue ) |
|
677 { |
|
678 if ( name == Reader::KIOStdOpt ) |
|
679 { |
|
680 if ( attrnameval == KIOKill ) |
|
681 { |
|
682 RDEBUG8_2( " Setting iKillApp to %S ", &attrvalval ); |
|
683 SetPolicyValue( iResult.iKillApp, attrvalval ); |
|
684 } |
|
685 else |
|
686 { |
|
687 RDEBUG8_3( " WARNING Unsupported name attribute value: '%S' for '%S' ", &attrnameval, &name ); |
|
688 } |
|
689 } |
|
690 else if ( name == Reader::KIOStdSymOpt ) |
|
691 { |
|
692 if ( attrnameval == KUIOBreakDependency ) |
|
693 { |
|
694 RDEBUG8_2( " Setting iDependecyBreak to %S ", &attrvalval ); |
|
695 SetPolicyValue( iResult.iBreakDependency, attrvalval ); |
|
696 } |
|
697 else |
|
698 { |
|
699 RDEBUG8_3( " WARNING Unsupported name attribute value: '%S' for '%S' ", &attrnameval, &name ); |
|
700 } |
|
701 } |
|
702 else |
|
703 { |
|
704 RDEBUG("WARNING, unsupported name attribute value"); |
|
705 } |
|
706 } |
|
707 else |
|
708 { |
|
709 RDEBUG8_3( " ERROR invalid second attribute!: '%S', expteced: '%S' ", &attrval, &Reader::KIOAttrValue() ); |
|
710 } |
|
711 } |
|
712 else |
|
713 { |
|
714 RDEBUG8_3( " ERROR invalid first attribute!: '%S', expteced: '%S' ", &attrname, &Reader::KIOAttrName() ); |
|
715 } |
|
716 } |
|
717 else |
|
718 { |
|
719 RDEBUG8_3( " ERROR unsupported count of attributes!!: '%d' for '%S' ", c, &name); |
|
720 } |
|
721 } |
|
722 else |
|
723 { |
|
724 RDEBUG( " ERROR custom options not implemented!!!!" ); |
|
725 |
|
726 } |
|
727 } |
|
728 |
|
729 |
|
730 /////////////////////////////////////////////////// |
|
731 // |
|
732 // InstallOptionsParser |
|
733 // |
|
734 /////////////////////////////////////////////////// |
|
735 |
|
736 EXPORT_C void InstallOptionsParser::ParseOptionsL( const TDesC8 &aBuffer, SwiUI::TInstallOptions &aResult) |
|
737 { |
|
738 NApplicationManagement::TAMInstallOptions opts; |
|
739 opts.iOptions.iUsePhoneLang = EFalse; |
|
740 CAMInstOptsParser *parser = CAMInstOptsParser::NewLC( aBuffer, opts ); |
|
741 parser->ParseL(); |
|
742 aResult = opts.iOptions; |
|
743 CleanupStack::PopAndDestroy( parser ); |
|
744 } |
|
745 |
|
746 EXPORT_C void InstallOptionsParser::ParseOptionsL( const TDesC8 &aBuffer, NApplicationManagement::TAMInstallOptions &aResult) |
|
747 { |
|
748 aResult.iOptions.iUsePhoneLang = EFalse; |
|
749 CAMInstOptsParser *parser = CAMInstOptsParser::NewLC( aBuffer, aResult ); |
|
750 parser->ParseL(); |
|
751 CleanupStack::PopAndDestroy( parser ); |
|
752 } |
|
753 |
|
754 EXPORT_C void InstallOptionsParser::ParseOptionsL( const TDesC8 &aBuffer, SwiUI::TUninstallOptions &aResult) |
|
755 { |
|
756 CAMUninstOptsParser *parser = CAMUninstOptsParser::NewLC( aBuffer, aResult ); |
|
757 parser->ParseL(); |
|
758 CleanupStack::PopAndDestroy( parser ); |
|
759 } |
|
760 |
|
761 EXPORT_C void InstallOptionsParser::SerializeOptionsL( const SwiUI::TUninstallOptions &aOptions, CBufBase &aResult ) |
|
762 { |
|
763 using namespace AMXml; |
|
764 using namespace AMXml::Writer; |
|
765 using namespace SwiUI; |
|
766 |
|
767 aResult.InsertL(aResult.Size(), Writer::KUIOStartElement ); |
|
768 |
|
769 HBufC8 *tmp = HBufC8::NewLC( 128 ); |
|
770 TPtr8 ptmp( tmp->Des() ); |
|
771 |
|
772 if ( aOptions.iKillApp != EPolicyUserConfirm ) |
|
773 { |
|
774 ptmp.Format( KIOStdOptFormat, &KIOKill, ( aOptions.iKillApp == EPolicyAllowed ? &KIOValueTrue : &KIOValueFalse ) ); |
|
775 aResult.InsertL( aResult.Size(), ptmp ); |
|
776 } |
|
777 if ( aOptions.iBreakDependency != EPolicyUserConfirm ) |
|
778 { |
|
779 ptmp.Format( KIOStdSymOptFormat, &KUIOBreakDependency, ( aOptions.iKillApp == EPolicyAllowed ? &KIOValueTrue : &KIOValueFalse ) ); |
|
780 aResult.InsertL( aResult.Size(), ptmp ); |
|
781 } |
|
782 aResult.InsertL(aResult.Size(), Writer::KUIOStartElementEnd ); |
|
783 |
|
784 CleanupStack::PopAndDestroy( tmp ); |
|
785 } |
|
786 |
|
787 EXPORT_C void InstallOptionsParser::SerializeOptionsL( const SwiUI::TInstallOptions &aOptions, CBufBase &aResult ) |
|
788 { |
|
789 NApplicationManagement::TAMInstallOptions options; |
|
790 options.iOptions = aOptions; |
|
791 SerializeOptionsL( options, aResult ); |
|
792 } |
|
793 |
|
794 EXPORT_C void InstallOptionsParser::SerializeOptionsL( const NApplicationManagement::TAMInstallOptions &aOptions, CBufBase &aResult ) |
|
795 { |
|
796 |
|
797 using namespace AMXml; |
|
798 using namespace AMXml::Writer; |
|
799 using namespace SwiUI; |
|
800 |
|
801 const SwiUI::TInstallOptions &options = aOptions.iOptions; |
|
802 |
|
803 aResult.InsertL(aResult.Size(), Writer::KIOStartElement ); |
|
804 |
|
805 HBufC8 *tmp = HBufC8::NewLC( 128 ); |
|
806 TPtr8 ptmp( tmp->Des() ); |
|
807 TBuf8<1> b ; |
|
808 b.Append( options.iDrive ); |
|
809 ptmp.Format( KIOStdOptFormat, &KIODrive, &b ); |
|
810 aResult.InsertL( aResult.Size(), ptmp ); |
|
811 |
|
812 if( options.iUsePhoneLang ) |
|
813 { |
|
814 ptmp.Format( KIOStdOptFormat, &KIOLanguage, &KIODefaultLanguage ) ; |
|
815 } |
|
816 else |
|
817 { |
|
818 if( options.iLang != ELangNone ) |
|
819 { |
|
820 TBool found( EFalse ); |
|
821 for( TInt i( 0 ); !found && i < KNumLangOptions; i++ ) |
|
822 { |
|
823 if ( KLangOptions[i].iLang == options.iLang ) |
|
824 { |
|
825 #ifdef _DEBUG |
|
826 TPtrC8 code( KLangOptions[i].iCode ); |
|
827 RDEBUG8_2( " InstallOptionsParser::SerializeOptionsL : Found language %S", &code ); |
|
828 #endif |
|
829 TPtrC8 p( KLangOptions[i].iCode ); |
|
830 ptmp.Format( KIOStdOptFormat, &KIOLanguage, &p ) ; |
|
831 |
|
832 found = ETrue; |
|
833 } |
|
834 } |
|
835 if ( !found ) |
|
836 { |
|
837 ptmp.Format( KNullDesC8() ); |
|
838 } |
|
839 } |
|
840 else |
|
841 { |
|
842 ptmp.Format( KNullDesC8() ); |
|
843 } |
|
844 } |
|
845 aResult.InsertL( aResult.Size(), ptmp ); |
|
846 |
|
847 if ( options.iUpgrade != EPolicyUserConfirm ) |
|
848 { |
|
849 ptmp.Format( KIOStdOptFormat, &KIOUpgrade, ( options.iUpgrade == EPolicyAllowed ? &KIOValueTrue : &KIOValueFalse ) ); |
|
850 aResult.InsertL( aResult.Size(), ptmp ); |
|
851 |
|
852 } |
|
853 if ( options.iKillApp != EPolicyUserConfirm ) |
|
854 { |
|
855 ptmp.Format( KIOStdOptFormat, &KIOKill, ( options.iKillApp == EPolicyAllowed ? &KIOValueTrue : &KIOValueFalse ) ); |
|
856 aResult.InsertL( aResult.Size(), ptmp ); |
|
857 } |
|
858 if ( options.iPackageInfo != EPolicyUserConfirm ) |
|
859 { |
|
860 ptmp.Format( KIOStdSymOptFormat, &KIOPkginfo, ( options.iPackageInfo == EPolicyAllowed ? &KIOValueTrue : &KIOValueFalse ) ); |
|
861 aResult.InsertL( aResult.Size(), ptmp ); |
|
862 } |
|
863 if ( options.iCapabilities != EPolicyUserConfirm ) |
|
864 { |
|
865 ptmp.Format( KIOStdSymOptFormat, &KIOCapabilities, ( options.iCapabilities == EPolicyAllowed ? &KIOValueTrue : &KIOValueFalse ) ); |
|
866 aResult.InsertL( aResult.Size(), ptmp ); |
|
867 } |
|
868 if ( options.iUntrusted != EPolicyUserConfirm ) |
|
869 { |
|
870 ptmp.Format( KIOStdSymOptFormat, &KIOUntrusted, ( options.iUntrusted == EPolicyAllowed ? &KIOValueTrue : &KIOValueFalse ) ); |
|
871 aResult.InsertL( aResult.Size(), ptmp ); |
|
872 } |
|
873 if ( options.iOCSP != EPolicyUserConfirm ) |
|
874 { |
|
875 ptmp.Format( KIOStdSymOptFormat, &KIOOCSP, ( options.iOCSP == EPolicyAllowed ? &KIOValueTrue : &KIOValueFalse ) ); |
|
876 aResult.InsertL( aResult.Size(), ptmp ); |
|
877 } |
|
878 if ( options.iIgnoreOCSPWarnings != EPolicyUserConfirm ) |
|
879 { |
|
880 ptmp.Format( KIOStdSymOptFormat, &KIOOCSPWarning, ( options.iIgnoreOCSPWarnings == EPolicyAllowed ? &KIOValueTrue : &KIOValueFalse ) ); |
|
881 aResult.InsertL( aResult.Size(), ptmp ); |
|
882 } |
|
883 if ( options.iOptionalItems != EPolicyUserConfirm ) |
|
884 { |
|
885 ptmp.Format( KIOStdSymOptFormat, &KIOOptionalItems, ( options.iOptionalItems == EPolicyAllowed ? &KIOValueTrue : &KIOValueFalse ) ); |
|
886 aResult.InsertL( aResult.Size(), ptmp ); |
|
887 } |
|
888 if ( options.iOverwrite != EPolicyUserConfirm ) |
|
889 { |
|
890 ptmp.Format( KIOStdSymOptFormat, &KIOOverwrite, ( options.iOverwrite == EPolicyAllowed ? &KIOValueTrue : &KIOValueFalse ) ); |
|
891 aResult.InsertL( aResult.Size(), ptmp ); |
|
892 } |
|
893 if ( options.iUpgradeData != EPolicyUserConfirm ) |
|
894 { |
|
895 ptmp.Format( KIOStdSymOptFormat, &KIOUpgradeData, ( options.iUpgradeData == EPolicyAllowed ? &KIOValueTrue : &KIOValueFalse ) ); |
|
896 aResult.InsertL( aResult.Size(), ptmp ); |
|
897 } |
|
898 if ( options.iDownload != EPolicyUserConfirm ) |
|
899 { |
|
900 ptmp.Format( KIOStdOptFormat, &KIODownload, ( options.iDownload == EPolicyAllowed ? &KIOValueTrue : &KIOValueFalse ) ); |
|
901 aResult.InsertL( aResult.Size(), ptmp ); |
|
902 } |
|
903 if ( options.iPassword != KNullDesC() ) |
|
904 { |
|
905 TBuf8<KSWInstMaxPasswordLength> password; |
|
906 password.Copy( options.iPassword ); |
|
907 ptmp.Format( KIOStdOptFormat, &KIOHttpPassword, &password ); |
|
908 aResult.InsertL( aResult.Size(), ptmp ); |
|
909 } |
|
910 if ( options.iLogin != KNullDesC() ) |
|
911 { |
|
912 TBuf8<KSWInstMaxUserNameLength> login; |
|
913 login.Copy( options.iLogin ); |
|
914 ptmp.Format( KIOStdOptFormat, &KIOHttpUsername, &login ); |
|
915 aResult.InsertL( aResult.Size(), ptmp ); |
|
916 } |
|
917 if ( aOptions.iConRef != KNullDesC8() ) |
|
918 { |
|
919 ptmp.Format( KIOStdOptFormat, &KIOIAP, &aOptions.iConRef); |
|
920 aResult.InsertL( aResult.Size(), ptmp ); |
|
921 } |
|
922 aResult.InsertL( aResult.Size(), KIOStartElementEnd ); |
|
923 |
|
924 CleanupStack::PopAndDestroy( tmp ); |
|
925 } |
|
926 |
|
927 // End of File |