omadrm/drmengine/ro/src/DRMConstraint.cpp
branchRCL_3
changeset 12 8a03a285ab14
parent 0 95b198f216e5
--- a/omadrm/drmengine/ro/src/DRMConstraint.cpp	Fri Mar 12 15:43:46 2010 +0200
+++ b/omadrm/drmengine/ro/src/DRMConstraint.cpp	Mon Mar 15 12:41:43 2010 +0200
@@ -19,18 +19,18 @@
 // INCLUDE FILES
 #include <s32strm.h>
 #include <s32mem.h>
-#include "DRMConstraint.h"
+#include "DrmConstraint.h"
 
 // CONSTANTS
 
 // Synchronizing marker in the beginning of the stream in order to synchronize
-// to an externalized Constraint object having the new structure.  
+// to an externalized Constraint object having the new structure.
 const TInt32 KSyncMark = 0xAFCE;
 
 // Old and new version number of the Constraint object
 const TInt8 KVersion3_2_0 = 0;
-const TInt8 KVersion3_2_1 = 1; 
-   
+const TInt8 KVersion3_2_1 = 1;
+
 const TInt KSanityDataLengthLow = 0;
 const TInt KSanityDataLengthHigh = 32768;
 
@@ -55,17 +55,17 @@
 // Appends the strings of array aFrom to array aTo
 // -----------------------------------------------------------------------------
 //
-LOCAL_C void AppendToArrayL( RPointerArray<HBufC8>& aTo, 
+LOCAL_C void AppendToArrayL( RPointerArray<HBufC8>& aTo,
                              const RPointerArray<HBufC8>& aFrom )
     {
     HBufC8* addData = NULL;
-    
+
     for( TInt i = 0; i < aFrom.Count(); i++ )
         {
         addData = aFrom[i]->AllocLC();
         aTo.AppendL( addData );
-        CleanupStack::Pop( addData ); 
-        }    
+        CleanupStack::Pop( addData );
+        }
     }
 
 // -----------------------------------------------------------------------------
@@ -76,13 +76,13 @@
 LOCAL_C TInt CountArrayStoreSize( const RPointerArray<HBufC8>& aArray )
     {
     TInt size = 0;
-    
+
     for(TInt i = 0; i < aArray.Count(); i++ )
         {
         size += sizeof(TInt);
         size += aArray[i]->Size();
         }
-    return size;    
+    return size;
     }
 // -----------------------------------------------------------------------------
 // WriteArrayToStreamL
@@ -98,12 +98,12 @@
         aStream.WriteL( aArray[i]->Des() );
         }
     }
-    
+
 // -----------------------------------------------------------------------------
 // ReadArrayFromStringL
 // Reads the array from the string
 // -----------------------------------------------------------------------------
-//    
+//
 LOCAL_C void ReadArrayFromStringL( const TDesC8& aString,
                                    RPointerArray<HBufC8>& aArray )
     {
@@ -112,29 +112,29 @@
     HBufC8* addData = NULL;
     TPtr8 dataBuffer(NULL,0,0);
     CleanupClosePushL( inRead );
-    
-    
+
+
     aArray.ResetAndDestroy();
-    
-    
+
+
     for( TInt i = 0; i < aString.Size();)
         {
-        // If there is not enough data to read the integer 
+        // If there is not enough data to read the integer
         // it means that it's an old version and the whole thing is the
-        // string since in previous versions only one string is stored        
+        // string since in previous versions only one string is stored
         if(( aString.Size() - i) < sizeof(TInt) )
             {
             aArray.ResetAndDestroy();
             addData = aString.AllocLC();
             aArray.AppendL( addData );
             CleanupStack::Pop();
-            CleanupStack::PopAndDestroy(); // inRead              
-            return;            
+            CleanupStack::PopAndDestroy(); // inRead
+            return;
             }
-        
+
         size = inRead.ReadInt32L();
         i += sizeof(TInt);
-        
+
         // If the size is negative or the size left is not large enough
         // it means that it's an old version and the whole thing is the
         // string since in previous versions only one string is stored.
@@ -144,35 +144,35 @@
             addData = aString.AllocLC();
             aArray.AppendL( addData );
             CleanupStack::Pop();
-            CleanupStack::PopAndDestroy(); // inRead            
+            CleanupStack::PopAndDestroy(); // inRead
             return;
             }
-        addData = HBufC8::NewMaxLC( size );    
+        addData = HBufC8::NewMaxLC( size );
 
         // Set the read buffer:
         dataBuffer.Set(const_cast<TUint8*>(addData->Ptr()), 0, size);
-        
+
         // Read the data:
         inRead.ReadL( dataBuffer );
-        
+
         aArray.AppendL( addData );
         CleanupStack::Pop( addData );
 
         i += size;
         }
-    CleanupStack::PopAndDestroy();    
+    CleanupStack::PopAndDestroy();
     return;
     }
-    
+
 // -----------------------------------------------------------------------------
 // IsIndividualConstraintValid
 // -----------------------------------------------------------------------------
 //
-LOCAL_C TBool IsIndividualConstraintValid( const RPointerArray<HBufC8>& aConstraint, 
+LOCAL_C TBool IsIndividualConstraintValid( const RPointerArray<HBufC8>& aConstraint,
                                            const RPointerArray<HBufC8>& aValidConstraints)
     {
     TInt retVal = 0;
-    
+
     for( TInt i = 0; i < aConstraint.Count(); i++ )
         {
         for( TInt j = 0; j < aValidConstraints.Count(); j++ )
@@ -184,7 +184,7 @@
                 }
             }
         }
-    return EFalse;    
+    return EFalse;
     };
 
 // ============================ MEMBER FUNCTIONS ===============================
@@ -200,8 +200,8 @@
     CDRMConstraint* self = new( ELeave ) CDRMConstraint();
     CleanupStack::PushL( self );
     self->ConstructL();
-    
-    return self;    
+
+    return self;
     };
 
 // -----------------------------------------------------------------------------
@@ -213,9 +213,9 @@
     {
     CDRMConstraint* self = NewLC();
     CleanupStack::Pop();
-    
+
     return self;
-    }; 
+    };
 
 // -----------------------------------------------------------------------------
 // Default Constructor - First phase.
@@ -224,8 +224,8 @@
 //
 EXPORT_C CDRMConstraint::CDRMConstraint() :
     iSyncMark( KSyncMark ),
-    iVersion( KVersion3_2_1 ), // Version number for differentiation 
-                               // in InternalizeL. 
+    iVersion( KVersion3_2_1 ), // Version number for differentiation
+                               // in InternalizeL.
     iStartTime( Time::NullTTime() ),
     iEndTime( Time::NullTTime() ),
     iIntervalStart( Time::NullTTime() ),
@@ -233,38 +233,38 @@
     iCounter( 0 ),
     iOriginalCounter( 0 ),
     iTimedCounter( 0 ),
-	iTimedInterval( 0 ),
-	iAccumulatedTime( 0 ),
-	iVendorId( TUid::Null() ),
-	iSecureId( TUid::Null() ),
+    iTimedInterval( 0 ),
+    iAccumulatedTime( 0 ),
+    iVendorId( TUid::Null() ),
+    iSecureId( TUid::Null() ),
     iActiveConstraints( 0 ),
     iDrmMeteringInfo( NULL ),
-    iOriginalTimedCounter( 0 ) 
+    iOriginalTimedCounter( 0 )
     {
     }
-    
+
 // -----------------------------------------------------------------------------
 // Destructor
 // -----------------------------------------------------------------------------
-// 
+//
 EXPORT_C CDRMConstraint::~CDRMConstraint()
     {
 
     iIndividual.ResetAndDestroy();
     iIndividual.Close();
-    
+
     iSystem.ResetAndDestroy();
-    iSystem.Close(); 
-            
-#ifdef RD_DRM_METERING       
+    iSystem.Close();
+
+#ifdef RD_DRM_METERING
     if( iDrmMeteringInfo )
         {
         delete iDrmMeteringInfo;
         iDrmMeteringInfo = NULL;
         }
 #endif
-        
-    }; 
+
+    };
 
 // -----------------------------------------------------------------------------
 // CDRMConstraint::ExternalizeL
@@ -272,43 +272,43 @@
 //
 EXPORT_C void CDRMConstraint::ExternalizeL( RWriteStream& aStream ) const
     {
-    
+
     // used for the buffers
     TInt32 dataLength = 0;
-    
+
     // write the synchronizing marker
     aStream.WriteInt32L( iSyncMark );
-    
+
     // Write the version number
     aStream.WriteInt32L( iVersion );
-    
+
     // Write the start time
     WriteInt64L( iStartTime.Int64(), aStream );
-    
+
     // Write the end time
     WriteInt64L( iEndTime.Int64(), aStream );
-    
+
     // Write the interval start time
-    WriteInt64L( iIntervalStart.Int64(), aStream ); 
-    
-    // Write the interval   
+    WriteInt64L( iIntervalStart.Int64(), aStream );
+
+    // Write the interval
     aStream.WriteInt32L( iInterval.Int() );
-    
+
     // Write the counter
     aStream.WriteInt32L( iCounter );
-    
+
     // Write the original counter
     aStream.WriteInt32L( iOriginalCounter );
-    
+
     // Write the timed counter
     aStream.WriteInt32L( iTimedCounter );
 
     // Write the timed interval
     aStream.WriteInt32L( iTimedInterval.Int() );
-    
+
     // Write the accumulated time
     aStream.WriteInt32L( iAccumulatedTime.Int() );
-    
+
     // Write the individual
     dataLength = 0;
     if ( iIndividual.Count() )
@@ -319,58 +319,58 @@
 
     if ( dataLength )
         {
-        WriteArrayToStreamL( aStream, iIndividual );       
-        }         
-    
+        WriteArrayToStreamL( aStream, iIndividual );
+        }
+
     // Software Vendor Id
     aStream.WriteInt32L( iVendorId.iUid );
-    
+
     // Secure Id of the allowed application
     aStream.WriteInt32L( iSecureId.iUid );
-    
+
     // Active constraints
     aStream.WriteUint32L( iActiveConstraints );
-    
+
     // Metering info
-#ifdef RD_DRM_METERING    
+#ifdef RD_DRM_METERING
     dataLength = 0;
     if ( iDrmMeteringInfo )
         {
         dataLength = sizeof( TTimeIntervalSeconds ) + sizeof( TUint8 );
         }
-    
+
     aStream.WriteInt32L( dataLength );
-    
+
     if ( dataLength )
         {
         aStream.WriteInt32L( iDrmMeteringInfo->iGraceTime.Int() );
         aStream.WriteInt8L( iDrmMeteringInfo->iAllowUseWithoutMetering );
         }
-   
+
 #endif
-    
+
     // Write the system
     dataLength = 0;
     if ( iSystem.Count() )
         {
         dataLength = CountArrayStoreSize( iSystem );
         }
-    
+
     aStream.WriteInt32L( dataLength );
-        
+
     if ( dataLength )
         {
         WriteArrayToStreamL( aStream, iSystem );
         }
-            
+
     // write the original timed counter
     aStream.WriteInt32L( iOriginalTimedCounter );
-        
+
     // For future use
     aStream.WriteInt32L( 0 );
-    
+
     };
-    
+
 // -----------------------------------------------------------------------------
 // CDRMConstraint::InternalizeL
 // -----------------------------------------------------------------------------
@@ -380,271 +380,271 @@
 
     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) 
+        // 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 
+
+        // The version is marked as old version for differentiation in
         // InternalizeL.
         iVersion = KVersion3_2_0;
-                             
+
         }
-    else 
+    else
         {
         // The structure of the externalized Permission object is the new one.
-        // Read the version and Start time.    
+        // 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 ); 
+    ReadInt64L( timeData, aStream );
     iIntervalStart = timeData;
-    
-    // Read the interval   
+
+    // 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 
+
+        // Pop the buffer
         CleanupStack::PopAndDestroy(); // dataPart
-                    
+
         }
     else
         {
-        iIndividual.ResetAndDestroy();       
-        }           
-    
-    
-    // Read the system 
+        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, 
+            dataBuffer.Set( const_cast<TUint8*>(dataPart->Ptr()), 0,
                             dataLength );
-        
+
             // Read the data:
             aStream.ReadL( dataBuffer );
-        
-            // Pop the buffer 
+
+            // Pop the buffer
             CleanupStack::Pop(); // dataPart
-                
-            // If an old content identifier exists delete it        
+
+            // 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();
                 }
-        
-            // 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(); 
-    
+    iSecureId.iUid = aStream.ReadInt32L();
+
     // Active constraints
-    iActiveConstraints = aStream.ReadUint32L();    
+    iActiveConstraints = aStream.ReadUint32L();
 
-#ifdef RD_DRM_METERING    
-    
+#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 
+            else
                 {
                 iDrmMeteringInfo->iGraceTime = 0;
                 iDrmMeteringInfo->iAllowUseWithoutMetering = EFalse;
                 }
-        
-            // Read grace time 
+
+            // Read grace time
             iDrmMeteringInfo->iGraceTime = aStream.ReadInt32L();
-        
-            // Read whether content can be consumed without 
+
+            // Read whether content can be consumed without
             // metering being used
-            iDrmMeteringInfo->iAllowUseWithoutMetering = 
+            iDrmMeteringInfo->iAllowUseWithoutMetering =
                 aStream.ReadInt8L();
-           
+
             }
         else
             {
-        
-            // If old metering information exists delete it 
+
+            // 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 
+
+            // Pop the buffer
             CleanupStack::PopAndDestroy(); // dataPart
-                    
+
             }
         else
             {
-            iSystem.ResetAndDestroy();       
-            }         
-    
+            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 
+
+            // Pop the buffer
             CleanupStack::PopAndDestroy( dataPart );
             }
         }
-    
-    // Constraint can be considered to have the new structure from now on. 
-    if ( iVersion == KVersion3_2_0 ) 
+
+    // Constraint can be considered to have the new structure from now on.
+    if ( iVersion == KVersion3_2_0 )
         {
         iSyncMark = KSyncMark;
-        iVersion = KVersion3_2_1; 
+        iVersion = KVersion3_2_1;
         }
-    
+
     };
-    
+
 // -----------------------------------------------------------------------------
 // CDRMConstraint::Stateful
 // -----------------------------------------------------------------------------
@@ -654,35 +654,35 @@
     // counters, timed counters and accumulated are stateful
     if ( iActiveConstraints &  (EConstraintCounter |
                                EConstraintTimedCounter |
-                               EConstraintAccumulated ) ) 
+                               EConstraintAccumulated ) )
         {
         return ETrue;
         }
-        
+
      // Non-Activated interval is stateful
     if ( ( iActiveConstraints & EConstraintInterval ) &&
-        iIntervalStart == Time::NullTTime() ) 
+        iIntervalStart == Time::NullTTime() )
         {
         return ETrue;
         }
-        
+
     return EFalse;
     };
 
 // -----------------------------------------------------------------------------
 // CDRMConstraint::Size
 // -----------------------------------------------------------------------------
-//   
+//
 EXPORT_C TInt CDRMConstraint::Size() const
     {
     TInt size = 0;
-    
+
     // synchronizing marker
     size += sizeof(TInt32);
-    
+
     // version number
     size += sizeof(TInt32);
-    
+
     // usage start time
     size += sizeof(TTime);
 
@@ -702,13 +702,13 @@
     size += sizeof(TDRMCounter);
 
     // timed counter
-	size += sizeof(TDRMCounter);
+    size += sizeof(TDRMCounter);
 
     // Interval of the timed counter constraint
-	size += sizeof(TTimeIntervalSeconds);
+    size += sizeof(TTimeIntervalSeconds);
 
     // accumulated time
-	size += sizeof(TTimeIntervalSeconds);
+    size += sizeof(TTimeIntervalSeconds);
 
     // individual allowed usage
     size += sizeof(TInt32);
@@ -716,114 +716,114 @@
 
     // Software Vendor Id
     size += sizeof(TUid);
-    
+
     // Secure Id of the allowed application
     size += sizeof(TUid);
-	
-	// Bitmask of active constraints
+
+    // Bitmask of active constraints
     size += sizeof(TUint32);
-    
-#ifdef RD_DRM_METERING    
+
+#ifdef RD_DRM_METERING
     // Metering information
     size += sizeof(TInt32);
-    
+
     if (iDrmMeteringInfo)
         {
-        size += sizeof(TTimeIntervalSeconds); 
+        size += sizeof(TTimeIntervalSeconds);
         size += sizeof(TUint8);
         }
-    
+
 #endif //RD_DRM_METERING
-    
+
     // system allowed usage
     size += sizeof(TInt32);
     size += CountArrayStoreSize(iSystem);
-    
+
     // original timed counter value
     size += sizeof(TDRMCounter);
-    
+
     // For future use
     size += sizeof(TInt32);
-    
+
     return size;
-       
-    };    
+
+    };
 
 // -----------------------------------------------------------------------------
 // CDRMConstraint::Expired
 // -----------------------------------------------------------------------------
-//      
+//
 EXPORT_C TBool CDRMConstraint::Expired( const TTime& aTime ) const
     {
-	// Full Rights do not expire
-	if ( iActiveConstraints == EConstraintNone )
-		{
-		return EFalse;
-		}
+    // Full Rights do not expire
+    if ( iActiveConstraints == EConstraintNone )
+        {
+        return EFalse;
+        }
 
-	// First check counters, accumulated time and timed counters
-	// if any of these is expired the whole thing is expired regardless of the
-	// actual time based constrants or future rights
-	
+    // First check counters, accumulated time and timed counters
+    // if any of these is expired the whole thing is expired regardless of the
+    // actual time based constrants or future rights
+
     // Counters
-    if ( ( iActiveConstraints & EConstraintCounter ) && iCounter < 1 ) 
-    	{
-    	return ETrue;	
-    	}
-    		
-    // Accumulated time	
+    if ( ( iActiveConstraints & EConstraintCounter ) && iCounter < 1 )
+        {
+        return ETrue;
+        }
+
+    // Accumulated time
     if ( ( iActiveConstraints & EConstraintAccumulated ) && iAccumulatedTime.Int() == 0 )
-    	{
-    	return ETrue;
-    	}
-    		
+        {
+        return ETrue;
+        }
+
      // Timed Counters
-    if ( ( iActiveConstraints & EConstraintTimedCounter ) && iTimedCounter < 1 ) 
-    	{
-    	return ETrue;	
-    	} 
-    		
+    if ( ( iActiveConstraints & EConstraintTimedCounter ) && iTimedCounter < 1 )
+        {
+        return ETrue;
+        }
+
 
     // Dont check time based rights
     if ( aTime != Time::NullTTime() )
-    	{	
-    	
-    	// Check for activated intervals
-    	if ( ( iActiveConstraints & EConstraintInterval) && iIntervalStart != Time::NullTTime() )
-    		{
-        	TTimeIntervalSeconds current;
-        
-        	aTime.SecondsFrom( iIntervalStart, current );
-        
-        	if ( current >= iInterval )
-            	{
-            	return ETrue;
-            	}    			
-    		}
-    	
-    	// Check for end time
-    	if ( ( iActiveConstraints & EConstraintEndTime ) && aTime >= iEndTime )
-    		{
-    		return ETrue;	
-    		}	
-    		
-    	// Check for start time, future rights	
-    	if ( ( iActiveConstraints & EConstraintStartTime ) && aTime < iStartTime )
-    		{
-    		return EFalse;	
-    		}
-    	}
+        {
+
+        // Check for activated intervals
+        if ( ( iActiveConstraints & EConstraintInterval) && iIntervalStart != Time::NullTTime() )
+            {
+            TTimeIntervalSeconds current;
+
+            aTime.SecondsFrom( iIntervalStart, current );
+
+            if ( current >= iInterval )
+                {
+                return ETrue;
+                }
+            }
+
+        // Check for end time
+        if ( ( iActiveConstraints & EConstraintEndTime ) && aTime >= iEndTime )
+            {
+            return ETrue;
+            }
+
+        // Check for start time, future rights
+        if ( ( iActiveConstraints & EConstraintStartTime ) && aTime < iStartTime )
+            {
+            return EFalse;
+            }
+        }
 
     return EFalse;
     }
 // -----------------------------------------------------------------------------
 // CDRMConstraint::Merge
 // -----------------------------------------------------------------------------
-//      
+//
 EXPORT_C void CDRMConstraint::Merge( const CDRMConstraint& aConstraint )
     {
     TInt error = KErrNone;
-    
+
     if ( this != &aConstraint )
         {
         if ( aConstraint.iActiveConstraints & EConstraintStartTime )
@@ -838,7 +838,7 @@
                 iActiveConstraints |= EConstraintStartTime;
                 }
             }
-            
+
         if ( aConstraint.iActiveConstraints & EConstraintEndTime )
             {
             if ( iActiveConstraints & EConstraintEndTime )
@@ -851,7 +851,7 @@
                 iActiveConstraints |= EConstraintEndTime;
                 }
             }
-            
+
         if ( aConstraint.iActiveConstraints & EConstraintCounter )
             {
             if ( iActiveConstraints & EConstraintCounter )
@@ -866,7 +866,7 @@
                 iActiveConstraints |= EConstraintCounter;
                 }
             }
-        
+
         if ( aConstraint.iActiveConstraints & EConstraintInterval )
             {
             if ( iActiveConstraints & EConstraintInterval )
@@ -881,7 +881,7 @@
                 iActiveConstraints |= EConstraintInterval;
                 }
             }
-            
+
         if ( aConstraint.iActiveConstraints & EConstraintTimedCounter )
             {
             if ( iActiveConstraints & EConstraintTimedCounter )
@@ -899,7 +899,7 @@
                 iActiveConstraints |= EConstraintTimedCounter;
                 }
             }
-        
+
         if ( aConstraint.iActiveConstraints & EConstraintAccumulated )
             {
             if ( iActiveConstraints & EConstraintAccumulated )
@@ -912,20 +912,20 @@
                 iActiveConstraints |= EConstraintAccumulated;
                 }
             }
-             
+
         if( aConstraint.iActiveConstraints & EConstraintIndividual )
             {
             // Ignore the error since we don't return an error code or leave
             TRAP( error, AppendToArrayL( iIndividual, aConstraint.iIndividual ) );
             }
-            
+
         }
     }
 
 // -----------------------------------------------------------------------------
-// CDRMConstraint::Consume  
+// CDRMConstraint::Consume
 // -----------------------------------------------------------------------------
-//  
+//
 EXPORT_C void CDRMConstraint::Consume( const TTime& aCurrentTime )
     {
     if ( ( iActiveConstraints & EConstraintInterval ) &&
@@ -933,7 +933,7 @@
         {
         iIntervalStart = aCurrentTime;
         }
-        
+
     if ( iActiveConstraints & EConstraintCounter )
         {
         --iCounter;
@@ -946,13 +946,13 @@
 //
 EXPORT_C void CDRMConstraint::DuplicateL( const CDRMConstraint& aConstraint )
     {
-    
+
     // synchronizing marker
     iSyncMark = aConstraint.iSyncMark;
-    
+
     // version number
     iVersion = aConstraint.iVersion;
-    
+
     // usage start time
     iStartTime = aConstraint.iStartTime;
 
@@ -972,50 +972,50 @@
     iOriginalCounter = aConstraint.iOriginalCounter;
 
     // timed counter
-	iTimedCounter = aConstraint.iTimedCounter;
+    iTimedCounter = aConstraint.iTimedCounter;
 
     // Interval of the timed counter constraint
-	iTimedInterval = aConstraint.iTimedInterval;
+    iTimedInterval = aConstraint.iTimedInterval;
 
     // accumulated time
-	iAccumulatedTime = aConstraint.iAccumulatedTime;
+    iAccumulatedTime = aConstraint.iAccumulatedTime;
 
     // individual allowed usage
     iIndividual.ResetAndDestroy();
-    
+
     AppendToArrayL( iIndividual, aConstraint.iIndividual );
-	
+
     // Software Vendor Id
     iVendorId = aConstraint.iVendorId;
-	
+
     // Secure Id of the allowed application
     iSecureId = aConstraint.iSecureId;
-	
-	// Bitmask of active constraints
-    iActiveConstraints = aConstraint.iActiveConstraints;	// Bitmask
 
-#ifdef RD_DRM_METERING    
+    // Bitmask of active constraints
+    iActiveConstraints = aConstraint.iActiveConstraints;    // Bitmask
+
+#ifdef RD_DRM_METERING
     // Metering information
     if ( aConstraint.iDrmMeteringInfo )
         {
-        
+
         if( !iDrmMeteringInfo )
             {
             iDrmMeteringInfo = new (ELeave) TDrmMeteringInfo;
             }
-    
+
         iDrmMeteringInfo->iGraceTime = aConstraint.iDrmMeteringInfo->iGraceTime;
-        iDrmMeteringInfo->iAllowUseWithoutMetering = aConstraint.iDrmMeteringInfo->iAllowUseWithoutMetering; 
+        iDrmMeteringInfo->iAllowUseWithoutMetering = aConstraint.iDrmMeteringInfo->iAllowUseWithoutMetering;
         }
 #endif
-    
+
     // system allowed usage
     iSystem.ResetAndDestroy();
     AppendToArrayL( iSystem, aConstraint.iSystem );
-    
+
     // original timed counter value
     iOriginalTimedCounter = aConstraint.iOriginalTimedCounter;
-    
+
     };
 
 
@@ -1026,88 +1026,88 @@
 EXPORT_C TBool CDRMConstraint::Valid( const TTime& aTime,
                                       const RPointerArray<HBufC8>& aIndividual,
                                       TUint32& aRejection ) const
-	{
-	TBool drmTime = EFalse;
-	// Null the rejection requirement:
-	aRejection = EConstraintNone;
-	
-	// Full Rights are always valid
-	if ( iActiveConstraints == EConstraintNone )
-		{
-		return ETrue;
-		}
+    {
+    TBool drmTime = EFalse;
+    // Null the rejection requirement:
+    aRejection = EConstraintNone;
 
-	// First check counters, accumulated time and timed counters
-	// if any of these are invalid the whole thing is invalid regardless of the
-	// actual time based constraints
-	
+    // Full Rights are always valid
+    if ( iActiveConstraints == EConstraintNone )
+        {
+        return ETrue;
+        }
+
+    // First check counters, accumulated time and timed counters
+    // if any of these are invalid the whole thing is invalid regardless of the
+    // actual time based constraints
+
     // Counters
-    if ( ( iActiveConstraints & EConstraintCounter ) && iCounter < 1 ) 
-    	{
-    	aRejection |= EConstraintCounter;
-    	}
-    		
-    // Accumulated time	
+    if ( ( iActiveConstraints & EConstraintCounter ) && iCounter < 1 )
+        {
+        aRejection |= EConstraintCounter;
+        }
+
+    // Accumulated time
     if ( ( iActiveConstraints & EConstraintAccumulated ) && iAccumulatedTime.Int() == 0 )
-    	{
-    	aRejection |= EConstraintAccumulated;
-    	}
-    		
+        {
+        aRejection |= EConstraintAccumulated;
+        }
+
      // Timed Counters
-    if ( ( iActiveConstraints & EConstraintTimedCounter ) && iTimedCounter < 1 ) 
-    	{
-    	aRejection |= EConstraintTimedCounter;	
-    	} 
-    		
+    if ( ( iActiveConstraints & EConstraintTimedCounter ) && iTimedCounter < 1 )
+        {
+        aRejection |= EConstraintTimedCounter;
+        }
+
     // Dont check time based rights
     if ( aTime != Time::NullTTime() )
-    	{	
-    	drmTime = ETrue;
-    	// Check for activated intervals
-    	if ( (iActiveConstraints & EConstraintInterval) && iIntervalStart != Time::NullTTime() )
-    		{
-        	TTimeIntervalSeconds current;
-        
-        	aTime.SecondsFrom( iIntervalStart, current );
-        
-        	if ( ( current >= iInterval ) || ( aTime < iIntervalStart ) )
-            	{
-            	aRejection |= EConstraintInterval;
-            	}    			
-    		}
-    	
-    	// Check for end time
-    	if ( ( iActiveConstraints & EConstraintEndTime ) && aTime >= iEndTime ) 
-    	    {
-    	    aRejection |= EConstraintEndTime;
-    	    }
-    	    
-    	if ( ( iActiveConstraints & EConstraintStartTime ) && aTime < iStartTime )     
-    		{
-    		aRejection |= EConstraintStartTime;	
-    		}	
-    	}
+        {
+        drmTime = ETrue;
+        // Check for activated intervals
+        if ( (iActiveConstraints & EConstraintInterval) && iIntervalStart != Time::NullTTime() )
+            {
+            TTimeIntervalSeconds current;
+
+            aTime.SecondsFrom( iIntervalStart, current );
+
+            if ( ( current >= iInterval ) || ( aTime < iIntervalStart ) )
+                {
+                aRejection |= EConstraintInterval;
+                }
+            }
+
+        // Check for end time
+        if ( ( iActiveConstraints & EConstraintEndTime ) && aTime >= iEndTime )
+            {
+            aRejection |= EConstraintEndTime;
+            }
+
+        if ( ( iActiveConstraints & EConstraintStartTime ) && aTime < iStartTime )
+            {
+            aRejection |= EConstraintStartTime;
+            }
+        }
     else
         {
         drmTime = EFalse;
-        
-    	// Check for activated intervals
-    	if ( (iActiveConstraints & EConstraintInterval) )
-    		{
-            aRejection |= EConstraintInterval; 			
-    		}
-    	
-    	// Check for end time
-    	if ( ( iActiveConstraints & EConstraintEndTime ) ) 
-    	    {
-    	    aRejection |= EConstraintEndTime;
-    	    }
-    	    
-    	if( ( iActiveConstraints & EConstraintStartTime ) )     
-    		{
-    		aRejection |= EConstraintStartTime;	
-    		}
-        }	
+
+        // Check for activated intervals
+        if ( (iActiveConstraints & EConstraintInterval) )
+            {
+            aRejection |= EConstraintInterval;
+            }
+
+        // Check for end time
+        if ( ( iActiveConstraints & EConstraintEndTime ) )
+            {
+            aRejection |= EConstraintEndTime;
+            }
+
+        if( ( iActiveConstraints & EConstraintStartTime ) )
+            {
+            aRejection |= EConstraintStartTime;
+            }
+        }
 
     // IMSI Checking:
     if( iActiveConstraints & EConstraintIndividual )
@@ -1120,7 +1120,7 @@
             {
             aRejection |= EConstraintIndividual;
             }
-        }        
+        }
 
     if( aRejection )
         {
@@ -1128,12 +1128,12 @@
         if( !drmTime )
             {
             aRejection |= EConstraintNullDrmTime;
-            }       
-        return EFalse;        
+            }
+        return EFalse;
         }
 
-    return ETrue;		
-	};
+    return ETrue;
+    };
 
 
 // -----------------------------------------------------------------------------
@@ -1144,7 +1144,7 @@
 void CDRMConstraint::ConstructL()
     {
     };
-    
+
 // -----------------------------------------------------------------------------
 // CDRMConstraint::WriteInt64L
 // -----------------------------------------------------------------------------
@@ -1152,10 +1152,10 @@
 void CDRMConstraint::WriteInt64L( const TInt64& aWrite, RWriteStream& aStream ) const
     {
     TPtr8 output(NULL,0,0);
-    
-    output.Set( reinterpret_cast<TUint8*>(const_cast<TInt64*>(&aWrite)), 
+
+    output.Set( reinterpret_cast<TUint8*>(const_cast<TInt64*>(&aWrite)),
                 sizeof(TInt64), sizeof(TInt64) );
-    
+
     aStream.WriteL( output, sizeof(TInt64) );
     };
 
@@ -1166,9 +1166,9 @@
 void CDRMConstraint::ReadInt64L( TInt64& aRead, RReadStream& aStream )
     {
     TPtr8 input(NULL,0,0);
-    
+
     input.Set( reinterpret_cast<TUint8*>(&aRead), 0, sizeof(TInt64) );
-    
-    aStream.ReadL( input, sizeof(TInt64) );    
-    };        
+
+    aStream.ReadL( input, sizeof(TInt64) );
+    };
 // End of File