|
1 /* |
|
2 * Copyright (c) 2005 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: Implementation file for class CScreenSaverAIWPlugin |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <eikmenup.h> |
|
21 #include <f32file.h> |
|
22 #include <e32property.h> |
|
23 #include <AiwMenu.h> |
|
24 #include <AiwCommon.h> |
|
25 #include <AiwCommon.hrh> |
|
26 #include <barsread.h> |
|
27 #include <eikenv.h> |
|
28 #include <implementationproxy.h> |
|
29 #include <StringLoader.h> |
|
30 #include <aknnotewrappers.h> |
|
31 #include <data_caging_path_literals.hrh> |
|
32 #include <screensaveraiwplugin.rsg> |
|
33 #include <AknsSrvClient.h> |
|
34 #include <imageconversion.h> |
|
35 #include <centralrepository.h> |
|
36 #include <ScreensaverInternalCRKeys.h> |
|
37 #include <ScreensaverInternalPSKeys.h> |
|
38 #include <pslninternalcrkeys.h> |
|
39 #include "ScreenSaverAnimPluginInternalCRKeys.h" |
|
40 #include "screensaveraiwplugin.h" |
|
41 #include "screensaveraiwplugin.rh" |
|
42 |
|
43 _LIT(KResourceFileName, "screensaveraiwplugin.rsc"); |
|
44 _LIT(KDriveZ, "z:"); |
|
45 _LIT(KPluginUidAnimation, "[1020744D]25"); // '25' is the drive number (Z = ROM), not |
|
46 _LIT(KPluginUidSlideshow, "[102823ED]25"); // mandatory |
|
47 |
|
48 |
|
49 _LIT(KScreenSaverAIWPluginMimeTypeImage, "image"); |
|
50 _LIT(KScreenSaverAIWPluginMimeTypeOTABitmap, "image/x-ota-bitmap"); |
|
51 _LIT(KScreenSaverAIWPluginSeparator, "/"); |
|
52 |
|
53 _LIT(KScreenSaverAIWPluginMimeTypeGIF, "image/gif"); |
|
54 _LIT(KScreenSaverAIWPluginMimeTypeSVG, "image/svg+xml"); |
|
55 _LIT(KScreenSaverAIWPluginMimeTypeM3G, "application/m3g"); |
|
56 _LIT(KScreenSaverAIWPluginMimeTypeSWF, "application/x-shockwave-flash"); |
|
57 |
|
58 |
|
59 // ======== LOCAL FUNCTIONS ======== |
|
60 |
|
61 // ======== MEMBER FUNCTIONS ======== |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CScreenSaverAIWPlugin::NewL |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 CScreenSaverAIWPlugin* CScreenSaverAIWPlugin::NewL() |
|
68 { |
|
69 CScreenSaverAIWPlugin* self = new( ELeave ) CScreenSaverAIWPlugin; |
|
70 CleanupStack::PushL( self ); |
|
71 self->ConstructL(); |
|
72 CleanupStack::Pop(self); |
|
73 return self; |
|
74 } |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // CScreenSaverAIWPlugin::CScreenSaverAIWPlugin |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 CScreenSaverAIWPlugin::CScreenSaverAIWPlugin(): |
|
81 iConeResLoader(*CCoeEnv::Static()) |
|
82 { |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // CScreenSaverAIWPlugin::ConstructL |
|
87 // Symbian 2nd phase constructor can leave. |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 void CScreenSaverAIWPlugin::ConstructL() |
|
91 { |
|
92 TParse parse; |
|
93 parse.Set(KResourceFileName, &KDC_RESOURCE_FILES_DIR, &KDriveZ); |
|
94 TFileName resourceFileName; |
|
95 resourceFileName.Append(parse.FullName()); |
|
96 iConeResLoader.OpenL(resourceFileName); |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // CScreenSaverAIWPlugin::~CScreenSaverAIWPlugin |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 CScreenSaverAIWPlugin::~CScreenSaverAIWPlugin() |
|
104 { |
|
105 iConeResLoader.Close(); |
|
106 iSupportedImageFiles.Close(); |
|
107 delete iScreensaverRepository; |
|
108 delete iAnimationRepository; |
|
109 } |
|
110 |
|
111 // --------------------------------------------------------------------------- |
|
112 // From class CAiwServiceIfMenu. |
|
113 // --------------------------------------------------------------------------- |
|
114 // |
|
115 void CScreenSaverAIWPlugin::InitialiseL(MAiwNotifyCallback& /*aFrameworkCallback*/, |
|
116 const RCriteriaArray& /*aInterest*/) |
|
117 { |
|
118 // Not needed. |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------------------------- |
|
122 // From class CAiwServiceIfMenu. |
|
123 // |
|
124 // Implements setting the passed image(s) as screensaver. |
|
125 // --------------------------------------------------------------------------- |
|
126 // |
|
127 void CScreenSaverAIWPlugin::HandleServiceCmdL(const TInt& aCmdId, |
|
128 const CAiwGenericParamList& aInParamList, |
|
129 CAiwGenericParamList& /*aOutParamList*/, |
|
130 TUint /*aCmdOptions*/, |
|
131 const MAiwNotifyCallback* aCallback) |
|
132 { |
|
133 // Handle only KAiwCmdAssignScreenSaver command. |
|
134 if ( aCmdId == KAiwCmdAssignScreenSaver ) |
|
135 { |
|
136 #ifdef CSCREENSAVERAIWPLUGIN_TRACES |
|
137 DumpParamList(_L("HandleServiceCmdL"),aInParamList); |
|
138 #endif |
|
139 |
|
140 // Leave, if there were not given all the required parameters |
|
141 ValidateParamListL(aInParamList); |
|
142 |
|
143 // Get the supported image files to iSupportedImageFiles |
|
144 GetSupportedImageFilesL(aInParamList,iSupportedImageFiles); |
|
145 |
|
146 #ifdef CSCREENSAVERAIWPLUGIN_TRACES |
|
147 DumpSupportedImageFileList(iSupportedImageFiles); |
|
148 #endif |
|
149 |
|
150 TInt textResourceId = 0; |
|
151 if (iSupportedImageFiles.Count() == 1 && IsAnimatedImageL(iSupportedImageFiles[0].iFileName, |
|
152 iSupportedImageFiles[0].iMimeType)) |
|
153 { |
|
154 textResourceId = R_SCREEN_SAVER_AIW_PLUGIN_TEXT_IMAGE_AS_ANIMATION; |
|
155 SetAnimatedScreenSaverL(iSupportedImageFiles); |
|
156 } |
|
157 else |
|
158 { |
|
159 textResourceId = ((iSupportedImageFiles.Count() > 1)?R_SCREEN_SAVER_AIW_PLUGIN_TEXT_IMAGES_ADDED: |
|
160 R_SCREEN_SAVER_AIW_PLUGIN_TEXT_IMAGE_ADDED); |
|
161 SetSlideShowScreenSaverL(iSupportedImageFiles); |
|
162 } |
|
163 |
|
164 // display confirmation note |
|
165 DisplayInfoNoteL(textResourceId); |
|
166 |
|
167 // If aCallback defined inform consumers that we have done with |
|
168 // the operation. |
|
169 if (aCallback) |
|
170 { |
|
171 // Cope with the design problems of AIW framework |
|
172 MAiwNotifyCallback* nonConstCallback = |
|
173 const_cast<MAiwNotifyCallback*> (aCallback); |
|
174 |
|
175 CAiwGenericParamList* eventParamList = CAiwGenericParamList::NewL(); |
|
176 CleanupStack::PushL(eventParamList); |
|
177 nonConstCallback->HandleNotifyL( |
|
178 KAiwCmdAssignScreenSaver, |
|
179 KAiwEventCompleted, |
|
180 *eventParamList, |
|
181 aInParamList); |
|
182 CleanupStack::PopAndDestroy(eventParamList); |
|
183 } |
|
184 } |
|
185 } |
|
186 |
|
187 // --------------------------------------------------------------------------- |
|
188 // From class CAiwServiceIfMenu. |
|
189 // |
|
190 // Inserts plugin's menu items to aMenuPane. |
|
191 // --------------------------------------------------------------------------- |
|
192 // |
|
193 void CScreenSaverAIWPlugin::InitializeMenuPaneL(CAiwMenuPane& aMenuPane, |
|
194 TInt aIndex, |
|
195 TInt /*aCascadeId*/, |
|
196 const CAiwGenericParamList& aInParamList) |
|
197 { |
|
198 #ifdef CSCREENSAVERAIWPLUGIN_TRACES |
|
199 DumpParamList(_L("InitializeMenuPaneL"),aInParamList); |
|
200 #endif |
|
201 |
|
202 // Insert menu only if there is at least a single supported MIME type is given |
|
203 if ( AnyMimeTypeSupportedL(aInParamList) ) |
|
204 { |
|
205 TResourceReader reader; |
|
206 CCoeEnv::Static()->CreateResourceReaderLC(reader, R_SCREEN_SAVER_AIW_PLUGIN_MENU); |
|
207 aMenuPane.AddMenuItemsL(reader, KAiwCmdAssignScreenSaver, aIndex); |
|
208 CleanupStack::PopAndDestroy(); // reader |
|
209 } |
|
210 } |
|
211 |
|
212 // --------------------------------------------------------------------------- |
|
213 // From class CAiwServiceIfMenu. |
|
214 // |
|
215 // Implements menu command handling for EScreenSaverAIWPluginCmdSetScreenSaver. |
|
216 // --------------------------------------------------------------------------- |
|
217 // |
|
218 void CScreenSaverAIWPlugin::HandleMenuCmdL( |
|
219 TInt aMenuCmdId, |
|
220 const CAiwGenericParamList& aInParamList, |
|
221 CAiwGenericParamList& aOutParamList, |
|
222 TUint aCmdOptions, |
|
223 const MAiwNotifyCallback* aCallback) |
|
224 { |
|
225 if (aMenuCmdId == EScreenSaverAIWPluginCmdSetScreenSaver) |
|
226 { |
|
227 // Menu commands are handled as service commands. |
|
228 HandleServiceCmdL( |
|
229 KAiwCmdAssignScreenSaver, |
|
230 aInParamList, |
|
231 aOutParamList, |
|
232 aCmdOptions, |
|
233 aCallback ); |
|
234 } |
|
235 } |
|
236 |
|
237 // ----------------------------------------------------------------------------- |
|
238 // Implements showing information note |
|
239 // ----------------------------------------------------------------------------- |
|
240 // |
|
241 void CScreenSaverAIWPlugin::DisplayInfoNoteL(TInt aTextResourceId) |
|
242 { |
|
243 HBufC* text = StringLoader::LoadLC(aTextResourceId); |
|
244 CAknInformationNote* dlg = new (ELeave) CAknInformationNote(EFalse); |
|
245 dlg->ExecuteLD(*text); |
|
246 CleanupStack::PopAndDestroy(text); |
|
247 } |
|
248 |
|
249 |
|
250 // ----------------------------------------------------------------------------- |
|
251 // Validates aParamList if it is not valid |
|
252 // the method leaves with KErrArgument |
|
253 // ----------------------------------------------------------------------------- |
|
254 // |
|
255 void CScreenSaverAIWPlugin::ValidateParamListL(const CAiwGenericParamList& aParamList) |
|
256 { |
|
257 TBool valid = EFalse; |
|
258 |
|
259 // The parameter list must be dividable by 2 because the number of file name |
|
260 // items must be equal with the number of MIME type items. |
|
261 valid = !(aParamList.Count()%2); |
|
262 |
|
263 valid = valid && AnyMimeTypeSupportedL(aParamList); |
|
264 |
|
265 if (valid) |
|
266 { |
|
267 TInt index = 0; |
|
268 TPtrC fileName = GetAiwParamAsDescriptor(index, aParamList, EGenericParamFile); |
|
269 |
|
270 // At least one file name parameter should be given |
|
271 valid = !(fileName == KNullDesC); |
|
272 } |
|
273 |
|
274 if (!valid) |
|
275 { |
|
276 User::Leave(KErrArgument); |
|
277 } |
|
278 } |
|
279 |
|
280 // ----------------------------------------------------------------------------- |
|
281 // Gets supported image file list from generic param list |
|
282 // ----------------------------------------------------------------------------- |
|
283 // |
|
284 void CScreenSaverAIWPlugin::GetSupportedImageFilesL(const CAiwGenericParamList& aParamList, |
|
285 RArray<TImageFile>& aSupportedImageFiles) |
|
286 { |
|
287 aSupportedImageFiles.Reset(); |
|
288 for (TInt i = 0;; i++) |
|
289 { |
|
290 TImageFile imageFile; |
|
291 TPtrC fileName = GetAiwParamAsDescriptor(i, aParamList, EGenericParamFile); |
|
292 |
|
293 if (fileName == KNullDesC) |
|
294 { |
|
295 // last file item is reached |
|
296 break; |
|
297 } |
|
298 |
|
299 TPtrC mimeTypeString = GetAiwParamAsDescriptor(i, aParamList, EGenericParamMIMEType); |
|
300 if (mimeTypeString == KNullDesC) |
|
301 { |
|
302 // missing MIME type for file |
|
303 User::Leave(KErrArgument); |
|
304 break; |
|
305 } |
|
306 else if (IsMimeTypeSupportedL(mimeTypeString)) |
|
307 { |
|
308 imageFile.iFileName.Set(fileName); |
|
309 imageFile.iMimeType.Set(mimeTypeString); |
|
310 aSupportedImageFiles.Append(imageFile); |
|
311 } |
|
312 } |
|
313 } |
|
314 |
|
315 |
|
316 // ----------------------------------------------------------------------------- |
|
317 // Returns ETrue if any of the MIME types is supported |
|
318 // ----------------------------------------------------------------------------- |
|
319 // |
|
320 TBool CScreenSaverAIWPlugin::AnyMimeTypeSupportedL(const CAiwGenericParamList& aParamList) |
|
321 { |
|
322 TBool ret = EFalse; |
|
323 for (TInt i = 0;; i++) |
|
324 { |
|
325 TPtrC mimeTypeString = GetAiwParamAsDescriptor(i, aParamList, EGenericParamMIMEType); |
|
326 if (mimeTypeString == KNullDesC) |
|
327 { |
|
328 // If no MIME type parameters are passed just leave |
|
329 if (i <= 0) |
|
330 { |
|
331 User::Leave(KErrArgument); |
|
332 } |
|
333 break; |
|
334 } |
|
335 else if (IsMimeTypeSupportedL(mimeTypeString)) |
|
336 { |
|
337 ret = ETrue; |
|
338 break; |
|
339 } |
|
340 } |
|
341 return ret; |
|
342 } |
|
343 // ----------------------------------------------------------------------------- |
|
344 // Implements checking if a given MIME type is supported or not |
|
345 // ----------------------------------------------------------------------------- |
|
346 // |
|
347 TBool CScreenSaverAIWPlugin::IsMimeTypeSupportedL(const TDesC& aMimeTypeString) |
|
348 { |
|
349 // Check for a type separator in the string |
|
350 TInt pos = aMimeTypeString.Find(KScreenSaverAIWPluginSeparator); |
|
351 |
|
352 // Leave if no separator was found.. the MIME |
|
353 // standard requires it |
|
354 if (pos == KErrNotFound) |
|
355 { |
|
356 User::Leave(KErrArgument); |
|
357 } |
|
358 |
|
359 // Construct the compare string |
|
360 TPtrC compareString(aMimeTypeString.Left(pos)); |
|
361 |
|
362 // Perform the comparison |
|
363 TBool ret = EFalse; |
|
364 |
|
365 // Mime type case: IMAGE/* except IMAGE/X-OTA-BITMAP |
|
366 if (!compareString.CompareF(KScreenSaverAIWPluginMimeTypeImage) && |
|
367 aMimeTypeString.CompareF(KScreenSaverAIWPluginMimeTypeOTABitmap)) |
|
368 { |
|
369 ret = ETrue; |
|
370 } |
|
371 |
|
372 if (!ret) |
|
373 { |
|
374 TBool dummy; |
|
375 ret = IsAnimatedMimeTypeL(aMimeTypeString,dummy); |
|
376 } |
|
377 |
|
378 return ret; |
|
379 } |
|
380 |
|
381 // --------------------------------------------------------------------------- |
|
382 // Determines if the MIME type is animated or not and in addition returns |
|
383 // in aUseImageDecoder if image decoder should be used to determine if |
|
384 // the image is really animated |
|
385 // --------------------------------------------------------------------------- |
|
386 // |
|
387 TBool CScreenSaverAIWPlugin::IsAnimatedMimeTypeL( const TDesC& aMimeTypeString, TBool& aUseImageDecoder ) |
|
388 { |
|
389 TBool ret = EFalse; |
|
390 aUseImageDecoder = EFalse; |
|
391 |
|
392 // check if animated an needs image decoder |
|
393 if (!aMimeTypeString.CompareF(KScreenSaverAIWPluginMimeTypeGIF)) |
|
394 { |
|
395 aUseImageDecoder = ETrue; |
|
396 ret = ETrue; |
|
397 } |
|
398 else if (!aMimeTypeString.CompareF(KScreenSaverAIWPluginMimeTypeSVG) || |
|
399 !aMimeTypeString.CompareF(KScreenSaverAIWPluginMimeTypeM3G) || |
|
400 !aMimeTypeString.CompareF(KScreenSaverAIWPluginMimeTypeSWF)) |
|
401 { |
|
402 ret = ETrue; |
|
403 } |
|
404 |
|
405 return ret; |
|
406 } |
|
407 |
|
408 |
|
409 // ----------------------------------------------------------------------------- |
|
410 // Implements getting a AIW parameter as descriptor |
|
411 // ----------------------------------------------------------------------------- |
|
412 // |
|
413 TPtrC CScreenSaverAIWPlugin::GetAiwParamAsDescriptor( |
|
414 TInt& aIndex, |
|
415 const CAiwGenericParamList& aParamList, |
|
416 TGenericParamId aParamType) |
|
417 { |
|
418 const TAiwGenericParam* genericParam = NULL; |
|
419 genericParam = aParamList.FindFirst( |
|
420 aIndex, |
|
421 aParamType, |
|
422 EVariantTypeDesC); |
|
423 |
|
424 if (aIndex != KErrNotFound && genericParam) |
|
425 { |
|
426 // Get the data |
|
427 return genericParam->Value().AsDes(); |
|
428 } |
|
429 else |
|
430 { |
|
431 return KNullDesC(); |
|
432 } |
|
433 } |
|
434 |
|
435 #ifdef CSCREENSAVERAIWPLUGIN_TRACES |
|
436 |
|
437 // ----------------------------------------------------------------------------- |
|
438 // Dump parameters in aParamList |
|
439 // ----------------------------------------------------------------------------- |
|
440 // |
|
441 void CScreenSaverAIWPlugin::DumpParamList(const TDesC& aMethod, const CAiwGenericParamList& aParamList) |
|
442 { |
|
443 DumpParamList(aMethod,EGenericParamFile,aParamList); |
|
444 DumpParamList(aMethod,EGenericParamMIMEType,aParamList); |
|
445 } |
|
446 |
|
447 // ----------------------------------------------------------------------------- |
|
448 // Dump parameters in aParamList for a given aParamType |
|
449 // ----------------------------------------------------------------------------- |
|
450 // |
|
451 void CScreenSaverAIWPlugin::DumpParamList(const TDesC& aMethod, |
|
452 TGenericParamId aParamType, |
|
453 const CAiwGenericParamList& aParamList) |
|
454 { |
|
455 for (TInt i = 0 ;; i++) |
|
456 { |
|
457 TPtrC paramString = GetAiwParamAsDescriptor(i, aParamList, aParamType); |
|
458 if (paramString == KNullDesC) |
|
459 { |
|
460 break; |
|
461 } |
|
462 else |
|
463 { |
|
464 RDebug::Print( _L("ScreenSaverAIWPlugin: %x CScreenSaverAIWPlugin::%S: Index=%d, paramType=%d, paramString=%S"), this, &aMethod, i, aParamType, ¶mString); |
|
465 } |
|
466 } |
|
467 } |
|
468 |
|
469 // ----------------------------------------------------------------------------- |
|
470 // Dump supported image file list |
|
471 // ----------------------------------------------------------------------------- |
|
472 // |
|
473 void CScreenSaverAIWPlugin::DumpSupportedImageFileList(const RArray<TImageFile>& aSupportedImageFiles) |
|
474 { |
|
475 for (TInt i = 0 ; i < aSupportedImageFiles.Count() ; i++) |
|
476 { |
|
477 RDebug::Print( _L("ScreenSaverAIWPlugin: %x DumpSupportedImageFileList: Index=%d, file=%S, MIME type=%S"), this, i, &aSupportedImageFiles[i].iFileName, &aSupportedImageFiles[i].iMimeType); |
|
478 } |
|
479 } |
|
480 |
|
481 #endif |
|
482 |
|
483 // --------------------------------------------------------------------------- |
|
484 // Determines if an image is animated or not |
|
485 // --------------------------------------------------------------------------- |
|
486 // |
|
487 TBool CScreenSaverAIWPlugin::IsAnimatedImageL( const TDesC& aFileName, |
|
488 const TDesC& aMimeTypeString ) |
|
489 { |
|
490 TBool useImageDecoder = EFalse; |
|
491 TBool animated = IsAnimatedMimeTypeL( aMimeTypeString, useImageDecoder ); |
|
492 |
|
493 if (useImageDecoder) |
|
494 { |
|
495 animated = IsReallyAnimatedImageL(aFileName); |
|
496 } |
|
497 |
|
498 return animated; |
|
499 } |
|
500 |
|
501 // --------------------------------------------------------------------------- |
|
502 // Determines if an image file is really animated or not |
|
503 // --------------------------------------------------------------------------- |
|
504 // |
|
505 TBool CScreenSaverAIWPlugin::IsReallyAnimatedImageL( const TDesC& aFileName ) |
|
506 { |
|
507 CImageDecoder* decoder = CImageDecoder::FileNewL(CCoeEnv::Static()->FsSession(),aFileName); |
|
508 CleanupStack::PushL( decoder ); |
|
509 TBool animated = (decoder->FrameCount() > 1); |
|
510 CleanupStack::PopAndDestroy(); // decoder |
|
511 return animated; |
|
512 } |
|
513 |
|
514 // --------------------------------------------------------------------------- |
|
515 // Set and activate slide-show screen saver. |
|
516 // --------------------------------------------------------------------------- |
|
517 // |
|
518 void CScreenSaverAIWPlugin::SetSlideShowScreenSaverL( const RArray<TImageFile>& aSupportedImageFiles ) |
|
519 { |
|
520 StoreImageListToFileL(aSupportedImageFiles); |
|
521 |
|
522 if (iScreensaverRepository == NULL) |
|
523 { |
|
524 // Setting the screensaver type & plugin name |
|
525 iScreensaverRepository = CRepository::NewL(KCRUidScreenSaver); |
|
526 } |
|
527 if (iSlideshowRepository == NULL) |
|
528 { |
|
529 iSlideshowRepository = CRepository::NewL(KCRUidThemes); |
|
530 } |
|
531 |
|
532 // set psln to "not random" |
|
533 iSlideshowRepository->Set(KThemesScreenSaverSlideSetType, 0); |
|
534 |
|
535 // Slideshow plugin used |
|
536 iScreensaverRepository->Set(KScreenSaverPluginName, KPluginUidSlideshow); |
|
537 |
|
538 // Type 3 = plugin |
|
539 iScreensaverRepository->Set(KScreenSaverObject, EScreensaverTypePlugin); |
|
540 |
|
541 // Inform screensaver that slide set has changed |
|
542 User::LeaveIfError( |
|
543 RProperty::Set( |
|
544 KPSUidScreenSaver, |
|
545 KScreenSaverPluginSettingsChanged, |
|
546 EScreenSaverPluginSettingsChanged ) ); |
|
547 } |
|
548 |
|
549 // --------------------------------------------------------------------------- |
|
550 // Set and activate animated screen saver. |
|
551 // --------------------------------------------------------------------------- |
|
552 // |
|
553 void CScreenSaverAIWPlugin::SetAnimatedScreenSaverL( const RArray<TImageFile>& aSupportedImageFiles ) |
|
554 { |
|
555 if (iScreensaverRepository == NULL) |
|
556 { |
|
557 // Setting the screensaver type & plugin name |
|
558 iScreensaverRepository = CRepository::NewL(KCRUidScreenSaver); |
|
559 } |
|
560 |
|
561 if (iAnimationRepository == NULL) |
|
562 { |
|
563 // Setting the screensaver type & plugin name |
|
564 iAnimationRepository = CRepository::NewL(KCRUidScreenSaverAnimPlugin); |
|
565 } |
|
566 |
|
567 iAnimationRepository->Set(KScreenSaverAnimatedFileName, aSupportedImageFiles[0].iFileName); |
|
568 |
|
569 // Animation plugin used |
|
570 iScreensaverRepository->Set(KScreenSaverPluginName, KPluginUidAnimation); |
|
571 |
|
572 // Type 3 = plugin |
|
573 iScreensaverRepository->Set(KScreenSaverObject, EScreensaverTypePlugin); |
|
574 } |
|
575 |
|
576 // --------------------------------------------------------------------------- |
|
577 // Stores slide set image file names to file. |
|
578 // --------------------------------------------------------------------------- |
|
579 // |
|
580 void CScreenSaverAIWPlugin::StoreImageListToFileL( const RArray<TImageFile>& aSupportedImageFiles ) |
|
581 { |
|
582 // Get file from server. |
|
583 RFile imgFile; |
|
584 OpenImageFileL( imgFile, EAknsSrvInifileSSSS ); |
|
585 CleanupClosePushL( imgFile ); |
|
586 |
|
587 // Finally, write image filenames to the file. |
|
588 TFileText textFile; |
|
589 textFile.Set( imgFile ); |
|
590 textFile.Seek( ESeekEnd ); |
|
591 |
|
592 for (TInt i = 0 ; i < aSupportedImageFiles.Count(); i++) |
|
593 { |
|
594 User::LeaveIfError( textFile.Write( aSupportedImageFiles[i].iFileName ) ); |
|
595 } |
|
596 |
|
597 imgFile.Flush(); |
|
598 |
|
599 CleanupStack::PopAndDestroy(); // imgFile |
|
600 } |
|
601 |
|
602 // --------------------------------------------------------------------------- |
|
603 // Open image list file for operations. |
|
604 // --------------------------------------------------------------------------- |
|
605 // |
|
606 void CScreenSaverAIWPlugin::OpenImageFileL( RFile& aImageFile, const TInt aSlideSetType ) |
|
607 { |
|
608 // First, connect to skin server. |
|
609 RAknsSrvSession skinsrv; |
|
610 User::LeaveIfError( skinsrv.Connect() ); |
|
611 CleanupClosePushL( skinsrv ); |
|
612 |
|
613 // Then get file handle. |
|
614 TInt fileserverhandle = 0; |
|
615 TInt filehandle = 0; |
|
616 // Validate type and open image file. |
|
617 if ( aSlideSetType == EAknsSrvInifileSSWP ) |
|
618 { |
|
619 fileserverhandle = |
|
620 skinsrv.OpenImageInifile( EAknsSrvInifileSSWP, filehandle ); |
|
621 } |
|
622 else |
|
623 { |
|
624 fileserverhandle = |
|
625 skinsrv.OpenImageInifile( EAknsSrvInifileSSSS, filehandle ); |
|
626 |
|
627 } |
|
628 if ( fileserverhandle <= 0 || filehandle == 0 ) |
|
629 { |
|
630 User::Leave( fileserverhandle ); |
|
631 } |
|
632 |
|
633 // Finally adopt file from server. |
|
634 User::LeaveIfError( aImageFile.AdoptFromServer( fileserverhandle, filehandle ) ); |
|
635 CleanupStack::PopAndDestroy(); // skinsrv |
|
636 } |
|
637 |
|
638 |
|
639 |
|
640 // ======== ECOM INITIALIZATION ======== |
|
641 |
|
642 // Map the interface UIDs to implementation factory functions |
|
643 const TImplementationProxy ImplementationTable[] = |
|
644 { |
|
645 IMPLEMENTATION_PROXY_ENTRY(KScreenSaverAIWPluginImplementationUid, CScreenSaverAIWPlugin::NewL) |
|
646 }; |
|
647 |
|
648 // --------------------------------------------------------- |
|
649 // Exported proxy for instantiation method resolution |
|
650 // --------------------------------------------------------- |
|
651 // |
|
652 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
653 { |
|
654 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
655 return ImplementationTable; |
|
656 } |
|
657 |