bluetoothengine/btnotif/src/BTNAuthNotifier.cpp
branchRCL_3
changeset 6 6a29d5ad0713
parent 0 f63038272f30
child 14 f7fbeaeb166a
equal deleted inserted replaced
2:0b192a3a05a4 6:6a29d5ad0713
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 // INCLUDE FILES
    19 // INCLUDE FILES
    20 #include <StringLoader.h>    // Localisation stringloader
       
    21 #include <BTNotif.rsg>       // Own resources
    20 #include <BTNotif.rsg>       // Own resources
    22 #include "btnauthnotifier.h" // Own class definition
    21 #include "btnauthnotifier.h" // Own class definition
    23 #include "btNotifDebug.h"    // Debugging macros
    22 #include "btNotifDebug.h"    // Debugging macros
    24 #include <btextnotifiers.h>
    23 #include <btextnotifiers.h>
    25 #include <AknMediatorFacade.h> // Cover UI
    24 #include <AknMediatorFacade.h> // Cover UI
    37 #include <btengutil.h>
    36 #include <btengutil.h>
    38 #ifdef __SERIES60_HELP
    37 #ifdef __SERIES60_HELP
    39 #include <hlplch.h>
    38 #include <hlplch.h>
    40 #include <csxhelp/bt.hlp.hrh> // The bt hrh info is needed, for help launching
    39 #include <csxhelp/bt.hlp.hrh> // The bt hrh info is needed, for help launching
    41 #endif
    40 #endif
       
    41 #include <bluetoothuiutil.h>
    42 #include "btnotifnameutils.h"
    42 #include "btnotifnameutils.h"
    43 
    43 
    44 
    44 
    45 //
    45 //
    46 // SDP UUID Constants - Short form
    46 // SDP UUID Constants - Short form
   118 
   118 
   119     if( !iMessage.IsNull())
   119     if( !iMessage.IsNull())
   120         {
   120         {
   121         User::Leave(KErrInUse);
   121         User::Leave(KErrInUse);
   122         }
   122         }
   123     else if ( AutoLockOnL() )
   123 
       
   124     iMessage = aMessage;
       
   125     iReplySlot = aReplySlot;
       
   126 
       
   127     if ( AutoLockOnL() )
   124         {
   128         {
   125         // The phone is locked, access denied.
   129         // The phone is locked, access denied.
   126         // Write results back to caller and complete message.	
   130         // Write results back to caller and complete message.	
   127 		CompleteMessage(EFalse, KErrNone);	
   131 	CompleteMessage(EFalse, KErrNone);	
   128         return;
   132         return;
   129         }
   133         }
   130     
   134     
   131 	TBTAuthorisationParams param;
   135     TBTAuthorisationParams param;
   132  	TPckgC<TBTAuthorisationParams> pckg(param);
   136     TPckgC<TBTAuthorisationParams> pckg(param);
   133  	pckg.Set(aBuffer);
   137     pckg.Set(aBuffer);
   134 
   138 
   135  	iServiceUid = pckg().iUid.iUid;  // Pick up service uid from message
   139     iServiceUid = pckg().iUid.iUid;  // Pick up service uid from message
   136  	iBTAddr = pckg().iBDAddr;
   140     iBTAddr = pckg().iBDAddr;
   137  	if ( OtherOutgoPairing( iBTAddr ) )
   141     if ( OtherOutgoPairing( iBTAddr ) )
   138         {
   142         {
   139         // We won't allow connection request from another device during outgoing pairing:
   143         // We won't allow connection request from another device during outgoing pairing:
   140         FLOG(_L("[BTNOTIF]\t CBTAuthNotifier: outgoing pair in progress, reject request from other device"));
   144         FLOG(_L("[BTNOTIF]\t CBTAuthNotifier: outgoing pair in progress, reject request from other device"));
   141         CompleteMessage(KErrCancel);
   145         CompleteMessage(KErrCancel);
   142         return;
   146         return;
   143         }
   147         }	
   144  	
       
   145     iMessage = aMessage;
       
   146     iReplySlot = aReplySlot;
       
   147  	
   148  	
   148     // create iDevice so that the name won't be lost if the device does
   149     // create iDevice so that the name won't be lost if the device does
   149     // not exist in registry.
   150     // not exist in registry.
   150     iDevice = CBTDevice::NewL( iBTAddr );
   151     iDevice = CBTDevice::NewL( iBTAddr );
   151     BtNotifNameUtils::SetDeviceNameL(pckg().iName, *iDevice);
   152     BtNotifNameUtils::SetDeviceNameL(pckg().iName, *iDevice);
   199 
   200 
   200         // Show new prompt for dialog if it is still on the screen
   201         // Show new prompt for dialog if it is still on the screen
   201         if ( !iDevice->IsValidFriendlyName() && iDevice->IsValidDeviceName())
   202         if ( !iDevice->IsValidFriendlyName() && iDevice->IsValidDeviceName())
   202             {
   203             {
   203             // Create new prompt string with new device name
   204             // Create new prompt string with new device name
   204             HBufC* stringholder = StringLoader::LoadL( iStrResourceId, BTDeviceNameConverter::ToUnicodeL(iDevice->DeviceName()));
   205             RBuf stringholder;
   205             CleanupStack::PushL( stringholder );
   206             CleanupClosePushL( stringholder );
   206             iNotifUiUtil->UpdateQueryDlgL( *stringholder );
   207             BluetoothUiUtil::LoadResourceAndSubstringL( 
       
   208                     stringholder, iStrResourceId, 
       
   209                     BTDeviceNameConverter::ToUnicodeL(iDevice->DeviceName()), 0 );
       
   210             iNotifUiUtil->UpdateQueryDlgL( stringholder );
   207             iNotifUiUtil->UpdateCoverUiL( iDevice->DeviceName() );
   211             iNotifUiUtil->UpdateCoverUiL( iDevice->DeviceName() );
   208             CleanupStack::PopAndDestroy();  // stringholder
   212             CleanupStack::PopAndDestroy();  // stringholder
   209             }
   213             }
   210         }
   214         }
   211     FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::UpdateL() completed"));
   215     FLOG(_L("[BTNOTIF]\t CBTAuthNotifier::UpdateL() completed"));
   498         return;
   502         return;
   499         }
   503         }
   500 
   504 
   501     TBTDeviceName tempDeviceName; 
   505     TBTDeviceName tempDeviceName; 
   502     BtNotifNameUtils::GetDeviceDisplayName(tempDeviceName, iDevice);
   506     BtNotifNameUtils::GetDeviceDisplayName(tempDeviceName, iDevice);
   503     HBufC* stringholder = StringLoader::LoadLC( iStrResourceId, tempDeviceName);
   507     RBuf stringholder;
   504     TInt keypress = iNotifUiUtil->ShowQueryL( *stringholder, R_BT_AUTHORISATION_QUERY, 
   508     CleanupClosePushL( stringholder );
       
   509     BluetoothUiUtil::LoadResourceAndSubstringL( 
       
   510             stringholder, iStrResourceId, tempDeviceName, 0);
       
   511     TInt keypress = iNotifUiUtil->ShowQueryL( stringholder, R_BT_AUTHORISATION_QUERY, 
   505             iCoverUiDlgId, tempDeviceName, CAknQueryDialog::EConfirmationTone );
   512             iCoverUiDlgId, tempDeviceName, CAknQueryDialog::EConfirmationTone );
   506     CleanupStack::PopAndDestroy();  // stringholder
   513     CleanupStack::PopAndDestroy();  // stringholder
   507     // If this notifier is cancelled by the caller, no need to perform the rest operation:
   514     // If this notifier is cancelled by the caller, no need to perform the rest operation:
   508     if ( iSuspended || iMessage.IsNull() )
   515     if ( iSuspended || iMessage.IsNull() )
   509         {
   516         {