|         |      1 /* | 
|         |      2 * Copyright (c) 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:  Lock App internal utils | 
|         |     15  * | 
|         |     16 */ | 
|         |     17  | 
|         |     18  | 
|         |     19 #include <e32base.h> | 
|         |     20 #include <coemain.h> | 
|         |     21 #include <apgwgnam.h> | 
|         |     22 #include "lockapputils.h" | 
|         |     23  | 
|         |     24 #define KSysApUid TUid::Uid(0x100058F3) | 
|         |     25 #define KPhoneAppUid TUid::Uid(0x100058B3) | 
|         |     26  | 
|         |     27 // --------------------------------------------------------------------------- | 
|         |     28 // Queries bits in aStatusMask specified by the aQueryMask | 
|         |     29 // --------------------------------------------------------------------------- | 
|         |     30 TBool IsBitFieldSet( TUint aStatusMask, TUint aQueryMask ) | 
|         |     31     { | 
|         |     32     return (aStatusMask & aQueryMask); | 
|         |     33     } | 
|         |     34  | 
|         |     35 // --------------------------------------------------------------------------- | 
|         |     36 // Sets bits in aResultMask specified by the aSetMask | 
|         |     37 // --------------------------------------------------------------------------- | 
|         |     38 void SetBitField( TUint &aResultMask, TUint aSetMask, TBool aSet ) | 
|         |     39     { | 
|         |     40     if ( aSet ) | 
|         |     41         { | 
|         |     42         aResultMask = aResultMask | aSetMask; | 
|         |     43         } | 
|         |     44     else | 
|         |     45         { | 
|         |     46         aResultMask = aResultMask & ~ aSetMask; | 
|         |     47         } | 
|         |     48     } | 
|         |     49  | 
|         |     50 // --------------------------------------------------------------------------- | 
|         |     51 // Panic function for LockApp internal panics. | 
|         |     52 // --------------------------------------------------------------------------- | 
|         |     53 void DoPanic( TLockAppPanic aPanic ) | 
|         |     54     { | 
|         |     55     _LIT(KPanic,"LockApp"); | 
|         |     56     User::Panic( KPanic, aPanic ); | 
|         |     57     } | 
|         |     58  | 
|         |     59 // --------------------------------------------------------------------------- | 
|         |     60 // Causes client Panic (illegal use of the server services). | 
|         |     61 // Used RMessagePtr2::Panic() also completes the message. | 
|         |     62 // --------------------------------------------------------------------------- | 
|         |     63 void PanicClient(const RMessagePtr2& aMessage, TLockAppPanic aPanic ) | 
|         |     64     { | 
|         |     65     _LIT(KPanic, "LockAppServer"); | 
|         |     66     aMessage.Panic( KPanic, aPanic ); | 
|         |     67     } | 
|         |     68  | 
|         |     69 // --------------------------------------------------------------------------- | 
|         |     70 // Sends application spesific events to Sysap. | 
|         |     71 // Used mainly for lights control. | 
|         |     72 // --------------------------------------------------------------------------- | 
|         |     73 void SendMessageToSysAp( TInt aMessage ) | 
|         |     74     { | 
|         |     75     RWsSession& ws = CCoeEnv::Static()->WsSession( ); | 
|         |     76     TInt wgId = 0; | 
|         |     77     CApaWindowGroupName::FindByAppUid( KSysApUid, ws, wgId ); | 
|         |     78  | 
|         |     79     // if sysap window group exists | 
|         |     80     if ( wgId ) | 
|         |     81         { | 
|         |     82         TWsEvent event; | 
|         |     83         event.SetType( aMessage ); | 
|         |     84         event.SetTimeNow( ); | 
|         |     85         ws.SendEventToWindowGroup( wgId, event ); | 
|         |     86         } | 
|         |     87     } | 
|         |     88  | 
|         |     89 // --------------------------------------------------------------------------- | 
|         |     90 // Sends a key event to the windowgroup in background. | 
|         |     91 // Used mainly for sending red and green keys to phone app when | 
|         |     92 // devicelock or keyguard is in foreground. | 
|         |     93 // --------------------------------------------------------------------------- | 
|         |     94 void SendKeyToPhoneApp( const TKeyEvent& aKey, TEventCode aType ) | 
|         |     95     { | 
|         |     96     RWsSession& ws = CCoeEnv::Static()->WsSession( ); | 
|         |     97     TInt wgId = 0; | 
|         |     98     CApaWindowGroupName::FindByAppUid( KPhoneAppUid, ws, wgId ); | 
|         |     99  | 
|         |    100     // if sysap window group exists | 
|         |    101     if ( wgId ) | 
|         |    102         { | 
|         |    103         TWsEvent event; | 
|         |    104         *event.Key() = aKey; | 
|         |    105         event.SetType( aType ); | 
|         |    106         event.SetTimeNow( ); | 
|         |    107         ws.SendEventToWindowGroup( wgId, event ); | 
|         |    108         } | 
|         |    109     } | 
|         |    110  | 
|         |    111 // END OF FILE |