bluetoothengine/btnotif/src/BTNGenericQueryNotifier.cpp
branchRCL_3
changeset 53 eede1356aa52
parent 35 95674584745d
equal deleted inserted replaced
39:5a89845f78e2 53:eede1356aa52
     1 /*
     1 /*
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2002, 2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    24 #include <BTNotif.rsg>          // Own resources
    24 #include <BTNotif.rsg>          // Own resources
    25 #include <btengsettings.h>
    25 #include <btengsettings.h>
    26 #include <bluetoothuiutil.h>
    26 #include <bluetoothuiutil.h>
    27 #include "BTNGenericQueryNotifier.h"      // Own class definition
    27 #include "BTNGenericQueryNotifier.h"      // Own class definition
    28 #include "btNotifDebug.h"       // Debugging macros
    28 #include "btNotifDebug.h"       // Debugging macros
       
    29 #include <coreapplicationuisdomainpskeys.h>
    29 
    30 
    30 #ifdef __SERIES60_HELP
    31 #ifdef __SERIES60_HELP
    31 #include <hlplch.h>
    32 #include <hlplch.h>
    32 #include <csxhelp/bt.hlp.hrh> // The bt hrh info is needed, for help launching
    33 #include <csxhelp/bt.hlp.hrh> // The bt hrh info is needed, for help launching
    33 #endif
    34 #endif
       
    35 
       
    36 const TInt KBTNotifPhonePowerKeyWatcher = 30;
    34 
    37 
    35 // ================= MEMBER FUNCTIONS =======================
    38 // ================= MEMBER FUNCTIONS =======================
    36 
    39 
    37 // ----------------------------------------------------------
    40 // ----------------------------------------------------------
    38 // CBTGenericQueryNotifier::NewL
    41 // CBTGenericQueryNotifier::NewL
    53 // C++ default constructor can NOT contain any code, that
    56 // C++ default constructor can NOT contain any code, that
    54 // might leave.
    57 // might leave.
    55 // ----------------------------------------------------------
    58 // ----------------------------------------------------------
    56 //
    59 //
    57 CBTGenericQueryNotifier::CBTGenericQueryNotifier()
    60 CBTGenericQueryNotifier::CBTGenericQueryNotifier()
    58     {	
    61     {
    59     }
    62     }
    60 
    63 
    61 // ----------------------------------------------------------
    64 // ----------------------------------------------------------
    62 // Destructor
    65 // Destructor
    63 // ----------------------------------------------------------
    66 // ----------------------------------------------------------
    64 //
    67 //
    65 CBTGenericQueryNotifier::~CBTGenericQueryNotifier()
    68 CBTGenericQueryNotifier::~CBTGenericQueryNotifier()
    66     {
    69     {
    67     Cancel();   // Free own resources
    70     Cancel();   // Free own resources
    68     delete iName; 
    71     delete iName;
    69     iQueryMessage.Close(); 
    72     iQueryMessage.Close();
    70 	delete iQueryHeader;
    73 	delete iQueryHeader;
    71     }
    74 	if (iPhonePowerKey.Handle())
       
    75 		{
       
    76 		iPhonePowerKey.Cancel();
       
    77 		}
       
    78 	delete iPhonePowerKeyWatcher;
       
    79 	iPhonePowerKey.Close();
       
    80 	}
       
    81 
       
    82 // ----------------------------------------------------------
       
    83 // CBTGenericQueryNotifier::ConstructL
       
    84 // Symbian 2nd phase constructor can leave.
       
    85 // Attach to the P&S property and create
       
    86 // ----------------------------------------------------------
       
    87 //
       
    88 void CBTGenericQueryNotifier::ConstructL()
       
    89 	{
       
    90 	CBTNotifierBase::ConstructL();
       
    91 
       
    92 	/**
       
    93 	 * SysAp notifies Alarm UI to hide alarm when powerkey is pressed.
       
    94 	 * This is called from CSysApAppUi::HandleShortPowerKeyPressedL(),
       
    95 	 * so it seems to be a better choice than the following keys:
       
    96 	 * 	KPSUidAvkonDomain/KAknPowerMenuStatus
       
    97 	 * 	KPSUidCoreApplicationUIs/KCoreAppUIsAutolockStatus
       
    98 	 * KCoreAppUIsAutolockStatus  would be ideal, but it comes too late.
       
    99 	 */
       
   100 	User::LeaveIfError(iPhonePowerKey.Attach(KPSUidCoreApplicationUIs,
       
   101 			KCoreAppUIsHideAlarm));
       
   102 	iPhonePowerKeyWatcher = CBTNotifActive::NewL(this,
       
   103 			KBTNotifPhonePowerKeyWatcher, CActive::EPriorityStandard);
       
   104 	iPhonePowerKey.Subscribe(iPhonePowerKeyWatcher->RequestStatus());
       
   105 	iPhonePowerKeyWatcher->GoActive();
       
   106 	}
    72 
   107 
    73 // ----------------------------------------------------------
   108 // ----------------------------------------------------------
    74 // CBTGenericQueryNotifier::RegisterL
   109 // CBTGenericQueryNotifier::RegisterL
    75 // Register notifier.
   110 // Register notifier.
    76 // ----------------------------------------------------------
   111 // ----------------------------------------------------------
    93 TPtrC8 CBTGenericQueryNotifier::StartL( const TDesC8& /*aBuffer*/ )
   128 TPtrC8 CBTGenericQueryNotifier::StartL( const TDesC8& /*aBuffer*/ )
    94     {
   129     {
    95     FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::StartL()"));
   130     FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::StartL()"));
    96 
   131 
    97     TPtrC8 ret(KNullDesC8);
   132     TPtrC8 ret(KNullDesC8);
    98     return (ret);    
   133     return (ret);
    99     
   134 
   100     }
   135     }
   101 
   136 
   102 // ----------------------------------------------------------
   137 // ----------------------------------------------------------
   103 // CBTGenericQueryNotifier::GetParamsL
   138 // CBTGenericQueryNotifier::GetParamsL
   104 // Mandatory for BT Notifiers when using asynchronous launch. 
   139 // Mandatory for BT Notifiers when using asynchronous launch.
   105 // This notifier is synchronous so no implementation is needed.
   140 // This notifier is synchronous so no implementation is needed.
   106 // ----------------------------------------------------------
   141 // ----------------------------------------------------------
   107 //
   142 //
   108 void CBTGenericQueryNotifier::GetParamsL(const TDesC8& aBuffer, 
   143 void CBTGenericQueryNotifier::GetParamsL(const TDesC8& aBuffer,
   109                                      TInt aReplySlot, 
   144                                      TInt aReplySlot,
   110                                      const RMessagePtr2& aMessage)
   145                                      const RMessagePtr2& aMessage)
   111     {
   146     {
   112    	FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::GetParamsL"));    
   147    	FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::GetParamsL"));
   113 
   148 
   114    	if (iMessage.Handle())
   149    	if (iMessage.Handle())
   115    	    {
   150    	    {
   116    	    aMessage.Complete(KErrInUse);
   151    	    aMessage.Complete(KErrInUse);
   117    	    return;
   152    	    return;
   118    	    }
   153    	    }
   119    	
   154 
   120 	ProcessParamBufferL(aBuffer);
   155 	ProcessParamBufferL(aBuffer);
   121 	
   156 
   122     iMessage = aMessage;
   157     iMessage = aMessage;
   123     iReplySlot = aReplySlot;
   158     iReplySlot = aReplySlot;
   124     
   159 
   125     ShowQueryAndCompleteL();
   160     ShowQueryAndCompleteL();
   126     
   161 
   127    	FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::GetParamsL Complete"));    
   162    	FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::GetParamsL Complete"));
   128     }
   163     }
   129 
   164 
   130 // ----------------------------------------------------------
   165 // ----------------------------------------------------------
   131 // CBTGenericQueryNotifier::ProcessParamBufferL
   166 // CBTGenericQueryNotifier::ProcessParamBufferL
   132 // Parse the data out of the message that is sent by the
   167 // Parse the data out of the message that is sent by the
   133 // client of the notifier.
   168 // client of the notifier.
   134 // ----------------------------------------------------------
   169 // ----------------------------------------------------------
   135 void CBTGenericQueryNotifier::ProcessParamBufferL(const TDesC8& aBuffer)
   170 void CBTGenericQueryNotifier::ProcessParamBufferL(const TDesC8& aBuffer)
   136 	{
   171 	{
   137 	
   172 
   138 	TBTGenericQueryNotifierParams bParams;
   173 	TBTGenericQueryNotifierParams bParams;
   139 	TPckgC<TBTGenericQueryNotifierParams> bPckg(bParams);
   174 	TPckgC<TBTGenericQueryNotifierParams> bPckg(bParams);
   140 	bPckg.Set( aBuffer );
   175 	bPckg.Set( aBuffer );
   141 
   176 
   142 	if( bPckg().iMessageType == EBTNameQuery )
   177 	if( bPckg().iMessageType == EBTNameQuery )
   147 	iSecondaryDisplayCommand = ECmdBTnotifUnavailable;
   182 	iSecondaryDisplayCommand = ECmdBTnotifUnavailable;
   148 	switch (bPckg().iMessageType)
   183 	switch (bPckg().iMessageType)
   149 		{
   184 		{
   150 		case EBTReceiveMessageQuery:
   185 		case EBTReceiveMessageQuery:
   151 			iIsMessageQuery=EFalse;
   186 			iIsMessageQuery=EFalse;
   152 			iMessageResourceId=R_BT_RECEIVE_MESSAGE	;	
   187 			iMessageResourceId=R_BT_RECEIVE_MESSAGE	;
   153 			iSecondaryDisplayCommand=ECmdShowReceiveMessageFromDeviceDlg; 
   188 			iSecondaryDisplayCommand=ECmdShowReceiveMessageFromDeviceDlg;
   154 			break;
   189 			break;
   155 		case EBTReceiveMessagePairedQuery:
   190 		case EBTReceiveMessagePairedQuery:
   156 			iIsMessageQuery=EFalse;		
   191 			iIsMessageQuery=EFalse;
   157 			iMessageResourceId=R_BT_RECEIVE_MESSAGE_PAIRED;
   192 			iMessageResourceId=R_BT_RECEIVE_MESSAGE_PAIRED;
   158 			iSecondaryDisplayCommand= ECmdShowReceiveMessageFromPairedDeviceDlg; 
   193 			iSecondaryDisplayCommand= ECmdShowReceiveMessageFromPairedDeviceDlg;
   159 			break;			
   194 			break;
   160 		case EBTIsOffQuery:
   195 		case EBTIsOffQuery:
   161 			iIsMessageQuery=EFalse;		
   196 			iIsMessageQuery=EFalse;
   162     		iMessageResourceId=R_BT_POWER_IS_OFF ;
   197     		iMessageResourceId=R_BT_POWER_IS_OFF ;
   163 			iSecondaryDisplayCommand=ECmdShowBtIsOffDlg;		
   198 			iSecondaryDisplayCommand=ECmdShowBtIsOffDlg;
   164 			break;			
   199 			break;
   165 		case EBTActivateOffLineQuery:
   200 		case EBTActivateOffLineQuery:
   166 			iIsMessageQuery=EFalse;		
   201 			iIsMessageQuery=EFalse;
   167     		iMessageResourceId=R_BT_ACTIVATE_IN_OFFLINE;
   202     		iMessageResourceId=R_BT_ACTIVATE_IN_OFFLINE;
   168 			iSecondaryDisplayCommand=ECmdShowBtActivateInOfflineDlg;		
   203 			iSecondaryDisplayCommand=ECmdShowBtActivateInOfflineDlg;
   169 			break;			
   204 			break;
   170 		case EBTNoDevicesFoundQuery:
   205 		case EBTNoDevicesFoundQuery:
   171 			iIsMessageQuery=EFalse;		
   206 			iIsMessageQuery=EFalse;
   172 			iMessageResourceId=R_BT_NO_DEVICES_FOUND;
   207 			iMessageResourceId=R_BT_NO_DEVICES_FOUND;
   173 			break;	
   208 			break;
   174 		case EBTAcceptRequestQuery:
   209 		case EBTAcceptRequestQuery:
   175 			iIsMessageQuery=EFalse;		
   210 			iIsMessageQuery=EFalse;
   176 			iMessageResourceId=R_BT_AUTHORISATION_NAME ;
   211 			iMessageResourceId=R_BT_AUTHORISATION_NAME ;
   177 			iSecondaryDisplayCommand=ECmdShowAcceptConnRequestDlg;
   212 			iSecondaryDisplayCommand=ECmdShowAcceptConnRequestDlg;
   178 			break;		
   213 			break;
   179 			
   214 
   180 		case EBTIsOffJavaQuery:	
   215 		case EBTIsOffJavaQuery:
   181 			iIsMessageQuery=ETrue; 	
   216 			iIsMessageQuery=ETrue;
   182 			if( bPckg().iNameExists )			
   217 			if( bPckg().iNameExists )
   183 				{
   218 				{
   184 				iMessageResourceId=R_BT_IS_OFF_JAVA_APPNAME; // when caller provide Java application name.	
   219 				iMessageResourceId=R_BT_IS_OFF_JAVA_APPNAME; // when caller provide Java application name.
   185 				}
   220 				}
   186 			else
   221 			else
   187 				{
   222 				{
   188 				iMessageResourceId=R_BT_IS_OFF_JAVA; //r_bt_is_hidden_java	
   223 				iMessageResourceId=R_BT_IS_OFF_JAVA; //r_bt_is_hidden_java
   189 				}		
   224 				}
   190 			iSecondaryDisplayCommand=ECmdShowBtBtIsOffJavaDlg;
   225 			iSecondaryDisplayCommand=ECmdShowBtBtIsOffJavaDlg;
   191 			iQueryHeader=StringLoader::LoadL( R_BT_IS_OFF_JAVA_HEADER);		
   226 			iQueryHeader=StringLoader::LoadL( R_BT_IS_OFF_JAVA_HEADER);
   192 			break;
   227 			break;
   193 
   228 
   194 		case EBTIsNotShownQuery:
   229 		case EBTIsNotShownQuery:
   195 			iIsMessageQuery=ETrue;			
   230 			iIsMessageQuery=ETrue;
   196 			if( bPckg().iNameExists )
   231 			if( bPckg().iNameExists )
   197 				{
   232 				{
   198 				iMessageResourceId=R_BT_IS_HIDDEN_JAVA_APPNAME; // when caller provide Java application name.	
   233 				iMessageResourceId=R_BT_IS_HIDDEN_JAVA_APPNAME; // when caller provide Java application name.
   199 				}
   234 				}
   200 			else
   235 			else
   201 				{
   236 				{
   202 				iMessageResourceId=R_BT_IS_HIDDEN_JAVA; //r_bt_is_hidden_java	
   237 				iMessageResourceId=R_BT_IS_HIDDEN_JAVA; //r_bt_is_hidden_java
   203 				}									
   238 				}
   204 			iSecondaryDisplayCommand=ECmdShowBtIsNotVisibleDlg;
   239 			iSecondaryDisplayCommand=ECmdShowBtIsNotVisibleDlg;
   205 			iQueryHeader=StringLoader::LoadL( R_BT_IS_HIDDEN_JAVA_HEADER);
   240 			iQueryHeader=StringLoader::LoadL( R_BT_IS_HIDDEN_JAVA_HEADER);
   206 			break;
   241 			break;
   207 			
   242 
   208 		case EBTBlockConnectionQuery:
   243 		case EBTBlockConnectionQuery:
   209 		case EBTBlockPairedConnectionQuery:		
   244 		case EBTBlockPairedConnectionQuery:
   210 			iIsMessageQuery=ETrue;		
   245 			iIsMessageQuery=ETrue;
   211 			if( bPckg().iMessageType == EBTBlockConnectionQuery )
   246 			if( bPckg().iMessageType == EBTBlockConnectionQuery )
   212 				iMessageResourceId = R_BT_BLOCK_DEVICE_NOHELP; 
   247 				iMessageResourceId = R_BT_BLOCK_DEVICE_NOHELP;
   213 			else
   248 			else
   214 				iMessageResourceId = R_BT_BLOCK_PAIRED_DEVICE_NOHELP ; 
   249 				iMessageResourceId = R_BT_BLOCK_PAIRED_DEVICE_NOHELP ;
   215 				
   250 
   216 			iQueryHeader= StringLoader::LoadL( R_BT_BLOCK_DEVICE_HEADER );
   251 			iQueryHeader= StringLoader::LoadL( R_BT_BLOCK_DEVICE_HEADER );
   217 			break;
   252 			break;
   218 			
   253 
   219 		case EBTSwitchOffAnyway:
   254 		case EBTSwitchOffAnyway:
   220 			iIsMessageQuery=EFalse;		
   255 			iIsMessageQuery=EFalse;
   221 			iMessageResourceId=R_BT_SWITCH_OFF_ANYWAY;
   256 			iMessageResourceId=R_BT_SWITCH_OFF_ANYWAY;
   222 			break;		
   257 			break;
   223 					
   258 
   224 		default:
   259 		default:
   225 			FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier:: Unkown messageType! ")); 
   260 			FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier:: Unkown messageType! "));
   226  			User::Leave(KErrNotFound);		
   261  			User::Leave(KErrNotFound);
   227 		}
   262 		}
   228 	
   263 
   229 	// if the logic string contains substitute indicator "%U", replace it with device name:
   264 	// if the logic string contains substitute indicator "%U", replace it with device name:
   230 	//
   265 	//
   231 	HBufC* buf = StringLoader::LoadL( iMessageResourceId);
   266 	HBufC* buf = StringLoader::LoadL( iMessageResourceId);
   232 	iQueryMessage.Assign( buf );
   267 	iQueryMessage.Assign( buf );
   233 
   268 
   234 	TInt keyLen;
   269 	TInt keyLen;
   235 	TInt pos = BluetoothUiUtil::GetStringSubstringKeyPos( 
   270 	TInt pos = BluetoothUiUtil::GetStringSubstringKeyPos(
   236 	        iQueryMessage, 0, keyLen );
   271 	        iQueryMessage, 0, keyLen );
   237 	if( pos > KErrNotFound)
   272 	if( pos > KErrNotFound)
   238 		{		
   273 		{
   239 		//if no device name provided, default name will be used:
   274 		//if no device name provided, default name will be used:
   240 		if( !bPckg().iNameExists )			
   275 		if( !bPckg().iNameExists )
   241 			iName=StringLoader::LoadL(R_BT_DIALOG_DEF_NAME);
   276 			iName=StringLoader::LoadL(R_BT_DIALOG_DEF_NAME);
   242 		else
   277 		else
   243 			{
   278 			{
   244 			iName=HBufC::NewL(bPckg().iName.Length() );
   279 			iName=HBufC::NewL(bPckg().iName.Length() );
   245 			iName->Des().Copy(bPckg().iName);
   280 			iName->Des().Copy(bPckg().iName);
   246 			}
   281 			}
   247 		BluetoothUiUtil::LoadResourceAndSubstringL( 
   282 		BluetoothUiUtil::LoadResourceAndSubstringL(
   248 		        iQueryMessage, iMessageResourceId, *iName, 0);
   283 		        iQueryMessage, iMessageResourceId, *iName, 0);
   249 		}
   284 		}
   250 	else
   285 	else
   251 		{
   286 		{
   252 		iName=NULL;		
   287 		iName=NULL;
   253 		}		
   288 		}
   254 	}
   289 	}
   255 
   290 
   256 // ----------------------------------------------------------
   291 // ----------------------------------------------------------
   257 // CBTGenericQueryNotifier::UpdateL
   292 // CBTGenericQueryNotifier::UpdateL
   258 // Update notifier according to new data
   293 // Update notifier according to new data
   259 // ----------------------------------------------------------
   294 // ----------------------------------------------------------
   260 //	
   295 //
   261 TPtrC8 CBTGenericQueryNotifier::UpdateL(const TDesC8& aBuffer)
   296 TPtrC8 CBTGenericQueryNotifier::UpdateL(const TDesC8& aBuffer)
   262 	{
   297 	{
   263    	FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::UpdateL")); 
   298    	FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::UpdateL"));
   264 	ProcessParamBufferL(aBuffer);
   299 	ProcessParamBufferL(aBuffer);
   265 	if( !iNotifUiUtil->IsQueryReleased() )
   300 	if( !iNotifUiUtil->IsQueryReleased() )
   266 		{
   301 		{
   267 		if(iIsMessageQuery )
   302 		if(iIsMessageQuery )
   268 		    {
   303 		    {
   271 		else
   306 		else
   272 		    {
   307 		    {
   273 		    iNotifUiUtil->UpdateQueryDlgL(iQueryMessage);
   308 		    iNotifUiUtil->UpdateQueryDlgL(iQueryMessage);
   274 		    }
   309 		    }
   275 		}
   310 		}
   276    	FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::UpdateL complete")); 	
   311    	FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::UpdateL complete"));
   277 
   312 
   278     TPtrC8 ret(KNullDesC8);
   313     TPtrC8 ret(KNullDesC8);
   279     return (ret);   	
   314     return (ret);
   280 	}
   315 	}
   281 
   316 
   282 // ----------------------------------------------------------
   317 // ----------------------------------------------------------
   283 // CBTGenericQueryNotifier::ShowQueryAndCompleteL
   318 // CBTGenericQueryNotifier::ShowQueryAndCompleteL
   284 // Shows the notifier in backround and complete message
   319 // Shows the notifier in backround and complete message
   285 // ----------------------------------------------------------
   320 // ----------------------------------------------------------
   286 //
   321 //
   287 void CBTGenericQueryNotifier::ShowQueryAndCompleteL()
   322 void CBTGenericQueryNotifier::ShowQueryAndCompleteL()
   288 	{ 
   323 	{
   289    	FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::ShowQueryAndCompleteL")); 	
   324    	FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::ShowQueryAndCompleteL"));
   290 	
   325 
   291 	// Turn lights on and deactivate apps -key
   326 	// Turn lights on and deactivate apps -key
   292 	//
   327 	//
   293    	iNotifUiUtil->TurnLightsOn();  	
   328    	iNotifUiUtil->TurnLightsOn();
   294 	if( iIsNameQuery )
   329 	if( iIsNameQuery )
   295 	    {
   330 	    {
   296 	    TBool nameStatus = IsLocalNameModifiedL();
   331 	    TBool nameStatus = IsLocalNameModifiedL();
   297 	    if( !nameStatus )
   332 	    if( !nameStatus )
   298 	        {
   333 	        {
   299 	        (void) AskLocalBTNameQueryL();
   334 	        (void) AskLocalBTNameQueryL();
   300 	        }
   335 	        }
   301         // Check if Local name is set again before turn BT on. 
   336         // Check if Local name is set again before turn BT on.
   302         // Turn BT on only when there is local name, since user still has chance
   337         // Turn BT on only when there is local name, since user still has chance
   303         // to ignore the asking name query - like pressing End-key     
   338         // to ignore the asking name query - like pressing End-key
   304         //             
   339         //
   305         TBTDeviceName localName;           
   340         TBTDeviceName localName;
   306         localName.Zero();
   341         localName.Zero();
   307         TInt err = iBTEngSettings->GetLocalName(localName);
   342         TInt err = iBTEngSettings->GetLocalName(localName);
   308               
   343 
   309         if (localName.Length() <= 0)
   344         if (localName.Length() <= 0)
   310             {   
   345             {
   311             err = KErrCancel;
   346             err = KErrCancel;
   312             }
   347             }
   313 	    	    
   348 
   314 	    CompleteMessage( (!err) ? ETrue : EFalse, KErrNone );
   349 	    CompleteMessage( (!err) ? ETrue : EFalse, KErrNone );
   315 
   350 
   316 	    FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::ShowQueryAndCompleteL iIsNameQuery complete")); 
   351 	    FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::ShowQueryAndCompleteL iIsNameQuery complete"));
   317 	    return;
   352 	    return;
   318 	    }
   353 	    }
   319 	
   354 
   320 	TInt keypress;
   355 	TInt keypress;
   321     TBTDeviceName name(KNullDesC);
   356     TBTDeviceName name(KNullDesC);
   322     if( iName )
   357     if( iName )
   323 	    {
   358 	    {
   324 	    name.Copy( *iName );
   359 	    name.Copy( *iName );
   325 	    }
   360 	    }
   326     if( iIsMessageQuery	)
   361     if( iIsMessageQuery	)
   327 		{
   362 		{
   328 		
   363 
   329         keypress = iNotifUiUtil->ShowMessageQueryL(iQueryMessage, *iQueryHeader, 
   364         keypress = iNotifUiUtil->ShowMessageQueryL(iQueryMessage, *iQueryHeader,
   330                         R_BT_GENERIC_MESSAGE_QUERY, CAknQueryDialog::EConfirmationTone );        
   365                         R_BT_GENERIC_MESSAGE_QUERY, CAknQueryDialog::EConfirmationTone );
   331 		}
   366 		}
   332 	else
   367 	else
   333     	{
   368     	{
   334     	keypress = iNotifUiUtil->ShowQueryL( iQueryMessage, R_BT_GENERIC_QUERY, 
   369     	keypress = iNotifUiUtil->ShowQueryL( iQueryMessage, R_BT_GENERIC_QUERY,
   335     	        iSecondaryDisplayCommand, name, CAknQueryDialog::EConfirmationTone );
   370     	        iSecondaryDisplayCommand, name, CAknQueryDialog::EConfirmationTone );
   336     	}
   371     	}
   337 	
   372 
   338    	CompleteMessage( (keypress) ? ETrue: EFalse, KErrNone );
   373    	CompleteMessage( (keypress) ? ETrue: EFalse, KErrNone );
   339 
   374 
   340    	FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::ShowQueryAndCompleteL complete")); 			
   375    	FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::ShowQueryAndCompleteL complete"));
       
   376 	}
       
   377 
       
   378 // ----------------------------------------------------------
       
   379 // CBTAuthNotifier::RequestCompletedL
       
   380 // Gets called when P&S key notifies the change
       
   381 // ----------------------------------------------------------
       
   382 void CBTGenericQueryNotifier::RequestCompletedL(CBTNotifActive* aActive,
       
   383 		TInt aId, TInt aStatus)
       
   384 	{
       
   385 	FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::RequestCompletedL()"));
       
   386 	switch (aId)
       
   387 		{
       
   388 	case KBTNotifPhonePowerKeyWatcher:
       
   389 		{
       
   390 		iPhonePowerKey.Subscribe(aActive->RequestStatus());
       
   391 		aActive->GoActive();
       
   392 		TInt val = 0;
       
   393 		// If the Power key is pressed it is likely that he user does not
       
   394 		// want to continue with existing query, so we dismiss it to avoid
       
   395 		// any clashes with subsequent popups (ie for setting Lock code).
       
   396 		// This is probably just a temporary solution to resolve immediate problem,
       
   397 		// and the issue is raised with UI Framework team.
       
   398 		if (!aStatus && !iPhonePowerKey.Get(val) && val == ECoreAppUIsHideAlarm)
       
   399 			{
       
   400 			// DismissDialog() internally checks that actual query dialog is NOT NULL,
       
   401 			// so it is safe to call it here.
       
   402 			iNotifUiUtil->DismissDialog();
       
   403 			}
       
   404 		}
       
   405 		break;
       
   406 		}
       
   407 
       
   408 	FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::RequestCompletedL() completed"));
       
   409 	}
       
   410 
       
   411 // ----------------------------------------------------------
       
   412 // CBTAuthNotifier::HandleError
       
   413 // ----------------------------------------------------------
       
   414 void CBTGenericQueryNotifier::HandleError(CBTNotifActive* aActive, TInt aId,
       
   415 		TInt aError)
       
   416 	{
       
   417 	FTRACE(FPrint(_L("[BTNOTIF]\t CBTGenericQueryNotifier::HandleError() error = %d"), aError ));
       
   418 	(void) aActive;
       
   419 	(void) aId;
       
   420 	(void) aError;
       
   421 	}
       
   422 
       
   423 // ----------------------------------------------------------
       
   424 // CBTAuthNotifier::DoCancelRequest
       
   425 // Root caller is CBTNotifActive::CancelRequest(), which calls
       
   426 // CActive::Cancel that calls DoCancel() if request is active.
       
   427 // ----------------------------------------------------------
       
   428 void CBTGenericQueryNotifier::DoCancelRequest(CBTNotifActive* aActive, TInt aId)
       
   429 	{
       
   430 	FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::DoCancel() >>"));
       
   431 	(void) aActive;
       
   432 	(void) aId;
       
   433 
       
   434 	iPhonePowerKey.Cancel();
       
   435 
       
   436 	FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::DoCancel() <<"));
   341 	}
   437 	}
   342 
   438 
   343 // End of File
   439 // End of File