// ---------------------------------------------------------------------------
// CLbtTriggerInfo::SetTriggerEntry()
//
// (other items were commented in a header).
// ---------------------------------------------------------------------------
//  
EXPORT_C void CLbtTriggerInfo::InternalizeL( RReadStream& aStream )
    {	
	TInt trigType=aStream.ReadInt8L();
	if(trigType==1)	
	    {
		iEntry=CLbtSessionTrigger::NewL();
		iEntry->InternalizeL(aStream);
	    }
	else 
	    {
		iEntry=CLbtStartupTrigger::NewL();
		iEntry->InternalizeL(aStream);
	    }
	
    TInt trigValidity=aStream.ReadInt8L();
	
	if(iDynInfo !=NULL)
	    {
	    delete iDynInfo;
	    iDynInfo=NULL;
	    }
	
	iDynInfo=new TLbtTriggerDynamicInfo;
	
	switch(trigValidity)
	    {
		case 1: iDynInfo->iValidity=TLbtTriggerDynamicInfo::EInvalid;
						break;
		case 2: iDynInfo->iValidity=TLbtTriggerDynamicInfo::EValid;
						break;
		}
	
	iDynInfo->iDistanceToLatestLocation=aStream.ReadReal32L()	;
    }
Esempio n. 2
0
void CBTHidDevice::InternalizeL(RReadStream& aStream)
    {
    // Read the version number
    // Ignored in this version.
    aStream.ReadInt32L();

    // Read all member variables from the stream
    // Leave if we get any error

    // Get a pointer to the address to fill
    TPtr8 addr = iAddress.Des();
    // Read the address in
    aStream.ReadL(addr);

    iDeviceReleaseNumber = aStream.ReadUint32L();
    iDeviceSubClass = aStream.ReadUint32L();
    iCountryCode = aStream.ReadUint32L();
    iVirtuallyCabled = aStream.ReadInt8L();
    iReconnectInit = aStream.ReadInt8L();
    iNormallyConnectable = aStream.ReadInt8L();
    iProfileVersion = aStream.ReadUint32L();
    iVendorID = aStream.ReadUint32L();
    iProductID = aStream.ReadUint32L();
    iUseSecurity = aStream.ReadInt8L();
    aStream >> iDeviceName;
    aStream >> iDeviceClass;
    aStream >> *iDescList;
    }
// -----------------------------------------------------------------------------
// CWPPushMessage::InternalizeL
// -----------------------------------------------------------------------------
//
EXPORT_C void CWPPushMessage::InternalizeL( RReadStream& aStream )
    {
    // Restore the header
    TInt version( aStream.ReadInt32L() );

    TInt length( aStream.ReadInt32L() );
    HBufC8* header = HBufC8::NewLC( aStream, length );
    iAuthenticated = aStream.ReadInt8L();
    iSaved = aStream.ReadInt8L();

    // Restore the body
    length = aStream.ReadInt32L();
    HBufC8* body = HBufC8::NewL( aStream, length );

    // Store header and body
    CleanupStack::Pop(); // header
    Set( header, body );

    if( version == KProvisioningMsgVersion )
        {
        length = aStream.ReadInt32L();
        if( length > 0 )
            {
            delete iOriginator;
            iOriginator = NULL;
            iOriginator = HBufC8::NewL( aStream, length );
            }
        }
    }
void TBidirectionalEndOfLineContext::InternalizeL(RReadStream& aSource)
	{
	iFirstCategory = static_cast<TChar::TBdCategory>(aSource.ReadInt8L());
	iFirstStrongCategory = static_cast<TChar::TBdCategory>(aSource.ReadInt8L());
	iPositionOfLastStrongCategory = 0;
	iStartPosOfThisLine = 0;
	}
Esempio n. 5
0
// ---------------------------------------------------------------------------
// CLbtGeoHybrid::DoInternalizeL()
//
// (other items were commented in a header).
// ---------------------------------------------------------------------------
//
void CLbtGeoHybrid::DoInternalizeL( RReadStream& aStream ) 
    {
    TInt count = aStream.ReadInt8L();
    for( TInt i=0;i<count;i++ )
        {
        TInt areaType = aStream.ReadInt8L();
        if( areaType == 1 )
            {
            CLbtGeoCircle* area= CLbtGeoCircle::NewL();
            area->InternalizeL(aStream);
            iHybridArea.Append( area );
            }
        else if( areaType == 2 )
            {
            CLbtGeoRect* area= CLbtGeoRect::NewL();
            area->InternalizeL(aStream);
            iHybridArea.Append( area );
            }
        else if( areaType == 3 )
            {
            CLbtGeoCell* area= CLbtGeoCell::NewL();
            area->InternalizeL(aStream);
            iHybridArea.Append( area );
            }
        }
    }     
// -----------------------------------------------------------------------------
// CDRMEventTimeChange::Internalize
// Reads the data of the object from the given stream
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
EXPORT_C void CDRMEventTimeChange::InternalizeL(
    RReadStream& aInput) 
    {
    TInt8 securityLevel = 0;
    TInt64 timeData = 0;

    MDRMEvent::InternalizeL(aInput);

    // input the old time
    ReadInt64L( timeData, aInput );
    iOldTime = timeData;
    
    // input the new time
    ReadInt64L( timeData, aInput );    
    iNewTime = timeData;
    
    // input the old time zone
    iOldTimeZone = aInput.ReadInt32L();
    
    // input the new time zone
    iNewTimeZone = aInput.ReadInt32L();
    
    // input the old security level
    securityLevel = aInput.ReadInt8L();
    iOldSecurityLevel = static_cast<DRMClock::ESecurityLevel>(securityLevel);
    
    // input the new security level
    securityLevel = aInput.ReadInt8L();
    iNewSecurityLevel = static_cast<DRMClock::ESecurityLevel>(securityLevel);    
    
    };
// -----------------------------------------------------------------------------
// CDRMEventAddRemove::Internalize
// Reads the data of the object from the given stream
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
EXPORT_C void CDRMEventAddRemove::InternalizeL(
    RReadStream& aInput) 
    {
    TInt inputLength = 0;

    MDRMEvent::InternalizeL(aInput);

    // Read the length of the HBufC8*
    inputLength = aInput.ReadInt32L();

    // Reserve the HBufC8*
    if( !iContentID )
        {
        iContentID = HBufC8::NewL(inputLength);
        }
    else
        {
        iContentID->ReAllocL(inputLength);
        }

    TPtr8 inRead(iContentID->Des());

    // Read the HBufC8*
    aInput.ReadL(inRead, inputLength); 

    // this implementation may need to be changed if the size of the enum changes
    iStatus = static_cast<TAddRemoveEventStatus>(aInput.ReadInt8L());
    };
Esempio n. 8
0
EXPORT_C void CHeaderFooter::InternalizeL(RReadStream& aStream)
/** Internalises this object's text content and global format layers from a read 
stream. 

The presence of this function means that the standard templated operator>>() 
(defined in s32strm.h) is available to internalise objects of this class.

This function does not restore any fields, pictures or rich text-specific 
formatting, so may need to be accompanied by a call to RestoreComponentsL().

@param aStream Stream from which the object should be internalised. */
	{
	TUint flags = aStream.ReadInt8L();
	iFirstPageToPrintTo = aStream.ReadInt32L();
	if (flags & ETextExists)
		{
		delete iText;
		iText = NULL;
		CreateFormatLayersL();
		aStream>> *iParaLayer;
		aStream>> *iCharLayer;
		iText = CRichText::NewL(iParaLayer,iCharLayer);
		iText->SetFieldFactory(this);
		aStream>> *iText;
		}
// -----------------------------------------------------------------------------
// CSmlActiveContactSuiteProgressCallback::NotifyProgressL()
// Reads progress event related data and notifies observer.
// -----------------------------------------------------------------------------
//
void CSmlActiveContactSuiteProgressCallback::NotifyProgressL( RReadStream& aStream ) const
    {
    TInt8 status = aStream.ReadInt8L();
    TInt32 info1 = aStream.ReadInt32L();
    TInt32 info2 = aStream.ReadInt32L();
    
    iObserver->OnSyncMLSyncProgress( (MSyncMLProgressObserver::TStatus)status, info1, info2 );
    }
Esempio n. 10
0
void TWordUiData::InternalizeL(RReadStream& aStream)
	{
	TCardinality version;
	version.InternalizeL(aStream);
	if (version!=KVersionAppConfigurationData)
		User::Leave(KErrCorrupt); // !! need better error

	iNpcVisibility=0;
	iNpcVisibility=aStream.ReadUint8L();
	iPicturePrefs=0;
	iPicturePrefs=aStream.ReadUint8L();
	iToolbandVisibility=(TBool)aStream.ReadInt8L();
	iToolbarVisibility=(TBool)aStream.ReadInt8L();
	iWysiwygOn=(TBool)aStream.ReadInt8L();

	iCursorPos=aStream.ReadInt32L();
	iZoomFactor=aStream.ReadInt32L();
	}
/**
Intended Usage	: Restore the internal state from aStream.	

Error Condition	: Leave with the error code.
@leave  		KErrNoMemory.
@leave  		@see RReadStream.
@since			7.0
@param			aClientSide a boolean indicating whether the streaming is to performed in client/server side
@param			aStream The stream to read the data from.
@pre 			CImplementationInformation is fully constructed.
@post			CImplementationInformation is restored to the state specified by
				the contents of aStream.
*/
void CImplementationInformation::InternalizeL(TBool aClientSide,RReadStream& aStream)
	{
	delete iDisplayName;
	iDisplayName = NULL;
	delete iData;
	iData = NULL;
	delete iOpaqueData;
	iOpaqueData = NULL;

	iImplementationUid.iUid = aStream.ReadInt32L();
	iVersion = aStream.ReadInt32L();
	TInt inputLength = aStream.ReadInt32L();
	if(inputLength > 0)
  		{
  		// read in the iName string
  		iDisplayName = HBufC::NewL(inputLength);
  		TPtr inputBuf = iDisplayName->Des();
  		aStream.ReadL(inputBuf,inputLength);
  		}
  	inputLength = aStream.ReadInt32L();
	if(inputLength > 0) 
  		{
  		// read in the iData string
  		iData = HBufC8::NewL(inputLength);
  		TPtr8 inputBuf = iData->Des();
  		aStream.ReadL(inputBuf,inputLength);
  		}
	inputLength = aStream.ReadInt32L();
	if(inputLength > 0)
  		{
  		// read in the iOpaqueData string
  		iOpaqueData = HBufC8::NewL(inputLength);
 		TPtr8 inputBuf = iOpaqueData->Des();
  		aStream.ReadL(inputBuf,inputLength);
  		}
	if (aClientSide)
		{
		TUint checkDrive = aStream.ReadInt32L();
		if (checkDrive > (TUint) KMaxDrives)
			User::Leave(KErrCorrupt);
		iDrive = checkDrive;	
		iVid.iId = aStream.ReadInt32L();		
		}
	TInt8 additionalImplInfo=aStream.ReadInt8L();
	iRomOnly=additionalImplInfo&1;
	iRomBased=(additionalImplInfo&2)>>1;
	iDisabled=(additionalImplInfo&4)>>2;
	TInt count = aStream.ReadInt32L();
	if (count != KNoneExtendedInterface)
		{
		for(TInt i = 0; i < count; i++)
	   		{
	   		AddExtendedInterfaceL(TUid::Uid(aStream.ReadInt32L()));
			}
		}
	}
// -----------------------------------------------------------------------------
// CSmlActiveContactSuiteProgressCallback::NotifyErrorL()
// Reads progress error related data and notifies observer.
// -----------------------------------------------------------------------------
//
void CSmlActiveContactSuiteProgressCallback::NotifyErrorL( RReadStream& aStream ) const
    {
    TInt8 errorLevel = aStream.ReadInt8L();
    TInt32 error = aStream.ReadInt32L();
    TInt32 taskId = aStream.ReadInt32L();
    TInt32 info1 = aStream.ReadInt32L();
    TInt32 info2 = aStream.ReadInt32L();
    
    TNSmlErrorConversion errorconv( error );
    error = errorconv.Convert();
    
    iObserver->OnSyncMLSyncError( (MSyncMLProgressObserver::TErrorLevel)errorLevel, error, taskId, info1, info2 );
    }
Esempio n. 13
0
// the stream should be in the beginning of controller section
void CSettingsManager::ReadControllerTableL(RReadStream& aStream)
	{
	iControllerCnt = aStream.ReadInt8L();	
	TStreamId tempId;
	iArrUid.Reset();
	iArrStreamId.Reset();
	//read the available pairs of Uid - Streamd Ids.
	for(TInt8 i = 0; i < iControllerCnt;i++)
		{
		iArrUid.AppendL(TUid::Uid(aStream.ReadInt32L()));
		aStream >> tempId;
		iArrStreamId.AppendL(tempId);
		}
	}
// ---------------------------------------------------------------------------
// CXIMPContextStateEventImp::ConstructL()
// ---------------------------------------------------------------------------
//
void CXIMPContextStateEventImp::ConstructL( RReadStream& aStream )
    {
    iState = CXIMPContextStateImp::NewL();
    iState->InternalizeL( aStream );


    TStatusObjectExistency exists =
             ( TStatusObjectExistency ) aStream.ReadInt8L();

    if( exists  == EHasStatusObject )
        {
        iStateChangeReason = CXIMPStatusImp::NewL();
        iStateChangeReason->InternalizeL( aStream );
        }
    }
Esempio n. 15
0
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
//
void CWlanSsidList::InternalizeL(
    RReadStream& aStream )
    {    
    TInt count( 
        aStream.ReadInt32L() );
    TWlanSsid ssid;

    for( TInt idx( 0 ); idx < count; ++idx )
        {
        aStream.ReadL(
            ssid, aStream.ReadInt8L() );
        iSsidList.Append(
            ssid );
        }
    }
Esempio n. 16
0
EXPORT_C void CLogEvent::InternalizeL(RReadStream& aStream)
	{
	iId = (TLogId) aStream.ReadInt32L();
	iEventType.iUid = aStream.ReadInt32L();

	TInt64 time; 
	aStream >> time;
	iTime = time;

	iDurationType = (TLogDurationType) aStream.ReadInt8L();
	iDuration = (TLogDuration) aStream.ReadUint32L();
	iContact = (TLogContactItemId ) aStream.ReadInt32L();
	iLink = (TLogLink) aStream.ReadUint32L();
	iFlags = (TLogFlags) aStream.ReadUint8L();

	InternalizeBufL(aStream, iDescription);
	InternalizeBufL(aStream, iRemoteParty);
	InternalizeBufL(aStream, iDirection);
	InternalizeBufL(aStream, iStatus);
	InternalizeBufL(aStream, iSubject);
	InternalizeBufL(aStream, iNumber);

	TInt dataLen = aStream.ReadInt32L();
#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
	TUint dataVersion = 0;
	if(dataLen < 0)
		{
		//This is CLogEvent data version with dual SIM support.
		//The next property is the data length.
		dataVersion = (TUint)dataLen;
		dataLen = aStream.ReadInt32L();
		}
#endif
	HBufC8* temp = NULL;
	if(dataLen != 0)
		{
		temp = HBufC8::NewL(aStream, dataLen);
		}
	delete iData;
	iData = temp;
	
#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
	if(dataVersion >= KLogEventDataVersion)
		{
		aStream >> iSimId;
		}
Esempio n. 17
0
void CNcdNodeFolder::InternalizeL( RReadStream& aStream )
    {
    DLTRACEIN(("this: %X", this));

    // First use the parent to internalize the general data
    CNcdNode::InternalizeL( aStream );
    
    DLINFO(("Parent class internalized"));
    // Now internalize the data of this specific class

    // Insert child information to iChildren array
    // But first release previous info if it exists.
    iChildren.ResetAndDestroy();
    
    
    TInt childCount( aStream.ReadInt32L() );
    DLINFO(("Children: %d", childCount ));
    NcdNodeClassIds::TNcdNodeClassId classObjectType = 
        NcdNodeClassIds::ENcdNullObjectClassId;
    
    for ( TInt i = 0; i < childCount; ++i )
        {
        // This is safe casting because enum is same as TInt
        classObjectType = 
            static_cast<NcdNodeClassIds::TNcdNodeClassId>(aStream.ReadInt32L());
        if ( NcdNodeClassIds::ENcdChildEntityClassId == classObjectType )
            {
            CNcdChildEntity* childEntity = CNcdChildEntity::NewLC( aStream );
            iChildren.AppendL( childEntity );
            CleanupStack::Pop( childEntity );
            }
        else
            {
            // Wrong kind of class object info
            User::Leave( KErrCorrupt );
            }
        }
    
    iChildrenPreviouslyLoaded = aStream.ReadInt8L();
    DLTRACE((_L("node id: %S"), &Identifier().NodeId() ));
    DLTRACE(("read iChildrenPreviouslyLoaded: %d",iChildrenPreviouslyLoaded ));
    DLTRACEOUT((""));
    }
Esempio n. 18
0
/**
Utility method. Used to read from read stream and output to html file

*/
void CDbDbmsDumper::DumpStreamL(RReadStream& stream)
	{
	const TInt KStreamSize = stream.Source()->SizeL();

	iFile.Write(KDumpFont);

	_LIT8(KSizeMessage, "size is %d <BR>");
	_LIT8(KEightSpaces, "        ");
	_LIT8(KByteFormat, "%02x&nbsp;");
	_LIT8(KFormatString, "%S&nbsp;<BR>\r\n");

	iBuffer->Des().Format(KSizeMessage, KStreamSize);
	iFile.Write(*iBuffer);

	TBuf8<8> str(KEightSpaces); //Reserve 8 symbols

	TInt counter(0);
	while (counter < KStreamSize)
		{
		for(TInt i=0; i < 8; ++i)
			{
			if (counter >= KStreamSize)
				{
				break;	
				}
			//format byte in a printable character	
			TInt8 byte( stream.ReadInt8L() );
			iBuffer->Des().Format(KByteFormat, byte);
			iFile.Write(*iBuffer);
			
			 str[i] = (byte>32 ? byte : '.');
			++counter;
			}
		iBuffer->Des().Format(KFormatString, &str);
		iFile.Write(*iBuffer);
		}

	iFile.Write(KDumpFontEnd);
	}
Esempio n. 19
0
// -----------------------------------------------------------------------------
// CGuiEngineAppView::InternalizeL()
// Internalize BrushShapeType (read)
// -----------------------------------------------------------------------------
//
void CGuiEngineAppView::InternalizeL( RReadStream& aStream )
    {
    iBrushShapeType = static_cast<TBrushShapeType>( aStream.ReadInt8L() );
    }
// ---------------------------------------------------------------------------
// CAccPolObjectBase::InternalizeBaseL
// ---------------------------------------------------------------------------
//
EXPORT_C void CAccPolAudioUnitBase::InternalizeAudioUnitBaseL(
    RReadStream& aStream )
    {
    API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioUnitBase::InternalizeAudioUnitBaseL() - Enter" );
    TInt count( KErrNone );
    iUnitId = aStream.ReadUint8L();
    count = aStream.ReadInt8L();
    for( TInt i = 0; i < count; i++ )
        {
        iSourceId.Append( ( TInt )aStream.ReadUint8L() );
        }

    API_TRACE_1( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioUnitBase::InternalizeAudioUnitBaseL - Unit id         = %d", iUnitId );
    API_TRACE_1( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioUnitBase::InternalizeAudioUnitBaseL - Source id count = %d", iSourceId.Count() );

    count = aStream.ReadInt8L();
    for( TInt i = 0; i < count; i++ )
        {
        //Object type
        TUint8 objectType = aStream.ReadUint8L();
        switch( objectType )
            {
            case EAccPolAudioVolumeControlObject:
                {
                CAccPolVolumeControl *volumeControl =
                    CAccPolVolumeControl::NewLC();
                volumeControl->InternalizeL( aStream );
                this->AddControlL( *volumeControl );
                CleanupStack::PopAndDestroy( volumeControl );
                }
                break;

            case EAccPolAudioMuteControlObject:
                {
                CAccPolMuteControl *muteControl = CAccPolMuteControl::NewLC();
                muteControl->InternalizeL( aStream );
                this->AddControlL( *muteControl );
                CleanupStack::PopAndDestroy( muteControl );
                }
                break;

            case EAccPolAudioInputControlObject:
                {
                CAccPolInputControl *inputControl =
                    CAccPolInputControl::NewLC();
                inputControl->InternalizeL( aStream );
                this->AddControlL( *inputControl );
                CleanupStack::PopAndDestroy( inputControl );
                }
                break;

            default:
                {
                User::Leave( KErrNotSupported );
                }
                break;
            }
        }
    API_TRACE_1( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioUnitBase::InternalizeAudioUnitBaseL - Audio controls count = %d", iAudioControls.Count() );

    API_TRACE_( "[AccFW: ACCPOLAUDIODEVICETOPOLOGY] CAccPolAudioUnitBase::InternalizeAudioUnitBaseL - Return" );
    }
Esempio n. 21
0
// ---------------------------------------------------------------------------
// CCmFillRule::InternalizeL
// ---------------------------------------------------------------------------
//
void CCmFillRule::InternalizeL( RReadStream& aStream )
    {
    // Content
    delete iName;
    iName = NULL;

    TInt bufLength = aStream.ReadInt32L();    
    iName = HBufC8::NewL( aStream, bufLength );
    
    // cleanup
    iRuleArray.ResetAndDestroy();
    
    iAmount = aStream.ReadInt32L();
    iRealSize = aStream.ReadInt32L();
    iRealCount = aStream.ReadInt32L();
    iLimitType = (TCmLimitType)aStream.ReadInt16L();
    iMethod = (TCmFillMethod)aStream.ReadInt16L();
    iMediaType = (TCmMediaType)aStream.ReadInt16L();
    iSelected = (TCmFillRuleStatus)aStream.ReadInt16L();
    iStatus = (TCmListItemStatus)aStream.ReadInt16L();
    iPriority = (TUint8)aStream.ReadInt8L();
    iTemplateId = (TUint8)aStream.ReadInt8L();
    iId = (TUint)aStream.ReadInt32L();
    
    // rule count 
    TInt ruleCount = aStream.ReadInt16L();
    
    // Then internalize them from the stream one by one
    for (TInt index = 0; index < ruleCount; index++ )
        {
        CCmRule* newRule = CCmRule::NewLC();
        newRule->InternalizeL( aStream );   
        iRuleArray.AppendL( newRule );
        CleanupStack::Pop( newRule ); 
        newRule = NULL;
        }
        
    // cleanup
    iMediaServerArray.ResetAndDestroy();
    
    // media Server count
    TInt mediaServerCount = aStream.ReadInt16L();
    
    // Then internalize them from the stream one by one
    for (TInt index = 0; index < mediaServerCount; index++ )
        {
        CCmMediaServer* newServer = CCmMediaServer::NewLC();
        newServer->InternalizeL( aStream );     
        iMediaServerArray.AppendL( newServer );
        CleanupStack::Pop( newServer ); 
        newServer = NULL;
        }
        
    TInt excAlbumsCount( aStream.ReadInt16L() );
    bufLength = KErrNone;
    HBufC* temp = NULL;
    for ( TInt index(0); index < excAlbumsCount ; index++ )
        {
        bufLength = aStream.ReadInt32L();
        temp = HBufC::NewLC( aStream, bufLength );
        iExcAlbums->AppendL( *temp );
        CleanupStack::PopAndDestroy( temp );
        temp = NULL;
        }         

    TInt excPlayListCount( aStream.ReadInt16L() );
    bufLength = KErrNone;
    for ( TInt index(0); index < excPlayListCount ; index++ )
        {
        bufLength = aStream.ReadInt32L();
        temp = HBufC::NewLC( aStream, bufLength );
        iExcPlayLists->AppendL( *temp );
        CleanupStack::PopAndDestroy( temp );
        temp = NULL;
        }                         
    }
Esempio n. 22
0
// -----------------------------------------------------------------------------
// CDRMConstraint::InternalizeL
// -----------------------------------------------------------------------------
//
EXPORT_C void CDRMConstraint::InternalizeL( RReadStream& aStream )
    {

    TInt64 timeData = 0;
    TInt32 temp = 0;

    // used for the buffers
    TInt dataLength = 0;
    HBufC8* dataPart = NULL;
    TPtr8 dataBuffer(NULL,0,0);

    // Read the (possible) synchronizing marker.
    iSyncMark = aStream.ReadInt32L();

    if ( iSyncMark != KSyncMark )
        {

        // The structure of the externalized Permission object is the old one.
        // The first four bytes constitute half of the eight bytes of Start time.
        // Read another four bytes from the stream (and apply bit modifications)
        // in order to reconstruct the Start time (iStartTime).
        temp = aStream.ReadInt32L();

        timeData = temp;
        timeData <<= 32;

        Mem::Copy( &timeData, &iSyncMark, sizeof(TInt32) );

        iStartTime = timeData;
        timeData = 0;

        // The version is marked as old version for differentiation in
        // InternalizeL.
        iVersion = KVersion3_2_0;

        }
    else
        {
        // The structure of the externalized Permission object is the new one.
        // Read the version and Start time.
        iVersion = aStream.ReadInt32L();

        // Read the start time
        ReadInt64L( timeData, aStream );
        iStartTime = timeData;

        }

    // Read the end time
    ReadInt64L( timeData, aStream );
    iEndTime = timeData;

    // Read the interval start time
    ReadInt64L( timeData, aStream );
    iIntervalStart = timeData;

    // Read the interval
    iInterval = aStream.ReadInt32L();

    // Read the counter
    iCounter = aStream.ReadInt32L();

    // Read the original counter
    iOriginalCounter = aStream.ReadInt32L();

    // Read the timed counter
    iTimedCounter = aStream.ReadInt32L();

    // Read the timed interval
    iTimedInterval = aStream.ReadInt32L();

    // Read the accumulated time
    iAccumulatedTime = aStream.ReadInt32L();

    // Read the individual
    dataLength = aStream.ReadInt32L();

    SanitizeL( dataLength );

    if( dataLength > 0 )
        {
        // Reserve a new buffer:
        dataPart = HBufC8::NewMaxLC( dataLength );

        // Set the read buffer:
        dataBuffer.Set(const_cast<TUint8*>(dataPart->Ptr()), 0, dataLength);

        // Read the data:
        aStream.ReadL( dataBuffer );


        // Fill the array from the string
        ReadArrayFromStringL( dataBuffer, iIndividual);

        // Pop the buffer
        CleanupStack::PopAndDestroy(); // dataPart

        }
    else
        {
        iIndividual.ResetAndDestroy();
        }


    // Read the system
    if ( iVersion == KVersion3_2_0 ) // Constraint has the old structure.
        {

        dataLength = aStream.ReadInt32L();

        SanitizeL( dataLength );

        if( dataLength > 0 )
            {
            // Reserve a new buffer:
            dataPart = HBufC8::NewMaxLC( dataLength );

            // Set the read buffer:
            dataBuffer.Set( const_cast<TUint8*>(dataPart->Ptr()), 0,
                            dataLength );

            // Read the data:
            aStream.ReadL( dataBuffer );

            // Pop the buffer
            CleanupStack::Pop(); // dataPart

            // If an old content identifier exists delete it
            if ( iSystem.Count() )
                {
                iSystem.ResetAndDestroy();
                }

            // assign the new content id
            iSystem.AppendL( dataPart );
            }
        else
            {
            // If an old system exists delete it
            if ( iSystem.Count() )
                {
                iSystem.ResetAndDestroy();
                }
            }
        }

    // Software Vendor Id
    iVendorId.iUid = aStream.ReadInt32L();

    // Secure Id of the allowed application
    iSecureId.iUid = aStream.ReadInt32L();

    // Active constraints
    iActiveConstraints = aStream.ReadUint32L();

#ifdef RD_DRM_METERING

    // Do not read metering information if the version
    // is the old one because Metering is not activated in it.
    if ( iVersion == KVersion3_2_1 )
        {

        // Metering info
        dataLength = aStream.ReadInt32L();

        SanitizeL( dataLength );

        if( dataLength > 0 )
            {

            if( !iDrmMeteringInfo )
                {
                // Reserve a new metering information instance
                iDrmMeteringInfo = new (ELeave)TDrmMeteringInfo;
                }
            else
                {
                iDrmMeteringInfo->iGraceTime = 0;
                iDrmMeteringInfo->iAllowUseWithoutMetering = EFalse;
                }

            // Read grace time
            iDrmMeteringInfo->iGraceTime = aStream.ReadInt32L();

            // Read whether content can be consumed without
            // metering being used
            iDrmMeteringInfo->iAllowUseWithoutMetering =
                aStream.ReadInt8L();

            }
        else
            {

            // If old metering information exists delete it
            if( iDrmMeteringInfo )
                {
                delete iDrmMeteringInfo;
                iDrmMeteringInfo = NULL;
                }
            }
        }

#endif //RD_DRM_METERING

    // Read the system and original timed counter
    // according to the new structure.
    if ( iVersion == KVersion3_2_1 )
        {

        dataLength = aStream.ReadInt32L();

        SanitizeL( dataLength );

        if( dataLength > 0 )
            {
            // Reserve a new buffer:
            dataPart = HBufC8::NewMaxLC( dataLength );

            // Set the read buffer:
            dataBuffer.Set(const_cast<TUint8*>(dataPart->Ptr()), 0, dataLength);

            // Read the data:
            aStream.ReadL( dataBuffer );

            // Fill the array from the string
            ReadArrayFromStringL( dataBuffer, iSystem);

            // Pop the buffer
            CleanupStack::PopAndDestroy(); // dataPart

            }
        else
            {
            iSystem.ResetAndDestroy();
            }

        // Read the original timed counter
        iOriginalTimedCounter = aStream.ReadInt32L();

        // For future use or development, reads the data at the end of the stream
        dataLength = aStream.ReadInt32L();

        SanitizeL( dataLength );

        if ( dataLength > 0 )
            {

            // Reserve a new buffer:
            dataPart = HBufC8::NewMaxLC( dataLength );

            // Set the read buffer:
            dataBuffer.Set(const_cast<TUint8*>(dataPart->Ptr()), 0, dataLength);

            // Read the data:
            aStream.ReadL( dataBuffer );

            // Pop the buffer
            CleanupStack::PopAndDestroy( dataPart );
            }
        }

    // Constraint can be considered to have the new structure from now on.
    if ( iVersion == KVersion3_2_0 )
        {
        iSyncMark = KSyncMark;
        iVersion = KVersion3_2_1;
        }

    };