Example #1
0
LOCAL_C void test1(CArrayFix<TText>& aFix)
//
	{
	test.Next(_L("AppendL and InsertL single chars"));
	aFix.AppendL(_S("abcd"),4);
	test(aFix[0]=='a');
	test(aFix[1]=='b');
	test(aFix[3]=='d');
	test(aFix.Count()==4);
	aFix.InsertL(2,_S("ef"),2);
	test(aFix[1]=='b');
	test(aFix[2]=='e');
	test(aFix[4]=='c');
	test(aFix.Count()==6);	
	aFix.AppendL(TText('z'));
	test(aFix[6]=='z');
	aFix.InsertL(0,TText('y'));
	test(aFix[0]=='y');
	test(aFix[1]=='a');
	test(aFix.Count()==8);
	test.Next(_L("Delete single chars"));
	aFix.Delete(3);
	test(aFix[2]=='b');
	test(aFix[3]=='f');
	test(aFix[4]=='c');
	aFix.Delete(1,2);
	test(aFix[0]=='y');
	test(aFix[1]=='f');
	test(aFix[2]=='c');
	test(aFix.Count()==5);
	aFix.Compress();
	}
// ---------------------------------------------------------
// FavouritesUtil::ExternalizeL
// ---------------------------------------------------------
//
void FavouritesUtil::ExternalizeL
( const CArrayFix<TInt>& aArray, RWriteStream& aStream )
{
    aStream.WriteInt32L( aArray.Count() );
    for ( TInt i = 0; i < aArray.Count(); i++ )
    {
        aStream.WriteInt32L( aArray[ i ] );
    }
}
Example #3
0
EXPORT_C TInt FontUtils::GetAvailableHeightsInTwipsAndPointsL(const CGraphicsDevice& aDevice,const TDesC& aTypefaceName,CArrayFix<TInt>& aTwipsList,CDesCArray& aPointsList)
/** Gets a list of all heights in twips, available for the named typeface and the 
graphics device specified.

Also gets a list of heights in points, represented as character strings.

@param aDevice The graphics device.
@param aTypefaceName The name of the typeface.
@param aTwipsList On return, contains all available heights for the typeface, 
in twips.
@param aPointsList On return, the heights in points, represented as character 
strings.
@return KErrNotSupported if the named typeface is not supported by the graphics 
device, otherwise KErrNone. */
	{ // static
	aTwipsList.Reset();
	aPointsList.Reset();
	TInt err=GetAvailableHeightsInTwipsL(aDevice,aTypefaceName,aTwipsList);
	if (err==KErrNotSupported)
		return err;
	const TInt count=aTwipsList.Count();
	for (TInt ii=0;ii<count;ii++)
		{
		const TInt points=PointsFromTwips(aTwipsList[ii]);
		if (points<EMinFontHeight)
			continue;
		TBuf<8> num;
		num.Num(points);
		aPointsList.AppendL(num);
		}
	return KErrNone;
	}
// -----------------------------------------------------------------------------
// CPIMAgnToDoAdapter::ExportItemL
// (other items were commented in a header)
// -----------------------------------------------------------------------------
//
void CPIMAgnToDoAdapter::ExportItemL(const MPIMToDoItem& aItem,
                                     CCalEntry& aEntry, TBool aResetEntry)
{
    JELOG2(EPim);
    if (aResetEntry)
    {
        // Reset native entry for exporting new data
        aEntry.SetSummaryL(KNullDesC());
        aEntry.SetDescriptionL(KNullDesC());
        aEntry.SetPriorityL(0);
        aEntry.SetCompletedL(EFalse, aEntry.CompletedTimeL());
    }

    // Export item data to the native ToDo calendar entry
    const MPIMItemData& itemData = aItem.ItemData();
    CArrayFix<TPIMField>* fields = itemData.FieldsLC();

    // Add default values to the calendar entry
    AddDefaultValuesToEntryL(itemData, aEntry);

    // Convert each field to the native ToDo calendar entry
    TInt count = fields->Count();
    for (TInt i = 0; i < count; i++)
    {
        TPIMToDoField field = static_cast<TPIMToDoField>(fields->At(i));
        ConvertToAgnL(field, aEntry, itemData);
    }
    CleanupStack::PopAndDestroy(fields);
}
EXPORT_C TBool AknPhoneNumberTextUtils::WrapPhoneNumberToArrayL( 
    const TDesC& aPhoneNumberToWrap,
    TInt aLineWidthInPixels,
    TInt aMaxLines,
    const CFont& aFont,
    CArrayFix<TPtrC>& aWrappedArray )
    {
    TBool retVal( EFalse ); // Not truncated
 
    HBufC* reversedText = aPhoneNumberToWrap.AllocLC();
    TPtr revPtr = reversedText->Des();

    ReverseDescriptor( revPtr );

    CArrayFix<TInt>* lineWidthArray = new (ELeave) CArrayFixFlat<TInt>(KLineArrayGranularity);
    CleanupStack::PushL( lineWidthArray );

    lineWidthArray->AppendL( aLineWidthInPixels, aMaxLines );

    // Perform the wrap on the reversed text
    AknTextUtils::WrapToArrayL( revPtr, *lineWidthArray, aFont, aWrappedArray );

    // Now rearrange the TPtrCs to point to the original array
    TInt totalLen = reversedText->Length();
    TInt count = aWrappedArray.Count();
    TInt usedLen = 0; // Accumulates the length actually used
    for ( TInt index = 0; index < count; index++)
        {
        TPtrC& currentPtr = aWrappedArray.At(index);
        // The TPtrCs have to be moved. The reversing is taken into effect, but not purely reversed
        // because their otherwise they would have negative lengths.  That is, {a,b} does not go to
        // { final - a, final - b }, but rather to {final - b, final - a}; they are flipped, to get
        // their start points before the end points
        //
        // Now, representing the start position by pos, and the end by pos+len-1 we have the TPtrC at
        // {pos, pos+len-1} inclusive, in reversed array. 
        // The TPtrC must be modified to point to {total_len-1 - (pos+len-1), total_len-1 - pos} 
        // in the unreversed array:
        TInt len = currentPtr.Length();
        usedLen += len;
        TInt pos = currentPtr.Ptr() - reversedText->Ptr(); // pointer arithmetic
        TInt newPos = totalLen - pos - len;
        // If the TPtr is zero length then it must get special treatment, as the normal
        // calculations give an end point before the start point! i.e. {pos, pos-1}
        // We handle this by NOT flipping in this case.
        // { pos, pos-1 } -> {totalLen-1-pos, totalLen-1 - (pos-1)}
        // Note that a zero length wrapped line is completely possible amoung a bunch of other 
        // lines with characters on them, as the line lengths may be of wildly different lengths.
        if ( len == 0 ) 
            newPos--;
        currentPtr.Set( aPhoneNumberToWrap.Mid(newPos, len) );
        }

    // If the accumulated length is less than that in the entire input descriptor, then text does not fit
    if ( usedLen < totalLen )
        retVal = ETrue;

    CleanupStack::PopAndDestroy(2); // lineWidthArray first, and then reversedText
    return retVal;
    }
// -----------------------------------------------------------------------------
// CPIMEventPropertyConverter::ConvertExceptionDatesL
// Inserts exceptiondates to a parser.
// -----------------------------------------------------------------------------
//
void CPIMEventPropertyConverter::ConvertExceptionDatesL(const CArrayFix<
        TPIMDate>& aDates, CParserVCalEntity& aParser)
{
    JELOG2(EPim);
    TInt exDateCount = aDates.Count();
    if (exDateCount > 0)
    {
        CArrayPtrFlat<TVersitDateTime>* versitExDates =
            new(ELeave) CArrayPtrFlat<TVersitDateTime> (exDateCount);
        CleanupStack::PushL(versitExDates);
        CleanupResetAndDestroyPushL(*versitExDates);
        for (TInt i = 0; i < exDateCount; i++)
        {
            TVersitDateTime
            * versitDateTime =
                new(ELeave) TVersitDateTime(aDates.At(i).DateTime(), TVersitDateTime::EIsUTC);
            CleanupDeletePushL(versitDateTime);
            versitExDates->AppendL(versitDateTime);
            CleanupStack::Pop(versitDateTime); // versitDateTime
        }
        CParserPropertyValue* propertyValue =
            new(ELeave) CParserPropertyValueMultiDateTime(versitExDates);
        CleanupStack::Pop(2); // versitExDates is now owned by propertyValue
        AddPropertyToParserL(propertyValue, KVersitTokenEXDATE(), aParser);
        // Needed cleanup stack items are popped out in the AddPropretyToParserL
    }
}
Example #7
0
void QtFallbackWebPopup::showS60BrowserDialog()
{
    static MBrCtlDialogsProvider* dialogs = CBrowserDialogsProvider::NewL(0);
    if (!dialogs)
        return;

    int size = itemCount();
    CArrayFix<TBrCtlSelectOptionData>* options = new CArrayFixFlat<TBrCtlSelectOptionData>(qMax(1, size));
    RPointerArray<HBufC> items(qMax(1, size));
    CleanupStack::PushL(TCleanupItem(&ResetAndDestroy, &items));

    for (int i = 0; i < size; i++) {
        if (itemType(i) == Separator) {
            TBrCtlSelectOptionData data(_L("----------"), false, false, false);
            options->AppendL(data);
        } else {
            HBufC16* itemStr = HBufC16::NewL(itemText(i).length());
            itemStr->Des().Copy((const TUint16*)itemText(i).utf16(), itemText(i).length());
            CleanupStack::PushL(itemStr);
            TBrCtlSelectOptionData data(*itemStr, i == currentIndex(), false, itemIsEnabled(i));
            options->AppendL(data);
            items.AppendL(itemStr);
            CleanupStack::Pop();
        }
    }

    dialogs->DialogSelectOptionL(KNullDesC(), (TBrCtlSelectOptionType)(ESelectTypeSingle | ESelectTypeWithFindPane), *options);

    CleanupStack::PopAndDestroy(&items);

    int newIndex;
    for (newIndex = 0; newIndex < options->Count() && !options->At(newIndex).IsSelected(); newIndex++) {}
    if (newIndex == options->Count())
        newIndex = currentIndex();
    
    m_popupVisible = false;
    popupDidHide();

    if (currentIndex() != newIndex && newIndex >= 0)
        valueChanged(newIndex);

    delete options;
}
// -----------------------------------------------------------------------------
// CPIMAgnEventAdapter::ConvertFieldsToAgnL
// Reads PIM Item fields and converts them into Agenda entry's fields.
// -----------------------------------------------------------------------------
//
void CPIMAgnEventAdapter::ConvertFieldsToAgnL(const MPIMEventItem& aItem,
        CCalEntry& aEntry)
{
    JELOG2(EPim);
    CArrayFix<TPIMField>* fields = aItem.ItemData().FieldsLC();
    TInt amount = fields->Count();

    for (int i = 0; i < amount; i++)
    {
        TPIMEventField field = static_cast<TPIMEventField>(fields->At(i));
        switch (field)
        {
        case EPIMEventSummary: // Fallthrough
        case EPIMEventLocation: // Fallthrough
        case EPIMEventNote:
        {
            ConvertStringFieldToAgnL(aItem, aEntry, field);
            break;
        }
        case EPIMEventAlarm:
        {
            ConvertAlarmToAgnL(aItem, aEntry);
            break;
        }
        case EPIMEventStart: // Fallthrough
        case EPIMEventEnd:
        {
            ConvertDateFieldToAgnL(aItem, aEntry, field);
            break;
        }
        case EPIMEventClass:
        {
            ConvertClassToAgnL(aItem, aEntry);
            break;
        }
        case EPIMEventRevision: // fallthrough
        case EPIMEventUid:
        {
            // nothing
            break;
        }
        default:
        {
            User::Leave(KErrArgument);
        }
        }
    }
    CleanupStack::PopAndDestroy(fields);
}
// -----------------------------------------------------------------------------
// CPIMEventPropertyConverter::GetRepeatRuleFieldsL
// Gets the fields from a repeat rule
// -----------------------------------------------------------------------------
//
void CPIMEventPropertyConverter::GetRepeatRuleFieldsL(
    const MPIMRepeatRuleData* aRepeat, // Fields are read from this
    TInt* aInterval, // interval is stored here
    TInt* aFrequency, // frequency is stored here
    TVersitDateTime** aVersitEndDate) // end date is stored here
{
    JELOG2(EPim);
    TBool endExists = EFalse;
    CArrayFix<TPIMField>* repeatFields = aRepeat->GetFieldsL();
    CleanupStack::PushL(repeatFields);
    TInt fieldCount = repeatFields->Count();
    for (TInt i = 0; i < fieldCount; i++)
    {
        switch (repeatFields->At(i))
        {
        case EPIMRepeatRuleFrequency:
        {
            *aFrequency = aRepeat->GetIntL(EPIMRepeatRuleFrequency);
            break;
        }
        case EPIMRepeatRuleInterval:
        {
            *aInterval = aRepeat->GetIntL(EPIMRepeatRuleInterval);
            break;
        }
        case EPIMRepeatRuleEnd:
        {
            endExists = ETrue;
            break;
        }
        default:
        {
            // We ignore other fields
        }
        }
    }
    CleanupStack::PopAndDestroy(repeatFields);
    if (endExists)
    {
        TPIMDate endDate = aRepeat->GetDateL(EPIMRepeatRuleEnd);
        *aVersitEndDate
        = new(ELeave) TVersitDateTime(endDate.DateTime(), TVersitDateTime::EIsUTC);
    }
}
Example #10
0
TInt TDmAdUtil::FindLargestLocallyCreated(const CArrayFix<TSmlDmMappingInfo>& aPreviousUriSegmentList)
    {
    TRACE("TDmAdUtil::FindLargestLocallyCreated");
    TInt largest = 0;
    for (TInt i=0; i < aPreviousUriSegmentList.Count(); i++)
        {
        const TSmlDmMappingInfo& mappingInfo = aPreviousUriSegmentList.At(i);        
        if (mappingInfo.iURISeg.Find(KDmAdLocallyCreatedRtNodeUriSegPrefix) == 0)
            {            
            TPtrC8 numberPart(mappingInfo.iURISeg.Mid(KDmAdLocallyCreatedRtNodeUriSegPrefix().Length()));
            TInt number = TDmAdUtil::DesToInt(numberPart);
            if (number > largest)
                {
                largest = number;
                }
            }
        }
    return largest;
    }
Example #11
0
EXPORT_C TInt FontUtils::IndexOfNearestHeight(CArrayFix<TInt>& aTwipsList,TInt aHeight)
/** Gets the index into the supplied list of font heights of the closest  
match to the font height specified.

@param aTwipsList The twips list.
@param aHeight The requested font height. This may be generated by a call to GetAvailableHeightsInTwipsL() 
or GetAvailableHeightsInTwipsAndPointsL().
@return The index into the list of the closest font height to aHeight. */
	{ // static
	TInt pos=0;
	const TInt count=aTwipsList.Count();
	for (TInt ii=0; ii<count; ii++)
		{
		if (aTwipsList[ii]>aHeight)
			break;
		pos=ii;
		}
	return pos;
	}
Example #12
0
TBool CDataWrapperBase::GetPointListFromConfigL(const TDesC& aSectName, const TDesC& aKeyName, CArrayFix<TPoint>& aResult)
	{
	TBuf<KMaxTestExecuteCommandLength>	tempStore;
	TPoint								point;

	aResult.Reset();
	TBool	ok=ETrue;
	for ( TInt index=0; ok; )
		{
		tempStore.Format(KFormatFieldNumber, &aKeyName, ++index);
		ok=GetPointFromConfig(aSectName, tempStore, point);
		if ( ok )
			{
			aResult.AppendL(point);
			}
		}

	return aResult.Count()>0;
	}
Example #13
0
/**
Convert between view indexes and contact ids.
This method makes the request to the server.
@capability ReadUserData
 */
void RContactRemoteView::GetContactIdsL(const CArrayFix<TInt>& aIndexes, CContactIdArray& aContactIds)
    {
    CBufBase* buffer = CBufFlat::NewL(32);
    CleanupStack::PushL(buffer);
    RBufWriteStream writeStream(*buffer);
    CleanupClosePushL(writeStream);

    const TInt count = aIndexes.Count();
    writeStream.WriteUint32L(count);
    for (TInt i=0; i<count; ++i)
        {
        writeStream.WriteUint32L(aIndexes[i]);
        }
    writeStream.CommitL();
    CleanupStack::PopAndDestroy(&writeStream); //writeStream.Close()


    TPtr8 indexes(buffer->Ptr(0));
    const TInt bufferSize = buffer->Size();
    TPckg<TInt> size(bufferSize);
    
    HBufC8* buf=HBufC8::NewLC(bufferSize);
    TPtr8 ids(buf->Des());
    
    TIpcArgs args(&size, &indexes, &ids);
    User::LeaveIfError(SendReceive(ECntGetContactIds,args));


    RDesReadStream readStream(ids);
    CleanupClosePushL(readStream);
    CContactIdArray* array = CContactIdArray::NewLC();
    readStream >> *array;

    const TInt arrayCount = array->Count();
    for(TInt loop=0;loop<arrayCount;loop++)
        aContactIds.AddL((*array)[loop]);

    CleanupStack::PopAndDestroy(4,buffer); //array, &readStream, buf, buffer
    }
Example #14
0
RPointerArray<CX509Certificate> PkiUtil::GetCaCertListL(RPKIServiceAPI& aPkiService,
        const CArrayFixFlat<TCertInfo*>& aIkeCAList)
{

    __ASSERT_ALWAYS(aIkeCAList.Count() > 0, User::Invariant());
    _LIT8(KEmptyString, "");

    RPointerArray<CX509Certificate> certificateArray;
    ResetAndDestroyPushL(certificateArray);

    RArray<TUid> applUidArray;
    CleanupClosePushL(applUidArray);

    for (TInt i = 0; i < aIkeCAList.Count(); ++i)
    {
        const TCertInfo* certInfo = aIkeCAList[i];
        switch(certInfo->iFormat)
        {
        case CA_NAME:
        {
            // Reserve enough space for UTF-8
            TInt len = 3*( certInfo->iData.Length() );
            HBufC8* caName = HBufC8::NewLC(len);
            TPtr8 caNamePtr(caName->Des());

            if (CnvUtfConverter::ConvertFromUnicodeToUtf8(caNamePtr, certInfo->iData) != 0)
            {
                User::Leave(KErrCorrupt);
            }

            CX509Certificate* cert = ReadCertificateLC(aPkiService,
                                     KEmptyString,
                                     *caName,
                                     KEmptyString,
                                     EPKICACertificate);

            User::LeaveIfError(certificateArray.Append(cert));
            CleanupStack::Pop(cert);
            CleanupStack::PopAndDestroy(caName);
        }
        break;
        case KEY_ID:
        {
            TPKIKeyIdentifier keyId(NULL);

            for (TInt j = 0; j < certInfo->iData.Length(); j += 2)
            {
                TPtrC hexByte(certInfo->iData.Mid(j, 2));
                TLex lex(hexByte);
                TUint8 value;
                User::LeaveIfError(lex.Val(value, EHex));
                keyId.Append(&value, 1);
            }

            CX509Certificate* cert = ReadCertificateLC(aPkiService,
                                     keyId);
            User::LeaveIfError(certificateArray.Append(cert));
            CleanupStack::Pop(cert);
        }
        break;
        case APPL_UID:
        {
            TLex lex(certInfo->iData);
            TUint32 value;
            User::LeaveIfError(lex.Val(value, EHex));
            TUid id = { value };
            User::LeaveIfError(applUidArray.Append(id));
        }
        break;
        default:
            User::Leave(KErrArgument);
            break;
        }
    }

    if (applUidArray.Count() > 0)
    {
        CArrayFix<TCertificateListEntry>* certListArray = NULL;;
        aPkiService.ListApplicableCertificatesL(applUidArray, certListArray);

        CleanupStack::PushL(certListArray);
        if (certListArray->Count() == 0)
        {
            User::Leave(KErrNotFound);
        }

        for (TInt i = 0; i < certListArray->Count(); ++i)
        {
            TCertificateListEntry entry = (*certListArray)[i];
            if (entry.iOwnerType == EPKICACertificate)
            {
                CX509Certificate* cert = ReadCertificateLC(aPkiService,
                                         KEmptyString,
                                         entry.iIdentitySubjectName,
                                         KEmptyString,
                                         EPKICACertificate);
                User::LeaveIfError(certificateArray.Append(cert));
                CleanupStack::Pop(cert);
            }
        }
        CleanupStack::PopAndDestroy(certListArray);
    }

    CleanupStack::PopAndDestroy(); //applUidArray

    CleanupStack::Pop();
    return certificateArray;
}
Example #15
0
DMAD_EXPORT_C void TDmAdUtil::BuildRtNodeChildUriListL(MDmAdCallBack*                          aDmAdCallBack,
                                                  MDmAdStoreApi*                          aStoreApi,
                                                  const TDesC8&                           aUri,
                                                  const TDesC8&                           aParentLuid,
                                                  const CArrayFix<TSmlDmMappingInfo>&     aPreviousUriSegmentList,
                                                  CBufBase&                               aCurrentList)
    {
#ifdef DMAD_DUMP_PREVIOUS_URI_SEGMENT_LIST
        DEBUG_LOG(_L("BuildRtNodeChildUriListL:"));
        {
        for (TInt i=0; i < aPreviousUriSegmentList.Count(); i++)
            {
            const TSmlDmMappingInfo& mappingInfo = aPreviousUriSegmentList.At(i);
                        
            DEBUG_LOG1(_L("entry %d:"), i);            
            DEBUG_LOG1(_L8("Uri: %S"), &(mappingInfo.iURISeg));
            DEBUG_LOG_HEX(mappingInfo.iURISegLUID);
            
            }
        }
#endif

    RPointerArray<HBufC8> luidList;
    CleanupStack::PushL(TCleanupItem(PointerArrayCleanup, &luidList));
    
    aStoreApi->LuidListL(aUri, aParentLuid, luidList);


    // Finds largest number used in cli<x> named nodes.
    TInt largest = FindLargestLocallyCreated(aPreviousUriSegmentList);
    DEBUG_LOG1(_L("largest is cli%d"), largest);
    
    TInt countLuidList = luidList.Count();
    for (TInt j=0; j < countLuidList; j++)
        {
        const HBufC8* luidElem = luidList[j];

        HBufC8* uriSeg = 0;
        
        //Tries to find the luid from the aPreviousUriSegmentList
        for (TInt i=0; i < aPreviousUriSegmentList.Count(); i++)
            {
            const TSmlDmMappingInfo& mappingInfo = aPreviousUriSegmentList.At(i);
                        
            if (mappingInfo.iURISegLUID.Compare(*luidElem) == 0)
                {            
                uriSeg = mappingInfo.iURISeg.AllocLC();
                break;
                }
            }
        
        if (uriSeg == 0)
            {
            //Uri was not found from the aPreviousUriSegmentList
            uriSeg = BuildLocallyCreatedRtNodeUriSegLC(largest);
            
            DEBUG_LOG2(_L8("uriSeg %S, largest %d"), uriSeg, largest);
            
            HBufC8* wholeUri = TDmAdUtil::BuildUriLC(aUri, *uriSeg);            
            aDmAdCallBack->SetMappingL(*wholeUri, *luidElem);
            CleanupStack::PopAndDestroy(); //wholeUri
            }

        //If this is not the first element, inserts slash at the beginning
        //of the result list.
        if (j > 0)
            {            
            aCurrentList.InsertL(aCurrentList.Size(), KDmAdSeparator);
            }
        aCurrentList.InsertL(aCurrentList.Size(), *uriSeg);
        
        CleanupStack::PopAndDestroy(); // uriSeg
        }
    
    CleanupStack::PopAndDestroy(); //luidList
    }
LOCAL_C TBool TestGetBodyTextL()
	{
	__UHEAP_MARK;
	// Retrieve the store from the current context... 
	CMsvStore* store = pContext->EditStoreL();
	CleanupStack::PushL(store);
	
	// Populate CMsvBodyText from the data in the store...
	CMsvBodyText* obj = CMsvBodyText::NewLC();
	obj->RestoreL(*store);
	
	// Create a rich text object...
	CParaFormatLayer* paraLayer = CParaFormatLayer::NewL();
	CleanupStack::PushL(paraLayer);
	CCharFormatLayer* charLayer = CCharFormatLayer::NewL();
	CleanupStack::PushL(charLayer);
	CRichText* richText = CRichText::NewL(paraLayer, charLayer);
	CleanupStack::PushL(richText);
	
	// Create an array of available character sets...
	CArrayFix<CCnvCharacterSetConverter::SCharacterSet>* charSets;
	CCnvCharacterSetConverter* converter = CCnvCharacterSetConverter::NewL();
	CleanupStack::PushL(converter);
	charSets = converter->CreateArrayOfCharacterSetsAvailableLC(gFs);
	
	// For each available character set, call GetBodyTextL...
	TInt i;
	for (i = 0; i < charSets->Count(); i++)
		{
		// Over-ride the stored character set.
		obj->SetCharacterSet((*charSets)[i].Identifier());
		// Convert the 8 bit data to the specified character set.
		obj->GetBodyTextL(gFs, *store, *richText);
		test(richText->HasChanged());
		richText->Reset();
		}
	
	// Instead of decoding 10 bytes of data, increase the amount of data to 4000 bytes.
	obj->SetCharacterSet(0);
	obj->SetDefaultCharacterSet((*charSets)[0].Identifier());
	const TInt KTextBufferSize=4000;
	CBufBase *buffer=CBufFlat::NewL(KTextBufferSize);
	CleanupStack::PushL(buffer);
	while(buffer->Size()<KTextBufferSize)
		{
		buffer->InsertL(buffer->Size(),K10BytesData);
		}

	obj->StoreL(*store, *buffer);
	CleanupStack::PopAndDestroy(buffer);
	store->CommitL();
	obj->RestoreL(*store);
	obj->GetBodyTextL(gFs, *store, *richText);
	test(richText->HasChanged());
	
	// Clean up and release resources...
	CleanupStack::PopAndDestroy(charSets);
	CleanupStack::PopAndDestroy(converter);
	CleanupStack::PopAndDestroy(richText);
	CleanupStack::PopAndDestroy(charLayer);
	CleanupStack::PopAndDestroy(paraLayer);
	CleanupStack::PopAndDestroy(obj);
	CleanupStack::PopAndDestroy(store);
	__UHEAP_MARKEND;
		
	return ETrue;
	}
void CIkeV2PkiService::ImportNextCaElemFromIkeDataListL()
    {        
    __ASSERT_DEBUG(iIkeDataCAList != NULL, User::Invariant());
    __ASSERT_DEBUG(iIkeDataCAList->Count() > 0, User::Invariant());
    
    const TCertInfo certInfo = (*iIkeDataCAList)[0];        
    switch(certInfo.iFormat)
        {            
        case CA_NAME:    
            delete iSubjName;
            iSubjName = NULL;
            iSubjName = HBufC8::NewL(certInfo.iData.Length());
            iSubjName->Des().Copy(certInfo.iData);                    
        	iPkiService.ReadCertificateL(KEmptyString,
                                         *iSubjName, KEmptyString,
		                                 EPKICACertificate, 0,
		                                 EPKIRSA, iCertPtr,
		                                 &iResArray, iStatus);
            SET_ACTIVE;  
            break;                  
        case KEY_ID:
            if (!IkeParser::TextToHexOctets(certInfo.iData, iCertKeyId))
                {
                User::Leave(KErrArgument);
                }
            iPkiService.ReadCertificateL(iCertKeyId, iCertPtr,
            			                 &iResArray, iStatus);
            SET_ACTIVE;                     
            break;
       case APPL_UID:           
            {            
            //Get the list of applicable CA certs and appends it
            //to the original list, which was defined in the policy.
            //After this removes the currently handled node and
            //calls the method recursively.
            RArray<TUid>*  applUidList = IkeParser::GetApplUidListL(certInfo.iData);	
            CleanupStack::PushL(TCleanupItem(CIkeV2PkiServiceApplUidArrayCleanup,
                                 applUidList));

            CArrayFix<TCertificateListEntry>* applicableCaCertList;
            iPkiService.ListApplicableCertificatesL(*applUidList, applicableCaCertList);                                
            
            CleanupStack::PopAndDestroy(); //applUidList
                        
            if (applicableCaCertList->Count() > 0)
                {                                            
                CleanupStack::PushL(applicableCaCertList);
                TCertInfo* info = new (ELeave) TCertInfo;
                CleanupDeletePushL(info);
                for (TInt i = 0; i < applicableCaCertList->Count(); i++)
                    {
                    const TCertificateListEntry& entry = (*applicableCaCertList)[i];
                    info->iFormat = CA_NAME;
                    info->iData.Zero();
                    info->iData.Copy(entry.iIdentitySubjectName);

                    iIkeDataCAList->AppendL(*info);
                    DEBUG_LOG1(_L("Appending Applicable cert to the list (%S)"), &(info->iData));
                                                
                    }
                
                CleanupStack::PopAndDestroy(info);
                CleanupStack::PopAndDestroy(applicableCaCertList);
                
                iIkeDataCAList->Delete(0);                
                ImportNextCaElemFromIkeDataListL();
                }
            else
                {
                delete applicableCaCertList;
                applicableCaCertList = NULL;
                
                iStatus = KRequestPending;
                SET_ACTIVE;
                
                TRequestStatus* status = &iStatus;
                User::RequestComplete(status, KErrNotFound);                
                }                                                                
            }
            break;
        default:
            User::Leave(KErrArgument);                
            break;
        }
    }
Example #18
0
LOCAL_C void testFix(CArrayFix<TBuf<0x10> >& aFix)
//
// Test all methods
//
	{
	test.Next(_L("Test all methods"));
	test(aFix.Count()==0);
	test(aFix.Length()==sizeof(TBuf<0x10>));
	aFix.Compress();
	test(TRUE);
	aFix.Reset();
	test(TRUE);
	TKeyArrayFix kk(0,ECmpNormal,0x10);
	test(TRUE);
	aFix.Sort(kk);
	test(TRUE);
	TBuf<0x10> aa(_L("aaaaa"));
	aFix.InsertL(0,aa);
	test(TRUE);
	aFix[0].Fill(' ');
	test(TRUE);
	TBuf<0x10> z(aFix[0]);
    z.Length();
	test(TRUE);
	aFix[0].Fill('a');
	test(TRUE);
	TInt pp;
	test(aFix.Find(aa,kk,pp)==0);
	test(pp==0);
	aFix.Delete(0);
	TBuf<0x10> bb(_L("bbbbb"));
	aFix.AppendL(bb);
	test(aFix.Count()==1);
	test(aFix.InsertIsqAllowDuplicatesL(aa,kk)==0);
	test(aFix.InsertIsqAllowDuplicatesL(bb,kk)==2);
	test(aFix.FindIsq(aa,kk,pp)==0);
	test(pp==0);
	aFix.Reset();
	for(TInt index=0;index<KTestGranularity*7/2;index++)
		aFix.AppendL(aa);
	const TBuf<0x10> *end=NULL;
	const TBuf<0x10> *ptr=NULL;
	for(TInt index2=0;index2<KTestGranularity*7/2;index2++)
		{
		if (end==ptr)
			{
			end=aFix.End(index2);
			ptr=&aFix[index2];
			TInt seglen=end-ptr;
			test(seglen==KTestGranularity || seglen==(aFix.Count()-index2));
			}
		test(&aFix[index2]==ptr++);
		}
	const TBuf<0x10> *bak=NULL;
	ptr=NULL;
	for(TInt index3=KTestGranularity*7/2;index3>0;index3--)
		{
		if (bak==ptr)
			{
			bak=aFix.Back(index3);
			ptr=&aFix[index3-1]+1;
			TInt seglen=ptr-bak;
			test(seglen==KTestGranularity || seglen==index3 || seglen==index3%KTestGranularity);
			}
		test(&aFix[index3-1]==--ptr);
		}
	
	//Test ExpandL
	//Expand array in slot 1
	TBuf16<0x10> exp;
	exp=_L("abc AbC");
	aFix.InsertL(0,exp);
	aFix.InsertL(1,exp);
	aFix.InsertL(2,exp);
	exp=aFix.ExpandL(1);
	test(aFix[0]==_L("abc AbC"));
	test(aFix[1]==_L(""));
	test(aFix[2]==_L("abc AbC"));
	test(aFix[3]==_L("abc AbC"));
	
	//Test ResizeL and InsertReplL
	//Resize the array to containing 20 records,
	//copying a record into any new slots.
	TBuf<0x10> res(_L("bbbbb"));
	aFix.Reset();
	aFix.ResizeL(20,res);
	for(TInt i=0;i<20;i++)
	    {
        test(aFix[1]==_L("bbbbb"));
	    }
	}
Example #19
0
LOCAL_C void test2(CArrayFix<TArr<TText,4> >& aFix)
//
	{
	test(aFix.Length()==sizeof(TArr<TText,4>));
	test.Next(_L("AppendL and insert strings of length 4"));
	TPtrC des1=_L("abcd");
	TPtrC des2=_L("efgh");
	aFix.AppendL(*(const TArr<TText,4>*)des1.Ptr());
	aFix.AppendL(*(const TArr<TText,4>*)des2.Ptr());
	test(aFix.Count()==2);
	TPtrC des3(&aFix[0][0],4);
	TPtrC des4(&aFix[1][0],4);
	test(des3==_L("abcd"));
	test(des4==_L("efgh"));
	aFix.InsertL(1,*(const TArr<TText,4>*)_S("ijkl"));
	test(aFix.Count()==3);	
	TPtrC des5(&aFix[2][0],4);
	test(des3==_L("abcd"));
	test(des4==_L("ijkl"));
	test(des5==_L("efgh"));

	test.Next(_L("Reset and Compress"));
	aFix.Reset();
	TBuf<0x10> buf1=_L("abcdefgh");
	aFix.AppendL((const TArr<TText,4>*)buf1.Ptr(),2);
	aFix.Compress();
	TPtrC des6(&aFix[0][0],4);
	test(des6==_L("abcd"));
	TPtrC des7(&aFix[1][0],4);
	test(des7==_L("efgh"));
	buf1=_L("ghighhxy");
	aFix.InsertL(1,(const TArr<TText,4>*)buf1.Ptr(),2);
	aFix.Compress();
	TPtrC des8(&aFix[0][0],4);
	test(des8==_L("abcd"));
	TPtrC des9(&aFix[1][0],4);
	test(des9==_L("ghig"));
	TPtrC des10(&aFix[2][0],4);
	test(des10==_L("hhxy"));
	TPtrC des11(&aFix[3][0],4);
	test(des11==_L("efgh"));

	test.Next(_L("Sort strings"));
	TKeyArrayFix kk(0,ECmpNormal,0x04);
	aFix.Sort(kk);
	TPtrC des12(&aFix[0][0],4);
	test(des12==_L("abcd"));
	TPtrC des13(&aFix[1][0],4);
	test(des13==_L("efgh"));
	TPtrC des14(&aFix[2][0],4);
	test(des14==_L("ghig"));
	TPtrC des15(&aFix[3][0],4);
	test(des15==_L("hhxy"));
	
	test.Next(_L("Find and FindIsq"));
	aFix.Compress();
	test(aFix.InsertIsqL(*(const TArr<TText,4>*)_S("ffff"),kk)==2);
	aFix.Compress();
	test(aFix.InsertIsqAllowDuplicatesL(*(const TArr<TText,4>*)_S("ffff"),kk)==3);
	aFix.Compress();
	TRAPD(r,aFix.InsertIsqL(*(const TArr<TText,4>*)_S("ffff"),kk))
	test(r==KErrAlreadyExists);
	TInt aPos=0;
	test(aFix.Find(*(const TArr<TText,4>*)_S("xxxx"),kk,aPos)==1);
	test(aPos==6);
	test(aFix.Find(*(const TArr<TText,4>*)_S("abcd"),kk,aPos)==0);
	test(aPos==0);
	test(aFix.Find(*(const TArr<TText,4>*)_S("ghig"),kk,aPos)==0);
	test(aPos==4);
	test(aFix.Find(*(const TArr<TText,4>*)_S("ffff"),kk,aPos)==0);
	test(aPos==2);
	test(aFix.Find(*(const TArr<TText,4>*)_S("hhxy"),kk,aPos)==0);
	test(aPos==5);
	test(aFix.FindIsq(*(const TArr<TText,4>*)_S("bbbb"),kk,aPos)!=0);
	test(aPos==1);
	test(aFix.FindIsq(*(const TArr<TText,4>*)_S("abcd"),kk,aPos)==0);
	test(aPos==0);
	test(aFix.FindIsq(*(const TArr<TText,4>*)_S("ghig"),kk,aPos)==0);
	test(aPos==4);
	test(aFix.FindIsq(*(const TArr<TText,4>*)_S("ffff"),kk,aPos)==0);
	test(aPos==2);
	test(aFix.InsertIsqL(*(const TArr<TText,4>*)_S("fghz"),kk)==4);
	test(aFix.FindIsq(*(const TArr<TText,4>*)_S("fghz"),kk,aPos)==0);
	test(aPos==4);
	test(aFix.FindIsq(*(const TArr<TText,4>*)_S("hhxy"),kk,aPos)==0);
	test(aPos==6);
	}
Example #20
0
// -----------------------------------------------------------------------------
// CWPRoot::CreateLinksL
// -----------------------------------------------------------------------------
//
void CWPRoot::CreateLinksL()
    {
    FLOG( _L( "[Provisioning] CWPRoot::ParameterL2:" ) );
    
    iNeeders.Reset();
    delete iNeededIDs;
    iNeededIDs = NULL;
    iNeededIDs = new(ELeave) CDesCArrayFlat( KIDArrayGranularity );
    delete iProviderIDs;
    iProviderIDs = NULL;
    iProviderIDs = new(ELeave) CDesCArrayFlat( KIDArrayGranularity );

    AcceptL( *this );

    // We now have arrays of links and targets of links. Put them together.
    for( TInt i( 0 ); i < iNeeders.Count(); i++ )
        {
        CWPCharacteristic* needer = iNeeders[i];
        TPtrC neededID( iNeededIDs->MdcaPoint( i ) );

        TBool foundProvider( EFalse );
        for( TInt j( 0 ); j < iProviders.Count() && !foundProvider; j++ )
            {
            CWPCharacteristic* needed = iProviders[j];
            TPtrC providerID( iProviderIDs->MdcaPoint( j ) );

            if( providerID == neededID )
                {
            	if ( needer->Type() == KWPPxPhysical && needed->Type() != KWPNapDef)
            		{
            		// incorrect link found. do nothing.
            		}
            	else
            		{
#ifndef __SYNCML_DM_OTA
					FLOG ( _L( "[Provisioning] CWPRoot::CreateLinksL*********** __SYNCML_DM_OTA ***********" ) );
            		if (KWPApplication == needer->Type())
            			{
            			_LIT( KNSmlDMProvisioningDMAppIdVal, "w7" );
            			FLOG (_L( "[Provisioning] CWPRoot::CreateLinksL:Needer is Application" ) );
            			
            			CArrayFix<TPtrC>* name = new(ELeave) CArrayFixFlat<TPtrC>(1);
				        CleanupStack::PushL(name);
				        				        
				        needer->ParameterL(EWPParameterAppID, name);
				        
				        if ((name->Count() > 0)
				        	&&
				        	0 == name->At(0).Compare(KNSmlDMProvisioningDMAppIdVal) )
				            {
				            CleanupStack::PopAndDestroy(); // name
            				continue;
				            }
				            
				        
				        CleanupStack::PopAndDestroy(); // name
            			}
            		FLOG ( _L( "[Provisioning] CWPRoot::CreateLinksL:*********** __SYNCML_DM_OTA ***********" ) );
#endif
            		
                    needer->InsertLinkL( *needed );
                    foundProvider = ETrue;
            		}
                }
            }
        }
    
    // Free the temporary memory
    iNeeders.Reset();
    iProviders.Reset();
    delete iNeededIDs;
    iNeededIDs = NULL;
    delete iProviderIDs;
    iProviderIDs = NULL;
    }