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