コード例 #1
0
QList<CContactItemField *> CntTransformThumbnail::transformDetailL(const QContactDetail &detail)
{
    if(detail.definitionName() != QContactThumbnail::DefinitionName)
        User::Leave(KErrArgument);

    QList<CContactItemField *> fieldList;

    //cast to thumbnail
    const QContactThumbnail &thumbnail(static_cast<const QContactThumbnail&>(detail));

    //if thumbnail was not changed, use existing jpg image
    bool checksumExists;
    qint64 checksum = thumbnail.variantValue(KThumbnailChecksum).toLongLong(&checksumExists);
    if (!thumbnail.thumbnail().isNull() && checksumExists &&
            thumbnail.thumbnail().cacheKey() == checksum) {
        initializeThumbnailFieldL();
        CContactItemField *thumbnailField = CContactItemField::NewLC(*m_thumbnailFieldFromTemplate);
        QByteArray jpgData = thumbnail.variantValue(KThumbnailJpgImage).toByteArray();
        TPtrC8 ptr((TUint8*)jpgData.data(), jpgData.size());
        thumbnailField->StoreStorage()->SetThingL(ptr);
        fieldList.append(thumbnailField);
        CleanupStack::Pop(thumbnailField);
    } else if (!thumbnail.thumbnail().isNull()) {
        QByteArray jpgImage;
        QImage scaledImage;
        if (thumbnail.thumbnail().size().width() <= KMaxThumbnailSize.iWidth &&
                thumbnail.thumbnail().size().height() <= KMaxThumbnailSize.iHeight) {
            scaledImage = thumbnail.thumbnail();
        } else {
            scaledImage = thumbnail.thumbnail().scaled(
                              KMaxThumbnailSize.iWidth, KMaxThumbnailSize.iHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
        }
        if (!scaledImage.isNull()) {
            QBuffer buffer(&jpgImage);
            buffer.open(QIODevice::WriteOnly);
            scaledImage.save(&buffer, "JPG");
            buffer.close();
            initializeThumbnailFieldL();
            CContactItemField *thumbnailField = CContactItemField::NewLC(*m_thumbnailFieldFromTemplate);
            TPtrC8 ptr((TUint8*)jpgImage.data(), jpgImage.size());
            thumbnailField->StoreStorage()->SetThingL(ptr);
            fieldList.append(thumbnailField);
            CleanupStack::Pop(thumbnailField);
        }
    }

    return fieldList;
}
コード例 #2
0
TBool CPackagerCntComparator::DoCompareCContactItemFieldStorageTypeL(const CContactItemField& anItemField1, const CContactItemField& anItemField2) const
/** Compares two storage type items contained within their respective CContactItemField parent.

@param anItemField1 The first CContactItemField containing the storage type to be compared.
@param anItemField2 The second CContactItemField containing the storage type to be compared.
@return ETrue if the two items are equal, EFalse otherwise. */
	{
	// Check if storage type is same first, otherwise don't need to 
	// compare storage content.
	if(!DoCompareTUint(anItemField1.StorageType(), anItemField2.StorageType()))
		{
		return EFalse;
		}	
	
	TBool result = ETrue;
    switch (anItemField1.StorageType())
        {
    case KStorageTypeText:
		result = DoCompareTPtrC(anItemField1.TextStorage()->Text(), anItemField2.TextStorage()->Text());
        break;
        
    case KStorageTypeStore:
		result = (anItemField1.StoreStorage()->Thing()==anItemField2.StoreStorage()->Thing());
        break;
        
    case KStorageTypeDateTime:
		result = DoCompareTTime(anItemField1.DateTimeStorage()->Time(), anItemField2.DateTimeStorage()->Time());
        break;
        
    case KStorageTypeContactItemId:
		result = DoCompareTContactItemId(anItemField1.AgentStorage()->Value(), anItemField2.AgentStorage()->Value());
        break;
        
    default:
    	User::Leave(KErrNotSupported);
    	break;
        }
        		
	return result;	
	}
コード例 #3
0
//------------------------------------------------------------------------------------------------------------	
void CPerfTestContact::InsertBinaryFieldL(TUid aID, const TDesC8& aBufOfStuff )
	{
	CContactItemField*  itemFieldPtr = NULL;
	CContactStoreField* binStoragePtr = NULL;

	itemFieldPtr = CContactItemField::NewLC( KStorageTypeStore, aID );
	binStoragePtr = itemFieldPtr->StoreStorage(); // we don't have ownership here, hence no stack.

	binStoragePtr->SetThingL(aBufOfStuff);
	binStoragePtr = NULL; // we've finished with this ptr now.

	iContactItem->AddFieldL( *itemFieldPtr ); // hand ownership over here
	CleanupStack::Pop( itemFieldPtr ); // and pop,
	}	
コード例 #4
0
/*sets a specific contact field to a value as determined by its type.
field at aPos in aFields is set to aText*/
void CContactsRamTest::SetFieldL(const CContactItemField &aField, const TDesC& aText)
	{
	if( aField.IsTemplateLabelField() )
		{
		return;
		}
		
	if( 0 == aText.Size() )
		{
		return;
		}
	
	switch(aField.StorageType())
		{
		case KStorageTypeText:
			aField.TextStorage()->SetTextL(aText);
		break;
		case KStorageTypeStore:
			{
			HBufC8 *buf = HBufC8::NewLC(aText.Size());
			TPtr8 tptr8 = buf->Des();
			tptr8.Copy(aText);
			aField.StoreStorage()->SetThingL(*buf);
			CleanupStack::PopAndDestroy(buf);
			}
		break;
		case KStorageTypeContactItemId:
			{
			aField.AgentStorage()->SetAgentId( KAgentId );
			}
		break;
		case KStorageTypeDateTime:
			{
			if( aText.Size() > 0 ) 
				{
				aField.DateTimeStorage()->SetTime( TTime(KTime) );
				}
			else
				{
				aField.DateTimeStorage()->SetTime( TTime(0) );
				}
			}
		break;
		default:
			User::Panic(aText,EInvariantFalse);
		break;
		}
	}
コード例 #5
0
void CntThumbnailCreator::CreateContactFieldL()
{
    __ASSERT_DEBUG(m_imageData, User::Panic(KPanicCategory, KPanicUnitialized));

    initializeThumbnailFieldL();
    CContactItemField *thumbnailField = CContactItemField::NewLC(*m_thumbnailFieldFromTemplate);

    thumbnailField->StoreStorage()->SetThingL(*m_imageData);
    QT_TRYCATCH_LEAVING(m_fieldList->append(thumbnailField));
    CleanupStack::Pop(thumbnailField);

    // Complete request to proceed to the final state
    TRequestStatus *status = &iStatus;
    User::RequestComplete(status, KErrNone);
    SetActive();
}