|
1 /* |
|
2 * Copyright (c) 2002 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: DM Themes List |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ThemesList.h" |
|
20 |
|
21 #include <badesca.h> |
|
22 #include <implementationproxy.h> // For TImplementationProxy definition |
|
23 #include <e32def.h> |
|
24 #include <centralrepository.h> |
|
25 #include <AknSkinsInternalCRKeys.h> |
|
26 #include <sisregistrysession.h> |
|
27 #include <sisregistrypackage.h> |
|
28 |
|
29 #include "FileCoderB64.h" |
|
30 #include "aminstalloptions.h" |
|
31 #include "debug.h" |
|
32 |
|
33 #ifdef RD_MULTIPLE_DRIVE |
|
34 #include <driveinfo.h> |
|
35 #endif //RD_MULTIPLE_DRIVEs |
|
36 |
|
37 _LIT8( KSlash, "/" ); |
|
38 _LIT8(KCol,":"); |
|
39 const TInt KPostTimeOut = 10000000; // 10 seconds |
|
40 |
|
41 |
|
42 // ------------------------------------------------------------------------------------------------ |
|
43 // CThemesList* CThemesList::NewL( ) |
|
44 // ------------------------------------------------------------------------------------------------ |
|
45 CThemesList* CThemesList::NewL( ) //sf-MSmlDmCallback* aDmCallback ) |
|
46 { |
|
47 RDEBUG("CThemesList::NewL(): begin"); |
|
48 |
|
49 CThemesList* self = NewLC(); |
|
50 CleanupStack::Pop(); |
|
51 return self; |
|
52 } |
|
53 |
|
54 // ------------------------------------------------------------------------------------------------ |
|
55 // CThemesList* CThemesList::NewLC( ) |
|
56 // ------------------------------------------------------------------------------------------------ |
|
57 CThemesList* CThemesList::NewLC( ) //sf-MSmlDmCallback* aDmCallback ) |
|
58 { |
|
59 CThemesList* self = new( ELeave ) CThemesList(); |
|
60 CleanupStack::PushL( self ); |
|
61 self->ConstructL( ); |
|
62 return self; |
|
63 } |
|
64 |
|
65 |
|
66 // ------------------------------------------------------------------------------------------------ |
|
67 // CThemesList::CThemesList() |
|
68 // ------------------------------------------------------------------------------------------------ |
|
69 CThemesList::CThemesList( ) //sf-MSmlDmCallback* aDmCallback ) |
|
70 //sf- : iCallBack( aDmCallback ) |
|
71 : iDirty( ETrue ) |
|
72 , iAknsSrv( ) |
|
73 , iSkins( 0 ) |
|
74 , iInstallOptions() |
|
75 { |
|
76 GetDefaultInstallOptions( iInstallOptions ); |
|
77 } |
|
78 |
|
79 // ------------------------------------------------------------------------------------------------ |
|
80 // CThemesList::ConstructL() |
|
81 // ------------------------------------------------------------------------------------------------ |
|
82 void CThemesList::ConstructL( ) |
|
83 { |
|
84 User::LeaveIfError( iAknsSrv.Connect() ); |
|
85 } |
|
86 |
|
87 // ------------------------------------------------------------------------------------------------ |
|
88 // CThemesList::~CThemesList() |
|
89 // ------------------------------------------------------------------------------------------------ |
|
90 CThemesList::~CThemesList() |
|
91 { |
|
92 if (iSkins) |
|
93 { |
|
94 iSkins->ResetAndDestroy(); |
|
95 delete iSkins; |
|
96 } |
|
97 iAknsSrv.Close(); |
|
98 } |
|
99 |
|
100 // ------------------------------------------------------------------------------------------------ |
|
101 // CThemesList::GetInstalledPIDListL() |
|
102 // ------------------------------------------------------------------------------------------------ |
|
103 |
|
104 MSmlDmAdapter::TError CThemesList::GetInstalledPIDListL( const CArrayFix<TSmlDmMappingInfo>& aPreviousList, CDesC8ArrayFlat& themes, CDesC8Array& aNewThemes ) |
|
105 { |
|
106 TInt i = 0; |
|
107 TInt pos = 0; |
|
108 |
|
109 CheckUpdatesL(); |
|
110 |
|
111 CDesC8ArrayFlat* luids = new (ELeave) CDesC8ArrayFlat( 32 ); |
|
112 CleanupStack::PushL( luids ); |
|
113 |
|
114 // Create list of existing themes |
|
115 for (i = 0 ; i < aPreviousList.Count() ; i++) |
|
116 { |
|
117 themes.AppendL( aPreviousList[i].iURISeg ); |
|
118 luids->AppendL( aPreviousList[i].iURISegLUID ); |
|
119 } |
|
120 |
|
121 // Find and add missing themes |
|
122 |
|
123 for (i = 0 ; i < iSkins->Count() ; i++) |
|
124 { |
|
125 TAknsPkgIDBuf pidBuf; |
|
126 TBuf8<KSmlMaxURISegLen> name; |
|
127 |
|
128 TAknsPkgID pid = (*iSkins)[i]->PID(); |
|
129 pid.CopyToDes( pidBuf ); |
|
130 name.Copy( pidBuf ); |
|
131 |
|
132 if (luids->Find( name, pos ) != 0) |
|
133 { |
|
134 // not found |
|
135 // Check that current "name" is not in use |
|
136 if (themes.Find( name, pos ) != 0) |
|
137 { |
|
138 // not found |
|
139 // add it to both current and new themes |
|
140 // themes->AppendL( name ); |
|
141 aNewThemes.AppendL( name ); |
|
142 } |
|
143 } |
|
144 } |
|
145 |
|
146 // Fill result |
|
147 #if 0 |
|
148 for (i = 0 ; i < themes->Count() ; i++) |
|
149 { |
|
150 if (i > 0) |
|
151 { |
|
152 aList.InsertL( aList.Size(), KSlash ); |
|
153 } |
|
154 aList.InsertL( aList.Size(), (*themes)[i] ); |
|
155 } |
|
156 |
|
157 #endif |
|
158 // Cleanup |
|
159 CleanupStack::PopAndDestroy( luids ); |
|
160 //CleanupStack::PopAndDestroy( themes ); |
|
161 |
|
162 return MSmlDmAdapter::EOk; |
|
163 } |
|
164 |
|
165 // ------------------------------------------------------------------------------------------------ |
|
166 // CThemesList::GetThemeIdL() |
|
167 // ------------------------------------------------------------------------------------------------ |
|
168 MSmlDmAdapter::TError CThemesList::GetThemeIdL( const TDesC8& aPID, CBufBase& aResult ) |
|
169 { |
|
170 MSmlDmAdapter::TError ret = MSmlDmAdapter::ENotFound; |
|
171 |
|
172 CAknsSrvSkinInformationPkg* theme = FindThemeL( aPID ); |
|
173 if (theme != 0) |
|
174 { |
|
175 TAknsPkgIDBuf pid; |
|
176 theme->PID().CopyToDes( pid ); |
|
177 TBuf8<KAknsPkgIDDesSize> pid8; |
|
178 pid8.Copy( pid ); |
|
179 aResult.InsertL( aResult.Size(), pid8 ); |
|
180 ret = MSmlDmAdapter::EOk; |
|
181 } |
|
182 |
|
183 return ret; |
|
184 } |
|
185 |
|
186 // ------------------------------------------------------------------------------------------------ |
|
187 // CThemesList::GetThemeNameL() |
|
188 // ------------------------------------------------------------------------------------------------ |
|
189 MSmlDmAdapter::TError CThemesList::GetThemeNameL( const TDesC8& aPID, CBufBase& aResult ) |
|
190 { |
|
191 MSmlDmAdapter::TError ret = MSmlDmAdapter::ENotFound; |
|
192 |
|
193 CAknsSrvSkinInformationPkg* theme = FindThemeL( aPID ); |
|
194 if (theme != 0) |
|
195 { |
|
196 TDesC& name = theme->Name(); |
|
197 HBufC8* buf = HBufC8::NewLC( name.Length() ); |
|
198 buf->Des().Copy( name ); |
|
199 aResult.InsertL( aResult.Size(), *buf ); |
|
200 CleanupStack::PopAndDestroy( buf ); |
|
201 ret = MSmlDmAdapter::EOk; |
|
202 } |
|
203 |
|
204 return ret; |
|
205 } |
|
206 |
|
207 // ------------------------------------------------------------------------------------------------ |
|
208 // CThemesList::GetThemeVersionL() |
|
209 // ------------------------------------------------------------------------------------------------ |
|
210 MSmlDmAdapter::TError CThemesList::GetThemeVersionL( const TDesC8& aPID, CBufBase& /*aResult*/ ) |
|
211 { |
|
212 MSmlDmAdapter::TError ret = MSmlDmAdapter::ENotFound; |
|
213 |
|
214 CAknsSrvSkinInformationPkg* theme = FindThemeL( aPID ); |
|
215 if (theme != 0) |
|
216 { |
|
217 // Empty version, not supported (yet?) |
|
218 ret = MSmlDmAdapter::EOk; |
|
219 } |
|
220 |
|
221 return ret; |
|
222 } |
|
223 |
|
224 // ------------------------------------------------------------------------------------------------ |
|
225 // CThemesList::GetActiveThemeL() |
|
226 // ------------------------------------------------------------------------------------------------ |
|
227 MSmlDmAdapter::TError CThemesList::GetActiveThemeL( CBufBase& aResult ) |
|
228 { |
|
229 MSmlDmAdapter::TError ret = MSmlDmAdapter::EOk; |
|
230 TInt errCode = KErrNone; |
|
231 TAknsPkgID pid = KAknsNullPkgID; |
|
232 TAknsPkgIDBuf buf; |
|
233 |
|
234 CRepository* skinsRepository = CRepository::NewLC( KCRUidPersonalisation ); |
|
235 |
|
236 errCode = skinsRepository->Get( KPslnActiveSkinUid, buf ); |
|
237 if( errCode == KErrNone ) |
|
238 { |
|
239 TRAP( errCode, pid.SetFromDesL( buf ) ); |
|
240 } |
|
241 if( errCode != KErrNone ) |
|
242 { |
|
243 //sf- pid.Set( KAknsPIDDefaultSystemSkin ); |
|
244 //sf- changes to KAknsPIDS60DefaltSystemSkin and |
|
245 //sf- to KAknsPIDProductDefaultSystemSkin |
|
246 //sf- and the product default should be used (because variation might be done). |
|
247 //sf- Starting from S60 3.1 wk50 or wk52 |
|
248 //sf- But: CenRep key should always hold a value so this code is not necessary. |
|
249 } |
|
250 |
|
251 pid.CopyToDes( buf ); |
|
252 |
|
253 CleanupStack::PopAndDestroy( skinsRepository ); |
|
254 skinsRepository = 0; |
|
255 |
|
256 TBuf8<KAknsPkgIDDesSize> buf8; |
|
257 buf8.Copy( buf ); |
|
258 |
|
259 aResult.InsertL( aResult.Size(), buf8 ); |
|
260 |
|
261 return ret; |
|
262 } |
|
263 |
|
264 // ------------------------------------------------------------------------------------------------ |
|
265 // CThemesList::SetActiveThemeL() |
|
266 // ------------------------------------------------------------------------------------------------ |
|
267 MSmlDmAdapter::TError CThemesList::SetActiveThemeL( const TDesC8& aPID ) |
|
268 { |
|
269 MSmlDmAdapter::TError ret = MSmlDmAdapter::EOk; |
|
270 TInt errCode = KErrNone; |
|
271 |
|
272 CAknsSrvSkinInformationPkg* theme = FindThemeL( aPID ); |
|
273 if (theme == 0) |
|
274 { |
|
275 errCode = KErrNotFound; |
|
276 } |
|
277 if (errCode == KErrNone) |
|
278 { |
|
279 errCode = iAknsSrv.SetAllDefinitionSets( theme->PID() ); |
|
280 } |
|
281 if (errCode == KErrNone) |
|
282 { |
|
283 // Save settings to repository |
|
284 TAknsPkgIDBuf pidBuf; |
|
285 theme->PID().CopyToDes( pidBuf ); |
|
286 |
|
287 TAknSkinSrvSkinPackageLocation location = |
|
288 LocationFromPath( theme->IniFileDirectory() ); |
|
289 |
|
290 CRepository* skinsRepository = CRepository::NewLC( KCRUidPersonalisation ); |
|
291 |
|
292 errCode = skinsRepository->Set( KPslnActiveSkinUid, pidBuf ); |
|
293 errCode = skinsRepository->Set( KPslnActiveSkinLocation, location ); |
|
294 |
|
295 CleanupStack::PopAndDestroy( skinsRepository ); |
|
296 } |
|
297 |
|
298 if (errCode != KErrNone) |
|
299 { |
|
300 ret = MSmlDmAdapter::EError; |
|
301 } |
|
302 |
|
303 return ret; |
|
304 } |
|
305 |
|
306 // ------------------------------------------------------------------------------------------------ |
|
307 // CThemesList::SetInstallOptionsL() |
|
308 // ------------------------------------------------------------------------------------------------ |
|
309 MSmlDmAdapter::TError CThemesList::SetInstallOptionsL( const TDesC8& aOptions ) |
|
310 { |
|
311 MSmlDmAdapter::TError ret = MSmlDmAdapter::EOk; |
|
312 TInt errCode = KErrNone; |
|
313 |
|
314 GetDefaultInstallOptions( iInstallOptions ); |
|
315 |
|
316 if (aOptions.Length() > 0) |
|
317 { |
|
318 TRAP( errCode, InstallOptionsParser::ParseOptionsL( aOptions, iInstallOptions ) ); |
|
319 } |
|
320 if (errCode != KErrNone) |
|
321 { |
|
322 ret = MSmlDmAdapter::EError; |
|
323 } |
|
324 |
|
325 return ret; |
|
326 } |
|
327 |
|
328 // ------------------------------------------------------------------------------------------------ |
|
329 // CThemesList::InstallThemeL() |
|
330 // ------------------------------------------------------------------------------------------------ |
|
331 MSmlDmAdapter::TError CThemesList::InstallThemeL( const TDesC& aFileName, TDes8& aSisPkgUid, TDes8& aThemePkgId ) |
|
332 { |
|
333 MSmlDmAdapter::TError ret = MSmlDmAdapter::EOk; |
|
334 TInt errCode = KErrNone; |
|
335 |
|
336 CDesC8Array* pkgUidsOrg = InstalledPackagesL( ); |
|
337 CleanupStack::PushL( pkgUidsOrg ); |
|
338 CDesC8Array* thmPidsOrg = InstalledThemesL( ); |
|
339 CleanupStack::PushL( thmPidsOrg ); |
|
340 |
|
341 // Install using options if given and otherwise with default options |
|
342 SwiUI::RSWInstLauncher installer; |
|
343 User::LeaveIfError( installer.Connect() ); |
|
344 CleanupClosePushL( installer ); |
|
345 |
|
346 SwiUI::TInstallOptionsPckg optPckg( iInstallOptions ); |
|
347 errCode = installer.SilentInstall( aFileName, optPckg ); |
|
348 CleanupStack::PopAndDestroy( &installer ); |
|
349 |
|
350 // Retrieve new list of installed packages and themes |
|
351 CDesC8Array* pkgUidsNew = InstalledPackagesL( ); |
|
352 CleanupStack::PushL( pkgUidsNew ); |
|
353 CDesC8Array* thmPidsNew = InstalledThemesL( ); |
|
354 CleanupStack::PushL( thmPidsNew ); |
|
355 |
|
356 // Try to find sis package uid and theme package id |
|
357 CDesC8Array* pkgUidsDif = FindNewItemsL( *pkgUidsOrg, *pkgUidsNew ); |
|
358 CleanupStack::PushL( pkgUidsDif ); |
|
359 |
|
360 CDesC8Array* thmPidsDif = FindNewItemsL( *thmPidsOrg, *thmPidsNew ); |
|
361 CleanupStack::PushL( thmPidsDif ); |
|
362 |
|
363 if (pkgUidsDif->Count() == 1) |
|
364 { |
|
365 aSisPkgUid = (*pkgUidsDif)[0]; |
|
366 } |
|
367 if (thmPidsDif->Count() > 0) |
|
368 { |
|
369 aThemePkgId = (*thmPidsDif)[0]; |
|
370 } |
|
371 RDEBUG_2( " CThemesList::InstallThemeL : SISPKGUID %X", &(aSisPkgUid) ); |
|
372 RDEBUG_2( " CThemesList::InstallThemeL : THEMEPKGUID %X", &(aThemePkgId) ); |
|
373 |
|
374 // Cleanup |
|
375 CleanupStack::PopAndDestroy( thmPidsDif ); |
|
376 CleanupStack::PopAndDestroy( pkgUidsDif ); |
|
377 CleanupStack::PopAndDestroy( thmPidsNew ); |
|
378 CleanupStack::PopAndDestroy( pkgUidsNew ); |
|
379 CleanupStack::PopAndDestroy( thmPidsOrg ); |
|
380 CleanupStack::PopAndDestroy( pkgUidsOrg ); |
|
381 |
|
382 // Convert error code |
|
383 if (errCode != KErrNone) |
|
384 { |
|
385 ret = MSmlDmAdapter::EError; |
|
386 } |
|
387 |
|
388 return ret; |
|
389 } |
|
390 |
|
391 // ------------------------------------------------------------------------------------------------ |
|
392 // CThemesList::DeleteThemeL() |
|
393 // ------------------------------------------------------------------------------------------------ |
|
394 MSmlDmAdapter::TError CThemesList::DeleteThemeL( const TDesC8& aThemeId, const TUid& aPkgUid,HBufC8* aLuid) |
|
395 { |
|
396 MSmlDmAdapter::TError ret = MSmlDmAdapter::EOk; |
|
397 TInt errCode = KErrNone; |
|
398 |
|
399 CAknsSrvSkinInformationPkg* theme = FindThemeL( aThemeId ); |
|
400 if (theme != NULL) |
|
401 { |
|
402 // Save settings to repository |
|
403 TAknsPkgIDBuf pidBuf; |
|
404 TAknsPkgID themepid = theme->PID(); |
|
405 themepid.CopyToDes(pidBuf); |
|
406 |
|
407 CRepository* skinsRepository = CRepository::NewLC( |
|
408 KCRUidPersonalisation); |
|
409 |
|
410 TAknsPkgIDBuf repBuf; |
|
411 errCode = skinsRepository->Get(KPslnActiveSkinUid, repBuf); |
|
412 if (errCode == KErrNone) |
|
413 { |
|
414 TAknsPkgID activepid = KAknsNullPkgID; |
|
415 activepid.SetFromDesL(repBuf); |
|
416 |
|
417 //Comparing the UIds of the active theme and the theme to be deleted |
|
418 if (themepid.Uid() == activepid.Uid()) |
|
419 { |
|
420 // deleted theme is active theme, deactive it first |
|
421 TInt count = iSkins->Count(); |
|
422 if (count > 1) |
|
423 { |
|
424 pidBuf.Zero(); |
|
425 CAknsSrvSkinInformationPkg* defaultTheme = (*iSkins)[0]; |
|
426 defaultTheme->PID().CopyToDes(pidBuf); |
|
427 TBuf8<KAknsPkgIDDesSize> pidBuf8; |
|
428 pidBuf8.Copy(pidBuf); |
|
429 errCode = SetActiveThemeL(pidBuf8); |
|
430 |
|
431 if (errCode == KErrNone) |
|
432 { |
|
433 TRequestStatus timeoutStatus /*= KRequestPending*/; |
|
434 |
|
435 RTimer timeout; |
|
436 User::LeaveIfError(timeout.CreateLocal()); |
|
437 CleanupClosePushL(timeout); |
|
438 timeout.After(timeoutStatus, KPostTimeOut); |
|
439 |
|
440 User::WaitForRequest(timeoutStatus); |
|
441 |
|
442 if (timeoutStatus.Int() == KRequestPending) |
|
443 { |
|
444 timeout.Cancel(); |
|
445 User::WaitForRequest(timeoutStatus); |
|
446 } |
|
447 CleanupStack::PopAndDestroy(&timeout); |
|
448 } |
|
449 } |
|
450 else |
|
451 { |
|
452 errCode = KErrGeneral; |
|
453 } |
|
454 } |
|
455 |
|
456 CleanupStack::PopAndDestroy(skinsRepository); |
|
457 } |
|
458 |
|
459 } |
|
460 else |
|
461 { |
|
462 errCode = KErrNotFound; |
|
463 } |
|
464 |
|
465 |
|
466 if( errCode == KErrNone ) |
|
467 { |
|
468 iDirty = ETrue; |
|
469 |
|
470 // Uninstall silent |
|
471 SwiUI::RSWInstLauncher installer; |
|
472 User::LeaveIfError( installer.Connect() ); |
|
473 CleanupClosePushL( installer ); |
|
474 |
|
475 //Silent uninstall not working because of getting wrong package name |
|
476 //So we used SilentCustomUninstall which uses index and pkgUid to get correct package name |
|
477 |
|
478 TInt idx( KErrNotFound ); |
|
479 SwiUI::TOpUninstallIndexParam params; |
|
480 params.iUid = aPkgUid; |
|
481 TPtrC8 ptr1 = aLuid->Des(); |
|
482 idx= ptr1.Find(KCol); |
|
483 if(idx != KErrNotFound) |
|
484 { |
|
485 TPtrC8 ptr = ptr1.Right((ptr1.Length()-idx)-1); |
|
486 TLex8 lex(ptr); |
|
487 lex.Val(params.iIndex); |
|
488 } |
|
489 else |
|
490 { |
|
491 ret = MSmlDmAdapter::ENotFound; |
|
492 } |
|
493 |
|
494 SwiUI::TOpUninstallIndexParamPckg pckg( params ); |
|
495 SwiUI::TOperation operation( SwiUI::EOperationUninstallIndex ); |
|
496 |
|
497 SwiUI::TUninstallOptions uninstallOptions; |
|
498 SwiUI::TUninstallOptionsPckg optPckg( uninstallOptions ); |
|
499 |
|
500 errCode = installer.SilentCustomUninstall( operation, optPckg, pckg,SwiUI::KSisxMimeType() ); |
|
501 RDEBUG_2("CThemesList::DeleteThemeL Uninstall silent : errCode %X",errCode ); |
|
502 |
|
503 CleanupStack::PopAndDestroy( &installer ); |
|
504 } |
|
505 |
|
506 if (errCode == KErrNotFound) |
|
507 { |
|
508 ret = MSmlDmAdapter::ENotFound; |
|
509 } |
|
510 else if (errCode != KErrNone) |
|
511 { |
|
512 ret = MSmlDmAdapter::EError; |
|
513 } |
|
514 |
|
515 return ret; |
|
516 } |
|
517 |
|
518 |
|
519 |
|
520 /////////////////////////////////////////////////////////////////////////////////////////////////// |
|
521 // |
|
522 // Internal methods |
|
523 // |
|
524 /////////////////////////////////////////////////////////////////////////////////////////////////// |
|
525 |
|
526 |
|
527 // ------------------------------------------------------------------------------------------------ |
|
528 // CThemesList::CheckUpdatesL() |
|
529 // ------------------------------------------------------------------------------------------------ |
|
530 void CThemesList::CheckUpdatesL() |
|
531 { |
|
532 if (iDirty) |
|
533 { |
|
534 LoadSkinsL(); |
|
535 iDirty = EFalse; |
|
536 } |
|
537 } |
|
538 |
|
539 // ------------------------------------------------------------------------------------------------ |
|
540 // CThemesList::LoadSkinsL() |
|
541 // ------------------------------------------------------------------------------------------------ |
|
542 void CThemesList::LoadSkinsL() |
|
543 { |
|
544 // Cleanup old list |
|
545 if (iSkins) |
|
546 { |
|
547 iSkins->ResetAndDestroy(); |
|
548 delete iSkins; |
|
549 iSkins = 0; |
|
550 } |
|
551 |
|
552 // Drives z and c case EAknsSrvPhone: |
|
553 // drive e case EAknsSrvMMC: |
|
554 // all drives case EAknsSrvAll: |
|
555 iSkins = iAknsSrv.EnumerateSkinPackagesL( EAknsSrvAll ); |
|
556 } |
|
557 |
|
558 // ------------------------------------------------------------------------------------------------ |
|
559 // CThemesList:: |
|
560 // ------------------------------------------------------------------------------------------------ |
|
561 CAknsSrvSkinInformationPkg* CThemesList::FindThemeL( const TDesC8& aPID ) |
|
562 { |
|
563 CheckUpdatesL(); |
|
564 |
|
565 CAknsSrvSkinInformationPkg* theme = 0; |
|
566 TInt i = 0; |
|
567 TAknsPkgID pid = KAknsNullPkgID; |
|
568 |
|
569 TAknsPkgIDBuf pidBuf; |
|
570 pidBuf.Copy( aPID ); |
|
571 |
|
572 TRAPD( err, pid.SetFromDesL( pidBuf ) ); |
|
573 |
|
574 if (err == KErrNone) |
|
575 { |
|
576 for (i = 0 ; i < iSkins->Count() ; i++) |
|
577 { |
|
578 if ((*iSkins)[i]->PID() == pid) |
|
579 { |
|
580 theme = (*iSkins)[i]; |
|
581 break; |
|
582 } |
|
583 } |
|
584 } |
|
585 |
|
586 return theme; |
|
587 } |
|
588 |
|
589 // ------------------------------------------------------------------------------------------------ |
|
590 // CThemesList::GetDefaultInstallOptions() |
|
591 // ------------------------------------------------------------------------------------------------ |
|
592 void CThemesList::GetDefaultInstallOptions( SwiUI::TInstallOptions &aOptions ) |
|
593 { |
|
594 SwiUI::TInstallOptions defaultOptions; |
|
595 |
|
596 // Return options |
|
597 aOptions = defaultOptions; |
|
598 } |
|
599 |
|
600 // ------------------------------------------------------------------------------------------------ |
|
601 // CThemesList:: |
|
602 // ------------------------------------------------------------------------------------------------ |
|
603 TAknSkinSrvSkinPackageLocation CThemesList::LocationFromPath( const TDesC& aPath ) |
|
604 { |
|
605 #ifndef RD_MULTIPLE_DRIVE |
|
606 TBuf<1> driveLetterBuf; |
|
607 driveLetterBuf.CopyUC( aPath.Left(1) ); |
|
608 if( driveLetterBuf.Compare( _L("E") ) == 0 ) |
|
609 { |
|
610 return EAknsSrvMMC; |
|
611 } |
|
612 return EAknsSrvPhone; |
|
613 #else |
|
614 RFs fs; |
|
615 User::LeaveIfError(fs.Connect()); |
|
616 CleanupClosePushL(fs); |
|
617 |
|
618 TInt drive = EDriveC; |
|
619 TUint driveStatus = 0; |
|
620 TInt err = RFs::CharToDrive( aPath[0], drive ); |
|
621 err = DriveInfo::GetDriveStatus( fs, drive, driveStatus ); |
|
622 CleanupStack::PopAndDestroy(); // fs |
|
623 if ( driveStatus & DriveInfo::EDriveExternallyMountable ) |
|
624 { |
|
625 RDEBUG("CThemesList::LocationFromPath(): from MMC"); |
|
626 return EAknsSrvMMC; |
|
627 } |
|
628 |
|
629 |
|
630 RDEBUG("CThemesList::LocationFromPath(): from Phone"); |
|
631 return EAknsSrvPhone; |
|
632 |
|
633 #endif //RD_MULTIPLE_DRIVE |
|
634 } |
|
635 |
|
636 // ------------------------------------------------------------------------------------------------ |
|
637 // CThemesList:: |
|
638 // ------------------------------------------------------------------------------------------------ |
|
639 CDesC8Array* CThemesList::InstalledPackagesL( ) |
|
640 { |
|
641 CDesC8ArrayFlat* packages = new (ELeave) CDesC8ArrayFlat( 32 ); |
|
642 CleanupStack::PushL( packages ); |
|
643 |
|
644 RArray< TUid > uids; |
|
645 CleanupClosePushL( uids ); |
|
646 |
|
647 RPointerArray< Swi::CSisRegistryPackage > pkgs; |
|
648 CleanupClosePushL( pkgs ); |
|
649 |
|
650 Swi::RSisRegistrySession reg; |
|
651 User::LeaveIfError( reg.Connect() ); |
|
652 CleanupClosePushL( reg ); |
|
653 |
|
654 reg.InstalledUidsL( uids ); |
|
655 reg.InstalledPackagesL( pkgs ); |
|
656 |
|
657 TInt i = 0; |
|
658 TInt count = uids.Count(); |
|
659 for (i = 0 ; i < count ; i++) |
|
660 { |
|
661 TBuf8<KMaxUidName> uidBuf8; |
|
662 uidBuf8.Copy( uids[i].Name() ); |
|
663 |
|
664 RDEBUG8_3( "uid[%d]=%S", i, &uidBuf8 ); |
|
665 } |
|
666 |
|
667 count = pkgs.Count(); |
|
668 for (i = 0 ; i < count ; i++) |
|
669 { |
|
670 TPtrC uidName = pkgs[i]->Uid().Name(); |
|
671 TPtrC name = pkgs[i]->Name(); |
|
672 TPtrC vendor = pkgs[i]->Vendor(); |
|
673 |
|
674 RDEBUG_5( "pkg[%d]: uid=%S, idx=%d, name=%S", i, |
|
675 &uidName, |
|
676 pkgs[i]->Index(), |
|
677 &name ); |
|
678 |
|
679 |
|
680 TBuf<KMaxUidName+20> uidBuf; |
|
681 uidBuf = pkgs[i]->Uid().Name(); |
|
682 uidBuf.Append( _L(":") ); |
|
683 uidBuf.AppendNum( pkgs[i]->Index() ); |
|
684 |
|
685 TBuf8<KMaxUidName+20> uidBuf8; |
|
686 uidBuf8.Copy( uidBuf ); |
|
687 |
|
688 packages->AppendL( uidBuf8 ); |
|
689 } |
|
690 |
|
691 CleanupStack::PopAndDestroy( ® ); |
|
692 |
|
693 pkgs.ResetAndDestroy(); |
|
694 CleanupStack::PopAndDestroy( &pkgs ); |
|
695 CleanupStack::PopAndDestroy( &uids ); |
|
696 |
|
697 CleanupStack::Pop( packages ); |
|
698 return packages; |
|
699 } |
|
700 |
|
701 |
|
702 // ------------------------------------------------------------------------------------------------ |
|
703 // CThemesList:: |
|
704 // ------------------------------------------------------------------------------------------------ |
|
705 CDesC8Array* CThemesList::InstalledThemesL( ) |
|
706 { |
|
707 LoadSkinsL(); |
|
708 |
|
709 CDesC8ArrayFlat* themes = new (ELeave) CDesC8ArrayFlat( 32 ); |
|
710 CleanupStack::PushL( themes ); |
|
711 |
|
712 TInt i = 0; |
|
713 TInt count = iSkins->Count(); |
|
714 |
|
715 for (i = 0 ; i < count ; i++) |
|
716 { |
|
717 TAknsPkgIDBuf pidBuf; |
|
718 TBuf8<KAknsPkgIDDesSize> pidBuf8; |
|
719 |
|
720 TAknsPkgID pid = (*iSkins)[i]->PID(); |
|
721 pid.CopyToDes( pidBuf ); |
|
722 pidBuf8.Copy( pidBuf ); |
|
723 |
|
724 themes->AppendL( pidBuf8 ); |
|
725 |
|
726 TPtrC directory = (*iSkins)[i]->Directory(); |
|
727 TPtrC iniFileDirectory = (*iSkins)[i]->IniFileDirectory(); |
|
728 TPtrC name = (*iSkins)[i]->Name(); |
|
729 TPtrC idleStateWallPaperImageFileName = (*iSkins)[i]->IdleStateWallPaperImageFileName(); |
|
730 TPtrC pinboarWallPaperImageFileName = (*iSkins)[i]->PinboarWallPaperImageFileName(); |
|
731 TInt idleStateWallPaperImageIndex = (*iSkins)[i]->IdleStateWallPaperImageIndex(); |
|
732 TInt pinboardWallPaperImageIndex = (*iSkins)[i]->PinboardWallPaperImageIndex(); |
|
733 TBool isDeletable = (*iSkins)[i]->IsDeletable(); |
|
734 TBool isCopyable = (*iSkins)[i]->IsCopyable(); |
|
735 TAknsPkgID colorSchemePID = (*iSkins)[i]->ColorSchemePID(); |
|
736 TBool hasIconset = (*iSkins)[i]->HasIconset(); |
|
737 TAknsSkinSrvSkinProtectionType protectionType = (*iSkins)[i]->ProtectionType(); |
|
738 TBool isCorrupted = (*iSkins)[i]->IsCorrupted(); |
|
739 TDesC& fullName = (*iSkins)[i]->FullName(); |
|
740 |
|
741 |
|
742 TAknsPkgIDBuf colorSchemeBuf; |
|
743 colorSchemePID.CopyToDes( colorSchemeBuf ); |
|
744 |
|
745 RDEBUG_4( "skin[%d]: pid=%S, name=%S", i, &pidBuf, &name ); |
|
746 RDEBUG_2( " directory=%S", &directory ); |
|
747 RDEBUG_2( " iniFileDirectory=%S", &iniFileDirectory ); |
|
748 RDEBUG_2( " name=%S", &name ); |
|
749 RDEBUG_2( " idleStateWallPaperImageFileName=%S", &idleStateWallPaperImageFileName ); |
|
750 RDEBUG_2( " pinboarWallPaperImageFileName=%S", &pinboarWallPaperImageFileName ); |
|
751 RDEBUG_2( " idleStateWallPaperImageIndex=%d", idleStateWallPaperImageIndex ); |
|
752 RDEBUG_2( " pinboardWallPaperImageIndex=%d", pinboardWallPaperImageIndex ); |
|
753 RDEBUG_2( " isDeletable=%d", isDeletable ); |
|
754 RDEBUG_2( " isCopyable=%d", isCopyable ); |
|
755 RDEBUG_2( " colorSchemePID=%S", &colorSchemeBuf ); |
|
756 RDEBUG_2( " hasIconset=%d", hasIconset ); |
|
757 RDEBUG_2( " protectionType=%d", protectionType ); |
|
758 RDEBUG_2( " isCorrupted=%d", isCorrupted ); |
|
759 RDEBUG_2( " fullName=%S", &fullName ); |
|
760 } |
|
761 |
|
762 themes->Sort(); |
|
763 |
|
764 CleanupStack::Pop( themes ); |
|
765 return themes; |
|
766 } |
|
767 |
|
768 // ------------------------------------------------------------------------------------------------ |
|
769 // CThemesList:: |
|
770 // ------------------------------------------------------------------------------------------------ |
|
771 CDesC8Array* CThemesList::FindNewItemsL( const CDesC8Array& aItemsOrg, const CDesC8Array& aItemsNew ) |
|
772 { |
|
773 CDesC8Array* result = new (ELeave) CDesC8ArrayFlat( 16 ); |
|
774 CleanupStack::PushL( result ); |
|
775 |
|
776 TInt i = 0; |
|
777 TInt count = aItemsNew.Count(); |
|
778 for (i = 0 ; i < count ; i++) |
|
779 { |
|
780 result->AppendL( aItemsNew[ i ] ); |
|
781 } |
|
782 |
|
783 result->Sort(); |
|
784 |
|
785 count = aItemsOrg.Count(); |
|
786 for (i = 0 ; i < count ; i++) |
|
787 { |
|
788 TInt idx = -1; |
|
789 if (result->FindIsq( aItemsOrg[ i ], idx, ECmpNormal ) == 0) |
|
790 { |
|
791 result->Delete( idx ); |
|
792 } |
|
793 } |
|
794 |
|
795 result->Compress( ); |
|
796 |
|
797 CleanupStack::Pop( result ); |
|
798 return result; |
|
799 } |
|
800 |
|
801 // ------------------------------------------------------------------------------------------------ |
|
802 // EOF |
|
803 // ------------------------------------------------------------------------------------------------ |