// -----------------------------------------------------------------------------
// CCMSEncapsulatedContentInfo::DecodeL
// Decrypts raw data to this instance
// -----------------------------------------------------------------------------
void CCMSEncapsulatedContentInfo::DecodeL( const TDesC8& aRawData )
	{
	CArrayPtr<TASN1DecGeneric>* itemsData = DecodeSequenceLC( aRawData,
															  KMinNumberOfSubModules,
															  KMaxNumberOfSubModules );
	// we would not get this far if there is not atleast one
	// decoding attribute type
	TASN1DecObjectIdentifier decOid;
	HBufC* oid = decOid.DecodeDERL( *itemsData->At( 0 ) );
	delete iContentType;
	iContentType = oid;

	// decoding possible content
	HBufC8* contDesc = NULL;
	if( itemsData->Count() > 1 )
		{
		TASN1DecGeneric taggedContent( *itemsData->At( 1 ) );
		if( taggedContent.Tag() != KContentTag )
			{
			User::Leave( KErrArgument );
			}
		TASN1DecOctetString content;
		TInt pos = 0;
		contDesc = content.DecodeDERL( taggedContent.GetContentDER(), pos );
		}
	delete iContent;
	iContent = contDesc;
	CleanupStack::PopAndDestroy( itemsData );
	}
void COCSPResponseDecoder::DecodeBasicOCSPResponseL(const TDesC8& aEncoding)
    {
    CArrayPtr<TASN1DecGeneric>* items = DecodeSequenceLC(aEncoding, 3, 4);

    // First, the ResponseData object
    DecodeResponseDataL(items->At(0)->Encoding());

    // Continue, with the AlgorithmIdentifier
    iResponse->iSigningAlgorithm = CX509SigningAlgorithmIdentifier::NewL(items->At(1)->Encoding());

    // Now move on to the signature
    TASN1DecBitString encBS;
    iResponse->iSignature = encBS.ExtractOctetStringL(*items->At(2));

    // And finally, the certs (if they're there)
    if (items->Count() == 4)
        {
        // Check explicit tag [0]
        TASN1DecGeneric& certsDec = *items->At(3);
        if (certsDec.Tag() != KCertificatesTag)
            {
            User::Leave(OCSP::EMalformedResponse);
            }

        // It's OK, so decode the response bytes object therein
        DecodeCertificatesL(certsDec.GetContentDER());
        }

    CleanupStack::PopAndDestroy(items);
    }
void COCSPResponseDecoder::DecodeOCSPResponseL(const TDesC8& aEncoding)
    {
    CArrayPtr<TASN1DecGeneric>* items = DecodeSequenceLC(aEncoding, 1, 2);

    // Use integer decoding for enumerated
    TASN1DecInteger decInt;
    TInt status = decInt.DecodeDERShortL(*items->At(0));
    if (status == ESuccessfulEncoding)
        {
        if (items->Count() != 2)
            {
            User::Leave(OCSP::EMalformedResponse);
            }

        // Check tag on second part is [0]
        // We ignore any other parts in the sequence after that
        TASN1DecGeneric& responseBytesDec = *items->At(1);
        if (responseBytesDec.Tag() != KResponseBytesTag)
            {
            User::Leave(OCSP::EMalformedResponse);
            }

        // It's OK, so decode the response bytes object therein
        DecodeResponseBytesL(responseBytesDec.GetContentDER());
        }
    else
        {
        if (items->Count() != 1)
            {
            User::Leave(KErrArgument);
            }

        switch (status)
            {
            case EMalformedRequestEncoding:
                User::Leave(OCSP::EMalformedRequest);
            case EInternalErrorEncoding:
                User::Leave(OCSP::EServerInternalError);
                break;
            case ETryLaterEncoding:
                User::Leave(OCSP::ETryLater);
                break;
            case ESigRequiredEncoding:
                User::Leave(OCSP::ESignatureRequired);
                break;
            case EUnauthorisedEncoding:
                User::Leave(OCSP::EClientUnauthorised);
                break;
            default:
                User::Leave(OCSP::EMalformedResponse);
            }
        }
        CleanupStack::PopAndDestroy(items);
    }
void COCSPResponseDecoder::DecodeResponseExtensionL(const TDesC8& aEncoding)
    {
    CArrayPtr<TASN1DecGeneric>* items = DecodeSequenceLC(aEncoding, 2, 3);

    // Get oid
    TASN1DecGeneric& oid = *items->At(0);
    if (oid.Tag() != EASN1ObjectIdentifier)
        {
        User::Leave(OCSP::EMalformedResponse);
        }

    TASN1DecObjectIdentifier oidDec;
    HBufC* oidVal = oidDec.DecodeDERL(oid);
    CleanupStack::PushL(oidVal);

    TBool critical = EFalse; // Default value of critical flag
    if (items->Count() == 3)
        {
        // The critical flag is specified - what does it say?
        TASN1DecBoolean decBool;
        critical = decBool.DecodeDERL(*items->At(1));
        }

    TASN1DecGeneric& extnVal = items->Count() == 3 ? *items->At(2) : *items->At(1);
    if (extnVal.Tag() != EASN1OctetString)
        {
        User::Leave(OCSP::EMalformedResponse);
        }

    // Check oid to decide what to do
    if (*oidVal == KOCSPOidNonce)
        {
        iResponse->iNonce.Set(extnVal.GetContentDER());
        }
    else if (*oidVal == KOCSPOidArchiveCutoff)
        {
        TASN1DecGeneralizedTime decGT;
        TInt pos = 0;
        iResponse->iArchiveCutoff = new (ELeave) TTime(decGT.DecodeDERL(extnVal.GetContentDER(), pos));
        }
    else if (critical)
        {
        // Didn't understand extension, and it was critical!  Erk!
        User::Leave(OCSP::EUnknownCriticalExtension);
        }

    CleanupStack::PopAndDestroy(2, items); // oidVal, items
    }
// -----------------------------------------------------------------------------
// CCMSAuthenticatedData::DecodeAttributesL
// Decodes an array of attributes
// -----------------------------------------------------------------------------
CArrayPtrFlat< CCMSAttribute >* CCMSAuthenticatedData::DecodeAttributesL(
    TASN1DecGeneric* aAttributesDec ) // generic decoder for the sequence
    {
    TASN1DecSequence sequenceDecoder;
    CArrayPtr< TASN1DecGeneric >* attributes =
        sequenceDecoder.DecodeDERLC( *aAttributesDec );
    TInt attributeCount = attributes->Count();
    if( attributeCount <  1 )
        {
        User::Leave( KErrArgument );
        }
    CArrayPtrFlat< CCMSAttribute >* retVal =
        new( ELeave ) CArrayPtrFlat< CCMSAttribute >( attributeCount );
    CleanupStack::PushL( retVal );
    for( TInt i = 0; i < attributeCount; i++ )
        {
        CCMSAttribute* attribute = CCMSAttribute::NewLC();
        attribute->DecodeL( attributes->At( i )->Encoding() );
        retVal->AppendL( attribute );
        // attribute is left in cleanup stack, as retVal has not been pushed
        // with ResetAndDestroyPushL
        }
    CleanupStack::Pop( attributeCount ); // all attributes
    CleanupStack::Pop( retVal );
    CleanupStack::PopAndDestroy( attributes );
    return retVal;
    }
// -----------------------------------------------------------------------------
// CNSmlNotepadDatabase::ResetL
// -----------------------------------------------------------------------------
//
TInt CNSmlNotepadDatabase::ResetL()
	{
	_NOTEPAD_DBG_FILE("CNSmlNotepadDatabase::ResetL(): begin");
	
    TInt err(KErrNone);
    CArrayPtr<CNpdItem>* arrNpdItem = NULL;
    
    // Fetch all the available notes from the db
    arrNpdItem = FetchItemsLC();
      
    // Delete the Notes
    for( TInt count = 0; count < arrNpdItem->Count(); count++ )
        {
        CCalEntry* entryTobeDeleted(NULL);
        entryTobeDeleted = iEntryView->FetchL( arrNpdItem->At(count)->Key() );
        if(entryTobeDeleted)
            {
            CleanupStack::PushL(entryTobeDeleted);
            iEntryView->DeleteL(*entryTobeDeleted);
            CleanupStack::Pop(entryTobeDeleted);
            }        
        delete entryTobeDeleted;
        entryTobeDeleted = NULL;
        }
    CleanupStack::PopAndDestroy(arrNpdItem);
    _NOTEPAD_DBG_FILE("CNSmlNotepadDatabase::ResetL(): begin");
    return err;
	}
// -----------------------------------------------------------------------------
// CSIPSettListSIPProfSetADestListItem::EditItemL
// Called before the pop-up list is shown. Updates it, if there was a 
// non-matching destination UID at the start-up 
// -----------------------------------------------------------------------------
//
void CSIPSettListSIPProfSetDestListItem::EditItemL( 
    TBool aCalledFromMenu )
    {
    __GSLOGSTRING("CSIPSettListSIPProfSetDestListItem::EditItemL" )
    // Set backup value.
    iBackupValue = iEnumValue;
        
    if ( iEnumValue == KUnknownAPUID )
        {
        // destination was not found, create list for user to change the 
        // destination.
        // The destination will be anyway changed; no matter does the user
        // press Cancel or not..(Chosen destination will be the first one 
        // on the list, if user presses Cancel)        
        CArrayPtr<CAknEnumeratedText>* textArray = NULL;
        CArrayPtr<HBufC>* nullTextArray = NULL;
        InitializeListL( textArray, nullTextArray );     

        if ( textArray->Count() > KErrNone )
            {
            // There might be situation that no destinationss exist.
            iEnumValue = textArray->At( KErrNone )->EnumerationValue();
            }

        SetEnumeratedTextArrays( textArray, nullTextArray );    
        HandleTextArrayUpdateL();
        }
    
    CAknEnumeratedTextPopupSettingItem::EditItemL( aCalledFromMenu );
    }
// -----------------------------------------------------------------------------
// CCMSX509GeneralNames::DecodeL
// Decrypts raw data to this instance
// -----------------------------------------------------------------------------
void CCMSX509GeneralNames::DecodeL( const TDesC8& aRawData )
	{
    CArrayPtr< TASN1DecGeneric >* nameData =
        DecodeSequenceLC( aRawData );
    TInt nameCount = nameData->Count();
    if( nameCount == 0 )
        {
        User::Leave( KErrArgument );
        }
    CArrayPtr< CCMSX509GeneralName >* names =
        new( ELeave ) CArrayPtrFlat< CCMSX509GeneralName >( nameCount );
    CleanupStack::PushL( names );
    for( TInt i = 0; i < nameCount; i++ )
        {
        CCMSX509GeneralName* name = CCMSX509GeneralName::NewL( );
        CleanupStack::PushL( name );
        name->DecodeL( nameData->At( i )->Encoding() );
        names->AppendL( name );
        }
    CleanupStack::Pop( nameCount ); // names
    CleanupStack::Pop( names );
    CleanupStack::PopAndDestroy( nameData );
    if( iGeneralNames )
        {
        iGeneralNames->ResetAndDestroy();
        delete iGeneralNames;
        }
    iGeneralNames = names;
	}
TInt CJuikIconManagerImpl::FindEmptySlotL()
{
	for ( TInt i = 0; i < iIconArray->Count(); i++ )
		{
			if ( iIconArray->At(i) == NULL ) 
				return i;
		}
	return KErrNotFound;
}
void CEncapsulatedContentInfo::ConstructL(const TDesC8& aRawData)
	{	
	const TInt minItems = 1;	// Must have OID
	const TInt maxItems = 2;	// Must have data
	CArrayPtr<TASN1DecGeneric>* contentInfo = PKCS7ASN1::DecodeSequenceLC(aRawData, minItems, maxItems);
	
	//Decode Content Type	
	iContentType=(TCmsContentInfoType)(CmsUtils::DecodeContentTypeL(contentInfo->At(0)));
	
	//Decode Content Data
	if(contentInfo->Count() == 2)
		{
		iIsContentDataPresent=ETrue;
		const TASN1DecGeneric* contentInfoAt1 = contentInfo->At(1);
		
		//Decode [0] Explicit
		if ( contentInfoAt1->Tag() == 0 || contentInfoAt1->Class() == EContextSpecific )
			{
			//Decode Wrapper Octet string	
			TASN1DecGeneric decGen(contentInfoAt1->GetContentDER());
			decGen.InitL();
			if(decGen.Tag() == EASN1OctetString && decGen.Class() == EUniversal)
				{
				iContentData.Set(decGen.GetContentDER());
				}
			else
				{
				//Wrapper is not an Octect String
				User::Leave(KErrArgument);
				}			
			}
		else
			{
			//Not [0] Explicit
			User::Leave(KErrArgument);
			}
		}
	else
		{
		//No optional data
		iContentData.Set(KNullDesC8());	
		}
	CleanupStack::PopAndDestroy(contentInfo);
	}	
// ------------------------------------------------------------------------------------------------
// CNSmlDataModBase::MergeL
// Merges data from old item to new item.
// ------------------------------------------------------------------------------------------------
void CNSmlDataModBase::MergeL( TDes8& aNewItem, const TDesC8& aOldItem,TBool aFieldLevel )
	{
	TBool modified( EFalse );
	CVersitParser* newItemParser = ChildCreateParserLC();
	RDesReadStream newStream( aNewItem );
	CleanupClosePushL( newStream );
	newItemParser->InternalizeL( newStream );
	CVersitParser* oldItemParser = ChildCreateParserLC();
	RDesReadStream oldStream( aOldItem );
	CleanupClosePushL( oldStream );
	oldItemParser->InternalizeL( oldStream );

	// Now we're ready to start analysis
	CArrayPtr<CVersitParser>* newEntities = newItemParser->ArrayOfEntities( EFalse );
	CArrayPtr<CVersitParser>* oldEntities = oldItemParser->ArrayOfEntities( ETrue );

	if( newEntities && oldEntities )
		{
		CleanupPtrArrayPushL( oldEntities );
		for( TInt i = 0; ( i < newEntities->Count() ) && ( i < oldEntities->Count() ); i++ )
			{
			MergeEntityL( newEntities->At( i ), oldEntities->At( i ), modified, aFieldLevel );
			}
		CleanupStack::PopAndDestroy(); // oldEntities
		}
	else
		{
		MergeEntityL( newItemParser, oldItemParser, modified, aFieldLevel );
		}

	// Only update if anything was modified in process
	if ( modified )
		{
		aNewItem.Zero();
		RDesWriteStream dws( aNewItem );
		CleanupClosePushL( dws );
		newItemParser->ExternalizeL( dws );
		dws.CommitL();
		CleanupStack::PopAndDestroy(); // dws
		}

	CleanupStack::PopAndDestroy( 4 ); // oldStream, oldItemParser, newStream, newItemParser
	}
// -----------------------------------------------------------------------------
// CCMSOriginatorPublicKey::DecodeL
// Decrypts raw data to this instance
// -----------------------------------------------------------------------------
void CCMSOriginatorPublicKey::DecodeL( const TDesC8& aRawData )
	{
    TASN1DecGeneric decGen( aRawData );
    decGen.InitL();
    TASN1DecSequence decSeq;
    CArrayPtr< TASN1DecGeneric >* itemsData =
        decSeq.DecodeDERLC( decGen );
    TInt count = itemsData->Count();
    if( count != KNumberOfSubModules )
        {
        User::Leave( KErrArgument );
        }
	// we would not get this far if there is not 2 elements

	// decoding algorithm identifier
    CCMSX509AlgorithmIdentifier* algorithm =
        CCMSX509AlgorithmIdentifier::NewL( );
    CleanupStack::PushL( algorithm );
    algorithm->DecodeL( itemsData->At( 0 )->Encoding() );
    CleanupStack::Pop( algorithm );
    delete iAlgorithm;
    iAlgorithm = algorithm;

	// decoding public key
	TASN1DecGeneric gen( *itemsData->At( 1 ) );
	gen.InitL();
    // Symbian decoder can't handle zero length bit strings
    if( gen.LengthDERContent() > 1 )
        {
        TASN1DecBitString bitStringDecoder;
        HBufC8* tmp = bitStringDecoder.ExtractOctetStringL( gen );
        delete iPublicKey;
        iPublicKey = tmp;
        }
    else
        {
        HBufC8* tmp = KNullDesC8().AllocL();
        delete iPublicKey;
        iPublicKey = tmp;
        }

	CleanupStack::PopAndDestroy( itemsData );
	}
Beispiel #13
0
void CDmAdEngine::CompleteCommandsL(CArrayPtr<CDmAdRtNode>& aRtNodes, TInt aStatus)
    {
    TRACE("CDmAdEngine::CompleteCommandsL");
    
    for (TInt i=0; i < aRtNodes.Count(); i++)
        {
        CDmAdRtNode* rtNode = aRtNodes.At(i);
        CompleteCommandsL(*rtNode, aStatus);
        }
    }
CArrayFix<TInt>& CJuikIconManagerImpl::ProviderIconIndexL(TInt aProviderId) const
{
	CALLSTACKITEM_N(_CL("CJuikIconManagerImpl"), _CL("ProviderIconIndexL"));
	AssertIndexL( *iProviderIconIndexes, aProviderId );
	CArrayFix<TInt>* map = iProviderIconIndexes->At(aProviderId);
	if ( map )
		return *map;
	else
		Bug( _L("Trying to get removed provider") ).ErrorCode( MakeErrorCode( CONTEXT_UID_JAIKUUIKIT, KErrNotFound ) ).Raise();
	return *map; // to please compiler
}
void COCSPResponseDecoder::DecodeResponsesL(const TDesC8& aEncoding)
    {
    CArrayPtr<TASN1DecGeneric>* items = DecodeSequenceLC(aEncoding);
    TInt count = items->Count();
    for (TInt index = 0; index < count; ++index)
        {
        DecodeSingleResponseL(items->At(index)->Encoding());
        }

    CleanupStack::PopAndDestroy(items);
    }
//********************************************************************************************
void CVersitCardTest::CheckNumberOfSoundPropertiesL(const TDesC& aFileName, const CParserVCard& aParser, TInt aExpectedArrayElementCount, TInt aExpectedPropertyCount)
//
//	Check that the number of SOUND sub-elements are as expected
//
	{
    TheTest.Printf(_L("%S\n"), &aFileName);
    (void) aFileName;
    //
    TBool passedTest = EFalse;
    CArrayPtr<CParserProperty>* properties = aParser.PropertyL(KVersitTokenSOUND, TUid::Uid(KVersitPropertyHBufCUid), EFalse);
    TheTest(properties != NULL);
    if  (properties)
        {
        //
        CleanupStack::PushL(properties);
        const TInt count = properties->Count();
        TheTest(count == aExpectedPropertyCount);
        //
        for(TInt i=0; i<count; i++)
            {
            const CParserProperty* property = properties->At(i);

            // Check that the X-IRMC-N property parameter exists
            const TBool foundParam = property->Param(KSoundExtensionPropertyParameterName) != NULL;
	        TheTest(foundParam);

            // Check property value
            TheTest(property->Value() != NULL);

            CParserPropertyValueHBufC* propertyAsHBufC = static_cast<CParserPropertyValueHBufC*>(property->Value());

            // Check property value as an array
            CParserPropertyValueCDesCArray* valueAsArray = propertyAsHBufC->TreatAsArrayPropertyLC(*property);
            TheTest(valueAsArray->Value() != NULL);
            CDesCArray& array = *valueAsArray->Value();
            //
            const TInt arrayItemCount = array.Count();
            TheTest(arrayItemCount == aExpectedArrayElementCount);
            for(TInt j=0; j<arrayItemCount; j++)
                {
                const TPtrC pValue(array[j]);
                TheTest.Printf(_L("%S\n"), &pValue);
                }
            TheTest.Printf(_L("\n"));
            CleanupStack::PopAndDestroy(valueAsArray);
            //
            passedTest = ETrue;
            }

        CleanupStack::PopAndDestroy(properties);
        }
    TheTest(passedTest);
	}
void COCSPResponseDecoder::DecodeResponseBytesL(const TDesC8& aEncoding)
    {
    CArrayPtr<TASN1DecGeneric>* items = DecodeSequenceLC(aEncoding, 2, 2);

    TASN1DecObjectIdentifier decOid;
    HBufC* oid = decOid.DecodeDERL(*items->At(0));
    CleanupStack::PushL(oid);
    if (*oid != KOCSPOidBasic)
        {
        User::Leave(OCSP::EUnknownResponseType);
        }

    TASN1DecGeneric& response = *items->At(1);
    if (response.Tag() != EASN1OctetString)
        {
        User::Leave(OCSP::EMalformedResponse);
        }

    DecodeBasicOCSPResponseL(response.GetContentDER());

    CleanupStack::PopAndDestroy(2, items); // oid, items
    }
void CCmsContentInfo::ConstructL(const TDesC8& aRawData)
	{
	const TInt minItems = 2;	// Must have OID
	const TInt maxItems = 2;	// Must have data
	CArrayPtr<TASN1DecGeneric>* contentInfo = PKCS7ASN1::DecodeSequenceLC(aRawData, minItems, maxItems);
	
	//Decode Content Type	
	iContentType=(TCmsContentInfoType)(CmsUtils::DecodeContentTypeL(contentInfo->At(0)));

	//Decode Content Data
	const TASN1DecGeneric* contentInfoAt1 = contentInfo->At(1);
	if ( contentInfoAt1->Tag() == 0 || contentInfoAt1->Class() == EContextSpecific )
		{
		TASN1DecGeneric decGen(contentInfoAt1->GetContentDER());
		decGen.InitL();
		if (iContentType==EContentTypeData)
			{
			if (decGen.Tag()!=EASN1OctetString || decGen.Class()!=EUniversal)
				{
				User::Leave(KErrArgument);	
				}
			else
				{
				iContentData.Set(decGen.GetContentDER());	
				}
			}
		else
			{
			iContentData.Set(decGen.Encoding());				
			}
		}
	else
		{
		User::Leave(KErrArgument);	
		}
		
	CleanupStack::PopAndDestroy(contentInfo);
	}
CArrayPtr<CGulIcon>* CJuikIconManagerImpl::GetProviderIconsL( TInt aProviderId ) 
{
	CALLSTACKITEM_N(_CL("CJuikIconManagerImpl"), _CL("GetProviderIconsL"));
	CArrayFix<TInt>& map = ProviderIconIndexL(aProviderId);
	auto_ptr< CArrayPtr<CGulIcon> >  result( new (ELeave) CArrayPtrFlat<CGulIcon>(map.Count()) );
	for( TInt i=0; i < map.Count(); i++)
		{
			if ( map[i] >= 0 )
				result->AppendL( iIconArray->At( map[i] ) );
			else
				result->AppendL( NULL );
		}
	return result.release();
}
Beispiel #20
0
void CmsUtils::DecodeDigestAlgorithmsL(RPointerArray<CX509AlgorithmIdentifier>& aDigestAlgorithms, const TDesC8& aRawData)
	{
	CArrayPtr<TASN1DecGeneric>* algsData = PKCS7ASN1::DecodeSequenceLC(aRawData);
	TInt count = algsData->Count();
	CX509AlgorithmIdentifier* alIdent;

	for(TInt item = 0; item < count; item++)
		{
 		alIdent = CX509AlgorithmIdentifier::NewLC(algsData->At(item)->Encoding());
		aDigestAlgorithms.AppendL(alIdent);
		CleanupStack::Pop(alIdent);
		}
	CleanupStack::PopAndDestroy(algsData);			
	}
// -----------------------------------------------------------------------------
// CSIPSettListSIPProfSetTypeListItem::EditItemL
// Called before the pop-up list is shown. Updates it, if there was a 
// non-matching AP UID at the start-up 
// -----------------------------------------------------------------------------
//
void CSIPSettListSIPProfSetTypeListItem::EditItemL( 
    TBool aCalledFromMenu )
    {
    __GSLOGSTRING("CSIPSettListSIPProfSetTypeListItem::EditItemL Start" )
    CArrayPtr<CAknEnumeratedText>* array = EnumeratedTextArray();
    TBool found = EFalse;
    TInt i( 0 );
    for ( i = 0; i < array->Count(); i++ )
        {
        if ( array->At( i )->EnumerationValue() == iEnumValue )
            {
            found = ETrue;
            }
        }

    if ( !found && array->Count() > KErrNone )
        {
        iEnumValue = array->At( 0 )->EnumerationValue();
        }
    
    CAknEnumeratedTextPopupSettingItem::EditItemL( aCalledFromMenu );
    __GSLOGSTRING("CSIPSettListSIPProfSetTypeListItem::EditItemL End" )
    }
// ------------------------------------------------------------------------------------------------
// CNSmlDataModBase::StripL
// Strips data that is to be transmitted to the sync partner.
// ------------------------------------------------------------------------------------------------
void CNSmlDataModBase::StripL( TDes8& aItem )
	{
	_DBG_FILE("CNSmlDataModBase::StripL(): begin");
	if ( !NeedsMerge() )
		{
		if ( iUsedRemoteMimeType == -1 )
			{
			User::Leave( KErrNotFound );
			}
		return;
		}
	TBool modified( EFalse );
	CVersitParser* parser = ChildCreateParserLC();
	RDesReadStream drs( aItem );
	CleanupClosePushL( drs );
	parser->InternalizeL( drs );

	// Now we're ready to start analysis
	CArrayPtr<CVersitParser>* entities = parser->ArrayOfEntities( EFalse );
	if( entities )
		{
		for( TInt i = 0; i < entities->Count(); i++ )
			{
			StripEntityL( entities->At( i ), modified );
			}
		}
	else
		{
		StripEntityL( parser, modified );
		}

	// Only update if anything was modified in process
	if( modified )
		{
		aItem.Zero();
		RDesWriteStream dws( aItem );
		CleanupClosePushL( dws );
		parser->ExternalizeL( dws );
		dws.CommitL();
		CleanupStack::PopAndDestroy(); // dws
		}
	CleanupStack::PopAndDestroy( 2 ); // drs, parser
	_DBG_FILE("CNSmlDataModBase::StripL(): end");
	}
// -----------------------------------------------------------------------------
// CPIMEventPropertyConverter::ConvertExDatePropertyL
// Inserts EXDATE proprety from a vEvent to a PIM Event Item as a repeat rule
// field
// -----------------------------------------------------------------------------
//
void CPIMEventPropertyConverter::ConvertExDatePropertyL(
    const CPIMParserProperty& aProperty, // property to convert
    CPIMEventItem& aItem) // item to insert the field to
{
    JELOG2(EPim);
    if (aProperty.Name().CompareF(KVersitTokenEXDATE) != 0)
    {
        // some unsupported multidate
        return;
    }
    MPIMRepeatRuleData* repeatRule = aItem.GetRepeat();

    CParserPropertyValueMultiDateTime* propertyValue =
        static_cast<CParserPropertyValueMultiDateTime*>(aProperty.Value());
    CArrayPtr<TVersitDateTime>* value = propertyValue->Value();
    TInt valueCount = value->Count();
    for (TInt i = 0; i < valueCount; i++)
    {
        TPIMDate date(value->At(i)->iDateTime);
        repeatRule->AddExceptDateL(date);
    }
}
// -----------------------------------------------------------------------------
// CCMSX509CertificateList::DecodeExtensionsL
// Decodes Extensions
// -----------------------------------------------------------------------------
CArrayPtrFlat<CX509CertExtension>* CCMSX509CertificateList::DecodeExtensionsL(
	const TASN1DecGeneric* aExtensions )
	{
	CArrayPtr<TASN1DecGeneric>* extens =
			 DecodeSequenceLC( aExtensions->Encoding() );
	TInt extensionCount = extens->Count();
	CArrayPtrFlat< CX509CertExtension >* tmpExtensions =
		new(ELeave)CArrayPtrFlat< CX509CertExtension >( KDefaultGranularity );
	CleanupStack::PushL( tmpExtensions );
	CleanupResetAndDestroyPushL( *tmpExtensions );
	for( TInt j = 0; j < extensionCount; j++ )
		{
		CX509CertExtension* extension =
			CX509CertExtension::NewLC( extens->At( j )->Encoding() );
		tmpExtensions->AppendL( extension );
		CleanupStack::Pop( extension );
		}
	CleanupStack::Pop( tmpExtensions ); // ResetAndDestroy
	CleanupStack::Pop( tmpExtensions ); // normal cleanup
	CleanupStack::PopAndDestroy( extens );
	return tmpExtensions;
	}
void CWapDgrmTestStep::_PrintL(CArrayPtr<CSmsMessage>& aSmsArray)
/**
 *  print an array of SMS messages to the console
 */
{
	TInt Count = aSmsArray.Count();
	TInt j = 1;

	for (TInt i=0;i<Count;i++,j++)
	{
		// Ordinal
		_Print(i);
		_Print(_L8(": \n"));

		CSmsMessage* Sms = aSmsArray.At(i);
		_Print(*Sms);

		// Print data
		CSmsBufferBase& SmsBuffer = Sms->Buffer();
		_PrintL(SmsBuffer);
	}
}
// -----------------------------------------------------------------------------
// CSTSPath::DecodeL
// Decrypts raw data to this instance
// -----------------------------------------------------------------------------
void CSTSPath::DecodeL(const TDesC8& aRawData)
{
    CArrayPtr<TASN1DecGeneric>* itemsData = DecodeSequenceLC(ETrue, //must be sequence
                                            aRawData, KSTSMinNumberOfSubModules, KSTSMaxNumberOfSubModules);

    // we would not get this far if there is not 1-3 elements
    TInt pos = 0;
    if (pos >= itemsData->Count())
    {
        User::Leave(KErrArgument);
    }

    //decoding Path (octet string)
    TASN1DecOctetString path;
    HBufC8* tmpPath = path.DecodeDERL(*itemsData->At(pos++));
    delete iPath;
    iPath = tmpPath;
    //optional index and optional length are not needed

    CleanupStack::PopAndDestroy(itemsData);

}
Beispiel #27
0
void CmsUtils::DecodeCertificatesL(RPointerArray<CCmsCertificateChoice>& aCertificates, const TDesC8& aRawData)
	{
	TASN1DecGeneric decGen(aRawData);
	decGen.InitL();
	TASN1DecSequence decSeq;
	// have to do manual decoding of sequence because field is optional
	CArrayPtr<TASN1DecGeneric>* items = NULL;
	items = decSeq.DecodeDERLC(decGen);
	TInt count = items->Count();

	CCmsCertificateChoice* certificate;

	for(TInt item = 0; item < count; item++)
		{
 		certificate = CCmsCertificateChoice::NewL(items->At(item)->Encoding());
		CleanupStack::PushL(certificate);
		aCertificates.AppendL(certificate);
		CleanupStack::Pop(certificate);
		}

	CleanupStack::PopAndDestroy(items);			
	}
Beispiel #28
0
void CDmAdEngine::SaveRtNodesL(void)
    {
    TRACE("CDmAdEngine::SaveRtNodesL");
    
    CArrayPtr<CDmAdRtNode>* topLevelRtNodes;
    BuildTopLevelRtNodesListLC(iRtNodes, topLevelRtNodes);

    TInt countRtNodes;
    countRtNodes = topLevelRtNodes->Count();
    TInt i;
    for (i=0; i < countRtNodes; i++)
        {
        CDmAdRtNode* rtNode = topLevelRtNodes->At(i);
        CArrayPtr<CDmAdRtNode>* childRtNodes;
        BuildChildRtNodesListLC(iRtNodes, rtNode->Uri(), childRtNodes);
        
        TRAPD(err, iStoreApi->SaveTopLevelRtNodeL(*rtNode, *childRtNodes));
        CompleteCommandsL(*rtNode, err);
        CompleteCommandsL(*childRtNodes, err);
        
        CleanupStack::PopAndDestroy(); //childRtNodes
        }
    CleanupStack::PopAndDestroy(); //topLevelRtNodes

    //child rtNodes without top level RtNode
    countRtNodes = iRtNodes->Count();
    for (i=0; i < countRtNodes; i++)
        {
        CDmAdRtNode* rtNode = iRtNodes->At(i);
        TInt err = KErrNone;
        if (!rtNode->IsJustFetched())
            {
            TRAP(err, iStoreApi->SaveChildLevelRtNodeL(*rtNode));
            }
        CompleteCommandsL(*rtNode, err);
        }
    iRtNodes->ResetAndDestroy();
    }
TInt CJuikIconManagerImpl::GetNewProviderIdL()
{
	CALLSTACKITEM_N(_CL("CJuikIconManagerImpl"), _CL("GetNewProviderIdL"));
	TInt providerIx = KErrNotFound;
	for ( TInt i = 0; i < iProviderIconIndexes->Count(); i++)
		{
			if ( iProviderIconIndexes->At(i) == NULL )
				{
					providerIx = i;
					break;
				}
		}
	
	if ( providerIx == KErrNotFound )
		{
			iProviderIconIndexes->AppendL( new (ELeave) CArrayFixFlat<TInt>(3) );
			return LastIndex( *iProviderIconIndexes );
		}
	else
		{
			(*iProviderIconIndexes)[providerIx] =  new (ELeave) CArrayFixFlat<TInt>(3);
			return providerIx;
		}
} 
// ------------------------------------------------------------------------------------------------
// CNSmlDataModBase::MergeEntityL
// Merges data from old entity to new entity.
// ------------------------------------------------------------------------------------------------
void CNSmlDataModBase::MergeEntityL( CVersitParser* aNewEntity, CVersitParser* aOldEntity, TBool& aModified, TBool aFieldLevel ) const
	{
	_DBG_FILE("CNSmlDataModBase::MergeEntityL(): begin");

	// Remove all data that was not supposed to be supported by the partner but
	// it was still sent to us.
	StripAllNotOnPartnerListL( aNewEntity, aModified );
	
	if( !aFieldLevel )
		{
		// Remove all properties from old item that are supported by remote server.
		// If it is field level then old this is not done.
		StripAllOnPartnerListL( aOldEntity, aModified, ETrue );
		CArrayPtr<CParserProperty>* mergeProps = aOldEntity->ArrayOfProperties( ETrue );
		if( mergeProps )
		    {
			CleanupStack::PushL( mergeProps );
			
			for( TInt i = 0; i < mergeProps->Count(); i++ )
				{
				aNewEntity->AddPropertyL( mergeProps->At( i ), ETrue );
				}
			
			CleanupStack::PopAndDestroy(); // mergeProps
		    }
		}
    else // Support for Field level merge
        {
        //Field level merge. Merge new item with old item. Properties of 
        //the old item are copied to new item if the new item entity does not 
        //contain certain property.
        //------------------------------------------------------------------------
        // Old                 New                          Merged                 
        //------------------------------------------------------------------------
        // BEGIN:VCARD       -> BEGIN:VCARD                 = BEGIN:VCARD 
        // VERSION:2.1       -> VERSION:2.1                 = VERSION:2.1
        // N:Smith;John      -> N:White;John                = N:White;John
        // ORG:Firm                                         = ORG:Firm
        // TITLE:Boss                                       = TITLE:Boss
        //                   -> TEL;CELL;VOICE:1234         = TEL;CELL;VOICE:1234
        // END:VCARD         -> END:VCARD                   = END:VCARD

        CArrayPtr<CParserProperty>* newProps = aNewEntity->ArrayOfProperties( EFalse );
        if( newProps )
            {
            CArrayPtr<CParserProperty>* oldProps = aOldEntity->ArrayOfProperties( EFalse );

            // Iterate through old list of properties. Add missing properties from old 
            // contact item, if some of the properties is not included in new item. 
            for( TInt i = 0; i < oldProps->Count(); ) 
                {
                CParserProperty* oldProperty = oldProps->At( i );
                
                //Check if the property is included in received vCard
                CArrayPtr<CParserProperty>* properties = aNewEntity->PropertyL( 
                    oldProperty->Name(), oldProperty->Uid(), EFalse );

                if ( !properties )
                    {
                    // New vCard does not include certain property. Copy all matching properties from 
                    // existing contact item.
                    CArrayPtr<CParserProperty>* oldProperties =
                        aOldEntity->PropertyL( oldProperty->Name(), oldProperty->Uid(), ETrue );
                    CleanupPtrArrayPushL( oldProperties );
                    
                    for ( TInt j = oldProperties->Count()-1; j >= 0; --j )
                        {
                        CParserProperty* property = oldProperties->At( j );
                        oldProperties->Delete( j );
                        CleanupStack::PushL( property );
                        aNewEntity->AddPropertyL( property, EFalse );
                        CleanupStack::Pop( property );
                        aModified = ETrue;
                        }       
                    CleanupStack::PopAndDestroy( oldProperties );
                    }
                else
                    {
                    // If new vCard includes at least one property with same name we will not copy 
                    // any any property with same name from existing contact item.
                    delete properties;
                     ++i;
                    }
                }
            }
		}
	
	#ifdef __NSML_DEBUG__
		CArrayPtr<CParserProperty>* props = aNewEntity->ArrayOfProperties( EFalse );
		for( TInt i = 0; i < props->Count(); i++ )
			{
			TBuf8<512> b;
			const CParserProperty* p = props->At( i );
			b = p->Name();
			const CArrayPtr<CParserParam>* pa = ( ( CNSmlProperty* )p )->Parameters();
			if( pa )
				{
				for( TInt i2 = 0; i2 < pa->Count(); i2++ )
					{
					b.Append( _L8(":") );
					b.Append( pa->At( i2 )->Name() );
					}
				}
			DBG_ARGS8(_S8("CNSmlDataModBase::MergeEntityL(): %S"), &b);
			}
	#endif // __NSML_DEBUG__
	_DBG_FILE("CNSmlDataModBase::MergeEntityL(): end");
	}