phonebookui/Phonebook2/ccapplication/ccacommlauncherplugin/src/ccappcommlaunchercontainer.cpp
branchRCL_3
changeset 18 d4f567ce2e7c
parent 15 34879f5cfc63
equal deleted inserted replaced
17:2666d9724c76 18:d4f567ce2e7c
   574         {
   574         {
   575         executeContactAction = ETrue;
   575         executeContactAction = ETrue;
   576         iHasBeenDragged = EFalse;
   576         iHasBeenDragged = EFalse;
   577         }
   577         }
   578 
   578 
   579     if ( executeContactAction && iPlugin.CommandState().IsRunning() )
   579     if ( executeContactAction && iPlugin.CommandState().IsRunning()  )
   580         {
   580         {
   581         executeContactAction = EFalse;
   581         executeContactAction = EFalse;
   582         }
   582         }
   583 
   583 
   584     if (executeContactAction)
   584     if ( executeContactAction )
   585         {
   585         {
       
   586         SetInputBlockerL();
       
   587         
   586         VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector
   588         VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector
   587             contactActionType = iPlugin.Container().SelectedCommunicationMethod();
   589             contactActionType = iPlugin.Container().SelectedCommunicationMethod();
   588         
   590         
   589         if ( contactActionType
   591         if ( contactActionType
   590         		== VPbkFieldTypeSelectorFactory::EFindOnMapSelector )
   592         		== VPbkFieldTypeSelectorFactory::EFindOnMapSelector )
   591         	{
   593         	{
   592             if ( !iLongTap )
   594             HandleFindOnMapContactActionL();           
   593                 {
       
   594                 DoShowMapCmdL( (TPbk2CommandId)EPbk2ExtensionShowOnMap );
       
   595                 }
       
   596             else
       
   597                 {
       
   598                 iLongTap = EFalse;
       
   599                 }
       
   600         	}
   595         	}
   601         else
   596         else
   602         	{
   597         	{
   603             TPtrC fullName;
   598             HandleGenericContactActionL( contactActionType );
   604 
   599             }
   605             iPlugin.ContactHandler().ContactFieldItemDataL(
       
   606                 CCmsContactFieldItem::ECmsFullName, fullName);
       
   607 
       
   608             TUint paramFlag = CCAContactorService::TCSParameter::EEnableDefaults;
       
   609 
       
   610             CCAContactorService::TCSParameter param(
       
   611                 contactActionType,
       
   612                 *iPlugin.ContactHandler().ContactIdentifierLC(),//contactlinkarray
       
   613                 paramFlag,
       
   614                 fullName);
       
   615         
   600         
   616             iPlugin.ExecuteServiceL(param);
   601         RemoveInputBlocker();
       
   602         }
       
   603     }
       
   604 
       
   605 // ----------------------------------------------------------------------------
       
   606 // CCCAppCommLauncherContainer::HandleFindOnMapContactActionL()
       
   607 // ----------------------------------------------------------------------------
       
   608 //
       
   609 void CCCAppCommLauncherContainer::HandleFindOnMapContactActionL()
       
   610     {
       
   611     if ( !iLongTap )
       
   612         {
       
   613         DoShowMapCmdL( (TPbk2CommandId)EPbk2ExtensionShowOnMap );
       
   614         }
       
   615     else
       
   616         {
       
   617         iLongTap = EFalse;
       
   618         }
       
   619     }
       
   620 
       
   621 // ----------------------------------------------------------------------------
       
   622 // CCCAppCommLauncherContainer::HandleGenericContactActionL()
       
   623 // ----------------------------------------------------------------------------
       
   624 //
       
   625 void CCCAppCommLauncherContainer::HandleGenericContactActionL(
       
   626     VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector aActionType )
       
   627     {
       
   628     TPtrC fullName;
       
   629     iPlugin.ContactHandler().ContactFieldItemDataL(
       
   630         CCmsContactFieldItem::ECmsFullName, fullName );  
       
   631     
       
   632     //contactlinkarray
       
   633     HBufC8* contactIdentifier = iPlugin.ContactHandler().ContactIdentifierLC();
       
   634     
       
   635     TBool fieldSelectionReq(ETrue);
       
   636     TPtrC selectedField;
       
   637     if ( VPbkFieldTypeSelectorFactory::EVoiceCallSelector == aActionType )
       
   638         {
       
   639         fieldSelectionReq = IsVoiceCallFieldSelectionAmbiguous( aActionType, selectedField );        
       
   640         }   
       
   641     
       
   642     
       
   643     if( fieldSelectionReq ) 
       
   644         {
       
   645         ExecuteContactActionServiceWithFieldSelectionL( 
       
   646             aActionType, 
       
   647             *contactIdentifier,
       
   648             fullName );
       
   649         }
       
   650     else
       
   651         {
       
   652         // Speed up contact action by skipping slow field selection operation
       
   653         ExecuteContactActionServiceWithoutFieldSelectionL(
       
   654             aActionType,
       
   655             *contactIdentifier,
       
   656             fullName,
       
   657             selectedField );          
       
   658         }
       
   659     
       
   660     //The Timer can be started after user selected any call item
       
   661     if ( iPlugin.ContactorService()->IsSelected() && 
       
   662         ( aActionType == VPbkFieldTypeSelectorFactory::EVoiceCallSelector ||
       
   663           aActionType == VPbkFieldTypeSelectorFactory::EVideoCallSelector ||
       
   664           aActionType == VPbkFieldTypeSelectorFactory::EVOIPCallSelector) )
       
   665         {
       
   666         iPlugin.StartTimerL();
       
   667         }
       
   668     
       
   669     CleanupStack::PopAndDestroy(1);// contactlinkarray
       
   670     }
       
   671 
       
   672 // ----------------------------------------------------------------------------
       
   673 // CCCAppCommLauncherContainer::IsVoiceCallFieldSelectionAmbiguous()
       
   674 // ----------------------------------------------------------------------------
       
   675 //
       
   676 TBool CCCAppCommLauncherContainer::IsVoiceCallFieldSelectionAmbiguous(
       
   677     VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector aActionType,
       
   678     TPtrC& aSelectedField )
       
   679     {
       
   680     CCCAppCommLauncherContactHandler& handler = iPlugin.ContactHandler();
       
   681     
       
   682     if ( HasContactSingleAddress( aActionType, handler ) )
       
   683         {
       
   684         RPointerArray<CCmsContactField>& fields = handler.ContactFieldDataArray();
       
   685         
       
   686         for( TInt i=0; i < fields.Count(); i++ ) 
       
   687             {
       
   688             CCmsContactField* field = fields[i];
   617             
   689             
   618             //The Timer can be started after user selected any call item
   690             if ( HasFieldOnlyOneItem( *field ) &&
   619             if ( iPlugin.ContactorService()->IsSelected() && 
   691                  IsVoiceCallType( *field ) ) 
   620                 (contactActionType == VPbkFieldTypeSelectorFactory::EVoiceCallSelector ||
       
   621                  contactActionType == VPbkFieldTypeSelectorFactory::EVideoCallSelector ||
       
   622                  contactActionType == VPbkFieldTypeSelectorFactory::EVOIPCallSelector) )
       
   623                 {
   692                 {
   624                 iPlugin.StartTimerL();
   693                 const CCmsContactFieldItem* fieldItem = NULL;
   625                 }
   694                 
   626             
   695                 TInt error = KErrNone;
   627             CleanupStack::PopAndDestroy(1);// contactlinkarray
   696                 TRAP( error, fieldItem = &field->ItemL( 0 ) );
   628             }
   697                 
   629         }
   698                 if( error == KErrNone ) 
       
   699                     {
       
   700                     aSelectedField.Set(fieldItem->Data());
       
   701                     //Its safe to exit here
       
   702                     //Making of Voice Call is not tedious
       
   703                     //we have only one number
       
   704                     return EFalse;
       
   705                     }                   
       
   706                 }           
       
   707             }
       
   708         }
       
   709     
       
   710     return ETrue;
       
   711     }
       
   712 
       
   713 // ----------------------------------------------------------------------------
       
   714 // CCCAppCommLauncherContainer::HasContactSingleAddress()
       
   715 // ----------------------------------------------------------------------------
       
   716 //
       
   717 TBool CCCAppCommLauncherContainer::HasContactSingleAddress(
       
   718     VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector aActionType,
       
   719     CCCAppCommLauncherContactHandler& aHandler )
       
   720     {
       
   721     TInt amount = aHandler.AddressAmount( aActionType );
       
   722     if( 1 == amount )
       
   723         {
       
   724         return ETrue;
       
   725         }
       
   726     
       
   727     return EFalse;
       
   728     }
       
   729 
       
   730 // ----------------------------------------------------------------------------
       
   731 // CCCAppCommLauncherContainer::HasFieldOnlyOneItem()
       
   732 // ----------------------------------------------------------------------------
       
   733 //
       
   734 TBool CCCAppCommLauncherContainer::HasFieldOnlyOneItem( const CCmsContactField& field ) const
       
   735     {
       
   736     const RPointerArray<CCmsContactFieldItem>& items = field.Items();
       
   737     
       
   738     if ( 1 == items.Count() )
       
   739         {
       
   740         return ETrue;
       
   741         }
       
   742     
       
   743     return EFalse;
       
   744     }
       
   745 
       
   746 // ----------------------------------------------------------------------------
       
   747 // CCCAppCommLauncherContainer::IsVoiceCallType()
       
   748 // ----------------------------------------------------------------------------
       
   749 //
       
   750 TBool CCCAppCommLauncherContainer::IsVoiceCallType( const CCmsContactField& field ) const
       
   751     {
       
   752     CCmsContactFieldItem::TCmsContactField fieldType = field.Type();
       
   753     
       
   754     if( fieldType == CCmsContactFieldItem::ECmsLandPhoneGeneric ||
       
   755         fieldType == CCmsContactFieldItem::ECmsLandPhoneHome ||
       
   756         fieldType == CCmsContactFieldItem::ECmsLandPhoneWork ||
       
   757         fieldType == CCmsContactFieldItem::ECmsMobilePhoneGeneric ||
       
   758         fieldType == CCmsContactFieldItem::ECmsMobilePhoneHome ||
       
   759         fieldType == CCmsContactFieldItem::ECmsMobilePhoneWork  )
       
   760         {    
       
   761         return ETrue;
       
   762         }
       
   763     
       
   764     return EFalse;
       
   765     }
       
   766 
       
   767 
       
   768 // ----------------------------------------------------------------------------
       
   769 // CCCAppCommLauncherContainer::ExecuteContactActionServiceWithFieldSelectionL()
       
   770 // ----------------------------------------------------------------------------
       
   771 //
       
   772 void CCCAppCommLauncherContainer::ExecuteContactActionServiceWithFieldSelectionL( 
       
   773     VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector aActionType,
       
   774     TDesC8& aContactIdentifier,
       
   775     TDesC& aFullName )
       
   776     {
       
   777     TUint paramFlag = CCAContactorService::TCSParameter::EEnableDefaults;
       
   778 
       
   779     CCAContactorService::TCSParameter param(
       
   780         aActionType,
       
   781         aContactIdentifier,
       
   782         paramFlag,
       
   783         aFullName );
       
   784     
       
   785     iPlugin.ExecuteServiceL(param);    
       
   786     }
       
   787 
       
   788 // ----------------------------------------------------------------------------
       
   789 // CCCAppCommLauncherContainer::ExecuteContactActionServiceWithoutFieldSelectionL()
       
   790 // ----------------------------------------------------------------------------
       
   791 //
       
   792 void CCCAppCommLauncherContainer::ExecuteContactActionServiceWithoutFieldSelectionL( 
       
   793     VPbkFieldTypeSelectorFactory::TVPbkContactActionTypeSelector aActionType,
       
   794     TDesC8& aContactIdentifier,
       
   795     TDesC& aFullName,
       
   796     TDesC& aSelectedField )
       
   797     {
       
   798     CCAContactorService::TCSParameter param(
       
   799         aActionType,
       
   800         aContactIdentifier,
       
   801         CCAContactorService::TCSParameter::EUseFieldParam,
       
   802         aFullName,
       
   803         aSelectedField );
       
   804     
       
   805     iPlugin.ExecuteServiceL(param);
   630     }
   806     }
   631 
   807 
   632 // ----------------------------------------------------------------------------
   808 // ----------------------------------------------------------------------------
   633 // CCCAppCommLauncherContainer::ContactInfoFetchedNotifyL()
   809 // CCCAppCommLauncherContainer::ContactInfoFetchedNotifyL()
   634 // ----------------------------------------------------------------------------
   810 // ----------------------------------------------------------------------------
   913 //
  1089 //
   914 const TInt CCCAppCommLauncherContainer::GetListBoxItemAmount() const
  1090 const TInt CCCAppCommLauncherContainer::GetListBoxItemAmount() const
   915 	{
  1091 	{
   916 	return iModel->MdcaCount();
  1092 	return iModel->MdcaCount();
   917 	}
  1093 	}
       
  1094 
       
  1095 //-----------------------------------------------------------------------------
       
  1096 // CCCAppCommLauncherContainer::SetInputBlockerL()
       
  1097 //-----------------------------------------------------------------------------
       
  1098 //
       
  1099 void CCCAppCommLauncherContainer::SetInputBlockerL()
       
  1100      {
       
  1101      if (!iInputBlocker)
       
  1102          {
       
  1103          iInputBlocker = CAknInputBlock::NewCancelHandlerLC( this );
       
  1104          CleanupStack::Pop( iInputBlocker );   
       
  1105          iInputBlocker->SetCancelDelete( iInputBlocker );
       
  1106          }
       
  1107      } 
       
  1108 
       
  1109 // --------------------------------------------------------------------------
       
  1110 // CCCAppCommLauncherContainer::RemoveInputBlockerL
       
  1111 // --------------------------------------------------------------------------
       
  1112 //
       
  1113 void CCCAppCommLauncherContainer::RemoveInputBlocker()
       
  1114     {
       
  1115     if (iInputBlocker)
       
  1116         {
       
  1117         iInputBlocker->Cancel();
       
  1118         }
       
  1119     }
       
  1120 
       
  1121 // --------------------------------------------------------------------------
       
  1122 // CCCAppCommLauncherContainer::AknInputBlockCancel
       
  1123 // --------------------------------------------------------------------------
       
  1124 //
       
  1125 void CCCAppCommLauncherContainer::AknInputBlockCancel()
       
  1126      {
       
  1127      iInputBlocker = NULL;
       
  1128      }
   918 // End of File
  1129 // End of File