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