--- a/uifw/AknGlobalUI/OldStyleNotif/Src/aknkeylocknotifier.cpp Fri Apr 16 15:13:44 2010 +0300
+++ b/uifw/AknGlobalUI/OldStyleNotif/Src/aknkeylocknotifier.cpp Mon May 03 12:45:33 2010 +0300
@@ -88,396 +88,10 @@
_LIT_SECURITY_POLICY_C1( KWritePolicy, ECapabilityWriteDeviceData );
-/**
- * CAknKeylockScreenSaverObserver captures primary keys
- * from screensaver when screen saver is active.
- *
- * @lib aknoldstylenotif.lib
- * @since 3.2
- */
-NONSHARABLE_CLASS( CAknKeylockScreenSaverObserver ): public CActive
- {
-public:
-
- /**
- * Creates instance of the CAknKeylockScreenSaverObserver class.
- *
- * @param aWindowGroup application window group used to capture primary keys
- * @return Returns the instance just created.
- */
- static CAknKeylockScreenSaverObserver* NewL( RWindowGroup& aWindowGroup );
-
- /**
- * Destructor.
- */
- ~CAknKeylockScreenSaverObserver();
-
-public:
-
- /**
- * Starts asynchronic listening KUidCurrentCall event
- *
- * @return KErrNone: if no errors
- * @return KErrInUse: if already listening
- */
- TInt Start();
-
- /**
- * Stops asynchronic listening KUidAutolockStatus event
- */
- void Stop();
-
-public:
-
- /**
- * Method handles the lock state changes.
- *
- * @param aStatus The new lock state
- */
- void SetLockStatus( TBool aKeylockEnabled, TBool aAutolockEnabled );
-
-private: // constructors
-
- /**
- * C++ default constructor.
- *
- * @param aAppUi (pointer to autolock appui)
- */
- CAknKeylockScreenSaverObserver( RWindowGroup& aWindowGroup );
-
- /**
- * Symbian OS constructor.
- */
- void ConstructL();
-
-private: // from CActive
-
- /** @see CActive::RunL() */
- void RunL();
-
- /** @see CActive::DoCancel() */
- void DoCancel();
-
-private:
-
- /**
- * Used to capture primary keys defined in keylocking policies
- */
- void CapturePrimaryKeys( TBool aCapture );
-
-private: // data
-
- // screen saver on property
- RProperty iScreenSaverActiveProperty;
-
- // if screensaver is active or not
- TBool iScreenSaverActive;
-
- // if primary keys have been captured
- TBool iCaptured;
-
- // locking states
- TBool iKeylockEnabled;
- TBool iAutolockEnabled;
-
- // left softkey capture
- TInt iLeftSoftKey;
-
- // a reference to application window group
- RWindowGroup& iWindowGroup;
-
- // keylockpolicy support (not owned)
- CKeyLockPolicyApi* iUnlockPolicyApi;
-
- // keylockpolicy support (not owned)
- CKeyLockPolicyApi* iDevicelockPolicyApi;
-
- // primary key captures
- RArray<TUint> iPrimaryKeyCaptures;
- };
-
-// ===========================================================================
-// class CAknKeylockScreenSaverObserver
-// ===========================================================================
-
-// ---------------------------------------------------------------------------
-// Constructs a new entry with given values.
-// ---------------------------------------------------------------------------
-//
-CAknKeylockScreenSaverObserver* CAknKeylockScreenSaverObserver::NewL(
- RWindowGroup& aWindowGroup )
- {
- CAknKeylockScreenSaverObserver* self =
- new (ELeave) CAknKeylockScreenSaverObserver( aWindowGroup );
- CleanupStack::PushL( self );
- self->ConstructL();
- CleanupStack::Pop( self );
- return self;
- }
-
-
-// ---------------------------------------------------------------------------
-// Destructor
-// ---------------------------------------------------------------------------
-//
-CAknKeylockScreenSaverObserver::~CAknKeylockScreenSaverObserver()
- {
- Cancel();
-
- // Close the property handle.
- iScreenSaverActiveProperty.Close();
-
- // Release key captures.
- CapturePrimaryKeys( EFalse );
-
- // Delete policies.
- delete iUnlockPolicyApi;
- delete iDevicelockPolicyApi;
- }
-
-
-// ---------------------------------------------------------------------------
-// Starts listening to the KScreenSaverOn event.
-// ---------------------------------------------------------------------------
-//
-TInt CAknKeylockScreenSaverObserver::Start()
- {
- if ( IsActive() )
- {
- return KErrInUse;
- }
- iStatus = KRequestPending;
- iScreenSaverActiveProperty.Subscribe( iStatus );
- SetActive();
-
- return KErrNone;
- }
-
-
-// ---------------------------------------------------------------------------
-// Stops listening to the KScreenSaverOn event.
-// ---------------------------------------------------------------------------
-//
-void CAknKeylockScreenSaverObserver::Stop()
- {
- if ( !IsActive() )
- {
- return;
- }
- Cancel();
- iScreenSaverActiveProperty.Cancel();
- }
-// ---------------------------------------------------------------------------
-// C++ constructor
-// ---------------------------------------------------------------------------
-//
-CAknKeylockScreenSaverObserver::CAknKeylockScreenSaverObserver(
- RWindowGroup& aWindowGroup )
- : CActive( 0 ),
- iScreenSaverActive( EFalse ),
- iCaptured( EFalse ),
- iKeylockEnabled( EFalse ),
- iAutolockEnabled( EFalse ),
- iLeftSoftKey( NULL ),
- iWindowGroup( aWindowGroup )
- {
- }
-// ---------------------------------------------------------------------------
-// Second phase constructor.
-// ---------------------------------------------------------------------------
-//
-void CAknKeylockScreenSaverObserver::ConstructL()
- {
- // Add this active object to the scheduler.
- CActiveScheduler::Add( this );
-
- // We need policies to poll primary keys.
- iUnlockPolicyApi = CKeyLockPolicyApi::NewL( EPolicyDeactivateKeyguard );
- if ( !iUnlockPolicyApi->HasConfiguration() )
- {
- delete iUnlockPolicyApi;
- iUnlockPolicyApi = NULL;
- }
-
- // we need policies to poll primary keys
- iDevicelockPolicyApi = CKeyLockPolicyApi::NewL( EPolicyDevicelockQuery );
- if ( !iDevicelockPolicyApi->HasConfiguration() )
- {
- delete iDevicelockPolicyApi;
- iDevicelockPolicyApi = NULL;
- }
- }
-
-
-// ---------------------------------------------------------------------------
-// From base class CActive.
-// Handles change in the screen saver state.
-// ---------------------------------------------------------------------------
-//
-void CAknKeylockScreenSaverObserver::RunL()
- {
- if ( iKeylockEnabled || iAutolockEnabled )
- {
- // Resubscribe before processing new value to prevent missing updates.
- Start();
- }
-
- TInt screenSaverState;
- iScreenSaverActiveProperty.Get( screenSaverState );
- // Primary keys are captured from screensaver when screensaver
- // is the top most application.
- if ( screenSaverState > NULL )
- {
- __ASSERT_DEBUG( !iCaptured,
- Panic( EAknPanicKeyLockObserverAlreadyExists ) );
- iScreenSaverActive = ETrue;
- CapturePrimaryKeys( ETrue );
- }
- else
- {
- // If screensaver is disabled, stop capturing primary key events.
- if ( iScreenSaverActive )
- {
- CapturePrimaryKeys( EFalse );
- }
- iScreenSaverActive = EFalse;
- }
- }
-
-
-// ---------------------------------------------------------------------------
-// Set the lock status.
-// ---------------------------------------------------------------------------
-//
-void CAknKeylockScreenSaverObserver::SetLockStatus( TBool aKeylockEnabled,
- TBool aAutolockEnabled )
- {
- iKeylockEnabled = aKeylockEnabled;
- iAutolockEnabled = aAutolockEnabled;
-
- if ( iKeylockEnabled || iAutolockEnabled )
- {
- // Start observing screensaver activation.
- Start();
- }
- else
- {
- if ( iScreenSaverActive )
- {
- CapturePrimaryKeys( EFalse );
- }
- // Screensaver is only observed when keylock is enabled.
- Stop();
- }
- }
-
-
-// ---------------------------------------------------------------------------
-// Capture or uncapture primary keys.
-// ---------------------------------------------------------------------------
-//
-void CAknKeylockScreenSaverObserver::CapturePrimaryKeys( TBool aCapture )
- {
- if ( aCapture )
- {
- if ( iScreenSaverActive && !iCaptured )
- {
- if ( iKeylockEnabled && !iAutolockEnabled )
- {
- iCaptured = ETrue;
- // If no unlocking policy has been defined,
- // the default primary key is the left soft key.
- if ( !iUnlockPolicyApi )
- {
- // Capture LSK (starts unlock prosess, capturing
- // bypasses screensaver)
- iLeftSoftKey = iWindowGroup.CaptureKey( EKeyDevice0, 0, 0 );
- }
- else
- {
- iPrimaryKeyCaptures.Reset();
- TUint32 index( 0 );
- TUint32 primaryKey( 0 );
- TUint32 secondaryKey( 0 );
- while ( iUnlockPolicyApi->GetKeyCombination( index,
- primaryKey,
- secondaryKey ) == KErrNone )
- {
- iPrimaryKeyCaptures.Append(
- iWindowGroup.CaptureKeyUpAndDowns( primaryKey, 0, 0 ) );
- index++;
- }
- }
- }
- else
- {
- if ( iKeylockEnabled && iAutolockEnabled )
- {
- iCaptured = ETrue;
- // If no devicelock query policy has been defined,
- // the default primary key is the left soft key.
- if ( !iDevicelockPolicyApi )
- {
- // Capture LSK (starts unlock prosess,
- // capturing bypasses screensaver).
- iLeftSoftKey = iWindowGroup.CaptureKey( EKeyDevice0, 0, 0 );
- }
- else
- {
- iPrimaryKeyCaptures.Reset();
- TUint32 index( 0 );
- TUint32 primaryKey( 0 );
- TUint32 secondaryKey( 0 );
- while ( iDevicelockPolicyApi->GetKeyCombination( index, primaryKey, secondaryKey ) == KErrNone )
- {
- iPrimaryKeyCaptures.Append(
- iWindowGroup.CaptureKeyUpAndDowns( primaryKey, 0, 0 ) );
- index++;
- }
- }
- }
- }
- }
- }
- else
- {
- if (iCaptured)
- {
- if (iLeftSoftKey > 0)
- {
- iWindowGroup.CancelCaptureKey(iLeftSoftKey);
- }
- iLeftSoftKey = 0;
-
- if (iPrimaryKeyCaptures.Count() > 0)
- {
- for (TInt x = 0; x < iPrimaryKeyCaptures.Count(); x++)
- {
- iWindowGroup.CancelCaptureKeyUpAndDowns(iPrimaryKeyCaptures[x]);
- }
- iPrimaryKeyCaptures.Reset();
- }
-
- iCaptured = EFalse;
- }
- }
- }
-
-
-// ---------------------------------------------------------------------------
-// From base class CActive.
-// Cancels event listening.
-// ---------------------------------------------------------------------------
-//
-void CAknKeylockScreenSaverObserver::DoCancel()
- {
- iScreenSaverActiveProperty.Cancel();
- }
-
// ===========================================================================
// class CAknLockedNote.
@@ -941,7 +555,6 @@
delete iOfferLockNote;
delete iEcsNote; // Ecs change
delete iKeylockApi;
- delete iKeylockScreenSaverObserver;
}
@@ -1106,9 +719,6 @@
iKeylockApi = NULL;
}
- iKeylockScreenSaverObserver =
- CAknKeylockScreenSaverObserver::NewL( groupWin );
-
// Define P&S key that is used to publish the keyguard status.
RProperty::Define( KPSUidAvkonDomain,
KAknKeyguardStatus,
@@ -1135,8 +745,7 @@
// Keylock Disabled
return;
}
- // Keylock Enabled
- iKeylockScreenSaverObserver->SetLockStatus( ETrue, iAutolockEnabled );
+
if ( iOfferLockEnabled )
{
iOfferLockNote->CancelNote();
@@ -1264,8 +873,6 @@
{
TRACES( RDebug::Print(_L("(KeyGuard)CAknKeyLockControl::DisableKeylock")); )
- // Keep locking status in sync.
- iKeylockScreenSaverObserver->SetLockStatus( EFalse, iAutolockEnabled );
if ( iSoundsMuted )
{
CAknAppUiBase* appUi= iAvkonAppUiBase;