phonebookui/Speeddial/VPbkControlSrc/speeddialprivate.cpp
branchRCL_3
changeset 26 0d28c1c5b6dd
parent 3 04ab22b956c2
child 32 2828b4d142c0
equal deleted inserted replaced
23:5586b4d2ec3e 26:0d28c1c5b6dd
    99 
    99 
   100 #include <VPbkEng.rsg>
   100 #include <VPbkEng.rsg>
   101 #include <AiwContactAssignDataTypes.h>
   101 #include <AiwContactAssignDataTypes.h>
   102 
   102 
   103 #include "SpdiaContainer.h"
   103 #include "SpdiaContainer.h"
       
   104 #include <MPbk2FieldPropertyArray2.h>
       
   105 #include <MPbk2FieldProperty2.h>
       
   106 #include <MPbk2FieldProperty.h>
   104 
   107 
   105 // LOCAL CONSTANTS AND MACROS
   108 // LOCAL CONSTANTS AND MACROS
   106 //This order is based on 'Standard field ids' (PbkFields.hrh)
   109 //This order is based on 'Standard field ids' (PbkFields.hrh)
   107 
   110 
   108 const TUint KFieldIds[] = 
   111 const TUint KFieldIds[] = 
   147 _LIT(KNullCell, "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t%d\t");
   150 _LIT(KNullCell, "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t%d\t");
   148 _LIT(KDesTab, "\t");
   151 _LIT(KDesTab, "\t");
   149 _LIT(KDesTab2, "\t\t");
   152 _LIT(KDesTab2, "\t\t");
   150 
   153 
   151 
   154 
   152 
   155 class TXspIconHelper
       
   156     {
       
   157 
       
   158     public:    
       
   159     	TXspIconHelper( TInt aIndex, const TDesC& aLable);
       
   160     	TInt IconIndex() const;
       
   161     	TDesC& LableText();
       
   162     private:
       
   163     	TInt iIndex;
       
   164     	TBuf<50> iLableText;
       
   165     	      
       
   166     };
       
   167 
       
   168 TXspIconHelper::TXspIconHelper(TInt aIndex, const TDesC& aLable):
       
   169     iIndex (aIndex),
       
   170     iLableText (aLable)
       
   171 	{
       
   172 	}
       
   173 
       
   174 inline TInt TXspIconHelper::IconIndex() const 
       
   175 	{
       
   176 	return iIndex;
       
   177 	}
       
   178 
       
   179 inline TDesC& TXspIconHelper::LableText() 
       
   180 	{
       
   181 	return iLableText;
       
   182 	}
   153 
   183 
   154 // ---------------------------------------------------------
   184 // ---------------------------------------------------------
   155 // CSpeedDialPrivate::NewL()
   185 // CSpeedDialPrivate::NewL()
   156 // ---------------------------------------------------------
   186 // ---------------------------------------------------------
   157 //
   187 //
   264 		iContactLinkArray = NULL;
   294 		iContactLinkArray = NULL;
   265 	    iServiceHandler = CAiwServiceHandler::NewL();
   295 	    iServiceHandler = CAiwServiceHandler::NewL();
   266 		iServiceHandler->AttachL( R_SPEEDDIAL_EMAIL_SELECTION_INTEREST );
   296 		iServiceHandler->AttachL( R_SPEEDDIAL_EMAIL_SELECTION_INTEREST );
   267 		iServiceHandler->AttachL( R_SPDIA_SINGLE_ASSIGN_INTEREST );
   297 		iServiceHandler->AttachL( R_SPDIA_SINGLE_ASSIGN_INTEREST );
   268 		iWait = new( ELeave )CActiveSchedulerWait();
   298 		iWait = new( ELeave )CActiveSchedulerWait();
       
   299         iWaitFetchmail = new( ELeave )CActiveSchedulerWait();
   269 		
   300 		
   270 		
   301 		
   271 		iError = KErrNone;
   302 		iError = KErrNone;
   272 
   303 
   273         MVPbkContactStoreList& storeList = iContactManager->ContactStoresL();
   304         MVPbkContactStoreList& storeList = iContactManager->ContactStoresL();
   459     if ( iRemoveConfirmQueryDialog )
   490     if ( iRemoveConfirmQueryDialog )
   460         {
   491         {
   461         delete iRemoveConfirmQueryDialog;
   492         delete iRemoveConfirmQueryDialog;
   462         iRemoveConfirmQueryDialog = NULL;
   493         iRemoveConfirmQueryDialog = NULL;
   463         }
   494         }
       
   495 		
       
   496     ixspIconInfoArray.Close();    
   464     }
   497     }
   465        
   498        
   466 // ---------------------------------------------------------
   499 // ---------------------------------------------------------
   467 // CSpeedDialPrivate::InitializeArray
   500 // CSpeedDialPrivate::InitializeArray
   468 //
   501 //
   537 			fieldTypeList->AppendL(*fieldType);	
   570 			fieldTypeList->AppendL(*fieldType);	
   538 		}
   571 		}
   539 		
   572 		
   540 		MPbk2FieldPropertyArray* aPropertyArray = Pbk2FieldPropertiesFactory::CreateLC(*fieldTypeList,&iContactManager->FsSession() );
   573 		MPbk2FieldPropertyArray* aPropertyArray = Pbk2FieldPropertiesFactory::CreateLC(*fieldTypeList,&iContactManager->FsSession() );
   541 		
   574 		
   542 		for(count =0; count < aPropertyArray->Count(); ++ count)
   575 		ixspIconInfoArray.Reset();
       
   576 		const TInt arrayCount = aPropertyArray->Count();
       
   577 		for(count =0; count < arrayCount; ++ count)
   543 		{
   578 		{
   544 		   icon = pbk2IconFactory->CreateIconL(aPropertyArray->At(count).IconId());
   579 		   icon = pbk2IconFactory->CreateIconL(aPropertyArray->At(count).IconId());
   545 		   aArray->AppendL(icon);		   
   580 		   aArray->AppendL(icon);
   546 		}
   581 		   
   547 		
   582 		   // Append xSP icon info to helper array
       
   583 		   if ( aPropertyArray->At(count).FieldType().FieldTypeResId() == R_VPBK_FIELD_TYPE_IMPP )
       
   584 			   {
       
   585 			   const MPbk2FieldProperty& property = aPropertyArray->At(count);
       
   586 			   MPbk2FieldProperty2* property2 = reinterpret_cast<MPbk2FieldProperty2*>
       
   587 			           ( const_cast<MPbk2FieldProperty&> ( property ).FieldPropertyExtension(
       
   588 			                KMPbk2FieldPropertyExtension2Uid ) );
       
   589 			           			   
       
   590 			   TXspIconHelper helper( aArray->Count()-1, property2->XSpName() );		   
       
   591 			   ixspIconInfoArray.AppendL( helper );
       
   592 			   }
       
   593 		}		
   548 		CleanupStack::PopAndDestroy(aPropertyArray);
   594 		CleanupStack::PopAndDestroy(aPropertyArray);
   549 		
   595 		
   550 		delete fieldTypeList;
   596 		delete fieldTypeList;
   551 		delete pbk2IconFactory;
   597 		delete pbk2IconFactory;
   552 		
       
   553 		
   598 		
   554 	}
   599 	}
   555 // ---------------------------------------------------------
   600 // ---------------------------------------------------------
   556 // CSpeedDialPrivate::VoiceMailL  
   601 // CSpeedDialPrivate::VoiceMailL  
   557 //
   602 //
  1029 // CSpeedDialPrivate::SetIconArrayL
  1074 // CSpeedDialPrivate::SetIconArrayL
  1030 //
  1075 //
  1031 // ---------------------------------------------------------
  1076 // ---------------------------------------------------------
  1032 TInt CSpeedDialPrivate::SetIconArrayL(CArrayPtrFlat<CGulIcon>* aArray)
  1077 TInt CSpeedDialPrivate::SetIconArrayL(CArrayPtrFlat<CGulIcon>* aArray)
  1033     {
  1078     {
       
  1079     if ( aArray != NULL )
       
  1080         {
       
  1081         aArray->ResetAndDestroy();
       
  1082         }
       
  1083     else
       
  1084         {
       
  1085         return 0;
       
  1086         }
       
  1087 
       
  1088     CreateIndexIconsL( aArray );
       
  1089     CreateFieldIconsL( aArray );     
       
  1090 
       
  1091 	TInt existThumb = 0;
       
  1092 	const TInt count = iSdmArray->Count();
       
  1093     for (TInt index(0); index < count; index++)
       
  1094         {
       
  1095         if (CreateIndexIconL(index, (*iSdmArray)[index], existThumb > 0? EFalse: ETrue))
       
  1096             {
       
  1097             ++existThumb;
       
  1098             }
       
  1099         }
       
  1100 
       
  1101     return existThumb;
       
  1102     }
       
  1103 
       
  1104 // ---------------------------------------------------------
       
  1105 // CSpeedDialPrivate::CreateIndexIconsL
       
  1106 //
       
  1107 // ---------------------------------------------------------
       
  1108 TInt CSpeedDialPrivate::CreateIndexIconsL( CArrayPtrFlat<CGulIcon>* aArray )
       
  1109 	{
  1034 	CFbsBitmap* bitmap,*mask;
  1110 	CFbsBitmap* bitmap,*mask;
  1035 	bitmap = NULL;
  1111 	bitmap = NULL;
  1036 	mask= NULL;
  1112 	mask= NULL;
  1037 	MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
  1113 	MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
  1038  
  1114 
  1039     if ( aArray != NULL )
       
  1040         {
       
  1041         aArray->ResetAndDestroy();
       
  1042         }
       
  1043     else
       
  1044         {
       
  1045         return 0;
       
  1046         }
       
  1047 
       
  1048 	TInt existThumb(0);
       
  1049     for (TInt index(0); index < iSdmArray->Count(); index++)
  1115     for (TInt index(0); index < iSdmArray->Count(); index++)
  1050         {
  1116         {
  1051 		if(index == 0)
  1117 		if(index == 0)
  1052 		{
  1118 		    {
  1053 		 TUid uidVmbx;
  1119 		    TUid uidVmbx;
  1054 		 uidVmbx.iUid =KVmbxUid;
  1120 		    uidVmbx.iUid =KVmbxUid;
  1055 		 AknsUtils::CreateAppIconLC( skinInstance,uidVmbx, EAknsAppIconTypeContext,bitmap ,mask);		
  1121 		    AknsUtils::CreateAppIconLC( skinInstance,uidVmbx, EAknsAppIconTypeContext,bitmap ,mask);		
  1056 		 CleanupStack::Pop(2);
  1122 		    CleanupStack::Pop(2);
  1057 		}
  1123 		    }
  1058 		else
  1124 		else
  1059 		{
  1125 		   {
  1060 		 	if(User::Language() == ELangHindi)
  1126 		 	if(User::Language() == ELangHindi)
  1061 		 	{
  1127 		 	    {
  1062 		 		AknsUtils::CreateIconL(skinInstance, (*iDialSkinBmp)[index],bitmap,mask,iBmpPath,iDialHindiBmp[index],  iDialHindiBmpMask[index] );	
  1128 		 		AknsUtils::CreateIconL(skinInstance, (*iDialSkinBmp)[index],bitmap,mask,iBmpPath,iDialHindiBmp[index],  iDialHindiBmpMask[index] );	
  1063 		 	}
  1129 		 	    }
  1064 		 	else
  1130 		 	else
  1065 		 	 {
  1131 		 	    {
  1066 		 	 	AknsUtils::CreateIconL(skinInstance, (*iDialSkinBmp)[index],bitmap,mask,iBmpPath,iDialBmp[index],  iDialBmpMask[index] );	
  1132 		 	 	AknsUtils::CreateIconL(skinInstance, (*iDialSkinBmp)[index],bitmap,mask,iBmpPath,iDialBmp[index],  iDialBmpMask[index] );	
  1067 		 	 }
  1133 		 	    }
  1068 		}
  1134 		    }
       
  1135 		
  1069 		CGulIcon* icon = CGulIcon::NewL(bitmap,mask);
  1136 		CGulIcon* icon = CGulIcon::NewL(bitmap,mask);
  1070         CleanupStack::PushL(icon);
  1137 	    CleanupStack::PushL(icon);
  1071         aArray->AppendL(icon);
  1138 	    aArray->AppendL(icon);
  1072 
  1139 	    CleanupStack::Pop(); // icon
  1073         if (CreateIndexIconL(index,
  1140         }
  1074             (*iSdmArray)[index], existThumb > 0? EFalse: ETrue))
  1141     
  1075             {
  1142 	}
  1076             ++existThumb;
  1143 
  1077             }
       
  1078         CleanupStack::Pop(); // icon
       
  1079         }
       
  1080 
       
  1081 		CreateFieldIconsL(aArray);
       
  1082 
       
  1083     return existThumb;
       
  1084     }
       
  1085 	
       
  1086 	
       
  1087 // ---------------------------------------------------------
  1144 // ---------------------------------------------------------
  1088 // CSpeedDialPrivate::VoiceMailTypeL	
  1145 // CSpeedDialPrivate::VoiceMailTypeL	
  1089 //
  1146 //
  1090 // ---------------------------------------------------------
  1147 // ---------------------------------------------------------
  1091 //
  1148 //
  1463             	CleanupStack::PopAndDestroy( number );
  1520             	CleanupStack::PopAndDestroy( number );
  1464 				}
  1521 				}
  1465 			
  1522 			
  1466 			//Push
  1523 			//Push
  1467             const MVPbkFieldType* fieldType = field->BestMatchingFieldType();
  1524             const MVPbkFieldType* fieldType = field->BestMatchingFieldType();
  1468             TInt iconindex = FindIconIndex(fieldType->FieldTypeResId());
  1525             TInt iconindex = FindIconIndex(fieldType->FieldTypeResId(), field );
  1469             (*iSdmArray)[aIndex].SetIconIndex(iconindex);
  1526             (*iSdmArray)[aIndex].SetIconIndex(iconindex);
  1470     
  1527     
  1471             //No need to fetch thumbnail now...will be updated while grid is
  1528             //No need to fetch thumbnail now...will be updated while grid is
  1472             // drawn
  1529             // drawn
  1473             (*iSdmArray)[aIndex].SetThumbIndex(-1,NULL);	
  1530             (*iSdmArray)[aIndex].SetThumbIndex(-1,NULL);	
  1629         CAiwGenericParamList& outParamList = iServiceHandler->OutParamListL();
  1686         CAiwGenericParamList& outParamList = iServiceHandler->OutParamListL();
  1630         iServiceHandler->ExecuteServiceCmdL(KAiwCmdSelect, inParamList,
  1687         iServiceHandler->ExecuteServiceCmdL(KAiwCmdSelect, inParamList,
  1631                 outParamList, 0, this);
  1688                 outParamList, 0, this);
  1632                 }
  1689                 }
  1633                     );
  1690                     );
  1634         iOperationComplete = EFalse;
  1691         iFetchmailComplete = EFalse;
  1635         // Wait till the contact is selected
  1692         // Wait till the contact is selected
  1636         while ( !iOperationComplete )
  1693         while ( !iFetchmailComplete )
  1637         {
  1694         {
  1638             Wait();
  1695         WaitFetchMail();
  1639         }
  1696         }
  1640         iFetchmail = EFalse;
  1697         iFetchmail = EFalse;
  1641         return iMail;
  1698         return iMail;
  1642     }
  1699     }
  1643 
  1700 
  2548             	{  
  2605             	{  
  2549                 TInt length = paramMail->Value().AsDes().Length();
  2606                 TInt length = paramMail->Value().AsDes().Length();
  2550                 iMail = HBufC::NewL(length);
  2607                 iMail = HBufC::NewL(length);
  2551                 iMail->Des().Append(paramMail->Value().AsDes());
  2608                 iMail->Des().Append(paramMail->Value().AsDes());
  2552             	}            
  2609             	}            
  2553 	            iOperationComplete = ETrue;
  2610 
  2554 	    		Release();
  2611             if( iFetchmail )
  2555 	  
  2612                 {
       
  2613                 iFetchmailComplete = ETrue;
       
  2614                 ReleaseFetchMail();
       
  2615                 }
       
  2616             else
       
  2617                 {
       
  2618                 iOperationComplete = ETrue;
       
  2619                 Release();
       
  2620                 }  
       
  2621 
  2556             }
  2622             }
  2557         else if (aEventId == KAiwEventCanceled)
  2623         else if (aEventId == KAiwEventCanceled)
  2558             {
  2624             {
  2559             	iError = KErrCancel;    
  2625             	iError = KErrCancel;    
  2560 	            iOperationComplete = ETrue;
  2626 
  2561 	    		Release();
  2627                 if( iFetchmail )
       
  2628                     {
       
  2629                     iFetchmailComplete = ETrue;
       
  2630                     ReleaseFetchMail();
       
  2631                     }
       
  2632                 else
       
  2633                     {
       
  2634                     iOperationComplete = ETrue;
       
  2635                     Release();
       
  2636 	                }
  2562             }
  2637             }
  2563          else if (aEventId == KAiwEventError)
  2638          else if (aEventId == KAiwEventError)
  2564          	{
  2639          	{
  2565          	   	iError = KErrInUse;    
  2640          	   	iError = KErrInUse;    
  2566 	           	iOperationComplete = ETrue;
  2641 	           	iOperationComplete = ETrue;
  2993 	    MVPbkStoreContactField* field = (*iSdmArray)[aIndex].Field();	
  3068 	    MVPbkStoreContactField* field = (*iSdmArray)[aIndex].Field();	
  2994 		if(field)
  3069 		if(field)
  2995 		{
  3070 		{
  2996 			fieldId = field->BestMatchingFieldType()->FieldTypeResId();
  3071 			fieldId = field->BestMatchingFieldType()->FieldTypeResId();
  2997 		}
  3072 		}
  2998 	    aSdmData.SetIconIndex(FindIconIndex(fieldId));     
  3073 	    aSdmData.SetIconIndex(FindIconIndex(fieldId, field ));     
  2999 	   
  3074 	   
  3000 		// check for the functionality, why he is checking has thumbnail before adding
  3075 		// check for the functionality, why he is checking has thumbnail before adding
  3001 		
  3076 		
  3002 		if (iImageManager->HasImage(*aSdmData.Contact(),*iThumbNailFieldType))
  3077 		if (iImageManager->HasImage(*aSdmData.Contact(),*iThumbNailFieldType))
  3003 		{
  3078 		{
  3040 // CSpeedDialPrivate::FindIconIndex
  3115 // CSpeedDialPrivate::FindIconIndex
  3041 //
  3116 //
  3042 // ---------------------------------------------------------
  3117 // ---------------------------------------------------------
  3043 //
  3118 //
  3044 
  3119 
  3045 TInt CSpeedDialPrivate::FindIconIndex(TInt aId) const
  3120 TInt CSpeedDialPrivate::FindIconIndex( TInt aId, MVPbkStoreContactField* aField ) //const
  3046     {
  3121     {
  3047     TInt index(KNullIndexData);
  3122     TInt index(KNullIndexData);
  3048     for (TInt n(0); index == KNullIndexData && n < (sizeof KFieldIds/sizeof KFieldIds[0]); ++n)
  3123     
  3049         {
  3124 	// If impp field, find xSP icon info from helper
  3050        if ((TUint)aId == KFieldIds[n] )
  3125     if ( aField && ( aId == R_VPBK_FIELD_TYPE_IMPP ) )
       
  3126     	{
       
  3127     	TPtrC scheme = MVPbkContactFieldUriData::Cast( aField->FieldData()).Scheme();
       
  3128     	           	
       
  3129     	const TInt count = ixspIconInfoArray.Count(); 
       
  3130     	for ( TInt i=0; i < count; i++ )
       
  3131     		{
       
  3132     		if ( !scheme.CompareF( ixspIconInfoArray[i].LableText() ) )
       
  3133     			{
       
  3134     			index = ixspIconInfoArray[i].IconIndex();
       
  3135     			break;
       
  3136     			}
       
  3137     		}
       
  3138     	}
       
  3139     // If not impp field, calculate icon index as below
       
  3140     else
       
  3141     	{
       
  3142         for (TInt n(0); index == KNullIndexData && n < (sizeof KFieldIds/sizeof KFieldIds[0]); ++n)
  3051             {
  3143             {
  3052             index = n + iSdmCount;
  3144             if ((TUint)aId == KFieldIds[n] )
       
  3145                {
       
  3146                index = n + iSdmCount;
       
  3147                }
  3053             }
  3148             }
  3054         }
  3149     	}
  3055     return index;
  3150     return index;
  3056     }
  3151     }
  3057     
  3152     
  3058 
  3153 
  3059 // ---------------------------------------------------------
  3154 // ---------------------------------------------------------
  3417     	iWait->Start();
  3512     	iWait->Start();
  3418 
  3513 
  3419 }
  3514 }
  3420 
  3515 
  3421 // ---------------------------------------------------------
  3516 // ---------------------------------------------------------
       
  3517 // CSpeedDialPrivate::WaitFetchMail
       
  3518 //
       
  3519 // ---------------------------------------------------------
       
  3520 //
       
  3521 void CSpeedDialPrivate::WaitFetchMail()
       
  3522     {
       
  3523     if ( !( iWaitFetchmail->IsStarted() ) )
       
  3524         {
       
  3525         iWaitFetchmail->Start();
       
  3526         }
       
  3527     }
       
  3528 
       
  3529 // ---------------------------------------------------------
       
  3530 // CSpeedDialPrivate::ReleaseFetchMail
       
  3531 //
       
  3532 // ---------------------------------------------------------
       
  3533 //
       
  3534 void CSpeedDialPrivate::ReleaseFetchMail()
       
  3535     {
       
  3536     if ( iWaitFetchmail->IsStarted() )
       
  3537         {
       
  3538         iWaitFetchmail->AsyncStop();
       
  3539         }
       
  3540     }
       
  3541 
       
  3542 // ---------------------------------------------------------
  3422 // CSpeedDialPrivate::Cancel
  3543 // CSpeedDialPrivate::Cancel
  3423 // To cancel the aiw event
  3544 // To cancel the aiw event
  3424 // ---------------------------------------------------------
  3545 // ---------------------------------------------------------
  3425 //
  3546 //
  3426 TBool CSpeedDialPrivate::Cancel()
  3547 TBool CSpeedDialPrivate::Cancel()