// -----------------------------------------------------------------------------
// TSnapshotItem::CreateHashL
// Create hash value from group content
// -----------------------------------------------------------------------------
void TSnapshotItem::CreateHashL( CContactGroup& aGroup )
    {
    CMessageDigest* hash = CMessageDigestFactory::NewDigestLC( CMessageDigest::EMD5 );
    
    if ( aGroup.HasItemLabelField() )
        {
        TPtrC label = aGroup.GetGroupLabelL();
        HBufC8* tempBuf = CnvUtfConverter::ConvertFromUnicodeToUtf8L( label );
        CleanupStack::PushL( tempBuf );
        hash->Update( tempBuf->Des() );
        CleanupStack::PopAndDestroy( tempBuf );
        }
    
    // Create text field from items on group
    CContactIdArray* contactsIdArray = aGroup.ItemsContainedLC();
    const TInt idBufferMaxSize( 400 );
    HBufC8* tempIdBuf = HBufC8::NewLC( idBufferMaxSize );
    TPtr8 tempId = tempIdBuf->Des();
    const TInt KMaxNumLength(5);
    if ( contactsIdArray ) // this is NULL if there are no objects
        {
        tempId.AppendNum( contactsIdArray->Count(), EHex );
        for (TInt i=0; i< contactsIdArray->Count(); i++ )
            {
            if ( tempId.Length()+KMaxNumLength > tempId.MaxLength() )
                {
                // buffer is almost full, don't add any new items
                LOGGER_WRITE("buffer full");
                break;
                }
            // add item id
            tempId.AppendNum( (*contactsIdArray)[i] , EHex );
            }
        }
    else
        {
        tempId.AppendNum( 0 );
        }
    // update hash
    hash->Update( tempId );
    
    iHash.Copy( hash->Final() );
    
    CleanupStack::PopAndDestroy( tempIdBuf );
    CleanupStack::PopAndDestroy( contactsIdArray );
    CleanupStack::PopAndDestroy( hash );
    }
Exemple #2
0
void CTestConductor::CreateGroupTestDataL()
	{
	CContactGroup* groupOne = static_cast<CContactGroup*>(iDb->CreateContactGroupL(KGroupOneName));
	CContactIdArray* idsInGroupViewOne = NULL;

	CleanupStack::PushL(groupOne);

	iGroupOneId = groupOne->Id();
	for (TInt ii=1;ii<=KNumContactsInGroupOne;++ii)
		{
		test.Printf(_L("Making Group Contact %d \n"),ii);
		iDb->AddContactToGroupL(ii,iGroupOneId);
		}

	CleanupStack::PopAndDestroy(groupOne);

	groupOne = static_cast<CContactGroup*>(iDb->ReadContactL(iGroupOneId));
	CleanupStack::PushL(groupOne);

	idsInGroupViewOne = groupOne->ItemsContainedLC();
	CleanupStack::PopAndDestroy(idsInGroupViewOne);
	CleanupStack::PopAndDestroy(groupOne);
	}