mediakeys/MMKeyBearer/src/MMKeyBearerImplementation.cpp
branchRCL_3
changeset 20 c2c61fdca848
parent 19 924385140d98
equal deleted inserted replaced
19:924385140d98 20:c2c61fdca848
    24 #include <remconcoreapi.h>
    24 #include <remconcoreapi.h>
    25 #include <mediakeysinternalpskeys.h>
    25 #include <mediakeysinternalpskeys.h>
    26 #include <UsbWatcherInternalPSKeys.h>
    26 #include <UsbWatcherInternalPSKeys.h>
    27 #include <usbpersonalityids.h>
    27 #include <usbpersonalityids.h>
    28 #include <PSVariables.h>   // Property values
    28 #include <PSVariables.h>   // Property values
    29 #include <keyguardaccessapi.h>
       
    30 
    29 
    31 // Include this once it is exported
    30 // Include this once it is exported
    32 // #include <RemConExtensionApi.h>
    31 // #include <RemConExtensionApi.h>
    33 
    32 
    34 #include "MMKeyBearerImplementation.h"
    33 #include "MMKeyBearerImplementation.h"
    73 
    72 
    74     delete iMMKeyBearerObserver;
    73     delete iMMKeyBearerObserver;
    75     delete iMediaKeyObserver;
    74     delete iMediaKeyObserver;
    76     delete iAccessoryVolKeyObserver;
    75     delete iAccessoryVolKeyObserver;
    77     delete iUSBFileTransferObserver;
    76     delete iUSBFileTransferObserver;
    78     delete iKeyguardAccess;
    77     iAknServer.Close();
    79     }
    78     }
    80 
    79 
    81 // ---------------------------------------------------------
    80 // ---------------------------------------------------------
    82 // CMMKeyBearer::CMMKeyBearer()
    81 // CMMKeyBearer::CMMKeyBearer()
    83 // construction.
    82 // construction.
    84 // ---------------------------------------------------------
    83 // ---------------------------------------------------------
    85 //
    84 //
    86 CMMKeyBearer::CMMKeyBearer(TBearerParams& aParams)
    85 CMMKeyBearer::CMMKeyBearer(TBearerParams& aParams)
    87 :   CRemConBearerPlugin(aParams),
    86 :   CRemConBearerPlugin(aParams),
    88     iUSBFileTransfer(KUsbWatcherSelectedPersonalityNone)
    87     iUSBFileTransfer(KUsbWatcherSelectedPersonalityNone),
    89     {
    88     iAknServerConnected(EFalse)
    90     FUNC_LOG;
    89     {
    91     
    90     FUNC_LOG;
       
    91 
    92     //Pass
    92     //Pass
    93     }
    93     }
    94 
    94 
    95 // ---------------------------------------------------------
    95 // ---------------------------------------------------------
    96 // CMMKeyBearer::ConstructL()
    96 // CMMKeyBearer::ConstructL()
   103 
   103 
   104     // throw an indication up to RemCon.
   104     // throw an indication up to RemCon.
   105     TRemConAddress addr;
   105     TRemConAddress addr;
   106     addr.BearerUid() = Uid();
   106     addr.BearerUid() = Uid();
   107     TInt err = Observer().ConnectIndicate(addr);
   107     TInt err = Observer().ConnectIndicate(addr);
   108     iKeyguardAccess = CKeyguardAccessApi::NewL();
       
   109 
   108 
   110     // Start Active object for listening key events from P&S
   109     // Start Active object for listening key events from P&S
   111     TRAP_AND_LEAVE(
   110     TRAP_AND_LEAVE(
   112         iMMKeyBearerObserver = CMMKeyBearerObserver::NewL(*this, ESideVolumeKeys),
   111         iMMKeyBearerObserver = CMMKeyBearerObserver::NewL(*this, ESideVolumeKeys),
   113         "Volume key observer init failed" );
   112         "Volume key observer init failed" );
   341     FUNC_LOG;
   340     FUNC_LOG;
   342 
   341 
   343     INFO_3( "Received key: enumValue = %d, keyType = %d, usbFileTransfer = %d",
   342     INFO_3( "Received key: enumValue = %d, keyType = %d, usbFileTransfer = %d",
   344         aEnumValue, aKeyType, iUSBFileTransfer );
   343         aEnumValue, aKeyType, iUSBFileTransfer );
   345 
   344 
       
   345 	//Start the listener once again
       
   346     if (aKeyType == ESideVolumeKeys)
       
   347         {
       
   348         iMMKeyBearerObserver->Start();
       
   349         }
       
   350 
   346     // Mediakeys must be disabled when MTP (Music Transfer) is happening.
   351     // Mediakeys must be disabled when MTP (Music Transfer) is happening.
   347     if (aKeyType == EFileTransferStatus)
   352     if (aKeyType == EFileTransferStatus)
   348         {
   353         {
   349         iUSBFileTransferObserver->Start(); // Ensure first that no status change gets missed
   354         iUSBFileTransferObserver->Start(); // Ensure first that no status change gets missed
   350         iUSBFileTransfer = iUSBFileTransferObserver->GetValue(); // Read the MTP status
   355         iUSBFileTransfer = iUSBFileTransferObserver->GetValue(); // Read the MTP status
   360 
   365 
   361     // Check for keypadlock if the events are from device keypad
   366     // Check for keypadlock if the events are from device keypad
   362     // If events are from accessory device,then do not check for keypadlock
   367     // If events are from accessory device,then do not check for keypadlock
   363     if (aKeyType != EAccessoryVolumeKeys && aKeyType != ESideVolumeKeys )
   368     if (aKeyType != EAccessoryVolumeKeys && aKeyType != ESideVolumeKeys )
   364         {
   369         {
   365                
   370         TBool keysLocked = EFalse;
   366         TInt err=iKeyguardAccess->ShowKeysLockedNote();
   371         if (!(iAknServerConnected))  // Connect to server for first time
   367 
   372             {
   368         if (err==KErrNone)
   373             if(iAknServer.Connect() == KErrNone)
       
   374                 {
       
   375                 iAknServerConnected = ETrue;
       
   376                 }
       
   377             else if (aKeyType == EMediaKeys)                 // If connection fails, then return
       
   378                 {
       
   379                 iMediaKeyObserver->Start();
       
   380 	    	return ;
       
   381                 }
       
   382             }
       
   383         iAknServer.ShowKeysLockedNote(keysLocked);
       
   384 
       
   385         if (keysLocked && aKeyType == EMediaKeys)
   369             {
   386             {
   370             // Device is locked , Discard the key event
   387             // Device is locked , Discard the key event
   371 
   388             iMediaKeyObserver->Start();
   372             //Start the listener once again
       
   373             
       
   374             if (aKeyType == EMediaKeys)
       
   375                 {
       
   376                 iMediaKeyObserver->Start();
       
   377                 }
       
   378 
       
   379             return;
   389             return;
   380             }
   390             }
   381         }
   391         }
   382 
   392 
   383     /* To keep the background light on */
   393     /* To keep the background light on */
   406 
   416 
   407     // Msgtype  is ERemConCommand
   417     // Msgtype  is ERemConCommand
   408     TInt aError = Observer().NewCommand(addr);
   418     TInt aError = Observer().NewCommand(addr);
   409 
   419 
   410     //Start the listener once again
   420     //Start the listener once again
   411     if (aKeyType == ESideVolumeKeys)
   421     if (aKeyType == EMediaKeys)
   412         {
       
   413         iMMKeyBearerObserver->Start();
       
   414         }
       
   415     else if (aKeyType == EMediaKeys)
       
   416         {
   422         {
   417         iMediaKeyObserver->Start();
   423         iMediaKeyObserver->Start();
   418         }
   424         }
   419     else if (aKeyType == EAccessoryVolumeKeys)
   425     else if (aKeyType == EAccessoryVolumeKeys)
   420         {
   426         {