Esempio n. 1
0
void CCntMatchLog::ReadContactNameL(TLogContactItemId aContactId, TDes &aName, TLogContactNameFormat aNameFormat)
	/** Gets the text data for the family and given name fields of a given contact Id.
	
	@capability ReadUserData
	@param aContactId Contact Id to find data for
	@param aName On return contains the family and given name in the desired format if found, a 0 length string otherwise.
	@param aNameFormat Desired format of returned string - Chinese or Western format */
	{
		
	// Specify what fields to fetch and concatenate
	CContactTextDef* textDef = CContactTextDef::NewLC();
	_LIT(KRemotePartyNameSeparator, " ");	
	
	if(ELogChineseFormat == aNameFormat)
		{
		textDef->AppendL(TContactTextDefItem(KUidContactFieldFamilyName, KRemotePartyNameSeparator));
		textDef->AppendL(TContactTextDefItem(KUidContactFieldGivenName));
		}
	else //ELogWesternFormat == iContactNameFormat
		{
		textDef->AppendL(TContactTextDefItem(KUidContactFieldGivenName, KRemotePartyNameSeparator));
		textDef->AppendL(TContactTextDefItem(KUidContactFieldFamilyName));
		}
	textDef->SetExactMatchOnly(ETrue);
	iContactDb->ReadContactTextDefL(aContactId, aName, textDef);
	CleanupStack::PopAndDestroy(textDef);
	}
/**
Change the sorting order/text definition. It should be always called when 
there is not an iteration started in persistence layer.

@param aTextDef the new text definition to be used in the view session.
*/
void CCntPplViewSession::ChangeSortOrderL(const CContactTextDef& aTextDef)
	{
	//Cleanup the cached Prepare statement as the sort order will be changed
	Cancel();
    CleanupCachedPrepareStatement();
	
	//Copy the text definition
	CContactTextDef* textDef = CContactTextDef::NewLC();
	const TInt KTextDefCount = aTextDef.Count();
	for (TInt index = 0; index < KTextDefCount; ++index)
		{
		textDef->AppendL(TContactTextDefItem(aTextDef.At(index).iFieldType));
		}
	
	// Create select statement on contact table
	TCntSqlStatementType statementType(ESelect, KSqlContactTableName());
	CCntSqlStatement* sqlSmt = TSqlProvider::GetSqlStatementL(statementType);
	CleanupStack::PushL(sqlSmt);
	
	// Always select id, type flags.	
	sqlSmt->SetParamL(KContactId(), KSpace());
	sqlSmt->SetParamL(KContactTypeFlags(), KSpace());
	
	//Go through text definition to construct select statement.
	TBool isFastAccessOnly = ETrue;
	for(TInt ii = 0; ii < KTextDefCount; ++ii)
		{
		const TDesC& KColunmName = TCntPersistenceUtility::GetFastAccessColumnNameById(aTextDef.At(ii).iFieldType.iUid);
		if(KColunmName.Length() > 0) 
			{
			sqlSmt->SetParamL(KColunmName, KSpace());
			}
		else
			{
			isFastAccessOnly = EFalse;		
			}
		}
	
	if(!isFastAccessOnly)
		{
		//Fields in text blob are needed, add text fields header and
        //text blob columns in the select statement.		
		sqlSmt->SetParamL(KContactTextFieldHeader(), KSpace());
		sqlSmt->SetParamL(KContactTextFields(), KSpace());
		}

	CleanupStack::Pop(2, textDef); // sqlSmt, textDef.
	
	delete iCntSqlStatement;
	iCntSqlStatement = sqlSmt;
	
	delete iTextDef;
	iTextDef = textDef;
	
	iIsFastAccessFieldsOnly = isFastAccessOnly;
	}
CContactTextDef* CPackagerCntFactory::doCreateDefaultCContactTextDefL() const
/** Implementation method for constructing a new default CContactTextDef object. 

@return a Pointer to the CContactTextDef object. */
	{
	CContactTextDef* theTextDef = CContactTextDef::NewLC();
	theTextDef->AppendL(TContactTextDefItem(KUidContactFieldFamilyName));
	theTextDef->AppendL(TContactTextDefItem(KUidContactFieldGivenName));
	theTextDef->AppendL(TContactTextDefItem(KUidContactFieldCompanyName));
	theTextDef->AppendL(TContactTextDefItem(KUidContactFieldAddress));
	theTextDef->AppendL(TContactTextDefItem(KUidContactFieldEMail));
	theTextDef->AppendL(TContactTextDefItem(KUidContactFieldAdditionalName));
	CleanupStack::Pop(theTextDef);
	return theTextDef;
	}