htiui/HtiServicePlugins/HtiKeyEventServicePlugin/inc/KeyEventHandler.h
changeset 0 d6fe6244b863
child 3 2703485a934c
equal deleted inserted replaced
-1:000000000000 0:d6fe6244b863
       
     1 /*
       
     2 * Copyright (c) 2009 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:  Functional implentation of key event service.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CKEYEVENTHANDLER_H
       
    20 #define CKEYEVENTHANDLER_H
       
    21 
       
    22 
       
    23 // INCLUDES
       
    24 #include <HTIServicePluginInterface.h>
       
    25 #include <w32std.h>
       
    26 
       
    27 // CONSTANTS
       
    28 
       
    29 // CLASS DECLARATION
       
    30 
       
    31 /**
       
    32 *  Functional implentation of key event service.
       
    33 */
       
    34 class CKeyEventHandler : public CActive
       
    35     {
       
    36 public:
       
    37 
       
    38     static CKeyEventHandler* NewL();
       
    39 
       
    40     // Interface implementation
       
    41     void ProcessMessageL( const TDesC8& aMessage,
       
    42         THtiMessagePriority aPriority );
       
    43 
       
    44     virtual ~CKeyEventHandler();
       
    45 
       
    46     void SetDispatcher( MHtiDispatcher* aDispatcher );
       
    47 
       
    48     enum TError
       
    49         {
       
    50         EMissingCommand          = 0x01,
       
    51         EUnrecognizedCommand     = 0x02,
       
    52         ENotReadyCommand         = 0x03,
       
    53         EInvalidScancode         = 0x80,
       
    54         EEmptyUnicodeCharArray   = 0x90,
       
    55         EInvalidUnicodeCharArray = 0x91
       
    56         };
       
    57 
       
    58     enum TCommand
       
    59         {
       
    60         EPressKey         = 0x01,
       
    61         EKeyDown          = 0x02,
       
    62         EKeyUp            = 0x03,
       
    63         ETypeText         = 0x04,
       
    64         ELongKeyPress     = 0x05,
       
    65         ETypeTextPassword = 0x06,
       
    66         EPressKeySequence = 0x07,
       
    67         EResultOk = 0xFF // only for response message
       
    68         };
       
    69 
       
    70 protected:
       
    71 
       
    72     void RunL();
       
    73     TInt RunError(TInt aError);
       
    74     void DoCancel();
       
    75 
       
    76 private:
       
    77 
       
    78     CKeyEventHandler();
       
    79     void ConstructL();
       
    80 
       
    81 private: // helpers
       
    82 
       
    83     void HandleTypeTextFuncL( const TDesC8& aUnicodeChars );
       
    84     void HandleKeyboardFuncL( const TDesC8& aData );
       
    85     void HandleLongKeyPressFuncL( const TDesC8& aData );
       
    86     void HandlePressKeySequenceFuncL( const TDesC8& aData );
       
    87 
       
    88     void SendOkMsgL();
       
    89     void SendErrorMessageL( TInt aError, const TDesC8& aDescription );
       
    90 
       
    91     void TypeTextWithDelay( TInt aNextIndex );
       
    92     void SimulateKeyEventL( const TDesC8& aUnicodeChars, TInt aIndex );
       
    93     void PressKeySequenceKeyL();
       
    94 
       
    95     void KeyUp( TUint aCode );
       
    96     void KeyDown( TUint aCode );
       
    97 
       
    98 private:
       
    99 
       
   100     RWsSession iWsSession;
       
   101     MHtiDispatcher* iDispatcher; // referenced
       
   102 
       
   103     // Typetext specialities:
       
   104     RTimer  iTimer;
       
   105     TInt    iFocusedWindowGroup;
       
   106     HBufC8* iUnicodeChars;
       
   107     TInt    iUnicodeCharIndex;
       
   108 
       
   109     TBool                           iReady;
       
   110     TUint8                          iCommand;
       
   111     TUint                           iHoldingScanCode;
       
   112     TTimeIntervalMicroSeconds32     iKeySequenceHoldTime;
       
   113     TTimeIntervalMicroSeconds32     iKeySequenceInterval;
       
   114     TBool                           iHoldingKey;
       
   115     };
       
   116 
       
   117 #endif // CKEYEVENTHANDLER_H