phoneuis/dialer/src/cdialer.cpp
branchRCL_3
changeset 81 c26cc2a7c548
parent 62 5266b1f337bd
equal deleted inserted replaced
73:e30d4a1b8bad 81:c26cc2a7c548
    50 #include "cdialertoolbarcontainer.h"
    50 #include "cdialertoolbarcontainer.h"
    51 
    51 
    52 /// ROM drive.
    52 /// ROM drive.
    53 _LIT( KDialerResourceFile, "dialer.rsc" );
    53 _LIT( KDialerResourceFile, "dialer.rsc" );
    54 
    54 
       
    55 // number entry, keypad area, easydialing, toolbar
       
    56 const TInt KContainedControlsInTelephonyMode = 4;
       
    57 
    55 
    58 
    56 // ========================= MEMBER FUNCTIONS ================================
    59 // ========================= MEMBER FUNCTIONS ================================
    57 
    60 
    58 // ---------------------------------------------------------------------------
    61 // ---------------------------------------------------------------------------
    59 // CDialer::NewL
    62 // CDialer::NewL
    91     delete iNumberEntry;
    94     delete iNumberEntry;
    92 
    95 
    93     delete iEasyDialer;
    96     delete iEasyDialer;
    94     delete iDialingExtensionObserver;
    97     delete iDialingExtensionObserver;
    95     delete iToolbar;
    98     delete iToolbar;
    96     
       
    97     iComponentControls.Close();
       
    98 
    99 
    99     UnLoadResources();
   100     UnLoadResources();
   100     DIALER_PRINT("CDialer::~CDialer>"); 
   101     DIALER_PRINT("CDialer::~CDialer>"); 
   101     }
   102     }
   102 
   103 
   117     // set window
   118     // set window
   118     SetContainerWindowL( aContainer );
   119     SetContainerWindowL( aContainer );
   119     SetParent( const_cast<CCoeControl*>(&aContainer) );
   120     SetParent( const_cast<CCoeControl*>(&aContainer) );
   120 
   121 
   121     iNumberEntry = CDialerNumberEntry::NewL( *this );
   122     iNumberEntry = CDialerNumberEntry::NewL( *this );
   122     iComponentControls.Append( iNumberEntry );
       
   123 
   123 
   124     iController = aController;
   124     iController = aController;
   125     
   125     
   126     // Keypad and toolbar are not used in small displays.
   126     iKeypadArea = CDialerKeyPadContainer::NewL( *this, EModeEasyDialing );
   127     if ( ! FeatureManager::FeatureSupported(  KFeatureIdFfSmallScreenTouch ) ) 
   127     
   128         {
   128     iToolbar = CDialerToolbarContainer::NewL( *this, iController );
   129         iKeypadArea = CDialerKeyPadContainer::NewL( *this, EModeEasyDialing );
       
   130         iComponentControls.Append( iKeypadArea );
       
   131         
       
   132         iToolbar = CDialerToolbarContainer::NewL( *this, iController );
       
   133         iComponentControls.Append( iToolbar );
       
   134         }
       
   135 
   129 
   136     // try to create easydialing plugin. If plugin is not present, iEasydialer gets value NULL.
   130     // try to create easydialing plugin. If plugin is not present, iEasydialer gets value NULL.
   137     LoadEasyDialingPlugin();
   131     LoadEasyDialingPlugin();
   138 
   132 
   139     iNumberEntry->SetEasyDialingPlugin( iEasyDialer );
   133     iNumberEntry->SetEasyDialingPlugin( iEasyDialer );
   153     #ifdef RD_SCALABLE_UI_V2
   147     #ifdef RD_SCALABLE_UI_V2
   154     if ( AknLayoutUtils::PenEnabled() )
   148     if ( AknLayoutUtils::PenEnabled() )
   155         {
   149         {
   156         User::LeaveIfError( iPeninputServer.Connect() );
   150         User::LeaveIfError( iPeninputServer.Connect() );
   157         iPeninputServer.AddPenUiActivationHandler( this, EPluginInputModeAll ); 
   151         iPeninputServer.AddPenUiActivationHandler( this, EPluginInputModeAll ); 
   158         iVirtualKeyBoardOpen = iPeninputServer.IsVisible();
       
   159         }
   152         }
   160     #endif
   153     #endif
   161     DIALER_PRINT("CDialer::ConstructL>");
   154     DIALER_PRINT("CDialer::ConstructL>");
   162     }
   155     }
   163 
   156 
   201     DIALER_PRINTF( "CDialer::SetControllerL, aController = %x", aController );
   194     DIALER_PRINTF( "CDialer::SetControllerL, aController = %x", aController );
   202     __ASSERT_DEBUG( aController, DialerPanic(EDialerPanicNullController) );
   195     __ASSERT_DEBUG( aController, DialerPanic(EDialerPanicNullController) );
   203     if ( aController && iController != aController )
   196     if ( aController && iController != aController )
   204         {
   197         {
   205         iController = aController;
   198         iController = aController;
   206         if ( iToolbar )
   199         iToolbar->SetContentProviderL( iController );
   207             {
       
   208             iToolbar->SetContentProviderL( iController );
       
   209             }
       
   210         iNumberEntry->SetNumberEntryPromptTextL( iController->NumberEntryPromptTextL() );
   200         iNumberEntry->SetNumberEntryPromptTextL( iController->NumberEntryPromptTextL() );
   211         SizeChanged();
   201         SizeChanged();
   212         UpdateToolbar();
   202         UpdateToolbar();
   213         UpdateNumberEntryConfiguration();
   203         UpdateNumberEntryConfiguration();
   214         }
   204         }
   243         {
   233         {
   244         TBool numAvailable = ( iNumberEntry->TextLength() > 0 );
   234         TBool numAvailable = ( iNumberEntry->TextLength() > 0 );
   245         iController->SetNumberEntryIsEmpty( !numAvailable );
   235         iController->SetNumberEntryIsEmpty( !numAvailable );
   246         iToolbar->UpdateButtonStates();
   236         iToolbar->UpdateButtonStates();
   247         iToolbar->DrawDeferred();
   237         iToolbar->DrawDeferred();
   248         
   238         iKeypadArea->DrawDeferred(); // needed to remove drawing problem from leftmost button column
   249         if ( iKeypadArea )
       
   250             {
       
   251             iKeypadArea->DrawDeferred(); // needed to remove drawing problem from leftmost button column
       
   252             }
       
   253         }
   239         }
   254     }
   240     }
   255 
   241 
   256 // ---------------------------------------------------------------------------
   242 // ---------------------------------------------------------------------------
   257 // CDialer::UpdateNumberEntryConfiguration
   243 // CDialer::UpdateNumberEntryConfiguration
   377 // ---------------------------------------------------------------------------
   363 // ---------------------------------------------------------------------------
   378 //
   364 //
   379 void CDialer::RemoveNumberEntry()
   365 void CDialer::RemoveNumberEntry()
   380     {
   366     {
   381     ResetEditorToDefaultValues();
   367     ResetEditorToDefaultValues();
       
   368     iVirtualKeyBoardOpen = EFalse;
   382     
   369     
   383     iIsUsed = EFalse;
   370     iIsUsed = EFalse;
   384 
   371 
   385     // easydialer change begins
   372     // easydialer change begins
   386     if (iEasyDialer)
   373     if (iEasyDialer)
   387         {
   374         {
   388         TRAP_IGNORE( iEasyDialer->HandleCommandL( EEasyDialingClosePopup ); );
   375         TRAP_IGNORE( iEasyDialer->HandleCommandL( EEasyDialingClosePopup );
       
   376                      iEasyDialer->HandleCommandL( EEasyDialingVkbClosed ) );
   389         iEasyDialer->Reset();
   377         iEasyDialer->Reset();
   390         }
   378         }
   391     // easydialer change ends
   379     // easydialer change ends
   392     }
   380     }
   393 
   381 
   408 //  
   396 //  
   409 // ---------------------------------------------------------------------------
   397 // ---------------------------------------------------------------------------
   410 //
   398 //
   411 void CDialer::OpenVkbL()
   399 void CDialer::OpenVkbL()
   412     {
   400     {
       
   401     iVirtualKeyBoardOpen = ETrue;
   413     UpdateEdwinState( EVirtualKeyboardEditor );
   402     UpdateEdwinState( EVirtualKeyboardEditor );
   414     
   403     
   415     iNumberEntry->HandleCommandL( EDialerCmdTouchInput );
   404     iNumberEntry->HandleCommandL( EDialerCmdTouchInput );
       
   405     if ( iEasyDialer )
       
   406         {
       
   407         iEasyDialer->HandleCommandL( EEasyDialingVkbOpened );
       
   408         }
   416     }
   409     }
   417 
   410 
   418 // ---------------------------------------------------------------------------
   411 // ---------------------------------------------------------------------------
   419 // CDialer::GetEditorMode
   412 // CDialer::GetEditorMode
   420 //  
   413 //  
   451 //  
   444 //  
   452 // ---------------------------------------------------------------------------
   445 // ---------------------------------------------------------------------------
   453 //    
   446 //    
   454 void CDialer::EnableTactileFeedback( const TBool aEnable )
   447 void CDialer::EnableTactileFeedback( const TBool aEnable )
   455     {
   448     {
   456     if ( iKeypadArea )
   449     iKeypadArea->EnableTactileFeedback( aEnable );
   457         {
       
   458         iKeypadArea->EnableTactileFeedback( aEnable );
       
   459         }
       
   460     }
   450     }
   461 
   451 
   462 // ---------------------------------------------------------
   452 // ---------------------------------------------------------
   463 // CDialer::HandleQwertyModeChange
   453 // CDialer::HandleQwertyModeChange
   464 // ---------------------------------------------------------
   454 // ---------------------------------------------------------
   465 //
   455 //
   466 EXPORT_C void CDialer::HandleQwertyModeChange( TInt aMode )
   456 EXPORT_C void CDialer::HandleQwertyModeChange( TInt aMode )
   467     {
   457     {
   468     iQwertyMode = aMode;
   458     iQwertyMode = aMode;
   469     UpdateNumberEntryConfiguration();
   459     UpdateNumberEntryConfiguration();
       
   460     if ( iEasyDialer && aMode )
       
   461         {
       
   462         TRAP_IGNORE( iEasyDialer->HandleCommandL( EEasyDialingVkbClosed ) );
       
   463         }
   470     }
   464     }
   471 
   465 
   472 // ---------------------------------------------------------
   466 // ---------------------------------------------------------
   473 // CDialer::HandleKeyboardLayoutChange
   467 // CDialer::HandleKeyboardLayoutChange
   474 // ---------------------------------------------------------
   468 // ---------------------------------------------------------
   513 void CDialer::SizeChanged()
   507 void CDialer::SizeChanged()
   514     {
   508     {
   515     AknsUtils::RegisterControlPosition( this );
   509     AknsUtils::RegisterControlPosition( this );
   516     TRect parentRect( Rect() );
   510     TRect parentRect( Rect() );
   517        
   511        
       
   512     // Method is called before containers are created.
       
   513     if ( !iKeypadArea )
       
   514         {
       
   515         return;
       
   516         }
       
   517         
   518     TDialerVariety variety = ( Layout_Meta_Data::IsLandscapeOrientation() ?
   518     TDialerVariety variety = ( Layout_Meta_Data::IsLandscapeOrientation() ?
   519         EDialerVarietyLandscape : EDialerVarietyPortrait );
   519         EDialerVarietyLandscape : EDialerVarietyPortrait );
   520     
   520     
   521     
       
   522     // keypad area
   521     // keypad area
   523     if ( iKeypadArea ) 
   522     TDialerOperationMode keypadOpMode = 
   524         {
   523             ( EasyDialingEnabled() ? EModeEasyDialing : EModeDialer );
   525         TDialerOperationMode keypadOpMode = 
   524     iKeypadArea->SetOperationMode( keypadOpMode );
   526                 ( EasyDialingEnabled() ? EModeEasyDialing : EModeDialer );
   525     AknLayoutUtils::LayoutControl(
   527         
   526         iKeypadArea, parentRect, 
   528         iKeypadArea->SetOperationMode( keypadOpMode );
   527         AknLayoutScalable_Apps::dia3_keypad_num_pane( variety ).LayoutLine() );
   529         AknLayoutUtils::LayoutControl(
   528 
   530             iKeypadArea, parentRect, 
       
   531             AknLayoutScalable_Apps::dia3_keypad_num_pane( variety ).LayoutLine() );
       
   532         }
       
   533 
       
   534     
       
   535     // toolbar
   529     // toolbar
   536     if ( iToolbar )
   530     AknLayoutUtils::LayoutControl(
   537         {
   531         iToolbar, parentRect, 
   538         AknLayoutUtils::LayoutControl(
   532         AknLayoutScalable_Apps::dia3_keypad_fun_pane( variety ).LayoutLine() );
   539             iToolbar, parentRect, 
   533 
   540             AknLayoutScalable_Apps::dia3_keypad_fun_pane( variety ).LayoutLine() );
       
   541         }
       
   542 
       
   543     // Use hybrid keyboard mode if there is no visible virtual keypad.
       
   544     iHybridKeyboardMode = !iKeypadArea;
       
   545     
       
   546     // easy dial contacts list
   534     // easy dial contacts list
   547     if ( iEasyDialer )
   535     if ( iEasyDialer )
   548         {
   536         {
   549         AknLayoutUtils::LayoutControl(
   537         AknLayoutUtils::LayoutControl(
   550             iEasyDialer, parentRect, 
   538             iEasyDialer, parentRect, 
   551             AknLayoutScalable_Apps::dia3_listscroll_pane( variety ).LayoutLine() );
   539             AknLayoutScalable_Apps::dia3_listscroll_pane( variety ).LayoutLine() );
   552         
       
   553         iEasyDialer->SetKeyboardMode( 
       
   554             iHybridKeyboardMode ?
       
   555             CDialingExtensionInterface::EHybridQwerty :
       
   556             CDialingExtensionInterface::EDefaultKeyboard );
       
   557         }
   540         }
   558 
   541 
   559     // number entry
   542     // number entry
   560     LayoutNumberEntry( parentRect, variety );   
   543     LayoutNumberEntry( parentRect, variety );   
   561     }
   544     }
   575 // Returns contained controls in phone dialer mode
   558 // Returns contained controls in phone dialer mode
   576 // ---------------------------------------------------------------------------
   559 // ---------------------------------------------------------------------------
   577 //
   560 //
   578 TInt CDialer::CountComponentControls() const
   561 TInt CDialer::CountComponentControls() const
   579     {
   562     {
   580     return iComponentControls.Count();
   563     TInt count( KContainedControlsInTelephonyMode );
       
   564     
       
   565     if ( !iEasyDialer )
       
   566         {
       
   567         count--;
       
   568         }
       
   569     return count;
   581     }
   570     }
   582 
   571 
   583 // ---------------------------------------------------------------------------
   572 // ---------------------------------------------------------------------------
   584 // CDialer::ComponentControl(TInt aIndex) const
   573 // CDialer::ComponentControl(TInt aIndex) const
   585 //
   574 //
   586 // Returns contained control by given index.
   575 // Returns contained control by given index.
   587 // ---------------------------------------------------------------------------
   576 // ---------------------------------------------------------------------------
   588 //
   577 //
   589 CCoeControl* CDialer::ComponentControl( TInt aIndex ) const
   578 CCoeControl* CDialer::ComponentControl( TInt aIndex ) const
   590     {
   579     {
   591     return iComponentControls[ aIndex ];
   580     CCoeControl* currentControl(NULL);
       
   581     currentControl = ComponentControlForDialerMode( aIndex );
       
   582     return currentControl;
   592     } 
   583     } 
   593 
   584 
   594 // ---------------------------------------------------------------------------
   585 // ---------------------------------------------------------------------------
   595 // CDialer::Draw
   586 // CDialer::Draw
   596 // ---------------------------------------------------------------------------
   587 // ---------------------------------------------------------------------------
   659     {
   650     {
   660     if ( iVirtualKeyBoardOpen )
   651     if ( iVirtualKeyBoardOpen )
   661         {
   652         {
   662         // Clear editor flags and report
   653         // Clear editor flags and report
   663         // edwin state changed.
   654         // edwin state changed.
       
   655         iVirtualKeyBoardOpen = EFalse;
   664         UpdateNumberEntryConfiguration();
   656         UpdateNumberEntryConfiguration();
       
   657         if ( iEasyDialer )
       
   658             {
       
   659             iEasyDialer->HandleCommandL( EEasyDialingVkbClosed );
       
   660             }
   665         }
   661         }
   666     }
   662     }
   667 
   663 
   668 // ---------------------------------------------------------------------------
   664 // ---------------------------------------------------------------------------
   669 // CDialer::HandleResourceChange
   665 // CDialer::HandleResourceChange
   719         {
   715         {
   720         ControlEnv()->DeleteResourceFile( iResourceOffset );
   716         ControlEnv()->DeleteResourceFile( iResourceOffset );
   721         iResourceOffset = 0;
   717         iResourceOffset = 0;
   722         }
   718         }
   723     }
   719     }
       
   720 
       
   721 // ---------------------------------------------------------------------------
       
   722 // CDialer::ComponentControlForDialerMode
       
   723 // 
       
   724 // Returns contained control by given index in ohonedialer mode.
       
   725 //  
       
   726 // ---------------------------------------------------------------------------
       
   727 //
       
   728 CCoeControl* CDialer::ComponentControlForDialerMode( const TInt aIndex ) const
       
   729     {
       
   730     CCoeControl* currentControl(NULL);
       
   731     
       
   732     switch ( aIndex )
       
   733         {
       
   734         case 0:
       
   735             currentControl = iNumberEntry;
       
   736             break;
       
   737         case 1:
       
   738             currentControl = iKeypadArea;
       
   739             break;
       
   740             
       
   741         case 2:
       
   742             currentControl = iToolbar;
       
   743             break;
       
   744         case 3:
       
   745             currentControl = iEasyDialer;
       
   746             break;
       
   747             
       
   748         default:
       
   749             {
       
   750             __ASSERT_DEBUG( EFalse, _L("CDialer::ComponentControl no such component defined"));
       
   751             }
       
   752         }
       
   753 
       
   754     return currentControl;
       
   755     } 
   724 
   756 
   725 // ---------------------------------------------------------------------------
   757 // ---------------------------------------------------------------------------
   726 // CDialer::EdwinState
   758 // CDialer::EdwinState
   727 // 
   759 // 
   728 // Returns edwin state of the editor.
   760 // Returns edwin state of the editor.
   762             {
   794             {
   763             TBool vkbOpen = edwinState->Flags() & EAknEditorFlagTouchInputModeOpened;
   795             TBool vkbOpen = edwinState->Flags() & EAknEditorFlagTouchInputModeOpened;
   764             TInt flags = EAknEditorFlagNoT9 | 
   796             TInt flags = EAknEditorFlagNoT9 | 
   765                          EAknEditorFlagLatinInputModesOnly |
   797                          EAknEditorFlagLatinInputModesOnly |
   766                          EAknEditorFlagSelectionVisible;
   798                          EAknEditorFlagSelectionVisible;
   767             
   799             edwinState->SetDefaultInputMode( EAknEditorTextInputMode );
   768             // Use numeric input mode if in hybrid mode and virtual keyboard
   800             edwinState->SetCurrentInputMode( EAknEditorTextInputMode );
   769             // is not open. This signals to AvKON that hybrid mode needs to
       
   770             // be used.
       
   771             TInt inputMode = ( iHybridKeyboardMode && !vkbOpen ) ?
       
   772                 EAknEditorNumericInputMode : EAknEditorTextInputMode;
       
   773             edwinState->SetDefaultInputMode( inputMode );
       
   774             edwinState->SetCurrentInputMode( inputMode );
       
   775             
   801             
   776             if ( EVirtualKeyboardEditor == aType || vkbOpen )
   802             if ( EVirtualKeyboardEditor == aType || vkbOpen )
   777                 {
   803                 {
   778                 // Indicators would be shown after closing VKB unless disabled
   804                 // Indicators would be shown after closing VKB unless disabled
   779                 // here.
   805                 // here.
   780                 flags = ( flags |= EAknEditorFlagNoEditIndicators );
   806                 flags = ( flags |= EAknEditorFlagNoEditIndicators );
       
   807                 }
       
   808             else
       
   809                 {
       
   810                 iVirtualKeyBoardOpen = EFalse;
   781                 }
   811                 }
   782             
   812             
   783             edwinState->SetFlags( flags );
   813             edwinState->SetFlags( flags );
   784             edwinState->SetPermittedInputModes( 
   814             edwinState->SetPermittedInputModes( 
   785                 EAknEditorNumericInputMode | EAknEditorTextInputMode );
   815                 EAknEditorNumericInputMode | EAknEditorTextInputMode );
   848             iEasyDialer = CDialingExtensionInterface::NewL();
   878             iEasyDialer = CDialingExtensionInterface::NewL();
   849             iEasyDialer->InitializeL( *this );
   879             iEasyDialer->InitializeL( *this );
   850             
   880             
   851             iDialingExtensionObserver = CDialingExtensionObserver::NewL( iEasyDialer, iNumberEntry, this );
   881             iDialingExtensionObserver = CDialingExtensionObserver::NewL( iEasyDialer, iNumberEntry, this );
   852             iEasyDialer->AddObserverL( iDialingExtensionObserver );
   882             iEasyDialer->AddObserverL( iDialingExtensionObserver );
   853             
       
   854             iComponentControls.Append( iEasyDialer );
       
   855             } );
   883             } );
   856     
   884     
   857         if ( error )
   885         if ( error )
   858             {
   886             {
   859             DIALER_PRINT( "CDialer::LoadEasyDialingPlugin, load failed" )
   887             DIALER_PRINT( "CDialer::LoadEasyDialingPlugin, load failed" )
   918 // ---------------------------------------------------------------------------
   946 // ---------------------------------------------------------------------------
   919 //
   947 //
   920 void CDialer::OnPeninputUiDeactivated()
   948 void CDialer::OnPeninputUiDeactivated()
   921     {
   949     {
   922     DIALER_PRINT( "CDialer::OnPeninputUiDeactivated" )
   950     DIALER_PRINT( "CDialer::OnPeninputUiDeactivated" )
   923     iVirtualKeyBoardOpen = EFalse;
       
   924     FocusChanged( EDrawNow );
   951     FocusChanged( EDrawNow );
   925     if ( iEasyDialer )
       
   926         {
       
   927         TRAP_IGNORE( iEasyDialer->HandleCommandL( EEasyDialingVkbClosed ) );
       
   928         }
       
   929     }
   952     }
   930 
   953 
   931 // ---------------------------------------------------------------------------
   954 // ---------------------------------------------------------------------------
   932 // CDialer::OnPeninputUiActivated
   955 // CDialer::OnPeninputUiActivated
   933 //
   956 //
   935 // ---------------------------------------------------------------------------
   958 // ---------------------------------------------------------------------------
   936 //
   959 //
   937 void CDialer::OnPeninputUiActivated()
   960 void CDialer::OnPeninputUiActivated()
   938     {
   961     {
   939     DIALER_PRINT( "CDialer::OnPeninputUiActivated" )
   962     DIALER_PRINT( "CDialer::OnPeninputUiActivated" )
   940     iVirtualKeyBoardOpen = ETrue;
       
   941     if ( iEasyDialer )
       
   942         {
       
   943         TRAP_IGNORE( iEasyDialer->HandleCommandL( EEasyDialingVkbOpened ) );
       
   944         }   
       
   945     }
   963     }
   946 // End of File
   964 // End of File