|
1 /* |
|
2 * Copyright (c) 2002-2007 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: Model class for Psln application. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // Psln specific. |
|
20 #include "PslnModel.h" |
|
21 #include "PslnDiskUtil.h" |
|
22 #include "PslnFeatures.h" |
|
23 #include "PslnSkinEntry.h" |
|
24 #include "PslnSkinStore.h" |
|
25 #include "PslnEcomListener.h" |
|
26 #include "PslnDebug.h" |
|
27 #include "PslnConst.h" |
|
28 |
|
29 // Wrapper for wallpaper utils. |
|
30 #include "pslnwallpaperutilsloader.h" |
|
31 #include "pslnbrowserlaunchloader.h" |
|
32 |
|
33 // Resources |
|
34 #include <psln.rsg> |
|
35 #include <pslnskinnames.rsg> |
|
36 |
|
37 // Generic |
|
38 #include <StringLoader.h> |
|
39 #include <data_caging_path_literals.hrh> |
|
40 #include <f32file.h> |
|
41 #include <hal.h> |
|
42 |
|
43 // UI libraries |
|
44 #include <AknsSkinUID.h> |
|
45 #include <AknsConstants.h> |
|
46 #include <eikenv.h> |
|
47 #include <AknQueryDialog.h> |
|
48 |
|
49 // Misc |
|
50 #include <bautils.h> |
|
51 #include <mmf/common/mmfcontrollerpluginresolver.h> // For CleanupResetAndDestroyPushL |
|
52 |
|
53 // Central Repository and Publish&Subscribe keys. |
|
54 #include <centralrepository.h> |
|
55 #include <e32property.h> |
|
56 #include "pslninternalcrkeys.h" |
|
57 #include <AknSkinsInternalCRKeys.h> // wallpaper, screen saver |
|
58 #include <ScreensaverInternalCRKeys.h> // KScreenSaverObject |
|
59 #include <ScreensaverInternalPSKeys.h> // KScreenSaverPreviewMode |
|
60 #include <cenrepnotifyhandler.h> |
|
61 |
|
62 // For enabling first component transition effect |
|
63 #include <gfxtranseffect/gfxtranseffect.h> |
|
64 #include <akntranseffect.h> |
|
65 #ifdef RD_MULTIPLE_DRIVE |
|
66 #include <driveinfo.h> |
|
67 #endif //RD_MULTIPLE_DRIVE |
|
68 |
|
69 |
|
70 // CONSTANTS |
|
71 // Path of skin files. |
|
72 _LIT( KPslnSkinNamesFile,"z:PslnSkinNames.rsc" ); |
|
73 // Preview mode activated. |
|
74 const TInt KPslnActivatePreviewMode = 1; |
|
75 |
|
76 // Default item index. |
|
77 const TInt KPslnDefaultItemIndex = 0; |
|
78 |
|
79 // Screen saver type: user defined text |
|
80 const TInt KPslnSsText = 0; |
|
81 // Screen saver type: date & time |
|
82 const TInt KPslnSsDate = 1; |
|
83 // Screen saver type: object |
|
84 const TInt KPslnSsObject = 3; |
|
85 // Screen saver type: none |
|
86 const TInt KPslnSsNone = 4; |
|
87 |
|
88 // Granularity of screen saver array. |
|
89 const TInt KPslnSsArrayGranularity = 5; |
|
90 // Length of drive number descriptor. |
|
91 const TInt KPslnDriveNumberLength = 2; |
|
92 // Free RAM required when activating transition effects. |
|
93 const TInt KPslnTransitionEffectRAMThreshold = 2000000; |
|
94 // Maximum of text length in text screensaver for APAC. |
|
95 // For western variant, value is taken directly from resources. |
|
96 const TInt KPslnSsTextDialogAPACMaxLength = 7; |
|
97 // Path to wallpaper utils. |
|
98 _LIT( KPslnWallpaperUtilsLoaderName, |
|
99 "\\system\\libs\\PslnWallpaperUtilsLoader.dll"); |
|
100 _LIT( KPslnBrowserLaunchLoaderName, |
|
101 "\\system\\libs\\PslnBrowserLaunchLoader.dll"); |
|
102 // Screen saver UID is stored like [ss_uid]. This is the end mark. |
|
103 _LIT( KPslnScreenSaverUidEndMark, "]" ); |
|
104 |
|
105 // CLASS DECLARATIONS |
|
106 |
|
107 class CPslnActivationGuard : public CBase |
|
108 { |
|
109 public: |
|
110 virtual ~CPslnActivationGuard() |
|
111 { |
|
112 PSLN_TRACE_DEBUG("CPslnActivationGuard::destructor"); |
|
113 iModel->SkinSrvSession().EnableSkinChangeNotify(); |
|
114 } |
|
115 |
|
116 static CPslnActivationGuard* NewL( CPslnModel* aModel ) |
|
117 { |
|
118 PSLN_TRACE_DEBUG("CPslnActivationGuard::NewL"); |
|
119 CPslnActivationGuard* self = new (ELeave) CPslnActivationGuard(); |
|
120 self->iModel = aModel; |
|
121 PSLN_TRACE_DEBUG("CPslnActivationGuard DisableSkinChangeNotify"); |
|
122 aModel->SkinSrvSession().DisableSkinChangeNotify(); |
|
123 return self; |
|
124 } |
|
125 |
|
126 private: |
|
127 CPslnModel* iModel; |
|
128 }; |
|
129 |
|
130 // TYPE DEFINITIONS |
|
131 // Wallpaper Utils entry. |
|
132 typedef TAny* (*NewWallpaperUtilsL)(); |
|
133 |
|
134 // Browser Launcher entry. |
|
135 typedef TAny* (*NewBrowserLauncherL)(); |
|
136 |
|
137 |
|
138 // ============================ MEMBER FUNCTIONS =============================== |
|
139 // ----------------------------------------------------------------------------- |
|
140 // Two-phased constructor. |
|
141 // ----------------------------------------------------------------------------- |
|
142 // |
|
143 EXPORT_C CPslnModel* CPslnModel::NewL( MAknsSkinChangeObserver* aObserver ) |
|
144 { |
|
145 PSLN_TRACE_DEBUG("CPslnModel::NewL"); |
|
146 CPslnModel* self = new(ELeave) CPslnModel; |
|
147 |
|
148 CleanupStack::PushL( self ); |
|
149 self->ConstructL( aObserver ); |
|
150 CleanupStack::Pop( self ); |
|
151 |
|
152 PSLN_TRACE_DEBUG("CPslnModel::NewL OK"); |
|
153 return self; |
|
154 } |
|
155 |
|
156 // ----------------------------------------------------------------------------- |
|
157 // Two-phased constructor. Simpler version for PslnFramework use. |
|
158 // Deprecated. |
|
159 // ----------------------------------------------------------------------------- |
|
160 // |
|
161 EXPORT_C CPslnModel* CPslnModel::NewL() |
|
162 { |
|
163 CPslnModel* self = new(ELeave) CPslnModel; |
|
164 return self; |
|
165 } |
|
166 |
|
167 // ----------------------------------------------------------------------------- |
|
168 // Destructor |
|
169 // ----------------------------------------------------------------------------- |
|
170 // |
|
171 EXPORT_C CPslnModel::~CPslnModel() |
|
172 { |
|
173 PSLN_TRACE_DEBUG("CPslnModel::destructor"); |
|
174 |
|
175 delete iSkinsRepository; |
|
176 delete iScreenSaverRepository; |
|
177 iSkinSrvSession.Close(); |
|
178 |
|
179 while( iSkinNames.Count() ) |
|
180 { |
|
181 delete iSkinNames[0].iListName; |
|
182 delete iSkinNames[0].iTitleName; |
|
183 iSkinNames.Remove(0); |
|
184 } |
|
185 iSkinNames.Close(); |
|
186 |
|
187 delete iScreensaverFilenameArr; |
|
188 delete iScreensaverNameArr; |
|
189 iScreensaverCapsArr.Reset(); |
|
190 |
|
191 delete iSkinStore; |
|
192 if( iVisibleSkinArr ) |
|
193 { |
|
194 iVisibleSkinArr->ResetAndDestroy(); |
|
195 delete iVisibleSkinArr; |
|
196 } |
|
197 delete iScreenSaverInfo; |
|
198 |
|
199 delete iWallpaperSetter; |
|
200 if( iInternalState.IsSet( EPslnModelStateWallpaperDllLoaded ) ) |
|
201 { |
|
202 iWallpaperDll.Close(); |
|
203 } |
|
204 |
|
205 delete iBrowserLauncher; |
|
206 if( iInternalState.IsSet( EPslnModelStateBrowserLaunchDllLoaded ) ) |
|
207 { |
|
208 iBrowserLaunchDll.Close(); |
|
209 } |
|
210 |
|
211 // If client is bad-behaving and has not cancelled listening, |
|
212 // cancel itself. |
|
213 if ( iScreenSaverListener ) |
|
214 { |
|
215 if ( iScreenSaverListener->IsActive() ) |
|
216 { |
|
217 iScreenSaverListener->Cancel(); |
|
218 } |
|
219 delete iScreenSaverListener; |
|
220 // NUllified here, just in case if client later decides to try and |
|
221 // destroy this. |
|
222 iScreenSaverListener = NULL; |
|
223 } |
|
224 |
|
225 if(iThemesAppCenRepNotifyHandler) |
|
226 { |
|
227 iThemesAppCenRepNotifyHandler->StopListening(); |
|
228 delete iThemesAppCenRepNotifyHandler; |
|
229 } |
|
230 delete iThemesAppRepository; |
|
231 } |
|
232 |
|
233 // ----------------------------------------------------------------------------- |
|
234 // Activate a Skin. |
|
235 // ----------------------------------------------------------------------------- |
|
236 // |
|
237 EXPORT_C TBool CPslnModel::ActivateSkinL( |
|
238 const TDesC8& /*aPreviewType*/, |
|
239 const TInt /*aActiveSkinIndex*/ ) |
|
240 { |
|
241 PSLN_TRACE_DEBUG("CPslnModel::ActivateSkinL -- depricated!!"); |
|
242 User::Leave( KErrNotSupported ); |
|
243 return EFalse; |
|
244 } |
|
245 |
|
246 // ----------------------------------------------------------------------------- |
|
247 // Activate a screen saver. |
|
248 // ----------------------------------------------------------------------------- |
|
249 // |
|
250 EXPORT_C TInt CPslnModel::ActivateScreenSaver( const TInt aItemIndex, |
|
251 TPslnScreenSaverActivation aActivationType ) |
|
252 { |
|
253 PSLN_TRACE_DEBUG("CPslnModel::ActivateScreenSaver"); |
|
254 TRAPD( err, ActivateScreenSaverL( aItemIndex, aActivationType ) ); |
|
255 PSLN_TRACE_DEBUG1("CPslnModel::ActivateScreenSaver %d", err ); |
|
256 return err; |
|
257 } |
|
258 |
|
259 // ----------------------------------------------------------------------------- |
|
260 // CPslnModel::GuardActivationLC |
|
261 // ----------------------------------------------------------------------------- |
|
262 // |
|
263 EXPORT_C void CPslnModel::GuardActivationLC() |
|
264 { |
|
265 PSLN_TRACE_DEBUG("CPslnModel::GuardActivationLC"); |
|
266 CleanupStack::PushL( CPslnActivationGuard::NewL( this ) ); |
|
267 } |
|
268 |
|
269 // ----------------------------------------------------------------------------- |
|
270 // Download a skin. |
|
271 // ----------------------------------------------------------------------------- |
|
272 // |
|
273 EXPORT_C void CPslnModel::DownloadSkinL() |
|
274 { |
|
275 PSLN_TRACE_DEBUG("CPslnModel::DownloadSkinL BEGIN"); |
|
276 PSLN_TRACE_DEBUG("CPslnModel::DownloadSkinL Load DLL"); |
|
277 LoadBrowserLaunchL(); |
|
278 if ( iBrowserLauncher ) |
|
279 { |
|
280 PSLN_TRACE_DEBUG("CPslnModel::DownloadSkinL Launch embedded browser"); |
|
281 TRAPD( error, |
|
282 iBrowserLauncher->LaunchBrowserStandaloneL( ) ); |
|
283 if ( error != KErrNone ) |
|
284 { |
|
285 PSLN_TRACE_DEBUG1("CPslnModel::DownloadSkinL Handle exit: %d", error ); |
|
286 } |
|
287 if ( error == KErrNoMemory ) |
|
288 { |
|
289 PSLN_TRACE_DEBUG("CPslnModel::DownloadSkinL OOM"); |
|
290 User::Leave( error ); |
|
291 } |
|
292 } |
|
293 PSLN_TRACE_DEBUG("CPslnModel::DownloadSkinL END"); |
|
294 } |
|
295 |
|
296 // ----------------------------------------------------------------------------- |
|
297 // Set Background image path name. |
|
298 // ----------------------------------------------------------------------------- |
|
299 // |
|
300 EXPORT_C TInt CPslnModel::SetBackgroundImagePath( const TDesC& aImagePath ) |
|
301 { |
|
302 PSLN_TRACE_DEBUG("CPslnModel::SetBackgroundImagePath"); |
|
303 |
|
304 TRAP_IGNORE( LoadWallpaperUtilsL() ); |
|
305 TInt retVal = KErrNone; |
|
306 if ( iWallpaperSetter ) |
|
307 { |
|
308 if( aImagePath.Length() > 0 ) |
|
309 { |
|
310 retVal = iWallpaperSetter->SetIdleWallpaper( |
|
311 aImagePath, |
|
312 CCoeEnv::Static(), |
|
313 R_PSLN_SKINS_LOADING_IMAGE, |
|
314 R_PSLN_GENERAL_WAIT_NOTE ); |
|
315 } |
|
316 else |
|
317 { |
|
318 retVal = iWallpaperSetter->SetIdleWallpaper( KNullDesC, NULL ); |
|
319 } |
|
320 } |
|
321 else |
|
322 { |
|
323 retVal = KErrNoMemory; |
|
324 } |
|
325 return retVal; |
|
326 } |
|
327 |
|
328 // --------------------------------------------------------------------------- |
|
329 // CPslnModel::InvokeSSPluginFunctionL |
|
330 // --------------------------------------------------------------------------- |
|
331 // |
|
332 EXPORT_C void CPslnModel::InvokeSSPluginFunctionL( |
|
333 TInt aIndex, |
|
334 TScPluginCaps aFunction ) |
|
335 { |
|
336 PSLN_TRACE_DEBUG("CPslnModel::InvokeSSPluginFunctionL"); |
|
337 if ( !iScreensaverFilenameArr || iScreensaverFilenameArr->Count() == 0 ) |
|
338 { |
|
339 User::Leave( KErrNotFound ); |
|
340 } |
|
341 |
|
342 if( aIndex >= iScreensaverFilenameArr->MdcaCount() ) |
|
343 { |
|
344 User::Leave( KErrArgument ); |
|
345 } |
|
346 |
|
347 if(aFunction == EScpCapsConfigure && |
|
348 aIndex == GetScreenSaverIndexByFileName(KPslnScreenSaverTypeText)) |
|
349 { |
|
350 TBool ret = QueryAndSetScreensaverTextL(); |
|
351 if ( !ret ) |
|
352 { |
|
353 User::Leave( KErrCancel ); |
|
354 } |
|
355 return; |
|
356 } |
|
357 |
|
358 // Convert the UID of the given screensaver plugin from text to integer |
|
359 // The string format of the UID: [12345678] |
|
360 // The number inside the brackets in hexadecimal format |
|
361 TLex lex( iScreensaverFilenameArr->MdcaPoint( aIndex ) ); |
|
362 // Skip the first character: '[' |
|
363 lex.Get(); |
|
364 TUint screenSaverPluginImpUid; |
|
365 // Get the UID |
|
366 TInt err = lex.Val( screenSaverPluginImpUid, EHex ); |
|
367 PSLN_TRACE_DEBUG1("CPslnModel::InvokeSSPluginFunctionL lexed: %d", err ); |
|
368 User::LeaveIfError( err ); |
|
369 |
|
370 CScreensaverPluginInterfaceDefinition* plugin = |
|
371 CScreensaverPluginInterfaceDefinition::NewL( |
|
372 TUid::Uid( screenSaverPluginImpUid ) ); |
|
373 CleanupStack::PushL( plugin ); |
|
374 |
|
375 err = plugin->PluginFunction( aFunction, iEikEnv ); |
|
376 PSLN_TRACE_DEBUG1("CPslnModel::InvokeSSPluginFunctionL call return: %d", err ); |
|
377 CleanupStack::PopAndDestroy( plugin ); |
|
378 |
|
379 if( err == KErrCancel && aIndex == CurrentPropertyIndexL( KPslnScreenSettingId ) ) |
|
380 { |
|
381 SetScreenSaverToDefault(); |
|
382 } |
|
383 |
|
384 User::LeaveIfError( err ); |
|
385 } |
|
386 |
|
387 // --------------------------------------------------------------------------- |
|
388 // CPslnModel::PerformCompleteUpdateL |
|
389 // --------------------------------------------------------------------------- |
|
390 // |
|
391 EXPORT_C void CPslnModel::PerformCompleteUpdateL() |
|
392 { |
|
393 PSLN_TRACE_DEBUG("CPslnModel::PerformCompleteUpdateL"); |
|
394 |
|
395 if ( iInternalState.IsClear( EPslnModelStateSkinNamesLoaded ) ) |
|
396 { |
|
397 LoadSkinNamesResourceL(); |
|
398 } |
|
399 UpdateFromServerL(); |
|
400 SetActiveSkinL(); |
|
401 |
|
402 PSLN_TRACE_DEBUG("CPslnModel::PerformCompleteUpdateL COMPLETED"); |
|
403 } |
|
404 |
|
405 // --------------------------------------------------------------------------- |
|
406 // CPslnModel::LoadScreensaverArrayL |
|
407 // --------------------------------------------------------------------------- |
|
408 // |
|
409 EXPORT_C void CPslnModel::LoadScreensaverArrayL() |
|
410 { |
|
411 PSLN_TRACE_DEBUG("CPslnModel::LoadScreensaverArrayL"); |
|
412 |
|
413 // Destroy old arrays, if any |
|
414 delete iScreensaverNameArr; |
|
415 iScreensaverNameArr = NULL; |
|
416 delete iScreensaverFilenameArr; |
|
417 iScreensaverFilenameArr = NULL; |
|
418 iScreensaverCapsArr.Reset(); |
|
419 |
|
420 // Load default items |
|
421 iScreensaverNameArr = iEikEnv->ReadDesC16ArrayResourceL( |
|
422 R_SCREEN_SAVER_SETTING_PAGE_LBX ); |
|
423 |
|
424 // Add descriptors for system screensavers |
|
425 iScreensaverFilenameArr = |
|
426 new (ELeave) CDesC16ArrayFlat( KPslnSsArrayGranularity ); |
|
427 iScreensaverFilenameArr->AppendL( KPslnScreenSaverTypeDateTime ); |
|
428 iScreensaverFilenameArr->AppendL( KPslnScreenSaverTypeText ); |
|
429 |
|
430 // System screensavers have no capabilities |
|
431 User::LeaveIfError( iScreensaverCapsArr.Append( EFalse ) ); |
|
432 User::LeaveIfError( iScreensaverCapsArr.Append( EScpCapsConfigure ) ); |
|
433 |
|
434 if ( IsSupportScreenSaverNoneOption() ) |
|
435 { |
|
436 iScreensaverFilenameArr->InsertL(0, KPslnScreenSaverTypeNone ); |
|
437 User::LeaveIfError( iScreensaverCapsArr.Insert( 0, EFalse ) ); |
|
438 } |
|
439 else |
|
440 { |
|
441 iScreensaverNameArr->Delete(0); |
|
442 } |
|
443 |
|
444 FindAndAppendScreensaversL(); |
|
445 } |
|
446 |
|
447 // --------------------------------------------------------------------------- |
|
448 // CPslnModel::VisibleSkin |
|
449 // --------------------------------------------------------------------------- |
|
450 // |
|
451 EXPORT_C CPslnSkinEntry* CPslnModel::VisibleSkin( const TInt aIndex ) |
|
452 { |
|
453 PSLN_TRACE_DEBUG("CPslnModel::VisibleSkin"); |
|
454 if ( !iSkinStore ) |
|
455 { |
|
456 TRAPD( err, iSkinStore = CPslnSkinStore::NewL( this ) ); |
|
457 if ( err != KErrNone ) |
|
458 { |
|
459 return NULL; |
|
460 } |
|
461 } |
|
462 CPslnSkinEntry* visibleSkin = NULL; |
|
463 if ( iVisibleSkinArr ) |
|
464 { |
|
465 if( ( aIndex >= 0 ) && ( aIndex < iVisibleSkinArr->Count() ) ) |
|
466 { |
|
467 CPslnSkinNameEntry* nameEntry = (*iVisibleSkinArr)[aIndex]; |
|
468 visibleSkin = iSkinStore->Find( |
|
469 nameEntry->PkgID(), nameEntry->Location() ); |
|
470 } |
|
471 } |
|
472 return visibleSkin; |
|
473 } |
|
474 |
|
475 // ----------------------------------------------------------------------------- |
|
476 // Get a skin's name by index. |
|
477 // ----------------------------------------------------------------------------- |
|
478 // |
|
479 EXPORT_C void CPslnModel::GetSkinNameByIndex( const TInt aIndex, TDes& aSkinName, |
|
480 const TPslnSkinNameType aType ) const |
|
481 { |
|
482 PSLN_TRACE_DEBUG("CPslnModel::GetSkinNameByIndex"); |
|
483 |
|
484 TAknsPkgID pid = KAknsNullPkgID; |
|
485 if ( iVisibleSkinArr ) |
|
486 { |
|
487 if( ( aIndex >= 0 ) && ( aIndex < iVisibleSkinArr->Count() ) ) |
|
488 { |
|
489 pid = (*iVisibleSkinArr)[aIndex]->PkgID(); |
|
490 } |
|
491 } |
|
492 |
|
493 GetSkinNameByPID( pid, aSkinName, aType ); |
|
494 } |
|
495 |
|
496 // ----------------------------------------------------------------------------- |
|
497 // Return if the selected skin is activated. |
|
498 // ----------------------------------------------------------------------------- |
|
499 // |
|
500 EXPORT_C TBool CPslnModel::IsActiveSkinSelected( TInt aSkinIndex ) const |
|
501 { |
|
502 PSLN_TRACE_DEBUG("CPslnModel::IsActiveOfSkinSelected"); |
|
503 |
|
504 TInt skinIndex = iCurrentSkinIndex; |
|
505 if ( aSkinIndex >= 0 ) |
|
506 { |
|
507 skinIndex = aSkinIndex; |
|
508 } |
|
509 return ( iActiveSkinIndex == skinIndex ); |
|
510 } |
|
511 |
|
512 // ----------------------------------------------------------------------------- |
|
513 // CPslnModel::LocationOfSkin |
|
514 // Deprecated. |
|
515 // ----------------------------------------------------------------------------- |
|
516 // |
|
517 EXPORT_C TAknSkinSrvSkinPackageLocation CPslnModel::LocationOfSkin( |
|
518 const TInt aIndex ) |
|
519 { |
|
520 PSLN_TRACE_DEBUG("CPslnModel::LocationOfSkin"); |
|
521 TAknSkinSrvSkinPackageLocation skinLocation = EAknsSrvPhone; |
|
522 CPslnSkinEntry* entry = VisibleSkin( aIndex ); |
|
523 if( entry ) |
|
524 { |
|
525 skinLocation = entry->Location(); |
|
526 } |
|
527 return skinLocation; |
|
528 } |
|
529 |
|
530 // ----------------------------------------------------------------------------- |
|
531 // Return the active skin index. |
|
532 // ----------------------------------------------------------------------------- |
|
533 // |
|
534 EXPORT_C TInt CPslnModel::ActiveSkinIndex () const |
|
535 { |
|
536 PSLN_TRACE_DEBUG("CPslnModel::ActiveSkinIndex"); |
|
537 return iActiveSkinIndex; |
|
538 } |
|
539 |
|
540 // ----------------------------------------------------------------------------- |
|
541 // Return the skin index of the selection currently active. |
|
542 // ----------------------------------------------------------------------------- |
|
543 // |
|
544 EXPORT_C TInt CPslnModel::CurrentSelectedSkinIndex () const |
|
545 { |
|
546 PSLN_TRACE_DEBUG("CPslnModel::CurrentSelectedSkinIndex"); |
|
547 return iCurrentSkinIndex; |
|
548 } |
|
549 |
|
550 // ----------------------------------------------------------------------------- |
|
551 // Get number of skins. |
|
552 // ----------------------------------------------------------------------------- |
|
553 // |
|
554 EXPORT_C TInt CPslnModel::NumberOfSkins() const |
|
555 { |
|
556 PSLN_TRACE_DEBUG("CPslnModel::NumberOfSkins"); |
|
557 TInt numberOfSkins = 0; |
|
558 if ( iVisibleSkinArr ) |
|
559 { |
|
560 numberOfSkins = iVisibleSkinArr->Count(); |
|
561 } |
|
562 return numberOfSkins; |
|
563 } |
|
564 |
|
565 // --------------------------------------------------------------------------- |
|
566 // CPslnModel::ScreensaverNames |
|
567 // --------------------------------------------------------------------------- |
|
568 // |
|
569 EXPORT_C const MDesC16Array& CPslnModel::ScreensaverNames() const |
|
570 { |
|
571 PSLN_TRACE_DEBUG("CPslnModel::ScreensaverNames"); |
|
572 return *iScreensaverNameArr; |
|
573 } |
|
574 |
|
575 // --------------------------------------------------------------------------- |
|
576 // CPslnModel::ScreensaverHasCapability |
|
577 // --------------------------------------------------------------------------- |
|
578 // |
|
579 EXPORT_C TBool CPslnModel::ScreensaverHasCapability( |
|
580 const TInt aIndex, |
|
581 const TScPluginCaps aCapability ) const |
|
582 { |
|
583 PSLN_TRACE_DEBUG("CPslnModel::ScreensaverHasCapability"); |
|
584 if( ( aIndex < 0 ) || ( aIndex >= iScreensaverCapsArr.Count() ) ) |
|
585 { |
|
586 return EFalse; |
|
587 } |
|
588 |
|
589 return ( iScreensaverCapsArr[ aIndex ] & aCapability ); |
|
590 } |
|
591 |
|
592 // ----------------------------------------------------------------------------- |
|
593 // CPslnModel::ProtectionOfSkin |
|
594 // ----------------------------------------------------------------------------- |
|
595 // |
|
596 EXPORT_C TAknsSkinSrvSkinProtectionType CPslnModel::ProtectionOfSkin( |
|
597 const TInt aIndex ) |
|
598 { |
|
599 PSLN_TRACE_DEBUG("CPslnModel::ProtectionOfSkin"); |
|
600 TAknsSkinSrvSkinProtectionType skinProtectionType = EAknsSrvNoProtection; |
|
601 CPslnSkinEntry* entry = VisibleSkin( aIndex ); |
|
602 if( entry ) |
|
603 { |
|
604 skinProtectionType = entry->Protection(); |
|
605 } |
|
606 return skinProtectionType; |
|
607 } |
|
608 |
|
609 // ----------------------------------------------------------------------------- |
|
610 // CPslnModel::IsValidForActivation |
|
611 // ----------------------------------------------------------------------------- |
|
612 // |
|
613 EXPORT_C TBool CPslnModel::IsValidForActivation( const TInt aItemIndex ) |
|
614 { |
|
615 PSLN_TRACE_DEBUG("CPslnModel::IsValidForActivation"); |
|
616 CPslnSkinEntry* skinEntry = VisibleSkin( aItemIndex ); |
|
617 return ( skinEntry && !skinEntry->IsCorrupted() ); |
|
618 } |
|
619 |
|
620 // ----------------------------------------------------------------------------- |
|
621 // CPslnModel::IsValidForPreview |
|
622 // ----------------------------------------------------------------------------- |
|
623 // |
|
624 EXPORT_C TBool CPslnModel::IsValidForPreview( const TInt aItemIndex ) |
|
625 { |
|
626 PSLN_TRACE_DEBUG("CPslnModel::IsValidForPreview"); |
|
627 CPslnSkinEntry* skinEntry = VisibleSkin( aItemIndex ); |
|
628 if( !skinEntry ) |
|
629 { |
|
630 return EFalse; |
|
631 } |
|
632 |
|
633 if( skinEntry->IsCorrupted() ) |
|
634 { |
|
635 return EFalse; |
|
636 } |
|
637 TInt type = skinEntry->Protection(); |
|
638 if( type != EAknsSrvNoProtection && type != EAknsSrvProtected ) |
|
639 { |
|
640 return EFalse; |
|
641 } |
|
642 |
|
643 TBool skinFileExist = SkinFileExist( aItemIndex ); |
|
644 if( !skinFileExist ) |
|
645 { |
|
646 return EFalse; |
|
647 } |
|
648 |
|
649 return ETrue; |
|
650 } |
|
651 |
|
652 // ----------------------------------------------------------------------------- |
|
653 // Checks if the skin support animated background. |
|
654 // ----------------------------------------------------------------------------- |
|
655 // |
|
656 EXPORT_C TBool CPslnModel::IsSupportAnimBg( TInt aItemIndex ) |
|
657 { |
|
658 CPslnSkinEntry* skinEntry = VisibleSkin( aItemIndex ); |
|
659 return skinEntry && skinEntry->IsSupportAnimBg(); |
|
660 } |
|
661 |
|
662 // ----------------------------------------------------------------------------- |
|
663 // Set current selected skin index. |
|
664 // ----------------------------------------------------------------------------- |
|
665 // |
|
666 EXPORT_C void CPslnModel::SetCurrentSelectedSkinIndex( |
|
667 const TInt aCurrentSkinIndex ) |
|
668 { |
|
669 PSLN_TRACE_DEBUG1("CPslnModel::SetCurrentSelectedSkinIndex:%d", aCurrentSkinIndex ); |
|
670 if ( aCurrentSkinIndex >= 0 ) |
|
671 { |
|
672 iCurrentSkinIndex = aCurrentSkinIndex; |
|
673 } |
|
674 // If given index is negative, assume that first skin is selected. |
|
675 else |
|
676 { |
|
677 iCurrentSkinIndex = 0; |
|
678 } |
|
679 } |
|
680 |
|
681 // ----------------------------------------------------------------------------- |
|
682 // CPslnModel::SetCurrentPropertyType |
|
683 // ----------------------------------------------------------------------------- |
|
684 // |
|
685 EXPORT_C TInt CPslnModel::SetCurrentPropertyType( |
|
686 const TInt /*aProperty*/, const TInt /*aCurItemIndex*/ ) |
|
687 { |
|
688 // deprecated. |
|
689 return KErrNotSupported; |
|
690 } |
|
691 |
|
692 // ----------------------------------------------------------------------------- |
|
693 // Get a Skin's Properties Type index. |
|
694 // ----------------------------------------------------------------------------- |
|
695 // |
|
696 EXPORT_C TInt CPslnModel::CurrentPropertyIndex( const TInt aProperty ) |
|
697 { |
|
698 PSLN_TRACE_DEBUG1("CPslnModel::CurrentPropertyIndex:%d", aProperty ); |
|
699 TInt currentIndex = KErrNotFound; |
|
700 TRAP_IGNORE( currentIndex = CurrentPropertyIndexL( aProperty ) ); |
|
701 PSLN_TRACE_DEBUG1("CPslnModel::CurrentPropertyIndex return:%d", currentIndex ); |
|
702 return currentIndex; |
|
703 } |
|
704 |
|
705 // ----------------------------------------------------------------------------- |
|
706 // Starts to listen for ECOM screensaver changes. |
|
707 // ----------------------------------------------------------------------------- |
|
708 // |
|
709 EXPORT_C void CPslnModel::EnableScreenSaverNotifications( |
|
710 const TBool& aActive, MPslnScreenSaverECOMObserver& aObserver ) |
|
711 { |
|
712 PSLN_TRACE_DEBUG("CPslnModel::EnableScreenSaverNotifications" ); |
|
713 if ( aActive ) |
|
714 { |
|
715 // Create listening class (active object) |
|
716 TRAP_IGNORE( |
|
717 iScreenSaverListener = CPslnEcomListener::NewL( *this, aObserver ) ); |
|
718 } |
|
719 else |
|
720 { |
|
721 // Check if model has already destroyed this. |
|
722 if ( iScreenSaverListener ) |
|
723 { |
|
724 if ( iScreenSaverListener->IsActive() ) |
|
725 { |
|
726 iScreenSaverListener->Cancel(); |
|
727 } |
|
728 delete iScreenSaverListener; |
|
729 iScreenSaverListener = NULL; |
|
730 } |
|
731 } |
|
732 } |
|
733 |
|
734 // ----------------------------------------------------------------------------- |
|
735 // Activates skin. This overloaded version knows in which state the activation |
|
736 // is requested. |
|
737 // ----------------------------------------------------------------------------- |
|
738 // |
|
739 EXPORT_C TBool CPslnModel::ActivateSkinL( |
|
740 const TDesC8& /*aPreviewType*/, |
|
741 const TInt /*aActiveSkinIndex*/, |
|
742 const TBool& /*aActivateFromPreview*/ ) |
|
743 { |
|
744 PSLN_TRACE_DEBUG("CPslnModel::ActivateSkinL -- depricated!!"); |
|
745 User::Leave( KErrNotSupported ); |
|
746 return EFalse; |
|
747 } |
|
748 |
|
749 // ----------------------------------------------------------------------------- |
|
750 // Activates skin. |
|
751 // ----------------------------------------------------------------------------- |
|
752 // |
|
753 EXPORT_C TBool CPslnModel::ActivateSkinL( |
|
754 const TInt aActiveSkinIndex ) |
|
755 { |
|
756 PSLN_TRACE_DEBUG("CPslnModel::ActivateSkinL"); |
|
757 |
|
758 TInt indexToActivate = aActiveSkinIndex; |
|
759 if( aActiveSkinIndex == KErrNotFound ) |
|
760 { |
|
761 indexToActivate = iActiveSkinIndex; |
|
762 } |
|
763 PSLN_TRACE_DEBUG1("CPslnModel::ActivateSkinL activate skin index=%d", indexToActivate ); |
|
764 // Get skin's full name. |
|
765 HBufC* fullName = HBufC::NewLC( KMaxFileName ); |
|
766 TPtr fullNamePtr = fullName->Des(); |
|
767 fullNamePtr = GetSkinFullName( indexToActivate ); |
|
768 |
|
769 if ( !PslnDiskUtil::QueryAndSetAutomatedL( iSkinSrvSession, fullNamePtr ) ) |
|
770 { |
|
771 CleanupStack::PopAndDestroy( fullName ); |
|
772 PSLN_TRACE_DEBUG("CPslnModel::ActivateSkinL set autom. not ok"); |
|
773 return EFalse; |
|
774 } |
|
775 CleanupStack::PopAndDestroy( fullName ); |
|
776 |
|
777 // Find out the skin package ID |
|
778 CPslnSkinEntry* activeEntry = VisibleSkin( indexToActivate ); |
|
779 if ( !activeEntry ) |
|
780 { |
|
781 PSLN_TRACE_DEBUG("CPslnModel::ActivateSkinL NULL entry"); |
|
782 User::Leave( KErrGeneral ); |
|
783 } |
|
784 |
|
785 if ( !activeEntry->IsSupportAnimBg() ) |
|
786 { |
|
787 //Stop animated background |
|
788 SetAnimBackground( EPslnDisableAllEffects ); |
|
789 } |
|
790 TAknsPkgID activeSkinPid = activeEntry->PkgID(); |
|
791 // Activate whole skin |
|
792 PSLN_TRACE_DEBUG("CPslnModel::ActivateSkinL set all definition sets"); |
|
793 TInt error = iSkinSrvSession.SetAllDefinitionSets( activeSkinPid ); |
|
794 |
|
795 // For enabling first component transition effect |
|
796 GfxTransEffect::Enable(); |
|
797 |
|
798 if ( error != KErrNone ) |
|
799 { |
|
800 PSLN_TRACE_DEBUG1("CPslnModel::ActivateSkinL error when setting definition sets: %d", error ); |
|
801 User::LeaveIfError( error ); |
|
802 } |
|
803 |
|
804 // Otherwise, save to shareddata |
|
805 TAknsPkgIDBuf pidBuf; |
|
806 activeSkinPid.CopyToDes( pidBuf ); |
|
807 |
|
808 iSkinsRepository->Set( |
|
809 KPslnActiveSkinUid, |
|
810 pidBuf ); |
|
811 iSkinsRepository->Set( |
|
812 KPslnActiveSkinLocation, |
|
813 activeEntry->Location() ); |
|
814 |
|
815 iActiveSkinIndex = indexToActivate; |
|
816 return ETrue; |
|
817 } |
|
818 |
|
819 // ----------------------------------------------------------------------------- |
|
820 // Leaving version of CurrentPropertyIndex. |
|
821 // ----------------------------------------------------------------------------- |
|
822 // |
|
823 EXPORT_C TInt CPslnModel::CurrentPropertyIndexL( const TInt aProperty ) |
|
824 { |
|
825 PSLN_TRACE_DEBUG1("CPslnModel::CurrentPropertyIndex prop=%d", aProperty ); |
|
826 |
|
827 TInt itemIndex = KErrNotFound; |
|
828 |
|
829 switch( aProperty ) |
|
830 { |
|
831 case KPslnBgIdleSettingId: |
|
832 { |
|
833 itemIndex = GetWallPaperItemIndex(); |
|
834 break; |
|
835 } |
|
836 case KPslnScreenSettingId: |
|
837 { |
|
838 itemIndex = GetScreenSaverItemIndexL(); |
|
839 break; |
|
840 } |
|
841 default: |
|
842 break; |
|
843 } |
|
844 return itemIndex; |
|
845 } |
|
846 |
|
847 // ----------------------------------------------------------------------------- |
|
848 // Sets transition effects. |
|
849 // ----------------------------------------------------------------------------- |
|
850 // |
|
851 EXPORT_C TInt CPslnModel::SetTransitionEffectsL( const TInt aEffectValue ) |
|
852 { |
|
853 PSLN_TRACE_DEBUG("CPslnModel::SetTransitionEffectsL"); |
|
854 TInt retVal = KErrNone; |
|
855 |
|
856 // For the first time only, read default enable mask. |
|
857 if ( iInternalState.IsClear( EPslnModelStateTransitionEnableCRKeyRead ) ) |
|
858 { |
|
859 // Initialize to enable all. |
|
860 iEffectsDefaultEnableMask = EPslnEnableAllEffects; |
|
861 |
|
862 retVal = iThemesAppRepository->Get( |
|
863 KThemesDefaultTransitionEffects, |
|
864 iEffectsDefaultEnableMask ); |
|
865 if ( retVal == KErrNone ) |
|
866 { |
|
867 iInternalState.Set( EPslnModelStateTransitionEnableCRKeyRead ); |
|
868 } |
|
869 } |
|
870 |
|
871 // Only accept default mask, zero or max value. |
|
872 if ( aEffectValue != iEffectsDefaultEnableMask && |
|
873 aEffectValue != EPslnEnableAllEffects && |
|
874 aEffectValue != EPslnDisableAllEffects ) |
|
875 { |
|
876 retVal = KErrArgument; |
|
877 } |
|
878 else |
|
879 { |
|
880 if ( aEffectValue == EPslnEnableAllEffects || |
|
881 aEffectValue == iEffectsDefaultEnableMask ) |
|
882 { |
|
883 TInt freeRAM = 0; |
|
884 HAL::Get( HALData::EMemoryRAMFree, freeRAM ); |
|
885 if ( freeRAM < KPslnTransitionEffectRAMThreshold ) |
|
886 { |
|
887 return KErrNoMemory; |
|
888 } |
|
889 } |
|
890 |
|
891 // Use mask, if activating effects. |
|
892 TInt effectValue = aEffectValue; |
|
893 if ( aEffectValue != EPslnDisableAllEffects ) |
|
894 { |
|
895 effectValue = iEffectsDefaultEnableMask; |
|
896 } |
|
897 |
|
898 iThemesAppRepository->Set( |
|
899 KThemesTransitionEffects, |
|
900 effectValue ); |
|
901 } |
|
902 |
|
903 // Need to have TFXSrv running before calling enable |
|
904 const TInt KWaitForTFXServerStart( 100000 ); |
|
905 User::After( KWaitForTFXServerStart ); |
|
906 // For enabling first component transition effect |
|
907 GfxTransEffect::Enable(); |
|
908 |
|
909 PSLN_TRACE_DEBUG1("CPslnModel::SetTransitionEffectsL %d", retVal ); |
|
910 return retVal; |
|
911 } |
|
912 |
|
913 // ----------------------------------------------------------------------------- |
|
914 // Gets current value of transition effects. |
|
915 // ----------------------------------------------------------------------------- |
|
916 // |
|
917 EXPORT_C TInt CPslnModel::GetTransitionEffectStateL() |
|
918 { |
|
919 if( PslnFeatures::IsSupported( KPslnSupportFastPreviewTheme ) ) |
|
920 { |
|
921 return iTransitionEffectValue; |
|
922 } |
|
923 |
|
924 |
|
925 PSLN_TRACE_DEBUG("CPslnModel::GetTransitionEffectStateL"); |
|
926 TInt effectsValue = KErrNone; |
|
927 |
|
928 TInt error = iThemesAppRepository->Get( KThemesTransitionEffects, effectsValue ); |
|
929 if ( error != KErrNone || effectsValue < 0 ) |
|
930 { |
|
931 PSLN_TRACE_DEBUG2("CPslnModel::GetTransitionEffectStateL Error: %d %d", error, effectsValue ); |
|
932 effectsValue = KErrNotFound; |
|
933 } |
|
934 |
|
935 PSLN_TRACE_DEBUG1("CPslnModel::GetTransitionEffectStateL return %d", effectsValue ); |
|
936 return effectsValue; |
|
937 } |
|
938 |
|
939 // ----------------------------------------------------------------------------- |
|
940 // Get Animated Background state |
|
941 // ----------------------------------------------------------------------------- |
|
942 // |
|
943 EXPORT_C TInt CPslnModel::AnimBackgroundState() const |
|
944 { |
|
945 TInt value = KErrNone; |
|
946 TInt error = iThemesAppRepository->Get( KThemesAnimBackgroundSupport, value ); |
|
947 if ( error != KErrNone || value < 0 ) |
|
948 { |
|
949 value = KMaxTInt; |
|
950 } |
|
951 |
|
952 return value; |
|
953 } |
|
954 |
|
955 // ----------------------------------------------------------------------------- |
|
956 // Set Animated Background state |
|
957 // ----------------------------------------------------------------------------- |
|
958 // |
|
959 EXPORT_C TInt CPslnModel::SetAnimBackground( TInt aValue ) |
|
960 { |
|
961 ASSERT( aValue == EPslnEnableAllEffects || |
|
962 aValue == EPslnDisableAllEffects ); |
|
963 |
|
964 TInt retVal = KErrNone; |
|
965 if ( aValue == EPslnEnableAllEffects ) |
|
966 { |
|
967 TInt freeRAM = 0; |
|
968 HAL::Get( HALData::EMemoryRAMFree, freeRAM ); |
|
969 if ( freeRAM < KPslnTransitionEffectRAMThreshold ) |
|
970 { |
|
971 return KErrNoMemory; |
|
972 } |
|
973 } |
|
974 iThemesAppRepository->Set( KThemesAnimBackgroundSupport, aValue ); |
|
975 |
|
976 return retVal; |
|
977 } |
|
978 |
|
979 // ----------------------------------------------------------------------------- |
|
980 // Checks if screensaver is on memory card. |
|
981 // ----------------------------------------------------------------------------- |
|
982 // |
|
983 EXPORT_C TBool CPslnModel::IsScreenSaverOnMemoryCard( const TInt aIndex ) const |
|
984 { |
|
985 if ( !iScreensaverFilenameArr || iScreensaverFilenameArr->Count() == 0 ) |
|
986 { |
|
987 return EFalse; |
|
988 } |
|
989 |
|
990 TLex lex( iScreensaverFilenameArr->MdcaPoint( aIndex ) ); |
|
991 // Skip the first character: '[' |
|
992 lex.Get(); |
|
993 TUint screenSaverPluginImpUid; |
|
994 TInt currentDrive = EDriveC; |
|
995 // Get the UID |
|
996 lex.Val( screenSaverPluginImpUid, EHex ); |
|
997 // Skip character: ']' |
|
998 lex.Get(); |
|
999 // Get the drive |
|
1000 if ( !lex.Eos() ) |
|
1001 { |
|
1002 // Find out which drive the plugin is on |
|
1003 if ( lex.Val( currentDrive ) != KErrNone ) |
|
1004 { |
|
1005 return EFalse; |
|
1006 } |
|
1007 } |
|
1008 #ifndef RD_MULTIPLE_DRIVE |
|
1009 if ( currentDrive == EDriveE ) |
|
1010 { |
|
1011 return ETrue; |
|
1012 } |
|
1013 return EFalse; |
|
1014 #else |
|
1015 RFs& fs = iEikEnv->FsSession(); |
|
1016 |
|
1017 TUint driveStatus = 0; |
|
1018 TBool retVal = EFalse; |
|
1019 TInt err = DriveInfo::GetDriveStatus( fs, currentDrive, driveStatus ); |
|
1020 if ( driveStatus & DriveInfo::EDriveExternallyMountable && |
|
1021 driveStatus & DriveInfo::EDriveRemovable ) |
|
1022 { |
|
1023 retVal = ETrue; |
|
1024 } |
|
1025 return retVal; |
|
1026 #endif // RD_MULTIPLE_DRIVE |
|
1027 } |
|
1028 |
|
1029 // ----------------------------------------------------------------------------- |
|
1030 // Sets currently active content (screensaver/wallpaper) index. |
|
1031 // ----------------------------------------------------------------------------- |
|
1032 // |
|
1033 EXPORT_C void CPslnModel::SetCurrentPropertyTypeL( |
|
1034 const TInt aProperty, const TInt aCurItemIndex ) |
|
1035 { |
|
1036 PSLN_TRACE_DEBUG2("CPslnModel::SetCurrentPropertyTypeL prop=%d index=%d", |
|
1037 aProperty, aCurItemIndex ); |
|
1038 |
|
1039 if( aCurItemIndex < KPslnDefaultItemIndex ) |
|
1040 { |
|
1041 User::Leave( KErrArgument ); |
|
1042 } |
|
1043 |
|
1044 TInt retVal = KErrNone; |
|
1045 switch( aProperty ) |
|
1046 { |
|
1047 case KPslnBgIdleSettingId: |
|
1048 retVal = iSkinsRepository->Set( KPslnWallpaperType, aCurItemIndex ); |
|
1049 break; |
|
1050 case KPslnScreenSettingId: |
|
1051 { |
|
1052 TInt screensaverType = GetScreensaverTypeByIndex(aCurItemIndex); |
|
1053 if ( screensaverType == KPslnSsText ) |
|
1054 { |
|
1055 // Query text if necessary |
|
1056 TBool ret = QueryAndSetScreensaverTextL(); |
|
1057 if ( !ret ) |
|
1058 { |
|
1059 User::Leave( KErrCancel ); |
|
1060 } |
|
1061 } |
|
1062 |
|
1063 if ( screensaverType == KPslnSsObject ) |
|
1064 { |
|
1065 retVal = iScreenSaverRepository->Set( |
|
1066 KScreenSaverPluginName, |
|
1067 iScreensaverFilenameArr->MdcaPoint( aCurItemIndex ) ); |
|
1068 } |
|
1069 else |
|
1070 { |
|
1071 retVal = iScreenSaverRepository->Set( |
|
1072 KScreenSaverPluginName, |
|
1073 KNullDesC ); |
|
1074 } |
|
1075 |
|
1076 retVal = iScreenSaverRepository->Set( |
|
1077 KScreenSaverObject, |
|
1078 screensaverType ); |
|
1079 |
|
1080 break; |
|
1081 } |
|
1082 default: |
|
1083 break; |
|
1084 } |
|
1085 User::LeaveIfError( retVal ); |
|
1086 } |
|
1087 |
|
1088 // ----------------------------------------------------------------------------- |
|
1089 // Checks if the theme is on memory card. |
|
1090 // ----------------------------------------------------------------------------- |
|
1091 // |
|
1092 EXPORT_C TBool CPslnModel::IsThemeOnMemoryCard( const TInt& aIndex ) |
|
1093 { |
|
1094 #ifndef RD_MULTIPLE_DRIVE |
|
1095 return EFalse; |
|
1096 #else |
|
1097 PSLN_TRACE_DEBUG("CPslnModel::IsThemeOnMemoryCard"); |
|
1098 TBool isThemeOnMemoryCard = EFalse; |
|
1099 CPslnSkinEntry* entry = VisibleSkin( aIndex ); |
|
1100 if( entry ) |
|
1101 { |
|
1102 isThemeOnMemoryCard = entry->IsOnMemoryCard(); |
|
1103 } |
|
1104 return isThemeOnMemoryCard; |
|
1105 #endif //RD_MULTIPLE_DRIVE |
|
1106 } |
|
1107 |
|
1108 // ----------------------------------------------------------------------------- |
|
1109 // Checks if the theme is on mass memory. |
|
1110 // ----------------------------------------------------------------------------- |
|
1111 // |
|
1112 EXPORT_C TBool CPslnModel::IsThemeOnMassDrive( const TInt& aIndex ) |
|
1113 { |
|
1114 #ifndef RD_MULTIPLE_DRIVE |
|
1115 return EFalse; |
|
1116 #else |
|
1117 PSLN_TRACE_DEBUG("CPslnModel::IsThemeOnMassDrive"); |
|
1118 TBool isThemeOnMemoryCard = EFalse; |
|
1119 CPslnSkinEntry* entry = VisibleSkin( aIndex ); |
|
1120 if( entry ) |
|
1121 { |
|
1122 isThemeOnMemoryCard = entry->IsOnMassDrive(); |
|
1123 } |
|
1124 return isThemeOnMemoryCard; |
|
1125 #endif //RD_MULTIPLE_DRIVE |
|
1126 } |
|
1127 |
|
1128 // ----------------------------------------------------------------------------- |
|
1129 // Checks if the screensaver is on mass memory. |
|
1130 // ----------------------------------------------------------------------------- |
|
1131 // |
|
1132 EXPORT_C TBool CPslnModel::IsScreenSaverOnMassDrive( const TInt& aIndex ) const |
|
1133 { |
|
1134 #ifndef RD_MULTIPLE_DRIVE |
|
1135 return EFalse; |
|
1136 #else |
|
1137 |
|
1138 if ( !iScreensaverFilenameArr || iScreensaverFilenameArr->Count() == 0 ) |
|
1139 { |
|
1140 return EFalse; |
|
1141 } |
|
1142 |
|
1143 TLex lex( iScreensaverFilenameArr->MdcaPoint( aIndex ) ); |
|
1144 // Skip the first character: '[' |
|
1145 lex.Get(); |
|
1146 TUint screenSaverPluginImpUid; |
|
1147 TInt currentDrive = EDriveC; |
|
1148 // Get the UID |
|
1149 lex.Val( screenSaverPluginImpUid, EHex ); |
|
1150 // Skip character: ']' |
|
1151 lex.Get(); |
|
1152 // Get the drive |
|
1153 if ( !lex.Eos() ) |
|
1154 { |
|
1155 // Find out which drive the plugin is on |
|
1156 if ( lex.Val( currentDrive ) != KErrNone ) |
|
1157 { |
|
1158 return EFalse; |
|
1159 } |
|
1160 } |
|
1161 |
|
1162 RFs& fs = iEikEnv->FsSession(); |
|
1163 |
|
1164 TUint driveStatus = 0; |
|
1165 TBool retVal = EFalse; |
|
1166 TInt err = DriveInfo::GetDriveStatus( fs, currentDrive, driveStatus ); |
|
1167 |
|
1168 // It is mass memory, if it is externally mountable, but not removable. |
|
1169 if ( driveStatus & DriveInfo::EDriveExternallyMountable && |
|
1170 !( driveStatus & DriveInfo::EDriveRemovable ) ) |
|
1171 { |
|
1172 retVal = ETrue; |
|
1173 } |
|
1174 return retVal; |
|
1175 #endif // RD_MULTIPLE_DRIVE |
|
1176 } |
|
1177 |
|
1178 // ----------------------------------------------------------------------------- |
|
1179 // Shares skin server session. |
|
1180 // ----------------------------------------------------------------------------- |
|
1181 // |
|
1182 EXPORT_C RAknsSrvSession CPslnModel::SkinSrvSession() const |
|
1183 { |
|
1184 return iSkinSrvSession; |
|
1185 } |
|
1186 |
|
1187 // ----------------------------------------------------------------------------- |
|
1188 // Starts or stops transition effects. |
|
1189 // ----------------------------------------------------------------------------- |
|
1190 // |
|
1191 EXPORT_C void CPslnModel::TransEffect(TInt aAction) const |
|
1192 { |
|
1193 __ASSERT_DEBUG( EPslnTransitionEffectDummyFirst < aAction && |
|
1194 aAction < EPslnTransitionEffectDummyLast, |
|
1195 User::Panic(_L("Invalid action for CPslnModel::TransEffect"), 1) ); |
|
1196 |
|
1197 switch (aAction) |
|
1198 { |
|
1199 case EPslnTransitionEffectStartPreview: |
|
1200 GfxTransEffect::BeginFullScreen( /*AknTransEffect::EApplicationExit*/1500, TRect(), |
|
1201 AknTransEffect::EParameterType, |
|
1202 AknTransEffect::GfxTransParam( KUidPsln ) ); |
|
1203 break; |
|
1204 case EPslnTransitionEffectStartThemeActivation: |
|
1205 GfxTransEffect::BeginFullScreen( /*AknTransEffect::EApplicationExit*/1501, TRect(), |
|
1206 AknTransEffect::EParameterType, |
|
1207 AknTransEffect::GfxTransParam( KUidPsln ) ); |
|
1208 break; |
|
1209 |
|
1210 case EPslnTransitionEffectStop: |
|
1211 GfxTransEffect::EndFullScreen(); |
|
1212 break; |
|
1213 } |
|
1214 } |
|
1215 |
|
1216 // --------------------------------------------------------------------------- |
|
1217 // Set current screensaver to default screensaver. |
|
1218 // --------------------------------------------------------------------------- |
|
1219 // |
|
1220 EXPORT_C void CPslnModel::SetScreenSaverToDefault() |
|
1221 { |
|
1222 // Default Screensaver is Date |
|
1223 iScreenSaverRepository->Set( |
|
1224 KScreenSaverObject, |
|
1225 KPslnSsDate ); |
|
1226 iScreenSaverRepository->Set( |
|
1227 KScreenSaverPluginName, |
|
1228 KNullDesC ); |
|
1229 |
|
1230 } |
|
1231 |
|
1232 // ----------------------------------------------------------------------------- |
|
1233 // CPslnModel::GetSeparatelyLocalizedSkinName |
|
1234 // ----------------------------------------------------------------------------- |
|
1235 // |
|
1236 TBool CPslnModel::GetSeparatelyLocalizedSkinName( |
|
1237 const TAknsPkgID aPID, TDes& aSkinName, |
|
1238 const TPslnSkinNameType aType ) const |
|
1239 { |
|
1240 PSLN_TRACE_DEBUG("CPslnModel::GetSeparatelyLocalizedSkinName"); |
|
1241 TBool retValue = EFalse; |
|
1242 TInt i = KErrNone; |
|
1243 for( ; i < iSkinNames.Count(); i++ ) |
|
1244 { |
|
1245 if( iSkinNames[i].iPid == aPID ) |
|
1246 { |
|
1247 switch( aType ) |
|
1248 { |
|
1249 case EPslnSkinNameTypeList: |
|
1250 aSkinName = *iSkinNames[i].iListName; |
|
1251 break; |
|
1252 case EPslnSkinNameTypeTitle: |
|
1253 aSkinName = *iSkinNames[i].iTitleName; |
|
1254 break; |
|
1255 } |
|
1256 retValue = ETrue; |
|
1257 break; // break the for loop |
|
1258 } |
|
1259 } |
|
1260 return retValue; |
|
1261 } |
|
1262 |
|
1263 |
|
1264 // ----------------------------------------------------------------------------- |
|
1265 // C++ constructor can NOT contain any code, that might leave. |
|
1266 // ----------------------------------------------------------------------------- |
|
1267 // |
|
1268 CPslnModel::CPslnModel() |
|
1269 { |
|
1270 PSLN_TRACE_DEBUG("CPslnModel::constructor"); |
|
1271 iEikEnv = CEikonEnv::Static(); |
|
1272 iActiveSkinIndex = KErrNotFound; |
|
1273 iCurrentSkinIndex = KErrNotFound; |
|
1274 iInternalState.ClearAll(); |
|
1275 } |
|
1276 |
|
1277 // ----------------------------------------------------------------------------- |
|
1278 // Symbian 2nd phase constructor can leave. |
|
1279 // ----------------------------------------------------------------------------- |
|
1280 // |
|
1281 void CPslnModel::ConstructL( MAknsSkinChangeObserver* aObserver ) |
|
1282 { |
|
1283 PSLN_TRACE_DEBUG("CPslnModel::ConstructL"); |
|
1284 |
|
1285 PSLN_TRACE_DEBUG("CPslnModel::ConstructL CenRep"); |
|
1286 iSkinsRepository = CRepository::NewL( KCRUidPersonalisation ); |
|
1287 iScreenSaverRepository = CRepository::NewL( KCRUidScreenSaver ); |
|
1288 iThemesAppRepository = CRepository::NewL( KCRUidThemes ); |
|
1289 |
|
1290 // Connect to skin server. |
|
1291 User::LeaveIfError( iSkinSrvSession.Connect( aObserver ) ); |
|
1292 |
|
1293 if( PslnFeatures::IsSupported( KPslnSupportFastPreviewTheme ) ) |
|
1294 { |
|
1295 InitTransitionEffectVauleL(); |
|
1296 } |
|
1297 |
|
1298 PSLN_TRACE_DEBUG("CPslnModel::ConstructL OK"); |
|
1299 } |
|
1300 |
|
1301 // ----------------------------------------------------------------------------- |
|
1302 // Loads the skin name resource file |
|
1303 // ----------------------------------------------------------------------------- |
|
1304 // |
|
1305 void CPslnModel::LoadSkinNamesResourceL() |
|
1306 { |
|
1307 PSLN_TRACE_DEBUG("CPslnModel::LoadSkinNamesResourceL"); |
|
1308 TParse* fp = new (ELeave) TParse; |
|
1309 fp->Set( KPslnSkinNamesFile, &KDC_APP_RESOURCE_DIR, NULL ); |
|
1310 TFileName filename = fp->FullName(); |
|
1311 delete fp; |
|
1312 |
|
1313 BaflUtils::NearestLanguageFile( iEikEnv->FsSession(), filename ); |
|
1314 TResourceReader reader; |
|
1315 TInt resourceFileOffset = iEikEnv->AddResourceFileL( filename ); |
|
1316 iEikEnv->CreateResourceReaderLC( reader, R_PSLN_SKINNAME_LIST ); |
|
1317 |
|
1318 TInt items = reader.ReadInt16(); |
|
1319 for( TInt i = 0; i < items; i++ ) |
|
1320 { |
|
1321 TInt pid1 = reader.ReadInt32(); |
|
1322 TInt pid2 = reader.ReadInt32(); |
|
1323 HBufC16* listname = reader.ReadHBufC16L(); |
|
1324 CleanupStack::PushL( listname ); |
|
1325 HBufC16* titlename = reader.ReadHBufC16L(); |
|
1326 CleanupStack::PushL( titlename ); |
|
1327 |
|
1328 TPslnSkinNameEntry entry; |
|
1329 entry.iPid.Set( pid2, pid1 ); |
|
1330 entry.iListName = listname; |
|
1331 entry.iTitleName = titlename; |
|
1332 User::LeaveIfError( iSkinNames.Append( entry ) ); |
|
1333 |
|
1334 // Title and list name are deleted in the model's destructor. |
|
1335 CleanupStack::Pop( 2, listname ); // titlename, listname |
|
1336 } |
|
1337 CleanupStack::PopAndDestroy(); // reader |
|
1338 |
|
1339 if( resourceFileOffset ) |
|
1340 { |
|
1341 iEikEnv->DeleteResourceFile( resourceFileOffset ); |
|
1342 } |
|
1343 |
|
1344 iInternalState.Set( EPslnModelStateSkinNamesLoaded ); |
|
1345 PSLN_TRACE_DEBUG("CPslnModel::LoadSkinNamesResourceL DONE"); |
|
1346 } |
|
1347 |
|
1348 // --------------------------------------------------------------------------- |
|
1349 // CPslnModel::FindAndAppendScreensaversL |
|
1350 // --------------------------------------------------------------------------- |
|
1351 // |
|
1352 TBool CPslnModel::FindAndAppendScreensaversL() |
|
1353 { |
|
1354 PSLN_TRACE_DEBUG("CPslnModel::FindAndAppendScreensaversL"); |
|
1355 |
|
1356 TBool found = EFalse; |
|
1357 |
|
1358 RImplInfoPtrArray screenSaverList; |
|
1359 CleanupResetAndDestroyPushL( screenSaverList ); |
|
1360 |
|
1361 CScreensaverPluginInterfaceDefinition::ListImplementationsL( screenSaverList ); |
|
1362 |
|
1363 const TInt ssCount = screenSaverList.Count(); |
|
1364 |
|
1365 for( TInt i = 0; i < ssCount; i++ ) |
|
1366 { |
|
1367 PSLN_TRACE_DEBUG("CPslnModel::FindAndAppendScreensaversL Plugin found"); |
|
1368 |
|
1369 CImplementationInformation* implInfo = screenSaverList[i]; |
|
1370 |
|
1371 // The the screensaver ecom plugin implementation UID will be used in place of |
|
1372 // screensaver file name |
|
1373 // The string format of the UID: [12345678] |
|
1374 // The number inside the brackets in hexadecimal format |
|
1375 TUid impUid = implInfo->ImplementationUid(); |
|
1376 |
|
1377 // Stash plugin drive number after the UID. |
|
1378 HBufC* ssName = HBufC::NewLC( KMaxUidName + KPslnDriveNumberLength ); |
|
1379 TPtr ssNamePtr = ssName->Des(); |
|
1380 ssNamePtr = impUid.Name(); |
|
1381 ssNamePtr.AppendNum( implInfo->Drive() ); |
|
1382 |
|
1383 // Query plugin name. |
|
1384 MScreensaverPlugin* plugin = NULL; |
|
1385 |
|
1386 TRAPD( err, plugin = static_cast<MScreensaverPlugin*>( |
|
1387 CScreensaverPluginInterfaceDefinition::NewL( |
|
1388 TUid::Uid( impUid.iUid ) ) ) ); |
|
1389 |
|
1390 PSLN_TRACE_DEBUG("CPslnModel::FindAndAppendScreensaversL Getting caps"); |
|
1391 |
|
1392 if ( err == KErrNone ) |
|
1393 { |
|
1394 CleanupStack::PushL( plugin ); |
|
1395 |
|
1396 PSLN_TRACE_DEBUG("CPslnModel::FindAndAppendScreensaversL Getting caps"); |
|
1397 |
|
1398 // Convert the string stored in OpaqueData to an integer |
|
1399 // It is the string represantation of TScPluginCaps values |
|
1400 // opaque_data has the type TDescC8 so we have to use TLex8 |
|
1401 TLex8 lex(implInfo->OpaqueData()); |
|
1402 PSLN_TRACE_DEBUG("CPslnModel::FindAndAppendScreensaversL After Getting caps"); |
|
1403 TInt capabilities = EScpCapsNone; |
|
1404 TInt err2 = KErrNone; |
|
1405 if ( !lex.Eos() ) |
|
1406 { |
|
1407 err2 = lex.Val( capabilities ); |
|
1408 } |
|
1409 PSLN_TRACE_DEBUG("CPslnModel::FindAndAppendScreensaversL After Eos check"); |
|
1410 if ( err2 != KErrNone ) |
|
1411 { |
|
1412 PSLN_TRACE_DEBUG("CPslnModel::FindAndAppendScreensaversL Failed"); |
|
1413 // skip the failing plugin |
|
1414 CleanupStack::Pop( plugin ); // using PopAndDestroy fails here. |
|
1415 delete plugin; |
|
1416 plugin = NULL; |
|
1417 break; |
|
1418 } |
|
1419 |
|
1420 // Append screensaver name. |
|
1421 PSLN_TRACE_DEBUG("CPslnModel::FindAndAppendScreensaversL Do Check"); |
|
1422 if ( plugin && iScreensaverNameArr ) |
|
1423 { |
|
1424 if ( plugin->Name() != KNullDesC ) |
|
1425 { |
|
1426 PSLN_TRACE_DEBUG("CPslnModel::FindAndAppendScreensaversL Trying to add Name"); |
|
1427 iScreensaverNameArr->AppendL( plugin->Name() ); |
|
1428 } |
|
1429 else |
|
1430 { |
|
1431 PSLN_TRACE_DEBUG("CPslnModel::FindAndAppendScreensaversL Trying to add DisplayName"); |
|
1432 iScreensaverNameArr->AppendL( implInfo->DisplayName() ); |
|
1433 } |
|
1434 } |
|
1435 CleanupStack::Pop( plugin ); // using PopAndDestroy fails here. |
|
1436 delete plugin; |
|
1437 plugin = NULL; |
|
1438 |
|
1439 PSLN_TRACE_DEBUG("CPslnModel::FindAndAppendScreensaversL CapsArr Append"); |
|
1440 User::LeaveIfError( |
|
1441 iScreensaverCapsArr.Append( capabilities ) ); |
|
1442 PSLN_TRACE_DEBUG("CPslnModel::FindAndAppendScreensaversL CapsArrAppend OK"); |
|
1443 |
|
1444 found = ETrue; |
|
1445 |
|
1446 PSLN_TRACE_DEBUG("CPslnModel::FindAndAppendScreensaversL Append"); |
|
1447 if ( iScreensaverFilenameArr ) |
|
1448 { |
|
1449 iScreensaverFilenameArr->AppendL( ssNamePtr ); |
|
1450 } |
|
1451 } |
|
1452 CleanupStack::PopAndDestroy( ssName ); |
|
1453 } |
|
1454 PSLN_TRACE_DEBUG("CPslnModel::FindAndAppendScreensaversL COMPLETED"); |
|
1455 CleanupStack::PopAndDestroy( &screenSaverList ); |
|
1456 return found; |
|
1457 } |
|
1458 |
|
1459 // --------------------------------------------------------------------------- |
|
1460 // CPslnModel::UpdateFromServerL |
|
1461 // --------------------------------------------------------------------------- |
|
1462 // |
|
1463 void CPslnModel::UpdateFromServerL() |
|
1464 { |
|
1465 PSLN_TRACE_DEBUG("CPslnModel::UpdateFromServerL"); |
|
1466 if ( !iSkinStore ) |
|
1467 { |
|
1468 iSkinStore = CPslnSkinStore::NewL( this ); |
|
1469 } |
|
1470 iSkinStore->UpdateAllSkinsL( iEikEnv->FsSession() ); |
|
1471 UpdateVisibleSkinListL(); |
|
1472 } |
|
1473 |
|
1474 // --------------------------------------------------------------------------- |
|
1475 // CPslnModel::UpdateVisibleSkinListL |
|
1476 // --------------------------------------------------------------------------- |
|
1477 // |
|
1478 void CPslnModel::UpdateVisibleSkinListL() |
|
1479 { |
|
1480 PSLN_TRACE_DEBUG("CPslnModel::UpdateVisibleSkinListL"); |
|
1481 if( iVisibleSkinArr ) |
|
1482 { |
|
1483 iVisibleSkinArr->ResetAndDestroy(); |
|
1484 delete iVisibleSkinArr; |
|
1485 iVisibleSkinArr = NULL; |
|
1486 } |
|
1487 |
|
1488 if ( iSkinStore ) |
|
1489 { |
|
1490 iVisibleSkinArr = iSkinStore->CreateNameArrayL(); |
|
1491 } |
|
1492 } |
|
1493 |
|
1494 // ----------------------------------------------------------------------------- |
|
1495 // CPslnModel::SetActiveSkinL |
|
1496 // ----------------------------------------------------------------------------- |
|
1497 // |
|
1498 void CPslnModel::SetActiveSkinL() |
|
1499 { |
|
1500 PSLN_TRACE_DEBUG("CPslnModel::SetActiveSkinL"); |
|
1501 |
|
1502 TInt activeSkinLocation = KErrNotFound; |
|
1503 |
|
1504 iSkinsRepository->Get( |
|
1505 KPslnActiveSkinLocation, |
|
1506 activeSkinLocation ); |
|
1507 |
|
1508 // If skin is from memory card, check memory card status. |
|
1509 if( activeSkinLocation == EAknsSrvMMC ) |
|
1510 { |
|
1511 if( PslnDiskUtil::MmcStatus() < 0 ) |
|
1512 { |
|
1513 // If skin is on memory card, and there is access error, |
|
1514 // activate default skin. |
|
1515 ActivateDefaultSkinL(); |
|
1516 return; |
|
1517 } |
|
1518 } |
|
1519 |
|
1520 TAknsPkgIDBuf pidBuf; |
|
1521 iSkinsRepository->Get( |
|
1522 KPslnActiveSkinUid, |
|
1523 pidBuf ); |
|
1524 |
|
1525 TAknsPkgID activeSkinPid; |
|
1526 activeSkinPid.SetFromDesL( pidBuf ); |
|
1527 |
|
1528 if ( !iVisibleSkinArr ) |
|
1529 { |
|
1530 User::Leave( KErrGeneral ); |
|
1531 } |
|
1532 TInt activeSkinIndex = KErrNotFound; |
|
1533 for( TInt i = 0; i < iVisibleSkinArr->Count(); i++ ) |
|
1534 { |
|
1535 CPslnSkinNameEntry* nameEntry = (*iVisibleSkinArr)[i]; |
|
1536 if ( !nameEntry ) |
|
1537 { |
|
1538 User::Leave( KErrGeneral ); |
|
1539 } |
|
1540 if( ( activeSkinPid == nameEntry->PkgID() ) && |
|
1541 ( activeSkinLocation == nameEntry->Location() ) ) |
|
1542 { |
|
1543 activeSkinIndex = i; |
|
1544 break; |
|
1545 } |
|
1546 } |
|
1547 |
|
1548 if( activeSkinIndex == KErrNotFound ) |
|
1549 { |
|
1550 // If the currently active skin no longer exists, activate the default. |
|
1551 ActivateDefaultSkinL(); |
|
1552 return; |
|
1553 } |
|
1554 |
|
1555 iActiveSkinIndex = activeSkinIndex; |
|
1556 } |
|
1557 |
|
1558 // ----------------------------------------------------------------------------- |
|
1559 // Screen saver text query |
|
1560 // ----------------------------------------------------------------------------- |
|
1561 // |
|
1562 TBool CPslnModel::QueryAndSetScreensaverTextL() |
|
1563 { |
|
1564 PSLN_TRACE_DEBUG("CPslnModel::QueryAndSetScreensaverTextL"); |
|
1565 |
|
1566 HBufC* displayText = HBufC::NewLC( KPslnMaxNumberOfScreenSaverText ); |
|
1567 TPtr txtPtr = displayText->Des(); |
|
1568 |
|
1569 TInt error = iScreenSaverRepository->Get( KScreenSaverText, txtPtr ); |
|
1570 |
|
1571 // Just load the default text if nothing was set in the skin settings. |
|
1572 if ( ( txtPtr.Length() == 0 ) || ( error != KErrNone ) ) |
|
1573 { |
|
1574 GetDefaultTextToScreensaverL( txtPtr ); |
|
1575 } |
|
1576 |
|
1577 // Set text to query. |
|
1578 CAknTextQueryDialog* dlg = CAknTextQueryDialog::NewL( |
|
1579 txtPtr, |
|
1580 CAknQueryDialog::ENoTone ); |
|
1581 dlg->SetPredictiveTextInputPermitted( ETrue ); |
|
1582 |
|
1583 // If in APAC region, set dialog length dynamically. |
|
1584 if ( PslnFeatures::IsAPACSupported() ) |
|
1585 { |
|
1586 dlg->SetMaxLength( KPslnSsTextDialogAPACMaxLength ); |
|
1587 } |
|
1588 |
|
1589 TBool retValue = EFalse; |
|
1590 // Show query for Screen saver txt. |
|
1591 if( dlg->ExecuteLD( R_PSLN_SCREEN_SAVER_TEXT_QUERY_DIALOG ) ) |
|
1592 { |
|
1593 error = iScreenSaverRepository->Set( KScreenSaverText, txtPtr ); |
|
1594 if ( error == KErrNone ) |
|
1595 { |
|
1596 retValue = ETrue; |
|
1597 } |
|
1598 } |
|
1599 CleanupStack::PopAndDestroy( displayText ); |
|
1600 return retValue; |
|
1601 } |
|
1602 |
|
1603 |
|
1604 // --------------------------------------------------------------------------- |
|
1605 // CPslnModel::GetSkinFullName |
|
1606 // --------------------------------------------------------------------------- |
|
1607 // |
|
1608 const TDesC& CPslnModel::GetSkinFullName( const TInt aItemIndex ) |
|
1609 { |
|
1610 PSLN_TRACE_DEBUG("CPslnModel::GetSkinFullName"); |
|
1611 CPslnSkinEntry* skinEntry = VisibleSkin( aItemIndex ); |
|
1612 if ( skinEntry ) |
|
1613 { |
|
1614 return skinEntry->FullName(); |
|
1615 } |
|
1616 return KNullDesC; |
|
1617 } |
|
1618 |
|
1619 // ----------------------------------------------------------------------------- |
|
1620 // CPslnModel::GetSkinNameByPID |
|
1621 // ----------------------------------------------------------------------------- |
|
1622 // |
|
1623 void CPslnModel::GetSkinNameByPID( const TAknsPkgID aPID, TDes& aSkinName, |
|
1624 const TPslnSkinNameType aType ) const |
|
1625 { |
|
1626 PSLN_TRACE_DEBUG("CPslnModel::GetSkinNameByPID"); |
|
1627 |
|
1628 aSkinName = KNullDesC; |
|
1629 |
|
1630 if( GetSeparatelyLocalizedSkinName( aPID, aSkinName, aType ) ) |
|
1631 { |
|
1632 return; |
|
1633 } |
|
1634 |
|
1635 if ( iSkinStore ) |
|
1636 { |
|
1637 CPslnSkinEntry* entry = iSkinStore->Find( aPID, EAknsSrvAll ); |
|
1638 if ( entry ) |
|
1639 { |
|
1640 entry->GetName( aSkinName ); |
|
1641 } |
|
1642 } |
|
1643 } |
|
1644 |
|
1645 // --------------------------------------------------------------------------- |
|
1646 // CPslnModel::ActivateDefaultSkinL |
|
1647 // --------------------------------------------------------------------------- |
|
1648 // |
|
1649 void CPslnModel::ActivateDefaultSkinL() |
|
1650 { |
|
1651 PSLN_TRACE_DEBUG("CPslnModel::ActivateDefaultSkinL"); |
|
1652 GuardActivationLC(); |
|
1653 ActivateSkinL( KPslnSeries60SkinIndex ); |
|
1654 CleanupStack::PopAndDestroy(); // activation guard |
|
1655 } |
|
1656 |
|
1657 // --------------------------------------------------------------------------- |
|
1658 // Sets default text to parameter. |
|
1659 // --------------------------------------------------------------------------- |
|
1660 // |
|
1661 void CPslnModel::GetDefaultTextToScreensaverL( TDes& aDisplayText ) |
|
1662 { |
|
1663 PSLN_TRACE_DEBUG("CPslnModel::GetDefaultTextToScreensaverL"); |
|
1664 HBufC* strBuffer = NULL; |
|
1665 strBuffer = StringLoader::LoadLC( R_PSLN_SCREEN_SAVER_DEFAULT_TEXT ); |
|
1666 if ( strBuffer ) |
|
1667 { |
|
1668 aDisplayText = strBuffer->Des(); |
|
1669 } |
|
1670 CleanupStack::PopAndDestroy( strBuffer ); |
|
1671 } |
|
1672 |
|
1673 // --------------------------------------------------------------------------- |
|
1674 // Gets wallpaper item index. Same as above, but can leave. |
|
1675 // --------------------------------------------------------------------------- |
|
1676 // |
|
1677 TInt CPslnModel::GetWallPaperItemIndex() |
|
1678 { |
|
1679 PSLN_TRACE_DEBUG("CPslnModel::GetWallPaperItemIndexL"); |
|
1680 TInt itemIndex = KErrNotFound; |
|
1681 |
|
1682 TInt error = iSkinsRepository->Get( KPslnWallpaperType, itemIndex ); |
|
1683 if ( error != KErrNone ) |
|
1684 { |
|
1685 itemIndex = KPslnDefaultItemIndex; |
|
1686 } |
|
1687 if ( itemIndex == KPslnDefaultItemIndex ) |
|
1688 { |
|
1689 // Verify that key values are coherent. |
|
1690 TFileName wallpaperPath; |
|
1691 error = iSkinsRepository->Get( KPslnIdleBackgroundImagePath, wallpaperPath ); |
|
1692 if ( wallpaperPath.Length() > 0 ) |
|
1693 { |
|
1694 // Wallpaper image is defined, but type is claimed as None. |
|
1695 // Assume that image is desired. |
|
1696 itemIndex = 1; |
|
1697 } |
|
1698 } |
|
1699 |
|
1700 return itemIndex; |
|
1701 } |
|
1702 |
|
1703 // --------------------------------------------------------------------------- |
|
1704 // Gets screensaver item index. Same as above, but can leave. |
|
1705 // --------------------------------------------------------------------------- |
|
1706 // |
|
1707 TInt CPslnModel::GetScreenSaverItemIndexL() |
|
1708 { |
|
1709 PSLN_TRACE_DEBUG("CPslnModel::GetScreenSaverItemIndexL"); |
|
1710 TInt screenObjectType = KErrNotFound; |
|
1711 TInt error = KErrNone; |
|
1712 |
|
1713 error = iScreenSaverRepository->Get( |
|
1714 KScreenSaverObject, screenObjectType ); |
|
1715 |
|
1716 if ( error != KErrNone ) |
|
1717 { |
|
1718 return KErrNotFound; |
|
1719 } |
|
1720 |
|
1721 if ( screenObjectType == KPslnSsNone && !IsSupportScreenSaverNoneOption() ) |
|
1722 { |
|
1723 //if "none" option is not supported and the settings of cenrep is none |
|
1724 //then change it to the default screen saver - "date". |
|
1725 screenObjectType = KPslnSsDate; |
|
1726 } |
|
1727 |
|
1728 switch ( screenObjectType ) |
|
1729 { |
|
1730 case KPslnSsNone: |
|
1731 return GetScreenSaverIndexByFileName(KPslnScreenSaverTypeNone); |
|
1732 case KPslnSsDate: |
|
1733 return GetScreenSaverIndexByFileName(KPslnScreenSaverTypeDateTime); |
|
1734 case KPslnSsText: |
|
1735 return GetScreenSaverIndexByFileName(KPslnScreenSaverTypeText); |
|
1736 case KPslnSsObject: |
|
1737 break; |
|
1738 default: |
|
1739 return KErrNotFound; |
|
1740 } |
|
1741 |
|
1742 TInt itemIndex = KErrNotFound; |
|
1743 HBufC* screenSaverFileName = HBufC::NewLC( KMaxFileName ); |
|
1744 TPtr ssFilePtr = screenSaverFileName->Des(); |
|
1745 error = iScreenSaverRepository->Get( |
|
1746 KScreenSaverPluginName, |
|
1747 ssFilePtr ); |
|
1748 |
|
1749 // Try to look for ']'. |
|
1750 TInt eqPos = ssFilePtr.Find( KPslnScreenSaverUidEndMark ); |
|
1751 |
|
1752 // If not found, use the whole string. |
|
1753 if( eqPos == KErrNotFound ) |
|
1754 { |
|
1755 eqPos = ssFilePtr.Length(); |
|
1756 } |
|
1757 // strip all characters right of it. |
|
1758 ssFilePtr = ssFilePtr.Left( eqPos + 1 ); |
|
1759 |
|
1760 if ( error == KErrNone && iScreensaverFilenameArr ) |
|
1761 { |
|
1762 // Loop through all the screensavers. |
|
1763 for( TInt i = 0; i < iScreensaverFilenameArr->MdcaCount(); i++ ) |
|
1764 { |
|
1765 TPtrC ssNamePtr = GetRealScreenSaverUid( i ); |
|
1766 if( ssNamePtr.CompareF( ssFilePtr ) == 0 ) |
|
1767 { |
|
1768 itemIndex = i; |
|
1769 break; |
|
1770 } |
|
1771 } |
|
1772 } |
|
1773 CleanupStack::PopAndDestroy( screenSaverFileName ); |
|
1774 return itemIndex; |
|
1775 } |
|
1776 |
|
1777 // --------------------------------------------------------------------------- |
|
1778 // Dynamically loads AknsWallpaperUtils to memory. |
|
1779 // --------------------------------------------------------------------------- |
|
1780 // |
|
1781 void CPslnModel::LoadWallpaperUtilsL() |
|
1782 { |
|
1783 // Wallpaper utils dll loading. |
|
1784 if( iInternalState.IsClear( EPslnModelStateWallpaperDllLoaded ) ) |
|
1785 { |
|
1786 PSLN_TRACE_DEBUG("CPslnModel::LoadWallpaperUtilsL about load"); |
|
1787 if( iWallpaperDll.Load( KPslnWallpaperUtilsLoaderName ) == KErrNone ) |
|
1788 { |
|
1789 PSLN_TRACE_DEBUG("CPslnModel::LoadWallpaperUtilsL loaded"); |
|
1790 iInternalState.Set( EPslnModelStateWallpaperDllLoaded ); |
|
1791 // Request the entry function |
|
1792 NewWallpaperUtilsL wallpaperUtils = |
|
1793 (NewWallpaperUtilsL) iWallpaperDll.Lookup( KPslnDllEntryPoint ); |
|
1794 if( wallpaperUtils ) |
|
1795 { |
|
1796 PSLN_TRACE_DEBUG("CPslnModel::LoadWallpaperUtilsL create"); |
|
1797 // Create the class |
|
1798 iWallpaperSetter = |
|
1799 (CPslnWallpaperUtilsLoader*) (*wallpaperUtils)(); |
|
1800 } |
|
1801 } |
|
1802 } |
|
1803 if ( !iWallpaperSetter ) |
|
1804 { |
|
1805 User::Leave( KErrNotFound ); |
|
1806 } |
|
1807 } |
|
1808 |
|
1809 // ----------------------------------------------------------------------------- |
|
1810 // This function removes file information from ScreenSaver UID. |
|
1811 // ----------------------------------------------------------------------------- |
|
1812 // |
|
1813 TPtrC CPslnModel::GetRealScreenSaverUid( const TInt aIndex ) |
|
1814 { |
|
1815 PSLN_TRACE_DEBUG("CPslnModel::GetRealScreenSaverUid"); |
|
1816 // Look for ']' - this indicates the end of screensaver UID. |
|
1817 TInt eqPos = |
|
1818 iScreensaverFilenameArr->MdcaPoint( aIndex ).Find( |
|
1819 KPslnScreenSaverUidEndMark ); |
|
1820 // If not found, use the whole string. |
|
1821 if( eqPos == KErrNotFound ) |
|
1822 { |
|
1823 eqPos = iScreensaverFilenameArr->MdcaPoint( aIndex ).Length(); |
|
1824 } |
|
1825 // strip all characters right of it. |
|
1826 return iScreensaverFilenameArr->MdcaPoint( aIndex ).Left( eqPos + 1 ); |
|
1827 } |
|
1828 |
|
1829 // ----------------------------------------------------------------------------- |
|
1830 // This is leaving version of ActivateScreenSaver. |
|
1831 // ----------------------------------------------------------------------------- |
|
1832 // |
|
1833 void CPslnModel::ActivateScreenSaverL( const TInt aItemIndex, |
|
1834 TPslnScreenSaverActivation aActivationType ) |
|
1835 { |
|
1836 PSLN_TRACE_DEBUG("CPslnModel::ActivateScreenSaver"); |
|
1837 |
|
1838 TInt error = KErrNone; |
|
1839 if ( aActivationType == EPslnScreenSaverPreviewActivation ) |
|
1840 { |
|
1841 // get screen saver type to be previewed |
|
1842 TInt previewSsType = GetScreensaverTypeByIndex( aItemIndex ); |
|
1843 if ( previewSsType == KErrNotFound ) |
|
1844 { |
|
1845 User::Leave( KErrNotFound ); |
|
1846 } |
|
1847 |
|
1848 // create CScreenSaverInfo object to backup the current screensaver settings |
|
1849 if ( !iScreenSaverInfo ) |
|
1850 { |
|
1851 iScreenSaverInfo = CPslnScreenSaverInfo::NewL(); |
|
1852 } |
|
1853 |
|
1854 //backup current screensaver settings |
|
1855 error = iScreenSaverRepository->Get( |
|
1856 KScreenSaverObject, |
|
1857 iScreenSaverInfo->iScreenSaverType ); |
|
1858 |
|
1859 if ( previewSsType == KPslnSsText ) |
|
1860 { |
|
1861 TPtr ptr = iScreenSaverInfo->iScreenSaverTxt->Des(); |
|
1862 error = iScreenSaverRepository->Get( |
|
1863 KScreenSaverText, |
|
1864 ptr ); |
|
1865 } |
|
1866 else if ( previewSsType == KPslnSsObject ) |
|
1867 { |
|
1868 TPtr ptr = iScreenSaverInfo->iFileName->Des(); |
|
1869 error = iScreenSaverRepository->Get( |
|
1870 KScreenSaverPluginName, |
|
1871 ptr ); |
|
1872 } |
|
1873 |
|
1874 //set values to screen saver needed to preview |
|
1875 if ( previewSsType == KPslnSsText ) |
|
1876 { |
|
1877 // Load the default text. |
|
1878 if ( iScreenSaverInfo->iScreenSaverTxt->Length() == 0 ) |
|
1879 { |
|
1880 HBufC* screensaverText = HBufC::NewLC( KPslnMaxNumberOfScreenSaverText ); |
|
1881 TPtr ptr = screensaverText->Des(); |
|
1882 |
|
1883 GetDefaultTextToScreensaverL( ptr ); |
|
1884 |
|
1885 error = iScreenSaverRepository->Set( |
|
1886 KScreenSaverText, |
|
1887 ptr ); |
|
1888 |
|
1889 CleanupStack::PopAndDestroy(screensaverText); |
|
1890 } |
|
1891 } |
|
1892 else if ( previewSsType == KPslnSsObject ) |
|
1893 { |
|
1894 // Get Screen saver filename based on index. |
|
1895 if( ( aItemIndex >= 0 ) && ( aItemIndex < iScreensaverFilenameArr->Count() ) ) |
|
1896 { |
|
1897 TPtrC ptr = iScreensaverFilenameArr->MdcaPoint( aItemIndex ); |
|
1898 error = iScreenSaverRepository->Set( |
|
1899 KScreenSaverPluginName, |
|
1900 ptr ); |
|
1901 } |
|
1902 } |
|
1903 |
|
1904 error = iScreenSaverRepository->Set( |
|
1905 KScreenSaverObject, |
|
1906 previewSsType ); |
|
1907 |
|
1908 // Set preview mode active, the screensaver is listening the value. |
|
1909 error = RProperty::Set( |
|
1910 KPSUidScreenSaver, |
|
1911 KScreenSaverPreviewMode, |
|
1912 KPslnActivatePreviewMode ); |
|
1913 } |
|
1914 else if ( aActivationType == EPslnScreenSaverPreviewDeactivation ) |
|
1915 { |
|
1916 TInt previewSsType = KErrNotFound; |
|
1917 error = iScreenSaverRepository->Get( |
|
1918 KScreenSaverObject, |
|
1919 previewSsType ); |
|
1920 |
|
1921 //restore the screen saver settings. |
|
1922 if ( previewSsType == KPslnSsObject ) |
|
1923 { |
|
1924 error = iScreenSaverRepository->Set( |
|
1925 KScreenSaverPluginName, |
|
1926 iScreenSaverInfo->iFileName->Des() ); |
|
1927 } |
|
1928 else if ( previewSsType == KPslnSsText ) |
|
1929 { |
|
1930 error = iScreenSaverRepository->Set( |
|
1931 KScreenSaverText, |
|
1932 iScreenSaverInfo->iScreenSaverTxt->Des() ); |
|
1933 } |
|
1934 |
|
1935 if ( error == KErrNone ) |
|
1936 { |
|
1937 error = iScreenSaverRepository->Set( |
|
1938 KScreenSaverObject, |
|
1939 iScreenSaverInfo->iScreenSaverType ); |
|
1940 } |
|
1941 } |
|
1942 else |
|
1943 { |
|
1944 User::Leave( KErrNotSupported ); |
|
1945 } |
|
1946 } |
|
1947 |
|
1948 // --------------------------------------------------------------------------- |
|
1949 // Dynamically loads browser launcher dll to memory. |
|
1950 // --------------------------------------------------------------------------- |
|
1951 // |
|
1952 void CPslnModel::LoadBrowserLaunchL() |
|
1953 { |
|
1954 // Browser launch dll loading. |
|
1955 if( iInternalState.IsClear( EPslnModelStateBrowserLaunchDllLoaded ) ) |
|
1956 { |
|
1957 PSLN_TRACE_DEBUG("CPslnModel::LoadBrowserLaunchL about load"); |
|
1958 if( iBrowserLaunchDll.Load( KPslnBrowserLaunchLoaderName ) == KErrNone ) |
|
1959 { |
|
1960 PSLN_TRACE_DEBUG("CPslnModel::LoadBrowserLaunchL loaded"); |
|
1961 iInternalState.Set( EPslnModelStateBrowserLaunchDllLoaded ); |
|
1962 // Request the entry function |
|
1963 NewBrowserLauncherL browserLaucnher = |
|
1964 (NewBrowserLauncherL) iBrowserLaunchDll.Lookup( KPslnDllEntryPoint ); |
|
1965 if( browserLaucnher ) |
|
1966 { |
|
1967 PSLN_TRACE_DEBUG("CPslnModel::LoadBrowserLaunchL create"); |
|
1968 // Create the class |
|
1969 iBrowserLauncher = |
|
1970 (CPslnBrowserLaunchLoader*) (*browserLaucnher)(); |
|
1971 } |
|
1972 } |
|
1973 } |
|
1974 if ( !iBrowserLauncher ) |
|
1975 { |
|
1976 User::Leave( KErrNotFound ); |
|
1977 } |
|
1978 } |
|
1979 |
|
1980 // ----------------------------------------------------------------------------- |
|
1981 // CPslnModel::SkinFileExist |
|
1982 // ----------------------------------------------------------------------------- |
|
1983 // |
|
1984 TBool CPslnModel::SkinFileExist( const TInt& aIndex ) |
|
1985 { |
|
1986 if( !IsThemeOnMemoryCard(aIndex) ) |
|
1987 { |
|
1988 return ETrue; |
|
1989 } |
|
1990 |
|
1991 TFileName fullname; |
|
1992 fullname = GetSkinFullName( aIndex ); |
|
1993 |
|
1994 TInt filehandle = 0; |
|
1995 TInt fileserverhandle = iSkinSrvSession.OpenBitmapFile( fullname, filehandle ); |
|
1996 |
|
1997 RFile file; |
|
1998 TInt errorcode = file.AdoptFromServer( fileserverhandle, filehandle ); |
|
1999 file.Close(); |
|
2000 |
|
2001 if ( errorcode == KErrNone ) |
|
2002 { |
|
2003 return ETrue; |
|
2004 } |
|
2005 |
|
2006 return EFalse; |
|
2007 } |
|
2008 |
|
2009 // --------------------------------------------------------------------------- |
|
2010 // Used to notify the client about changes for integer value keys. |
|
2011 // --------------------------------------------------------------------------- |
|
2012 // |
|
2013 void CPslnModel::HandleNotifyInt(TUint32 aId, TInt aNewValue) |
|
2014 { |
|
2015 if( aId == KThemesTransitionEffects ) |
|
2016 { |
|
2017 iTransitionEffectValue = aNewValue; |
|
2018 } |
|
2019 } |
|
2020 |
|
2021 // --------------------------------------------------------------------------- |
|
2022 // Gets transition effect value and initialize CenRep notify handler. |
|
2023 // --------------------------------------------------------------------------- |
|
2024 // |
|
2025 void CPslnModel::InitTransitionEffectVauleL() |
|
2026 { |
|
2027 iTransitionEffectValue = KErrNone; |
|
2028 |
|
2029 TInt error = iThemesAppRepository->Get( KThemesTransitionEffects, iTransitionEffectValue ); |
|
2030 if ( error != KErrNone || iTransitionEffectValue < 0 ) |
|
2031 { |
|
2032 iTransitionEffectValue = KErrNotFound; |
|
2033 } |
|
2034 |
|
2035 iThemesAppCenRepNotifyHandler = |
|
2036 CCenRepNotifyHandler::NewL(*this, *iThemesAppRepository, |
|
2037 CCenRepNotifyHandler::EIntKey, KThemesTransitionEffects); |
|
2038 iThemesAppCenRepNotifyHandler->StartListeningL(); |
|
2039 |
|
2040 } |
|
2041 |
|
2042 // ----------------------------------------------------------------------------- |
|
2043 // Get screen saver object type from index. |
|
2044 // ----------------------------------------------------------------------------- |
|
2045 // |
|
2046 TInt CPslnModel::GetScreensaverTypeByIndex(TInt aIndex) |
|
2047 { |
|
2048 if(aIndex < 0 || aIndex >= iScreensaverFilenameArr->MdcaCount()) |
|
2049 { |
|
2050 return KErrNotFound; |
|
2051 } |
|
2052 |
|
2053 TPtrC ptr = iScreensaverFilenameArr->MdcaPoint(aIndex); |
|
2054 if(ptr.Compare(KPslnScreenSaverTypeNone) == 0) |
|
2055 { |
|
2056 return KPslnSsNone; |
|
2057 } |
|
2058 if(ptr.Compare(KPslnScreenSaverTypeDateTime) == 0) |
|
2059 { |
|
2060 return KPslnSsDate; |
|
2061 } |
|
2062 if(ptr.Compare(KPslnScreenSaverTypeText) == 0) |
|
2063 { |
|
2064 return KPslnSsText; |
|
2065 } |
|
2066 |
|
2067 return KPslnSsObject; |
|
2068 } |
|
2069 |
|
2070 // --------------------------------------------------------------------------- |
|
2071 // Get screensaver item index from filename |
|
2072 // --------------------------------------------------------------------------- |
|
2073 // |
|
2074 TInt CPslnModel::GetScreenSaverIndexByFileName(const TDesC &aFileName) const |
|
2075 { |
|
2076 for( TInt i = 0; i < iScreensaverFilenameArr->MdcaCount(); i++ ) |
|
2077 { |
|
2078 if( aFileName.Compare((*iScreensaverFilenameArr)[i]) == 0 ) |
|
2079 { |
|
2080 return i; |
|
2081 } |
|
2082 } |
|
2083 return KErrNotFound; |
|
2084 } |
|
2085 |
|
2086 // --------------------------------------------------------------------------- |
|
2087 // Get if the "None" screen saver is supported. |
|
2088 // --------------------------------------------------------------------------- |
|
2089 // |
|
2090 TBool CPslnModel::IsSupportScreenSaverNoneOption() const |
|
2091 { |
|
2092 return PslnFeatures::IsSupported( KPslnSupportScreenSaverSupportNoneOption ); |
|
2093 } |
|
2094 |
|
2095 |
|
2096 |
|
2097 // End of File |
|
2098 |