phoneuis/easydialing/src/easydialingplugin.cpp
branchRCL_3
changeset 6 38529f706030
parent 5 2a26698d78ba
child 7 544e34b3255a
equal deleted inserted replaced
5:2a26698d78ba 6:38529f706030
    73 #endif
    73 #endif
    74 
    74 
    75 #include <phoneappcommands.hrh>
    75 #include <phoneappcommands.hrh>
    76 #include <bautils.h>    // for BaflUtils
    76 #include <bautils.h>    // for BaflUtils
    77 
    77 
       
    78 // Transition effects
       
    79 #include <gfxtranseffect/gfxtranseffect.h>
       
    80 
    78 // EXTERNAL DATA STRUCTURES
    81 // EXTERNAL DATA STRUCTURES
    79 
    82 
    80 // EXTERNAL FUNCTION PROTOTYPES
    83 // EXTERNAL FUNCTION PROTOTYPES
    81 
    84 
    82 // CONSTANTS
    85 // CONSTANTS
    99 const TText KArabicPresentationFormsBRangenStart = 0xFE70;
   102 const TText KArabicPresentationFormsBRangenStart = 0xFE70;
   100 const TText KArabicPresentationFormsBRangeEnd = 0xFEFF;
   103 const TText KArabicPresentationFormsBRangeEnd = 0xFEFF;
   101 
   104 
   102 const TInt KMaxRunInfoArrayCount = 20;
   105 const TInt KMaxRunInfoArrayCount = 20;
   103 
   106 
       
   107 // Transition context_uid for dialer_list component effects
       
   108 #define KGfxContactListBoxUid TUid::Uid( 0x2000B47B )
       
   109 const TInt KGfxContactListBoxOpenEffect  = 3;
       
   110 const TInt KGfxContactListBoxCloseEffect = 4;
       
   111 
   104 // MACROS
   112 // MACROS
   105 
   113 
   106 // LOCAL CONSTANTS AND MACROS
   114 // LOCAL CONSTANTS AND MACROS
   107 _LIT(KResourceFile, "\\resource\\easydialingpluginresources.rsc");
   115 _LIT(KResourceFile, "\\resource\\easydialingpluginresources.rsc");
   108 
   116 
   188     
   196     
   189     iContactDataManager = new (ELeave) CEasyDialingContactDataManager(iContactManager);
   197     iContactDataManager = new (ELeave) CEasyDialingContactDataManager(iContactManager);
   190     iContactDataManager->ConstructL();
   198     iContactDataManager->ConstructL();
   191     iContactDataManager->SetObserver(this);
   199     iContactDataManager->SetObserver(this);
   192 
   200 
   193     PERF_MEASURE_START
       
   194 
       
   195     InitPredictiveContactSearchL();
       
   196 
       
   197     PERF_MEASURE_STOP
       
   198  
       
   199     // Find a handle to ca launcher extension MCCAConnectionExt.
   201     // Find a handle to ca launcher extension MCCAConnectionExt.
   200     // Easydialing has to use the extension API, because it needs function CloseAppL
   202     // Easydialing has to use the extension API, because it needs function CloseAppL
   201     // only found in extension.
   203     // only found in extension.
   202     // MCCAConnection extension has to be obtained through MCCAParameter extension,
   204     // MCCAConnection extension has to be obtained through MCCAParameter extension,
   203     // since MCCAConnection is not designed to be extensible API.
   205     // since MCCAConnection is not designed to be extensible API.
   258         }
   260         }
   259     delete iPredictiveContactSearchHandler;
   261     delete iPredictiveContactSearchHandler;
   260 
   262 
   261     delete iListBoxModel;
   263     delete iListBoxModel;
   262     
   264     
       
   265     if ( iContactListBox )
       
   266         {
       
   267         GfxTransEffect::Deregister( iContactListBox );
       
   268         }
       
   269     
   263     delete iContactListBox;
   270     delete iContactListBox;
   264 
   271 
   265     if (iContactLauncher)
   272     if (iContactLauncher)
   266         {
   273         {
   267         iContactLauncher->Close();
   274         iContactLauncher->Close();
   311 
   318 
   312     CTextListBoxModel* model = iContactListBox->Model();
   319     CTextListBoxModel* model = iContactListBox->Model();
   313     model->SetItemTextArray( iListBoxModel );
   320     model->SetItemTextArray( iListBoxModel );
   314     model->SetOwnershipType( ELbmDoesNotOwnItemArray );
   321     model->SetOwnershipType( ELbmDoesNotOwnItemArray );
   315 
   322 
   316 
       
   317     iContactListBox->MakeVisible( EFalse );
   323     iContactListBox->MakeVisible( EFalse );
   318     
   324     
   319     SetFocus( EFalse );    
   325     SetFocus( EFalse );    
   320     iContactListBox->ActivateL();
   326     iContactListBox->ActivateL();
   321 
   327     
       
   328     GfxTransEffect::Register( iContactListBox, 
       
   329                               KGfxContactListBoxUid, EFalse );
       
   330     
       
   331     // Do delayed initialization of PCS. PCS constructions takes a long time.
       
   332     // On the other hand, easy dialing initialization is done in phone application
       
   333     // constructor, so it contributes the whole system boot time. These are good 
       
   334     // reasons not to construct PCS in easy dialing constructor, but do it later as
       
   335     // an asynchronous operation.
       
   336     AsyncActionLaunchL( EInitializePcs );
   322     }
   337     }
   323 
   338 
   324 
   339 
   325 // -----------------------------------------------------------------------------
   340 // -----------------------------------------------------------------------------
   326 // Reset
   341 // Reset
   633     // matches are shown if search string is just space (would show all contacts)
   648     // matches are shown if search string is just space (would show all contacts)
   634     // even if somebody might have unnamed contacts. Should be quite rare.
   649     // even if somebody might have unnamed contacts. Should be quite rare.
   635     // It's assumed later on in the code that string is not just empty space.
   650     // It's assumed later on in the code that string is not just empty space.
   636     TLex searchString( aSearchString );
   651     TLex searchString( aSearchString );
   637     searchString.SkipSpace();
   652     searchString.SkipSpace();
   638     if ( searchString.Eos() )
   653     if ( searchString.Eos() ) // the end of the string reached after skipping empty space
   639         {
   654         {
   640         // the end of the string reached after skipping empty space
   655         // It's assumed here that if we get here due to switching to call
       
   656         // handling etc, then dialer and thus ed is already set invisible
       
   657         // and effect will not be shown as listbox is already invisible.
       
   658         // However if user empties number entry, then it's feasible to show
       
   659         // effect.
       
   660         HideContactListBoxWithEffect();
   641         Reset();
   661         Reset();
   642         }
   662         }
   643     else // proper search string
   663     else // proper search string
   644         {
   664         {
   645         iSearchString.Copy( aSearchString.Left( iSearchString.MaxLength() ) );
   665         iSearchString.Copy( aSearchString.Left( iSearchString.MaxLength() ) );
   701         {
   721         {
   702         case TVPbkContactStoreEvent::EContactAdded:
   722         case TVPbkContactStoreEvent::EContactAdded:
   703         case TVPbkContactStoreEvent::EContactDeleted:
   723         case TVPbkContactStoreEvent::EContactDeleted:
   704         case TVPbkContactStoreEvent::EContactChanged:
   724         case TVPbkContactStoreEvent::EContactChanged:
   705             {
   725             {
   706             if ( iSearchString.Length() > 0 )
   726             DoHandleContactsChangedL();
   707                 {
   727             }
   708                 if ( iContactLauncherActive )
       
   709                     {
       
   710                     // Set the flag to make a search when communication launcher exits.
       
   711                     iNewSearchNeeded = ETrue;                   
       
   712                     }
       
   713                 else
       
   714                     {
       
   715                     // We get here if user e.g. leaves dialer open and goes to Contacts
       
   716                     // application and does some editing.
       
   717                     iContactDataManager->Reload(); // to update thumbnails
       
   718                     AsyncActionLaunchL( ELaunchSearch );
       
   719                     }
       
   720                 }
       
   721             }
       
   722             
       
   723             break;
   728             break;
   724        
   729        
   725         default:
   730         default:
   726             
       
   727             break;
   731             break;
   728         }
   732         }
   729     
   733     }
   730 
       
   731     
       
   732     }
       
   733 
       
   734 
   734 
   735 // -----------------------------------------------------------------------------
   735 // -----------------------------------------------------------------------------
   736 // CEasyDialingPlugin::OpenComplete
   736 // CEasyDialingPlugin::OpenComplete
   737 // From MVPbkContactStoreListObserver.
   737 // From MVPbkContactStoreListObserver.
   738 //
   738 //
   792     {
   792     {
   793     if ( iPredictiveContactSearchHandler )
   793     if ( iPredictiveContactSearchHandler )
   794         {
   794         {
   795         TRAP_IGNORE( SetSortOrderL( iContactDataManager->NameOrder() ) );
   795         TRAP_IGNORE( SetSortOrderL( iContactDataManager->NameOrder() ) );
   796         }
   796         }
       
   797     }
       
   798 
       
   799 // -----------------------------------------------------------------------------
       
   800 // FavouritesChanged
       
   801 // From MContactDataManagerObserver
       
   802 // -----------------------------------------------------------------------------
       
   803 //
       
   804 void CEasyDialingPlugin::FavouritesChanged()
       
   805     {
       
   806     TRAP_IGNORE( DoHandleContactsChangedL() );
   797     }
   807     }
   798 
   808 
   799 // -----------------------------------------------------------------------------
   809 // -----------------------------------------------------------------------------
   800 // InformContactorEvent
   810 // InformContactorEvent
   801 // From MEDContactorObserver
   811 // From MEDContactorObserver
   844 // Initiates predictive contact search.
   854 // Initiates predictive contact search.
   845 // -----------------------------------------------------------------------------
   855 // -----------------------------------------------------------------------------
   846 //
   856 //
   847 void CEasyDialingPlugin::LaunchSearchL()
   857 void CEasyDialingPlugin::LaunchSearchL()
   848     {
   858     {
   849     if ( iSearchString.Length() == 0 )
   859     if ( iSearchString.Length() == 0 || !iPredictiveContactSearchHandler )
   850         {
   860         {
   851         return;
   861         return;
   852         }
   862         }
   853     
   863     
   854     iDiscardCompletingSearches = EFalse;
   864     iDiscardCompletingSearches = EFalse;
  1090         {
  1100         {
  1091         iContactListBox->SetRectToNumberOfItems( iNumberOfNames );
  1101         iContactListBox->SetRectToNumberOfItems( iNumberOfNames );
  1092         iContactListBox->HandleItemAdditionL();
  1102         iContactListBox->HandleItemAdditionL();
  1093         // Scroll the list to bottom
  1103         // Scroll the list to bottom
  1094         iContactListBox->ScrollToMakeItemVisible( iNumberOfNames-1 );
  1104         iContactListBox->ScrollToMakeItemVisible( iNumberOfNames-1 );
  1095         iContactListBox->MakeVisible( ETrue );
  1105         ShowContactListBoxWithEffect();
  1096         }
  1106         }
  1097     else
  1107     else
  1098         {
  1108         {  
  1099         iContactListBox->MakeVisible( EFalse );
  1109         HideContactListBoxWithEffect();
  1100         }
  1110         }
  1101 
  1111 
  1102     if ( IsFocused() )
  1112     if ( IsFocused() )
  1103         {
  1113         {
  1104         SetFocus( EFalse );
  1114         SetFocus( EFalse );
  1609     else if ( iActionToBeLaunched == ELaunchSearch )
  1619     else if ( iActionToBeLaunched == ELaunchSearch )
  1610         {
  1620         {
  1611         LaunchSearchL();
  1621         LaunchSearchL();
  1612         return;
  1622         return;
  1613         }
  1623         }
       
  1624     else if ( iActionToBeLaunched == EInitializePcs )
       
  1625         {
       
  1626         PERF_MEASURE_START
       
  1627         InitPredictiveContactSearchL();
       
  1628         PERF_MEASURE_STOP
       
  1629  
       
  1630         return;
       
  1631         }
  1614     
  1632     
  1615     // If not for launching current contact or performing search, 
  1633     // If not for launching current contact or performing search, 
  1616     // the action is launching some communication method.
  1634     // the action is launching some communication method.
  1617     
  1635     
  1618     if ( iContactorService->IsBusy() )
  1636     if ( iContactorService->IsBusy() )
  1756      
  1774      
  1757      // iInputBlocker will be deleted right after this callback by CAknInputBlock
  1775      // iInputBlocker will be deleted right after this callback by CAknInputBlock
  1758      // cause we are using CAknInputBlock::SetCancelDelete method.
  1776      // cause we are using CAknInputBlock::SetCancelDelete method.
  1759      iInputBlocker = NULL;
  1777      iInputBlocker = NULL;
  1760      }
  1778      }
       
  1779 
       
  1780 // -----------------------------------------------------------------------------
       
  1781 // CEasyDialingPlugin::DoHandleContactsChangedL
       
  1782 // -----------------------------------------------------------------------------
       
  1783 //
       
  1784 void CEasyDialingPlugin::DoHandleContactsChangedL()
       
  1785     {
       
  1786     if ( iSearchString.Length() > 0 )
       
  1787         {
       
  1788         if ( iContactLauncherActive )
       
  1789             {
       
  1790             // Set the flag to make a search when communication launcher exits.
       
  1791             iNewSearchNeeded = ETrue;                   
       
  1792             }
       
  1793         else
       
  1794             {
       
  1795             // We get here if user e.g. leaves dialer open and goes to Contacts
       
  1796             // application and does some editing.
       
  1797             iContactDataManager->Reload(); // to update thumbnails
       
  1798             AsyncActionLaunchL( ELaunchSearch );
       
  1799             }
       
  1800         }
       
  1801     }
       
  1802 
       
  1803 // -----------------------------------------------------------------------------
       
  1804 // CEasyDialingPlugin::ShowContactListBoxWithEffect
       
  1805 // Use appear/disappear effects when in foreground and when listbox truly
       
  1806 // changes visiblity.
       
  1807 // -----------------------------------------------------------------------------
       
  1808 //
       
  1809 void CEasyDialingPlugin::ShowContactListBoxWithEffect()
       
  1810     {  
       
  1811     CAknAppUi* appUi = static_cast<CAknAppUi*>( iCoeEnv->AppUi() );
       
  1812        
       
  1813     // Show effect only if listbox is about to come visible.
       
  1814     if ( !iContactListBox->IsVisible() &&
       
  1815          appUi && appUi->IsForeground() && 
       
  1816          GfxTransEffect::IsRegistered( iContactListBox ) )
       
  1817         {
       
  1818         GfxTransEffect::Begin( iContactListBox, KGfxContactListBoxOpenEffect );
       
  1819         iContactListBox->MakeVisible( ETrue );
       
  1820         GfxTransEffect::SetDemarcation( iContactListBox, iContactListBox->Rect() );
       
  1821         GfxTransEffect::End( iContactListBox );
       
  1822         }
       
  1823     else
       
  1824         {
       
  1825         iContactListBox->MakeVisible( ETrue );
       
  1826         }
       
  1827     }
       
  1828 
       
  1829 // -----------------------------------------------------------------------------
       
  1830 // CEasyDialingPlugin::HideContactListBoxWithEffect
       
  1831 // -----------------------------------------------------------------------------
       
  1832 //
       
  1833 void CEasyDialingPlugin::HideContactListBoxWithEffect()
       
  1834     {
       
  1835     CAknAppUi* appUi = static_cast<CAknAppUi*>( iCoeEnv->AppUi() );
       
  1836            
       
  1837     // Show effect only if listbox is about to disappear from the screen.
       
  1838     if ( iContactListBox->IsVisible() &&
       
  1839          appUi && appUi->IsForeground() && 
       
  1840          GfxTransEffect::IsRegistered( iContactListBox ) )
       
  1841         {
       
  1842         GfxTransEffect::Begin( iContactListBox, KGfxContactListBoxCloseEffect );
       
  1843         iContactListBox->MakeVisible( EFalse );
       
  1844         GfxTransEffect::SetDemarcation( iContactListBox, iContactListBox->Rect() );
       
  1845         GfxTransEffect::End( iContactListBox );
       
  1846         }
       
  1847     else
       
  1848         {
       
  1849         iContactListBox->MakeVisible( EFalse );
       
  1850         }
       
  1851     }
  1761 
  1852 
  1762 /*
  1853 /*
  1763  * ==============================================================================
  1854  * ==============================================================================
  1764  * 
  1855  * 
  1765  * Local functions
  1856  * Local functions