bluetoothengine/btnotif/src/BTNGenericInfoNotifier.cpp
branchRCL_3
changeset 6 6a29d5ad0713
parent 0 f63038272f30
child 10 b6f55cd40afd
equal deleted inserted replaced
2:0b192a3a05a4 6:6a29d5ad0713
    22 #include <BTNotif.rsg>          // Own resources
    22 #include <BTNotif.rsg>          // Own resources
    23 #include "BTNGenericInfoNotifier.h"      // Own class definition
    23 #include "BTNGenericInfoNotifier.h"      // Own class definition
    24 #include "btNotifDebug.h"       // Debugging macros
    24 #include "btNotifDebug.h"       // Debugging macros
    25 #include <SecondaryDisplay/BTnotifSecondaryDisplayAPI.h>
    25 #include <SecondaryDisplay/BTnotifSecondaryDisplayAPI.h>
    26 #include <e32cmn.h>
    26 #include <e32cmn.h>
       
    27 #include <bluetoothuiutil.h>
    27 #include "btnotifnameutils.h"
    28 #include "btnotifnameutils.h"
    28 
    29 
    29 // ================= MEMBER FUNCTIONS =======================
    30 // ================= MEMBER FUNCTIONS =======================
    30 
    31 
    31 // ----------------------------------------------------------
    32 // ----------------------------------------------------------
    57 // ----------------------------------------------------------
    58 // ----------------------------------------------------------
    58 //
    59 //
    59 CBTGenericInfoNotifier::~CBTGenericInfoNotifier()
    60 CBTGenericInfoNotifier::~CBTGenericInfoNotifier()
    60     {
    61     {
    61     Cancel();   // Free own resources
    62     Cancel();   // Free own resources
    62     delete iQueryMessage; 
    63     iQueryMessage.Close(); 
    63     }
    64     }
    64 
    65 
    65 // ----------------------------------------------------------
    66 // ----------------------------------------------------------
    66 // CBTGenericInfoNotifier::RegisterL
    67 // CBTGenericInfoNotifier::RegisterL
    67 // Register notifier.
    68 // Register notifier.
   201 		default:
   202 		default:
   202 			FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier:: Unkown messageType! ")); 
   203 			FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier:: Unkown messageType! ")); 
   203 			User::Leave(KErrNotFound);		
   204 			User::Leave(KErrNotFound);		
   204 		}
   205 		}
   205     
   206     
   206 	// if the logic string contains substitute indicator "%U", replace it with device name:	
   207 	// if the logic string contains substitute indicator "%U", replace it with device name:
   207 	iQueryMessage = StringLoader::LoadL( iMessageResourceId);
   208 	HBufC* buf = StringLoader::LoadL( iMessageResourceId);
   208 	_LIT(PU,"%U");
   209 	iQueryMessage.Assign( buf );
   209 	if( iQueryMessage->Find(PU) != KErrNotFound)
   210 	
       
   211     TInt keyLen;
       
   212     TInt pos = BluetoothUiUtil::GetStringSubstringKeyPos( 
       
   213             iQueryMessage, 0, keyLen );
       
   214     if( pos > KErrNotFound)
   210 		{
   215 		{
   211 		iBTAddr = TBTDevAddr( bPckg().iRemoteAddr );
   216 		iBTAddr = TBTDevAddr( bPckg().iRemoteAddr );
   212         iDevice = CBTDevice::NewL(iBTAddr);
   217 		if( !iDevice )
       
   218 		    {
       
   219             iDevice = CBTDevice::NewL(iBTAddr);
       
   220 		    }
   213 	    GetDeviceFromRegL( iBTAddr );
   221 	    GetDeviceFromRegL( iBTAddr );
   214 		}
   222 		}
   215 	else
   223 	else
   216 	    {
   224 	    {
   217 	    ShowNoteAndCompleteL();
   225 	    ShowNoteAndCompleteL();
   223 // Shows the notifier in backround 
   231 // Shows the notifier in backround 
   224 // ----------------------------------------------------------
   232 // ----------------------------------------------------------
   225 //
   233 //
   226 void CBTGenericInfoNotifier::ShowNoteAndCompleteL()
   234 void CBTGenericInfoNotifier::ShowNoteAndCompleteL()
   227 	{
   235 	{
   228 	iNotifUiUtil->ShowInfoNoteL( *iQueryMessage, iSecondaryDisplayCommand );
   236 	iNotifUiUtil->ShowInfoNoteL( iQueryMessage, iSecondaryDisplayCommand );
   229     CompleteMessage(KErrNone);
   237     CompleteMessage(KErrNone);
   230     FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::ShowNoteAndComplete() complete"));
   238     FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::ShowNoteAndComplete() complete"));
   231 	}
   239 	}
   232 
   240 
   233 void CBTGenericInfoNotifier::HandleGetDeviceCompletedL(const CBTDevice* /*aDev*/)
   241 void CBTGenericInfoNotifier::HandleGetDeviceCompletedL(const CBTDevice* /*aDev*/)
   234     {
   242     {
   235     FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::HandleGetDeviceCompleted()"));
   243     FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::HandleGetDeviceCompleted()"));
   236     
   244     
   237     delete iQueryMessage;
       
   238     iQueryMessage=NULL;
       
   239     
       
   240     TBTDeviceName name;
   245     TBTDeviceName name;
   241     BtNotifNameUtils::GetDeviceDisplayName(name, iDevice);
   246     BtNotifNameUtils::GetDeviceDisplayName(name, iDevice);
   242     iQueryMessage = StringLoader::LoadL( iMessageResourceId, name);            
   247     iQueryMessage.Zero();
       
   248     BluetoothUiUtil::LoadResourceAndSubstringL( 
       
   249             iQueryMessage, iMessageResourceId, name, 0);      
   243     
   250     
   244     ShowNoteAndCompleteL();
   251     ShowNoteAndCompleteL();
   245 
   252 
   246     FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::HandleGetDeviceComplete() Complete"));        
   253     FLOG(_L("[BTNOTIF]\t CBTGenericInfoNotifier::HandleGetDeviceComplete() Complete"));        
   247     }
   254     }