mediakeys/MMKeyBearer/src/MMKeyBearerImplementation.cpp
changeset 21 c4cbaa4fb734
parent 0 2e3d3ce01487
child 51 50b444048a8d
--- a/mediakeys/MMKeyBearer/src/MMKeyBearerImplementation.cpp	Tue Feb 02 10:12:00 2010 +0200
+++ b/mediakeys/MMKeyBearer/src/MMKeyBearerImplementation.cpp	Fri Apr 16 15:08:06 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies). 
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). 
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -26,6 +26,7 @@
 #include <UsbWatcherInternalPSKeys.h>
 #include <usbpersonalityids.h>
 #include <PSVariables.h>   // Property values
+#include <keyguardaccessapi.h>
 
 // Include this once it is exported
 // #include <RemConExtensionApi.h>
@@ -74,7 +75,7 @@
     delete iMediaKeyObserver;
     delete iAccessoryVolKeyObserver;
     delete iUSBFileTransferObserver;
-    iAknServer.Close();
+    delete iKeyguardAccess;
     }
 
 // ---------------------------------------------------------
@@ -84,11 +85,10 @@
 //
 CMMKeyBearer::CMMKeyBearer(TBearerParams& aParams)
 :   CRemConBearerPlugin(aParams),
-    iUSBFileTransfer(KUsbWatcherSelectedPersonalityNone),
-    iAknServerConnected(EFalse)
+    iUSBFileTransfer(KUsbWatcherSelectedPersonalityNone)
     {
     FUNC_LOG;
-
+    
     //Pass
     }
 
@@ -105,6 +105,7 @@
     TRemConAddress addr;
     addr.BearerUid() = Uid();
     TInt err = Observer().ConnectIndicate(addr);
+    iKeyguardAccess = CKeyguardAccessApi::NewL();
 
     // Start Active object for listening key events from P&S
     TRAP_AND_LEAVE(
@@ -361,30 +362,10 @@
     // If events are from accessory device,then do not check for keypadlock
     if (aKeyType != EAccessoryVolumeKeys)
         {
-        TBool keysLocked = EFalse;
-        if (!(iAknServerConnected))  // Connect to server for first time
-            {
-            if(iAknServer.Connect() == KErrNone)
-                {
-                iAknServerConnected = ETrue;
-                }
-            else                   // If connection fails, then return
-                {
-                //Start the listener once again
-               if (aKeyType == ESideVolumeKeys)
-                    {
-                    iMMKeyBearerObserver->Start();
-                    }
-                if (aKeyType == EMediaKeys)
-                    {
-                    iMediaKeyObserver->Start();
-                    }
-                return ;
-                }
-            }
-        iAknServer.ShowKeysLockedNote(keysLocked);
+               
+        TInt err=iKeyguardAccess->ShowKeysLockedNote();
 
-        if (keysLocked)
+        if (err==KErrNone)
             {
             // Device is locked , Discard the key event