phoneapp/phoneuicontrol/src/cphonenumberentrymanager.cpp
changeset 77 2be0b271d017
parent 72 c76a0b1755b9
equal deleted inserted replaced
72:c76a0b1755b9 77:2be0b271d017
    23 #include "cphonenumberentrymanager.h"
    23 #include "cphonenumberentrymanager.h"
    24 #include "mpeengineinfo.h"
    24 #include "mpeengineinfo.h"
    25 #include "mphoneviewcommandhandle.h"
    25 #include "mphoneviewcommandhandle.h"
    26 #include "mphonestatemachine.h"
    26 #include "mphonestatemachine.h"
    27 #include "mphonecustomization.h"
    27 #include "mphonecustomization.h"
    28 
    28 #include "cphonestate.h"
    29 #include "cphonecbamanager.h"
    29 
       
    30 #include "cphoneuicommandmanager.h"
    30 #include "cphonepubsubproxy.h"
    31 #include "cphonepubsubproxy.h"
    31 #include "cphonekeys.h"
    32 #include "cphonekeys.h"
    32 #include "tphonecmdparamstring.h"
    33 #include "tphonecmdparamstring.h"
    33 #include "tphonecmdparamboolean.h"
    34 #include "tphonecmdparamboolean.h"
    34 #include "tphonecmdparaminteger.h"
    35 #include "tphonecmdparaminteger.h"
    38 #include "phoneui.pan"
    39 #include "phoneui.pan"
    39 #include "phoneviewcommanddefinitions.h"
    40 #include "phoneviewcommanddefinitions.h"
    40 #include "phoneappcommands.hrh"
    41 #include "phoneappcommands.hrh"
    41 #include "phonelogger.h"
    42 #include "phonelogger.h"
    42 
    43 
    43 const TInt  KPhoneKeyStart            = 33;
       
    44 const TInt  KPhoneKeyEnd              = 127;
       
    45 
       
    46 // ======== MEMBER FUNCTIONS ========
    44 // ======== MEMBER FUNCTIONS ========
    47 
    45 
    48 // ---------------------------------------------------------------------------
    46 // ---------------------------------------------------------------------------
    49 // CPhoneNumberEntryManager::CPhoneNumberEntryManager
    47 // CPhoneNumberEntryManager::CPhoneNumberEntryManager
    50 // ---------------------------------------------------------------------------
    48 // ---------------------------------------------------------------------------
    52 CPhoneNumberEntryManager::CPhoneNumberEntryManager(
    50 CPhoneNumberEntryManager::CPhoneNumberEntryManager(
    53          CPhoneState* aState,
    51          CPhoneState* aState,
    54          MPhoneViewCommandHandle& aViewCommandHandle,
    52          MPhoneViewCommandHandle& aViewCommandHandle,
    55          MPhoneStateMachine& aStateMachine,
    53          MPhoneStateMachine& aStateMachine,
    56          MPhoneCustomization* aCustomization,
    54          MPhoneCustomization* aCustomization,
    57          CPhoneCbaManager& aCbaManager )
    55          CPhoneUiCommandManager& aUiCommandManager )
    58    : iState ( aState ),
    56    : iState ( aState ),
    59      iViewCommandHandle ( aViewCommandHandle ),
    57      iViewCommandHandle ( aViewCommandHandle ),
    60      iStateMachine ( aStateMachine ),
    58      iStateMachine ( aStateMachine ),
    61      iCustomization ( aCustomization ),
    59      iCustomization ( aCustomization ),
    62      iCbaManager ( aCbaManager ),
    60      iUiCommandManager ( aUiCommandManager ),
    63      iEnv( *CEikonEnv::Static() )
    61      iEnv( *CEikonEnv::Static() )
    64     {
    62     {
    65     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneNumberEntryManager::CPhoneNumberEntryManager() ");
    63     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneNumberEntryManager::CPhoneNumberEntryManager() ");
    66     }
    64     }
    67 
    65 
    68  // ---------------------------------------------------------------------------
    66 // ---------------------------------------------------------------------------
    69  // CPhoneNumberEntryManager::NewL
    67 // CPhoneNumberEntryManager::NewL
    70  // ---------------------------------------------------------------------------
    68 // ---------------------------------------------------------------------------
    71  //
    69 //
    72 CPhoneNumberEntryManager* CPhoneNumberEntryManager::NewL( 
    70 CPhoneNumberEntryManager* CPhoneNumberEntryManager::NewL( 
    73         CPhoneState* aState,
    71         CPhoneState* aState,
    74         MPhoneViewCommandHandle& aViewCommandHandle,
    72         MPhoneViewCommandHandle& aViewCommandHandle,
    75         MPhoneStateMachine& aStateMachine,
    73         MPhoneStateMachine& aStateMachine,
    76         MPhoneCustomization* aCustomization,
    74         MPhoneCustomization* aCustomization,
    77         CPhoneCbaManager& aCbaManager )
    75         CPhoneUiCommandManager& aUiCommandManager )
    78      {
    76      {
    79      __LOGMETHODSTARTEND( EPhoneControl, "CPhoneNumberEntryManager::NewL() ");
    77      __LOGMETHODSTARTEND( EPhoneControl, "CPhoneNumberEntryManager::NewL() ");
    80      CPhoneNumberEntryManager* self = new (ELeave) CPhoneNumberEntryManager(
    78      CPhoneNumberEntryManager* self = new (ELeave) CPhoneNumberEntryManager(
    81              aState,
    79              aState,
    82              aViewCommandHandle,
    80              aViewCommandHandle,
    83              aStateMachine,
    81              aStateMachine,
    84              aCustomization,
    82              aCustomization,
    85              aCbaManager );
    83              aUiCommandManager );
    86      
    84      
    87      CleanupStack::PushL( self );
    85      CleanupStack::PushL( self );
    88      self->ConstructL();
    86      self->ConstructL();
    89      CleanupStack::Pop( self );
    87      CleanupStack::Pop( self );
    90      
    88      
   114 
   112 
   115 // -----------------------------------------------------------
   113 // -----------------------------------------------------------
   116 // CPhoneNumberEntryManager::StoreNumberEntryContentL
   114 // CPhoneNumberEntryManager::StoreNumberEntryContentL
   117 // -----------------------------------------------------------
   115 // -----------------------------------------------------------
   118 //
   116 //
   119 void CPhoneNumberEntryManager::StoreNumberEntryContentL()
   117 EXPORT_C void CPhoneNumberEntryManager::StoreNumberEntryContentL()
   120     {
   118     {
   121     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneNumberEntryManager::StoreNumberEntryContentL( ) ");
   119     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneNumberEntryManager::StoreNumberEntryContentL( ) ");
   122     // Store the number entry content to cache
   120     // Store the number entry content to cache
   123     if ( !iNumberEntryContent )
   121     if ( !iNumberEntryContent )
   124         {
   122         {
   145 
   143 
   146 // -----------------------------------------------------------
   144 // -----------------------------------------------------------
   147 // CPhoneNumberEntryManager::IsNumberEntryContentStored
   145 // CPhoneNumberEntryManager::IsNumberEntryContentStored
   148 // -----------------------------------------------------------
   146 // -----------------------------------------------------------
   149 //
   147 //
   150 TBool CPhoneNumberEntryManager::IsNumberEntryContentStored()
   148 EXPORT_C TBool CPhoneNumberEntryManager::IsNumberEntryContentStored()
   151     {
   149     {
   152     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneNumberEntryManager::IsNumberEntryContentStored( ) ");
   150     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneNumberEntryManager::IsNumberEntryContentStored( ) ");
   153     return iNumberEntryContent ? ETrue : EFalse;
   151     return iNumberEntryContent ? ETrue : EFalse;
   154     }
   152     }
   155 
   153 
   156 // -----------------------------------------------------------
   154 // -----------------------------------------------------------
   157 // CPhoneNumberEntryManager::ClearNumberEntryContentCache
   155 // CPhoneNumberEntryManager::ClearNumberEntryContentCache
   158 // -----------------------------------------------------------
   156 // -----------------------------------------------------------
   159 //
   157 //
   160 void CPhoneNumberEntryManager::ClearNumberEntryContentCache()
   158 EXPORT_C void CPhoneNumberEntryManager::ClearNumberEntryContentCache()
   161     {
   159     {
   162     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneNumberEntryManager::ClearNumberEntryContentCache( ) ");
   160     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneNumberEntryManager::ClearNumberEntryContentCache( ) ");
   163     delete iNumberEntryContent;
   161     delete iNumberEntryContent;
   164     iNumberEntryContent = NULL;
   162     iNumberEntryContent = NULL;
   165     }
   163     }
   166 
       
   167  
   164  
   168 // -----------------------------------------------------------
   165 // -----------------------------------------------------------
   169 // CPhoneNumberEntryManager::SetNumberEntryVisibilityL
   166 // CPhoneNumberEntryManager::SetNumberEntryVisibilityL
   170 // -----------------------------------------------------------
   167 // -----------------------------------------------------------
   171 //
   168 //
   172 void CPhoneNumberEntryManager::SetNumberEntryVisibilityL( TPhoneCmdParamBoolean aVisible )
   169 EXPORT_C void CPhoneNumberEntryManager::SetNumberEntryVisibilityL( TBool aVisible )
   173     {
   170     {
   174     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneNumberEntryManager::SetNumberEntryVisibilityL( ) ");
   171     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneNumberEntryManager::SetNumberEntryVisibilityL( ) ");
   175     __PHONELOG1( EBasic, EPhoneControl, 
   172     __PHONELOG1( EBasic, EPhoneControl, 
   176             "CPhoneNumberEntryManager::SetNumberEntryVisibilityL : aVisible =%d", 
   173             "CPhoneNumberEntryManager::SetNumberEntryVisibilityL : aVisible =%d", 
   177             aVisible.Boolean() );
   174             aVisible );
   178     iViewCommandHandle.ExecuteCommandL( EPhoneViewSetNumberEntryVisible, &aVisible );
   175     TPhoneCmdParamBoolean booleanParam;
       
   176     booleanParam.SetBoolean( ETrue );
       
   177     if ( !aVisible )
       
   178         {
       
   179         booleanParam.SetBoolean( EFalse );
       
   180         }
       
   181     iViewCommandHandle.ExecuteCommandL( EPhoneViewSetNumberEntryVisible, &booleanParam );
   179     }
   182     }
   180 
   183 
   181 // -----------------------------------------------------------
   184 // -----------------------------------------------------------
   182 // CPhoneNumberEntryManager::IsNumberEntryUsedL
   185 // CPhoneNumberEntryManager::IsNumberEntryUsedL
   183 // -----------------------------------------------------------
   186 // -----------------------------------------------------------
   184 //
   187 //
   185 TBool CPhoneNumberEntryManager::IsNumberEntryUsedL() const
   188 EXPORT_C TBool CPhoneNumberEntryManager::IsNumberEntryUsedL() const
   186     {
   189     {
   187     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneNumberEntryManager::IsNumberEntryUsedL( ) ");
   190     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneNumberEntryManager::IsNumberEntryUsedL( ) ");
   188     return iViewCommandHandle.HandleCommandL(
   191     return iViewCommandHandle.HandleCommandL(
   189         EPhoneViewGetNumberEntryIsUsedStatus ) ==
   192         EPhoneViewGetNumberEntryIsUsedStatus ) ==
   190         EPhoneViewResponseSuccess;
   193         EPhoneViewResponseSuccess;
   192 
   195 
   193 // -----------------------------------------------------------
   196 // -----------------------------------------------------------
   194 // CPhoneNumberEntryManager::IsNumberEntryVisibleL
   197 // CPhoneNumberEntryManager::IsNumberEntryVisibleL
   195 // -----------------------------------------------------------
   198 // -----------------------------------------------------------
   196 //
   199 //
   197 TBool CPhoneNumberEntryManager::IsNumberEntryVisibleL() const
   200 EXPORT_C TBool CPhoneNumberEntryManager::IsNumberEntryVisibleL() const
   198     {
   201     {
   199     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneNumberEntryManager::IsNumberEntryVisibleL( ) ");
   202     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneNumberEntryManager::IsNumberEntryVisibleL( ) ");
   200     return iViewCommandHandle.HandleCommandL(
   203     return iViewCommandHandle.HandleCommandL(
   201         EPhoneViewGetNumberEntryIsVisibleStatus ) ==
   204         EPhoneViewGetNumberEntryIsVisibleStatus ) ==
   202         EPhoneViewResponseSuccess;
   205         EPhoneViewResponseSuccess;
   204 
   207 
   205 // -----------------------------------------------------------
   208 // -----------------------------------------------------------
   206 // CPhoneNumberEntryManager::PhoneNumberFromEntryLC()
   209 // CPhoneNumberEntryManager::PhoneNumberFromEntryLC()
   207 // -----------------------------------------------------------
   210 // -----------------------------------------------------------
   208 //
   211 //
   209 HBufC* CPhoneNumberEntryManager::PhoneNumberFromEntryLC() const
   212 EXPORT_C HBufC* CPhoneNumberEntryManager::PhoneNumberFromEntryLC() const
   210     {
   213     {
   211     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneNumberEntryManager::PhoneNumberFromEntryLC( ) ");
   214     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneNumberEntryManager::PhoneNumberFromEntryLC( ) ");
   212     HBufC* phoneNumber = HBufC::NewLC( KPhoneNumberEntryBufferSize );
   215     HBufC* phoneNumber = HBufC::NewLC( KPhoneNumberEntryBufferSize );
   213     TPtr ptr( phoneNumber->Des() );
   216     TPtr ptr( phoneNumber->Des() );
   214     TPhoneCmdParamString stringParam;
   217     TPhoneCmdParamString stringParam;
   217         EPhoneViewGetNumberFromEntry,
   220         EPhoneViewGetNumberFromEntry,
   218         &stringParam );
   221         &stringParam );
   219     return phoneNumber;
   222     return phoneNumber;
   220     }
   223     }
   221 
   224 
   222 // -----------------------------------------------------------------------------
       
   223 // CPhoneNumberEntryManager::IsValidAlphaNumericKey
       
   224 // Checks is the key event a number, a special character
       
   225 // or if VoIP is enabled some other character
       
   226 // -----------------------------------------------------------------------------
       
   227 //
       
   228 TBool CPhoneNumberEntryManager::IsValidAlphaNumericKey( 
       
   229         const TKeyEvent& aKeyEvent,
       
   230         TEventCode aEventCode )
       
   231     {
       
   232     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneNumberEntryManager::IsValidAlphaNumericKey( ) ");
       
   233     TBool ret(EFalse);
       
   234     const TBool numericKeyEntered( 
       
   235             CPhoneKeys::IsNumericKey( aKeyEvent, aEventCode ) );
       
   236     // a numeric key (1,2,3,4,6,7,8,9,0,+,*,p,w )
       
   237     // or
       
   238     // a letter from fullscreen qwerty, miniqwerty or handwriting
       
   239     // when voip is enabled.
       
   240     if ( numericKeyEntered
       
   241         || IsAlphanumericSupportedAndCharInput( aKeyEvent ) )
       
   242         {
       
   243         ret= ETrue;
       
   244         }
       
   245     return ret;
       
   246     }
       
   247 
       
   248 // -----------------------------------------------------------------------------
       
   249 // CPhoneNumberEntryManager::IsAlphanumericSupportedAndCharInput
       
   250 // -----------------------------------------------------------------------------
       
   251 //
       
   252 TBool CPhoneNumberEntryManager::IsAlphanumericSupportedAndCharInput(
       
   253         const TKeyEvent& aKeyEvent ) const
       
   254     {
       
   255     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneNumberEntryManager::IsAlphanumericSupportedAndCharInput( ) ");
       
   256     TBool ret = ( ( iCustomization &&
       
   257                  iCustomization->AllowAlphaNumericMode() ) &&
       
   258                  ( ( aKeyEvent.iScanCode >= KPhoneKeyStart &&
       
   259                      aKeyEvent.iScanCode <= KPhoneKeyEnd ) ||
       
   260                      aKeyEvent.iModifiers & EModifierSpecial ) );
       
   261     __PHONELOG1( EBasic, EPhoneControl, 
       
   262             "CPhoneNumberEntryManager::IsAlphanumericSupportedAndCharInput: %d", ret );
       
   263     return ret;
       
   264     }
       
   265 
       
   266 // -----------------------------------------------------------
       
   267 // CPhoneNumberEntryManager::HandleNumberEntryClearedL
       
   268 // -----------------------------------------------------------
       
   269 //
       
   270 void CPhoneNumberEntryManager::HandleNumberEntryClearedL()
       
   271     {
       
   272     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneNumberEntryManager::HandleNumberEntryClearedL( ) ");
       
   273     }
       
   274 
       
   275 // ---------------------------------------------------------
   225 // ---------------------------------------------------------
   276 // CPhoneNumberEntryManager::NumberEntryClearL
   226 // CPhoneNumberEntryManager::NumberEntryClearL
   277 // ---------------------------------------------------------
   227 // ---------------------------------------------------------
   278 //
   228 //
   279 void CPhoneNumberEntryManager::NumberEntryClearL() const
   229 EXPORT_C void CPhoneNumberEntryManager::NumberEntryClearL() const
   280     {
   230     {
   281     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneNumberEntryManager::NumberEntryClearL( ) ");
   231     __LOGMETHODSTARTEND( EPhoneControl, "CPhoneNumberEntryManager::NumberEntryClearL( ) ");
   282     iViewCommandHandle.ExecuteCommandL( EPhoneViewClearNumberEntryContent );
   232     iViewCommandHandle.ExecuteCommandL( EPhoneViewClearNumberEntryContent );
   283     }
   233     }
   284 
   234 
       
   235 // -----------------------------------------------------------
       
   236 // CPhoneNumberEntryManager::SetVisibilityIfNumberEntryUsedL
       
   237 // -----------------------------------------------------------
       
   238 //
       
   239 EXPORT_C TBool CPhoneNumberEntryManager::SetVisibilityIfNumberEntryUsedL(
       
   240         TBool aVisibility )
       
   241     {
       
   242     __LOGMETHODSTARTEND(EPhoneControl, 
       
   243             "CPhoneGsmInCall::SetVisibilityIfNumberEntryUsedL() ");
       
   244     TBool retValue(EFalse);
       
   245     if ( IsNumberEntryUsedL() )
       
   246         {
       
   247         TPhoneCmdParamBoolean booleanParam;
       
   248         booleanParam.SetBoolean( EFalse );
       
   249         if ( aVisibility )
       
   250             {
       
   251             booleanParam.SetBoolean( ETrue );
       
   252             }
       
   253         iViewCommandHandle.ExecuteCommandL( EPhoneViewSetNumberEntryVisible, &booleanParam );
       
   254         __PHONELOG1( EBasic, EPhoneControl, 
       
   255                     "SetVisibilityIfNumberEntryUsedL: %d", 
       
   256                     aVisibility );
       
   257         retValue = ETrue;
       
   258         }
       
   259     return retValue;
       
   260     }
       
   261 
       
   262 // -----------------------------------------------------------
       
   263 // CPhoneNumberEntryManager::RemoveNumberEntryIfVisibilityIsFalseL
       
   264 // -----------------------------------------------------------
       
   265 //
       
   266 EXPORT_C void CPhoneNumberEntryManager::RemoveNumberEntryIfVisibilityIsFalseL()
       
   267     {
       
   268     __LOGMETHODSTARTEND(EPhoneControl, 
       
   269                 "CPhoneNumberEntryManager::RemoveNumberEntryIfVisibilityIsFalseL() ");
       
   270     // Remove the number entry if it isn't DTMF dialer
       
   271     if ( !IsNumberEntryVisibleL() )
       
   272         {
       
   273         iViewCommandHandle.ExecuteCommandL( EPhoneViewRemoveNumberEntry );
       
   274         }
       
   275     }
       
   276 
       
   277 // -----------------------------------------------------------
       
   278 // CPhoneNumberEntryManager::RemoveNumberEntryIfVisibilityIsFalseL
       
   279 // -----------------------------------------------------------
       
   280 //
       
   281 EXPORT_C void CPhoneNumberEntryManager::ClearNumberEntryContentCacheIfContentStored()
       
   282     {
       
   283     __LOGMETHODSTARTEND(EPhoneControl, 
       
   284                     "CPhoneNumberEntryManager::ClearNumberEntryContentCacheIfContentStored() ");
       
   285     if ( IsNumberEntryContentStored() )
       
   286         {
       
   287         ClearNumberEntryContentCache();
       
   288         }
       
   289     }
       
   290 
       
   291 // ---------------------------------------------------------
       
   292 // CPhoneNumberEntryManager::CallFromNumberEntryL
       
   293 // ---------------------------------------------------------
       
   294 //
       
   295 EXPORT_C void CPhoneNumberEntryManager::CallFromNumberEntryL()
       
   296     {
       
   297     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneNumberEntryManager::CallFromNumberEntryL( ) ");
       
   298     __ASSERT_DEBUG( iStateMachine.PhoneEngineInfo(), Panic( EPhoneCtrlInvariant ) );
       
   299     if ( IsCustomizedDialerVisibleL() )
       
   300         {
       
   301         return;
       
   302         }
       
   303     HBufC* phoneNumber = PhoneNumberFromEntryLC();
       
   304     iStateMachine.PhoneEngineInfo()->SetPhoneNumber( *phoneNumber );
       
   305     if ( phoneNumber->Des().Length() < KPhoneValidPhoneNumberLength )
       
   306         {
       
   307         iViewCommandHandle.ExecuteCommandL( EPhoneViewRemoveNumberEntry );
       
   308         iState->HandleNumberEntryClearedL();
       
   309         }
       
   310     CleanupStack::PopAndDestroy( phoneNumber );
       
   311 
       
   312     if ( !iCustomization ||
       
   313          !iCustomization->HandleCallFromNumberEntryL() )
       
   314         {
       
   315         // Customization didn't handle call. Dial voice call
       
   316         // as normally
       
   317         iState->DialVoiceCallL();
       
   318         }
       
   319     }
       
   320 
       
   321 // -----------------------------------------------------------
       
   322 // CPhoneState::IsCustomizedDialerVisibleL()
       
   323 // -----------------------------------------------------------
       
   324 //
       
   325 EXPORT_C TBool CPhoneNumberEntryManager::IsCustomizedDialerVisibleL() const
       
   326     {
       
   327     __LOGMETHODSTARTEND(EPhoneControl, "CPhoneNumberEntryManager::IsCustomizedDialerVisibleL( ) ");
       
   328     return iViewCommandHandle.HandleCommandL(
       
   329         EPhoneIsCustomizedDialerVisible ) == EPhoneViewResponseSuccess;
       
   330     }