26
|
1 |
/*
|
|
2 |
* Copyright (c) 2003 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 for screensaver shared data monitoring.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
#include <coemain.h>
|
|
21 |
#include <ScreensaverInternalCRKeys.h>
|
|
22 |
#include <UsbWatcherInternalPSKeys.h>
|
|
23 |
#include <avkondomainpskeys.h> // kaknkeyguardstatus
|
|
24 |
#include <ctsydomainpskeys.h> // kpsuidctsycallinformation
|
|
25 |
#include <startupdomainpskeys.h> // kpsglobalsystemstate
|
|
26 |
#include <ScreensaverInternalPSKeys.h>
|
|
27 |
#include <UikonInternalPSKeys.h> // kuikmmcinserted
|
|
28 |
#include <hwrmpowerstatesdkpskeys.h>
|
|
29 |
#include <ctsydomaincrkeys.h>
|
|
30 |
#include <centralrepository.h>
|
|
31 |
|
|
32 |
#ifdef RD_UI_TRANSITION_EFFECTS_PHASE2
|
|
33 |
#include <akntransitionutils.h>
|
|
34 |
#endif
|
|
35 |
|
|
36 |
#include "screensavershareddatamonitor.h"
|
|
37 |
#include "screensavershareddatai.h"
|
|
38 |
#include "screensaverrepositorywatcher.h"
|
|
39 |
#include "screensaverview.h"
|
|
40 |
#include "screensaverengine.h"
|
|
41 |
#include "screensaverappui.h"
|
|
42 |
#include "screensaversubscriber.h"
|
|
43 |
#include "screensaverutility.h"
|
|
44 |
|
|
45 |
//System shuttingdown value
|
|
46 |
const TInt KSystemShuttingdown = 1;
|
|
47 |
|
|
48 |
// -----------------------------------------------------------------------------
|
|
49 |
// CScreensaverSharedDataMonitor::~CScreensaverSharedDataMonitor
|
|
50 |
// -----------------------------------------------------------------------------
|
|
51 |
//
|
|
52 |
CScreensaverSharedDataMonitor::~CScreensaverSharedDataMonitor()
|
|
53 |
{
|
|
54 |
DeleteSubscriber( iPreviewModeSubscriber );
|
|
55 |
iPreviewModeProperty.Close();
|
|
56 |
|
|
57 |
DeleteSubscriber( iMMCWatchSubscriber );
|
|
58 |
iMMCWatchProperty.Close();
|
|
59 |
|
|
60 |
DeleteSubscriber( iUSBWatchSubscriber );
|
|
61 |
iUSBWatchProperty.Close();
|
|
62 |
|
|
63 |
DeleteSubscriber( iKeyguardStateSubscriber );
|
|
64 |
iKeyguardStateProperty.Close();
|
|
65 |
|
|
66 |
DeleteSubscriber( iCallStateSubscriber );
|
|
67 |
iCallStateProperty.Close();
|
|
68 |
|
|
69 |
DeleteSubscriber( iShuttingDownSubscriber );
|
|
70 |
iShuttingDownProperty.Close();
|
|
71 |
|
|
72 |
DeleteSubscriber( iActivateSSSubscriber );
|
|
73 |
iActivateSSProperty.Close();
|
|
74 |
|
|
75 |
DeleteSubscriber( iChargerStateSubscriber );
|
|
76 |
iChargerStateProperty.Close();
|
|
77 |
|
|
78 |
delete iMessageWaitingWatcher;
|
|
79 |
delete iMessageWaitingRepository;
|
|
80 |
}
|
|
81 |
|
|
82 |
// -----------------------------------------------------------------------------
|
|
83 |
// CScreensaverSharedDataMonitor::NewL
|
|
84 |
// -----------------------------------------------------------------------------
|
|
85 |
//
|
|
86 |
CScreensaverSharedDataMonitor* CScreensaverSharedDataMonitor::NewL( CScreensaverSharedDataI* aData )
|
|
87 |
{
|
|
88 |
CScreensaverSharedDataMonitor* self = new( ELeave )CScreensaverSharedDataMonitor( aData );
|
|
89 |
CleanupStack::PushL( self );
|
|
90 |
self->ConstructL();
|
|
91 |
CleanupStack::Pop(); // self;
|
|
92 |
return self;
|
|
93 |
}
|
|
94 |
|
|
95 |
// -----------------------------------------------------------------------------
|
|
96 |
// CScreensaverSharedDataMonitor::CScreensaverSharedDataMonitor
|
|
97 |
// -----------------------------------------------------------------------------
|
|
98 |
//
|
|
99 |
CScreensaverSharedDataMonitor::CScreensaverSharedDataMonitor(
|
|
100 |
CScreensaverSharedDataI* aData )
|
|
101 |
:iData( aData )
|
|
102 |
{
|
|
103 |
// No implementation required
|
|
104 |
}
|
|
105 |
|
|
106 |
// -----------------------------------------------------------------------------
|
|
107 |
// CScreensaverSharedDataMonitor::ConstructL
|
|
108 |
// -----------------------------------------------------------------------------
|
|
109 |
//
|
|
110 |
void CScreensaverSharedDataMonitor::ConstructL()
|
|
111 |
{
|
|
112 |
User::LeaveIfError(iPreviewModeProperty.Attach(KPSUidScreenSaver, KScreenSaverPreviewMode));
|
|
113 |
iPreviewModeSubscriber = new (ELeave) CSubscriber(TCallBack(HandlePreviewModeChanged, this), iPreviewModeProperty);
|
|
114 |
iPreviewModeSubscriber->SubscribeL();
|
|
115 |
|
|
116 |
|
|
117 |
// MMC watcher
|
|
118 |
User::LeaveIfError(iMMCWatchProperty.Attach(KPSUidUikon, KUikMMCInserted));
|
|
119 |
iMMCWatchSubscriber = new (ELeave) CSubscriber(
|
|
120 |
TCallBack(HandleMMCStateChanged, this), iMMCWatchProperty);
|
|
121 |
iMMCWatchSubscriber->SubscribeL();
|
|
122 |
|
|
123 |
// USB watcher (MMC dismount)
|
|
124 |
User::LeaveIfError(iUSBWatchProperty.Attach(
|
|
125 |
KPSUidUsbWatcher, KUsbWatcherSelectedPersonality));
|
|
126 |
iUSBWatchSubscriber = new (ELeave) CSubscriber(
|
|
127 |
TCallBack(HandleUSBStateChanged, this), iUSBWatchProperty);
|
|
128 |
iUSBWatchSubscriber->SubscribeL();
|
|
129 |
|
|
130 |
// Keyguard state watcher
|
|
131 |
User::LeaveIfError(iKeyguardStateProperty.Attach(
|
|
132 |
KPSUidAvkonDomain, KAknKeyguardStatus));
|
|
133 |
iKeyguardStateSubscriber = new (ELeave) CSubscriber(
|
|
134 |
TCallBack(HandleKeyguardStateChanged, this), iKeyguardStateProperty);
|
|
135 |
iKeyguardStateSubscriber->SubscribeL();
|
|
136 |
|
|
137 |
// Call state watcher
|
|
138 |
User::LeaveIfError(iCallStateProperty.Attach( KPSUidCtsyCallInformation, KCTsyCallState ) );
|
|
139 |
iCallStateSubscriber = new (ELeave) CSubscriber(
|
|
140 |
TCallBack(HandleCallStateChanged, this), iCallStateProperty);
|
|
141 |
iCallStateSubscriber->SubscribeL();
|
|
142 |
|
|
143 |
// Shutting down state watcher
|
|
144 |
User::LeaveIfError( iShuttingDownProperty.Attach( KPSUidStartup, KPSGlobalSystemState ) );
|
|
145 |
iShuttingDownSubscriber = new (ELeave) CSubscriber(
|
|
146 |
TCallBack(HandleShuttingDownStateChanged, this), iShuttingDownProperty);
|
|
147 |
iShuttingDownSubscriber->SubscribeL();
|
|
148 |
|
|
149 |
User::LeaveIfError( iActivateSSProperty.Attach( KPSUidScreenSaver, KScreenSaverActivate ) );
|
|
150 |
iActivateSSSubscriber = new( ELeave ) CSubscriber(
|
|
151 |
TCallBack( HandleActivateSSChanged, this ), iActivateSSProperty );
|
|
152 |
iActivateSSSubscriber->SubscribeL();
|
|
153 |
|
|
154 |
User::LeaveIfError( iChargerStateProperty.Attach( KPSUidHWRMPowerState, KHWRMChargingStatus ) );
|
|
155 |
iChargerStateSubscriber = new (ELeave) CSubscriber(
|
|
156 |
TCallBack( HandleChargerStateChanged, this ), iChargerStateProperty );
|
|
157 |
iChargerStateSubscriber->SubscribeL();
|
|
158 |
|
|
159 |
iMessageWaitingRepository = CRepository::NewL( KCRUidCtsyMessageWaitingIndicator );
|
|
160 |
iMessageWaitingWatcher = CScreensaverRepositoryWatcher::NewL( KCRUidCtsyMessageWaitingIndicator,
|
|
161 |
TCallBack( HandleMessageWaitingStateChanged, this ),
|
|
162 |
iMessageWaitingRepository );
|
|
163 |
|
|
164 |
}
|
|
165 |
|
|
166 |
// -----------------------------------------------------------------------------
|
|
167 |
// CScreensaverSharedDataMonitor::View
|
|
168 |
// -----------------------------------------------------------------------------
|
|
169 |
//
|
|
170 |
CScreensaverView* CScreensaverSharedDataMonitor::View()
|
|
171 |
{
|
|
172 |
return STATIC_CAST( CScreensaverAppUi*, CCoeEnv::Static()->AppUi() )->ScreensaverView();
|
|
173 |
}
|
|
174 |
|
|
175 |
// -----------------------------------------------------------------------------
|
|
176 |
// CScreensaverSharedDataMonitor::Model
|
|
177 |
// -----------------------------------------------------------------------------
|
|
178 |
//
|
|
179 |
CScreensaverEngine& CScreensaverSharedDataMonitor::Model()
|
|
180 |
{
|
|
181 |
return STATIC_CAST( CScreensaverAppUi*, CCoeEnv::Static()->AppUi() )->Model();
|
|
182 |
}
|
|
183 |
|
|
184 |
|
|
185 |
// -----------------------------------------------------------------------------
|
|
186 |
// CScreensaverSharedDataMonitor::DeteleSubscriber
|
|
187 |
// -----------------------------------------------------------------------------
|
|
188 |
//
|
|
189 |
void CScreensaverSharedDataMonitor::DeleteSubscriber( CSubscriber*& aSubscriber )
|
|
190 |
{
|
|
191 |
if ( aSubscriber )
|
|
192 |
{
|
|
193 |
aSubscriber->StopSubscribe();
|
|
194 |
}
|
|
195 |
delete aSubscriber;
|
|
196 |
}
|
|
197 |
|
|
198 |
// -----------------------------------------------------------------------------
|
|
199 |
// CScreensaverSharedDataMonitor::HandlePreviewModeChanged
|
|
200 |
// Handles preview mode property key change. If key is changed to 1,
|
|
201 |
// preview mode is started
|
|
202 |
// -----------------------------------------------------------------------------
|
|
203 |
//
|
|
204 |
TInt CScreensaverSharedDataMonitor::HandlePreviewModeChanged(TAny *aPtr)
|
|
205 |
{
|
|
206 |
CScreensaverSharedDataMonitor *data = STATIC_CAST(CScreensaverSharedDataMonitor*, aPtr);
|
|
207 |
|
|
208 |
if ( data->iData->ScreensaverPreviewMode() == 1)
|
|
209 |
{
|
|
210 |
TRAP_IGNORE( data->Model().StartPreviewModeL() );
|
|
211 |
}
|
|
212 |
|
|
213 |
return KErrNone;
|
|
214 |
}
|
|
215 |
|
|
216 |
|
|
217 |
// -----------------------------------------------------------------------------
|
|
218 |
// CScreensaverSharedDataMonitor::HandleMMCStateChanged
|
|
219 |
// Handles MMC state change callback. If current plugin is loaded from
|
|
220 |
// MMC, screensaver defaults to date & time when MMC removed
|
|
221 |
// -----------------------------------------------------------------------------
|
|
222 |
//
|
|
223 |
TInt CScreensaverSharedDataMonitor::HandleMMCStateChanged(TAny* aPtr)
|
|
224 |
{
|
|
225 |
User::ResetInactivityTime();
|
|
226 |
STATIC_CAST(CScreensaverSharedDataMonitor*, aPtr)->Model().StopScreenSaver();
|
|
227 |
return KErrNone;
|
|
228 |
}
|
|
229 |
|
|
230 |
// -----------------------------------------------------------------------------
|
|
231 |
// CScreensaverSharedDataMonitor::HandleUSBStateChanged
|
|
232 |
// Handles USB state change callback. If current plugin is loaded from
|
|
233 |
// MMC, screensaver defaults to date & time when USB attached
|
|
234 |
// -----------------------------------------------------------------------------
|
|
235 |
//
|
|
236 |
TInt CScreensaverSharedDataMonitor::HandleUSBStateChanged(TAny* aPtr)
|
|
237 |
{
|
|
238 |
// Same handler as in MMC removal, parameter tells it's because of USB
|
|
239 |
User::ResetInactivityTime();
|
|
240 |
STATIC_CAST(CScreensaverSharedDataMonitor*, aPtr)->Model().StopScreenSaver();
|
|
241 |
return KErrNone;
|
|
242 |
}
|
|
243 |
|
|
244 |
// -----------------------------------------------------------------------------
|
|
245 |
// CScreensaverSharedDataMonitor::HandleKeyguardStateChanged
|
|
246 |
// Handles keyguards status change callback.
|
|
247 |
// When keys become locked, screensaver timeout is shortened.
|
|
248 |
// -----------------------------------------------------------------------------
|
|
249 |
//
|
|
250 |
TInt CScreensaverSharedDataMonitor::HandleKeyguardStateChanged(TAny* aPtr)
|
|
251 |
{
|
|
252 |
// If keyguard just became unlocked, inform model so that
|
|
253 |
// short timeout use is reset. Otherwise there might be a situation
|
|
254 |
// where short timeout was in use, user opened keys, did something
|
|
255 |
// without letting the device idle for short timeout period and
|
|
256 |
// locked keys again. Then short timeout would remain in use without this
|
|
257 |
// notification.
|
|
258 |
// Also inform of keys locked, in case Screensaver is running this
|
|
259 |
// happened because of automatic keyguard fired, and screensaver
|
|
260 |
// should update the display to show the keyguard indicator
|
|
261 |
CScreensaverSharedDataMonitor* _this =
|
|
262 |
STATIC_CAST(CScreensaverSharedDataMonitor*, aPtr);
|
|
263 |
|
|
264 |
_this->Model().HandleKeyguardStateChanged( _this->iData->IsKeyguardOn() );
|
|
265 |
return KErrNone;
|
|
266 |
}
|
|
267 |
|
|
268 |
// -----------------------------------------------------------------------------
|
|
269 |
// CScreensaverSharedDataMonitor::HandleCallStateChanged
|
|
270 |
// Handles call state change callback. If call state changes,
|
|
271 |
// screensaver is stopped
|
|
272 |
// -----------------------------------------------------------------------------
|
|
273 |
//
|
|
274 |
TInt CScreensaverSharedDataMonitor::HandleCallStateChanged(TAny* aPtr)
|
|
275 |
{
|
|
276 |
#ifdef RD_UI_TRANSITION_EFFECTS_PHASE2
|
|
277 |
// Prevent fullscreen transition from screensaver on incoming call
|
|
278 |
CAknTransitionUtils::SetData( KScreensaverCallStateChange, (TAny*)1 );
|
|
279 |
#endif
|
|
280 |
User::ResetInactivityTime();
|
|
281 |
STATIC_CAST(CScreensaverSharedDataMonitor*, aPtr)->Model().StopScreenSaver();
|
|
282 |
return KErrNone;
|
|
283 |
}
|
|
284 |
|
|
285 |
// -----------------------------------------------------------------------------
|
|
286 |
// CScreensaverSharedDataMonitor::HandleShuttingDownStateChanged
|
|
287 |
// -----------------------------------------------------------------------------
|
|
288 |
//
|
|
289 |
TInt CScreensaverSharedDataMonitor::HandleShuttingDownStateChanged( TAny* /*aPtr*/ )
|
|
290 |
{
|
|
291 |
TInt startupState = -1;
|
|
292 |
|
|
293 |
RProperty::Get( KPSUidStartup, KPSGlobalSystemState, startupState );
|
|
294 |
|
|
295 |
if( startupState == ESwStateShuttingDown )
|
|
296 |
{
|
|
297 |
RProperty::Set( KPSUidScreenSaver, KScreenSaverAllowScreenSaver, KSystemShuttingdown);
|
|
298 |
}
|
|
299 |
|
|
300 |
return KErrNone;
|
|
301 |
}
|
|
302 |
|
|
303 |
// ---------------------------------------------------------------------------
|
|
304 |
// CScreensaverSharedDataMonitor::HandleActivateSSChanged
|
|
305 |
// ---------------------------------------------------------------------------
|
|
306 |
//
|
|
307 |
TInt CScreensaverSharedDataMonitor::HandleActivateSSChanged( TAny* aPtr )
|
|
308 |
{
|
|
309 |
TInt activateState = -1;
|
|
310 |
|
|
311 |
RProperty::Get( KPSUidScreenSaver, KScreenSaverActivate, activateState );
|
|
312 |
|
|
313 |
if( activateState && -1 != activateState )
|
|
314 |
{
|
|
315 |
// Enable SS
|
|
316 |
SCRLOGGER_WRITE("SharedDataMonitor: Activate SS");
|
|
317 |
STATIC_CAST(CScreensaverSharedDataMonitor*, aPtr)->Model().StartScreenSaver();
|
|
318 |
}
|
|
319 |
else if ( !activateState )
|
|
320 |
{
|
|
321 |
// Disable SS
|
|
322 |
SCRLOGGER_WRITE("SharedDataMonitor: Stop SS");
|
|
323 |
STATIC_CAST(CScreensaverSharedDataMonitor*, aPtr)->Model().StopScreenSaver();
|
|
324 |
}
|
|
325 |
else
|
|
326 |
{
|
|
327 |
// Unknown state
|
|
328 |
}
|
|
329 |
return KErrNone;
|
|
330 |
}
|
|
331 |
|
|
332 |
// ---------------------------------------------------------------------------
|
|
333 |
// CScreensaverSharedDataMonitor::HandleChargerStateChanged
|
|
334 |
// ---------------------------------------------------------------------------
|
|
335 |
//
|
|
336 |
TInt CScreensaverSharedDataMonitor::HandleChargerStateChanged( TAny* aPtr )
|
|
337 |
{
|
|
338 |
TInt state = -1;
|
|
339 |
|
|
340 |
RProperty::Get( KPSUidHWRMPowerState, KHWRMChargingStatus, state );
|
|
341 |
|
|
342 |
switch ( state )
|
|
343 |
{
|
|
344 |
case EChargingStatusError: // Some error has occurred when charger is connected or charging.
|
|
345 |
case EChargingStatusNotConnected: // Charger not connected/uninitialized
|
|
346 |
case EChargingStatusCharging: // Device is charging
|
|
347 |
{
|
|
348 |
User::ResetInactivityTime();
|
|
349 |
STATIC_CAST(CScreensaverSharedDataMonitor*, aPtr)->Model().StopScreenSaver();
|
|
350 |
}
|
|
351 |
break;
|
|
352 |
case EChargingStatusChargingComplete: // Charging completed
|
|
353 |
case EChargingStatusNotCharging: // Charger is connected, device not charging
|
|
354 |
case EChargingStatusAlmostComplete: // Charging almost completed
|
|
355 |
case EChargingStatusChargingContinued: // Charging continued after brief interruption
|
|
356 |
default:
|
|
357 |
break;
|
|
358 |
}
|
|
359 |
return KErrNone;
|
|
360 |
}
|
|
361 |
|
|
362 |
// ---------------------------------------------------------------------------
|
|
363 |
//
|
|
364 |
// ---------------------------------------------------------------------------
|
|
365 |
//
|
|
366 |
TInt CScreensaverSharedDataMonitor::HandleMessageWaitingStateChanged( TAny* aPtr )
|
|
367 |
{
|
|
368 |
CScreensaverSharedDataMonitor* self = STATIC_CAST(CScreensaverSharedDataMonitor*, aPtr);
|
|
369 |
if ( self->iMessageWaitingWatcher->ChangedKey() == KCtsyMessageWaitingDisplayStatus )
|
|
370 |
{
|
|
371 |
self->View()->UpdateAndRefresh();
|
|
372 |
}
|
|
373 |
return KErrNone;
|
|
374 |
}
|
|
375 |
|
|
376 |
// End of file
|