uifw/AvKon/src/AknKeyLock.cpp
changeset 0 2f259fa3e83a
child 30 56e9a0aaad89
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2002 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: 
       
    15 *
       
    16 */
       
    17 
       
    18 // AKNKEYLOCK.CPP
       
    19 //
       
    20 // Copyright (c) 1997-2001 Symbian Ltd.  All rights reserved.
       
    21 //
       
    22 
       
    23 // Avkon KeyLock Client
       
    24 
       
    25 #include <AknNotifySignature.h>
       
    26 #include <AknCapServerDefs.h>
       
    27 #include <AknNotifierWrapperDefs.h>
       
    28 #include <apgtask.h>
       
    29 #include <coemain.h>
       
    30 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    31 #include <uikon.hrh>
       
    32 #else
       
    33 #include <uikon.hrh>
       
    34 #include <uiklaf/private/pluginuid.hrh>
       
    35 #endif
       
    36 #include <avkondomainpskeys.h>      // KPSUidAvkonDomain, KAknKeyguardStatus, TAknKeyguardStatus
       
    37 #include <e32property.h>
       
    38 #include "aknkeylock.h"
       
    39 #include "AknNotifierController.h"
       
    40 
       
    41 // RAknKeyLock
       
    42 
       
    43 EXPORT_C void RAknKeyLock::EnableKeyLock()
       
    44 	{
       
    45 	SendMessage(ELockEnabled);
       
    46 	}
       
    47 
       
    48 EXPORT_C void RAknKeyLock::DisableKeyLock()
       
    49 	{
       
    50 	SendMessage(ELockDisabled);
       
    51 	}
       
    52 
       
    53 EXPORT_C void RAknKeyLock::OfferKeyLock()
       
    54 	{
       
    55 	SendMessage(EOfferKeylock);
       
    56 	}
       
    57 
       
    58 
       
    59 
       
    60 EXPORT_C TBool RAknKeyLock::IsKeyLockEnabled()
       
    61 	{
       
    62 	TInt value;
       
    63 	TInt err = RProperty::Get(KPSUidAvkonDomain, KAknKeyguardStatus, value);
       
    64 	if ( err != KErrNone ) 
       
    65 	    return EFalse;
       
    66 	switch( value ) 
       
    67 	    {
       
    68 	    case EKeyguardLocked:
       
    69 	    case EKeyguardAutolockEmulation:
       
    70 	        return ETrue;
       
    71 	    case EKeyguardNotActive:
       
    72 	    default:
       
    73 	        return EFalse;
       
    74 	    }
       
    75 	}
       
    76 
       
    77 EXPORT_C void RAknKeyLock::EnableSoftNotifications(TBool aEnable)
       
    78 	{
       
    79     AknNotifierController::HideAllNotifications(!aEnable);
       
    80     }
       
    81 
       
    82 EXPORT_C void RAknKeyLock::CancelAllNotifications()
       
    83 	{
       
    84     AknNotifierController::CancelAllNotifications();
       
    85 	}
       
    86 
       
    87 
       
    88 EXPORT_C void RAknKeyLock::EnableAutoLockEmulation()
       
    89 	{
       
    90 	SendMessage(EEnableAutoLockEmulation);
       
    91 	}
       
    92 
       
    93 
       
    94 EXPORT_C void RAknKeyLock::DisableWithoutNote()
       
    95 	{
       
    96 	SendMessage(EDisableWithoutNote);
       
    97 	}
       
    98 
       
    99 EXPORT_C void RAknKeyLock::EnableWithoutNote()
       
   100 	{
       
   101 	SendMessage(EEnableWithoutNote);
       
   102 	}
       
   103 
       
   104 void RAknKeyLock::SendMessage(TKeyLockNotifierReason aMessage)
       
   105 	{
       
   106 	TPckgBuf<SAknNotifierPackage<SAknKeyLockNotifierParams> > data;
       
   107 	TRequestStatus status;
       
   108 	data().iParamData.iReason = aMessage;
       
   109 	StartNotifierAndGetResponse(status,KAknKeyLockNotifierUid, data, data);
       
   110 	User::WaitForRequest(status);
       
   111 	CancelNotifier(KAknKeyLockNotifierUid);
       
   112 	}
       
   113 
       
   114 // RAknKeyLock2
       
   115 
       
   116 EXPORT_C TInt RAknKeylock2::Connect()
       
   117 	{
       
   118 	TInt ret = KErrNotReady;
       
   119 	CCoeEnv* coe = CCoeEnv::Static();
       
   120 	if (!coe)
       
   121 		{
       
   122 		return KErrNotSupported; // we need that window group list
       
   123 		}
       
   124     TApaTaskList list(CCoeEnv::Static()->WsSession());
       
   125     TApaTask task = list.FindApp(KAknCapServerUid);
       
   126     if (task.Exists() )
       
   127         {
       
   128         if ( Handle() == NULL)
       
   129             {
       
   130             _LIT(KServerNameFormat, "%08x_%08x_AppServer");
       
   131 	        TFullName serverName;
       
   132 	        TUid serviceUid = KAknNotifierServiceUid;
       
   133 	        serverName.Format(KServerNameFormat, KUikonUidPluginInterfaceNotifiers, KAknCapServerUid);
       
   134 			ret = CreateSession(serverName,*reinterpret_cast<TVersion*>(&serviceUid));           
       
   135             }
       
   136         else 
       
   137         	{
       
   138         	ret = KErrNone; // or should this be KErrAlreadyExist		
       
   139         	}
       
   140         }
       
   141 	return ret;
       
   142 	}
       
   143 
       
   144 
       
   145 // End of File