phoneapp/phoneuicontrol/src/cphoneaccessorybthandler.cpp
changeset 65 2a5d4ab426d3
parent 46 bc5a64e5bc3c
child 76 cfea66083b62
equal deleted inserted replaced
60:1eef62f5c541 65:2a5d4ab426d3
    99 // ---------------------------------------------------------
    99 // ---------------------------------------------------------
   100 //
   100 //
   101 void CPhoneAccessoryBTHandler::ShowBTAddressL()
   101 void CPhoneAccessoryBTHandler::ShowBTAddressL()
   102     {
   102     {
   103     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneAccessoryBTHandler::ShowBTAddressL( ) ");
   103     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneAccessoryBTHandler::ShowBTAddressL( ) ");
   104     if ( FeatureManager::FeatureSupported( KFeatureIdOnScreenDialer ))
   104     iViewCommandHandle->ExecuteCommandL( EPhoneViewClearNumberEntryContent );
   105         {
   105     
   106         iViewCommandHandle->ExecuteCommandL( EPhoneViewClearNumberEntryContent );                      
       
   107         }
       
   108     else
       
   109         {
       
   110         // Remove number entry from screen
       
   111         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );   
       
   112         }
       
   113      
       
   114     // Get BT address
       
   115     TBuf<KPhoneBtAddressTextLength> addressBuffer;
   106     TBuf<KPhoneBtAddressTextLength> addressBuffer;
   116 
   107     CPhoneCenRepProxy::Instance()->GetString( 
   117     CPhoneCenRepProxy::Instance()->GetString(             
       
   118         KCRUidBluetoothLocalDeviceAddress,
   108         KCRUidBluetoothLocalDeviceAddress,
   119         KBTLocalDeviceAddress,
   109         KBTLocalDeviceAddress,
   120         addressBuffer );
   110         addressBuffer );
   121     
       
   122     // BT address was empty. BT is not turned on.
   111     // BT address was empty. BT is not turned on.
   123     if ( addressBuffer.Length() == 0 )
   112     if ( addressBuffer.Length() == 0 )
   124         {
   113         {
   125         __PHONELOG( EBasic, EPhoneControl, "CPhoneAccessoryBTHandler::ShowBTAddressL.NoAddress" );
   114         __PHONELOG( EBasic, 
       
   115                 EPhoneControl, 
       
   116                 "CPhoneAccessoryBTHandler::ShowBTAddressL.NoAddress" );
   126         }
   117         }
   127 
       
   128     // So we got the address. Now we need the localised text:
   118     // So we got the address. Now we need the localised text:
   129     HBufC* buf = StringLoader::LoadLC( 
   119     HBufC* buf = StringLoader::LoadLC( 
   130         CPhoneMainResourceResolver::Instance()->
   120         CPhoneMainResourceResolver::Instance()->
   131         ResolveResourceID( EPhonePhoneBtDevAddress ) , 
   121         ResolveResourceID( EPhonePhoneBtDevAddress ) , 
   132         addressBuffer );
   122         addressBuffer );
   133         
       
   134     TPhoneCmdParamNote noteParam;
   123     TPhoneCmdParamNote noteParam;
   135     noteParam.SetType( EPhoneNoteCustom );
   124     noteParam.SetType( EPhoneNoteCustom );
   136     noteParam.SetResourceId( CPhoneMainResourceResolver::Instance()->
   125     noteParam.SetResourceId( CPhoneMainResourceResolver::Instance()->
   137         ResolveResourceID( EPhoneInformationWaitNote ) );
   126         ResolveResourceID( EPhoneInformationWaitNote ) );
   138     noteParam.SetText( *buf );
   127     noteParam.SetText( *buf );
   139 
   128     
   140     // Display note
       
   141     iViewCommandHandle->ExecuteCommandL( EPhoneViewShowNote, &noteParam );
   129     iViewCommandHandle->ExecuteCommandL( EPhoneViewShowNote, &noteParam );
   142     
   130     CleanupStack::PopAndDestroy( buf );
   143     CleanupStack::PopAndDestroy( buf );               
       
   144     }    
   131     }    
   145 
   132 
   146 // -----------------------------------------------------------
   133 // -----------------------------------------------------------
   147 // CPhoneAccessoryBTHandler::ShowBTLoopbackL
   134 // CPhoneAccessoryBTHandler::ShowBTLoopbackL
   148 // Handling for message EPEMessageShowBTLoopback.
   135 // Handling for message EPEMessageShowBTLoopback.
   150 // -----------------------------------------------------------
   137 // -----------------------------------------------------------
   151 //
   138 //
   152 void CPhoneAccessoryBTHandler::ShowBTLoopbackL()
   139 void CPhoneAccessoryBTHandler::ShowBTLoopbackL()
   153     {
   140     {
   154     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneAccessoryBTHandler::ShowBTLoopbackL( ) ");
   141     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneAccessoryBTHandler::ShowBTLoopbackL( ) ");
   155     if ( FeatureManager::FeatureSupported( KFeatureIdOnScreenDialer ))
   142     iViewCommandHandle->ExecuteCommandL( EPhoneViewClearNumberEntryContent );
   156         {
   143     // Get current status of BT loopback
   157         iViewCommandHandle->ExecuteCommandL( EPhoneViewClearNumberEntryContent );                      
       
   158         }
       
   159     else
       
   160         {
       
   161         // Remove number entry from screen
       
   162         iViewCommandHandle->ExecuteCommandL( EPhoneViewRemoveNumberEntry );   
       
   163         }
       
   164     TInt btLoopback( EBTDutOff );
   144     TInt btLoopback( EBTDutOff );
   165 
   145     TInt err = RProperty::Get( 
   166     // Get current status of BT loopback
   146             KPSUidBluetoothDutMode, 
   167     TInt err = RProperty::Get( KPSUidBluetoothDutMode, KBTDutEnabled, 
   147             KBTDutEnabled, 
   168         btLoopback );
   148             btLoopback );
   169 
       
   170     // If loopback was disabled enable it. According to current knowledge
   149     // If loopback was disabled enable it. According to current knowledge
   171     // disabling BT test loop is not possible. If error getting the value
   150     // disabling BT test loop is not possible. If error getting the value
   172     // assume that it is disabled.
   151     // assume that it is disabled.
   173     if ( btLoopback == EBTDutOff || err != KErrNone )
   152     if ( btLoopback == EBTDutOff || err != KErrNone )
   174         {
   153         {
   179         if( !err )
   158         if( !err )
   180             {
   159             {
   181             btLoopback = EBTDutOn;
   160             btLoopback = EBTDutOn;
   182             }
   161             }
   183         }
   162         }
   184 
   163     // Get localised text according to setting status
   185     HBufC* btLoopbackString( NULL );
   164     HBufC* btLoopbackString( NULL );
   186 
       
   187     // Get localised text according to setting status
       
   188     btLoopbackString = StringLoader::LoadLC( 
   165     btLoopbackString = StringLoader::LoadLC( 
   189         CPhoneMainResourceResolver::Instance()->
   166         CPhoneMainResourceResolver::Instance()->
   190         ResolveResourceID( btLoopback == EBTDutOn ? 
   167         ResolveResourceID( btLoopback == EBTDutOn ? 
   191         EPhoneBtLoopbackEnabled : EPhoneBtLoopbackDisabled ) );
   168         EPhoneBtLoopbackEnabled : EPhoneBtLoopbackDisabled ) );
   192 
       
   193     TPhoneCmdParamNote noteParam;
   169     TPhoneCmdParamNote noteParam;
   194     noteParam.SetType( EPhoneNoteCustom );
   170     noteParam.SetType( EPhoneNoteCustom );
   195     noteParam.SetResourceId( CPhoneMainResourceResolver::Instance()->
   171     noteParam.SetResourceId( CPhoneMainResourceResolver::Instance()->
   196         ResolveResourceID( EPhoneInformationWaitNote ) );
   172         ResolveResourceID( EPhoneInformationWaitNote ) );
   197     noteParam.SetText( *btLoopbackString );
   173     noteParam.SetText( *btLoopbackString );
   198     noteParam.SetTone( CAknNoteDialog::EConfirmationTone );
   174     noteParam.SetTone( CAknNoteDialog::EConfirmationTone );
   199 
   175 
   200     // Display note
       
   201     iViewCommandHandle->ExecuteCommandL( EPhoneViewShowNote, &noteParam );
   176     iViewCommandHandle->ExecuteCommandL( EPhoneViewShowNote, &noteParam );
   202 
       
   203     CleanupStack::PopAndDestroy( btLoopbackString );
   177     CleanupStack::PopAndDestroy( btLoopbackString );
   204     }
   178     }
   205 
   179 
   206 // -----------------------------------------------------------
   180 // -----------------------------------------------------------
   207 // CPhoneAccessoryBTHandler::ShowBTActivatedL
   181 // CPhoneAccessoryBTHandler::ShowBTActivatedL
   212     {
   186     {
   213     // Get localised text 
   187     // Get localised text 
   214     HBufC* buf = StringLoader::LoadLC( 
   188     HBufC* buf = StringLoader::LoadLC( 
   215             CPhoneMainResourceResolver::Instance()->
   189             CPhoneMainResourceResolver::Instance()->
   216             ResolveResourceID( EPhoneInfoBTAccActivated ) );
   190             ResolveResourceID( EPhoneInfoBTAccActivated ) );
   217     
       
   218     TPhoneCmdParamNote noteParam;
   191     TPhoneCmdParamNote noteParam;
   219     noteParam.SetType( EPhoneNoteConfirmation );
   192     noteParam.SetType( EPhoneNoteConfirmation );
   220     noteParam.SetText( *buf );
   193     noteParam.SetText( *buf );
   221 
       
   222     // Display note
       
   223     iViewCommandHandle->ExecuteCommandL( EPhoneViewShowNote, &noteParam );
   194     iViewCommandHandle->ExecuteCommandL( EPhoneViewShowNote, &noteParam );
   224     CleanupStack::PopAndDestroy( buf );
   195     CleanupStack::PopAndDestroy( buf );
   225     }
   196     }
   226 
   197 
   227 // ---------------------------------------------------------
   198 // ---------------------------------------------------------
   230 //
   201 //
   231 TBool CPhoneAccessoryBTHandler::DoSetHandsfreeModeL( 
   202 TBool CPhoneAccessoryBTHandler::DoSetHandsfreeModeL( 
   232         TBool aHandsfreeMode, TPEAudioOutput aAudioOutput )
   203         TBool aHandsfreeMode, TPEAudioOutput aAudioOutput )
   233     {
   204     {
   234     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneAccessoryBTHandler::DoSetHandsfreeModeL( ) ");
   205     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneAccessoryBTHandler::DoSetHandsfreeModeL( ) ");
   235     __ASSERT_DEBUG( iStateMachine->PhoneEngineInfo(), 
   206     __ASSERT_DEBUG( iStateMachine->PhoneEngineInfo(), Panic( EPhoneCtrlInvariant ));
   236         Panic( EPhoneCtrlInvariant ));
   207     TBool allowed(EFalse);
   237  
       
   238     TBool allowed;
       
   239     // Only toggle the handsfree mode if there is no wired accessory connected
   208     // Only toggle the handsfree mode if there is no wired accessory connected
   240     if( iStateMachine->PhoneEngineInfo()->AudioOutput() != EPEWiredAudioAccessory )
   209     if( iStateMachine->PhoneEngineInfo()->AudioOutput() != EPEWiredAudioAccessory )
   241         {
   210         {
   242         TBool showNote = aHandsfreeMode || 
   211         iStateMachine->PhoneEngineInfo()->
   243             !FeatureManager::FeatureSupported( KFeatureIdTouchCallHandling );
   212                 SetAudioOutputCommand( aAudioOutput, aHandsfreeMode );
   244 
   213         iStateMachine->
   245         iStateMachine->PhoneEngineInfo()->SetAudioOutputCommand( 
   214                 SendPhoneEngineMessage( MPEPhoneModel::EPEMessageSetAudioOutput );
   246             aAudioOutput, showNote );
       
   247         iStateMachine->SendPhoneEngineMessage( 
       
   248             MPEPhoneModel::EPEMessageSetAudioOutput );
       
   249         allowed = ETrue; 
   215         allowed = ETrue; 
   250         }
   216         }
   251     else
       
   252         {
       
   253         allowed = EFalse;   
       
   254         }
       
   255     return allowed;
   217     return allowed;
   256     }
   218     }
   257 
   219 
   258 //  End of File  
   220 //  End of File