phoneuis/dialer/src/cdialer.cpp
branchRCL_3
changeset 25 91c2fb4b78df
parent 19 544e34b3255a
child 31 ba54057fe027
equal deleted inserted replaced
19:544e34b3255a 25:91c2fb4b78df
   102 //
   102 //
   103 void CDialer::ConstructL( 
   103 void CDialer::ConstructL( 
   104     const CCoeControl& aContainer, 
   104     const CCoeControl& aContainer, 
   105     const TRect& aRect,
   105     const TRect& aRect,
   106     MPhoneDialerController* aController )
   106     MPhoneDialerController* aController )
   107     {    
   107     {
   108     DIALER_PRINT("CDialer::ConstructL<");	
   108     DIALER_PRINT("CDialer::ConstructL<");	
   109     LoadResourceL();    
   109     LoadResourceL();
   110     
   110     
   111     // set window
   111     // set window
   112     SetContainerWindowL( aContainer );
   112     SetContainerWindowL( aContainer );
   113     SetParent( const_cast<CCoeControl*>(&aContainer) );
   113     SetParent( const_cast<CCoeControl*>(&aContainer) );
   114 
   114 
   115     iNumberEntry = CDialerNumberEntry::NewL( *this );    
   115     iNumberEntry = CDialerNumberEntry::NewL( *this );
   116 
   116 
   117     iController = aController;
   117     iController = aController;
   118     
   118     
   119     iKeypadArea = CDialerKeyPadContainer::NewL( *this, EModeEasyDialing );    
   119     iKeypadArea = CDialerKeyPadContainer::NewL( *this, EModeEasyDialing );
   120     
   120     
   121     iToolbar = CDialerToolbarContainer::NewL( *this, iController );
   121     iToolbar = CDialerToolbarContainer::NewL( *this, iController );
   122 
   122 
   123     // try to create easydialing plugin. If plugin is not present, iEasydialer gets value NULL.
   123     // try to create easydialing plugin. If plugin is not present, iEasydialer gets value NULL.
   124     LoadEasyDialingPlugin();
   124     LoadEasyDialingPlugin();
   181         iController = aController;
   181         iController = aController;
   182         iToolbar->SetContentProviderL( iController );
   182         iToolbar->SetContentProviderL( iController );
   183         iNumberEntry->SetNumberEntryPromptTextL( iController->NumberEntryPromptTextL() );
   183         iNumberEntry->SetNumberEntryPromptTextL( iController->NumberEntryPromptTextL() );
   184         SizeChanged();
   184         SizeChanged();
   185         UpdateToolbar();
   185         UpdateToolbar();
       
   186         UpdateNumberEntryConfiguration();
   186         }
   187         }
   187     }
   188     }
   188 
   189 
   189 // ---------------------------------------------------------------------------
   190 // ---------------------------------------------------------------------------
   190 // CDialer::Controller
   191 // CDialer::Controller
   192 //
   193 //
   193 EXPORT_C MPhoneDialerController* CDialer::Controller()
   194 EXPORT_C MPhoneDialerController* CDialer::Controller()
   194     {
   195     {
   195     return iController;
   196     return iController;
   196     }
   197     }
   197             
   198 
   198 // ---------------------------------------------------------------------------
   199 // ---------------------------------------------------------------------------
   199 // CDialer::GetEasyDialingInterface
   200 // CDialer::GetEasyDialingInterface
   200 // ---------------------------------------------------------------------------
   201 // ---------------------------------------------------------------------------
   201 //
   202 //
   202 EXPORT_C CDialingExtensionInterface* CDialer::GetEasyDialingInterface() const
   203 EXPORT_C CDialingExtensionInterface* CDialer::GetEasyDialingInterface() const
   234         CSPSettings* serviceProviderSettings = NULL;
   235         CSPSettings* serviceProviderSettings = NULL;
   235         TRAPD( err, serviceProviderSettings = CSPSettings::NewL() );
   236         TRAPD( err, serviceProviderSettings = CSPSettings::NewL() );
   236         if ( !err )
   237         if ( !err )
   237             {
   238             {
   238             voipSupported = serviceProviderSettings->IsFeatureSupported( 
   239             voipSupported = serviceProviderSettings->IsFeatureSupported( 
   239                 ESupportInternetCallFeature );            
   240                 ESupportInternetCallFeature );
   240             delete serviceProviderSettings;
   241             delete serviceProviderSettings;
   241             }
   242             }
   242 
   243 
   243         if ( EasyDialingEnabled() || voipSupported )
   244         if ( EasyDialingEnabled() || voipSupported )
   244             {
   245             {
   252 // ---------------------------------------------------------------------------
   253 // ---------------------------------------------------------------------------
   253 // CDialer::RelayoutAndDraw
   254 // CDialer::RelayoutAndDraw
   254 // ---------------------------------------------------------------------------
   255 // ---------------------------------------------------------------------------
   255 //
   256 //
   256 EXPORT_C void CDialer::RelayoutAndDraw()
   257 EXPORT_C void CDialer::RelayoutAndDraw()
   257 	{
   258     {
   258 	if ( iIsUsed )
   259     if ( iIsUsed )
   259 		{
   260         {
   260 		SetSize( Size() );
   261         SetSize( Size() );
   261 		DrawDeferred();
   262         DrawDeferred();
   262 		UpdateToolbar();
   263         UpdateToolbar();
   263 		}
   264         }
   264 	}
   265     }
   265 
   266 
   266 // Methods from MNumberEntry
   267 // Methods from MNumberEntry
   267 
   268 
   268 // ---------------------------------------------------------------------------
   269 // ---------------------------------------------------------------------------
   269 // CDialer::CreateNumberEntry
   270 // CDialer::CreateNumberEntry
   273 //
   274 //
   274 void CDialer::CreateNumberEntry()
   275 void CDialer::CreateNumberEntry()
   275     {
   276     {
   276     DIALER_PRINT("CDialer::CreateNumberEntry<");
   277     DIALER_PRINT("CDialer::CreateNumberEntry<");
   277     
   278     
   278     iIsUsed = ETrue;    
   279     if ( !iIsUsed )
   279 
   280         {
   280     UpdateNumberEntryConfiguration();
   281         iIsUsed = ETrue;
   281     
   282         UpdateNumberEntryConfiguration();
   282     DIALER_PRINT("CDialer::CreateNumberEntry>");        
   283         }
   283     }
   284     
   284     
   285     DIALER_PRINT("CDialer::CreateNumberEntry>");
       
   286     }
       
   287 
   285 // ---------------------------------------------------------------------------
   288 // ---------------------------------------------------------------------------
   286 // CDialer::GetNumberEntry
   289 // CDialer::GetNumberEntry
   287 //  
   290 //  
   288 // ---------------------------------------------------------------------------
   291 // ---------------------------------------------------------------------------
   289 //
   292 //
   291     {
   294     {
   292     CCoeControl* control( NULL );
   295     CCoeControl* control( NULL );
   293     control = iNumberEntry->GetNumberEntry();
   296     control = iNumberEntry->GetNumberEntry();
   294     return control;
   297     return control;
   295     }
   298     }
   296     
   299 
   297 // ---------------------------------------------------------------------------
   300 // ---------------------------------------------------------------------------
   298 // CDialer::IsNumberEntryUsed
   301 // CDialer::IsNumberEntryUsed
   299 //  
   302 //  
   300 // ---------------------------------------------------------------------------
   303 // ---------------------------------------------------------------------------
   301 //
   304 //
   302 TBool CDialer::IsNumberEntryUsed() const
   305 TBool CDialer::IsNumberEntryUsed() const
   303     {
   306     {
   304     return iIsUsed;
   307     return iIsUsed;
   305     }
   308     }
   306     
   309 
   307 // ---------------------------------------------------------------------------
   310 // ---------------------------------------------------------------------------
   308 // CDialer::SetNumberEntryVisible
   311 // CDialer::SetNumberEntryVisible
   309 //  
   312 //  
   310 // ---------------------------------------------------------------------------
   313 // ---------------------------------------------------------------------------
   311 //
   314 //
   312 void CDialer::SetNumberEntryVisible( const TBool& /*aVisibility*/ )
   315 void CDialer::SetNumberEntryVisible( const TBool& /*aVisibility*/ )
   313     {
   316     {
   314     }
   317     }
   315     
   318 
   316 // ---------------------------------------------------------------------------
   319 // ---------------------------------------------------------------------------
   317 // CDialer::SetTextToNumberEntry
   320 // CDialer::SetTextToNumberEntry
   318 //  
   321 //  
   319 // ---------------------------------------------------------------------------
   322 // ---------------------------------------------------------------------------
   320 //
   323 //
   321 void CDialer::SetTextToNumberEntry( const TDesC& aDesC )
   324 void CDialer::SetTextToNumberEntry( const TDesC& aDesC )
   322     {
   325     {
   323     iNumberEntry->SetTextToNumberEntry( aDesC );
   326     iNumberEntry->SetTextToNumberEntry( aDesC );
   324     }
   327     }
   325     
   328 
   326 // ---------------------------------------------------------------------------
   329 // ---------------------------------------------------------------------------
   327 // CDialer::GetTextFromNumberEntry
   330 // CDialer::GetTextFromNumberEntry
   328 //  
   331 //  
   329 // ---------------------------------------------------------------------------
   332 // ---------------------------------------------------------------------------
   330 //
   333 //
   331 void CDialer::GetTextFromNumberEntry( TDes& aDes )
   334 void CDialer::GetTextFromNumberEntry( TDes& aDes )
   332     {
   335     {
   333     iNumberEntry->GetTextFromNumberEntry( aDes );
   336     iNumberEntry->GetTextFromNumberEntry( aDes );
   334     }
   337     }
   335     
   338 
   336 // ---------------------------------------------------------------------------
   339 // ---------------------------------------------------------------------------
   337 // CDialer::RemoveNumberEntry
   340 // CDialer::RemoveNumberEntry
   338 //  
   341 //  
   339 // ---------------------------------------------------------------------------
   342 // ---------------------------------------------------------------------------
   340 //
   343 //
   341 void CDialer::RemoveNumberEntry()
   344 void CDialer::RemoveNumberEntry()
   342     {
   345     {
   343     ResetEditorToDefaultValues();
   346     ResetEditorToDefaultValues();
       
   347     iVirtualKeyBoardOpen = EFalse;
       
   348     
   344     iIsUsed = EFalse;
   349     iIsUsed = EFalse;
   345 
   350 
   346     // easydialer change begins
   351     // easydialer change begins
   347     if (iEasyDialer)
   352     if (iEasyDialer)
   348         {
   353         {
   349         TRAP_IGNORE( iEasyDialer->HandleCommandL( EEasyDialingClosePopup ) );
   354         TRAP_IGNORE( iEasyDialer->HandleCommandL( EEasyDialingClosePopup );
       
   355                      iEasyDialer->HandleCommandL( EEasyDialingVkbClosed ) );
   350         iEasyDialer->Reset();
   356         iEasyDialer->Reset();
   351         }
   357         }
   352     // easydialer change ends
   358     // easydialer change ends
   353     }
   359     }
   354     
   360 
   355 // ---------------------------------------------------------------------------
   361 // ---------------------------------------------------------------------------
   356 // CDialer::ChangeEditorMode
   362 // CDialer::ChangeEditorMode
   357 //  
   363 //  
   358 // ---------------------------------------------------------------------------
   364 // ---------------------------------------------------------------------------
   359 //
   365 //
   361     {
   367     {
   362     TInt ret( KErrNotSupported );
   368     TInt ret( KErrNotSupported );
   363     ret = iNumberEntry->ChangeEditorMode( aDefaultMode );
   369     ret = iNumberEntry->ChangeEditorMode( aDefaultMode );
   364     return ret;
   370     return ret;
   365     }
   371     }
   366     
   372 
   367 // ---------------------------------------------------------------------------
   373 // ---------------------------------------------------------------------------
   368 // CDialer::OpenVKBL
   374 // CDialer::OpenVKBL
   369 //  
   375 //  
   370 // ---------------------------------------------------------------------------
   376 // ---------------------------------------------------------------------------
   371 //
   377 //
   373     {
   379     {
   374     iVirtualKeyBoardOpen = ETrue;
   380     iVirtualKeyBoardOpen = ETrue;
   375     UpdateEdwinState( EVirtualKeyboardEditor );
   381     UpdateEdwinState( EVirtualKeyboardEditor );
   376     
   382     
   377     iNumberEntry->HandleCommandL( EDialerCmdTouchInput );
   383     iNumberEntry->HandleCommandL( EDialerCmdTouchInput );
       
   384     if ( iEasyDialer )
       
   385         {
       
   386         iEasyDialer->HandleCommandL( EEasyDialingVkbOpened );
       
   387         }
   378     }
   388     }
   379 
   389 
   380 // ---------------------------------------------------------------------------
   390 // ---------------------------------------------------------------------------
   381 // CDialer::GetEditorMode
   391 // CDialer::GetEditorMode
   382 //  
   392 //  
   383 // ---------------------------------------------------------------------------
   393 // ---------------------------------------------------------------------------
   384 //
   394 //
   385 TInt CDialer::GetEditorMode() const
   395 TInt CDialer::GetEditorMode() const
   386     {
   396     {
   387     TBool vkbOpen = EdwinState()->Flags() & EAknEditorFlagTouchInputModeOpened;
   397     return ( iEditorType == ENumericEditor ) ? 
   388     return ( iQwertyMode || vkbOpen ) ? EAknEditorTextInputMode : 
   398         EAknEditorNumericInputMode : EAknEditorTextInputMode;
   389                                   EAknEditorNumericInputMode;
   399     }
   390     }
   400 
   391     
       
   392 // ---------------------------------------------------------------------------
   401 // ---------------------------------------------------------------------------
   393 // CDialer::ResetEditorToDefaultValues
   402 // CDialer::ResetEditorToDefaultValues
   394 //  
   403 //  
   395 // ---------------------------------------------------------------------------
   404 // ---------------------------------------------------------------------------
   396 //
   405 //
   397 void CDialer::ResetEditorToDefaultValues()
   406 void CDialer::ResetEditorToDefaultValues()
   398     {
   407     {
   399     iNumberEntry->ResetEditorToDefaultValues();
   408     iNumberEntry->ResetEditorToDefaultValues();
   400     }
   409     }
   401     
   410 
   402 // ---------------------------------------------------------------------------
   411 // ---------------------------------------------------------------------------
   403 // CDialer::SetNumberEntryPromptText
   412 // CDialer::SetNumberEntryPromptText
   404 //  
   413 //  
   405 // ---------------------------------------------------------------------------
   414 // ---------------------------------------------------------------------------
   406 //    
   415 //    
   425 //
   434 //
   426 EXPORT_C void CDialer::HandleQwertyModeChange( TInt aMode )
   435 EXPORT_C void CDialer::HandleQwertyModeChange( TInt aMode )
   427     {
   436     {
   428     iQwertyMode = aMode;
   437     iQwertyMode = aMode;
   429     UpdateNumberEntryConfiguration();
   438     UpdateNumberEntryConfiguration();
       
   439     if ( iEasyDialer && aMode )
       
   440         {
       
   441         TRAP_IGNORE( iEasyDialer->HandleCommandL( EEasyDialingVkbClosed ) );
       
   442         }
   430     }
   443     }
   431 
   444 
   432 // ---------------------------------------------------------
   445 // ---------------------------------------------------------
   433 // CDialer::HandleKeyboardLayoutChange
   446 // CDialer::HandleKeyboardLayoutChange
   434 // ---------------------------------------------------------
   447 // ---------------------------------------------------------
   532         {
   545         {
   533         count--;
   546         count--;
   534         }
   547         }
   535     return count;
   548     return count;
   536     }
   549     }
   537     
   550 
   538 // ---------------------------------------------------------------------------
   551 // ---------------------------------------------------------------------------
   539 // CDialer::ComponentControl(TInt aIndex) const
   552 // CDialer::ComponentControl(TInt aIndex) const
   540 //
   553 //
   541 // Returns contained control by given index.
   554 // Returns contained control by given index.
   542 // ---------------------------------------------------------------------------
   555 // ---------------------------------------------------------------------------
   558 
   571 
   559 // ---------------------------------------------------------------------------
   572 // ---------------------------------------------------------------------------
   560 // CDialer::FocusChanged
   573 // CDialer::FocusChanged
   561 // ---------------------------------------------------------------------------
   574 // ---------------------------------------------------------------------------
   562 //
   575 //
   563 void CDialer::FocusChanged(TDrawNow aDrawNow)
   576 void CDialer::FocusChanged( TDrawNow aDrawNow )
   564     {
   577     {
   565     if ( iEasyDialer )
   578     if ( iEasyDialer )
   566         {           
   579         {           
   567         // Number entry is set to focus if dialer is in focus and easydialing plugin
   580         // Number entry is set to focus if dialer is in focus and easydialing plugin
   568         // is not in focus.
   581         // is not in focus.
   569         TBool numberEntryFocus = IsFocused() && !iEasyDialer->IsFocused();
   582         TBool numberEntryFocus = IsFocused() && !iEasyDialer->IsFocused();
   570         iNumberEntry->SetFocus( numberEntryFocus, aDrawNow );
   583         iNumberEntry->SetFocus( numberEntryFocus, aDrawNow );
   571         }
   584         }
   572     else
   585     else
   573         {
   586         {
   574         iNumberEntry->SetFocus( IsFocused(), aDrawNow );    
   587         iNumberEntry->SetFocus( IsFocused(), aDrawNow );
   575         }
   588         }
   576     }
   589     }
   577     
   590 
   578 // ---------------------------------------------------------------------------
   591 // ---------------------------------------------------------------------------
   579 // CDialer::MakeVisible
   592 // CDialer::MakeVisible
   580 // ---------------------------------------------------------------------------
   593 // ---------------------------------------------------------------------------
   581 //
   594 //
   582 void CDialer::MakeVisible( TBool aVisible )
   595 void CDialer::MakeVisible( TBool aVisible )
   618         {
   631         {
   619         // Clear editor flags and report
   632         // Clear editor flags and report
   620         // edwin state changed.
   633         // edwin state changed.
   621         iVirtualKeyBoardOpen = EFalse;
   634         iVirtualKeyBoardOpen = EFalse;
   622         UpdateNumberEntryConfiguration();
   635         UpdateNumberEntryConfiguration();
       
   636         if ( iEasyDialer )
       
   637             {
       
   638             iEasyDialer->HandleCommandL( EEasyDialingVkbClosed );
       
   639             }
   623         }
   640         }
   624     }
   641     }
   625 
   642 
   626 // ---------------------------------------------------------------------------
   643 // ---------------------------------------------------------------------------
   627 // CDialer::HandleResourceChange
   644 // CDialer::HandleResourceChange
   677         {
   694         {
   678         ControlEnv()->DeleteResourceFile( iResourceOffset );
   695         ControlEnv()->DeleteResourceFile( iResourceOffset );
   679         iResourceOffset = 0;
   696         iResourceOffset = 0;
   680         }
   697         }
   681     }
   698     }
   682     
   699 
   683 // ---------------------------------------------------------------------------
   700 // ---------------------------------------------------------------------------
   684 // CDialer::ComponentControlForDialerMode
   701 // CDialer::ComponentControlForDialerMode
   685 // 
   702 // 
   686 // Returns contained control by given index in ohonedialer mode.
   703 // Returns contained control by given index in ohonedialer mode.
   687 //  
   704 //  
   737 //  
   754 //  
   738 // ---------------------------------------------------------------------------
   755 // ---------------------------------------------------------------------------
   739 //
   756 //
   740 void CDialer::UpdateEdwinState( TEditorType aType )
   757 void CDialer::UpdateEdwinState( TEditorType aType )
   741     {
   758     {
       
   759     iEditorType = aType;
   742     CAknEdwinState* edwinState = EdwinState();
   760     CAknEdwinState* edwinState = EdwinState();
   743     
   761     
   744     switch ( aType )
   762     switch ( aType )
   745         {
   763         {
   746         case ENumericEditor:
   764         case ENumericEditor:
   818 
   836 
   819     if ( error )
   837     if ( error )
   820         {
   838         {
   821         DIALER_PRINT( "CDialer::LoadEasyDialingPlugin, load failed" )
   839         DIALER_PRINT( "CDialer::LoadEasyDialingPlugin, load failed" )
   822                 
   840                 
   823         delete iEasyDialer;        
   841         delete iEasyDialer;
   824         iEasyDialer = NULL;
   842         iEasyDialer = NULL;
   825         
   843         
   826         delete iDialingExtensionObserver;
   844         delete iDialingExtensionObserver;
   827         iDialingExtensionObserver = NULL;
   845         iDialingExtensionObserver = NULL;
   828         }
   846         }
   845 // CDialer::LayoutNumberEntry
   863 // CDialer::LayoutNumberEntry
   846 // ---------------------------------------------------------------------------
   864 // ---------------------------------------------------------------------------
   847 //
   865 //
   848 void CDialer::LayoutNumberEntry( const TRect& aParent, TInt aVariety )
   866 void CDialer::LayoutNumberEntry( const TRect& aParent, TInt aVariety )
   849     {
   867     {
   850     // Use larger number entry if Easy dialing is not currently enabled.
   868     TAknLayoutRect neLayoutRect;
       
   869     neLayoutRect.LayoutRect( aParent, AknLayoutScalable_Apps::dia3_numentry_pane( aVariety ) );
       
   870     TRect neRect = neLayoutRect.Rect();
       
   871 
   851     if ( EasyDialingEnabled() )
   872     if ( EasyDialingEnabled() )
   852         {
   873         {
   853         iNumberEntry->SetOperationMode( EModeEasyDialing );
   874         iNumberEntry->SetOperationMode( EModeEasyDialing );
   854         AknLayoutUtils::LayoutControl(
   875         
   855             iNumberEntry, aParent, 
   876         // Layout doesn't define any margin between number entry and contact list.
   856             AknLayoutScalable_Apps::dia3_numentry_pane( aVariety ).LayoutLine() );
   877         // Add a small margin here.
       
   878         neRect.iTl.iY += 2;
   857         }
   879         }
   858     else
   880     else
   859         {
   881         {
   860         iNumberEntry->SetOperationMode( EModeDialer );
   882         iNumberEntry->SetOperationMode( EModeDialer );
   861         TAknLayoutRect neLayoutRect;
   883         
   862         neLayoutRect.LayoutRect( aParent, AknLayoutScalable_Apps::dia3_numentry_pane( aVariety ) );
   884         // Use rect which is an union of layout rects for ED and NE
   863         TAknLayoutRect edLayoutRect;
   885         TAknLayoutRect edLayoutRect;
   864         edLayoutRect.LayoutRect( aParent, AknLayoutScalable_Apps::dia3_listscroll_pane( aVariety ) );
   886         edLayoutRect.LayoutRect( aParent, AknLayoutScalable_Apps::dia3_listscroll_pane( aVariety ) );
   865 
   887         neRect.iTl.iY = edLayoutRect.Rect().iTl.iY;
   866         // create rect which is union of layout rects for ED and NE
   888         }
   867         TRect neRect( edLayoutRect.Rect().iTl, neLayoutRect.Rect().iBr );
   889 
   868 
   890     iNumberEntry->SetRect( neRect );
   869         iNumberEntry->SetRect( neRect );
       
   870         }
       
   871     }
   891     }
   872 
   892 
   873 // End of File
   893 // End of File