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