locationsystemui/locationsysui/locbtnotifier/src/locbtnotifierplugin.cpp
branchRCL_3
changeset 44 2b4ea9893b66
parent 42 02ba3f1733c6
child 45 6b6920c56e2f
equal deleted inserted replaced
42:02ba3f1733c6 44:2b4ea9893b66
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  CLocBtNotifierPlugIn class implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // System Includes
       
    20 #include <cfactionindication.h>
       
    21 #include <centralrepository.h>
       
    22 #include <AknGlobalNote.h>
       
    23 
       
    24 
       
    25 // User Includes
       
    26 #include "locbtnotifierplugin.h"
       
    27 #include "locbtnotifierconstantsmanager.h"
       
    28 #include "locbtnotifierprivatecrkeys.h"
       
    29 #include "locbtnotifierdebug.h"
       
    30 
       
    31 // CONSTANTS
       
    32 
       
    33 // Security Policy
       
    34 _LIT_SECURITY_POLICY_PASS( KSecurityPolicy );
       
    35 
       
    36 // LocBtNotifier action
       
    37 _LIT( KLocBtNotifierAction, "showNote" );
       
    38 
       
    39 // LocBtNotifier action parameters
       
    40 _LIT( KPsBatteryKeyState, "BatteryState" );
       
    41 _LIT( KPsAntennaKeyState, "AntennaState" );
       
    42 _LIT( KPsPowerKeyState,   "PowerState" );
       
    43 
       
    44 // BtGpsPsy Battery key state values
       
    45 _LIT( KBatteryStateNormal, "EBatteryStateNormal" );
       
    46 _LIT( KBatteryStateNA,     "EBatteryStateNA" );
       
    47 _LIT( KBatteryStateLow,    "EBatteryStateLow" );
       
    48 _LIT( KBatteryStateFull,   "EBatteryStateFull" );
       
    49 
       
    50 // BtGpsPsy Antenna key state values
       
    51 _LIT( KExtAntennaNA,  "EExtAntennaNA" );
       
    52 _LIT( KExtAntennaOff, "EExtAntennaOff" );
       
    53 _LIT( KExtAntennaOn,  "EExtAntennaOn" );
       
    54 
       
    55 // BtGpsPsy Power key state values
       
    56 _LIT( KExtPowerNA,  "EExtPowerNA" );
       
    57 _LIT( KExtPowerOff, "EExtPowerOff" );
       
    58 _LIT( KExtPowerOn,  "EExtPowerOn" );
       
    59 
       
    60 // Max length of the text to be displayed in the Information Note
       
    61 const TInt KMaxInfoTextLength = 256;
       
    62 
       
    63 // Logging constants
       
    64 _LIT(KLogFile, "locbtnotifier.txt");
       
    65 
       
    66 _LIT(KLogDir, "locbtnotifier");
       
    67 
       
    68 
       
    69 
       
    70 
       
    71 // ======== MEMBER FUNCTIONS ========
       
    72 
       
    73 
       
    74 
       
    75 // ---------------------------------------------------------------------------
       
    76 // CLocBtNotifierPlugIn::CLocBtNotifierPlugIn
       
    77 // ---------------------------------------------------------------------------
       
    78 //
       
    79  CLocBtNotifierPlugIn::CLocBtNotifierPlugIn(): 
       
    80  iBatteryStatus( CLocBtNotifierPlugIn::EBatteryStateUnInitialized ),
       
    81  iAntennaStatus( CLocBtNotifierPlugIn::EAntennaStateUnInitialized ),
       
    82  iPowerStatus( CLocBtNotifierPlugIn::EPowerStateUnInitialized ),
       
    83  iInfoText ( NULL , 0 )
       
    84     {
       
    85     
       
    86     }
       
    87 
       
    88 // ---------------------------------------------------------------------------
       
    89 // CLocBtNotifierPlugIn::NewL
       
    90 // Two Phased constructor 
       
    91 // ---------------------------------------------------------------------------
       
    92 //
       
    93 CLocBtNotifierPlugIn* CLocBtNotifierPlugIn::NewL()
       
    94     {
       
    95     LOCBTNOTIFIERDEBUG( "CLocBtNotifierPlugIn::NewL : IN" );
       
    96    
       
    97     CLocBtNotifierPlugIn* self = new( ELeave ) CLocBtNotifierPlugIn;
       
    98     
       
    99     
       
   100     LOCBTNOTIFIERDEBUG( "CLocBtNotifierPlugIn::NewL : OUT" );
       
   101     
       
   102     return self;
       
   103     }
       
   104 
       
   105 
       
   106 
       
   107 // ---------------------------------------------------------------------------
       
   108 // CLocBtNotifierPlugIn::~CLocBtNotifierPlugIn
       
   109 // Destructor
       
   110 // ---------------------------------------------------------------------------
       
   111 //
       
   112 CLocBtNotifierPlugIn::~CLocBtNotifierPlugIn()
       
   113     {
       
   114     LOCBTNOTIFIERDEBUG( "CLocBtNotifierPlugIn::~CLocBtNotifierPlugIn : IN" );
       
   115     
       
   116     delete iGlobalNote;
       
   117     delete iConstantsManager;
       
   118    
       
   119     LOCBTNOTIFIERDEBUG( "CLocBtNotifierPlugIn::~CLocBtNotifierPlugIn : OUT" );
       
   120     }
       
   121 
       
   122 
       
   123 // ---------------------------------------------------------------------------
       
   124 // From class CCFActionPlugIn
       
   125 // CLocBtNotifierPlugIn::InitializeL
       
   126 // ---------------------------------------------------------------------------
       
   127 //
       
   128 void CLocBtNotifierPlugIn::InitializeL()
       
   129     {
       
   130     LOCBTNOTIFIERDEBUG( "CLocBtNotifierPlugIn::InitializeL : IN" );
       
   131     
       
   132     iGlobalNote = CAknGlobalNote::NewL();
       
   133     iConstantsManager = CLocBtNotifierConstantsManager::NewL();
       
   134  
       
   135     LOCBTNOTIFIERDEBUG( "CLocBtNotifierPlugIn::InitializeL : OUT" );
       
   136     }
       
   137 
       
   138 // ---------------------------------------------------------------------------
       
   139 // From class CCFActionPlugIn
       
   140 // CLocBtNotifierPlugIn::ExecuteL
       
   141 // ---------------------------------------------------------------------------
       
   142 //
       
   143 CCFActionPlugIn::TExecutionTime CLocBtNotifierPlugIn::ExecuteL(
       
   144                                 CCFActionIndication* aActionIndication )
       
   145     {
       
   146     LOCBTNOTIFIERDEBUG( "CLocBtNotifierPlugIn::ExecuteL : IN" );
       
   147     
       
   148     CCFActionPlugIn::TExecutionTime time = CCFActionPlugIn::ENone;
       
   149     
       
   150     // Parse PS key settings
       
   151     const RKeyValueArray& parameters = aActionIndication->Parameters();
       
   152     
       
   153     // Get the key and value of the action parameters
       
   154     TPtrC key( KNullDesC );
       
   155     TPtrC value( KNullDesC );
       
   156     
       
   157     key.Set( parameters[0]->Key() );
       
   158     value.Set( parameters[0]->Value() );
       
   159     
       
   160     // Check key value of the action parameter
       
   161     if( !( key.CompareF( KPsBatteryKeyState ) ) )
       
   162         {
       
   163         // Handle the Battery Key State change events
       
   164         HandleBatteryKeyStateL( value );
       
   165         }	
       
   166     
       
   167     else if( !( key.CompareF ( KPsAntennaKeyState ) ) )
       
   168         {
       
   169         // Handle the Antenna key State change events
       
   170         HandleAntennaKeyStateL( value );
       
   171         }
       
   172         
       
   173     else if( !( key.CompareF ( KPsPowerKeyState ) ) )
       
   174         {
       
   175         // Handle the Power key State change events
       
   176         HandlePowerKeyStateL( value );
       
   177         }
       
   178        
       
   179     LOCBTNOTIFIERDEBUG( "CLocBtNotifierPlugIn::ExecuteL : OUT" );   
       
   180     
       
   181     return time;
       
   182     }
       
   183     
       
   184 // ---------------------------------------------------------------------------
       
   185 // From class CCFActionPlugIn
       
   186 // CLocBtNotifierPlugIn::GetActionsL
       
   187 // ---------------------------------------------------------------------------
       
   188 //
       
   189 void CLocBtNotifierPlugIn::GetActionsL( CDesCArray& aActionList ) const
       
   190     {
       
   191     LOCBTNOTIFIERDEBUG( "CLocBtNotifierPlugIn::GetActionsL : IN" );
       
   192     
       
   193     aActionList.AppendL( KLocBtNotifierAction );
       
   194     
       
   195     LOCBTNOTIFIERDEBUG( "CLocBtNotifierPlugIn::GetActionsL : OUT" );
       
   196     }
       
   197     
       
   198 // ---------------------------------------------------------------------------
       
   199 // From class CCFActionPlugIn
       
   200 // CLocBtNotifierPlugIn::SecurityPolicy
       
   201 // ---------------------------------------------------------------------------
       
   202 //
       
   203 const TSecurityPolicy& CLocBtNotifierPlugIn::SecurityPolicy() const
       
   204     {
       
   205     return KSecurityPolicy;
       
   206     }
       
   207     
       
   208 // ---------------------------------------------------------------------------
       
   209 // CLocBtNotifierPlugIn::HandleBatteryKeyState
       
   210 // ---------------------------------------------------------------------------
       
   211 //
       
   212 void CLocBtNotifierPlugIn::HandleBatteryKeyStateL( TDesC& aValue )
       
   213     {
       
   214     LOCBTNOTIFIERDEBUG( "CLocBtNotifierPlugIn::HandleBatteryKeyState : IN" );
       
   215     
       
   216     // Current Battery State
       
   217     CLocBtNotifierPlugIn::TBtGpsPsyBatteryKeyState batteryState = 
       
   218                           CLocBtNotifierPlugIn::EBatteryStateUnInitialized ;
       
   219     
       
   220         
       
   221     // Get the current PS key state value
       
   222     if( !( aValue.CompareF( KBatteryStateNA ) ) )
       
   223         {    
       
   224         batteryState = CLocBtNotifierPlugIn::EBatteryStateNotApplicable;
       
   225         }
       
   226     else if( !( aValue.CompareF( KBatteryStateNormal ) ) )
       
   227         {
       
   228         batteryState = CLocBtNotifierPlugIn::EBatteryStateNormal;
       
   229         }
       
   230     else if( !( aValue.CompareF( KBatteryStateLow ) ) )
       
   231         {
       
   232     	batteryState = CLocBtNotifierPlugIn::EBatteryStateLow;
       
   233         }
       
   234     else if( !( aValue.CompareF( KBatteryStateFull ) ) )
       
   235         {
       
   236         batteryState = CLocBtNotifierPlugIn::EBatteryStateFull;
       
   237         }
       
   238     else
       
   239     	{
       
   240     	// Invalid
       
   241     	return;
       
   242     	}
       
   243     
       
   244     LOCBTNOTIFIERDEBUG1( "Battery State (%d)",  batteryState );
       
   245        
       
   246     
       
   247     if( iBatteryStatus == CLocBtNotifierPlugIn::EBatteryStateUnInitialized )
       
   248         {
       
   249         // Initializing the previous battery Status for the first callback   
       
   250         // from context framework
       
   251         iBatteryStatus = CLocBtNotifierPlugIn::EBatteryStateInitialized;
       
   252         
       
   253         LOCBTNOTIFIERDEBUG1( "Previous Battery State (%d)",  iBatteryStatus );
       
   254        
       
   255         return;
       
   256         }
       
   257     else if ( iBatteryStatus == CLocBtNotifierPlugIn::EBatteryStateInitialized 
       
   258               && batteryState != CLocBtNotifierPlugIn::EBatteryStateNotApplicable )
       
   259     	{
       
   260     	// Initializing the previous battery status to current value of PS key
       
   261         // after pairing of BT GPS device happens
       
   262     	iBatteryStatus = batteryState;
       
   263     	
       
   264       LOCBTNOTIFIERDEBUG1( "Previous Battery State (%d)",  iBatteryStatus );
       
   265        
       
   266     	return;
       
   267     	}   
       
   268      
       
   269      
       
   270     LOCBTNOTIFIERDEBUG1( "Previous Battery State (%d)",  iBatteryStatus );
       
   271                 
       
   272     //Check that there is a change in the Battery State before displaying the note
       
   273     if( iBatteryStatus != batteryState )
       
   274         {
       
   275        
       
   276         LOCBTNOTIFIERDEBUG1( "Previous Battery State (%d)",  iBatteryStatus );
       
   277             
       
   278        
       
   279         LOCBTNOTIFIERDEBUG1( "Battery State (%d)",  batteryState );
       
   280                
       
   281     	switch( batteryState )
       
   282     	    {
       
   283     	    case CLocBtNotifierPlugIn::EBatteryStateNotApplicable :
       
   284     	         {
       
   285     	         // No note shown
       
   286     	         break;
       
   287     	         }
       
   288     	         
       
   289     	    case CLocBtNotifierPlugIn::EBatteryStateNormal :
       
   290     	         {
       
   291     	         // No note shown
       
   292     	         iBatteryStatus = batteryState;
       
   293     	         break;
       
   294     	         }
       
   295     	         
       
   296     	    case CLocBtNotifierPlugIn::EBatteryStateLow :
       
   297     	         {
       
   298     	         iBatteryStatus = batteryState;
       
   299     	         ShowBatteryNoteL( batteryState );
       
   300     	         break;
       
   301     	         }
       
   302     	         
       
   303     	    case CLocBtNotifierPlugIn::EBatteryStateFull :
       
   304     	         {
       
   305     	         iBatteryStatus = batteryState;
       
   306     	         ShowBatteryNoteL( batteryState );
       
   307     	         break;
       
   308     	         }
       
   309     	         
       
   310     	    default :
       
   311     	         {
       
   312     	         break;
       
   313     	         }
       
   314     	    }
       
   315     	    
       
   316     	
       
   317     	
       
   318         }
       
   319       
       
   320     LOCBTNOTIFIERDEBUG1( "Previous Battery State (%d)",  iBatteryStatus );
       
   321              
       
   322     LOCBTNOTIFIERDEBUG( "CLocBtNotifierPlugIn::HandleBatteryKeyState : OUT" );
       
   323     }
       
   324     
       
   325     
       
   326 // ---------------------------------------------------------------------------
       
   327 // CLocBtNotifierPlugIn::ShowBatteryNoteL
       
   328 // ---------------------------------------------------------------------------
       
   329 //
       
   330 void CLocBtNotifierPlugIn::ShowBatteryNoteL( TBtGpsPsyBatteryKeyState aState )
       
   331     {
       
   332     LOCBTNOTIFIERDEBUG( "CLocBtNotifierPlugIn::ShowBatteryNoteL : IN" );
       
   333 	
       
   334 	// Check if the note can be shown
       
   335 	if( !( IsBatteryNoteShownL( aState ) ) )
       
   336 	    {
       
   337 	    return;
       
   338 	    }
       
   339 	    
       
   340 	switch( aState )
       
   341         {
       
   342         case CLocBtNotifierPlugIn::EBatteryStateLow : 
       
   343         	 {
       
   344         	 iInfoText.Set( iConstantsManager->GetBatteryLowDialogText() );
       
   345         	 break;            
       
   346         	 }
       
   347              
       
   348         case CLocBtNotifierPlugIn::EBatteryStateFull : 
       
   349              {
       
   350              iInfoText.Set( iConstantsManager->GetBatteryFullDialogText() );
       
   351              break;	
       
   352              }
       
   353              
       
   354         default :
       
   355              {
       
   356              break;
       
   357              } 
       
   358         }
       
   359     
       
   360     iGlobalNote->ShowNoteL( EAknGlobalInformationNote, iInfoText );    
       
   361     
       
   362     LOCBTNOTIFIERDEBUG( "CLocBtNotifierPlugIn::ShowBatteryNoteL : OUT" );
       
   363     }
       
   364     
       
   365     
       
   366 // ---------------------------------------------------------------------------
       
   367 // CLocBtNotifierPlugIn::IsBatteryNoteShown
       
   368 // ---------------------------------------------------------------------------
       
   369 //
       
   370 TBool CLocBtNotifierPlugIn::IsBatteryNoteShownL( TBtGpsPsyBatteryKeyState aState )
       
   371     {
       
   372     
       
   373     LOCBTNOTIFIERDEBUG( "CLocBtNotifierPlugIn::IsBatteryNoteShown : IN" );
       
   374 	
       
   375 	TBool shown = EFalse;
       
   376 	
       
   377 	switch( aState )
       
   378 	    {
       
   379 	    case CLocBtNotifierPlugIn::EBatteryStateLow :
       
   380 	         {
       
   381 	         IsDialogShownL( KBluetoothGpsPsyBatteryLowDialog, shown );
       
   382              break;	
       
   383              }
       
   384              
       
   385         case CLocBtNotifierPlugIn::EBatteryStateFull :
       
   386              {
       
   387              IsDialogShownL( KBluetoothGpsPsyBatteryFullDialog, shown );
       
   388              break;	
       
   389              }
       
   390              
       
   391         default :
       
   392              {
       
   393              break;
       
   394              }
       
   395 	         
       
   396 	    }
       
   397     LOCBTNOTIFIERDEBUG( "CLocBtNotifierPlugIn::IsBatteryNoteShown : OUT" );
       
   398 	
       
   399 	return shown;
       
   400     }
       
   401   
       
   402     
       
   403 // ---------------------------------------------------------------------------
       
   404 // CLocBtNotifierPlugIn::HandleAntennaKeyState
       
   405 // ---------------------------------------------------------------------------
       
   406 //
       
   407 void CLocBtNotifierPlugIn::HandleAntennaKeyStateL( TDesC& aValue )
       
   408     {
       
   409    LOCBTNOTIFIERDEBUG( "CLocBtNotifierPlugIn::HandleAntennaKeyState : IN" );
       
   410     
       
   411     // Current Antenna State
       
   412     CLocBtNotifierPlugIn::TBtGpsPsyAntennaKeyState antennaState = 
       
   413                           CLocBtNotifierPlugIn::EAntennaStateUnInitialized ;
       
   414                           
       
   415         
       
   416     // Get the current PS key state value
       
   417     if( !( aValue.CompareF( KExtAntennaNA ) ) )
       
   418         {
       
   419     	antennaState = CLocBtNotifierPlugIn::EAntennaStateNotApplicable;
       
   420         }
       
   421     else if( !( aValue.CompareF( KExtAntennaOff ) ) )
       
   422         {
       
   423     	antennaState = CLocBtNotifierPlugIn::EExtAntennaOff;
       
   424         }
       
   425     else if( !( aValue.CompareF( KExtAntennaOn ) ) )
       
   426         {
       
   427         antennaState = CLocBtNotifierPlugIn::EExtAntennaOn ;
       
   428         }
       
   429      else
       
   430     	{
       
   431     	// Invalid
       
   432     	return;
       
   433     	}
       
   434     
       
   435    LOCBTNOTIFIERDEBUG1( " Antenna State (%d)",  antennaState );
       
   436     
       
   437     if( iAntennaStatus == CLocBtNotifierPlugIn::EAntennaStateUnInitialized )
       
   438         {
       
   439         // Initializing the previous Antenna Status for the first callback   
       
   440         // from context framework
       
   441         iAntennaStatus = CLocBtNotifierPlugIn::EAntennaStateInitialized;
       
   442         
       
   443         LOCBTNOTIFIERDEBUG1( "Previous Antenna State (%d)",  iAntennaStatus );
       
   444 
       
   445         return;
       
   446         }
       
   447     else if ( iAntennaStatus == CLocBtNotifierPlugIn::EAntennaStateInitialized
       
   448               && antennaState != CLocBtNotifierPlugIn::EAntennaStateNotApplicable )
       
   449     	{
       
   450     	// Initializing the previous Antenna status to current value of PS key
       
   451         // after pairing of BT GPS device happens
       
   452     	iAntennaStatus = antennaState;
       
   453     	
       
   454     	LOCBTNOTIFIERDEBUG1( "Previous Antenna State (%d)",  iAntennaStatus );
       
   455         
       
   456     	return;
       
   457     	}   
       
   458             
       
   459     	LOCBTNOTIFIERDEBUG1( "Previous Antenna State (%d)",  iAntennaStatus );
       
   460          
       
   461     //Check that there is a change in the Antenna State before displaying the note
       
   462     if( iAntennaStatus != antennaState )
       
   463         {
       
   464         
       
   465         LOCBTNOTIFIERDEBUG1( "Previous Antenna State (%d)",  iAntennaStatus );
       
   466  
       
   467         
       
   468         LOCBTNOTIFIERDEBUG1( " Antenna State (%d)",  antennaState );
       
   469          
       
   470     	switch( antennaState )
       
   471     	    {
       
   472     	    case CLocBtNotifierPlugIn::EAntennaStateNotApplicable :
       
   473     	         {
       
   474     	         // No note shown
       
   475     	         break;
       
   476     	         }
       
   477     	         
       
   478     	    case CLocBtNotifierPlugIn::EExtAntennaOff :
       
   479     	         {
       
   480     	         iAntennaStatus = antennaState;
       
   481     	         ShowAntennaNoteL( antennaState );
       
   482     	         break;
       
   483     	         }
       
   484     	         
       
   485     	    case CLocBtNotifierPlugIn::EExtAntennaOn :
       
   486     	         {
       
   487     	         iAntennaStatus = antennaState;
       
   488     	         ShowAntennaNoteL( antennaState );
       
   489     	         break;
       
   490     	         }
       
   491     	         
       
   492     	    default :
       
   493     	         {
       
   494     	         break;
       
   495     	         }
       
   496     	    }
       
   497     	    
       
   498     	
       
   499         }
       
   500         
       
   501     	LOCBTNOTIFIERDEBUG1( "Previous Antenna State (%d)",  iAntennaStatus );
       
   502         
       
   503     LOCBTNOTIFIERDEBUG( "CLocBtNotifierPlugIn::HandleAntennaKeyState : OUT" );
       
   504     }
       
   505 
       
   506   
       
   507 // ---------------------------------------------------------------------------
       
   508 // CLocBtNotifierPlugIn::ShowAntennaNoteL
       
   509 // ---------------------------------------------------------------------------
       
   510 //
       
   511 void CLocBtNotifierPlugIn::ShowAntennaNoteL( TBtGpsPsyAntennaKeyState aState )
       
   512     {
       
   513     LOCBTNOTIFIERDEBUG( "CLocBtNotifierPlugIn::ShowAntennaNoteL : IN" );
       
   514 	
       
   515 	// Check if the note can be shown
       
   516 	if( !( IsAntennaNoteShownL( aState ) ) )
       
   517 	    {
       
   518 		return;
       
   519 	    }
       
   520 	    
       
   521 	switch( aState )
       
   522         {
       
   523         case CLocBtNotifierPlugIn::EExtAntennaOff : 
       
   524         	 {
       
   525         	 iInfoText.Set( iConstantsManager->GetExtAntennaDisconnectedDialogText() );
       
   526         	 break;            
       
   527         	 }
       
   528              
       
   529         case CLocBtNotifierPlugIn::EExtAntennaOn : 
       
   530              {
       
   531              iInfoText.Set( iConstantsManager->GetExtAntennaConnectedDialogText() );
       
   532              break;	
       
   533              }
       
   534              
       
   535         default :
       
   536              {
       
   537              break;
       
   538              } 
       
   539         }
       
   540     
       
   541     iGlobalNote->ShowNoteL( EAknGlobalInformationNote, iInfoText );    
       
   542     
       
   543     LOCBTNOTIFIERDEBUG( "CLocBtNotifierPlugIn::ShowAntennaNoteL : OUT" );
       
   544     } 
       
   545 
       
   546     
       
   547     
       
   548 // ---------------------------------------------------------------------------
       
   549 // CLocBtNotifierPlugIn::IsAntennaNoteShown
       
   550 // ---------------------------------------------------------------------------
       
   551 //
       
   552 TBool CLocBtNotifierPlugIn::IsAntennaNoteShownL( TBtGpsPsyAntennaKeyState aState )
       
   553     {
       
   554     LOCBTNOTIFIERDEBUG( "CLocBtNotifierPlugIn::IsAntennaNoteShown : IN" );
       
   555 	
       
   556 	TBool shown = EFalse;
       
   557 	
       
   558 	switch( aState )
       
   559 	    {
       
   560 	    case CLocBtNotifierPlugIn::EExtAntennaOff :
       
   561 	         {
       
   562              IsDialogShownL( KBluetoothGpsPsyExtAntennaDisconnectedDialog, shown );
       
   563              break;	
       
   564              }
       
   565              
       
   566         case CLocBtNotifierPlugIn::EExtAntennaOn :
       
   567              {
       
   568              IsDialogShownL( KBluetoothGpsPsyExtAntennaConnectedDialog, shown );
       
   569              break;	
       
   570              }
       
   571              
       
   572         default :
       
   573              {
       
   574              break;
       
   575              }
       
   576 	         
       
   577 	    }
       
   578     
       
   579  LOCBTNOTIFIERDEBUG( "CLocBtNotifierPlugIn::IsAntennaNoteShown : OUT" );
       
   580 	
       
   581 	return shown;
       
   582     }
       
   583 
       
   584 
       
   585 // ---------------------------------------------------------------------------
       
   586 // CLocBtNotifierPlugIn::HandlePowerKeyState
       
   587 // ---------------------------------------------------------------------------
       
   588 //
       
   589 void CLocBtNotifierPlugIn::HandlePowerKeyStateL( TDesC& aValue )
       
   590     {
       
   591   LOCBTNOTIFIERDEBUG( "CLocBtNotifierPlugIn::HandlePowerKeyState : IN" );
       
   592     
       
   593     // Current Power State
       
   594     CLocBtNotifierPlugIn::TBtGpsPsyPowerKeyState powerState = 
       
   595                           CLocBtNotifierPlugIn::EPowerStateUnInitialized ;
       
   596                           
       
   597         
       
   598     // Get the current PS key state value
       
   599     if( !( aValue.CompareF( KExtPowerNA ) ) )
       
   600         {
       
   601     	powerState = CLocBtNotifierPlugIn::EPowerStateNotApplicable;
       
   602         }
       
   603     else if( !( aValue.CompareF( KExtPowerOff ) ) )
       
   604         {
       
   605     	powerState = CLocBtNotifierPlugIn::EExtPowerOff;
       
   606         }
       
   607     else if( !( aValue.CompareF( KExtPowerOn ) ) )
       
   608         {
       
   609         powerState = CLocBtNotifierPlugIn::EExtPowerOn;
       
   610         }
       
   611     else
       
   612     	{
       
   613     	// Invalid
       
   614     	return;
       
   615     	}
       
   616     
       
   617    LOCBTNOTIFIERDEBUG1( "Power State (%d)",  powerState );
       
   618  
       
   619     if( iPowerStatus == CLocBtNotifierPlugIn::EPowerStateUnInitialized )
       
   620         {
       
   621         // Initializing the previous Power Status for the first callback   
       
   622         // from context framework
       
   623         iPowerStatus = CLocBtNotifierPlugIn::EPowerStateInitialized;
       
   624         
       
   625         	LOCBTNOTIFIERDEBUG1( "Previous Power State (%d)",  iPowerStatus );
       
   626 
       
   627         return;
       
   628         }
       
   629     else if ( iPowerStatus == CLocBtNotifierPlugIn::EPowerStateInitialized
       
   630               && powerState != CLocBtNotifierPlugIn::EPowerStateNotApplicable )
       
   631     	{
       
   632     	// Initializing the previous Power status to current value of PS key
       
   633         // after pairing of BT GPS device happens
       
   634     	iPowerStatus = powerState;
       
   635     	
       
   636       LOCBTNOTIFIERDEBUG1( "Previous Power State (%d)",  iPowerStatus );
       
   637 
       
   638     	return;
       
   639     	}   
       
   640     	
       
   641     	LOCBTNOTIFIERDEBUG1( "Previous Power State (%d)",  iPowerStatus );
       
   642              
       
   643     //Check that there is a change in the Power State before displaying the note
       
   644     if( iPowerStatus != powerState )
       
   645         {
       
   646         
       
   647         LOCBTNOTIFIERDEBUG1( "Previous Power State (%d)",  iPowerStatus );
       
   648  
       
   649         LOCBTNOTIFIERDEBUG1( " Power State (%d)",  powerState );
       
   650        
       
   651     	switch( powerState )
       
   652     	    {
       
   653     	    case CLocBtNotifierPlugIn::EPowerStateNotApplicable :
       
   654     	         {
       
   655     	         // No note shown
       
   656     	         break;
       
   657     	         }
       
   658     	         
       
   659     	    case CLocBtNotifierPlugIn::EExtPowerOff :
       
   660     	         {
       
   661     	         iPowerStatus = powerState;
       
   662     	         ShowPowerNoteL( powerState );
       
   663     	         break;
       
   664     	         }
       
   665     	         
       
   666     	    case EExtPowerOn :
       
   667     	         {
       
   668     	         iPowerStatus = powerState;
       
   669     	         ShowPowerNoteL( powerState );
       
   670     	         break;
       
   671     	         }
       
   672     	         
       
   673     	    default :
       
   674     	         {
       
   675     	         break;
       
   676     	         }
       
   677     	    }
       
   678     	    
       
   679     	
       
   680         }
       
   681       	
       
   682       	LOCBTNOTIFIERDEBUG1( "Previous Power State (%d)",  iPowerStatus );
       
   683          
       
   684     LOCBTNOTIFIERDEBUG( "CLocBtNotifierPlugIn::HandlePowerKeyState : OUT" );
       
   685     }
       
   686 
       
   687   
       
   688 // ---------------------------------------------------------------------------
       
   689 // CLocBtNotifierPlugIn::ShowPowerNoteL
       
   690 // ---------------------------------------------------------------------------
       
   691 //
       
   692 void CLocBtNotifierPlugIn::ShowPowerNoteL( TBtGpsPsyPowerKeyState aState )
       
   693     {
       
   694     LOCBTNOTIFIERDEBUG( "CLocBtNotifierPlugIn::ShowPowerNoteL : IN" );
       
   695 	
       
   696 	// Check if the note can be shown
       
   697 	if( !( IsPowerNoteShownL( aState ) ) )
       
   698 	    {
       
   699 		return;
       
   700 	    }
       
   701 	    
       
   702 	switch( aState )
       
   703         {
       
   704         case CLocBtNotifierPlugIn::EExtPowerOff : 
       
   705         	 {
       
   706         	 iInfoText.Set( iConstantsManager->GetExtPowerDisconnectedDialogText() );
       
   707         	 break;            
       
   708         	 }
       
   709              
       
   710         case CLocBtNotifierPlugIn::EExtPowerOn : 
       
   711              {
       
   712              iInfoText.Set( iConstantsManager->GetExtPowerConnectedDialogText() );
       
   713              break;	
       
   714              }
       
   715              
       
   716         default :
       
   717              {
       
   718              break;
       
   719              } 
       
   720         }
       
   721     
       
   722     iGlobalNote->ShowNoteL( EAknGlobalInformationNote, iInfoText );    
       
   723         
       
   724     LOCBTNOTIFIERDEBUG( "CLocBtNotifierPlugIn::ShowPowerNoteL : OUT" );
       
   725     } 
       
   726 
       
   727     
       
   728     
       
   729 // ---------------------------------------------------------------------------
       
   730 // CLocBtNotifierPlugIn::IsPowerNoteShown
       
   731 // ---------------------------------------------------------------------------
       
   732 //
       
   733 TBool CLocBtNotifierPlugIn::IsPowerNoteShownL( TBtGpsPsyPowerKeyState aState )
       
   734     {
       
   735     LOCBTNOTIFIERDEBUG( "CLocBtNotifierPlugIn::IsPowerNoteShown : IN" );
       
   736 	
       
   737 	TBool shown = EFalse;
       
   738 	
       
   739 	switch( aState )
       
   740 	    {
       
   741 	    case CLocBtNotifierPlugIn::EExtPowerOff :
       
   742 	         {
       
   743 	         IsDialogShownL( KBluetoothGpsPsyExtPowerDisconnectedDialog, shown );
       
   744            break;	
       
   745              }
       
   746              
       
   747         case CLocBtNotifierPlugIn::EExtPowerOn :
       
   748              {
       
   749              IsDialogShownL( KBluetoothGpsPsyExtPowerConnectedDialog, shown  );
       
   750              break;	
       
   751              }
       
   752              
       
   753         default :
       
   754              {
       
   755              break;
       
   756              }
       
   757 	         
       
   758 	    }
       
   759 	    
       
   760     LOCBTNOTIFIERDEBUG( "CLocBtNotifierPlugIn::IsPowerNoteShown : OUT" );
       
   761 	
       
   762 	return shown;
       
   763     }
       
   764     
       
   765         
       
   766 // ---------------------------------------------------------------------------
       
   767 // CLocBtNotifierPlugIn::IsDialogShown
       
   768 // ---------------------------------------------------------------------------
       
   769 // 
       
   770 void CLocBtNotifierPlugIn::IsDialogShownL( TUint32 aKey , TBool& aShown )
       
   771     {
       
   772     LOCBTNOTIFIERDEBUG( "CLocBtNotifierPlugIn::IsDialogShown : IN" );
       
   773     
       
   774     // CRepository instance for accessing the BtGpsPsy settings
       
   775     CRepository* cenRep = CRepository::NewL( KCRUidLocBtGpsPsy );
       
   776     
       
   777         
       
   778     // Get the value of the specified Cen Rep key
       
   779     TInt err = cenRep->Get( aKey, aShown );
       
   780     
       
   781     if( err != KErrNone )
       
   782     // Failed to Get value of cenrep key,return error
       
   783         {
       
   784         User::Leave( err );
       
   785         }
       
   786     
       
   787     delete cenRep;
       
   788     
       
   789     LOCBTNOTIFIERDEBUG( "CLocBtNotifierPlugIn::IsDialogShown : OUT" );
       
   790     }
       
   791 
       
   792