|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implementation of screensaver plugin display object class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <AknDef.h> |
|
21 #include <power_save_display_mode.h> |
|
22 |
|
23 #include "ScreensaverpluginIntDef.h" |
|
24 #include "screensaverctrlplugin.h" |
|
25 #include "screensaverview.h" |
|
26 #include "screensaverappui.h" |
|
27 #include "screensaverutility.h" |
|
28 #include "ScreensaverUtils.h" |
|
29 #include "screensavershareddatai.h" |
|
30 |
|
31 // If plugin refresh rate is lower than this threshold, wserv heartbeat |
|
32 // is stopped between redraws |
|
33 const TInt KStopWsHbPluginRefreshThreshold = 1000000; // 1 sec |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CScreensaverCtrlPlugin::NewL |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 CScreensaverCtrlPlugin* CScreensaverCtrlPlugin::NewL() |
|
40 { |
|
41 CScreensaverCtrlPlugin* self = new( ELeave ) CScreensaverCtrlPlugin(); |
|
42 CleanupStack::PushL( self ); |
|
43 self->ConstructL(); |
|
44 CleanupStack::Pop(); |
|
45 return self; |
|
46 } |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CScreensaverCtrlPlugin::~CScreensaverCtrlPlugin |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CScreensaverCtrlPlugin::~CScreensaverCtrlPlugin() |
|
53 { |
|
54 DeleteTimer( iPluginRefreshTimer ); |
|
55 DeleteTimer( iPluginTimeoutTimer ); |
|
56 DeletePlugin(); |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // CScreensaverCtrlPlugin::StartTimer |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 void CScreensaverCtrlPlugin::StartTimer() |
|
64 { |
|
65 // Notify plugin that screensaver is starting |
|
66 SendPluginEvent( EScreensaverEventStarting ); |
|
67 |
|
68 |
|
69 StartPluginRefreshTimer(); |
|
70 |
|
71 if ( RefreshTimerValue() >= KStopWsHbPluginRefreshThreshold ) |
|
72 { |
|
73 StartCaptureScreenTimer(); |
|
74 } |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CScreensaverCtrlPlugin::CancelTimer |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 void CScreensaverCtrlPlugin::CancelTimer() |
|
82 { |
|
83 DeleteTimer( iPluginRefreshTimer ); |
|
84 DeleteTimer( iPluginTimeoutTimer ); |
|
85 |
|
86 SendPluginEvent( EScreensaverEventStopping ); |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // CScreensaverCtrlPlugin::DrawObject |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 void CScreensaverCtrlPlugin::DrawObject() |
|
94 { |
|
95 CScreensaverBase::DrawObject(); |
|
96 |
|
97 if( iPluginFlag.IsSet( EPluginFlagSuspend ) ) |
|
98 { |
|
99 Suspend( -1 ); |
|
100 iPluginFlag.Clear( EPluginFlagSuspend ); |
|
101 } |
|
102 } |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // CScreensaverCtrlPlugin::ClearScreen |
|
106 // ----------------------------------------------------------------------------- |
|
107 // |
|
108 void CScreensaverCtrlPlugin::ClearScreen() |
|
109 { |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CScreensaverCtrlPlugin::Refresh |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 void CScreensaverCtrlPlugin::Refresh() |
|
117 { |
|
118 SCRLOGGER_WRITEF( _L("SCR:CScreensaverCtrlPlugin::Refresh start") ); |
|
119 // Currently only keylock indicator is updated, because |
|
120 // thats the only indicator whose state may change while screensaver |
|
121 // is displaying. Other indicators' state changing also dismisses |
|
122 // screensaver. Once redisplaying, the indicators are updated anyway. |
|
123 // Key lock indicator depends on status of key guard. |
|
124 Array().SetDependencyStatus( ESsKeyLockInd, !Model().SharedDataInterface()->IsKeyguardOn() ); |
|
125 Array().SetVisibilityForIndicators(); |
|
126 |
|
127 SCRLOGGER_WRITEF( _L("SCR:CScreensaverCtrlPlugin::Refresh DrawObject") ); |
|
128 // Cause a redraw |
|
129 DrawObject(); |
|
130 |
|
131 SCRLOGGER_WRITEF( _L("SCR:CScreensaverCtrlPlugin::Refresh finish") ); |
|
132 } |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // CScreensaverCtrlPlugin::SendPluginEvent |
|
136 // ----------------------------------------------------------------------------- |
|
137 // |
|
138 TInt CScreensaverCtrlPlugin::SendPluginEvent( TScreensaverEvent aEvent ) |
|
139 { |
|
140 if ( iPlugin ) |
|
141 { |
|
142 TRAPD( err, iPlugin->HandleScreensaverEventL( aEvent, NULL ) ); |
|
143 return err; |
|
144 } |
|
145 |
|
146 return KErrNone; |
|
147 } |
|
148 |
|
149 // From MScreensaverPluginHost |
|
150 // ----------------------------------------------------------------------------- |
|
151 // CScreensaverCtrlPlugin::UseStandardIndicators |
|
152 // ----------------------------------------------------------------------------- |
|
153 // |
|
154 void CScreensaverCtrlPlugin::UseStandardIndicators() |
|
155 { |
|
156 SCRLOGGER_WRITE("Host: UseStandardIndicators()"); |
|
157 |
|
158 iPluginFlag.Clear( EPluginFlagOverrideIndicators ); |
|
159 } |
|
160 |
|
161 // ----------------------------------------------------------------------------- |
|
162 // CScreensaverCtrlPlugin::OverrideStandardIndicators |
|
163 // ----------------------------------------------------------------------------- |
|
164 // |
|
165 void CScreensaverCtrlPlugin::OverrideStandardIndicators() |
|
166 { |
|
167 SCRLOGGER_WRITE("Host: OverrideStandardIndicators()"); |
|
168 |
|
169 iPluginFlag.Set( EPluginFlagOverrideIndicators ); |
|
170 } |
|
171 |
|
172 // ----------------------------------------------------------------------------- |
|
173 // CScreensaverCtrlPlugin::StandardIndicatorsUsed |
|
174 // ----------------------------------------------------------------------------- |
|
175 // |
|
176 TBool CScreensaverCtrlPlugin::StandardIndicatorsUsed() const |
|
177 { |
|
178 SCRLOGGER_WRITE("Host: StandardIndicatorsUsed()"); |
|
179 |
|
180 return iPluginFlag.IsClear( EPluginFlagOverrideIndicators ); |
|
181 } |
|
182 |
|
183 // ----------------------------------------------------------------------------- |
|
184 // CScreensaverCtrlPlugin::SetRefreshTimerValue |
|
185 // ----------------------------------------------------------------------------- |
|
186 // |
|
187 void CScreensaverCtrlPlugin::SetRefreshTimerValue( TInt aValue ) |
|
188 { |
|
189 SCRLOGGER_WRITEF( _L("SCR: Host: SetRefreshTimerValue(%d)"), aValue ); |
|
190 |
|
191 iPluginRefreshRate = aValue; |
|
192 iPluginFlag.Clear( EPluginFlagTimerNotUsed ); |
|
193 } |
|
194 |
|
195 // ----------------------------------------------------------------------------- |
|
196 // CScreensaverCtrlPlugin::RefreshTimerValue |
|
197 // ----------------------------------------------------------------------------- |
|
198 // |
|
199 TInt CScreensaverCtrlPlugin::RefreshTimerValue() const |
|
200 { |
|
201 SCRLOGGER_WRITE("Host: RefreshTimerValue()"); |
|
202 |
|
203 return iPluginRefreshRate; |
|
204 } |
|
205 |
|
206 // ----------------------------------------------------------------------------- |
|
207 // CScreensaverCtrlPlugin::GetIndicatorPayload |
|
208 // ----------------------------------------------------------------------------- |
|
209 // |
|
210 TInt CScreensaverCtrlPlugin::GetIndicatorPayload( |
|
211 TScreensaverIndicatorIndex aIndex, TIndicatorPayload& aResult ) const |
|
212 { |
|
213 SCRLOGGER_WRITEF( _L("SCR: Host: GetIndicatorPayload(%d, %x)"), |
|
214 aIndex, &aResult ); |
|
215 |
|
216 return Model().IndicatorArray().GetIndicatorPayload( ( TScreensaverIndicatorId ) aIndex, aResult ); |
|
217 } |
|
218 |
|
219 // ----------------------------------------------------------------------------- |
|
220 // CScreensaverCtrlPlugin::SetActiveDisplayArea |
|
221 // ----------------------------------------------------------------------------- |
|
222 // |
|
223 TInt CScreensaverCtrlPlugin::SetActiveDisplayArea( |
|
224 TRect& aRect, const TScreensaverPartialMode& aMode ) |
|
225 { |
|
226 SCRLOGGER_WRITEF( _L("SCR: Host: SetActiveDisplayArea(<rect>, %d)"), aMode ); |
|
227 SCRLOGGER_WRITEF( _L(" -> rect: (%d, %d, %d, %d)"), |
|
228 aRect.iTl.iX, aRect.iTl.iY, aRect.iBr.iX, aRect.iBr.iY ); |
|
229 // Make sure everything is in display memory |
|
230 ScreensaverUtility::FlushDrawBuffer(); |
|
231 |
|
232 // Save the active area |
|
233 TInt err = SetPowerSaveDisplayActiveArea( aRect ); |
|
234 if ( err == KErrNone ) |
|
235 { |
|
236 // And activate power save display. Full mode = full colors |
|
237 // err = ActivatePowerSaveDisplay( aMode.iType |
|
238 // == EPartialModeTypeFull ); |
|
239 } |
|
240 |
|
241 return err; |
|
242 } |
|
243 |
|
244 // ----------------------------------------------------------------------------- |
|
245 // CScreensaverCtrlPlugin::SetActiveDisplayArea |
|
246 // ----------------------------------------------------------------------------- |
|
247 // |
|
248 TInt CScreensaverCtrlPlugin::SetActiveDisplayArea( |
|
249 TInt aStartRow, TInt aEndRow, const TScreensaverPartialMode& aMode ) |
|
250 { |
|
251 SCRLOGGER_WRITEF( _L("SCR: Host: SetActiveDisplayArea(%d, %d, %d)"), |
|
252 aStartRow, aEndRow, aMode ); |
|
253 |
|
254 TRect psRect( 0, aStartRow, 1, aEndRow); |
|
255 return SetActiveDisplayArea( psRect, aMode ); |
|
256 } |
|
257 |
|
258 // ----------------------------------------------------------------------------- |
|
259 // CScreensaverCtrlPlugin::ExitPartialMode |
|
260 // ----------------------------------------------------------------------------- |
|
261 // |
|
262 void CScreensaverCtrlPlugin::ExitPartialMode() |
|
263 { |
|
264 SCRLOGGER_WRITE("Host: ExitPartialMode()"); |
|
265 |
|
266 LcdPartialMode()->Exit(); |
|
267 // Make sure the partial area is empty |
|
268 // Make this less idiotic |
|
269 TRect psRect( 0, 0, 0, 0); |
|
270 SetPowerSaveDisplayActiveArea( psRect ); |
|
271 } |
|
272 |
|
273 // ----------------------------------------------------------------------------- |
|
274 // CScreensaverCtrlPlugin::GetColorModel |
|
275 // ----------------------------------------------------------------------------- |
|
276 // |
|
277 const TScreensaverColorModel& CScreensaverCtrlPlugin::GetColorModel() const |
|
278 { |
|
279 SCRLOGGER_WRITE("Host / Own use: GetColorModel()"); |
|
280 |
|
281 return Model().GetColorModel(); |
|
282 } |
|
283 |
|
284 // ----------------------------------------------------------------------------- |
|
285 // CScreensaverCtrlPlugin::Suspend |
|
286 // ----------------------------------------------------------------------------- |
|
287 // |
|
288 void CScreensaverCtrlPlugin::Suspend( TInt aTime ) |
|
289 { |
|
290 SCRLOGGER_WRITEF( _L("SCR: Host: Suspend(%d)"), aTime ); |
|
291 |
|
292 View()->SetDisplayObject( Model().SharedDataInterface()->DefaultScreensaverType() ); |
|
293 |
|
294 View()->ShowDisplayObject(); |
|
295 |
|
296 if ( aTime >= 0 ) |
|
297 { |
|
298 CScreensaverEngine& model = MUTABLE_CAST( CScreensaverEngine&, Model() ); |
|
299 |
|
300 model.StartSuspendTimer( aTime ); |
|
301 } |
|
302 } |
|
303 |
|
304 // ----------------------------------------------------------------------------- |
|
305 // CScreensaverCtrlPlugin::RequestLights |
|
306 // ----------------------------------------------------------------------------- |
|
307 // |
|
308 void CScreensaverCtrlPlugin::RequestLights( TInt aSecs ) |
|
309 { |
|
310 SCRLOGGER_WRITEF( _L("SCR: Host: RequestLights(%d)"), aSecs ); |
|
311 |
|
312 if ( aSecs <= 0 ) |
|
313 { |
|
314 // Turn lights off, kill lights timer |
|
315 Model().SharedDataInterface()->SetSSForcedLightsOn( 0 ); |
|
316 } |
|
317 else |
|
318 { |
|
319 // Make sure nobody tries to overextend our hospitality |
|
320 TInt secs = (aSecs > KMaxLightsOnTime) ? KMaxLightsOnTime : aSecs; |
|
321 |
|
322 // Turn lights on, start lights timer |
|
323 Model().SharedDataInterface()->SetSSForcedLightsOn( secs ); |
|
324 } |
|
325 } |
|
326 |
|
327 // ----------------------------------------------------------------------------- |
|
328 // CScreensaverCtrlPlugin::DisplayInfo |
|
329 // ----------------------------------------------------------------------------- |
|
330 // |
|
331 TInt CScreensaverCtrlPlugin::DisplayInfo( TScreensaverDisplayInfo* aInfo ) |
|
332 { |
|
333 SCRLOGGER_WRITEF( _L("SCR: Host: DisplayInfo(%x)"), aInfo ); |
|
334 |
|
335 if ( !aInfo ) |
|
336 { |
|
337 return KErrArgument; |
|
338 } |
|
339 // Sanity check: the indicated size of the info struct should be |
|
340 // same or less than the actual size (allows for extensibility) |
|
341 if ( aInfo->iSize > sizeof( TScreensaverDisplayInfo ) ) |
|
342 { |
|
343 ASSERT( EFalse ); |
|
344 return KErrArgument; |
|
345 } |
|
346 |
|
347 // Fill our own perception of the info structure |
|
348 TScreensaverDisplayInfo info; |
|
349 |
|
350 info.iSize = aInfo->iSize; |
|
351 |
|
352 // Currently whole screen |
|
353 info.iRect = CCoeEnv::Static()->ScreenDevice()->SizeInPixels(); |
|
354 info.iParent = this; |
|
355 |
|
356 // Copy only the size of the caller struct |
|
357 Mem::Copy( aInfo, &info, aInfo->iSize ); |
|
358 |
|
359 return KErrNone; |
|
360 } |
|
361 |
|
362 // ----------------------------------------------------------------------------- |
|
363 // CScreensaverCtrlPlugin::UseRefreshTimer |
|
364 // ----------------------------------------------------------------------------- |
|
365 // |
|
366 void CScreensaverCtrlPlugin::UseRefreshTimer( TBool aOn ) |
|
367 { |
|
368 SCRLOGGER_WRITEF( _L("SCR: Host: UseRefreshTimer(%d)"), aOn ); |
|
369 |
|
370 if ( aOn ) |
|
371 { |
|
372 // Use normal timer, plugin timer allowed |
|
373 iPluginFlag.Clear( EPluginFlagTimerNotUsed ); |
|
374 } |
|
375 else |
|
376 { |
|
377 // Plugin does not want Draw() calls, let timer tick the usual way |
|
378 iPluginFlag.Set( EPluginFlagTimerNotUsed ); |
|
379 } |
|
380 } |
|
381 |
|
382 // ----------------------------------------------------------------------------- |
|
383 // CScreensaverCtrlPlugin::RequestTimeout |
|
384 // ----------------------------------------------------------------------------- |
|
385 // |
|
386 void CScreensaverCtrlPlugin::RequestTimeout( TInt aSecs ) |
|
387 { |
|
388 StartPluginTimeoutTimer( aSecs ); |
|
389 } |
|
390 |
|
391 // ----------------------------------------------------------------------------- |
|
392 // CScreensaverCtrlPlugin::RevertToDefaultSaver |
|
393 // ----------------------------------------------------------------------------- |
|
394 // |
|
395 void CScreensaverCtrlPlugin::RevertToDefaultSaver() |
|
396 { |
|
397 SCRLOGGER_WRITE("Host: RevertToDefaultSaver()"); |
|
398 |
|
399 Model().SharedDataInterface()->SetDisplayObjectType( |
|
400 Model().SharedDataInterface()->DefaultScreensaverType() ); |
|
401 } |
|
402 |
|
403 // --- end MScreensaverPluginHost --- |
|
404 |
|
405 // ----------------------------------------------------------------------------- |
|
406 // CScreensaverCtrlPlugin::CScreensaverCtrlPlugin |
|
407 // ----------------------------------------------------------------------------- |
|
408 // |
|
409 CScreensaverCtrlPlugin::CScreensaverCtrlPlugin() |
|
410 :iPluginFlag() |
|
411 { |
|
412 } |
|
413 |
|
414 // ----------------------------------------------------------------------------- |
|
415 // CScreensaverCtrlPlugin::ConstructL |
|
416 // ----------------------------------------------------------------------------- |
|
417 // |
|
418 void CScreensaverCtrlPlugin::ConstructL() |
|
419 { |
|
420 iPluginFlag.ClearAll(); |
|
421 |
|
422 |
|
423 CreateWindowL(); |
|
424 |
|
425 SetRect( iCoeEnv->ScreenDevice()->SizeInPixels() ); |
|
426 ConstructAndConnectLCDL(); |
|
427 LoadPluginL( this ); |
|
428 ActivateL(); |
|
429 |
|
430 // Notify plugin that display control has changed |
|
431 SendPluginEvent( EScreensaverEventDisplayChanged ); |
|
432 |
|
433 if( Model().ScreenSaverIsPreviewing() ) |
|
434 { |
|
435 SendPluginEvent( EScreensaverEventPreview ); |
|
436 } |
|
437 } |
|
438 |
|
439 // ----------------------------------------------------------------------------- |
|
440 // CScreensaverCtrlPlugin::HandleResourceChange |
|
441 // ----------------------------------------------------------------------------- |
|
442 // |
|
443 void CScreensaverCtrlPlugin::HandleResourceChange( TInt aType ) |
|
444 { |
|
445 if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
446 { |
|
447 // Screen layout has changed - resize |
|
448 SetRect( iCoeEnv->ScreenDevice()->SizeInPixels() ); |
|
449 // Notify plugin that the display has changed |
|
450 SendPluginEvent( EScreensaverEventDisplayChanged ); |
|
451 } |
|
452 } |
|
453 |
|
454 // ----------------------------------------------------------------------------- |
|
455 // CScreensaverCtrlPlugin::SizeChanged |
|
456 // ----------------------------------------------------------------------------- |
|
457 // |
|
458 void CScreensaverCtrlPlugin::SizeChanged() |
|
459 { |
|
460 } |
|
461 |
|
462 // ----------------------------------------------------------------------------- |
|
463 // CScreensaverCtrlPlugin::Draw |
|
464 // ----------------------------------------------------------------------------- |
|
465 // |
|
466 void CScreensaverCtrlPlugin::Draw( const TRect& /*aRect*/ ) const |
|
467 { |
|
468 |
|
469 if ( !Model().ScreenSaverIsOn() && !Model().ScreenSaverIsPreviewing() ) |
|
470 { |
|
471 return; |
|
472 } |
|
473 |
|
474 // Graphics context to draw on. |
|
475 CWindowGc& gc = SystemGc(); |
|
476 |
|
477 // Fix for error ESMG-74Y4PE - S60 3.2 wk26, Power Saver: |
|
478 // Flickering when power saver is deactivated. |
|
479 // We now clear the screen with a black brush so the screensaver |
|
480 // background is changed to black. There will no longer be a white |
|
481 // intermediate screen and this will reduce the "flicker" effect. |
|
482 gc.SetBrushColor( KRgbBlack ); |
|
483 |
|
484 // Start with a clear screen |
|
485 // If there is no plugin module, indicator view overrides plugin module or |
|
486 // plugin drawing is suspended then the standard screensaver bar is shown, |
|
487 // let's draw it. |
|
488 |
|
489 // Let plugin module handle the drawing, unless not requested |
|
490 |
|
491 TInt err = KErrNone; |
|
492 if ( iPluginFlag.IsClear( EPluginFlagTimerNotUsed ) ) |
|
493 { |
|
494 err = iPlugin->Draw( gc ); |
|
495 } |
|
496 |
|
497 if( err != KErrNone ) |
|
498 { |
|
499 iPluginFlag.Set( EPluginFlagSuspend ); |
|
500 } |
|
501 } |
|
502 |
|
503 // ----------------------------------------------------------------------------- |
|
504 // CScreensaverCtrlPlugin::LoadPluginL |
|
505 // ----------------------------------------------------------------------------- |
|
506 // |
|
507 void CScreensaverCtrlPlugin::LoadPluginL( MScreensaverPluginHost* /*aPluginHost*/ ) |
|
508 { |
|
509 DeletePlugin(); |
|
510 LoadPluginModuleL(); |
|
511 User::LeaveIfNull( iPlugin ); |
|
512 } |
|
513 |
|
514 // ----------------------------------------------------------------------------- |
|
515 // CScreensaverCtrlPlugin::LoadPluginModule |
|
516 // ----------------------------------------------------------------------------- |
|
517 // |
|
518 void CScreensaverCtrlPlugin::LoadPluginModuleL() |
|
519 { |
|
520 TFileName pluginName; |
|
521 |
|
522 Model().SharedDataInterface()->GetPluginName( pluginName ); |
|
523 |
|
524 // Create plugin object in the DLL |
|
525 // Convert the UID of the given screensaver plugin from text to integer |
|
526 // The string format of the UID: [12345678] |
|
527 // The number inside the brackets in hexadecimal format |
|
528 TLex lex( pluginName ); |
|
529 |
|
530 // Skip the first character: '[' |
|
531 lex.Get(); |
|
532 |
|
533 TUint screenSaverPluginImpUid; |
|
534 |
|
535 // Get the UID |
|
536 TInt err = lex.Val( screenSaverPluginImpUid, EHex ); |
|
537 |
|
538 // Bail out, if the UID is not parseable |
|
539 if ( err != KErrNone ) |
|
540 { |
|
541 iPlugin = NULL; |
|
542 } |
|
543 //codescanner will crib if leaving function inside trap is called |
|
544 //after line break within the macro. Hence the following trap call |
|
545 //is made in a single line |
|
546 TRAP(err, iPlugin = STATIC_CAST( MScreensaverPlugin*, |
|
547 CScreensaverPluginInterfaceDefinition::NewL( |
|
548 TUid::Uid( screenSaverPluginImpUid ) ) ) ); |
|
549 |
|
550 if( err != KErrNone ) |
|
551 return; |
|
552 |
|
553 TRAP( err, err = iPlugin->InitializeL( this ) ); |
|
554 |
|
555 if( err != KErrNone ) |
|
556 { |
|
557 // Loaded OK, but failed to initialize - cannot use plugin |
|
558 delete iPlugin; |
|
559 iPlugin = NULL; |
|
560 } |
|
561 |
|
562 } |
|
563 |
|
564 // ----------------------------------------------------------------------------- |
|
565 // CScreensaverCtrlPlugin::DeletePlugin |
|
566 // ----------------------------------------------------------------------------- |
|
567 // |
|
568 void CScreensaverCtrlPlugin::DeletePlugin() |
|
569 { |
|
570 if( iPlugin ) |
|
571 { |
|
572 delete iPlugin; |
|
573 iPlugin = NULL; |
|
574 } |
|
575 } |
|
576 |
|
577 // ----------------------------------------------------------------------------- |
|
578 // CScreensaverCtrlPlugin::StartPluginRefreshTimer |
|
579 // ----------------------------------------------------------------------------- |
|
580 // |
|
581 void CScreensaverCtrlPlugin::StartPluginRefreshTimer() |
|
582 { |
|
583 DeleteTimer( iPluginRefreshTimer ); |
|
584 |
|
585 if( ( iPluginRefreshRate != 0 ) ) |
|
586 { |
|
587 TRAP_IGNORE( iPluginRefreshTimer = CPeriodic::NewL( CActive::EPriorityStandard ) ); |
|
588 |
|
589 iPluginRefreshTimer->Start( iPluginRefreshRate, iPluginRefreshRate, |
|
590 TCallBack( HandleRefreshTimerExpiry, this ) ); |
|
591 SCRLOGGER_WRITEF( _L("SCR: iRefreshTimer->Start(%d, %d, HandleRefreshTimerExpiry)"), |
|
592 iPluginRefreshRate,iPluginRefreshRate ); |
|
593 } |
|
594 } |
|
595 |
|
596 // ----------------------------------------------------------------------------- |
|
597 // CScreensaverCtrlPlugin::StartPluginTimeoutTimer |
|
598 // ----------------------------------------------------------------------------- |
|
599 // |
|
600 void CScreensaverCtrlPlugin::StartPluginTimeoutTimer( TInt aSecs ) |
|
601 { |
|
602 // Cancel pending timeouts |
|
603 DeleteTimer( iPluginTimeoutTimer ); |
|
604 |
|
605 TRAP_IGNORE( iPluginTimeoutTimer = CPeriodic::NewL( CActive::EPriorityStandard ) ); |
|
606 |
|
607 // Nothing more to do? |
|
608 if( ( aSecs <= 0 ) || ( aSecs > ( 35 * 60 ) ) ) // 35 mins max |
|
609 { |
|
610 return; |
|
611 } |
|
612 |
|
613 TInt timeOut = aSecs * 1000000; // uSecs |
|
614 |
|
615 iPluginTimeoutTimer->Start( timeOut, timeOut, TCallBack( |
|
616 HandlePluginTimeoutTimerExpiry, this ) ); |
|
617 SCRLOGGER_WRITEF( _L("SCR: iPluginTimeoutTimer->Start(%d, %d, HandlePluginTimeoutTimerTimeout)"), |
|
618 timeOut, timeOut ); |
|
619 } |
|
620 |
|
621 // ----------------------------------------------------------------------------- |
|
622 // CScreensaverCtrlPlugin::HandlePluginTimeoutTimerExpiry |
|
623 // ----------------------------------------------------------------------------- |
|
624 // |
|
625 TInt CScreensaverCtrlPlugin::HandlePluginTimeoutTimerExpiry( TAny* aPtr ) |
|
626 { |
|
627 CScreensaverCtrlPlugin *plugin= STATIC_CAST( CScreensaverCtrlPlugin*, aPtr ); |
|
628 SCRLOGGER_WRITEF( _L("SCR: Inside CScreensaverView::HandlePluginTimeoutTimerTimeout()") ); |
|
629 if ( plugin ) |
|
630 { |
|
631 plugin->DeleteTimer( plugin->iPluginRefreshTimer ); |
|
632 plugin->DeleteTimer( plugin->iPluginTimeoutTimer ); |
|
633 plugin->SendPluginEvent( EScreensaverEventTimeout ); |
|
634 } |
|
635 |
|
636 return KErrNone; |
|
637 } |
|
638 //End of file |