// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
//
void CaSqlQueryCreator::CreateFindIconQueryL( CCaInnerEntry* aEntry,
        CCaSqlQuery* aQuery)
    {
    RBuf iconQuery;
    iconQuery.CleanupClosePushL();
    iconQuery.CreateL( KSQLGetIconIdWhere );

    if( aEntry->Icon()->FileName().Compare( KNullDesC ) )
        {
        iconQuery.ReAllocL( iconQuery.Length() + KSQLUpdateIconFileName().Length()
                + KAnd().Length() );
        iconQuery.Append( KSQLUpdateIconFileName );
        iconQuery.Append( KAnd );
        }
    else
        { 
        iconQuery.ReAllocL( iconQuery.Length() + KSQLEmptyIconFileName().Length()
                + KAnd().Length() );
        iconQuery.Append( KSQLEmptyIconFileName );
        iconQuery.Append( KAnd );
        }

    if( aEntry->Icon()->SkinId().Compare( KNullDesC ) )
        {
        iconQuery.ReAllocL( iconQuery.Length() + KSQLUpdateIconSkinId().Length()
                + KAnd().Length() );
        iconQuery.Append( KSQLUpdateIconSkinId );
        iconQuery.Append( KAnd );
        }
    else
        {
        iconQuery.ReAllocL( iconQuery.Length() + KSQLEmptyIconSkinId().Length()
                + KAnd().Length() );
        iconQuery.Append( KSQLEmptyIconSkinId );
        iconQuery.Append( KAnd );
        }

    if( aEntry->Icon()->ApplicationId().Compare( KNullDesC ) )
        {
        iconQuery.ReAllocL( iconQuery.Length() + KSQLUpdateIconAppId().Length()
                + KAnd().Length() );
        iconQuery.Append( KSQLUpdateIconAppId );
        iconQuery.Append( KAnd );
        }
    else
        {
        iconQuery.ReAllocL( iconQuery.Length() + KSQLEmptyIconAppId().Length()
                + KAnd().Length() );
        iconQuery.Append( KSQLEmptyIconAppId );
        iconQuery.Append( KAnd );
        }

    if (!iconQuery.Right(KAnd().Length()).Compare(KAnd))
        {    
        iconQuery.Delete( iconQuery.Length() - KAnd().Length(), KAnd().Length() );
        }
    
    aQuery->SetQueryL( iconQuery );
    CleanupStack::PopAndDestroy( &iconQuery );
    }
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
//
void CaSqlQueryCreator::CreateUpdateIconQueryL(
        const CCaInnerEntry* aEntry, CCaSqlQuery* aQuery )
    {
    DEBUG(("_CA_:CASqlQueryCreator::CreateUpdateIconQueryL"));
    RBuf query;
    query.CleanupClosePushL();
    query.CreateL( KSQLUpdateIcon().Length() );
    query.Append( KSQLUpdateIcon );
    if( aEntry->Icon()->FileName().Compare( KNullDesC ) )
        {
        query.ReAllocL( query.Length() + KSQLUpdateIconFileName().Length()
                + KComma().Length() );
        query.Append( KSQLUpdateIconFileName );
        query.Append( KComma );
        }
    if( aEntry->Icon()->SkinId().Compare( KNullDesC ) )
        {
        query.ReAllocL( query.Length() + KSQLUpdateIconSkinId().Length()
                + KComma().Length() );
        query.Append( KSQLUpdateIconSkinId );
        query.Append( KComma );
        }
     if( aEntry->Icon()->ApplicationId().Compare(KNullDesC) )
        {
        query.ReAllocL( query.Length() + KSQLUpdateIconAppId().Length()
                + KComma().Length() );
        query.Append( KSQLUpdateIconAppId );
        }
    if( !query.Right( KComma().Length() ).Compare( KComma ) )
        {
        query.Delete( query.Length() - KComma().Length(), KComma().Length() );
        }
    // add WHERE expr
    query.ReAllocL( query.Length() + KSQLUpdateIconWhere().Length() );
    query.Append( KSQLUpdateIconWhere );

    aQuery->SetQueryL( query );
    aQuery->SetTableType( CCaSqlQuery::EIconTable );

    CleanupStack::PopAndDestroy( &query );
    }
void CConeErrorMsgTestAppUi::TestLeaveWithErrorTextL(const TDesC& aErrorText, const TDesC* aContextErrorText, const TBool& aExceedMaxDesc)
	{
	RBuf testMsg;
	testMsg.CreateL(aErrorText);
	testMsg.CleanupClosePushL();
	
	TInt err=KErrNone;
	
	if (aContextErrorText)
		{
		RBuf testConMsg;
		testConMsg.CreateL(*aContextErrorText);
		testConMsg.CleanupClosePushL();
		TRAP(err,iCoeEnv->LeaveWithErrorText(testMsg, &testConMsg));
	
		TDes& errConRxText = static_cast<CTestCoeEnv*>(iCoeEnv)->TestErrorContextText();
		RBuf errConMsg;
		errConMsg.CreateL(errConRxText);
		errConMsg.CleanupClosePushL();
		INFO_PRINTF3(_L("Err Cntxt Msg Tx: %S, Err Cntxt Msg Rx: %S"), &testConMsg, &errConMsg);
		if (aExceedMaxDesc)
			{
			TEST(testConMsg!=errConMsg);
			TEST(errConMsg.Length()==80); // KErrorContextTextLength
			TEST(errConMsg[79]==KBaflCharTruncation);
			testConMsg.Delete(80, 1); // remove the last char
			testConMsg[79]=KBaflCharTruncation; // set the last char to the truncation char
			TEST(testConMsg==errConMsg);
			}
		else
			{
			TEST(testConMsg==errConMsg);
			}
		
		CleanupStack::PopAndDestroy(2);
		}
	else
		{
		TRAP(err,iCoeEnv->LeaveWithErrorText(testMsg));
		
		TDes& errConText = static_cast<CTestCoeEnv*>(iCoeEnv)->TestErrorContextText();
		INFO_PRINTF3(_L("Actual Context Length: %d, Expected Context Length: %d"), errConText.Length(), 0);			
		TEST(errConText.Length()==0);
		}

	INFO_PRINTF3(_L("Actual Leave Code: %d, Expected Leave Code: %d"), err, KErrExtendedWithText);
	TEST(err==KErrExtendedWithText);
	
	TDes& errRxText = ((CTestCoeEnv *)iCoeEnv)->TestErrorText();
	RBuf errMsg;
	errMsg.CreateL(errRxText);
	errMsg.CleanupClosePushL();
	INFO_PRINTF3(_L("Err Msg Tx: %S, Err Msg Rx: %S"), &testMsg, &errMsg);
	if (aExceedMaxDesc)
		{
		TEST(testMsg!=errMsg);
		TEST(errMsg.Length()==80); // KErrorTextLength
		TEST(errMsg[79]==KBaflCharTruncation);
		testMsg.Delete(80, 1); // remove the last char
		testMsg[79]=KBaflCharTruncation; // set the last char to the truncation char
		TEST(testMsg==errMsg);
		}
	else
		{
		TEST(testMsg==errMsg);
		}

	CleanupStack::PopAndDestroy(2);
	}