26
|
1 |
/*
|
|
2 |
* Copyright (c) 2003-2006 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 connections.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
#include <msvids.h>
|
|
21 |
#include <MProfileName.h> // Profile API, not yet included in .h
|
|
22 |
#include <MProfileTones.h>
|
|
23 |
#include <TProfileToneSettings.h>
|
|
24 |
#include <centralrepository.h>
|
|
25 |
#include <coreapplicationuisdomainpskeys.h> // KCoreAppUIsUipInd, KLightsVTForcedLightsOn
|
|
26 |
#include <activeidle2domainpskeys.h> // KPSUidAiInformation
|
|
27 |
#include <settingsinternalcrkeys.h> // KSettingsScreenSaverPeriod
|
|
28 |
#include <LogsDomainCRKeys.h> // KLogsNewMissedCalls
|
|
29 |
#include <ScreensaverInternalCRKeys.h>
|
|
30 |
#include <AvkonInternalCRKeys.h> // KAknNewContactsNoteActive
|
|
31 |
#include <avkondomainpskeys.h> // KAknKeyguardStatus
|
|
32 |
#include <ctsydomaincrkeys.h> // Message (voice) waiting status
|
|
33 |
#include <ctsydomainpskeys.h> // KCTsyCallState
|
|
34 |
#include <startupdomainpskeys.h> // KPSGlobalSystemState
|
|
35 |
#include <AknSkinsInternalCRKeys.h>
|
|
36 |
#include <MProfileEngine.h> // Profile engine API
|
|
37 |
#include <MProfile.h>
|
|
38 |
#include <NcnListDomainCRKeys.h>
|
|
39 |
|
|
40 |
#include "screensaverappui.h"
|
|
41 |
#include "screensaverctrlmovingtext.h"
|
|
42 |
#include "screensaverengine.h"
|
|
43 |
#include "screensavershareddatai.h"
|
|
44 |
#include "ScreensaverInternalPSKeys.h"
|
|
45 |
#include "screensaverutility.h"
|
|
46 |
#include "screensaverrepositorywatcher.h"
|
|
47 |
#include "screensaversubscriber.h"
|
|
48 |
|
|
49 |
const TInt KTimeoutDefault = 15; // seconds (also in GS)
|
|
50 |
const TInt KTimeoutMin = 5; // minimum timeout in seconds (also in GS)
|
|
51 |
|
|
52 |
// Screensaver "On/Off" status values
|
|
53 |
const TInt KScreensaverOff = 0;
|
|
54 |
const TInt KScreensaverOn = 1;
|
|
55 |
|
|
56 |
// Screensaver activated from idle status values
|
|
57 |
const TInt KScreensaverNotFromIdle = 0;
|
|
58 |
const TInt KScreensaverStartedFromIdle = 1;
|
|
59 |
|
|
60 |
// Screen saver text type.
|
|
61 |
// _LIT( KScreenSaverTypeText, "Text" );
|
|
62 |
// Screensaver "None" (Sleep mode)
|
|
63 |
// _LIT( KScreenSaverTypeNone, "None" );
|
|
64 |
|
|
65 |
// Define security policies for Screensavers property keys
|
|
66 |
_LIT_SECURITY_POLICY_PASS(KSSPolicyPass);
|
|
67 |
_LIT_SECURITY_POLICY_C1(KSSPolicyWriteUserData, ECapabilityWriteUserData);
|
|
68 |
_LIT_SECURITY_POLICY_S0(KSSPolicyWriteSSOnly, 0x100056cf);
|
|
69 |
|
|
70 |
//
|
|
71 |
// CScreensaverSharedDataI
|
|
72 |
//
|
|
73 |
// -----------------------------------------------------------------------------
|
|
74 |
// CScreensaverSharedDataI::NewL
|
|
75 |
// -----------------------------------------------------------------------------
|
|
76 |
//
|
|
77 |
CScreensaverSharedDataI* CScreensaverSharedDataI::NewL()
|
|
78 |
{
|
|
79 |
CScreensaverSharedDataI* self = new (ELeave) CScreensaverSharedDataI();
|
|
80 |
CleanupStack::PushL(self);
|
|
81 |
self->ConstructL();
|
|
82 |
CleanupStack::Pop(); //self
|
|
83 |
return self;
|
|
84 |
}
|
|
85 |
|
|
86 |
|
|
87 |
// -----------------------------------------------------------------------------
|
|
88 |
// CScreensaverSharedDataI::~CScreensaverSharedDataI
|
|
89 |
// -----------------------------------------------------------------------------
|
|
90 |
//
|
|
91 |
CScreensaverSharedDataI::~CScreensaverSharedDataI()
|
|
92 |
{
|
|
93 |
// Release the active profile resources
|
|
94 |
InvalidateActiveProfile();
|
|
95 |
|
|
96 |
// Release the profile engine
|
|
97 |
if (iProfileEngine)
|
|
98 |
{
|
|
99 |
// No need to delete pointer, just release resources
|
|
100 |
iProfileEngine->Release();
|
|
101 |
}
|
|
102 |
|
|
103 |
delete iScreensaverRepositoryWatcher;
|
|
104 |
delete iScreensaverRepository;
|
|
105 |
delete iSettingsRepositoryWatcher;
|
|
106 |
delete iSettingsRepository;
|
|
107 |
delete iCTsyRepository;
|
|
108 |
delete iInboxFolder;
|
|
109 |
delete iMsvSession;
|
|
110 |
}
|
|
111 |
|
|
112 |
// -----------------------------------------------------------------------------
|
|
113 |
// CScreensaverSharedDataI::DisplayObjectType
|
|
114 |
// -----------------------------------------------------------------------------
|
|
115 |
//
|
|
116 |
TDisplayObjectType CScreensaverSharedDataI::DisplayObjectType() const
|
|
117 |
{
|
|
118 |
TInt type = 0;
|
|
119 |
|
|
120 |
if (iScreensaverRepository)
|
|
121 |
{
|
|
122 |
iScreensaverRepository->Get( KScreenSaverObject, type );
|
|
123 |
}
|
|
124 |
|
|
125 |
return ( TDisplayObjectType )type;
|
|
126 |
}
|
|
127 |
|
|
128 |
// -----------------------------------------------------------------------------
|
|
129 |
// CScreensaverSharedDataI::SetDisplayObjectType
|
|
130 |
// -----------------------------------------------------------------------------
|
|
131 |
//
|
|
132 |
void CScreensaverSharedDataI::SetDisplayObjectType( const TDisplayObjectType aType )
|
|
133 |
{
|
|
134 |
if( iScreensaverRepository )
|
|
135 |
{
|
|
136 |
iScreensaverRepository->Set(KScreenSaverObject, aType);
|
|
137 |
}
|
|
138 |
}
|
|
139 |
|
|
140 |
// -----------------------------------------------------------------------------
|
|
141 |
// CScreensaverSharedDataI::GetDisplayObjectText
|
|
142 |
// -----------------------------------------------------------------------------
|
|
143 |
//
|
|
144 |
void CScreensaverSharedDataI::GetDisplayObjectText( TDes& aDes ) const
|
|
145 |
{
|
|
146 |
CEikonEnv::Static()->ReadResource(aDes, R_SCREEN_SAVER_TEXT);
|
|
147 |
|
|
148 |
if ( iScreensaverRepository )
|
|
149 |
{
|
|
150 |
iScreensaverRepository->Get( KScreenSaverText, aDes );
|
|
151 |
}
|
|
152 |
}
|
|
153 |
|
|
154 |
// -----------------------------------------------------------------------------
|
|
155 |
// CScreensaverSharedDataI::PluginName
|
|
156 |
// -----------------------------------------------------------------------------
|
|
157 |
//
|
|
158 |
void CScreensaverSharedDataI::GetPluginName( TFileName& aFileName ) const
|
|
159 |
{
|
|
160 |
if ( iScreensaverRepository )
|
|
161 |
{
|
|
162 |
iScreensaverRepository->Get( KScreenSaverPluginName, aFileName );
|
|
163 |
}
|
|
164 |
}
|
|
165 |
|
|
166 |
// -----------------------------------------------------------------------------
|
|
167 |
// CScreensaverSharedDataI::ColorInversionUsed
|
|
168 |
// -----------------------------------------------------------------------------
|
|
169 |
//
|
|
170 |
TBool CScreensaverSharedDataI::IsInvertedColors() const
|
|
171 |
{
|
|
172 |
TInt colorInversionUsed(0);
|
|
173 |
|
|
174 |
if( iScreensaverRepository )
|
|
175 |
{
|
|
176 |
iScreensaverRepository->Get( KScreenSaverInvertedColors, colorInversionUsed );
|
|
177 |
}
|
|
178 |
|
|
179 |
return ( colorInversionUsed != 0 );
|
|
180 |
}
|
|
181 |
|
|
182 |
// -----------------------------------------------------------------------------
|
|
183 |
// CScreensaverSharedDataI::ScreensaverTimeout
|
|
184 |
// -----------------------------------------------------------------------------
|
|
185 |
//
|
|
186 |
TInt CScreensaverSharedDataI::ScreensaverTimeout() const
|
|
187 |
{
|
|
188 |
TInt timeout = KTimeoutDefault;
|
|
189 |
|
|
190 |
if (iSettingsRepository)
|
|
191 |
{
|
|
192 |
iSettingsRepository->Get(KSettingsAutomaticKeyguardTime, timeout);
|
|
193 |
}
|
|
194 |
// No less than minimum timeout
|
|
195 |
// Old backed up minutes 1-4 will cause default timeout after
|
|
196 |
// being restored to new sw using seconds
|
|
197 |
if (timeout < KTimeoutMin)
|
|
198 |
{
|
|
199 |
return KTimeoutDefault;
|
|
200 |
}
|
|
201 |
|
|
202 |
return timeout;
|
|
203 |
}
|
|
204 |
|
|
205 |
// -----------------------------------------------------------------------------
|
|
206 |
// CScreensaverSharedDataI::IsNCNActive
|
|
207 |
// -----------------------------------------------------------------------------
|
|
208 |
//
|
|
209 |
TBool CScreensaverSharedDataI::IsNCNActive() const
|
|
210 |
{
|
|
211 |
// Setting the flag here is also needed, because Screensaver should not
|
|
212 |
// display new calls when Ncn note has been cancelled (even if the missed
|
|
213 |
// calls count is still nonzero).
|
|
214 |
// Also, when the phone is (re)started, and there are missed calls,
|
|
215 |
// Ncn will pop a note, This is the only way Screensaver knows about that.
|
|
216 |
|
|
217 |
CRepository* avkonRepository = NULL;
|
|
218 |
|
|
219 |
TRAP_IGNORE( avkonRepository = CRepository::NewL( KCRUidAvkon ) );
|
|
220 |
|
|
221 |
TInt value = 0;
|
|
222 |
|
|
223 |
if ( avkonRepository )
|
|
224 |
{
|
|
225 |
avkonRepository->Get( KAknNewContactsNoteActive, value );
|
|
226 |
}
|
|
227 |
|
|
228 |
delete avkonRepository;
|
|
229 |
|
|
230 |
return ( value != 0 );
|
|
231 |
}
|
|
232 |
|
|
233 |
// -----------------------------------------------------------------------------
|
|
234 |
// CScreensaverSharedDataI::NewMissedCalls
|
|
235 |
// -----------------------------------------------------------------------------
|
|
236 |
//
|
|
237 |
TInt CScreensaverSharedDataI::NewMissedCalls() const
|
|
238 |
{
|
|
239 |
CRepository* logsRepository = NULL;
|
|
240 |
|
|
241 |
TRAP_IGNORE( logsRepository = CRepository::NewL( KCRUidLogs ) );
|
|
242 |
|
|
243 |
TInt value = 0;
|
|
244 |
|
|
245 |
if ( logsRepository )
|
|
246 |
{
|
|
247 |
logsRepository->Get( KLogsNewMissedCalls, value );
|
|
248 |
}
|
|
249 |
|
|
250 |
delete logsRepository;
|
|
251 |
|
|
252 |
return value;
|
|
253 |
}
|
|
254 |
|
|
255 |
// -----------------------------------------------------------------------------
|
|
256 |
// CScreensaverSharedDataI::SetSSForcedLightsOn
|
|
257 |
// -----------------------------------------------------------------------------
|
|
258 |
//
|
|
259 |
void CScreensaverSharedDataI::SetSSForcedLightsOn(TInt aSecs)
|
|
260 |
{
|
|
261 |
SCRLOGGER_WRITEF(_L("SCR: RequestLights(%d)"), aSecs);
|
|
262 |
|
|
263 |
RProperty::Set( KPSUidCoreApplicationUIs, KLightsSSForcedLightsOn, aSecs );
|
|
264 |
}
|
|
265 |
|
|
266 |
// -----------------------------------------------------------------------------
|
|
267 |
// CScreensaverSharedDataI::SetScreensaverStatus
|
|
268 |
// Indicate whether Screensaver is active or not
|
|
269 |
// -----------------------------------------------------------------------------
|
|
270 |
//
|
|
271 |
void CScreensaverSharedDataI::SetScreensaverStatus( TBool aOn /* = ETrue */ )
|
|
272 |
{
|
|
273 |
//Check if the value is already updated. If so, setting the value again
|
|
274 |
//will cause unnecessary call backs to any subscribers of this property
|
|
275 |
if ( aOn )
|
|
276 |
{
|
|
277 |
RProperty::Set( KPSUidScreenSaver, KScreenSaverOn, KScreensaverOn );
|
|
278 |
//else - no need to re-apply the same value
|
|
279 |
}
|
|
280 |
else //aOn is false
|
|
281 |
{
|
|
282 |
RProperty::Set( KPSUidScreenSaver, KScreenSaverOn, KScreensaverOff );
|
|
283 |
//else - no need to re-apply the same value
|
|
284 |
|
|
285 |
//if stop from idle, change the status
|
|
286 |
RProperty::Set( KPSUidScreenSaver, KScreenSaverOn, KScreensaverNotFromIdle);
|
|
287 |
}
|
|
288 |
}
|
|
289 |
|
|
290 |
// -----------------------------------------------------------------------------
|
|
291 |
// CScreensaverSharedDataI::SetSSStartedFromIdleStatus
|
|
292 |
// Set "Screensaver started from Idle" status
|
|
293 |
// -----------------------------------------------------------------------------
|
|
294 |
//
|
|
295 |
void CScreensaverSharedDataI::SetSSStartedFromIdleStatus()
|
|
296 |
{
|
|
297 |
TInt idleState = EPSAiBackground;
|
|
298 |
RProperty::Get(KPSUidAiInformation, KActiveIdleState, idleState);
|
|
299 |
|
|
300 |
if (idleState == EPSAiBackground)
|
|
301 |
{
|
|
302 |
RProperty::Set( KPSUidScreenSaver, KScreenSaverActivatedFromIdle, KScreensaverNotFromIdle );
|
|
303 |
}
|
|
304 |
else
|
|
305 |
{
|
|
306 |
RProperty::Set( KPSUidScreenSaver, KScreenSaverActivatedFromIdle, KScreensaverStartedFromIdle );
|
|
307 |
}
|
|
308 |
}
|
|
309 |
|
|
310 |
// -----------------------------------------------------------------------------
|
|
311 |
// CScreensaverSharedDataI::IsScreenSaverAllowed
|
|
312 |
// Set "Screensaver started from Idle" status
|
|
313 |
// -----------------------------------------------------------------------------
|
|
314 |
//
|
|
315 |
TInt CScreensaverSharedDataI::IsScreenSaverAllowed() const
|
|
316 |
{
|
|
317 |
TInt value = 0;
|
|
318 |
|
|
319 |
RProperty::Get( KPSUidScreenSaver, KScreenSaverAllowScreenSaver, value );
|
|
320 |
|
|
321 |
return value;
|
|
322 |
}
|
|
323 |
|
|
324 |
TInt CScreensaverSharedDataI::ScreensaverPreviewMode() const
|
|
325 |
{
|
|
326 |
TInt value = 0;
|
|
327 |
|
|
328 |
RProperty::Get( KPSUidScreenSaver, KScreenSaverPreviewMode, value );
|
|
329 |
|
|
330 |
return value;
|
|
331 |
}
|
|
332 |
|
|
333 |
// -----------------------------------------------------------------------------
|
|
334 |
// CScreensaverSharedDataI::SetScreensaverPreviewMode
|
|
335 |
// -----------------------------------------------------------------------------
|
|
336 |
//
|
|
337 |
void CScreensaverSharedDataI::SetScreensaverPreviewMode( const TInt aMode )
|
|
338 |
{
|
|
339 |
RProperty::Set( KPSUidScreenSaver, KScreenSaverPreviewMode, aMode );
|
|
340 |
}
|
|
341 |
|
|
342 |
// -----------------------------------------------------------------------------
|
|
343 |
// CScreensaverSharedDataI::ScreensaverPreviewState
|
|
344 |
// Get preview state
|
|
345 |
// -----------------------------------------------------------------------------
|
|
346 |
//
|
|
347 |
TScreenSaverPreviewState CScreensaverSharedDataI::ScreensaverPreviewState() const
|
|
348 |
{
|
|
349 |
TInt state = EScreenSaverPreviewNone;
|
|
350 |
RProperty::Get( KPSUidScreenSaver, KScreenSaverPreviewState, state );
|
|
351 |
|
|
352 |
return ( TScreenSaverPreviewState ) state;
|
|
353 |
}
|
|
354 |
|
|
355 |
// -----------------------------------------------------------------------------
|
|
356 |
// CScreensaverSharedDataI::SetScreensaverPreviewState
|
|
357 |
// Report preview state
|
|
358 |
// -----------------------------------------------------------------------------
|
|
359 |
//
|
|
360 |
void CScreensaverSharedDataI::SetScreensaverPreviewState(
|
|
361 |
const TScreenSaverPreviewState aState )
|
|
362 |
{
|
|
363 |
RProperty::Set( KPSUidScreenSaver, KScreenSaverPreviewState, aState );
|
|
364 |
}
|
|
365 |
|
|
366 |
// -----------------------------------------------------------------------------
|
|
367 |
// CScreensaverSharedDataI::IsKeyguardOn
|
|
368 |
// -----------------------------------------------------------------------------
|
|
369 |
//
|
|
370 |
TBool CScreensaverSharedDataI::IsKeyguardOn() const
|
|
371 |
{
|
|
372 |
// Report preview state
|
|
373 |
TInt state = 0;
|
|
374 |
|
|
375 |
RProperty::Get( KPSUidAvkonDomain, KAknKeyguardStatus, state );
|
|
376 |
|
|
377 |
return ( state != 0 );
|
|
378 |
}
|
|
379 |
|
|
380 |
// -----------------------------------------------------------------------------
|
|
381 |
// CScreensaverSharedDataI::IsUsePowerSaveMode
|
|
382 |
// -----------------------------------------------------------------------------
|
|
383 |
TBool CScreensaverSharedDataI::IsUsePowerSaveMode() const
|
|
384 |
{
|
|
385 |
TInt state = 0;
|
|
386 |
|
|
387 |
// Check if power save mode has been denied
|
|
388 |
RProperty::Get( KPSUidScreenSaver, KScreenSaverNoPowerSaveMode, state );
|
|
389 |
|
|
390 |
return ( state != 1 );
|
|
391 |
}
|
|
392 |
|
|
393 |
// -----------------------------------------------------------------------------
|
|
394 |
// CScreensaverSharedDataI::SystemStartupComplete
|
|
395 |
// Returns whether system startup has been completed
|
|
396 |
// -----------------------------------------------------------------------------
|
|
397 |
//
|
|
398 |
TBool CScreensaverSharedDataI::IsSystemStartupComplete()
|
|
399 |
{
|
|
400 |
if ( iStartupComplete == EFalse )
|
|
401 |
{
|
|
402 |
TInt startupState = -1;
|
|
403 |
RProperty::Get( KPSUidStartup, KPSGlobalSystemState, startupState );
|
|
404 |
|
|
405 |
switch (startupState)
|
|
406 |
{
|
|
407 |
case ESwStateNormalRfOn:
|
|
408 |
case ESwStateNormalRfOff:
|
|
409 |
case ESwStateNormalBTSap:
|
|
410 |
iStartupComplete = ETrue;
|
|
411 |
break;
|
|
412 |
default:
|
|
413 |
break;
|
|
414 |
}
|
|
415 |
}
|
|
416 |
return iStartupComplete;
|
|
417 |
}
|
|
418 |
|
|
419 |
// -----------------------------------------------------------------------------
|
|
420 |
// CScreensaverSharedDataI::DefaultScreensaverType
|
|
421 |
// -----------------------------------------------------------------------------
|
|
422 |
//
|
|
423 |
TDisplayObjectType CScreensaverSharedDataI::DefaultScreensaverType() const
|
|
424 |
{
|
|
425 |
return iDefaultType;
|
|
426 |
}
|
|
427 |
|
|
428 |
// -----------------------------------------------------------------------------
|
|
429 |
// CScreensaverSharedDataI::UnreadMessagesNumber
|
|
430 |
// -----------------------------------------------------------------------------
|
|
431 |
//
|
|
432 |
TInt CScreensaverSharedDataI::UnreadMessagesNumber()
|
|
433 |
{
|
|
434 |
TInt numberOfUnreadMessages = 0;
|
|
435 |
// Check how many unread messages there are in the In-box.
|
|
436 |
if( !iInboxFolder )
|
|
437 |
{
|
|
438 |
TRAPD( err, ConnectToInboxL() );
|
|
439 |
if (err != KErrNone)
|
|
440 |
{
|
|
441 |
return numberOfUnreadMessages;
|
|
442 |
}
|
|
443 |
}
|
|
444 |
|
|
445 |
const TInt itemCount = iInboxFolder->Count();
|
|
446 |
for ( TInt index = 0; index < itemCount; index++ )
|
|
447 |
{
|
|
448 |
const TMsvEntry entry = ( *iInboxFolder )[index];
|
|
449 |
if ( entry.iType.iUid == KUidMsvMessageEntryValue && entry.Unread())
|
|
450 |
{
|
|
451 |
if( entry.Visible() )
|
|
452 |
{
|
|
453 |
numberOfUnreadMessages++;
|
|
454 |
}
|
|
455 |
}
|
|
456 |
}
|
|
457 |
return numberOfUnreadMessages;
|
|
458 |
}
|
|
459 |
|
|
460 |
// -----------------------------------------------------------------------------
|
|
461 |
// CScreensaverSharedDataI::ProfileName
|
|
462 |
// -----------------------------------------------------------------------------
|
|
463 |
const TDesC& CScreensaverSharedDataI::ProfileName()
|
|
464 |
{
|
|
465 |
// Get the active profile name from profile engine, not from
|
|
466 |
// shareddata ( may not be up-to-date after phone restart )
|
|
467 |
|
|
468 |
if ( ConnectToActiveProfile() )
|
|
469 |
{
|
|
470 |
// Ectract profile name
|
|
471 |
const MProfileName& profileName = iActiveProfile->ProfileName();
|
|
472 |
|
|
473 |
return ( profileName.Name() );
|
|
474 |
}
|
|
475 |
|
|
476 |
return KNullDesC;
|
|
477 |
}
|
|
478 |
|
|
479 |
// -----------------------------------------------------------------------------
|
|
480 |
// CScreensaverSharedDataI::ActiveProfile
|
|
481 |
// -----------------------------------------------------------------------------
|
|
482 |
TInt CScreensaverSharedDataI::ActiveProfile()
|
|
483 |
{
|
|
484 |
// Return the current profile Id
|
|
485 |
TInt profileId = 0;
|
|
486 |
|
|
487 |
// Connect to profile engine
|
|
488 |
if ( ConnectToProfileEngine() )
|
|
489 |
{
|
|
490 |
profileId = iProfileEngine->ActiveProfileId();
|
|
491 |
}
|
|
492 |
|
|
493 |
return profileId;
|
|
494 |
}
|
|
495 |
|
|
496 |
// -----------------------------------------------------------------------------
|
|
497 |
// CScreensaverSharedDataI::IsHaveNewEmail
|
|
498 |
// -----------------------------------------------------------------------------
|
|
499 |
TBool CScreensaverSharedDataI::IsHaveNewEmail() const
|
|
500 |
{
|
|
501 |
TInt state = 0;
|
|
502 |
// Check the new email state from PubSub
|
|
503 |
TInt error = RProperty::Get(
|
|
504 |
KPSUidCoreApplicationUIs, KCoreAppUIsNewEmailStatus, state);
|
|
505 |
|
|
506 |
SCRLOGGER_WRITEF(_L("SCR: QueryNewEmail state=%d error=%d"), state, error);
|
|
507 |
|
|
508 |
if ( ( error == KErrNone ) && ( state == ECoreAppUIsNewEmail ) )
|
|
509 |
{
|
|
510 |
return ETrue;
|
|
511 |
}
|
|
512 |
else
|
|
513 |
{
|
|
514 |
return EFalse;
|
|
515 |
}
|
|
516 |
}
|
|
517 |
|
|
518 |
// -----------------------------------------------------------------------------
|
|
519 |
// CScreensaverSharedDataI::IsHaveNewVoicemail
|
|
520 |
// -----------------------------------------------------------------------------
|
|
521 |
TBool CScreensaverSharedDataI::IsHaveNewVoicemail() const
|
|
522 |
{
|
|
523 |
// Show the indicator, if either line has messages waiting
|
|
524 |
if ( ( VoiceMailCount( KCtsyMessageWaitingVoiceMailCount ) > 0 )
|
|
525 |
|| ( VoiceMailCount( KCtsyMessageWaitingAuxLineCount ) > 0 ) )
|
|
526 |
{
|
|
527 |
return ETrue;
|
|
528 |
}
|
|
529 |
else
|
|
530 |
{
|
|
531 |
return EFalse;
|
|
532 |
}
|
|
533 |
}
|
|
534 |
|
|
535 |
// -----------------------------------------------------------------------------
|
|
536 |
// CScreensaverSharedDataI::IsHaveNewInstantMessages
|
|
537 |
// -----------------------------------------------------------------------------
|
|
538 |
TBool CScreensaverSharedDataI::IsHaveNewInstantMessages() const
|
|
539 |
{
|
|
540 |
TInt showValue = 0;
|
|
541 |
TInt error = RProperty::Get(
|
|
542 |
KPSUidCoreApplicationUIs, KCoreAppUIsUipInd, showValue);
|
|
543 |
|
|
544 |
SCRLOGGER_WRITEF(_L("SCR: QueryNewInstantMessages state=%d error=%d"),
|
|
545 |
showValue, error);
|
|
546 |
|
|
547 |
return ( ( error == KErrNone ) && ( showValue == ECoreAppUIsShow ) );
|
|
548 |
}
|
|
549 |
|
|
550 |
|
|
551 |
// -----------------------------------------------------------------------------
|
|
552 |
// CScreensaverSharedDataI::IsSilentMode
|
|
553 |
// -----------------------------------------------------------------------------
|
|
554 |
TBool CScreensaverSharedDataI::IsSilentMode()
|
|
555 |
{
|
|
556 |
// Connect to active profile, and return silent mode status
|
|
557 |
if (ConnectToActiveProfile())
|
|
558 |
{
|
|
559 |
return iActiveProfile->IsSilent();
|
|
560 |
}
|
|
561 |
|
|
562 |
return EFalse;
|
|
563 |
}
|
|
564 |
|
|
565 |
|
|
566 |
// -----------------------------------------------------------------------------
|
|
567 |
// CScreensaverSharedDataI::IsVibraMode
|
|
568 |
// -----------------------------------------------------------------------------
|
|
569 |
TBool CScreensaverSharedDataI::IsVibraMode()
|
|
570 |
{
|
|
571 |
// Get the active profile name from profile engine, not from
|
|
572 |
// shareddata (may not be up-to-date after phone restart)
|
|
573 |
if (ConnectToActiveProfile())
|
|
574 |
{
|
|
575 |
// Extract profile vibra setting
|
|
576 |
return iActiveProfile->ProfileTones().ToneSettings().iVibratingAlert;
|
|
577 |
}
|
|
578 |
|
|
579 |
return EFalse;
|
|
580 |
}
|
|
581 |
|
|
582 |
// ---------------------------------------------------------------------------
|
|
583 |
// CScreensaverSharedDataI::IsOngoingCall()
|
|
584 |
// ---------------------------------------------------------------------------
|
|
585 |
//
|
|
586 |
TBool CScreensaverSharedDataI::IsOngoingCall()
|
|
587 |
{
|
|
588 |
TInt state = EPSCTsyCallStateUninitialized;
|
|
589 |
// Check the call state from PubSub
|
|
590 |
RProperty::Get( KPSUidCtsyCallInformation, KCTsyCallState, state );
|
|
591 |
|
|
592 |
return ( state != EPSCTsyCallStateNone &&
|
|
593 |
state != EPSCTsyCallStateUninitialized );
|
|
594 |
}
|
|
595 |
|
|
596 |
// -----------------------------------------------------------------------------
|
|
597 |
// CScreensaverSharedDataI::HandleSessionEventL
|
|
598 |
// -----------------------------------------------------------------------------
|
|
599 |
//
|
|
600 |
void CScreensaverSharedDataI::HandleSessionEventL(TMsvSessionEvent aEvent, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/)
|
|
601 |
{
|
|
602 |
switch (aEvent)
|
|
603 |
{
|
|
604 |
case EMsvEntriesChanged:
|
|
605 |
AppUi()->ScreensaverView()->UpdateAndRefresh();
|
|
606 |
break;
|
|
607 |
case EMsvCloseSession:
|
|
608 |
case EMsvServerTerminated:
|
|
609 |
delete iInboxFolder;
|
|
610 |
iInboxFolder = NULL;
|
|
611 |
delete iMsvSession;
|
|
612 |
iMsvSession = NULL;
|
|
613 |
break;
|
|
614 |
default:
|
|
615 |
break;
|
|
616 |
}
|
|
617 |
}
|
|
618 |
|
|
619 |
// -----------------------------------------------------------------------------
|
|
620 |
// CScreensaverSharedDataI::HandleEntryEventL
|
|
621 |
// -----------------------------------------------------------------------------
|
|
622 |
//
|
|
623 |
void CScreensaverSharedDataI::HandleEntryEventL(TMsvEntryEvent /*aEvent */, TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/)
|
|
624 |
{
|
|
625 |
}
|
|
626 |
|
|
627 |
// -----------------------------------------------------------------------------
|
|
628 |
// CScreensaverSharedDataI::ScreensaverRepository
|
|
629 |
// -----------------------------------------------------------------------------
|
|
630 |
//
|
|
631 |
CRepository* CScreensaverSharedDataI::ScreensaverRepository() const
|
|
632 |
{
|
|
633 |
return iScreensaverRepository;
|
|
634 |
}
|
|
635 |
|
|
636 |
// -----------------------------------------------------------------------------
|
|
637 |
// CScreensaverSharedDataI::CScreensaverSharedDataI
|
|
638 |
// -----------------------------------------------------------------------------
|
|
639 |
//
|
|
640 |
CScreensaverSharedDataI::CScreensaverSharedDataI()
|
|
641 |
{
|
|
642 |
iStartupComplete = EFalse;
|
|
643 |
}
|
|
644 |
|
|
645 |
|
|
646 |
// -----------------------------------------------------------------------------
|
|
647 |
// CScreensaverSharedDataI::ConstructL
|
|
648 |
// -----------------------------------------------------------------------------
|
|
649 |
//
|
|
650 |
void CScreensaverSharedDataI::ConstructL()
|
|
651 |
{
|
|
652 |
GetDefaultType();
|
|
653 |
ConnectToSSCRL();
|
|
654 |
ConnectToPslnSettingCRL();
|
|
655 |
ConnectToCommonTsyCRL();
|
|
656 |
|
|
657 |
// Define and publish "Screensaver is on" property
|
|
658 |
// Read: pass, Write: Screensaver only
|
|
659 |
DefineScreensaverProperties( KScreenSaverOn, KSSPolicyWriteSSOnly );
|
|
660 |
|
|
661 |
// Define and publish "Screensaver activated from idle" property
|
|
662 |
// Read: pass, Write: Screensaver only
|
|
663 |
DefineScreensaverProperties( KScreenSaverActivatedFromIdle, KSSPolicyWriteSSOnly );
|
|
664 |
|
|
665 |
// Define and attach "allow screensaver property"
|
|
666 |
// Read: Readuserdata, Write: writeuserdata
|
|
667 |
DefineScreensaverProperties( KScreenSaverAllowScreenSaver, KSSPolicyWriteUserData );
|
|
668 |
|
|
669 |
// Define and attach "screensaver preview property"
|
|
670 |
// Read: Readuserdata, Write: writeuserdata
|
|
671 |
DefineScreensaverProperties( KScreenSaverPreviewMode, KSSPolicyWriteUserData );
|
|
672 |
|
|
673 |
// Define and attach "screensaver preview state property"
|
|
674 |
// Read: Readuserdata, Write: writeuserdata
|
|
675 |
DefineScreensaverProperties( KScreenSaverPreviewState, KSSPolicyWriteUserData );
|
|
676 |
|
|
677 |
// Define and initialize "current plugin settings changed" property
|
|
678 |
// Read: pass, Write: pass
|
|
679 |
DefineScreensaverProperties( KScreenSaverPluginSettingsChanged, KSSPolicyPass );
|
|
680 |
|
|
681 |
// Define and initialize "no power save mode" property
|
|
682 |
// Read: pass, Write: pass
|
|
683 |
DefineScreensaverProperties( KScreenSaverNoPowerSaveMode, KSSPolicyPass );
|
|
684 |
|
|
685 |
DefineScreensaverProperties( KScreenSaverActivate, KSSPolicyWriteUserData );
|
|
686 |
}
|
|
687 |
|
|
688 |
// -----------------------------------------------------------------------------
|
|
689 |
// CScreensaverSharedDataI::ConnectToSSCR
|
|
690 |
// -----------------------------------------------------------------------------
|
|
691 |
//
|
|
692 |
void CScreensaverSharedDataI::ConnectToSSCRL()
|
|
693 |
{
|
|
694 |
iScreensaverRepository = CRepository::NewL( KCRUidScreenSaver );
|
|
695 |
|
|
696 |
if( iScreensaverRepository )
|
|
697 |
iScreensaverRepositoryWatcher = CScreensaverRepositoryWatcher::NewL(
|
|
698 |
KCRUidScreenSaver,
|
|
699 |
TCallBack( HandleDisplayObjChanged, this ),
|
|
700 |
iScreensaverRepository );
|
|
701 |
}
|
|
702 |
|
|
703 |
// -----------------------------------------------------------------------------
|
|
704 |
// CScreensaverSharedDataI::ConnectToPslnSettingCRL
|
|
705 |
// -----------------------------------------------------------------------------
|
|
706 |
//
|
|
707 |
void CScreensaverSharedDataI::ConnectToPslnSettingCRL()
|
|
708 |
{
|
|
709 |
TRAPD(ret, iSettingsRepository = CRepository::NewL(KCRUidSecuritySettings));
|
|
710 |
|
|
711 |
if( ret == KErrNone )
|
|
712 |
{
|
|
713 |
iSettingsRepositoryWatcher = CScreensaverRepositoryWatcher::NewL(
|
|
714 |
KCRUidPersonalizationSettings,
|
|
715 |
KSettingsAutomaticKeyguardTime,
|
|
716 |
CCenRepNotifyHandler::EIntKey,
|
|
717 |
TCallBack(HandleTimeoutChanged, this),
|
|
718 |
iSettingsRepository);
|
|
719 |
}
|
|
720 |
}
|
|
721 |
|
|
722 |
// -----------------------------------------------------------------------------
|
|
723 |
// CScreensaverSharedDataI::ConnectToCommonTsyCRL
|
|
724 |
// Connects to common tsy central repository
|
|
725 |
// -----------------------------------------------------------------------------
|
|
726 |
//
|
|
727 |
void CScreensaverSharedDataI::ConnectToCommonTsyCRL()
|
|
728 |
{
|
|
729 |
iCTsyRepository = CRepository::NewL( KCRUidCtsyMessageWaitingIndicator );
|
|
730 |
}
|
|
731 |
|
|
732 |
// -----------------------------------------------------------------------------
|
|
733 |
// CScreensaverSharedDataI::ConnectToInboxL
|
|
734 |
// -----------------------------------------------------------------------------
|
|
735 |
//
|
|
736 |
void CScreensaverSharedDataI::ConnectToInboxL()
|
|
737 |
{
|
|
738 |
if (!iMsvSession)
|
|
739 |
{
|
|
740 |
iMsvSession = CMsvSession::OpenSyncL( *this );
|
|
741 |
}
|
|
742 |
iInboxFolder = iMsvSession->GetEntryL( KMsvGlobalInBoxIndexEntryId );
|
|
743 |
|
|
744 |
TMsvSelectionOrdering ordering = iInboxFolder->SortType();
|
|
745 |
ordering.SetShowInvisibleEntries( EFalse );
|
|
746 |
iInboxFolder->SetSortTypeL( ordering );
|
|
747 |
|
|
748 |
iInboxFolder->AddObserverL( *this );
|
|
749 |
}
|
|
750 |
|
|
751 |
// -----------------------------------------------------------------------------
|
|
752 |
// CScreensaverSharedDataI::ConnectToProfileEngine
|
|
753 |
// Connect to Profile engine. Returns ETrue if successfully connected
|
|
754 |
// -----------------------------------------------------------------------------
|
|
755 |
//
|
|
756 |
TBool CScreensaverSharedDataI::ConnectToProfileEngine()
|
|
757 |
{
|
|
758 |
// Check if already connected
|
|
759 |
if ( iProfileEngine )
|
|
760 |
{
|
|
761 |
// Done
|
|
762 |
return ETrue;
|
|
763 |
}
|
|
764 |
// The member variable is also used to indicate successful
|
|
765 |
// connection, hence a pointer instead of just RSystemAgent
|
|
766 |
TRAPD( err, ( iProfileEngine = CreateProfileEngineL() ) );
|
|
767 |
|
|
768 |
if ( err != KErrNone )
|
|
769 |
{
|
|
770 |
// Something went wrong on allocation
|
|
771 |
iProfileEngine = NULL;
|
|
772 |
return EFalse;
|
|
773 |
}
|
|
774 |
|
|
775 |
// Successfully connected
|
|
776 |
return ETrue;
|
|
777 |
}
|
|
778 |
|
|
779 |
// -----------------------------------------------------------------------------
|
|
780 |
// CScreensaverSharedDataI::ClearPreviewFlag
|
|
781 |
// Connect to current active Profile. Returns ETrue if successfully connected
|
|
782 |
// -----------------------------------------------------------------------------
|
|
783 |
//
|
|
784 |
TBool CScreensaverSharedDataI::ConnectToActiveProfile()
|
|
785 |
{
|
|
786 |
InvalidateActiveProfile();
|
|
787 |
|
|
788 |
if ( ConnectToProfileEngine() )
|
|
789 |
{
|
|
790 |
TRAPD( err, ( iActiveProfile = iProfileEngine->ActiveProfileL() ) );
|
|
791 |
if ( ( err == KErrNone ) && ( iActiveProfile ) )
|
|
792 |
{
|
|
793 |
return ETrue;
|
|
794 |
}
|
|
795 |
}
|
|
796 |
return EFalse;
|
|
797 |
}
|
|
798 |
|
|
799 |
// -----------------------------------------------------------------------------
|
|
800 |
// CScreensaverSharedDataI::DefineScreensaverProperties
|
|
801 |
// -----------------------------------------------------------------------------
|
|
802 |
//
|
|
803 |
void CScreensaverSharedDataI::DefineScreensaverProperties(
|
|
804 |
TUint32 aKey, const TSecurityPolicy& aWritePolicy )
|
|
805 |
{
|
|
806 |
RProperty::Define(
|
|
807 |
KPSUidScreenSaver,
|
|
808 |
aKey,
|
|
809 |
RProperty::EInt,
|
|
810 |
KSSPolicyPass,
|
|
811 |
aWritePolicy );
|
|
812 |
|
|
813 |
RProperty::Set( KPSUidScreenSaver, aKey, 0);
|
|
814 |
}
|
|
815 |
|
|
816 |
// -----------------------------------------------------------------------------
|
|
817 |
// CScreensaverSharedDataI::HandleTimeoutChanged
|
|
818 |
// -----------------------------------------------------------------------------
|
|
819 |
//
|
|
820 |
TInt CScreensaverSharedDataI::HandleTimeoutChanged(TAny* aPtr)
|
|
821 |
{
|
|
822 |
STATIC_CAST(CScreensaverSharedDataI*, aPtr)->ResetInactivityTimeout();
|
|
823 |
return KErrNone;
|
|
824 |
}
|
|
825 |
|
|
826 |
// -----------------------------------------------------------------------------
|
|
827 |
// CScreensaverSharedDataI::ResetInactivityTimeout
|
|
828 |
// -----------------------------------------------------------------------------
|
|
829 |
//
|
|
830 |
void CScreensaverSharedDataI::ResetInactivityTimeout()
|
|
831 |
{
|
|
832 |
AppUi()->Model().ResetInactivityTimeout();
|
|
833 |
}
|
|
834 |
|
|
835 |
|
|
836 |
// -----------------------------------------------------------------------------
|
|
837 |
// CScreensaverSharedDataI::HandleDisplayObjChanged
|
|
838 |
// -----------------------------------------------------------------------------
|
|
839 |
//
|
|
840 |
TInt CScreensaverSharedDataI::HandleDisplayObjChanged(TAny* aPtr)
|
|
841 |
{
|
|
842 |
CScreensaverSharedDataI* self = STATIC_CAST(CScreensaverSharedDataI*, aPtr);
|
|
843 |
|
|
844 |
self->AppUi()->ScreensaverView()->SetDisplayObject( self->DisplayObjectType() );
|
|
845 |
|
|
846 |
return KErrNone;
|
|
847 |
}
|
|
848 |
|
|
849 |
// -----------------------------------------------------------------------------
|
|
850 |
// CScreensaverSharedDataI::GetDefaultType
|
|
851 |
// -----------------------------------------------------------------------------
|
|
852 |
//
|
|
853 |
void CScreensaverSharedDataI::GetDefaultType()
|
|
854 |
{
|
|
855 |
/*
|
|
856 |
default type is hardcoded, so commented out below code.
|
|
857 |
Remove the comment when default type is read from CenRep.
|
|
858 |
//Store the default screensaver for this device
|
|
859 |
TBuf<16> screensaverName;
|
|
860 |
|
|
861 |
TInt error = GetDefaultTypeString( screensaverName );
|
|
862 |
|
|
863 |
if ( KErrNone == error )
|
|
864 |
{
|
|
865 |
if ( screensaverName.CompareF( KScreenSaverTypeNone ) == 0 )
|
|
866 |
{
|
|
867 |
iDefaultType = EDisplayNone;
|
|
868 |
}
|
|
869 |
else if ( screensaverName.CompareF( KScreenSaverTypeText ) == 0 )
|
|
870 |
{
|
|
871 |
iDefaultType = EDisplayText;
|
|
872 |
}
|
|
873 |
else //go back to the "old" option, ie - Date type
|
|
874 |
{
|
|
875 |
iDefaultType = EDisplayTime;
|
|
876 |
}
|
|
877 |
}
|
|
878 |
*/
|
|
879 |
|
|
880 |
#ifdef USE_DATE_AND_TEXT
|
|
881 |
iDefaultType = EDisplayTime;
|
|
882 |
#else
|
|
883 |
iDefaultType = EDisplayNone;
|
|
884 |
#endif
|
|
885 |
|
|
886 |
|
|
887 |
|
|
888 |
}
|
|
889 |
|
|
890 |
// -----------------------------------------------------------------------------
|
|
891 |
// CScreensaverSharedDataI::GetDefaultTypeString
|
|
892 |
// -----------------------------------------------------------------------------
|
|
893 |
//
|
|
894 |
TInt CScreensaverSharedDataI::GetDefaultTypeString( TDes& DefaultScreenSaver )
|
|
895 |
{
|
|
896 |
CRepository* skinsRepository = NULL;
|
|
897 |
TRAP_IGNORE( skinsRepository = CRepository::NewL( KCRUidPersonalisation ) );
|
|
898 |
|
|
899 |
TInt error = skinsRepository->Get( KPslnSystemDefaultScreenSaver,
|
|
900 |
DefaultScreenSaver );
|
|
901 |
|
|
902 |
delete skinsRepository;
|
|
903 |
|
|
904 |
return error;
|
|
905 |
}
|
|
906 |
|
|
907 |
// -----------------------------------------------------------------------------
|
|
908 |
// CScreensaverSharedDataI::VoiceMailCount
|
|
909 |
// -----------------------------------------------------------------------------
|
|
910 |
//
|
|
911 |
TInt CScreensaverSharedDataI::VoiceMailCount( const TUint32 aKey ) const
|
|
912 |
{
|
|
913 |
TInt line(0);
|
|
914 |
TInt error = KErrNone;
|
|
915 |
|
|
916 |
error = iCTsyRepository->Get( aKey, line );
|
|
917 |
|
|
918 |
if( error != KErrNone )
|
|
919 |
{
|
|
920 |
line = 0;
|
|
921 |
}
|
|
922 |
|
|
923 |
return line;
|
|
924 |
}
|
|
925 |
|
|
926 |
// -----------------------------------------------------------------------------
|
|
927 |
// CScreensaverSharedDataI::InvalidateActiveProfile
|
|
928 |
// Invalidate the cached active profile, so that next call to ConnectToActiveProfile
|
|
929 |
// will use the newest profile data (in case it has changed)
|
|
930 |
// -----------------------------------------------------------------------------
|
|
931 |
//
|
|
932 |
void CScreensaverSharedDataI::InvalidateActiveProfile()
|
|
933 |
{
|
|
934 |
if (iActiveProfile)
|
|
935 |
{
|
|
936 |
iActiveProfile->Release();
|
|
937 |
iActiveProfile = NULL;
|
|
938 |
}
|
|
939 |
}
|
|
940 |
|
|
941 |
// -----------------------------------------------------------------------------
|
|
942 |
// CScreensaverSharedDataI::AppUi
|
|
943 |
// -----------------------------------------------------------------------------
|
|
944 |
//
|
|
945 |
CScreensaverAppUi *CScreensaverSharedDataI::AppUi() const
|
|
946 |
{
|
|
947 |
return STATIC_CAST( CScreensaverAppUi*, CCoeEnv::Static()->AppUi() );
|
|
948 |
}
|
|
949 |
// End of file.
|