idlefw/plugins/wsplugin/src/sindlaunchhandler.cpp
branchRCL_3
changeset 9 d0529222e3f0
parent 4 1a2a00e78665
child 10 5ef93ea513cb
child 18 bd874ee5e5e2
equal deleted inserted replaced
4:1a2a00e78665 9:d0529222e3f0
     1 /*
       
     2 * Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  SIND app launch handler for Active Idle WS Plug-in.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "sindlaunchhandler.h"
       
    20 #include "keyhandlertimer.h"
       
    21 #include "uistate.h"
       
    22 #include <e32property.h>
       
    23 #include <e32event.h>
       
    24 #include <e32keys.h>
       
    25 #include <activeidle2internalpskeys.h>
       
    26 
       
    27 //#define AI_ENABLE_RD_LOGGING
       
    28 #define AI_RD_LOG_TO_DEBUG_OUTPUT
       
    29 
       
    30 #include "debug.h"
       
    31 
       
    32 namespace AiWsPlugin {
       
    33 
       
    34 
       
    35 CSINDLaunchHandler::CSINDLaunchHandler()
       
    36     {
       
    37     }
       
    38     
       
    39 void CSINDLaunchHandler::ConstructL()
       
    40     {
       
    41     // Read capability: ReadDeviceData.
       
    42     _LIT_SECURITY_POLICY_C1( KReadDevicePolicy, ECapabilityReadDeviceData );
       
    43     // Write capability: WriteDeviceData.
       
    44     _LIT_SECURITY_POLICY_C1( KWriteDevicePolicy, ECapabilityWriteDeviceData );
       
    45 
       
    46     // Initialize Shortcut Plug-in command API
       
    47     RProperty::Define( 
       
    48     	KUidSystemCategory,
       
    49     	KPSUidShortcutCmd,  
       
    50       	RProperty::EText,
       
    51         KReadDevicePolicy,
       
    52         KWriteDevicePolicy 
       
    53         );
       
    54         
       
    55     iTimer = CKeyHandlerTimer::NewL( this );
       
    56     
       
    57     iSINDKeyDown = EFalse;
       
    58     }
       
    59 
       
    60 CSINDLaunchHandler* CSINDLaunchHandler::NewLC()
       
    61     {
       
    62     CSINDLaunchHandler* self = new(ELeave) CSINDLaunchHandler;
       
    63     CleanupStack::PushL( self );
       
    64     self->ConstructL();
       
    65     return self;
       
    66     }
       
    67     
       
    68 CSINDLaunchHandler::~CSINDLaunchHandler()
       
    69     {
       
    70     delete iTimer;
       
    71     }
       
    72 
       
    73 void CSINDLaunchHandler::SetUiStateQuery( MUiState& aUiState )
       
    74     {
       
    75     iUiState = &aUiState;
       
    76     }
       
    77     
       
    78 void CSINDLaunchHandler::FocusChanged( TBool /*aState*/ )
       
    79     {
       
    80     // Focus status is queried from iUiState
       
    81     }
       
    82     
       
    83 TBool CSINDLaunchHandler::OfferRawEvent(const TRawEvent& aRawEvent)
       
    84     {
       
    85     switch( aRawEvent.Type() )
       
    86         {
       
    87         case TRawEvent::EKeyDown:
       
    88             {
       
    89             if ( iUiState->HasFocus() && aRawEvent.ScanCode() == EStdKeyDevice1 )
       
    90         		{		
       
    91 				__PRINTS( "XAI: CSINDLaunchHandler: SIND key down, start timer");
       
    92 				const TTimeIntervalMicroSeconds32 KLongKeyPress(600000);
       
    93 				iTimer->Cancel();
       
    94 				iTimer->After(KLongKeyPress);
       
    95                 iSINDLaunched = EFalse;
       
    96                 iSINDKeyDown = ETrue;                
       
    97         		}        		
       
    98             else if( iUiState->HasFocus() && iSINDKeyDown )
       
    99                 {
       
   100                 __PRINTS( "XAI: CSINDLaunchHandler: SIND key down, other key pressed, cancel timer");
       
   101                 iTimer->Cancel();
       
   102                 SkipVoiceDial();
       
   103                 }
       
   104             break;
       
   105             }
       
   106         case TRawEvent::EKeyUp:
       
   107             {
       
   108             if ( iUiState->HasFocus() && aRawEvent.ScanCode() == EStdKeyDevice1 && !iSINDLaunched && iTimer->IsActive() )
       
   109                 {                
       
   110                 __PRINTS( "XAI: SIND key up, cancel timer");
       
   111                 iTimer->Cancel();
       
   112                 SkipVoiceDial();
       
   113                 }
       
   114             break;
       
   115             }
       
   116         }
       
   117     return EFalse;
       
   118     }
       
   119 
       
   120 void CSINDLaunchHandler::SkipVoiceDial()
       
   121     {
       
   122     __PRINTS( "XAI: CSINDLaunchHandler::SkipVoiceDial()");
       
   123     // Handle skip scenario only if voice dial ui hasn't been launched
       
   124     if( !iSINDLaunched )
       
   125         {
       
   126         RProperty::Set(
       
   127 	    	KUidSystemCategory, 
       
   128 		    KPSUidShortcutCmd,
       
   129 		    KAiPSSkipNameDialer );  
       
   130         }
       
   131     iSINDKeyDown = EFalse; 
       
   132     }
       
   133     
       
   134 void CSINDLaunchHandler::TimerDone()
       
   135     {
       
   136     __PRINTS( "XAI: CSINDLaunchHandler::TimerDone()");
       
   137     __PRINTS( "XAI: Start Voice Dial UI");
       
   138     RProperty::Set(
       
   139 		KUidSystemCategory, 
       
   140 		KPSUidShortcutCmd,
       
   141 		KAiPSLaunchNameDialer );    		
       
   142     iSINDLaunched = ETrue;
       
   143     iSINDKeyDown = EFalse; 
       
   144     }    
       
   145 
       
   146 } // namespace AiWsPlugin