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: This file implements the Screen Saver Animation Plugin which |
|
15 * is used by Screen Saver application to load animation |
|
16 * screen savers. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 #include <eikenv.h> |
|
25 #include <bautils.h> |
|
26 #include <apgcli.h> |
|
27 #include <data_caging_path_literals.hrh> |
|
28 #include <centralrepository.h> |
|
29 #include <DRMHelper.h> |
|
30 #include <aknnotewrappers.h> |
|
31 #include <aknnavi.h> |
|
32 #include <aknnavide.h> |
|
33 #include <npupp.h> |
|
34 #include <CEcomBrowserPluginInterface.h> |
|
35 #include <BrowserPluginInterface.h> |
|
36 #include <mmf/common/mmfcontrollerpluginresolver.h> |
|
37 #include <DRMHelperServerInternalCRKeys.h> |
|
38 #include <NPNExtensions.h> |
|
39 #include <screensaveranimplugin.rsg> |
|
40 #include <coecntrl.h> |
|
41 #include "ScreenSaverAnimPluginInternalCRKeys.h" |
|
42 #include "ScreenSaverAnimPlugin.h" |
|
43 #include "ScreenSaverAnimPluginContainer.h" |
|
44 #include "ScreenSaverAnimSettingDialog.h" |
|
45 #include "NpnImplementation.h" |
|
46 #include "ScreenSaverAnimPluginHelper.h" |
|
47 |
|
48 // Constants |
|
49 #ifdef SCREENSAVER_LOG_ENABLED |
|
50 const TInt KMaxBufLen = 64; |
|
51 #endif |
|
52 const TInt KSixteenBytes = 128; |
|
53 const TInt KUrlMaxLen = 1024; |
|
54 |
|
55 // Animation Timeout values |
|
56 const TInt KMinDurationValue = 1; |
|
57 const TInt KMaxDurationValue = 60; |
|
58 const TInt KDefaultDurationValue = 5; |
|
59 |
|
60 // Backlight Values |
|
61 const TInt KMinBackLightValue = 0; |
|
62 const TInt KMaxBackLightValue = 30; |
|
63 const TInt KDefaultBackLightValue = 0; |
|
64 |
|
65 const TInt KScreensaverAnimPluginInterfaceUid = 0x102750CB; |
|
66 |
|
67 |
|
68 _LIT( KResourceFileName, "Z:ScreenSaverAnimPlugin.rsc" ); |
|
69 |
|
70 |
|
71 CScreenSaverAnimSettingObject::CScreenSaverAnimSettingObject() |
|
72 { |
|
73 iAnimationTimeout = KDefaultDurationValue; |
|
74 iLightsTimeout = KDefaultBackLightValue; |
|
75 } |
|
76 // ============================ MEMBER FUNCTIONS ============================= |
|
77 |
|
78 |
|
79 // --------------------------------------------------------------------------- |
|
80 // CScreenSaverAnimPlugin::NewL |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 CScreenSaverAnimPlugin* CScreenSaverAnimPlugin::NewL() |
|
84 { |
|
85 CScreenSaverAnimPlugin* self = new ( ELeave ) CScreenSaverAnimPlugin; |
|
86 CleanupStack::PushL( self ); |
|
87 self->ConstructL(); |
|
88 CleanupStack::Pop( self ); |
|
89 return self; |
|
90 } |
|
91 |
|
92 // ---------------------------------------------------------------------------- |
|
93 // CScreenSaverAnimPlugin::~CScreenSaverAnimPlugin |
|
94 // ---------------------------------------------------------------------------- |
|
95 // |
|
96 CScreenSaverAnimPlugin::~CScreenSaverAnimPlugin() |
|
97 { |
|
98 if ( iResourceOffset != 0 ) |
|
99 { |
|
100 iEikEnv->DeleteResourceFile( iResourceOffset ); |
|
101 } |
|
102 UnregisterForDrmExpiry(); |
|
103 NotifyCenrepChangeCancel(); |
|
104 UnInitializeCenRep(); |
|
105 |
|
106 // Final place to delete plug-in. Plug-in is deleted here |
|
107 // if plug-in notices runtime error. |
|
108 SetPluginDeleted(); |
|
109 |
|
110 delete iDrmHelper; |
|
111 delete iSettingObject; |
|
112 delete iScreensaverName; |
|
113 } |
|
114 |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // CScreenSaverAnimPlugin::InitializeL |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 TInt CScreenSaverAnimPlugin::InitializeL( MScreensaverPluginHost *aHost ) |
|
121 { |
|
122 |
|
123 if ( !aHost ) |
|
124 { |
|
125 return KErrCancel; |
|
126 } |
|
127 #ifdef SCREENSAVER_LOG_ENABLED |
|
128 _LIT( msg, "InitializeL called " ); |
|
129 PrintDebugMsg( msg ); |
|
130 #endif |
|
131 |
|
132 iScreenSaverHost = aHost; |
|
133 iScreenSaverHost->UseRefreshTimer( EFalse ); |
|
134 |
|
135 #ifdef SCREENSAVER_LOG_ENABLED |
|
136 _LIT( cenrepmsg, "before NotifyCenrepChangeL" ); |
|
137 PrintDebugMsg( cenrepmsg ); |
|
138 #endif |
|
139 |
|
140 NotifyCenrepChangeL(); |
|
141 |
|
142 #ifdef SCREENSAVER_LOG_ENABLED |
|
143 _LIT( cenrepmsg1, "After NotifyCenrepChangeL" ); |
|
144 PrintDebugMsg( cenrepmsg1 ); |
|
145 #endif |
|
146 |
|
147 iScreenSaverHost->OverrideStandardIndicators(); |
|
148 |
|
149 iScreenSaverHost->ExitPartialMode(); |
|
150 |
|
151 #ifdef SCREENSAVER_LOG_ENABLED |
|
152 _LIT( FindPluginLmsg, "before FindPluginL" ); |
|
153 PrintDebugMsg( FindPluginLmsg ); |
|
154 #endif |
|
155 |
|
156 TRAPD( err, FindPluginL( iSettingObject->iFileName ) ) |
|
157 |
|
158 if ( err != KErrNone ) |
|
159 { |
|
160 iScreenSaverHost->RevertToDefaultSaver(); |
|
161 return err; |
|
162 } |
|
163 |
|
164 #ifdef SCREENSAVER_LOG_ENABLED |
|
165 _LIT( FindPluginLmsg1, "After FindPluginL" ); |
|
166 PrintDebugMsg( FindPluginLmsg1 ); |
|
167 #endif |
|
168 |
|
169 return KErrNone; |
|
170 |
|
171 } |
|
172 |
|
173 // ----------------------------------------------------------------------------- |
|
174 // CScreenSaverAnimPlugin::Draw |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 TInt CScreenSaverAnimPlugin::Draw(CWindowGc& /*aGc*/) |
|
178 { |
|
179 return KErrNone; |
|
180 } |
|
181 // ----------------------------------------------------------------------------- |
|
182 // CScreenSaverAnimPlugin::SetWindow |
|
183 // ----------------------------------------------------------------------------- |
|
184 // |
|
185 TInt CScreenSaverAnimPlugin::SetWindow( CCoeControl* aParent ) |
|
186 { |
|
187 |
|
188 iParentControl = aParent; |
|
189 NPWindow window; |
|
190 TInt ret = KErrNone; |
|
191 |
|
192 window.window = STATIC_CAST( MPluginAdapter*, this ); |
|
193 iNPPinstance->ndata = STATIC_CAST( MPluginAdapter*, this ); |
|
194 window.x = 0; /* Position of top left corner relative */ |
|
195 window.y = 0; /* to a netscape page.*/ |
|
196 |
|
197 if ( aParent ) |
|
198 { |
|
199 window.width = aParent->Rect().Width(); /* Max window size */ |
|
200 window.height = aParent->Rect().Height(); |
|
201 window.type = NPWindowTypeDrawable; |
|
202 } |
|
203 |
|
204 if ( iPluginFuncs && !iPluginFuncs->setwindow( iNPPinstance, &window ) ) |
|
205 { |
|
206 ret = KErrNone; |
|
207 } |
|
208 else |
|
209 { |
|
210 ret = KErrGeneral; |
|
211 } |
|
212 return ret; |
|
213 } |
|
214 |
|
215 // ----------------------------------------------------------------------------- |
|
216 // CScreenSaverAnimPlugin::Name |
|
217 // ----------------------------------------------------------------------------- |
|
218 // |
|
219 const TDesC16& CScreenSaverAnimPlugin::Name() const |
|
220 { |
|
221 if ( iScreensaverName ) |
|
222 { |
|
223 return *iScreensaverName; |
|
224 } |
|
225 else |
|
226 { |
|
227 return KNullDesC; |
|
228 } |
|
229 } |
|
230 |
|
231 // ----------------------------------------------------------------------------- |
|
232 // CScreenSaverAnimPlugin::Capabilities |
|
233 // ----------------------------------------------------------------------------- |
|
234 // |
|
235 TInt CScreenSaverAnimPlugin::Capabilities() |
|
236 { |
|
237 return EScpCapsConfigure; |
|
238 } |
|
239 |
|
240 // ----------------------------------------------------------------------------- |
|
241 // CScreenSaverAnimPlugin::PluginFunction |
|
242 // ----------------------------------------------------------------------------- |
|
243 // |
|
244 TInt CScreenSaverAnimPlugin::PluginFunction( |
|
245 TScPluginCaps aFunction, |
|
246 TAny* /*aParam*/) |
|
247 { |
|
248 if ( aFunction == EScpCapsSelectionNotification |
|
249 || aFunction == EScpCapsPreviewNotification ) |
|
250 { |
|
251 _LIT( msg, "Plugin function called Sel Notify" ); |
|
252 PrintDebugMsg( msg ); |
|
253 |
|
254 if ( iSettingObject->iFileName.Length() == 0 || UpdateFileName() ) |
|
255 { |
|
256 // File is not configured yet or deleted/renamed, |
|
257 // pop the settings dialog |
|
258 TInt err = KErrNone; |
|
259 TRAP( err, PopSettingsDialogL() ); |
|
260 return err; |
|
261 } |
|
262 else |
|
263 { |
|
264 return KErrNone; |
|
265 } |
|
266 } |
|
267 if ( aFunction == EScpCapsConfigure ) |
|
268 { |
|
269 _LIT( msg, "Plugin function called Configure" ); |
|
270 PrintDebugMsg( msg ); |
|
271 UpdateFileName(); |
|
272 TInt err = KErrNone; |
|
273 TRAP( err, PopSettingsDialogL() ); |
|
274 return err; |
|
275 } |
|
276 return KErrNone; |
|
277 } |
|
278 |
|
279 // ----------------------------------------------------------------------------- |
|
280 // CScreenSaverAnimPlugin::HandleScreensaverEventL |
|
281 // ----------------------------------------------------------------------------- |
|
282 // |
|
283 TInt CScreenSaverAnimPlugin::HandleScreensaverEventL( |
|
284 TScreensaverEvent aEvent, |
|
285 TAny* /*aData*/ ) |
|
286 { |
|
287 |
|
288 if ( aEvent == EScreensaverEventDisplayChanged ) |
|
289 { |
|
290 // Display Changed is called when there is a change in the size |
|
291 // of the window and when the parent control is set for the |
|
292 // first time. |
|
293 TScreensaverDisplayInfo* displayInfo = new( ELeave ) |
|
294 TScreensaverDisplayInfo; |
|
295 displayInfo->iSize = sizeof( TScreensaverDisplayInfo ); |
|
296 iScreenSaverHost->DisplayInfo( displayInfo ); |
|
297 iParentControl = displayInfo->iParent; |
|
298 delete displayInfo; |
|
299 } |
|
300 |
|
301 if ( aEvent == EScreensaverEventStopping ) |
|
302 { |
|
303 #ifdef SCREENSAVER_LOG_ENABLED |
|
304 _LIT( KStopEventMsg, "Stop Event" ); |
|
305 PrintDebugMsg( KStopEventMsg ); |
|
306 #endif |
|
307 |
|
308 // Delete the Plugin |
|
309 SendEndEvent(); |
|
310 DeletePlugin(); |
|
311 } |
|
312 |
|
313 if ( aEvent == EScreensaverEventStarting ) |
|
314 { |
|
315 #ifdef SCREENSAVER_LOG_ENABLED |
|
316 _LIT( KStartEventMsg, "Start Event" ); |
|
317 PrintDebugMsg( KStartEventMsg ); |
|
318 #endif |
|
319 // Check for drm rights |
|
320 // If the file is not valid, suspend and return |
|
321 if ( iDrmHelper ) |
|
322 { |
|
323 TBool yes = EFalse; |
|
324 iDrmHelper->CanSetAutomated( |
|
325 iSettingObject->iFileName, yes ); |
|
326 if ( !yes ) |
|
327 { |
|
328 iScreenSaverHost->RevertToDefaultSaver(); |
|
329 return KErrNotFound; |
|
330 } |
|
331 } |
|
332 |
|
333 if ( iScreenSaverHost ) |
|
334 { |
|
335 iScreenSaverHost->RequestTimeout( |
|
336 iSettingObject->iAnimationTimeout ); |
|
337 } |
|
338 |
|
339 #ifdef SCREENSAVER_LOG_ENABLED |
|
340 _LIT( KStartMsg, "Starting" ); |
|
341 PrintDebugMsg( KStartMsg ); |
|
342 #endif |
|
343 |
|
344 // Reset plugin creation error |
|
345 // The plugin cannot leave or return error |
|
346 // The plugin sets the error using pluginFinishedL |
|
347 iPluginError = KErrNone; |
|
348 // Create the plugin |
|
349 TRAPD( err,CreatePluginL() ); |
|
350 if ( err != KErrNone ) |
|
351 { |
|
352 DeletePlugin(); |
|
353 return err; |
|
354 } |
|
355 |
|
356 // Check whether the plugin has |
|
357 // reported any error using PluginFinishedL |
|
358 if ( iPluginError ) |
|
359 { |
|
360 SetPluginDeleted(); |
|
361 return iPluginError; |
|
362 } |
|
363 |
|
364 #ifdef SCREENSAVER_LOG_ENABLED |
|
365 _LIT( KStartedMsg, "Started" ); |
|
366 PrintDebugMsg( KStartedMsg ); |
|
367 #endif |
|
368 |
|
369 // send an event to plugins |
|
370 if ( iPluginFuncs ) |
|
371 { |
|
372 NPAnimationEvent event; |
|
373 event = NPStartAnimation; |
|
374 iPluginFuncs->setvalue( iNPPinstance, |
|
375 ( NPNVariable )NPNScreenSaverAnimationEvent, |
|
376 &event ); |
|
377 } |
|
378 |
|
379 // Request lights only if set - otherwise it will turn off lights |
|
380 // (e.g. in preview). Not nice. |
|
381 TInt nLights = iSettingObject->iLightsTimeout; |
|
382 |
|
383 if ( nLights > 0 ) |
|
384 { |
|
385 iScreenSaverHost->RequestLights( nLights ); |
|
386 } |
|
387 } |
|
388 |
|
389 if ( aEvent == EScreensaverEventTimeout ) |
|
390 { |
|
391 #ifdef SCREENSAVER_LOG_ENABLED |
|
392 _LIT( KTimeoutEventMsg, "Timeout Event" ); |
|
393 PrintDebugMsg( KTimeoutEventMsg ); |
|
394 #endif |
|
395 // Delete the Plugin |
|
396 SendEndEvent(); |
|
397 DeletePlugin(); |
|
398 iScreenSaverHost->Suspend( -1) ; |
|
399 } |
|
400 |
|
401 return KErrNone; |
|
402 } |
|
403 |
|
404 // ----------------------------------------------------------------------------- |
|
405 // CScreenSaverAnimPlugin::GetAnimSettings |
|
406 // ----------------------------------------------------------------------------- |
|
407 // |
|
408 TInt CScreenSaverAnimPlugin::GetAnimSettings() |
|
409 { |
|
410 // Read the file last, since if it is missing the reading will be |
|
411 // stopped and settings all wrong |
|
412 TInt err = iAnimPluginSession->Get( KScreenSaverAnimationTimeOut, |
|
413 iSettingObject->iAnimationTimeout ); |
|
414 |
|
415 if ( iSettingObject->iAnimationTimeout < KMinDurationValue || |
|
416 iSettingObject->iAnimationTimeout > KMaxDurationValue ) |
|
417 { |
|
418 // Out of range set it to default |
|
419 iSettingObject->iAnimationTimeout = KDefaultDurationValue; |
|
420 } |
|
421 |
|
422 if ( err != KErrNone ) |
|
423 { |
|
424 return err; |
|
425 } |
|
426 |
|
427 err = iAnimPluginSession->Get( KScreenSaverLightsTimeOut, |
|
428 iSettingObject->iLightsTimeout ); |
|
429 |
|
430 if ( iSettingObject->iLightsTimeout < KMinBackLightValue || |
|
431 iSettingObject->iLightsTimeout > KMaxBackLightValue ) |
|
432 { |
|
433 // Out of range set it to default |
|
434 iSettingObject->iLightsTimeout = KDefaultBackLightValue; |
|
435 } |
|
436 |
|
437 if ( err != KErrNone ) |
|
438 { |
|
439 return err; |
|
440 } |
|
441 |
|
442 // read the file from central repository and return |
|
443 err = iAnimPluginSession->Get( KScreenSaverAnimatedFileName, |
|
444 iSettingObject->iFileName ); |
|
445 |
|
446 if ( err != KErrNone ) |
|
447 { |
|
448 return err; |
|
449 } |
|
450 |
|
451 if ( !BaflUtils::FileExists( iEikEnv->FsSession(), |
|
452 iSettingObject->iFileName ) ) |
|
453 { |
|
454 return KErrNotFound; |
|
455 } |
|
456 |
|
457 TBool yes = EFalse; |
|
458 if ( iDrmHelper ) |
|
459 { |
|
460 TInt err = iDrmHelper->CanSetAutomated( |
|
461 iSettingObject->iFileName, yes ); |
|
462 if ( !yes ) |
|
463 { |
|
464 return KErrNotFound; |
|
465 } |
|
466 } |
|
467 |
|
468 return err; |
|
469 } |
|
470 |
|
471 // ----------------------------------------------------------------------------- |
|
472 // CScreenSaverAnimPlugin::SetAnimSettings |
|
473 // ----------------------------------------------------------------------------- |
|
474 // |
|
475 TInt CScreenSaverAnimPlugin::SetAnimSettings() const |
|
476 { |
|
477 |
|
478 TInt err = KErrNone; |
|
479 err = iAnimPluginSession->Set( KScreenSaverAnimatedFileName, |
|
480 iSettingObject->iFileName ); |
|
481 if ( err != KErrNone ) |
|
482 { |
|
483 return err; |
|
484 } |
|
485 err = iAnimPluginSession->Set( KScreenSaverAnimationTimeOut, |
|
486 iSettingObject->iAnimationTimeout ); |
|
487 |
|
488 if ( err != KErrNone ) |
|
489 { |
|
490 return err; |
|
491 } |
|
492 |
|
493 err = iAnimPluginSession->Set( KScreenSaverLightsTimeOut, |
|
494 iSettingObject->iLightsTimeout ); |
|
495 |
|
496 return err; |
|
497 |
|
498 } |
|
499 |
|
500 // ----------------------------------------------------------------------------- |
|
501 // CScreenSaverAnimPlugin::RegisterForDrmExpiry |
|
502 // ----------------------------------------------------------------------------- |
|
503 // |
|
504 TInt CScreenSaverAnimPlugin::RegisterForDrmExpiry() |
|
505 { |
|
506 TInt err = iDrmHelper->SetAutomatedType( |
|
507 CDRMHelper::EAutomatedTypeScreenSaver ); |
|
508 if ( err == KErrNone ) |
|
509 { |
|
510 return iDrmHelper->SetAutomatedSilent( iSettingObject->iFileName, |
|
511 ETrue ); |
|
512 } |
|
513 else |
|
514 { |
|
515 return err; |
|
516 } |
|
517 } |
|
518 |
|
519 // ----------------------------------------------------------------------------- |
|
520 // CScreenSaverAnimPlugin::UnregisterForDrmExpiry |
|
521 // ----------------------------------------------------------------------------- |
|
522 // |
|
523 TInt CScreenSaverAnimPlugin::UnregisterForDrmExpiry() |
|
524 { |
|
525 if ( iDrmHelper ) |
|
526 { |
|
527 iDrmHelper->SetAutomatedType( |
|
528 CDRMHelper::EAutomatedTypeScreenSaver ); |
|
529 return iDrmHelper->RemoveAutomated( iSettingObject->iFileName ); |
|
530 } |
|
531 else |
|
532 { |
|
533 return KErrNone; |
|
534 } |
|
535 } |
|
536 |
|
537 // ----------------------------------------------------------------------------- |
|
538 // CScreenSaverAnimPlugin::ReadDrmNotification |
|
539 // ----------------------------------------------------------------------------- |
|
540 // |
|
541 TInt CScreenSaverAnimPlugin::ReadDrmNotification( TDes8& aString ) |
|
542 { |
|
543 return iDrmSession->Get( KDRMHelperServerNotification, aString ); |
|
544 } |
|
545 |
|
546 // ----------------------------------------------------------------------------- |
|
547 // CScreenSaverAnimPlugin::ProcessDrmNotificationL |
|
548 // ----------------------------------------------------------------------------- |
|
549 // |
|
550 void CScreenSaverAnimPlugin::ProcessDrmNotificationL() |
|
551 { |
|
552 |
|
553 TInt size = KSixteenBytes; |
|
554 HBufC8* buf = HBufC8::NewLC( size ); |
|
555 TPtr8 bufPtr = buf->Des(); |
|
556 |
|
557 TInt error = ReadDrmNotification( bufPtr ); |
|
558 while ( error == KErrTooBig ) |
|
559 { |
|
560 size += KSixteenBytes; |
|
561 CleanupStack::PopAndDestroy( buf ); // buf |
|
562 buf = HBufC8::NewLC( size ); |
|
563 bufPtr = buf->Des(); |
|
564 error = ReadDrmNotification( bufPtr ); |
|
565 } |
|
566 |
|
567 TUint8 count = ( TUint8 )( *( buf->Ptr() ) ); |
|
568 TChar type = ( TUint8 )( *( buf->Ptr() + 1 ) ); |
|
569 |
|
570 TUint8 permType = ( TUint8 )( *( buf->Ptr() + 2 ) ); |
|
571 TUint8 autoType = ( TUint8 )( *( buf->Ptr() + 3 ) ); |
|
572 |
|
573 TPtr8 ptr( ( TUint8* ) ( buf->Ptr() + 4 ) , buf->Length() - 5 , buf->Length() - 5 ); |
|
574 HBufC8* content = HBufC8::NewLC( ptr.Length() ); |
|
575 *content = ptr; |
|
576 |
|
577 TBool matched = CheckContentIdL( iSettingObject->iFileName, *content ); |
|
578 |
|
579 CleanupStack::PopAndDestroy( content ); |
|
580 CleanupStack::PopAndDestroy( buf ); |
|
581 |
|
582 if ( !matched ) |
|
583 { |
|
584 return; |
|
585 } |
|
586 |
|
587 if ( type == 'E') |
|
588 { |
|
589 if ( count == 0 ) |
|
590 { |
|
591 #ifdef SCREENSAVER_LOG_ENABLED |
|
592 _LIT( msg, "First Notification" ); |
|
593 PrintDebugMsg( msg ); |
|
594 #endif |
|
595 |
|
596 // Expire screen saver here..., no note |
|
597 if ( iScreenSaverHost ) |
|
598 { |
|
599 SendEndEvent(); |
|
600 // Delete the Plugin |
|
601 DeletePlugin(); |
|
602 iScreenSaverHost->Suspend(-1); |
|
603 } |
|
604 } |
|
605 else |
|
606 { |
|
607 #ifdef SCREENSAVER_LOG_ENABLED |
|
608 _LIT( msg, "Second Notification" ); |
|
609 PrintDebugMsg( msg ); |
|
610 #endif |
|
611 |
|
612 // Show expiration notes... |
|
613 iDrmHelper->SetAutomatedType( |
|
614 CDRMHelper::EAutomatedTypeScreenSaver ); |
|
615 iDrmHelper->CheckRightsAmountL( iSettingObject->iFileName ); |
|
616 UnregisterForDrmExpiry(); |
|
617 } |
|
618 } |
|
619 } |
|
620 |
|
621 // ----------------------------------------------------------------------------- |
|
622 // CScreenSaverAnimPlugin::FindAndStartPluginL |
|
623 // ----------------------------------------------------------------------------- |
|
624 // |
|
625 void CScreenSaverAnimPlugin::FindAndStartPluginL( const TDesC& aFileName, |
|
626 TBool aCheckFileMode ) |
|
627 { |
|
628 FindPluginL( aFileName ); |
|
629 CreatePluginL( aCheckFileMode ); |
|
630 } |
|
631 |
|
632 // ----------------------------------------------------------------------------- |
|
633 // CScreenSaverAnimPlugin::FindPluginL |
|
634 // ----------------------------------------------------------------------------- |
|
635 // |
|
636 void CScreenSaverAnimPlugin::FindPluginL( const TDesC& aFileName ) |
|
637 { |
|
638 |
|
639 RApaLsSession ls; |
|
640 CleanupClosePushL( ls ); |
|
641 TUid dummyUid( KNullUid ); |
|
642 TDataType dataType; |
|
643 User::LeaveIfError( ls.Connect() ); |
|
644 User::LeaveIfError( ls.AppForDocument( aFileName, |
|
645 dummyUid, dataType ) ); |
|
646 CleanupStack::PopAndDestroy( &ls ); |
|
647 |
|
648 #ifdef SCREENSAVER_LOG_ENABLED |
|
649 _LIT( msg, "before FindAnimPluginL" ); |
|
650 PrintDebugMsg( msg ); |
|
651 #endif |
|
652 |
|
653 iPluginUID = FindAnimPluginL( dataType.Des() ); |
|
654 |
|
655 #ifdef SCREENSAVER_LOG_ENABLED |
|
656 _LIT( msg1, "After FindAnimPluginL" ); |
|
657 PrintDebugMsg( msg1 ); |
|
658 #endif |
|
659 |
|
660 if ( iPluginUID == KNullUid ) |
|
661 { |
|
662 User::Leave( KErrNotFound ); |
|
663 } |
|
664 |
|
665 #ifdef SCREENSAVER_LOG_ENABLED |
|
666 _LIT( registermsg, "Before RegisterForDrmExpiry" ); |
|
667 PrintDebugMsg( registermsg ); |
|
668 #endif |
|
669 |
|
670 RegisterForDrmExpiry(); |
|
671 |
|
672 #ifdef SCREENSAVER_LOG_ENABLED |
|
673 _LIT( registermsg1, "After RegisterForDrmExpiry" ); |
|
674 PrintDebugMsg( registermsg1 ); |
|
675 #endif |
|
676 |
|
677 } |
|
678 |
|
679 // ----------------------------------------------------------------------------- |
|
680 // CScreenSaverAnimPlugin::CreatePluginL |
|
681 // ----------------------------------------------------------------------------- |
|
682 // |
|
683 void CScreenSaverAnimPlugin::CreatePluginL( TBool aCheckFileMode ) |
|
684 { |
|
685 |
|
686 /* Create the Netscape plugin for the animation format. |
|
687 * Allocate memory for the plugin functions array. This |
|
688 * would be filled by the netscape plugin. |
|
689 * Initialize the plugin. |
|
690 */ |
|
691 |
|
692 iPluginFuncs = |
|
693 ( NPPluginFuncs* ) User::AllocL( sizeof( NPPluginFuncs ) ); |
|
694 Mem::FillZ( ( void* )iPluginFuncs, sizeof( NPPluginFuncs ) ); |
|
695 |
|
696 iNPPinstance = ( NPP ) User::AllocL( sizeof( NPP_t ) ); |
|
697 Mem::FillZ( ( void* )iNPPinstance, sizeof( NPP_t ) ); |
|
698 |
|
699 iPluginType = ( HBufC8* )User::AllocL( sizeof( NPMIMEType ) ); |
|
700 Mem::FillZ( ( void* )iPluginType, sizeof( NPMIMEType ) ); |
|
701 |
|
702 TRAPD( err, iPluginInterface = |
|
703 CEcomBrowserPluginInterface::CreatePluginL( iPluginUID, |
|
704 ( NPNetscapeFuncs* ) ( &NpnImplementationFuncs ), |
|
705 iPluginFuncs ) ); |
|
706 |
|
707 if ( err != KErrNone ) |
|
708 { |
|
709 SetPluginDeleted(); |
|
710 User::Leave( err ); |
|
711 } |
|
712 |
|
713 #ifdef SCREENSAVER_LOG_ENABLED |
|
714 _LIT( newpmsg, "Before newp" ); |
|
715 PrintDebugMsg( newpmsg ); |
|
716 #endif |
|
717 |
|
718 // Create an instance. |
|
719 // Flash Plugin needs the NPInteractionMode in the newp |
|
720 |
|
721 CDesCArrayFlat* attributeNames = new( ELeave ) CDesCArrayFlat( 1 ); |
|
722 CDesCArrayFlat* attributeValues = new( ELeave ) CDesCArrayFlat( 1 ); |
|
723 attributeNames->AppendL( KAttributeInteractionMode ); |
|
724 attributeValues->AppendL( KValueScreensaver ); |
|
725 |
|
726 User::LeaveIfError( iPluginFuncs->newp( *iPluginType, iNPPinstance, |
|
727 0 /*mode*/, |
|
728 attributeNames /*argn*/, |
|
729 attributeValues /*argv*/, |
|
730 NULL /*saved*/ ) ); |
|
731 |
|
732 delete attributeNames; |
|
733 delete attributeValues; |
|
734 |
|
735 #ifdef SCREENSAVER_LOG_ENABLED |
|
736 _LIT( newpmsg1, "After newp" ); |
|
737 PrintDebugMsg( newpmsg1 ); |
|
738 #endif |
|
739 |
|
740 // Set ScreenSaver Mode |
|
741 if ( iPluginFuncs ) |
|
742 { |
|
743 NPInteractionMode mode; |
|
744 mode = NPScreenSaverMode; |
|
745 iPluginFuncs->setvalue( iNPPinstance, |
|
746 ( NPNVariable )NPNInteractionMode, |
|
747 &mode ); |
|
748 } |
|
749 |
|
750 if ( !aCheckFileMode ) |
|
751 { |
|
752 SetWindow( iParentControl ); |
|
753 AsFile(); |
|
754 } |
|
755 |
|
756 } |
|
757 |
|
758 // ----------------------------------------------------------------------------- |
|
759 // CScreenSaverAnimPlugin::FindAnimPluginL |
|
760 // ----------------------------------------------------------------------------- |
|
761 // |
|
762 TUid CScreenSaverAnimPlugin::FindAnimPluginL( const TDesC& aDataType ) |
|
763 { |
|
764 |
|
765 TUid impUid = KNullUid; |
|
766 |
|
767 TResourceReader reader; |
|
768 iEikEnv->CreateResourceReaderLC( reader, R_MIMETYPE_SPECIFIC_PLUGIN_ARRAY ); |
|
769 TInt countResource = reader.ReadInt16(); |
|
770 |
|
771 for ( TInt i = 0; i < countResource; i++ ) |
|
772 { |
|
773 HBufC* newMimeTypeEntry = reader.ReadHBufCL(); |
|
774 TPtr mimePtr( newMimeTypeEntry->Des() ); |
|
775 impUid.iUid = reader.ReadInt32(); |
|
776 if ( newMimeTypeEntry->Compare( aDataType ) == 0 ) |
|
777 { |
|
778 delete newMimeTypeEntry; |
|
779 break; |
|
780 } |
|
781 else |
|
782 { |
|
783 delete newMimeTypeEntry; |
|
784 } |
|
785 } |
|
786 CleanupStack::PopAndDestroy(); // reader |
|
787 |
|
788 if ( CheckIfPluginPresentL( KBrowserPluginInterfaceUid, impUid ) || |
|
789 CheckIfPluginPresentL( TUid::Uid( KScreensaverAnimPluginInterfaceUid ),impUid ) ) |
|
790 { |
|
791 return impUid; |
|
792 } |
|
793 |
|
794 return KNullUid; |
|
795 } |
|
796 |
|
797 // ----------------------------------------------------------------------------- |
|
798 // CScreenSaverAnimPlugin::CheckIfPluginPresentL |
|
799 // ----------------------------------------------------------------------------- |
|
800 // |
|
801 TBool CScreenSaverAnimPlugin::CheckIfPluginPresentL( TUid aInterfaceUid , |
|
802 TUid aImpUid ) |
|
803 { |
|
804 TBool ret( EFalse ); |
|
805 RImplInfoPtrArray animPluginList; |
|
806 |
|
807 REComSession::ListImplementationsL( aInterfaceUid, animPluginList ); |
|
808 |
|
809 const TInt count = animPluginList.Count(); |
|
810 |
|
811 for ( TInt i = 0; i < count; i++ ) |
|
812 { |
|
813 CImplementationInformation* implInfo = animPluginList[i]; |
|
814 if ( aImpUid == implInfo->ImplementationUid() ) |
|
815 { |
|
816 ret = ETrue; |
|
817 break; |
|
818 } |
|
819 } |
|
820 animPluginList.ResetAndDestroy(); |
|
821 return ret; |
|
822 } |
|
823 |
|
824 // ----------------------------------------------------------------------------- |
|
825 // CScreenSaverAnimPlugin::ParseMimeStringL |
|
826 // ----------------------------------------------------------------------------- |
|
827 // |
|
828 TBool CScreenSaverAnimPlugin::ParseMimeStringL( const TDesC& aMIMEDescription, |
|
829 const TDesC& aDataType ) |
|
830 { |
|
831 |
|
832 if ( aMIMEDescription.Length() == 0 || |
|
833 aDataType.Length() == 0 ) |
|
834 { |
|
835 return EFalse; |
|
836 } |
|
837 |
|
838 _LIT( KPattern1Ptr, ",;|" ); |
|
839 _LIT( KPattern2Ptr, ";|" ); |
|
840 |
|
841 TUint end( aMIMEDescription.Length() ); |
|
842 TUint i( 0 ); |
|
843 TUint marker( 0 ); |
|
844 TUint16 mimeSeparator( '|' ); |
|
845 TUint fieldSeparator( ';' ); |
|
846 HBufC* newMimeTypeEntry = NULL; |
|
847 |
|
848 // Parse the aMIMEDescription string to populate the mimeTypes |
|
849 for ( ; i < end; ) // outer for loop |
|
850 { |
|
851 // Search until end of buffer or match one of the delimiters ';' or '|'. |
|
852 // We are looking for the mimeType, ie "text/html", |
|
853 // "application/pdf", etc. |
|
854 for ( ; ( i < end ) && ( KPattern2Ptr().Locate( ( aMIMEDescription )[i] ) == |
|
855 KErrNotFound ); i++ ) |
|
856 { |
|
857 // Walking the aMIMEDescription string |
|
858 } |
|
859 |
|
860 if ( i > marker ) |
|
861 { |
|
862 // Create new mimeType entry, the first entry is mimeType |
|
863 newMimeTypeEntry = HBufC::NewLC( i - marker ); |
|
864 TPtr mimePtr( newMimeTypeEntry->Des() ); |
|
865 mimePtr.Copy( aMIMEDescription.Mid( marker, i - marker ) ); |
|
866 if ( newMimeTypeEntry->Compare( aDataType ) == 0 ) |
|
867 { |
|
868 CleanupStack::PopAndDestroy( newMimeTypeEntry ); //newMimeTypeEntry |
|
869 return ETrue; |
|
870 } |
|
871 CleanupStack::PopAndDestroy( newMimeTypeEntry ); //newMimeTypeEntry |
|
872 } |
|
873 |
|
874 // Are we at the end of the supported mime string |
|
875 if ( i == end ) |
|
876 { |
|
877 // This break with i=end means we leave outer for loop |
|
878 break; |
|
879 } |
|
880 |
|
881 marker = ++i; |
|
882 if ( ( aMIMEDescription )[i - 1] == mimeSeparator ) |
|
883 { |
|
884 // Found a mime separator '|', get next supported mime |
|
885 continue; |
|
886 } |
|
887 |
|
888 // There can be multiple mimeFileExtentions per mimeType |
|
889 for ( ; ( i < end ); ) // inner for loop |
|
890 { |
|
891 // Search until end of buffer or match one of the delimiters |
|
892 // ';' or ',' or '|'. |
|
893 for ( ; (i < end) && ( KPattern1Ptr().Locate( ( aMIMEDescription )[i] ) == |
|
894 KErrNotFound ); i++ ) |
|
895 { |
|
896 // Walking the aMIMEDescription string |
|
897 } |
|
898 |
|
899 // Are we at the end of the supported mime string |
|
900 if ( i == end ) |
|
901 { |
|
902 // This break means we leave the inner loop, |
|
903 // and with i=end means |
|
904 // we leave the outer loop |
|
905 break; |
|
906 } |
|
907 |
|
908 marker = ++i; |
|
909 if ( ( aMIMEDescription )[i - 1] == mimeSeparator ) |
|
910 { |
|
911 // Found a mime separator '|', get next supported mime |
|
912 break; |
|
913 } |
|
914 |
|
915 if ( ( aMIMEDescription )[i - 1] == fieldSeparator ) |
|
916 { |
|
917 // Found a field separator ';', get the mimeDescription. |
|
918 // Search until end of buffer or match one of the |
|
919 // delimiters ';' or '|'. |
|
920 for ( ; (i < end) && |
|
921 ( KPattern2Ptr().Locate( ( aMIMEDescription )[i] ) == |
|
922 KErrNotFound ); i++ ) |
|
923 { |
|
924 // Walking the aMIMEDescription string |
|
925 } |
|
926 |
|
927 |
|
928 // Are we at the end of the supported mime string |
|
929 if ( i == end ) |
|
930 { |
|
931 // This break means we leave the inner loop, |
|
932 // and with i=end means |
|
933 // we leave the outer loop |
|
934 break; |
|
935 } |
|
936 |
|
937 marker = ++i; |
|
938 // Make sure we start at the next mime, |
|
939 // after we found the mimeDescription. |
|
940 // We are handling a mime string with an extra semi-colon(s), |
|
941 // ie "...mimeDescription1;|mimeType2 |
|
942 for (; (i < end) && |
|
943 ((aMIMEDescription)[i-1] != mimeSeparator); i++) |
|
944 { |
|
945 // Walking the aMIMEDescription string |
|
946 } |
|
947 |
|
948 // Leave the inner loop and look for the next mime |
|
949 break; |
|
950 } // end of if fieldSeparator aka get mimeDescription |
|
951 |
|
952 // If we get here, we have another mimeFileExtension. |
|
953 // Continue on the |
|
954 // inner loop to find additional mimeFileExtensions. |
|
955 |
|
956 } // end of inner for (;i<end;) |
|
957 } // end of outer for (;i<end;) |
|
958 |
|
959 return EFalse; |
|
960 |
|
961 } |
|
962 |
|
963 // ----------------------------------------------------------------------------- |
|
964 // CScreenSaverAnimPlugin::DeletePlugin |
|
965 // ----------------------------------------------------------------------------- |
|
966 // |
|
967 void CScreenSaverAnimPlugin::DeletePlugin() |
|
968 { |
|
969 #ifdef SCREENSAVER_LOG_ENABLED |
|
970 _LIT( msg, "delete called " ); |
|
971 PrintDebugMsg( msg ); |
|
972 #endif |
|
973 if ( iPluginFuncs ) |
|
974 { |
|
975 iPluginFuncs->destroy( iNPPinstance, NULL ); |
|
976 } |
|
977 SetPluginDeleted(); |
|
978 } |
|
979 // ----------------------------------------------------------------------------- |
|
980 // CScreenSaverAnimPlugin::SetPluginDeleted |
|
981 // ----------------------------------------------------------------------------- |
|
982 // |
|
983 void CScreenSaverAnimPlugin::SetPluginDeleted() |
|
984 { |
|
985 |
|
986 delete iPluginType; |
|
987 iPluginType = NULL; |
|
988 |
|
989 delete iPluginFuncs; |
|
990 iPluginFuncs = NULL; |
|
991 |
|
992 delete iNPPinstance; |
|
993 iNPPinstance = NULL; |
|
994 |
|
995 delete iPluginInterface; |
|
996 iPluginInterface = NULL; |
|
997 |
|
998 } |
|
999 |
|
1000 // ----------------------------------------------------------------------------- |
|
1001 // CScreenSaverAnimPlugin::AsFile |
|
1002 // ----------------------------------------------------------------------------- |
|
1003 // |
|
1004 void CScreenSaverAnimPlugin::AsFile() |
|
1005 { |
|
1006 |
|
1007 // Set the File-name to the plugin. |
|
1008 // Note that the SVG-T plugin atleast wants setwindow |
|
1009 // to be called first |
|
1010 iPluginFuncs->asfile( iNPPinstance, NULL, iSettingObject->iFileName ); |
|
1011 } |
|
1012 |
|
1013 // ----------------------------------------------------------------------------- |
|
1014 // CScreenSaverAnimPlugin::UpdateFileName |
|
1015 // ----------------------------------------------------------------------------- |
|
1016 // |
|
1017 TBool CScreenSaverAnimPlugin::UpdateFileName() |
|
1018 { |
|
1019 if ( !BaflUtils::FileExists( iEikEnv->FsSession(), |
|
1020 iSettingObject->iFileName ) ) |
|
1021 { |
|
1022 // File is deleted now, Show empty string |
|
1023 iSettingObject->iFileName.Copy( KEmptyString ); |
|
1024 return ETrue; |
|
1025 } |
|
1026 |
|
1027 TBool canbeautomated( EFalse ); |
|
1028 |
|
1029 TInt res = 0; |
|
1030 iDrmHelper->SetAutomatedType( |
|
1031 CDRMHelper::EAutomatedTypeScreenSaver ); |
|
1032 res = iDrmHelper->CanSetAutomated( iSettingObject->iFileName, |
|
1033 canbeautomated ); |
|
1034 |
|
1035 if ( res || !canbeautomated ) |
|
1036 { |
|
1037 iSettingObject->iFileName.Copy( KEmptyString ); |
|
1038 return ETrue; |
|
1039 } |
|
1040 return EFalse; |
|
1041 } |
|
1042 |
|
1043 // ----------------------------------------------------------------------------- |
|
1044 // CScreenSaverAnimPlugin::PopSettingsDialogL |
|
1045 // ----------------------------------------------------------------------------- |
|
1046 // |
|
1047 void CScreenSaverAnimPlugin::PopSettingsDialogL() |
|
1048 { |
|
1049 #ifdef SCREENSAVER_LOG_ENABLED |
|
1050 _LIT( msg, "Pop Settings Dialog" ); |
|
1051 PrintDebugMsg( msg ); |
|
1052 #endif |
|
1053 |
|
1054 // Get the Status Pane Control |
|
1055 CEikStatusPane* sp = iEikEnv->AppUiFactory()->StatusPane(); |
|
1056 |
|
1057 // Fetch pointer to the default navi pane control |
|
1058 CAknNavigationControlContainer* NaviPane = |
|
1059 ( CAknNavigationControlContainer* )sp->ControlL( |
|
1060 TUid::Uid( EEikStatusPaneUidNavi ) ); |
|
1061 |
|
1062 NaviPane->PushDefaultL( ETrue ); |
|
1063 |
|
1064 CScreenSaverAnimSettingDialog* dlg = |
|
1065 CScreenSaverAnimSettingDialog::NewL( this, iSettingObject ); |
|
1066 |
|
1067 #ifdef SCREENSAVER_LOG_ENABLED |
|
1068 _LIT( msg1, "dlg created Call executeld" ); |
|
1069 PrintDebugMsg( msg1 ); |
|
1070 #endif |
|
1071 |
|
1072 dlg->ExecuteLD(); |
|
1073 |
|
1074 NaviPane->Pop(); |
|
1075 |
|
1076 #ifdef SCREENSAVER_LOG_ENABLED |
|
1077 _LIT( msg2, "Executed dlg, write to cenrep" ); |
|
1078 PrintDebugMsg( msg2 ); |
|
1079 #endif |
|
1080 |
|
1081 User::LeaveIfError( SetAnimSettings() ); |
|
1082 |
|
1083 // Check if a file is selected |
|
1084 if ( iSettingObject->iFileName.Length() == 0 ) |
|
1085 { |
|
1086 // Don't Pop an error note |
|
1087 // Just leave |
|
1088 User::Leave( KErrCancel ) ; |
|
1089 } |
|
1090 } |
|
1091 |
|
1092 // ----------------------------------------------------------------------------- |
|
1093 // CScreenSaverAnimPlugin::HandleRepositoryCallBack |
|
1094 // ----------------------------------------------------------------------------- |
|
1095 // |
|
1096 TInt CScreenSaverAnimPlugin::HandleRepositoryCallBack( TAny* aPtr ) |
|
1097 { |
|
1098 STATIC_CAST( CScreenSaverAnimPlugin*, aPtr )->HandleSettingsChange( aPtr ); |
|
1099 return KErrNone; |
|
1100 } |
|
1101 |
|
1102 // ----------------------------------------------------------------------------- |
|
1103 // CScreenSaverAnimPlugin::HandleRepositoryCallBack |
|
1104 // ----------------------------------------------------------------------------- |
|
1105 // |
|
1106 TInt CScreenSaverAnimPlugin::HandleDrmNotification( TAny* aPtr ) |
|
1107 { |
|
1108 TRAPD( err, STATIC_CAST( CScreenSaverAnimPlugin*, aPtr ) |
|
1109 ->ProcessDrmNotificationL() ); |
|
1110 return err; |
|
1111 } |
|
1112 |
|
1113 // ----------------------------------------------------------------------------- |
|
1114 // CScreenSaverAnimPlugin::HandleSettingsChange |
|
1115 // ----------------------------------------------------------------------------- |
|
1116 // |
|
1117 void CScreenSaverAnimPlugin::HandleSettingsChange( TAny* /*aPtr*/ ) |
|
1118 { |
|
1119 if ( iScreensaverRepositoryWatcher ) |
|
1120 { |
|
1121 if ( iScreensaverRepositoryWatcher->ChangedKey() == |
|
1122 KScreenSaverAnimationTimeOut ) |
|
1123 { |
|
1124 // Update the iSettingObject |
|
1125 iAnimPluginSession->Get( KScreenSaverAnimationTimeOut, |
|
1126 iSettingObject->iAnimationTimeout ); |
|
1127 } |
|
1128 if ( iScreensaverRepositoryWatcher->ChangedKey() == |
|
1129 KScreenSaverLightsTimeOut ) |
|
1130 { |
|
1131 // Update the iSettingObject |
|
1132 iAnimPluginSession->Get( KScreenSaverLightsTimeOut, |
|
1133 iSettingObject->iLightsTimeout ); |
|
1134 } |
|
1135 |
|
1136 if ( iScreensaverRepositoryWatcher->ChangedKey() == |
|
1137 KScreenSaverAnimatedFileName ) |
|
1138 { |
|
1139 UnregisterForDrmExpiry(); |
|
1140 iAnimPluginSession->Get( KScreenSaverAnimatedFileName, |
|
1141 iSettingObject->iFileName ); |
|
1142 // Find the Plugin for the new file |
|
1143 TInt err; |
|
1144 TRAP( err, FindPluginL( iSettingObject->iFileName ) ); |
|
1145 if ( err != KErrNone ) |
|
1146 { |
|
1147 NotifyCenrepChangeCancel(); |
|
1148 iScreenSaverHost->RevertToDefaultSaver(); |
|
1149 return; |
|
1150 } |
|
1151 } |
|
1152 } |
|
1153 } |
|
1154 |
|
1155 // ----------------------------------------------------------------------------- |
|
1156 // CScreenSaverAnimPlugin::InitializeCenRepL |
|
1157 // ----------------------------------------------------------------------------- |
|
1158 // |
|
1159 void CScreenSaverAnimPlugin::InitializeCenRepL() |
|
1160 { |
|
1161 |
|
1162 TRAPD( err, iAnimPluginSession = |
|
1163 CRepository::NewL( KCRUidScreenSaverAnimPlugin ) ); |
|
1164 #ifdef SCREENSAVER_LOG_ENABLED |
|
1165 TBuf<KMaxBufLen> buffer; |
|
1166 _LIT( msg, "After SS Cenrep Init : %d" ); |
|
1167 buffer.Format( msg, err ); |
|
1168 PrintDebugMsg( buffer ); |
|
1169 #endif |
|
1170 User::LeaveIfError( err ); |
|
1171 |
|
1172 TRAPD( err1, iDrmSession = CRepository::NewL( KCRUidDRMHelperServer ) ); |
|
1173 #ifdef SCREENSAVER_LOG_ENABLED |
|
1174 TBuf<KMaxBufLen> buffer1; |
|
1175 _LIT( msg1, "After DRM Cenrep Init : %d" ); |
|
1176 buffer1.Format( msg1, err1 ); |
|
1177 PrintDebugMsg( buffer1 ); |
|
1178 #endif |
|
1179 User::LeaveIfError( err1 ); |
|
1180 |
|
1181 } |
|
1182 // ----------------------------------------------------------------------------- |
|
1183 // CScreenSaverAnimPlugin::NotifyCenrepChangeL |
|
1184 // ----------------------------------------------------------------------------- |
|
1185 // |
|
1186 void CScreenSaverAnimPlugin::NotifyCenrepChangeL() |
|
1187 { |
|
1188 |
|
1189 iScreensaverRepositoryWatcher = CScreensaverRepositoryWatcher::NewL( |
|
1190 KCRUidScreenSaverAnimPlugin, |
|
1191 TCallBack( HandleRepositoryCallBack, this ), |
|
1192 iAnimPluginSession ); |
|
1193 |
|
1194 iDrmExpiryWatcher = CScreensaverRepositoryWatcher::NewL( |
|
1195 KCRUidDRMHelperServer, |
|
1196 KDRMHelperServerNotification, |
|
1197 CCenRepNotifyHandler::EIntKey, |
|
1198 TCallBack( HandleDrmNotification, this ), |
|
1199 iDrmSession ); |
|
1200 } |
|
1201 |
|
1202 // ----------------------------------------------------------------------------- |
|
1203 // CScreenSaverAnimPlugin::NotifyCenrepChangeCancel |
|
1204 // ----------------------------------------------------------------------------- |
|
1205 // |
|
1206 void CScreenSaverAnimPlugin::NotifyCenrepChangeCancel() |
|
1207 { |
|
1208 |
|
1209 delete iScreensaverRepositoryWatcher; |
|
1210 iScreensaverRepositoryWatcher = NULL; |
|
1211 |
|
1212 delete iDrmExpiryWatcher; |
|
1213 iDrmExpiryWatcher = NULL; |
|
1214 |
|
1215 } |
|
1216 // ----------------------------------------------------------------------------- |
|
1217 // CScreenSaverAnimPlugin::UnInitializeCenRep |
|
1218 // ----------------------------------------------------------------------------- |
|
1219 // |
|
1220 void CScreenSaverAnimPlugin::UnInitializeCenRep() |
|
1221 { |
|
1222 if ( iAnimPluginSession ) |
|
1223 { |
|
1224 delete iAnimPluginSession; |
|
1225 iAnimPluginSession = NULL; |
|
1226 } |
|
1227 if ( iDrmSession ) |
|
1228 { |
|
1229 delete iDrmSession; |
|
1230 iDrmSession = NULL; |
|
1231 } |
|
1232 } |
|
1233 |
|
1234 // ----------------------------------------------------------------------------- |
|
1235 // CScreenSaverAnimPlugin::CScreenSaverAnimPlugin |
|
1236 // ----------------------------------------------------------------------------- |
|
1237 // |
|
1238 CScreenSaverAnimPlugin::CScreenSaverAnimPlugin(): |
|
1239 iParentControl( NULL ),iPluginError( KErrNone ) |
|
1240 { |
|
1241 } |
|
1242 |
|
1243 // ----------------------------------------------------------------------------- |
|
1244 // CScreenSaverAnimPlugin::ConstructL |
|
1245 // ----------------------------------------------------------------------------- |
|
1246 // |
|
1247 void CScreenSaverAnimPlugin::ConstructL() |
|
1248 { |
|
1249 #ifdef SCREENSAVER_LOG_ENABLED |
|
1250 _LIT( msg, "ConstructL of ScreenSaverAnimPlugin" ); |
|
1251 PrintDebugMsg( msg ); |
|
1252 #endif |
|
1253 |
|
1254 // Find which drive this DLL is installed. |
|
1255 TFileName fileName; |
|
1256 |
|
1257 // Get the full resource file |
|
1258 TParse lParse; |
|
1259 |
|
1260 // Add the resource dir |
|
1261 lParse.Set( KResourceFileName, &KDC_RESOURCE_FILES_DIR, NULL ); |
|
1262 |
|
1263 // Get the filename with full path |
|
1264 fileName = lParse.FullName(); |
|
1265 |
|
1266 iEikEnv = CEikonEnv::Static(); |
|
1267 |
|
1268 BaflUtils::NearestLanguageFile( iEikEnv->FsSession(), fileName ); //for |
|
1269 // localization |
|
1270 |
|
1271 iDrmHelper = CDRMHelper::NewL( *iEikEnv ); |
|
1272 |
|
1273 #ifdef SCREENSAVER_LOG_ENABLED |
|
1274 _LIT( msg1, "Before Cenrep Init " ); |
|
1275 PrintDebugMsg( msg1 ); |
|
1276 #endif |
|
1277 |
|
1278 InitializeCenRepL(); |
|
1279 |
|
1280 #ifdef SCREENSAVER_LOG_ENABLED |
|
1281 _LIT( msg2, "After Cenrep Init " ); |
|
1282 PrintDebugMsg( msg2 ); |
|
1283 #endif |
|
1284 |
|
1285 iSettingObject = new( ELeave ) CScreenSaverAnimSettingObject; |
|
1286 |
|
1287 GetAnimSettings(); |
|
1288 |
|
1289 iResourceOffset = iEikEnv->AddResourceFileL( fileName ); |
|
1290 |
|
1291 #ifdef SCREENSAVER_LOG_ENABLED |
|
1292 _LIT( msg3, "ConstructL end " ); |
|
1293 PrintDebugMsg( msg3 ); |
|
1294 #endif |
|
1295 |
|
1296 // Load localised name of screensaver to be returned for |
|
1297 // Themes app in Name() query |
|
1298 iScreensaverName = iEikEnv->AllocReadResourceL( R_SANIM_SCREENSAVER_NAME ); |
|
1299 } |
|
1300 |
|
1301 // ----------------------------------------------------------------------------- |
|
1302 // CScreenSaverAnimPlugin::SendEndEvent |
|
1303 // ----------------------------------------------------------------------------- |
|
1304 // |
|
1305 TInt CScreenSaverAnimPlugin::SendEndEvent() |
|
1306 { |
|
1307 NPAnimationEvent event; |
|
1308 event = NPEndAnimation; |
|
1309 if ( iPluginFuncs ) |
|
1310 { |
|
1311 return iPluginFuncs->setvalue( iNPPinstance, |
|
1312 ( NPNVariable )NPNScreenSaverAnimationEvent, |
|
1313 &event ); |
|
1314 } |
|
1315 return KErrNone; |
|
1316 |
|
1317 } |
|
1318 |
|
1319 // ----------------------------------------------------------------------------- |
|
1320 // CScreenSaverAnimPlugin::CheckFileValidity |
|
1321 // ----------------------------------------------------------------------------- |
|
1322 // |
|
1323 TInt CScreenSaverAnimPlugin::CheckFileValidityL( const TDesC& aFileName ) |
|
1324 { |
|
1325 FindAndStartPluginL( aFileName , ETrue /* Check File Mode */); |
|
1326 NPCheckFile checkFile; |
|
1327 checkFile.fileValidityCheckError = KErrNone; |
|
1328 checkFile.fileName = HBufC::NewL( aFileName.Length() ); |
|
1329 checkFile.fileName->Des().Copy( aFileName ); |
|
1330 |
|
1331 if ( iPluginFuncs ) |
|
1332 { |
|
1333 iPluginFuncs->getvalue( iNPPinstance, |
|
1334 ( NPPVariable )NPPCheckFileIsValid, |
|
1335 &checkFile ); |
|
1336 } |
|
1337 delete checkFile.fileName; |
|
1338 DeletePlugin(); |
|
1339 return checkFile.fileValidityCheckError; |
|
1340 |
|
1341 } |
|
1342 |
|
1343 /* MPluginAdapter Interface functions, The plugins call |
|
1344 * these back |
|
1345 */ |
|
1346 // ----------------------------------------------------------------------------- |
|
1347 // CScreenSaverAnimPlugin::GetVersion |
|
1348 // ----------------------------------------------------------------------------- |
|
1349 // |
|
1350 TUint16 CScreenSaverAnimPlugin::GetVersion() |
|
1351 { |
|
1352 return 0; |
|
1353 } |
|
1354 |
|
1355 // ----------------------------------------------------------------------------- |
|
1356 // CScreenSaverAnimPlugin::PluginConstructedL |
|
1357 // Called when the plug-in has completed its creation. |
|
1358 // ----------------------------------------------------------------------------- |
|
1359 // |
|
1360 void CScreenSaverAnimPlugin::PluginConstructedL( CCoeControl* |
|
1361 /*aPluginControl*/ ) |
|
1362 { |
|
1363 } |
|
1364 |
|
1365 // ----------------------------------------------------------------------------- |
|
1366 // CScreenSaverAnimPlugin::PluginFinishedL |
|
1367 // Called when the plug-in has completed its creation. |
|
1368 // ----------------------------------------------------------------------------- |
|
1369 // |
|
1370 void CScreenSaverAnimPlugin::PluginFinishedL() |
|
1371 { |
|
1372 TInt error; |
|
1373 iPluginFuncs->getvalue( iNPPinstance, |
|
1374 ( NPPVariable )NPPScreenSaverGetLastError, |
|
1375 &error ); |
|
1376 |
|
1377 #ifdef SCREENSAVER_LOG_ENABLED |
|
1378 TBuf<KMaxBufLen> buffer1; |
|
1379 _LIT( msg, "Plugin finishedL Error: %d" ); |
|
1380 buffer1.Format( msg, error ); |
|
1381 PrintDebugMsg( buffer1 ); |
|
1382 #endif |
|
1383 |
|
1384 if ( iScreenSaverHost ) |
|
1385 { |
|
1386 if ( error != KErrNone ) |
|
1387 { |
|
1388 iPluginError = error; |
|
1389 // Plugin has encountered an error |
|
1390 iScreenSaverHost->RevertToDefaultSaver(); |
|
1391 } |
|
1392 } |
|
1393 } |
|
1394 |
|
1395 #ifndef __SERIES60_30__ |
|
1396 // ----------------------------------------------------------------------------- |
|
1397 // CScreenSaverAnimPlugin::OpenUrlL |
|
1398 // Called by the plug-in to open a URL in the parent frame. |
|
1399 // This function is not implemented in Series 60. It is supported |
|
1400 // in Series 80 and in the Nokia 7710 smartphone |
|
1401 // ----------------------------------------------------------------------------- |
|
1402 // |
|
1403 |
|
1404 void CScreenSaverAnimPlugin::OpenUrlL( const TDesC& /* aUrl */ ) |
|
1405 { |
|
1406 } |
|
1407 |
|
1408 // ----------------------------------------------------------------------------- |
|
1409 // CScreenSaverAnimPlugin::OpenUrlInTargetWindowL |
|
1410 // Called by the plug-in to open a URL in a named window or frame. |
|
1411 // ----------------------------------------------------------------------------- |
|
1412 // |
|
1413 void CScreenSaverAnimPlugin::OpenUrlInTargetWindowL( const TDesC& /* aUrl */, |
|
1414 const TDesC& /* aNewTargetWindowName */ ) |
|
1415 { |
|
1416 } |
|
1417 |
|
1418 // ----------------------------------------------------------------------------- |
|
1419 // CScreenSaverAnimPlugin::HasNavigationHistoryPrevious |
|
1420 // Specifies whether or not the frame has a previous navigation history item. |
|
1421 // ----------------------------------------------------------------------------- |
|
1422 // |
|
1423 TBool CScreenSaverAnimPlugin::HasNavigationHistoryPrevious() const |
|
1424 { |
|
1425 return EFalse; |
|
1426 } |
|
1427 |
|
1428 // ----------------------------------------------------------------------------- |
|
1429 // CScreenSaverAnimPlugin::LoadNavigationHistoryPreviousL |
|
1430 // Informs the browser to load the next navigation history URL in its parent |
|
1431 // frame. |
|
1432 // ----------------------------------------------------------------------------- |
|
1433 // |
|
1434 void CScreenSaverAnimPlugin::LoadNavigationHistoryPreviousL() |
|
1435 { |
|
1436 } |
|
1437 |
|
1438 // ----------------------------------------------------------------------------- |
|
1439 // CScreenSaverAnimPlugin::HasNavigationHistoryNext |
|
1440 // Returns whether the frame has a next navigation history item. |
|
1441 // ----------------------------------------------------------------------------- |
|
1442 // |
|
1443 TBool CScreenSaverAnimPlugin::HasNavigationHistoryNext() const |
|
1444 { |
|
1445 return EFalse; |
|
1446 } |
|
1447 |
|
1448 // ----------------------------------------------------------------------------- |
|
1449 // CScreenSaverAnimPlugin::LoadNavigationHistoryNextL |
|
1450 // Informs the browser to load the next navigation history URL in its parent |
|
1451 // frame. |
|
1452 // ----------------------------------------------------------------------------- |
|
1453 // |
|
1454 void CScreenSaverAnimPlugin::LoadNavigationHistoryNextL() |
|
1455 { |
|
1456 } |
|
1457 |
|
1458 #endif |
|
1459 |
|
1460 // ----------------------------------------------------------------------------- |
|
1461 // CScreenSaverAnimPlugin::GetParentControl |
|
1462 // Returns the window system level control object for the plug-in. |
|
1463 // ----------------------------------------------------------------------------- |
|
1464 // |
|
1465 CCoeControl* CScreenSaverAnimPlugin::GetParentControl() |
|
1466 { |
|
1467 return iParentControl; |
|
1468 } |
|
1469 |
|
1470 // ----------------------------------------------------------------------------- |
|
1471 // CScreenSaverAnimPlugin::GetParentControlObserver |
|
1472 // Returns the observer for the plug-in control. |
|
1473 // ----------------------------------------------------------------------------- |
|
1474 // |
|
1475 MCoeControlObserver* CScreenSaverAnimPlugin::GetParentControlObserver() |
|
1476 { |
|
1477 return this; |
|
1478 } |
|
1479 |
|
1480 // ----------------------------------------------------------------------------- |
|
1481 // CScreenSaverAnimPlugin::GetParentControlObserver |
|
1482 // Sets the plug-in notifier allowing the plug-in to control |
|
1483 // portions of the browser. |
|
1484 // ----------------------------------------------------------------------------- |
|
1485 // |
|
1486 void CScreenSaverAnimPlugin::SetPluginNotifier( MPluginNotifier* /*aNotifier*/ ) |
|
1487 { |
|
1488 } |
|
1489 |
|
1490 // ----------------------------------------------------------------------------- |
|
1491 // CScreenSaverAnimPlugin::SetContentInteractive |
|
1492 // Tells the plugin adapter if plugin content can accept user interaction. |
|
1493 // ----------------------------------------------------------------------------- |
|
1494 // |
|
1495 void CScreenSaverAnimPlugin::SetContentInteractive( TBool /*aInteractive*/ ) |
|
1496 { |
|
1497 } |
|
1498 |
|
1499 // ----------------------------------------------------------------------------- |
|
1500 // CScreenSaverAnimPlugin::HandleControlEventL |
|
1501 // Handles an event from an observed control.This function is called |
|
1502 // when a control for which this control is the observer calls |
|
1503 // CCoeControl::ReportEventL(). It should be implemented by the observer |
|
1504 // control, and should handle all events sent by controls it observes. |
|
1505 // ----------------------------------------------------------------------------- |
|
1506 // |
|
1507 void CScreenSaverAnimPlugin::HandleControlEventL( CCoeControl* /*aControl*/, |
|
1508 TCoeEvent /*aEventType*/ ) |
|
1509 { |
|
1510 } |
|
1511 |
|
1512 // ----------------------------------------------------------------------------- |
|
1513 // CScreenSaverAnimPlugin::CheckContentIdL |
|
1514 // ----------------------------------------------------------------------------- |
|
1515 // |
|
1516 TBool CScreenSaverAnimPlugin::CheckContentIdL( const TDesC& aFileName, |
|
1517 TDesC8& aContentUri ) |
|
1518 { |
|
1519 |
|
1520 TBool matched = EFalse; |
|
1521 HBufC* contentURI = NULL; |
|
1522 HBufC8* contentURI8 = NULL; |
|
1523 |
|
1524 RFile fileHandle; |
|
1525 |
|
1526 TInt error = fileHandle.Open( iEikEnv->FsSession(), |
|
1527 aFileName, |
|
1528 EFileRead | EFileShareReadersOnly ); |
|
1529 if ( error != KErrNone ) |
|
1530 { |
|
1531 return matched; |
|
1532 } |
|
1533 |
|
1534 CleanupClosePushL( fileHandle ); |
|
1535 CData* content = CData::NewL( fileHandle, KDefaultContentObject, EPeek ); |
|
1536 CleanupStack::PopAndDestroy( &fileHandle ); |
|
1537 |
|
1538 CleanupStack::PushL( content ); |
|
1539 |
|
1540 contentURI = HBufC::NewLC( KUrlMaxLen ); |
|
1541 |
|
1542 // create attribute set |
|
1543 RStringAttributeSet stringAttributeSet; |
|
1544 CleanupClosePushL( stringAttributeSet ); |
|
1545 // add the attributes we are interested in |
|
1546 stringAttributeSet.AddL( EContentID ); |
|
1547 |
|
1548 User::LeaveIfError( content->GetStringAttributeSet( stringAttributeSet ) ); |
|
1549 |
|
1550 // pass on values of string attributes |
|
1551 TPtr ptr = contentURI->Des(); |
|
1552 error = stringAttributeSet.GetValue( EContentID, ptr ); |
|
1553 if ( error == KErrNone ) |
|
1554 { |
|
1555 contentURI8 = HBufC8::NewLC( contentURI->Length() ); |
|
1556 contentURI8->Des().Copy( contentURI->Des() ); |
|
1557 if ( contentURI8->Compare( aContentUri ) == 0 ) |
|
1558 { |
|
1559 matched = ETrue; |
|
1560 } |
|
1561 CleanupStack::PopAndDestroy( contentURI8 ); |
|
1562 } |
|
1563 |
|
1564 CleanupStack::PopAndDestroy( 2, contentURI ); // stringAttributeSet.Close() |
|
1565 CleanupStack::PopAndDestroy( content ); |
|
1566 |
|
1567 return matched; |
|
1568 } |
|
1569 |
|
1570 // End Of file. |
|
1571 |
|