uifw/AknGlobalUI/OldStyleNotif/Src/aknkeylocknotifier.cpp
branchRCL_3
changeset 20 d48ab3b357f1
parent 19 aecbbf00d063
equal deleted inserted replaced
19:aecbbf00d063 20:d48ab3b357f1
     1 /*
     1 /*
     2 * Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    31 #include <AknUtils.h>
    31 #include <AknUtils.h>
    32 #include <eikcba.h>
    32 #include <eikcba.h>
    33 #include <aknnotecontrol.h>
    33 #include <aknnotecontrol.h>
    34 #include <aknlayoutscalable_avkon.cdl.h>
    34 #include <aknlayoutscalable_avkon.cdl.h>
    35 
    35 
    36 #include <SecondaryDisplay/AknSecondaryDisplayDefs.h>
    36 #include <secondarydisplay/AknSecondaryDisplayDefs.h>
    37 #include <avkondomainpskeys.h> // KPSUidAvkonDomain, KAknKeyguardStatus, TAknKeyguardStatus
    37 #include <avkondomainpskeys.h> // KPSUidAvkonDomain, KAknKeyguardStatus, TAknKeyguardStatus
    38 #include <startupdomainpskeys.h> // KStartupSecurityCodeQueryStatus
    38 #include <startupdomainpskeys.h> // KStartupSecurityCodeQueryStatus
    39 #include <coreapplicationuisdomainpskeys.h> // KCoreAppUIsAutolockStatus
    39 #include <coreapplicationuisdomainpskeys.h> // KCoreAppUIsAutolockStatus
    40 #include <AknNotifySignature.h>
    40 #include <AknNotifySignature.h>
    41 #include "AknCapServerEntry.h"
    41 #include "AknCapServerEntry.h"
    42 #include <aknglobalpopupprioritycontroller.h>
    42 #include <aknglobalpopupprioritycontroller.h>
    43 #include "GlobalWindowPriorities.h"
    43 #include "GlobalWindowPriorities.h"
    44 #include <keylockpolicyapi.h>
    44 #include <keylockpolicyapi.h>
       
    45 #include <ScreensaverInternalPSKeys.h>
    45 
    46 
    46 #include <PSVariables.h>   // Property values
    47 #include <PSVariables.h>   // Property values
    47 #include <coreapplicationuisdomainpskeys.h>
    48 #include <coreapplicationuisdomainpskeys.h>
    48 #include <startupdomainpskeys.h>
    49 #include <startupdomainpskeys.h>
    49 #include <ctsydomainpskeys.h>
    50 #include <ctsydomainpskeys.h>
    50 #include <bafindf.h>
    51 #include <bafindf.h>
    51 #include "AknNotifyPlugin.hrh"
    52 #include "AknNotifyPlugin.hrh"
    52 
    53 #include "akntrace.h"
    53 
    54 
    54 
    55 
    55 #ifdef _DEBUG
    56 #ifdef _DEBUG
    56     #define TRACES(x)   x
    57     #define TRACES(x)   x
    57 #else
    58 #else
    86 
    87 
    87 _LIT( KRESOURCEFILE, "\\resource\\aknnotpi.rsc" );
    88 _LIT( KRESOURCEFILE, "\\resource\\aknnotpi.rsc" );
    88 _LIT_SECURITY_POLICY_C1( KWritePolicy, ECapabilityWriteDeviceData );
    89 _LIT_SECURITY_POLICY_C1( KWritePolicy, ECapabilityWriteDeviceData );
    89 
    90 
    90 
    91 
    91 
    92 /**
    92 
    93  *  CAknKeylockScreenSaverObserver captures primary keys
    93 
    94  *  from screensaver when screen saver is active.
       
    95  *
       
    96  *  @lib   aknoldstylenotif.lib
       
    97  *  @since 3.2
       
    98  */
       
    99 NONSHARABLE_CLASS( CAknKeylockScreenSaverObserver ): public CActive
       
   100     {
       
   101 public:
       
   102 
       
   103     /**
       
   104     * Creates instance of the CAknKeylockScreenSaverObserver class.
       
   105     *
       
   106     * @param aWindowGroup application window group used to capture primary keys
       
   107     * @return Returns the instance just created.
       
   108     */
       
   109     static CAknKeylockScreenSaverObserver* NewL( RWindowGroup& aWindowGroup );
       
   110 
       
   111     /**
       
   112     * Destructor.
       
   113     */
       
   114     ~CAknKeylockScreenSaverObserver();
       
   115 
       
   116 public:
       
   117 
       
   118     /**
       
   119     * Starts asynchronic listening KUidCurrentCall event
       
   120     *
       
   121     * @return KErrNone: if no errors
       
   122     * @return KErrInUse: if already listening
       
   123     */
       
   124     TInt Start();
       
   125 
       
   126     /**
       
   127     * Stops asynchronic listening KUidAutolockStatus event
       
   128     */
       
   129     void Stop();
       
   130 
       
   131 public:
       
   132 
       
   133     /**
       
   134      *  Method handles the lock state changes.
       
   135      *
       
   136      * @param aStatus The new lock state
       
   137      */
       
   138     void SetLockStatus( TBool aKeylockEnabled, TBool aAutolockEnabled );
       
   139 
       
   140 private: // constructors
       
   141 
       
   142     /**
       
   143     * C++ default constructor.
       
   144     *
       
   145     * @param aAppUi (pointer to autolock appui)
       
   146     */
       
   147     CAknKeylockScreenSaverObserver( RWindowGroup& aWindowGroup );
       
   148 
       
   149     /**
       
   150     * Symbian OS constructor.
       
   151     */
       
   152     void ConstructL();
       
   153 
       
   154 private: // from CActive
       
   155 
       
   156     /** @see CActive::RunL() */
       
   157     void RunL();
       
   158 
       
   159     /** @see CActive::DoCancel() */
       
   160     void DoCancel();
       
   161 
       
   162 private:
       
   163 
       
   164     /**
       
   165     * Used to capture primary keys defined in keylocking policies
       
   166     */
       
   167     void CapturePrimaryKeys( TBool aCapture );
       
   168 
       
   169 private: // data
       
   170 
       
   171     // screen saver on property
       
   172     RProperty  iScreenSaverActiveProperty;
       
   173 
       
   174     // if screensaver is active or not
       
   175     TBool iScreenSaverActive;
       
   176 
       
   177     // if primary keys have been captured
       
   178     TBool iCaptured;
       
   179 
       
   180     // locking states
       
   181     TBool iKeylockEnabled;
       
   182     TBool iAutolockEnabled;
       
   183 
       
   184     // left softkey capture
       
   185     TInt iLeftSoftKey;
       
   186 
       
   187     // a reference to application window group
       
   188     RWindowGroup& iWindowGroup;
       
   189 
       
   190     // keylockpolicy support (not owned)
       
   191     CKeyLockPolicyApi* iUnlockPolicyApi;
       
   192 
       
   193     // keylockpolicy support (not owned)
       
   194     CKeyLockPolicyApi* iDevicelockPolicyApi;
       
   195 
       
   196     // primary key captures
       
   197     RArray<TUint> iPrimaryKeyCaptures;
       
   198     };
       
   199 
       
   200 // ===========================================================================
       
   201 // class CAknKeylockScreenSaverObserver
       
   202 // ===========================================================================
       
   203 
       
   204 // ---------------------------------------------------------------------------
       
   205 // Constructs a new entry with given values.
       
   206 // ---------------------------------------------------------------------------
       
   207 //
       
   208 CAknKeylockScreenSaverObserver* CAknKeylockScreenSaverObserver::NewL(
       
   209     RWindowGroup& aWindowGroup )
       
   210     {
       
   211     CAknKeylockScreenSaverObserver* self =
       
   212         new (ELeave) CAknKeylockScreenSaverObserver( aWindowGroup );
       
   213     CleanupStack::PushL( self );
       
   214     self->ConstructL();
       
   215     CleanupStack::Pop( self );
       
   216     return self;
       
   217     }
       
   218 
       
   219 
       
   220 // ---------------------------------------------------------------------------
       
   221 // Destructor
       
   222 // ---------------------------------------------------------------------------
       
   223 //
       
   224 CAknKeylockScreenSaverObserver::~CAknKeylockScreenSaverObserver()
       
   225     {
       
   226     Cancel();
       
   227 
       
   228     // Close the property handle.
       
   229     iScreenSaverActiveProperty.Close();
       
   230 
       
   231     // Release key captures.
       
   232     CapturePrimaryKeys( EFalse );
       
   233 
       
   234     // Delete policies.
       
   235     delete iUnlockPolicyApi;
       
   236     delete iDevicelockPolicyApi;
       
   237     }
       
   238 
       
   239 
       
   240 // ---------------------------------------------------------------------------
       
   241 // Starts listening to the KScreenSaverOn event.
       
   242 // ---------------------------------------------------------------------------
       
   243 //
       
   244 TInt CAknKeylockScreenSaverObserver::Start()
       
   245     {
       
   246     _AKNTRACE_FUNC_ENTER;
       
   247     
       
   248     if ( IsActive() )
       
   249         {
       
   250         return KErrInUse;
       
   251         }
       
   252     iStatus = KRequestPending;
       
   253     iScreenSaverActiveProperty.Subscribe( iStatus );
       
   254     SetActive();
       
   255     
       
   256     _AKNTRACE_FUNC_EXIT;
       
   257     
       
   258     return KErrNone;
       
   259     }
       
   260 
       
   261 
       
   262 // ---------------------------------------------------------------------------
       
   263 // Stops listening to the KScreenSaverOn event.
       
   264 // ---------------------------------------------------------------------------
       
   265 //
       
   266 void CAknKeylockScreenSaverObserver::Stop()
       
   267     {
       
   268     _AKNTRACE_FUNC_ENTER;
       
   269     
       
   270     if ( !IsActive() )
       
   271         {
       
   272         return;
       
   273         }
       
   274     Cancel();
       
   275     iScreenSaverActiveProperty.Cancel();
       
   276     
       
   277     _AKNTRACE_FUNC_EXIT;
       
   278     }
       
   279 
       
   280 
       
   281 // ---------------------------------------------------------------------------
       
   282 // C++ constructor
       
   283 // ---------------------------------------------------------------------------
       
   284 //
       
   285 CAknKeylockScreenSaverObserver::CAknKeylockScreenSaverObserver(
       
   286     RWindowGroup& aWindowGroup )
       
   287     : CActive( 0 ),
       
   288       iScreenSaverActive( EFalse ),
       
   289       iCaptured( EFalse ),
       
   290       iKeylockEnabled( EFalse ),
       
   291       iAutolockEnabled( EFalse ),
       
   292       iLeftSoftKey( NULL ),
       
   293       iWindowGroup( aWindowGroup )
       
   294     {
       
   295     }
       
   296 
       
   297 
       
   298 // ---------------------------------------------------------------------------
       
   299 // Second phase constructor.
       
   300 // ---------------------------------------------------------------------------
       
   301 //
       
   302 void CAknKeylockScreenSaverObserver::ConstructL()
       
   303     {
       
   304     _AKNTRACE_FUNC_ENTER;
       
   305     
       
   306     // Add this active object to the scheduler.
       
   307     CActiveScheduler::Add( this );
       
   308     User::LeaveIfError( iScreenSaverActiveProperty.Attach( KPSUidScreenSaver,
       
   309                                                            KScreenSaverOn ) );
       
   310 
       
   311     // We need policies to poll primary keys.
       
   312     iUnlockPolicyApi = CKeyLockPolicyApi::NewL( EPolicyDeactivateKeyguard );
       
   313     if ( !iUnlockPolicyApi->HasConfiguration() )
       
   314         {
       
   315         delete iUnlockPolicyApi;
       
   316         iUnlockPolicyApi = NULL;
       
   317         }
       
   318 
       
   319     // we need policies to poll primary keys
       
   320     iDevicelockPolicyApi = CKeyLockPolicyApi::NewL( EPolicyDevicelockQuery );
       
   321     if ( !iDevicelockPolicyApi->HasConfiguration() )
       
   322         {
       
   323         delete iDevicelockPolicyApi;
       
   324         iDevicelockPolicyApi = NULL;
       
   325         }
       
   326     
       
   327     _AKNTRACE_FUNC_EXIT;
       
   328     }
       
   329 
       
   330 
       
   331 // ---------------------------------------------------------------------------
       
   332 // From base class CActive.
       
   333 // Handles change in the screen saver state.
       
   334 // ---------------------------------------------------------------------------
       
   335 //
       
   336 void CAknKeylockScreenSaverObserver::RunL()
       
   337     {
       
   338     _AKNTRACE_FUNC_ENTER;
       
   339     
       
   340     if ( iKeylockEnabled || iAutolockEnabled )
       
   341         {
       
   342         // Resubscribe before processing new value to prevent missing updates.
       
   343         Start();
       
   344         }
       
   345 
       
   346     TInt screenSaverState;
       
   347     iScreenSaverActiveProperty.Get( screenSaverState );
       
   348     // Primary keys are captured from screensaver when screensaver
       
   349     // is the top most application.
       
   350     if ( screenSaverState > NULL )
       
   351         {
       
   352          __ASSERT_DEBUG( !iCaptured,
       
   353                          Panic( EAknPanicKeyLockObserverAlreadyExists ) );
       
   354         iScreenSaverActive = ETrue;
       
   355         CapturePrimaryKeys( ETrue );
       
   356         }
       
   357     else
       
   358         {
       
   359         // If screensaver is disabled, stop capturing primary key events.
       
   360         if ( iScreenSaverActive )
       
   361             {
       
   362             CapturePrimaryKeys( EFalse );
       
   363             }
       
   364         iScreenSaverActive = EFalse;
       
   365         }
       
   366     
       
   367     _AKNTRACE_FUNC_EXIT;
       
   368     }
       
   369 
       
   370 
       
   371 // ---------------------------------------------------------------------------
       
   372 // Set the lock status.
       
   373 // ---------------------------------------------------------------------------
       
   374 //
       
   375 void CAknKeylockScreenSaverObserver::SetLockStatus( TBool aKeylockEnabled,
       
   376                                                     TBool aAutolockEnabled )
       
   377     {
       
   378     _AKNTRACE_FUNC_ENTER;
       
   379     
       
   380     iKeylockEnabled  = aKeylockEnabled;
       
   381     iAutolockEnabled = aAutolockEnabled;
       
   382 
       
   383     if ( iKeylockEnabled || iAutolockEnabled )
       
   384         {
       
   385         // Start observing screensaver activation.
       
   386         Start();
       
   387         }
       
   388     else
       
   389         {
       
   390         if ( iScreenSaverActive )
       
   391             {
       
   392             CapturePrimaryKeys( EFalse );
       
   393             }
       
   394         // Screensaver is only observed when keylock is enabled.
       
   395         Stop();
       
   396         }
       
   397     
       
   398     _AKNTRACE_FUNC_EXIT;
       
   399     }
       
   400 
       
   401 
       
   402 // ---------------------------------------------------------------------------
       
   403 // Capture or uncapture primary keys.
       
   404 // ---------------------------------------------------------------------------
       
   405 //
       
   406 void CAknKeylockScreenSaverObserver::CapturePrimaryKeys( TBool aCapture )
       
   407     {
       
   408     _AKNTRACE_FUNC_ENTER;
       
   409     
       
   410     if ( aCapture )
       
   411         {
       
   412         if ( iScreenSaverActive && !iCaptured )
       
   413             {
       
   414             if ( iKeylockEnabled && !iAutolockEnabled )
       
   415                 {
       
   416                 iCaptured = ETrue;
       
   417                 // If no unlocking policy has been defined,
       
   418                 // the default primary key is the left soft key.
       
   419                 if ( !iUnlockPolicyApi )
       
   420                     {
       
   421                     // Capture LSK (starts unlock prosess, capturing
       
   422                     // bypasses screensaver)
       
   423                     iLeftSoftKey = iWindowGroup.CaptureKey( EKeyDevice0, 0, 0 );
       
   424                     }
       
   425                 else
       
   426                     {
       
   427                     iPrimaryKeyCaptures.Reset();
       
   428                     TUint32 index( 0 );
       
   429                     TUint32 primaryKey( 0 );
       
   430                     TUint32 secondaryKey( 0 );
       
   431                     while ( iUnlockPolicyApi->GetKeyCombination( index,
       
   432                                                                  primaryKey,
       
   433                                                                  secondaryKey ) == KErrNone )
       
   434                         {
       
   435                         if (KErrNone != iPrimaryKeyCaptures.Append(iWindowGroup.CaptureKeyUpAndDowns(primaryKey, 0, 0)))
       
   436                             {
       
   437                             return;
       
   438                             }
       
   439                         index++;
       
   440                         }
       
   441                     }
       
   442                 }
       
   443             else
       
   444                 {
       
   445                 if ( iKeylockEnabled && iAutolockEnabled )
       
   446                     {
       
   447                     iCaptured = ETrue;
       
   448                     // If no devicelock query policy has been defined,
       
   449                     // the default primary key is the left soft key.
       
   450                     if ( !iDevicelockPolicyApi )
       
   451                         {
       
   452                         // Capture LSK (starts unlock prosess,
       
   453                         // capturing bypasses screensaver).
       
   454                         iLeftSoftKey = iWindowGroup.CaptureKey( EKeyDevice0, 0, 0 );
       
   455                         }
       
   456                     else
       
   457                         {
       
   458                         iPrimaryKeyCaptures.Reset();
       
   459                         TUint32 index( 0 );
       
   460                         TUint32 primaryKey( 0 );
       
   461                         TUint32 secondaryKey( 0 );
       
   462                         while ( iDevicelockPolicyApi->GetKeyCombination( index, primaryKey, secondaryKey ) == KErrNone )
       
   463                             {
       
   464                             if (KErrNone != iPrimaryKeyCaptures.Append(iWindowGroup.CaptureKeyUpAndDowns(primaryKey, 0, 0)))
       
   465                                 {
       
   466                                 return;
       
   467                                 }
       
   468                             index++;
       
   469                             }
       
   470                         }
       
   471                     }
       
   472                 }
       
   473             }
       
   474         }
       
   475     else
       
   476         {
       
   477         if (iCaptured)
       
   478             {
       
   479             if (iLeftSoftKey > 0)
       
   480                 {
       
   481                 iWindowGroup.CancelCaptureKey(iLeftSoftKey); 
       
   482                 }
       
   483             iLeftSoftKey = 0;
       
   484             
       
   485             if (iPrimaryKeyCaptures.Count() > 0)
       
   486                 {
       
   487                 for (TInt x = 0; x < iPrimaryKeyCaptures.Count(); x++)
       
   488                     {
       
   489                     iWindowGroup.CancelCaptureKeyUpAndDowns(iPrimaryKeyCaptures[x]);
       
   490                     }
       
   491                 iPrimaryKeyCaptures.Reset();
       
   492                 }
       
   493             
       
   494             iCaptured = EFalse;
       
   495             }
       
   496         }
       
   497     
       
   498     _AKNTRACE_FUNC_EXIT;
       
   499     }
       
   500 
       
   501 
       
   502 // ---------------------------------------------------------------------------
       
   503 // From base class CActive.
       
   504 // Cancels event listening.
       
   505 // ---------------------------------------------------------------------------
       
   506 //
       
   507 void CAknKeylockScreenSaverObserver::DoCancel()
       
   508     {
       
   509     _AKNTRACE_FUNC_ENTER;
       
   510     
       
   511     iScreenSaverActiveProperty.Cancel();
       
   512     
       
   513     _AKNTRACE_FUNC_EXIT;
       
   514     }
    94 
   515 
    95 
   516 
    96 // ===========================================================================
   517 // ===========================================================================
    97 // class CAknLockedNote.
   518 // class CAknLockedNote.
    98 // ===========================================================================
   519 // ===========================================================================
   115 // Handles a dialog button press for the button with ID aCommand.
   536 // Handles a dialog button press for the button with ID aCommand.
   116 // ---------------------------------------------------------------------------
   537 // ---------------------------------------------------------------------------
   117 //
   538 //
   118 TBool CAknLockedNote::OkToExitL( TInt aCommand )
   539 TBool CAknLockedNote::OkToExitL( TInt aCommand )
   119     {
   540     {
       
   541     _AKNTRACE_FUNC_ENTER;
       
   542     
   120     iLocked = EFalse;
   543     iLocked = EFalse;
   121     if ( iCommandObserver )
   544     if ( iCommandObserver )
   122         {
   545         {
   123         iCommandObserver->ProcessCommandL( aCommand );
   546         iCommandObserver->ProcessCommandL( aCommand );
   124         }
   547         }
       
   548     
       
   549     _AKNTRACE_FUNC_EXIT;
       
   550     
   125     return ETrue;
   551     return ETrue;
   126     }
   552     }
   127 
   553 
   128 
   554 
   129 // ---------------------------------------------------------------------------
   555 // ---------------------------------------------------------------------------
   141 // Cancels the note.
   567 // Cancels the note.
   142 // ---------------------------------------------------------------------------
   568 // ---------------------------------------------------------------------------
   143 //
   569 //
   144 void CAknLockedNote::CancelNote()
   570 void CAknLockedNote::CancelNote()
   145     {
   571     {
       
   572     _AKNTRACE_FUNC_ENTER;
       
   573     
   146     if ( iTimer )
   574     if ( iTimer )
   147         {
   575         {
   148         iTimer->Cancel();
   576         iTimer->Cancel();
   149         }
   577         }
   150     ExitSleepingDialog();
   578     ExitSleepingDialog();
   151     iLocked = EFalse;
   579     iLocked = EFalse;
       
   580     
       
   581     _AKNTRACE_FUNC_EXIT;
   152     }
   582     }
   153 
   583 
   154 
   584 
   155 // ---------------------------------------------------------------------------
   585 // ---------------------------------------------------------------------------
   156 // From base class CEikDialog.
   586 // From base class CEikDialog.
   157 // Handles focus change event.
   587 // Handles focus change event.
   158 // ---------------------------------------------------------------------------
   588 // ---------------------------------------------------------------------------
   159 //
   589 //
   160 void CAknLockedNote::FocusChanged( TDrawNow /*aDrawNow*/ )
   590 void CAknLockedNote::FocusChanged( TDrawNow /*aDrawNow*/ )
   161     {
   591     {
       
   592     _AKNTRACE_FUNC_ENTER;
       
   593     
   162     if ( !IsFocused() && iCommandObserver )
   594     if ( !IsFocused() && iCommandObserver )
   163         {
   595         {
   164         TRAP_IGNORE( iCommandObserver->ProcessCommandL( KNoteCmdFocusLost ) )
   596         TRAP_IGNORE( iCommandObserver->ProcessCommandL( KNoteCmdFocusLost ) )
   165         }
   597         }
       
   598   
       
   599     _AKNTRACE_FUNC_EXIT;
   166     }
   600     }
   167 
   601 
   168 
   602 
   169 // ---------------------------------------------------------------------------
   603 // ---------------------------------------------------------------------------
   170 // From base class CEikDialog.
   604 // From base class CEikDialog.
   241 // Displays the note.
   675 // Displays the note.
   242 // ---------------------------------------------------------------------------
   676 // ---------------------------------------------------------------------------
   243 //
   677 //
   244 TInt CAknSleepingNote::ShowNote( const TInt aTimeout, const TTone aTone )
   678 TInt CAknSleepingNote::ShowNote( const TInt aTimeout, const TTone aTone )
   245     {
   679     {
       
   680     _AKNTRACE_FUNC_ENTER;
       
   681     
   246     TRAP_IGNORE(AknGlobalPopupPriorityController::SetPopupPriorityL( *this, KGlobalWindowPriority_KeyLock ));
   682     TRAP_IGNORE(AknGlobalPopupPriorityController::SetPopupPriorityL( *this, KGlobalWindowPriority_KeyLock ));
   247     iTimeoutInMicroseconds = aTimeout;
   683     iTimeoutInMicroseconds = aTimeout;
   248     iTone = aTone;
   684     iTone = aTone;
       
   685     
       
   686     _AKNTRACE_FUNC_EXIT;
       
   687     
   249     return RouseSleepingDialog();
   688     return RouseSleepingDialog();
   250     }
   689     }
   251 
   690 
   252 
   691 
   253 // ---------------------------------------------------------------------------
   692 // ---------------------------------------------------------------------------
   255 // Handles a dialog button press for the button with ID aCommand.
   694 // Handles a dialog button press for the button with ID aCommand.
   256 // ---------------------------------------------------------------------------
   695 // ---------------------------------------------------------------------------
   257 //
   696 //
   258 TBool CAknSleepingNote::OkToExitL( TInt aCommand )
   697 TBool CAknSleepingNote::OkToExitL( TInt aCommand )
   259     {
   698     {
       
   699     _AKNTRACE_FUNC_ENTER;
       
   700     
   260     if ( iCommandObserver )
   701     if ( iCommandObserver )
   261         {
   702         {
   262         iCommandObserver->ProcessCommandL( aCommand );
   703         iCommandObserver->ProcessCommandL( aCommand );
   263         }
   704         }
       
   705 
       
   706     _AKNTRACE_FUNC_EXIT;
       
   707 
   264     return ETrue;
   708     return ETrue;
   265     }
   709     }
   266 
   710 
   267 
   711 
   268 // ---------------------------------------------------------------------------
   712 // ---------------------------------------------------------------------------
   270 // Updates the note animation on skin change event.
   714 // Updates the note animation on skin change event.
   271 // ---------------------------------------------------------------------------
   715 // ---------------------------------------------------------------------------
   272 //
   716 //
   273 void CAknSleepingNote::HandleResourceChange( TInt aType )
   717 void CAknSleepingNote::HandleResourceChange( TInt aType )
   274     {
   718     {
       
   719     _AKNTRACE_FUNC_ENTER;
       
   720     
   275     if ( aType == KAknsMessageSkinChange )
   721     if ( aType == KAknsMessageSkinChange )
   276         {
   722         {
   277         TInt animationRes( 0 );
   723         TInt animationRes( 0 );
   278         switch ( iResourceId )
   724         switch ( iResourceId )
   279             {
   725             {
   323                 }
   769                 }
   324             }
   770             }
   325         }
   771         }
   326 
   772 
   327     CAknNoteDialog::HandleResourceChange( aType );
   773     CAknNoteDialog::HandleResourceChange( aType );
       
   774     
       
   775     _AKNTRACE_FUNC_EXIT;
   328     }
   776     }
   329 
   777 
   330 
   778 
   331 // ---------------------------------------------------------------------------
   779 // ---------------------------------------------------------------------------
   332 // From base class CEikDialog.
   780 // From base class CEikDialog.
   415 // Sets the emergency number to be displayed.
   863 // Sets the emergency number to be displayed.
   416 // ---------------------------------------------------------------------------
   864 // ---------------------------------------------------------------------------
   417 //
   865 //
   418 void CAknEcsNote::SetEmergencyNumber( const TDesC& aMatchedNumber )
   866 void CAknEcsNote::SetEmergencyNumber( const TDesC& aMatchedNumber )
   419     {
   867     {
       
   868     _AKNTRACE_FUNC_ENTER;
       
   869     
   420     TRect mainPane;
   870     TRect mainPane;
   421     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EPopupParent,
   871     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EPopupParent,
   422                                        mainPane );
   872                                        mainPane );
   423 
   873 
   424     TAknLayoutRect popupNoteWindow;
   874     TAknLayoutRect popupNoteWindow;
   478         number.Append( ' ' );
   928         number.Append( ' ' );
   479         }
   929         }
   480 
   930 
   481     number.Append( aMatchedNumber );
   931     number.Append( aMatchedNumber );
   482     TRAP_IGNORE( SetTextL( number ) );
   932     TRAP_IGNORE( SetTextL( number ) );
       
   933     
       
   934     _AKNTRACE_FUNC_EXIT;
   483     }
   935     }
   484 
   936 
   485 
   937 
   486 // ---------------------------------------------------------------------------
   938 // ---------------------------------------------------------------------------
   487 // Makes the note go to sleep.
   939 // Makes the note go to sleep.
   488 // ---------------------------------------------------------------------------
   940 // ---------------------------------------------------------------------------
   489 //
   941 //
   490 void CAknEcsNote::SleepNote()
   942 void CAknEcsNote::SleepNote()
   491     {
   943     {
       
   944     _AKNTRACE_FUNC_ENTER;
       
   945     
   492     if ( iNoteOnScreen )
   946     if ( iNoteOnScreen )
   493         {
   947         {
   494         // Causes flicker to other notes if called when note is not on screen.
   948         // Causes flicker to other notes if called when note is not on screen.
   495         ExitSleepingDialog();
   949         ExitSleepingDialog();
   496         }
   950         }
   497     iNoteOnScreen = EFalse;
   951     iNoteOnScreen = EFalse;
       
   952     
       
   953     _AKNTRACE_FUNC_EXIT;
   498     }
   954     }
   499 
   955 
   500 
   956 
   501 // ===========================================================================
   957 // ===========================================================================
   502 // class CAknKeyLockControl
   958 // class CAknKeyLockControl
   519 // ---------------------------------------------------------------------------
   975 // ---------------------------------------------------------------------------
   520 //
   976 //
   521 CAknKeyLockControl::CAknKeyLockControl( CAknKeyLockNotifierSubject* aNotif ) :
   977 CAknKeyLockControl::CAknKeyLockControl( CAknKeyLockNotifierSubject* aNotif ) :
   522     iNotif( aNotif )
   978     iNotif( aNotif )
   523     {
   979     {
       
   980     _AKNTRACE_FUNC_ENTER;
       
   981     
   524     AKNTASHOOK_ADD( this, "CAknKeyLockControl" );
   982     AKNTASHOOK_ADD( this, "CAknKeyLockControl" );
       
   983     
       
   984     _AKNTRACE_FUNC_EXIT;
   525     }
   985     }
   526 
   986 
   527 
   987 
   528 // ---------------------------------------------------------------------------
   988 // ---------------------------------------------------------------------------
   529 // Destructor
   989 // Destructor
   530 // ---------------------------------------------------------------------------
   990 // ---------------------------------------------------------------------------
   531 //
   991 //
   532 CAknKeyLockControl::~CAknKeyLockControl()
   992 CAknKeyLockControl::~CAknKeyLockControl()
   533     {
   993     {
       
   994     _AKNTRACE_FUNC_ENTER;
       
   995     
   534     AKNTASHOOK_REMOVE();
   996     AKNTASHOOK_REMOVE();
   535     // We implicitely trust that Eikon env exists
   997     // We implicitely trust that Eikon env exists
   536     // (though in practice it does not make the
   998     // (though in practice it does not make the
   537     // difference as this destructor is really never called...)
   999     // difference as this destructor is really never called...)
   538     RWindowGroup& groupWin = iEikonEnv->RootWin();
  1000     RWindowGroup& groupWin = iEikonEnv->RootWin();
   553     delete iEcsDetector;
  1015     delete iEcsDetector;
   554     delete iKeyLockCba;
  1016     delete iKeyLockCba;
   555     delete iOfferLockNote;
  1017     delete iOfferLockNote;
   556     delete iEcsNote; // Ecs change
  1018     delete iEcsNote; // Ecs change
   557     delete iKeylockApi;
  1019     delete iKeylockApi;
       
  1020     delete iKeylockScreenSaverObserver;
       
  1021     
       
  1022     _AKNTRACE_FUNC_EXIT;
   558     }
  1023     }
   559 
  1024 
   560 
  1025 
   561 // ---------------------------------------------------------------------------
  1026 // ---------------------------------------------------------------------------
   562 // Second phase construction.
  1027 // Second phase construction.
   563 // ---------------------------------------------------------------------------
  1028 // ---------------------------------------------------------------------------
   564 //
  1029 //
   565 void CAknKeyLockControl::ConstructL()
  1030 void CAknKeyLockControl::ConstructL()
   566     {
  1031     {
   567     TRACES( RDebug::Print(_L("(KeyGuard)CAknKeyLockControl::ConstructL ")); )
  1032     _AKNTRACE_FUNC_ENTER;
   568 
  1033 
   569     FeatureManager::InitializeLibL();
  1034     FeatureManager::InitializeLibL();
   570     iFeatureKeypadNoSlider =
  1035     iFeatureKeypadNoSlider =
   571         FeatureManager::FeatureSupported( KFeatureIdKeypadNoSlider );
  1036         FeatureManager::FeatureSupported( KFeatureIdKeypadNoSlider );
   572     iFeatureNoPowerkey =
  1037     iFeatureNoPowerkey =
   599     iOfferLockNote->ConstructSleepingNoteL( R_KEYLOCK_OFFER_LOCK_NOTE );
  1064     iOfferLockNote->ConstructSleepingNoteL( R_KEYLOCK_OFFER_LOCK_NOTE );
   600     iOfferLockNote->ButtonGroupContainer().ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition( 0, 2 );
  1065     iOfferLockNote->ButtonGroupContainer().ButtonGroup()->AsControl()->DrawableWindow()->SetOrdinalPosition( 0, 2 );
   601 
  1066 
   602     TBool touchEnabled( AknLayoutUtils::PenEnabled() );
  1067     TBool touchEnabled( AknLayoutUtils::PenEnabled() );
   603 
  1068 
   604 	TBool hasSlider(iHardwareSupport != EKeyguardDefaultHardware);
  1069     TBool hasSlider = HasSliderKey();
   605 
       
   606     iKeyLockCba = CEikButtonGroupContainer::NewL(
  1070     iKeyLockCba = CEikButtonGroupContainer::NewL(
   607                     CEikButtonGroupContainer::ECba,
  1071                     CEikButtonGroupContainer::ECba,
   608                     CEikButtonGroupContainer::EHorizontal,
  1072                     CEikButtonGroupContainer::EHorizontal,
   609                     this,
  1073                     this,
   610                     (touchEnabled&&hasSlider) ? R_AVKON_SOFTKEYS_EMPTY :
  1074                     (touchEnabled&&hasSlider) ? R_AVKON_SOFTKEYS_EMPTY :
   717         // Keylock API not initialized.
  1181         // Keylock API not initialized.
   718         delete iKeylockApi;
  1182         delete iKeylockApi;
   719         iKeylockApi = NULL;
  1183         iKeylockApi = NULL;
   720         }
  1184         }
   721 
  1185 
       
  1186     iKeylockScreenSaverObserver =
       
  1187         CAknKeylockScreenSaverObserver::NewL( groupWin );
       
  1188 
   722     // Define P&S key that is used to publish the keyguard status.
  1189     // Define P&S key that is used to publish the keyguard status.
   723     RProperty::Define( KPSUidAvkonDomain,
  1190     RProperty::Define( KPSUidAvkonDomain,
   724                        KAknKeyguardStatus,
  1191                        KAknKeyguardStatus,
   725                        RProperty::EInt,
  1192                        RProperty::EInt,
   726                        TSecurityPolicy( TSecurityPolicy::EAlwaysPass ),
  1193                        TSecurityPolicy( TSecurityPolicy::EAlwaysPass ),
   727                        KWritePolicy );
  1194                        KWritePolicy );
   728 
  1195 
   729     iStatusProperty.Attach( KPSUidAvkonDomain, KAknKeyguardStatus );
  1196     iStatusProperty.Attach( KPSUidAvkonDomain, KAknKeyguardStatus );
   730     iStatusProperty.Set( EKeyguardNotActive );
  1197     iStatusProperty.Set( EKeyguardNotActive );
       
  1198     
       
  1199     _AKNTRACE_FUNC_EXIT;
   731     }
  1200     }
   732 
  1201 
   733 
  1202 
   734 // ---------------------------------------------------------------------------
  1203 // ---------------------------------------------------------------------------
   735 // Enable key lock.
  1204 // Enable key lock.
   736 // ---------------------------------------------------------------------------
  1205 // ---------------------------------------------------------------------------
   737 //
  1206 //
   738 void CAknKeyLockControl::EnableKeylock( TBool aShowNote )
  1207 void CAknKeyLockControl::EnableKeylock( TBool aShowNote, TBool aNotifySysApp )
   739     {
  1208     {
   740     TRACES( RDebug::Print(_L("(KeyGuard)CAknKeyLockControl::EnableKeylock %d"), aShowNote); )
  1209     _AKNTRACE_FUNC_ENTER;
   741 
  1210     _AKNTRACE("aShowNote:%d",aShowNote);
       
  1211     _AKNTRACE("aNotifySysApp:%d",aNotifySysApp);
       
  1212     
   742     // Policy can be used to disable support for keyguard.
  1213     // Policy can be used to disable support for keyguard.
   743     if ( !iAutolockEnabled && !CKeyLockPolicyApi::KeyguardAllowed() )
  1214     if ( !iAutolockEnabled && !CKeyLockPolicyApi::KeyguardAllowed() )
   744         {
  1215         {
   745         // Keylock Disabled
  1216         // Keylock Disabled
   746         return;
  1217         return;
   747         }
  1218         }
   748 
  1219     // Keylock Enabled
       
  1220     iKeylockScreenSaverObserver->SetLockStatus( ETrue, iAutolockEnabled );
   749     if ( iOfferLockEnabled )
  1221     if ( iOfferLockEnabled )
   750         {
  1222         {
   751         iOfferLockNote->CancelNote();
  1223         iOfferLockNote->CancelNote();
   752         }
  1224         }
   753 
  1225 
   754     // Update keyguard status to P&S system.
  1226     // Update keyguard status to P&S system.
   755     iStatusProperty.Set( iAutolockEnabled ? EKeyguardAutolockEmulation :
  1227     iStatusProperty.Set( iAutolockEnabled ? EKeyguardAutolockEmulation :
   756                                             EKeyguardLocked );
  1228                                             EKeyguardLocked );
   757     iKeyLockEnabled = ETrue;
  1229     iKeyLockEnabled = ETrue;
   758 
  1230 
   759     if ( !iAutolockEnabled )
  1231     if ( !iAutolockEnabled && aNotifySysApp )
   760         {
  1232         {
   761         SendMessageToSysAp( EEikKeyLockEnabled );
  1233         SendMessageToSysAp( EEikKeyLockEnabled );
   762         }
  1234         }
   763 
  1235     TBool hasSliderKey = HasSliderKey();
   764     if ( !AknLayoutUtils::PenEnabled() || iHardwareSupport == EKeyguardDefaultHardware)
  1236     if ( !AknLayoutUtils::PenEnabled() || !hasSliderKey)
   765         {
  1237         {
   766         iKeyLockCba->MakeVisible( ETrue );
  1238         iKeyLockCba->MakeVisible( ETrue );
   767         }
  1239         }
   768     else
  1240     else
   769         {
  1241         {
   791     if ( aShowNote )
  1263     if ( aShowNote )
   792         {
  1264         {
   793         DisplayLockedNote();
  1265         DisplayLockedNote();
   794         }
  1266         }
   795 
  1267 
   796     if ( !AknLayoutUtils::PenEnabled() || iHardwareSupport == EKeyguardDefaultHardware)
  1268     if ( !AknLayoutUtils::PenEnabled() || !hasSliderKey)
   797         {
  1269         {
   798         ShowKeylockCba();
  1270         ShowKeylockCba();
   799         }
  1271         }
   800     else
  1272     else
   801         {
  1273         {
   809             {
  1281             {
   810              Window().SetBackgroundColor( ~0 );
  1282              Window().SetBackgroundColor( ~0 );
   811             }
  1283             }
   812         }
  1284         }
   813 
  1285 
   814 		// in case Telephone-app is topmost, then the user is confused because he sees but can't use it.
  1286         // in case Telephone-app is topmost, then the user is confused because he sees but can't use it.
   815 		// therefore it's required to hide it, by sending to background. ETMA-7M8A2Y 20090105
  1287         // therefore it's required to hide it, by sending to background. ETMA-7M8A2Y 20090105
   816 		if ( AknLayoutUtils::PenEnabled() )
  1288         if ( AknLayoutUtils::PenEnabled() )
   817        	{ 		
  1289             {
   818 	   			TApaTaskList apaTaskList(CCoeEnv::Static()->WsSession());
  1290             TApaTaskList apaTaskList(CCoeEnv::Static()->WsSession());
   819 	   			#define KPhoneAppUid TUid::Uid(0x100058B3)
  1291             #define KPhoneAppUid TUid::Uid(0x100058B3)
   820 
  1292 
   821      			TApaTask apaTask = apaTaskList.FindApp(KPhoneAppUid);
  1293             TApaTask apaTask = apaTaskList.FindApp(KPhoneAppUid);
   822      			if (apaTask.Exists())
  1294             if (apaTask.Exists())
   823          	{
  1295                 {
   824 				 		#if defined(_DEBUG)
  1296                 #if defined(_DEBUG)
   825 				 			RDebug::Print(_L("(KeyGuard)CAknKeyLockControl::EnableKeylock() Bring phone to background"));
  1297                 RDebug::Print(_L("(KeyGuard)CAknKeyLockControl::EnableKeylock() Bring phone to background"));
   826 				 		#endif
  1298                 #endif
   827          		// Bring phone to background
  1299                 // Bring phone to background
   828          		apaTask.SendToBackground();
  1300                 apaTask.SendToBackground();
   829          	}
  1301                 }
   830 				}
  1302             }
   831 
  1303 
   832     // Start capturing system keys.
  1304     // Start capturing system keys.
   833     CaptureSystemKeys();
  1305     CaptureSystemKeys();
   834 
  1306 
   835     // Capture all pointer events.
  1307     // Capture all pointer events.
   860 
  1332 
   861     // Method HandleResourceChangeL with parameter KAknInternalFSWClose cannot
  1333     // Method HandleResourceChangeL with parameter KAknInternalFSWClose cannot
   862     // leave, but we trap it in just in case.
  1334     // leave, but we trap it in just in case.
   863     TRAP_IGNORE( static_cast<CAknCapAppServerAppUi*>( iEikonEnv->EikAppUi() )->HandleResourceChangeL(
  1335     TRAP_IGNORE( static_cast<CAknCapAppServerAppUi*>( iEikonEnv->EikAppUi() )->HandleResourceChangeL(
   864             KAknInternalFSWClose ); );
  1336             KAknInternalFSWClose ); );
       
  1337     
       
  1338     _AKNTRACE_FUNC_EXIT;
   865     }
  1339     }
   866 
  1340 
   867 
  1341 
   868 // ---------------------------------------------------------------------------
  1342 // ---------------------------------------------------------------------------
   869 // Disable key lock.
  1343 // Disable key lock.
   870 // ---------------------------------------------------------------------------
  1344 // ---------------------------------------------------------------------------
   871 //
  1345 //
   872 void CAknKeyLockControl::DisableKeylock()
  1346 void CAknKeyLockControl::DisableKeylock(TBool aNotifySysApp)
   873     {
  1347     {
   874     TRACES( RDebug::Print(_L("(KeyGuard)CAknKeyLockControl::DisableKeylock")); )
  1348     _AKNTRACE_FUNC_ENTER;
   875 
  1349     _AKNTRACE("aShowNote:%d",aNotifySysApp);
       
  1350 
       
  1351     // Keep locking status in sync.
       
  1352     iKeylockScreenSaverObserver->SetLockStatus( EFalse, iAutolockEnabled );
   876     if ( iSoundsMuted )
  1353     if ( iSoundsMuted )
   877         {
  1354         {
   878         CAknAppUiBase* appUi= iAvkonAppUiBase;
  1355         CAknAppUiBase* appUi= iAvkonAppUiBase;
   879         appUi->KeySounds()->ReleaseContext();
  1356         appUi->KeySounds()->ReleaseContext();
   880         appUi->KeySounds()->PopContext();
  1357         appUi->KeySounds()->PopContext();
   900 
  1377 
   901     // Update keyguard status to P&S system.
  1378     // Update keyguard status to P&S system.
   902     iStatusProperty.Set( EKeyguardNotActive );
  1379     iStatusProperty.Set( EKeyguardNotActive );
   903     iKeyLockEnabled = EFalse;
  1380     iKeyLockEnabled = EFalse;
   904 
  1381 
   905     if ( !iAutolockEnabled )	// only when Autolock was user-activated
  1382     if ( !iAutolockEnabled )    // only when Autolock was user-activated
   906         {
  1383         {
   907 		    // in case Telephone-app was topmost and sent to background, then the user is confused because he expects to see it again.
  1384         // in case Telephone-app was topmost and sent to background, then the user is confused because he expects to see it again.
   908 				// therefore it's required to show it, by sending to foreground. 
  1385         // therefore it's required to show it, by sending to foreground. 
   909 				if ( AknLayoutUtils::PenEnabled() )
  1386         if ( AknLayoutUtils::PenEnabled() )
   910 		     	{ 		
  1387             {       
   911     	    TInt callState;
  1388             TInt callState;
   912     	    RProperty::Get( KPSUidCtsyCallInformation, KCTsyCallState, callState );
  1389             RProperty::Get( KPSUidCtsyCallInformation, KCTsyCallState, callState );
   913     	    #if defined(_DEBUG)
  1390             #if defined(_DEBUG)
   914 						RDebug::Printf( "%s %s (%u) callState=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, callState );
  1391             RDebug::Printf( "%s %s (%u) callState=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, callState );
   915 						RDebug::Printf( "%s %s (%u) EPSCTsyCallStateNone=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, EPSCTsyCallStateNone );
  1392             RDebug::Printf( "%s %s (%u) EPSCTsyCallStateNone=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, EPSCTsyCallStateNone );
   916 					#endif
  1393             #endif
   917           if (callState != EPSCTsyCallStateNone )
  1394             if (callState != EPSCTsyCallStateNone )
   918               {
  1395                 {
   919                 	
  1396                 TApaTaskList apaTaskList(CCoeEnv::Static()->WsSession());
   920 				   			TApaTaskList apaTaskList(CCoeEnv::Static()->WsSession());
  1397                 #define KPhoneAppUid TUid::Uid(0x100058B3)
   921 				   			#define KPhoneAppUid TUid::Uid(0x100058B3)
  1398                 TApaTask apaTask = apaTaskList.FindApp(KPhoneAppUid);
   922 				
  1399                 if (apaTask.Exists())
   923 				   			TApaTask apaTask = apaTaskList.FindApp(KPhoneAppUid);
  1400                     {
   924 				   			if (apaTask.Exists())
  1401                     RDebug::Printf( "%s %s (%u) foreground=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
   925 				       	{
  1402                     #if defined(_DEBUG)
   926 									RDebug::Printf( "%s %s (%u) foreground=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
  1403                     RDebug::Print(_L("(AUTOLOCK)CAknKeyLockControl::EnableKeylock() Send phone to foreground"));
   927 							 		#if defined(_DEBUG)
  1404                     #endif
   928 							 			RDebug::Print(_L("(AUTOLOCK)CAknKeyLockControl::EnableKeylock() Send phone to foreground"));
  1405                     // Bring phone to foreground
   929 							 		#endif
  1406                     apaTask.BringToForeground();
   930 				       		// Bring phone to foreground
  1407                     }
   931 				       		apaTask.BringToForeground();
  1408                 }
   932 				       	}
  1409             }   // PenEnabled()
   933 		       		}
  1410         }
   934 					}	// PenEnabled()
  1411 
   935 
  1412 	if (aNotifySysApp)
   936         SendMessageToSysAp( EEikKeyLockDisabled );
  1413 		{
   937         }
  1414 		SendMessageToSysAp( EEikKeyLockDisabled );
   938     if ( iNotif )
  1415 		}
       
  1416 
       
  1417 	if ( iNotif )
   939         {
  1418         {
   940         iNotif->NotifyStatusChange( EKeyLockDisabled );
  1419         iNotif->NotifyStatusChange( EKeyLockDisabled );
   941         }
  1420         }
   942 
  1421 
   943     // Basically this cannot fail so we ignore return code.
  1422     // Basically this cannot fail so we ignore return code.
   944     static_cast<CAknNotifierAppServerAppUi*>(
  1423     static_cast<CAknNotifierAppServerAppUi*>(
   945         iEikonEnv->EikAppUi() )->SuppressAppSwitching( EFalse );
  1424         iEikonEnv->EikAppUi() )->SuppressAppSwitching( EFalse );
   946 
  1425 
   947     iAutolockEnabled = EFalse;
  1426     iAutolockEnabled = EFalse;
       
  1427     
       
  1428     _AKNTRACE_FUNC_EXIT;
   948     }
  1429     }
   949 
  1430 
   950 
  1431 
   951 // ---------------------------------------------------------------------------
  1432 // ---------------------------------------------------------------------------
   952 // Sends a message to the SysAp window group.
  1433 // Sends a message to the SysAp window group.
   953 // ---------------------------------------------------------------------------
  1434 // ---------------------------------------------------------------------------
   954 //
  1435 //
   955 void CAknKeyLockControl::SendMessageToSysAp( TInt aMessage )
  1436 void CAknKeyLockControl::SendMessageToSysAp( TInt aMessage )
   956     {
  1437     {
       
  1438     _AKNTRACE_FUNC_ENTER;
       
  1439     
   957     RWsSession& ws = iEikonEnv->WsSession();
  1440     RWsSession& ws = iEikonEnv->WsSession();
   958     TInt wgId = 0;
  1441     TInt wgId = 0;
   959     CApaWindowGroupName::FindByAppUid( KSysApUid, ws, wgId );
  1442     CApaWindowGroupName::FindByAppUid( KSysApUid, ws, wgId );
   960     if ( wgId )
  1443     if ( wgId )
   961         {
  1444         {
   962         TWsEvent event;
  1445         TWsEvent event;
   963         event.SetType( aMessage );
  1446         event.SetType( aMessage );
   964         event.SetTimeNow();
  1447         event.SetTimeNow();
   965         ws.SendEventToWindowGroup( wgId, event );
  1448         ws.SendEventToWindowGroup( wgId, event );
   966         }
  1449         }
       
  1450     
       
  1451     _AKNTRACE_FUNC_EXIT;
   967     }
  1452     }
   968 
  1453 
   969 
  1454 
   970 // ---------------------------------------------------------------------------
  1455 // ---------------------------------------------------------------------------
   971 // Displays the "offer keylock" note.
  1456 // Displays the "offer keylock" note.
   972 // ---------------------------------------------------------------------------
  1457 // ---------------------------------------------------------------------------
   973 //
  1458 //
   974 void CAknKeyLockControl::OfferKeylock()
  1459 void CAknKeyLockControl::OfferKeylock()
   975     {
  1460     {
       
  1461     _AKNTRACE_FUNC_ENTER;
       
  1462     
   976     iOfferLockNote->ShowNote( (CAknNoteDialog::TTimeout)KAknOfferKeyLockTimeout,
  1463     iOfferLockNote->ShowNote( (CAknNoteDialog::TTimeout)KAknOfferKeyLockTimeout,
   977                               CAknNoteDialog::ENoTone );
  1464                               CAknNoteDialog::ENoTone );
   978     iOfferLockEnabled = ETrue;
  1465     iOfferLockEnabled = ETrue;
       
  1466     
       
  1467     _AKNTRACE_FUNC_EXIT;
   979     }
  1468     }
   980 
  1469 
   981 
  1470 
   982 // ---------------------------------------------------------------------------
  1471 // ---------------------------------------------------------------------------
   983 // Displays the "locked" note.
  1472 // Displays the "locked" note.
   985 //
  1474 //
   986 void CAknKeyLockControl::DisplayLockedNote()
  1475 void CAknKeyLockControl::DisplayLockedNote()
   987     {
  1476     {
   988     if ( !iAutolockEnabled )
  1477     if ( !iAutolockEnabled )
   989         {
  1478         {
   990         iKeypadLockedNote->ShowNote( KKeyLockCustomShortTimeout,
       
   991                                      CAknNoteDialog::ENoTone );
       
   992         }
  1479         }
   993     }
  1480     }
   994 
  1481 
   995 
  1482 
   996 // ---------------------------------------------------------------------------
  1483 // ---------------------------------------------------------------------------
   999 //
  1486 //
  1000 void CAknKeyLockControl::DisplayKeyActiveNote()
  1487 void CAknKeyLockControl::DisplayKeyActiveNote()
  1001     {
  1488     {
  1002     if ( !iAutolockEnabled )
  1489     if ( !iAutolockEnabled )
  1003         {
  1490         {
  1004         iKeypadUnlockedNote->ShowNote( KKeyLockCustomShortTimeout,
       
  1005                                        CAknNoteDialog::ENoTone );
       
  1006         }
  1491         }
  1007     }
  1492     }
  1008 
  1493 
  1009 
  1494 
  1010 // ---------------------------------------------------------------------------
  1495 // ---------------------------------------------------------------------------
  1011 // Unlocks the keypad and displays the "keys active" note.
  1496 // Unlocks the keypad and displays the "keys active" note.
  1012 // ---------------------------------------------------------------------------
  1497 // ---------------------------------------------------------------------------
  1013 //
  1498 //
  1014 void CAknKeyLockControl::DoUnlock()
  1499 void CAknKeyLockControl::DoUnlock()
  1015     {
  1500     {
       
  1501     _AKNTRACE_FUNC_ENTER;
       
  1502     
  1016     DisableKeylock();
  1503     DisableKeylock();
  1017     DisplayKeyActiveNote();
  1504     DisplayKeyActiveNote();
       
  1505     
       
  1506     _AKNTRACE_FUNC_EXIT;
  1018     }
  1507     }
  1019 
  1508 
  1020 
  1509 
  1021 // ---------------------------------------------------------------------------
  1510 // ---------------------------------------------------------------------------
  1022 // From base class CCoeControl.
  1511 // From base class CCoeControl.
  1023 // Handles resource change events.
  1512 // Handles resource change events.
  1024 // ---------------------------------------------------------------------------
  1513 // ---------------------------------------------------------------------------
  1025 //
  1514 //
  1026 void CAknKeyLockControl::HandleResourceChange( TInt aType )
  1515 void CAknKeyLockControl::HandleResourceChange( TInt aType )
  1027     {
  1516     {
       
  1517     _AKNTRACE_FUNC_ENTER;
       
  1518     _AKNTRACE("aType:%d",aType);
       
  1519 
  1028     if ( aType == KEikDynamicLayoutVariantSwitch )
  1520     if ( aType == KEikDynamicLayoutVariantSwitch )
  1029         {
  1521         {
  1030         TRect screenRect;
  1522         TRect screenRect;
  1031         AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screenRect );
  1523         AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screenRect );
  1032         if ( !AknLayoutUtils::PenEnabled() )
  1524         if ( !AknLayoutUtils::PenEnabled() )
  1045                 {
  1537                 {
  1046                  Window().SetBackgroundColor( ~0 );
  1538                  Window().SetBackgroundColor( ~0 );
  1047                 }
  1539                 }
  1048             }
  1540             }
  1049         }
  1541         }
       
  1542     
       
  1543     _AKNTRACE_FUNC_EXIT;
  1050     }
  1544     }
  1051 
  1545 
  1052 
  1546 
  1053 // ---------------------------------------------------------------------------
  1547 // ---------------------------------------------------------------------------
  1054 // From base class MEikCommandObserver.
  1548 // From base class MEikCommandObserver.
  1055 // Process commands.
  1549 // Process commands.
  1056 // ---------------------------------------------------------------------------
  1550 // ---------------------------------------------------------------------------
  1057 //
  1551 //
  1058 void CAknKeyLockControl::ProcessCommandL( TInt aCommandId )
  1552 void CAknKeyLockControl::ProcessCommandL( TInt aCommandId )
  1059     {
  1553     {
  1060     TRACES( RDebug::Print(_L("(KeyGuard)CAknKeyLockControl::ProcessCommandL %d"), aCommandId); )
  1554     _AKNTRACE_FUNC_ENTER;
       
  1555     _AKNTRACE("aCommandId:%d",aCommandId);
  1061 
  1556 
  1062     switch ( aCommandId )
  1557     switch ( aCommandId )
  1063         {
  1558         {
  1064         case EAknSoftkeyUnlock:
  1559         case EAknSoftkeyUnlock:
  1065             {
  1560             {
  1116         default:
  1611         default:
  1117             {
  1612             {
  1118             break;
  1613             break;
  1119             }
  1614             }
  1120         }
  1615         }
       
  1616     
       
  1617     _AKNTRACE_FUNC_EXIT;
  1121     }
  1618     }
  1122 
  1619 
  1123 
  1620 
  1124 // ---------------------------------------------------------------------------
  1621 // ---------------------------------------------------------------------------
  1125 // From base class CCoeControl.
  1622 // From base class CCoeControl.
  1161 // Handles LSK keypress.
  1658 // Handles LSK keypress.
  1162 // ---------------------------------------------------------------------------
  1659 // ---------------------------------------------------------------------------
  1163 //
  1660 //
  1164 void CAknKeyLockControl::LeftSoftKeyPressed()
  1661 void CAknKeyLockControl::LeftSoftKeyPressed()
  1165     {
  1662     {
  1166     TRACES( RDebug::Print(_L("(KeyGuard)CAknKeyLockControl::LeftSoftKeyPressed")); )
  1663     _AKNTRACE_FUNC_ENTER; 
  1167 
  1664     
  1168     // Check that the confirmation note exists, as it's not created on
  1665     // Check that the confirmation note exists, as it's not created on
  1169     // startup if touch layout is in use. In emulator this might cause
  1666     // startup if touch layout is in use. In emulator this might cause
  1170     // a problem, as layout can be changed to a non-touch one, and
  1667     // a problem, as layout can be changed to a non-touch one, and
  1171     // the confirmation notes do not exist.
  1668     // the confirmation notes do not exist.
  1172     if ( iConfirmationNote )
  1669     if ( iConfirmationNote )
  1185                                          CAknNoteDialog::EConfirmationTone );
  1682                                          CAknNoteDialog::EConfirmationTone );
  1186             }
  1683             }
  1187         SendMessageToSysAp( EEikKeyLockLightsOnRequest );
  1684         SendMessageToSysAp( EEikKeyLockLightsOnRequest );
  1188         iUnlockConfirmation = ETrue;
  1685         iUnlockConfirmation = ETrue;
  1189         }
  1686         }
       
  1687     
       
  1688     _AKNTRACE_FUNC_EXIT;
  1190     }
  1689     }
  1191 
  1690 
  1192 
  1691 
  1193 // ---------------------------------------------------------------------------
  1692 // ---------------------------------------------------------------------------
  1194 // From base class CCoeControl.
  1693 // From base class CCoeControl.
  1196 // ---------------------------------------------------------------------------
  1695 // ---------------------------------------------------------------------------
  1197 //
  1696 //
  1198 TKeyResponse CAknKeyLockControl::OfferKeyEventL( const TKeyEvent& aKeyEvent,
  1697 TKeyResponse CAknKeyLockControl::OfferKeyEventL( const TKeyEvent& aKeyEvent,
  1199                                                  TEventCode aType )
  1698                                                  TEventCode aType )
  1200     {
  1699     {
       
  1700     _AKNTRACE_FUNC_ENTER; 
       
  1701     
  1201     if ( AknLayoutUtils::PenEnabled() )
  1702     if ( AknLayoutUtils::PenEnabled() )
  1202         {
  1703         {
  1203         TRACES( RDebug::Print(_L("(KeyGuard)CAknKeyLockControl::OfferKeyEventL: PenEnabled"));)
  1704         _AKNTRACE("(KeyGuard)CAknKeyLockControl::OfferKeyEventL: PenEnabled");
  1204         if ( iAutolockEnabled )
  1705         if ( iAutolockEnabled )
  1205             { // The case when touch device is locked and so must be unlocked by hold switch.
  1706             { // The case when touch device is locked and so must be unlocked by hold switch.
  1206             TRACES( RDebug::Print(_L("(KeyGuard)CAknKeyLockControl::OfferKeyEventL: Autolock Enabled"));)
  1707             _AKNTRACE("(KeyGuard)CAknKeyLockControl::OfferKeyEventL: Autolock Enabled");
  1207             if ( aType == EEventKey && aKeyEvent.iCode == EKeyDeviceF )
  1708             if ( aType == EEventKey && aKeyEvent.iCode == EKeyDeviceF )
  1208                 {
  1709                 {
  1209                 TRACES( RDebug::Print(_L("(KeyGuard)CAknKeyLockControl::OfferKeyEventL: SysAp message"));)
  1710                 _AKNTRACE("(KeyGuard)CAknKeyLockControl::OfferKeyEventL: SysAp message");
  1210                 SendMessageToSysAp( EEikKeyLockLightsOnRequest );
  1711                 SendMessageToSysAp( EEikKeyLockLightsOnRequest );
  1211                 if ( iAutolockEnabled && !iKeylockApi )
  1712                 if ( iAutolockEnabled && !iKeylockApi )
  1212                     {
  1713                     {
  1213                     TApaTaskList tasklist( iCoeEnv->WsSession() );
  1714                     TApaTaskList tasklist( iCoeEnv->WsSession() );
  1214                     TApaTask autolocktask = tasklist.FindApp( KAutolockUid );
  1715                     TApaTask autolocktask = tasklist.FindApp( KAutolockUid );
  1220                         TKeyEvent keyEvent;
  1721                         TKeyEvent keyEvent;
  1221                         keyEvent.iCode = EKeyBell;
  1722                         keyEvent.iCode = EKeyBell;
  1222                         autolocktask.SendKey( keyEvent );
  1723                         autolocktask.SendKey( keyEvent );
  1223                         }
  1724                         }
  1224                     }
  1725                     }
  1225                 TRACES( RDebug::Print(_L("(KeyGuard)CAknKeyLockControl::OfferKeyEventL: return EKeyWasConsumed"));)
  1726                 _AKNTRACE_FUNC_EXIT;
  1226                 return EKeyWasConsumed;
  1727                 return EKeyWasConsumed;
  1227                 }
  1728                 }
  1228             }
  1729             }
  1229         }
  1730         }
  1230 
  1731 
  1425                aKeyEvent.iScanCode == EStdKeyRightShift ) )
  1926                aKeyEvent.iScanCode == EStdKeyRightShift ) )
  1426             {
  1927             {
  1427             ShowLockedNote();
  1928             ShowLockedNote();
  1428             }
  1929             }
  1429         }
  1930         }
  1430 
  1931     _AKNTRACE_FUNC_EXIT;
  1431     return EKeyWasConsumed;
  1932     return EKeyWasConsumed;
  1432     }
  1933     }
  1433 
  1934 
  1434 
  1935 
  1435 // ---------------------------------------------------------------------------
  1936 // ---------------------------------------------------------------------------
  1436 // Shows the "locked" note.
  1937 // Shows the "locked" note.
  1437 // ---------------------------------------------------------------------------
  1938 // ---------------------------------------------------------------------------
  1438 //
  1939 //
  1439 void CAknKeyLockControl::ShowLockedNote()
  1940 void CAknKeyLockControl::ShowLockedNote()
  1440     {
  1941     {
       
  1942     _AKNTRACE_FUNC_ENTER;
       
  1943     
  1441     if ( !iLockedNoteDisplayed )
  1944     if ( !iLockedNoteDisplayed )
  1442         {
  1945         {
  1443         DoShowLockedNote();
  1946         DoShowLockedNote();
  1444         }
  1947         }
       
  1948     
       
  1949     _AKNTRACE_FUNC_EXIT;
  1445     }
  1950     }
  1446 
  1951 
  1447 
  1952 
  1448 // ---------------------------------------------------------------------------
  1953 // ---------------------------------------------------------------------------
  1449 // Shows the "locked" note.
  1954 // Shows the "locked" note.
  1451 //
  1956 //
  1452 void CAknKeyLockControl::DoShowLockedNote()
  1957 void CAknKeyLockControl::DoShowLockedNote()
  1453     {
  1958     {
  1454     if ( !iAutolockEnabled )
  1959     if ( !iAutolockEnabled )
  1455         {
  1960         {
  1456         iLockedNote->ShowNote( KKeyLockDisplayLockedTimeout,
       
  1457                                CAknNoteDialog::ENoTone );
       
  1458         iLockedNoteDisplayed = ETrue;
       
  1459         }
  1961         }
  1460     }
  1962     }
  1461 
  1963 
  1462 
  1964 
  1463 // ---------------------------------------------------------------------------
  1965 // ---------------------------------------------------------------------------
  1464 // Brings the keylock notifier's CBA visible.
  1966 // Brings the keylock notifier's CBA visible.
  1465 // ---------------------------------------------------------------------------
  1967 // ---------------------------------------------------------------------------
  1466 //
  1968 //
  1467 void CAknKeyLockControl::ShowKeylockCba()
  1969 void CAknKeyLockControl::ShowKeylockCba()
  1468     {
  1970     {
       
  1971     _AKNTRACE_FUNC_ENTER;
       
  1972     
  1469     RDrawableWindow* cbaWindow =
  1973     RDrawableWindow* cbaWindow =
  1470         iKeyLockCba->ButtonGroup()->AsControl()->DrawableWindow();
  1974         iKeyLockCba->ButtonGroup()->AsControl()->DrawableWindow();
  1471     cbaWindow->SetFaded( EFalse, RWindowTreeNode::EFadeWindowOnly );
  1975     cbaWindow->SetFaded( EFalse, RWindowTreeNode::EFadeWindowOnly );
  1472     cbaWindow->SetOrdinalPosition( 0, 1 );
  1976     cbaWindow->SetOrdinalPosition( 0, 1 );
  1473     cbaWindow->SetNonFading( ETrue );
  1977     cbaWindow->SetNonFading( ETrue );
       
  1978     
       
  1979     _AKNTRACE_FUNC_EXIT;
  1474     }
  1980     }
  1475 
  1981 
  1476 
  1982 
  1477 // ---------------------------------------------------------------------------
  1983 // ---------------------------------------------------------------------------
  1478 // Sets the necessary HW keys captured.
  1984 // Sets the necessary HW keys captured.
  1479 // ---------------------------------------------------------------------------
  1985 // ---------------------------------------------------------------------------
  1480 //
  1986 //
  1481 void CAknKeyLockControl::CaptureSystemKeys()
  1987 void CAknKeyLockControl::CaptureSystemKeys()
  1482     {
  1988     {
       
  1989     _AKNTRACE_FUNC_ENTER;
       
  1990     
  1483     if ( !iKeysCaptured )
  1991     if ( !iKeysCaptured )
  1484         {
  1992         {
  1485         RWindowGroup& groupWin = iCoeEnv->RootWin();
  1993         RWindowGroup& groupWin = iCoeEnv->RootWin();
  1486 
  1994 
  1487         // Capture app key (disable application switching).
  1995         // Capture app key (disable application switching).
  1505 
  2013 
  1506         iHoldSwitch = 0;
  2014         iHoldSwitch = 0;
  1507 
  2015 
  1508         if ( AknLayoutUtils::PenEnabled() )
  2016         if ( AknLayoutUtils::PenEnabled() )
  1509             {
  2017             {
  1510             TRACES( RDebug::Print(_L("(KeyGuard)CAknKeyLockControl::CaptureSystemKeys PenEnabled"));)
  2018              _AKNTRACE("(KeyGuard)CAknKeyLockControl::CaptureSystemKeys PenEnabled");
  1511             if ( iAutolockEnabled )
  2019             if ( iAutolockEnabled )
  1512                 { //Capture Hold Switch
  2020                 { //Capture Hold Switch
  1513                 TRACES( RDebug::Print(_L("(KeyGuard)CAknKeyLockControl::CaptureSystemKeys iAutolockEnabled"));)
  2021              _AKNTRACE("(KeyGuard)CAknKeyLockControl::CaptureSystemKeys iAutolockEnabled");
  1514                 iHoldSwitch = groupWin.CaptureKey( EKeyDeviceF, 0, 0 );
  2022                 iHoldSwitch = groupWin.CaptureKey( EKeyDeviceF, 0, 0 );
  1515                 }
  2023                 }
  1516             }
  2024             }
  1517         iKeysCaptured = ETrue;
  2025         iKeysCaptured = ETrue;
  1518         }
  2026         }
       
  2027     
       
  2028     _AKNTRACE_FUNC_EXIT;
  1519     }
  2029     }
  1520 
  2030 
  1521 
  2031 
  1522 // ---------------------------------------------------------------------------
  2032 // ---------------------------------------------------------------------------
  1523 // Releases captured HW keys.
  2033 // Releases captured HW keys.
  1524 // ---------------------------------------------------------------------------
  2034 // ---------------------------------------------------------------------------
  1525 //
  2035 //
  1526 void CAknKeyLockControl::UnCaptureSystemKeys()
  2036 void CAknKeyLockControl::UnCaptureSystemKeys()
  1527     {
  2037     {
       
  2038     _AKNTRACE_FUNC_ENTER;
       
  2039     
  1528     if ( iKeysCaptured )
  2040     if ( iKeysCaptured )
  1529         {
  2041         {
  1530         RWindowGroup& groupWin = iCoeEnv->RootWin();
  2042         RWindowGroup& groupWin = iCoeEnv->RootWin();
  1531         groupWin.CancelCaptureKeyUpAndDowns( iAppKey );
  2043         groupWin.CancelCaptureKeyUpAndDowns( iAppKey );
  1532         groupWin.CancelCaptureKeyUpAndDowns( iPowerKey );
  2044         groupWin.CancelCaptureKeyUpAndDowns( iPowerKey );
  1543             groupWin.CancelCaptureKey( iHoldSwitch );
  2055             groupWin.CancelCaptureKey( iHoldSwitch );
  1544             }
  2056             }
  1545 
  2057 
  1546         iKeysCaptured = EFalse;
  2058         iKeysCaptured = EFalse;
  1547         }
  2059         }
       
  2060     
       
  2061     _AKNTRACE_FUNC_EXIT;
  1548     }
  2062     }
  1549 
  2063 
  1550 
  2064 
  1551 // ---------------------------------------------------------------------------
  2065 // ---------------------------------------------------------------------------
  1552 // From base class MAknEcsObserver.
  2066 // From base class MAknEcsObserver.
  1554 // ---------------------------------------------------------------------------
  2068 // ---------------------------------------------------------------------------
  1555 //
  2069 //
  1556 void CAknKeyLockControl::HandleEcsEvent( CAknEcsDetector* aEcsDetector,
  2070 void CAknKeyLockControl::HandleEcsEvent( CAknEcsDetector* aEcsDetector,
  1557                                          CAknEcsDetector::TState aState )
  2071                                          CAknEcsDetector::TState aState )
  1558     {
  2072     {
       
  2073     _AKNTRACE_FUNC_ENTER;
       
  2074     
  1559     switch ( aState )
  2075     switch ( aState )
  1560         {
  2076         {
  1561         case CAknEcsDetector::ECompleteMatchThenSendKey:
  2077         case CAknEcsDetector::ECompleteMatchThenSendKey:
  1562             {
  2078             {
  1563             // Do nothing since note will be removed on ECallAttempted event.
  2079             // Do nothing since note will be removed on ECallAttempted event.
  1564             break;
  2080             break;
  1565             }
  2081             }
  1566         case CAknEcsDetector::ECompleteMatch:
  2082         case CAknEcsDetector::ECompleteMatch:
       
  2083         case CAknEcsDetector::EServiceNumMatch:
  1567             {
  2084             {
  1568             iEcsNote->SetEmergencyNumber( aEcsDetector->CurrentMatch() );
  2085             iEcsNote->SetEmergencyNumber( aEcsDetector->CurrentMatch() );
  1569             iEcsNote->ShowNote( CAknNoteDialog::ENoTimeout,
  2086             iEcsNote->ShowNote( CAknNoteDialog::ENoTimeout,
  1570                                 CAknNoteDialog::ENoTone );
  2087                                 CAknNoteDialog::ENoTone );
  1571 
  2088 
  1597         default:
  2114         default:
  1598             {
  2115             {
  1599             break;
  2116             break;
  1600             }
  2117             }
  1601         }
  2118         }
       
  2119     
       
  2120     _AKNTRACE_FUNC_EXIT;
  1602     }
  2121     }
  1603 
  2122 
  1604 
  2123 
  1605 // ---------------------------------------------------------------------------
  2124 // ---------------------------------------------------------------------------
  1606 // Cancels the offer keylock note.
  2125 // Cancels the offer keylock note.
  1607 // ---------------------------------------------------------------------------
  2126 // ---------------------------------------------------------------------------
  1608 //
  2127 //
  1609 void CAknKeyLockControl::DoExitOfferKeylock()
  2128 void CAknKeyLockControl::DoExitOfferKeylock()
  1610     {
  2129     {
       
  2130     _AKNTRACE_FUNC_ENTER;
       
  2131     
  1611     iOfferLockNote->CancelNote();
  2132     iOfferLockNote->CancelNote();
       
  2133     
       
  2134     _AKNTRACE_FUNC_EXIT;
  1612     }
  2135     }
  1613 
  2136 
  1614 
  2137 
  1615 // ---------------------------------------------------------------------------
  2138 // ---------------------------------------------------------------------------
  1616 // Cancels the offer keylock note.
  2139 // Cancels the offer keylock note.
  1617 // ---------------------------------------------------------------------------
  2140 // ---------------------------------------------------------------------------
  1618 //
  2141 //
  1619 void CAknKeyLockControl::OfferTimerExpired()
  2142 void CAknKeyLockControl::OfferTimerExpired()
  1620     {
  2143     {
       
  2144     _AKNTRACE_FUNC_ENTER;
       
  2145     
  1621     DoExitOfferKeylock();
  2146     DoExitOfferKeylock();
       
  2147     
       
  2148     _AKNTRACE_FUNC_EXIT;
  1622     }
  2149     }
  1623 
  2150 
  1624 
  2151 
  1625 // ---------------------------------------------------------------------------
  2152 // ---------------------------------------------------------------------------
  1626 // Sets the autolock state.
  2153 // Sets the autolock state.
  1627 // ---------------------------------------------------------------------------
  2154 // ---------------------------------------------------------------------------
  1628 //
  2155 //
  1629 void CAknKeyLockControl::AutolockEnabled( TBool aAutoLockOn )
  2156 void CAknKeyLockControl::AutolockEnabled( TBool aAutoLockOn )
  1630     {
  2157     {
       
  2158     _AKNTRACE_FUNC_ENTER;
       
  2159     
  1631     iAutolockEnabled = aAutoLockOn;
  2160     iAutolockEnabled = aAutoLockOn;
       
  2161     
       
  2162     _AKNTRACE_FUNC_EXIT;
  1632     }
  2163     }
  1633 
  2164 
  1634 
  2165 
  1635 // ---------------------------------------------------------------------------
  2166 // ---------------------------------------------------------------------------
  1636 // For CDMA implementation.
  2167 // For CDMA implementation.
  1654 // For capturing pointer events when key lock is enabled.
  2185 // For capturing pointer events when key lock is enabled.
  1655 // ---------------------------------------------------------------------------
  2186 // ---------------------------------------------------------------------------
  1656 //
  2187 //
  1657 void CAknKeyLockControl::CapturePointerEvents()
  2188 void CAknKeyLockControl::CapturePointerEvents()
  1658     {
  2189     {
       
  2190     _AKNTRACE_FUNC_ENTER;
       
  2191     
  1659     if ( AknLayoutUtils::PenEnabled() )
  2192     if ( AknLayoutUtils::PenEnabled() )
  1660         {
  2193         {
  1661         Window().SetPointerCapture( RWindowBase::TCaptureDragDrop );
  2194         Window().SetPointerCapture( RWindowBase::TCaptureDragDrop );
  1662         Window().ClaimPointerGrab( ETrue );
  2195         Window().ClaimPointerGrab( ETrue );
  1663         }
  2196         }
       
  2197     
       
  2198     _AKNTRACE_FUNC_EXIT;
  1664     }
  2199     }
  1665 
  2200 
  1666 
  2201 
  1667 // ---------------------------------------------------------------------------
  2202 // ---------------------------------------------------------------------------
  1668 // For releasing pointer events when key lock is disabled.
  2203 // For releasing pointer events when key lock is disabled.
  1669 // ---------------------------------------------------------------------------
  2204 // ---------------------------------------------------------------------------
  1670 //
  2205 //
  1671 void CAknKeyLockControl::UnCapturePointerEvents()
  2206 void CAknKeyLockControl::UnCapturePointerEvents()
  1672     {
  2207     {
       
  2208     _AKNTRACE_FUNC_ENTER;
       
  2209     
  1673     if ( AknLayoutUtils::PenEnabled() )
  2210     if ( AknLayoutUtils::PenEnabled() )
  1674         {
  2211         {
  1675         Window().SetPointerCapture( RWindowBase::TCaptureDisabled );
  2212         Window().SetPointerCapture( RWindowBase::TCaptureDisabled );
  1676         Window().ClaimPointerGrab( EFalse );
  2213         Window().ClaimPointerGrab( EFalse );
  1677         }
  2214         }
       
  2215     
       
  2216     _AKNTRACE_FUNC_EXIT;
       
  2217     }
       
  2218 
       
  2219 TBool CAknKeyLockControl::HasSliderKey()
       
  2220     {
       
  2221     _AKNTRACE_FUNC_ENTER;
       
  2222     
       
  2223     TBool hasSlider(iHardwareSupport != EKeyguardDefaultHardware);
       
  2224     if( FeatureManager::FeatureSupported( KFeatureIdFfPowerKeyAsKeyguard ) )
       
  2225         {
       
  2226         hasSlider = ETrue;  // the only purpose is to display empty sotkeys
       
  2227         }
       
  2228     
       
  2229     _AKNTRACE( "hasSlider:%d",hasSlider);
       
  2230     _AKNTRACE_FUNC_EXIT;
       
  2231     
       
  2232     return hasSlider;
  1678     }
  2233     }
  1679 
  2234 
  1680 
  2235 
  1681 // ===========================================================================
  2236 // ===========================================================================
  1682 // class CAknKeyLockNotifierSubject
  2237 // class CAknKeyLockNotifierSubject
  1786 // Starts the keylock notifier synchronously.
  2341 // Starts the keylock notifier synchronously.
  1787 // ---------------------------------------------------------------------------
  2342 // ---------------------------------------------------------------------------
  1788 //
  2343 //
  1789 TPtrC8 CAknKeyLockNotifierSubject::StartL( const TDesC8& aBuffer )
  2344 TPtrC8 CAknKeyLockNotifierSubject::StartL( const TDesC8& aBuffer )
  1790     {
  2345     {
       
  2346     _AKNTRACE_FUNC_ENTER; 
       
  2347     
  1791     SAknNotifierPackage<SAknKeyLockNotifierParams>* params =
  2348     SAknNotifierPackage<SAknKeyLockNotifierParams>* params =
  1792         ( SAknNotifierPackage<SAknKeyLockNotifierParams>*)aBuffer.Ptr();
  2349         ( SAknNotifierPackage<SAknKeyLockNotifierParams>*)aBuffer.Ptr();
  1793 
  2350 
  1794     if ( aBuffer.Length() < 0 ||
  2351     if ( aBuffer.Length() < 0 ||
  1795          (TUint)aBuffer.Length() < sizeof(SAknNotifierPackage<SAknKeyLockNotifierParams>) ||
  2352          (TUint)aBuffer.Length() < sizeof(SAknNotifierPackage<SAknKeyLockNotifierParams>) ||
  1796          params->iSignature != KAKNNOTIFIERSIGNATURE )
  2353          params->iSignature != KAKNNOTIFIERSIGNATURE )
  1797         {
  2354         {
  1798         User::Leave( KErrArgument );
  2355         User::Leave( KErrArgument );
  1799         }
  2356         }
  1800 
  2357 
       
  2358     _AKNTRACE( "params->iParamData.iReason:%d",params->iParamData.iReason);
       
  2359         
  1801     switch ( params->iParamData.iReason )
  2360     switch ( params->iParamData.iReason )
  1802         {
  2361         {
  1803         case ELockEnabled:
  2362         case ELockEnabled:
  1804         case ELockDisabled:
  2363         case ELockDisabled:
  1805         case EAllowNotifications:
  2364         case EAllowNotifications:
  1821             {
  2380             {
  1822             break;
  2381             break;
  1823             }
  2382             }
  1824         }
  2383         }
  1825 
  2384 
       
  2385     _AKNTRACE_FUNC_EXIT;
       
  2386     
  1826     return iRetPckg;
  2387     return iRetPckg;
  1827     }
  2388     }
  1828 
  2389 
  1829 
  2390 
  1830 // ---------------------------------------------------------------------------
  2391 // ---------------------------------------------------------------------------
  1834 //
  2395 //
  1835 void CAknKeyLockNotifierSubject::StartL( const TDesC8& aBuffer,
  2396 void CAknKeyLockNotifierSubject::StartL( const TDesC8& aBuffer,
  1836                                          TInt /*aReplySlot*/,
  2397                                          TInt /*aReplySlot*/,
  1837                                          const RMessagePtr2& aMessage )
  2398                                          const RMessagePtr2& aMessage )
  1838     {
  2399     {
       
  2400     _AKNTRACE_FUNC_ENTER; 
       
  2401     
  1839     SAknNotifierPackage<SAknKeyLockNotifierParams>* params =
  2402     SAknNotifierPackage<SAknKeyLockNotifierParams>* params =
  1840         ( SAknNotifierPackage<SAknKeyLockNotifierParams>*)aBuffer.Ptr();
  2403         ( SAknNotifierPackage<SAknKeyLockNotifierParams>*)aBuffer.Ptr();
  1841 
  2404 
  1842     if ( aBuffer.Length() < 0 ||
  2405     if ( aBuffer.Length() < 0 ||
  1843          (TUint)aBuffer.Length() < sizeof(SAknNotifierPackage<SAknKeyLockNotifierParams>) ||
  2406          (TUint)aBuffer.Length() < sizeof(SAknNotifierPackage<SAknKeyLockNotifierParams>) ||
  1844          params->iSignature != KAKNNOTIFIERSIGNATURE )
  2407          params->iSignature != KAKNNOTIFIERSIGNATURE )
  1845         {
  2408         {
  1846         User::Leave( KErrArgument );
  2409         User::Leave( KErrArgument );
  1847         }
  2410         }
  1848 
  2411 
       
  2412     _AKNTRACE( "params->iParamData.iReason:%d",params->iParamData.iReason);
       
  2413     
  1849     switch ( params->iParamData.iReason )
  2414     switch ( params->iParamData.iReason )
  1850         {
  2415         {
  1851         case ELockEnabled:
  2416         case ELockEnabled:
  1852             {
  2417             {
  1853             if ( !iKeyLockControl->iAutolockEnabled )
  2418             if ( !iKeyLockControl->iAutolockEnabled )
  1927             {
  2492             {
  1928             break;
  2493             break;
  1929             }
  2494             }
  1930         };
  2495         };
  1931 
  2496 
       
  2497     _AKNTRACE_FUNC_EXIT;
       
  2498     
  1932     aMessage.Complete( KErrNone );
  2499     aMessage.Complete( KErrNone );
  1933     }
  2500     }
  1934 
  2501 
  1935 
  2502 
  1936 // ---------------------------------------------------------------------------
  2503 // ---------------------------------------------------------------------------
  1981 // Disables the keylock.
  2548 // Disables the keylock.
  1982 // ---------------------------------------------------------------------------
  2549 // ---------------------------------------------------------------------------
  1983 //
  2550 //
  1984 void CAknKeyLockNotifierSubject::UnlockKeys()
  2551 void CAknKeyLockNotifierSubject::UnlockKeys()
  1985     {
  2552     {
       
  2553     _AKNTRACE_FUNC_ENTER; 
       
  2554     
  1986     if ( IsKeyLockEnabled() )
  2555     if ( IsKeyLockEnabled() )
  1987         {
  2556         {
  1988         iKeyLockControl->DisableKeylock();
  2557         iKeyLockControl->DisableKeylock();
  1989         }
  2558         }
       
  2559     
       
  2560     _AKNTRACE_FUNC_EXIT;
  1990     }
  2561     }
  1991 
  2562 
  1992 
  2563 
  1993 // ---------------------------------------------------------------------------
  2564 // ---------------------------------------------------------------------------
  1994 // From base class MAknKeyLockController.
  2565 // From base class MAknKeyLockController.
  1995 // Enables the keylock.
  2566 // Enables the keylock.
  1996 // ---------------------------------------------------------------------------
  2567 // ---------------------------------------------------------------------------
  1997 //
  2568 //
  1998 void CAknKeyLockNotifierSubject::LockKeys( TBool aAutoLockOn )
  2569 void CAknKeyLockNotifierSubject::LockKeys( TBool aAutoLockOn )
  1999     {
  2570     {
       
  2571     _AKNTRACE_FUNC_ENTER; 
       
  2572     _AKNTRACE( "aAutoLockOn:%d",aAutoLockOn);
       
  2573     
  2000     // We'll have to disable keylock if we are changing autolock status.
  2574     // We'll have to disable keylock if we are changing autolock status.
  2001     if ( IsKeyLockEnabled() && aAutoLockOn != iKeyLockControl->iAutolockEnabled )
  2575     if ( IsKeyLockEnabled() && aAutoLockOn != iKeyLockControl->iAutolockEnabled )
  2002         {
  2576         {
  2003         iKeyLockControl->DisableKeylock();
  2577         iKeyLockControl->DisableKeylock(EFalse);
  2004         }
  2578         }
  2005 
  2579 
  2006     if ( !IsKeyLockEnabled() )
  2580     if ( !IsKeyLockEnabled() )
  2007         {
  2581         {
  2008         iKeyLockControl->AutolockEnabled( aAutoLockOn );
  2582         iKeyLockControl->AutolockEnabled( aAutoLockOn );
  2009         iKeyLockControl->EnableKeylock();
  2583         iKeyLockControl->EnableKeylock(ETrue, EFalse);
  2010         }
  2584         }
       
  2585     
       
  2586     _AKNTRACE_FUNC_EXIT;
  2011     }
  2587     }
  2012 
  2588 
  2013 
  2589 
  2014 // ---------------------------------------------------------------------------
  2590 // ---------------------------------------------------------------------------
  2015 // From base class MAknKeyLockController.
  2591 // From base class MAknKeyLockController.
  2016 // Adds a keylock status change observer.
  2592 // Adds a keylock status change observer.
  2017 // ---------------------------------------------------------------------------
  2593 // ---------------------------------------------------------------------------
  2018 //
  2594 //
  2019 void CAknKeyLockNotifierSubject::AddObserverL( MAknKeyLockObserver* aObserver )
  2595 void CAknKeyLockNotifierSubject::AddObserverL( MAknKeyLockObserver* aObserver )
  2020     {
  2596     {
       
  2597     _AKNTRACE_FUNC_ENTER;
       
  2598     
  2021 #if defined(_DEBUG)
  2599 #if defined(_DEBUG)
  2022     TInt count = iObserverList->Count();
  2600     TInt count = iObserverList->Count();
  2023     for ( TInt index = 0; index < count; index++ )
  2601     for ( TInt index = 0; index < count; index++ )
  2024         {
  2602         {
  2025         if ( ((*iObserverList)[index]) == aObserver )
  2603         if ( ((*iObserverList)[index]) == aObserver )
  2030 #endif
  2608 #endif
  2031     iObserverList->AppendL( aObserver );
  2609     iObserverList->AppendL( aObserver );
  2032 
  2610 
  2033     // Make sure that the observer isn't obscuring the keylock CBA
  2611     // Make sure that the observer isn't obscuring the keylock CBA
  2034     ShowKeylockCba();
  2612     ShowKeylockCba();
       
  2613     
       
  2614     _AKNTRACE_FUNC_EXIT;
  2035     }
  2615     }
  2036 
  2616 
  2037 
  2617 
  2038 // ---------------------------------------------------------------------------
  2618 // ---------------------------------------------------------------------------
  2039 // From base class MAknKeyLockController.
  2619 // From base class MAknKeyLockController.
  2040 // Removes a keylock status change observer.
  2620 // Removes a keylock status change observer.
  2041 // ---------------------------------------------------------------------------
  2621 // ---------------------------------------------------------------------------
  2042 //
  2622 //
  2043 void CAknKeyLockNotifierSubject::RemoveObserver( MAknKeyLockObserver* aObserver )
  2623 void CAknKeyLockNotifierSubject::RemoveObserver( MAknKeyLockObserver* aObserver )
  2044     {
  2624     {
       
  2625     _AKNTRACE_FUNC_ENTER;
       
  2626     
  2045     TInt count = iObserverList->Count();
  2627     TInt count = iObserverList->Count();
  2046     for ( TInt index = 0; index < count; index++ )
  2628     for ( TInt index = 0; index < count; index++ )
  2047         {
  2629         {
  2048         if ( ((*iObserverList)[index]) == aObserver )
  2630         if ( ((*iObserverList)[index]) == aObserver )
  2049             {
  2631             {
  2052             }
  2634             }
  2053         }
  2635         }
  2054 #if defined(_DEBUG)
  2636 #if defined(_DEBUG)
  2055     Panic( EAknPanicKeyLockObserverNotFound );
  2637     Panic( EAknPanicKeyLockObserverNotFound );
  2056 #endif
  2638 #endif
       
  2639     
       
  2640     _AKNTRACE_FUNC_EXIT;
  2057     }
  2641     }
  2058 
  2642 
  2059 
  2643 
  2060 // ---------------------------------------------------------------------------
  2644 // ---------------------------------------------------------------------------
  2061 // Notifies the observers of a keylock status change.
  2645 // Notifies the observers of a keylock status change.
  2062 // ---------------------------------------------------------------------------
  2646 // ---------------------------------------------------------------------------
  2063 //
  2647 //
  2064 void CAknKeyLockNotifierSubject::NotifyStatusChange( TKeyLockStatus aStatus )
  2648 void CAknKeyLockNotifierSubject::NotifyStatusChange( TKeyLockStatus aStatus )
  2065     {
  2649     {
       
  2650     _AKNTRACE_FUNC_ENTER;
       
  2651     _AKNTRACE( "aStatus:%d",aStatus);
       
  2652     
  2066     TInt count = iObserverList->Count();
  2653     TInt count = iObserverList->Count();
  2067     for ( TInt index = count - 1; index >= 0; index-- )
  2654     for ( TInt index = count - 1; index >= 0; index-- )
  2068         {
  2655         {
  2069         ((*iObserverList)[index])->KeyLockStatusChange( aStatus );
  2656         ((*iObserverList)[index])->KeyLockStatusChange( aStatus );
  2070         }
  2657         }
       
  2658     
       
  2659     _AKNTRACE_FUNC_EXIT;
  2071     }
  2660     }
  2072 
  2661 
  2073 
  2662 
  2074 // ---------------------------------------------------------------------------
  2663 // ---------------------------------------------------------------------------
  2075 // Brings the keylock notifier's CBA visible.
  2664 // Brings the keylock notifier's CBA visible.
  2076 // ---------------------------------------------------------------------------
  2665 // ---------------------------------------------------------------------------
  2077 //
  2666 //
  2078 void CAknKeyLockNotifierSubject::ShowKeylockCba()
  2667 void CAknKeyLockNotifierSubject::ShowKeylockCba()
  2079     {
  2668     {
       
  2669     _AKNTRACE_FUNC_ENTER;
       
  2670     
  2080     if ( IsKeyLockEnabled() )
  2671     if ( IsKeyLockEnabled() )
  2081         {
  2672         {
  2082         iKeyLockControl->ShowKeylockCba();
  2673         iKeyLockControl->ShowKeylockCba();
  2083         }
  2674         }
       
  2675     
       
  2676     _AKNTRACE_FUNC_EXIT;
  2084     }
  2677     }
  2085 
  2678 
  2086 
  2679 
  2087 // ---------------------------------------------------------------------------
  2680 // ---------------------------------------------------------------------------
  2088 // Enables the keylock.
  2681 // Enables the keylock.
  2089 // ---------------------------------------------------------------------------
  2682 // ---------------------------------------------------------------------------
  2090 //
  2683 //
  2091 void CAknKeyLockNotifierSubject::DoEnableKeyLock()
  2684 void CAknKeyLockNotifierSubject::DoEnableKeyLock()
  2092     {
  2685     {
       
  2686     _AKNTRACE_FUNC_ENTER;
       
  2687     
  2093     if ( !IsKeyLockEnabled() )
  2688     if ( !IsKeyLockEnabled() )
  2094         {
  2689         {
  2095         iKeyLockControl->EnableKeylock();
  2690         iKeyLockControl->EnableKeylock();
  2096         }
  2691         }
       
  2692     
       
  2693     _AKNTRACE_FUNC_EXIT;
  2097     }
  2694     }
  2098 
  2695 
  2099 
  2696 
  2100 // ---------------------------------------------------------------------------
  2697 // ---------------------------------------------------------------------------
  2101 // Disables the keylock if active.
  2698 // Disables the keylock if active.
  2102 // ---------------------------------------------------------------------------
  2699 // ---------------------------------------------------------------------------
  2103 //
  2700 //
  2104 void CAknKeyLockNotifierSubject::DoDisableKeyLock()
  2701 void CAknKeyLockNotifierSubject::DoDisableKeyLock()
  2105     {
  2702     {
       
  2703     _AKNTRACE_FUNC_ENTER;
       
  2704     
  2106     if ( IsKeyLockEnabled() )
  2705     if ( IsKeyLockEnabled() )
  2107         {
  2706         {
  2108         iKeyLockControl->DisableKeylock();
  2707         iKeyLockControl->DisableKeylock();
  2109         // Attempt to display KeyActive note.
  2708         // Attempt to display KeyActive note.
  2110         iKeyLockControl->DisplayKeyActiveNote();
  2709         iKeyLockControl->DisplayKeyActiveNote();
  2112     else if ( iKeyLockControl->iOfferLockEnabled )
  2711     else if ( iKeyLockControl->iOfferLockEnabled )
  2113         {
  2712         {
  2114         // Remove the offer key lock CBA.
  2713         // Remove the offer key lock CBA.
  2115         iKeyLockControl->OfferTimerExpired();
  2714         iKeyLockControl->OfferTimerExpired();
  2116         }
  2715         }
       
  2716     
       
  2717     _AKNTRACE_FUNC_EXIT;
  2117     }
  2718     }
  2118 
  2719 
  2119 
  2720 
  2120 // ---------------------------------------------------------------------------
  2721 // ---------------------------------------------------------------------------
  2121 // Displays the offer keylock note.
  2722 // Displays the offer keylock note.
  2122 // ---------------------------------------------------------------------------
  2723 // ---------------------------------------------------------------------------
  2123 //
  2724 //
  2124 void CAknKeyLockNotifierSubject::DoOfferKeyLock()
  2725 void CAknKeyLockNotifierSubject::DoOfferKeyLock()
  2125     {
  2726     {
       
  2727     _AKNTRACE_FUNC_ENTER;
       
  2728     
  2126     if ( !IsKeyLockEnabled() )
  2729     if ( !IsKeyLockEnabled() )
  2127         {
  2730         {
  2128         NotifyStatusChange( EKeyLockOffered );
  2731         NotifyStatusChange( EKeyLockOffered );
  2129         iKeyLockControl->OfferKeylock();
  2732         iKeyLockControl->OfferKeylock();
  2130         }
  2733         }
  2131     }
  2734     
       
  2735     _AKNTRACE_FUNC_EXIT;
       
  2736     }