Revision: 201015 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Tue, 27 Apr 2010 16:56:11 +0300
branchRCL_3
changeset 15 04da681812a9
parent 14 8cdda00a45da
child 16 457cd4423b8c
Revision: 201015 Kit: 201017
commondrm/drmrightsmanagerui/inc/DRMRightsMgrAppUi.h
commondrm/drmrightsmanagerui/src/DRMRightsMgrAppUi.cpp
commondrm/drmrightsmanagerui/src/DRMRightsMgrDetailsContainer.cpp
commondrm/drmutility/src/DrmUiHandlingImpl.cpp
omadrm/drmengine/group/CryptoPrep.flm
omadrm/drmengine/keystorage/src/DrmStdKeyStorage.cpp
omadrm/drmengine/server/inc/DRMActiveDeletion.h
omadrm/drmengine/server/src/DRMActiveDeletion.cpp
omadrm/drmengine/server/src/DRMRightsClientStub.cpp
omadrm/drmengine/server/src/DRMServerStarter.cpp
omadrm/drmengine/server/src/drmcrypto.c
omadrm/drmhelper/src/DRMHelperClient.cpp
omadrm/drmlicensemanager/src/LMSecurity.cpp
omadrm/drmlicensemanager/src/LMSecurityDecrypt.cpp
omadrm/drmlicensemanager/src/LMSecurityEncrypt.cpp
omadrm/drmplugins/drmudtmodule/bwinscw/DrmUdtModuleU.DEF
omadrm/drmplugins/drmudtmodule/eabi/DrmUdtModuleU.DEF
omadrm/drmplugins/drmudtmodule/group/DrmUdtModule.mmp
omadrm/drmplugins/drmudtmodule/inc/DrmUdtConn.h
omadrm/drmplugins/drmudtmodule/src/DrmUdtConn.cpp
omadrm/drmplugins/drmudtmodule/src/DrmUdtHandler.cpp
omadrm/group/bld.inf
omadrm/rom/DRM5.iby
--- a/commondrm/drmrightsmanagerui/inc/DRMRightsMgrAppUi.h	Wed Apr 14 16:15:06 2010 +0300
+++ b/commondrm/drmrightsmanagerui/inc/DRMRightsMgrAppUi.h	Tue Apr 27 16:56:11 2010 +0300
@@ -25,7 +25,9 @@
 #include <AknProgressDialog.h>
 #include <apparc.h>
 #include <DRMRightsClient.h>
+#include <drmconstraint.h>
 
+#include "drmclockclient.h"
 #include "DrmViewItems.h"
 
 #include "DRMRightsManager.hrh"
@@ -173,9 +175,42 @@
         void CheckIndividualConstraint( const TDesC8& aContentURI,
                                         TBool& aIndividualConstraint,
                                         TBool& aUsageAllowed );
-
+        
+        /**
+        * Checks the composition of best rights to be shown in the details view.
+        * Leaves with KErrNotFound if no rights are found.
+        * @param aContentURI            ContentURI for object to be opened when
+        *                               application is launched
+        * @param aRights                Pointer to instance of CDRMRights for
+        *                               storing the rights                                                            
+        */                               
+        void FindBestCompositionRightsL( const TDesC8& aContentURI,
+                                         CDRMRights*& aRights ); 
 
-
+        /**
+        * Compares the permissions in the the permission list one by one and 
+        * constraint by constraint and stores the best constraint to the given 
+        * composition permission. The function should be called only for a list of 
+        * valid permissions. Puts the composition permission to cleanup stack. 
+        * @param aCompositionPermission Permission which includes a composition of best 
+        *                               constraints (or full rights information) from 
+        *                               the given permission list.                                 
+        * @param aPermissionList        List which includes permissions to be checked
+        *                               constraint by constraint in order to create the
+        *                               best composition permission.                                                                                          
+        */                  
+        void CheckBetterPermissionsAndStoreCompositionLC( 
+                CDRMPermission*& aCompositionPermission,
+                RPointerArray<CDRMPermission>& aList );
+        /**
+        * Compares two permissions, and returns ETrue if aNewOne is more suitable
+        * for the usage. Assumes both are valid, i.e. not expired.
+        * @param aNewOne                New constraint to be compared to the old one                             
+        * @param aOldOne                Old constraint to be compared to the new one 
+        */
+        TBool BetterPermission( const CDRMConstraint& aNewOne,
+                                const CDRMConstraint& aOldOne );
+                                                    
     public: // New functions
         /**
         * @param aContentURI    ContentURI for object to be opened when
@@ -390,7 +425,10 @@
         // update the details view when returning to details view from another
         // application
         TBool iForegroundHasBeenActive;
-
+        
+        // Drm clock client
+        RDRMClockClient iClockClient;
+        
     };
 
 // Include inline functions
--- a/commondrm/drmrightsmanagerui/src/DRMRightsMgrAppUi.cpp	Wed Apr 14 16:15:06 2010 +0300
+++ b/commondrm/drmrightsmanagerui/src/DRMRightsMgrAppUi.cpp	Tue Apr 27 16:56:11 2010 +0300
@@ -58,7 +58,70 @@
 _LIT8( Kflk, "flk:" );
 _LIT8( Kldf, "ldf:" );
 
-// ================= MEMBER FUNCTIONS =======================
+// ============================= LOCAL FUNCTIONS ===============================
+
+// ----------------------------------------------------------------------------
+// DoResetAndDestroy
+// Does RPointerArray< >->ResetAndDestroy() for the given array aPtr.
+// ----------------------------------------------------------------------------
+//
+LOCAL_C void DoResetAndDestroyPermission( TAny* aPtr )
+    {
+    ( reinterpret_cast< RPointerArray< CDRMPermission >* >( aPtr ) )->
+        ResetAndDestroy();
+    }
+
+// ----------------------------------------------------------------------------
+// PrepareRightsObjectL
+// Creates rights object based on the given permission.
+// ----------------------------------------------------------------------------
+//
+LOCAL_C void PrepareRightsObjectL( CDRMRights*& aRights,
+                                   CDRMPermission* aPermission )
+    {
+    CDRMAsset* asset( NULL );
+    
+    if ( !aPermission )
+        {
+        User::Leave( KErrArgument );
+        }
+    
+    aRights = CDRMRights::NewL();
+    CleanupStack::PushL( aRights );
+    aRights->SetPermissionL( *aPermission );
+                         
+    asset = CDRMAsset::NewLC();
+    aRights->SetAssetL( *asset );
+    CleanupStack::PopAndDestroy( asset );
+    CleanupStack::Pop( aRights );
+                         
+    // Content URI and Local Id are not set
+    }
+
+// ----------------------------------------------------------------------------
+// EndTime
+// Calculate the true end time: pick the smaller one of aTime1 & aTime2,
+// but ignore Time::NullTTime anyhow.
+// ----------------------------------------------------------------------------
+//
+LOCAL_C TTime EndTime( const TTime& aTime1, const TTime& aTime2 )
+    {
+    TTime nullTime = Time::NullTTime();
+
+    if ( aTime1 == nullTime )
+        {
+        return aTime2;
+        }
+
+    if ( aTime2 == nullTime )
+        {
+        return aTime1;
+        }
+
+    return Min( aTime1, aTime2 );
+    }
+       
+// ================= MEMBER FUNCTIONS ==========================================
 //
 // -----------------------------------------------------------------------------
 // CDRMRightsMgrAppUi::CDRMRightsMgrAppUi
@@ -92,6 +155,7 @@
         EAknEnableMSK | EAknSingleClickCompatible  );
 
     User::LeaveIfError( iRightsClient.Connect() );
+    User::LeaveIfError( iClockClient.Connect() );
     iDRMCommon = DRMCommon::NewL();
     if ( !iDRMCommon )
         {
@@ -129,6 +193,8 @@
     delete iDRMCommon;
 
     iRightsClient.Close();
+    
+    iClockClient.Close();
 
     if ( iStartEmbedded && iDoorObserver )
         {
@@ -557,8 +623,8 @@
     // from the background to the foreground.
     if ( iForegroundHasBeenActive && iContentURI )
         {
-        StartOnlyForDetailsL( iContentURI->Des(), iLocalID,
-            iStartEmbedded, iDrmScheme );
+        TRAP_IGNORE( StartOnlyForDetailsL( iContentURI->Des(), iLocalID, 
+            iStartEmbedded, iDrmScheme ) );
         }
     }
 
@@ -739,7 +805,10 @@
     {
     TBool listable( EFalse ), sendable( EFalse );
     TBool individualConstraint( EFalse ), usageAllowed( EFalse );
+    TInt err( KErrNone );
+    
 
+    aStatus = KErrNone;
     CDcfRep* dcfRep = CDcfRep::NewL();
     CleanupStack::PushL( dcfRep );
 
@@ -798,23 +867,32 @@
         {
         aStatus = iDRMCommon->GetSingleRightsObject( aContentURI,
             aLocalID, aRights );
-        if ( aStatus )
-            {
-            aRights = NULL;
-            }
+        CheckIndividualConstraint( aContentURI, individualConstraint, usageAllowed );
+        SetSelectedIndividualConstraint( individualConstraint );
+        SetSelectedUsageAllowed( usageAllowed );
         }
     else
         {
-        aStatus = iDRMCommon->GetActiveRights( aContentURI, 0, aRights );
+        SetSelectedIndividualConstraint( EFalse );
+        SetSelectedUsageAllowed( ETrue );
+        
+        // Get active rights if available
+        err = iDRMCommon->GetActiveRights( aContentURI, 0, aRights );
+        
+        if ( err < 0 )
+            {
+            // Find out the best composition of rights that should be shown in the
+            // details view. Checks also individual constraint.
+            TRAP( aStatus, FindBestCompositionRightsL( aContentURI, aRights ) );
+            }
+        }
+    
+    if ( aStatus )
+        {
+        aRights = NULL;
         }
 
-    CheckIndividualConstraint( aContentURI, individualConstraint, usageAllowed );
-    SetSelectedIndividualConstraint( individualConstraint );
-    SetSelectedUsageAllowed( usageAllowed );
-
     CleanupStack::PopAndDestroy( dcfRep );
-
-    // Do not show the note, show license information in the details view.
     }
 
 // ---------------------------------------------------------
@@ -880,23 +958,18 @@
                                                     TBool& aIndividualConstraint,
                                                     TBool& aUsageAllowed )
     {
+    
+    TTime time;
+    RPointerArray<HBufC8> individuals;
+    
     RPointerArray<CDRMRights>* uriList = NULL;
     TInt r = KErrNone;
     TUint32 retval(0);
+    TInt timeZone(0);
     DRMClock::ESecurityLevel secLevel = DRMClock::KInsecure;
     CDRMRightsConstraints* constraint = NULL;
-    RDRMClockClient client;
-    RDRMRightsClient rclient;
-    TTime time;
-    RPointerArray<HBufC8> individuals;
-
-    r = client.Connect();
-    if ( r == KErrNone )
-        {
-        TTime time;
-        TInt timeZone(0);
-        client.GetSecureTime(time, timeZone, secLevel);
-        }
+    
+    iClockClient.GetSecureTime(time, timeZone, secLevel);
 
     r = iDRMCommon->GetDetailedContentRights(aContentURI, uriList);
     if ( r )
@@ -909,19 +982,13 @@
     if ( !uriList || !uriList->Count() )
         {
         // no rights found
-        client.Close();
         delete uriList;
         uriList = NULL;
         }
     else
         {
         // supported IMSI information is provided by rights client
-        r = rclient.Connect();
-        if( r == KErrNone)
-            {
-            TRAP( r, r = rclient.GetSupportedIndividualsL( individuals ) );
-            rclient.Close();
-            }
+        TRAP( r, r = iRightsClient.GetSupportedIndividualsL( individuals ) );
 
         // Check only the first entry in the list. This is to be expanded to check
         // all the entries in the list.
@@ -959,7 +1026,6 @@
             constraint = NULL;
             }
 
-        client.Close();
         uriList->ResetAndDestroy();
 
         delete uriList;
@@ -969,4 +1035,498 @@
         }
     }
 
+// ---------------------------------------------------------
+// CDRMRightsMgrAppUi::FindBestCompositionRightsL
+// ---------------------------------------------------------
+//
+void CDRMRightsMgrAppUi::FindBestCompositionRightsL( const TDesC8& aContentURI,
+                                                     CDRMRights*& aRights )
+    {
+    TInt i, j, k;
+    RPointerArray<CDRMPermission> permissionList;
+    RPointerArray<CDRMPermission> permissionTempList;
+    RPointerArray<HBufC8> parentUidList;
+    RPointerArray<HBufC8> individuals;
+    
+    TInt count( 0 );
+    TInt status( KErrNone );
+    TTime time( Time::NullTTime() );
+    TInt err( KErrNone );
+    TUint32 reason( EConstraintNone );
+    TBool individualConstraintFound( EFalse );
+    
+    // Composition object of best rights to be shown in the 
+    // details view
+    CDRMPermission* perm( NULL ); 
+    
+    TCleanupItem cleanupPerm( DoResetAndDestroyPermission, &permissionList );
+    CleanupStack::PushL( cleanupPerm );
+    
+    TCleanupItem cleanupPerm2( DoResetAndDestroyPermission, 
+            &permissionTempList );
+    CleanupStack::PushL( cleanupPerm2 );
+    
+    CleanupClosePushL( parentUidList );
+    
+    // First get list of child ROs with the given Content URI
+    iRightsClient.GetDBEntriesL( aContentURI, permissionList );            
+    
+    if ( permissionList.Count() > 0 )
+        {        
+        // Check the UIDs of the possible parent rights objects
+        // and store the found ones to another pointer array for evaluation
+        for ( i = 0; i < permissionList.Count(); i++ )
+            {
+            if ( permissionList[i]->iParentUID )
+                {
+                if ( i == 0 )
+                    {
+                    // No need to check if the parent UID is a duplicate
+                    parentUidList.Append( permissionList[i]->iParentUID );
+                    }
+                else 
+                    {
+                    // Check parent UID list whether we have already stored the
+                    // UID or not
+                    for( j = 0; j < parentUidList.Count(); j++ )
+                        {
+                        if ( parentUidList[j]->Des().Compare(
+                                permissionList[i]->iParentUID->Des() ) != 0 )
+                            {
+                            parentUidList.Append( 
+                                    permissionList[i]->iParentUID );
+                            break;
+                            }
+                        }
+                    }
+                }
+            }
+        
+        // Get the list of parent rights objects based on the parent UID 
+        // and store the pointers from temporary array to the main list 
+        for ( j = 0; j < parentUidList.Count(); j++ )
+            {
+            // We do not want to leave if nothing is found from the database
+            TRAP( status, iRightsClient.GetDBEntriesL( parentUidList[j]->Des(),
+                    permissionTempList ) );
+            
+            if ( status )
+                {
+                continue;
+                }
+                    
+            for ( k = 0; k < permissionTempList.Count(); k++ ) 
+                {
+                // Store the pointer to the main list of permissions
+                permissionList.Append( permissionTempList[k] );
+                }    
+                    
+            // Close the temporary pointer array so that the referenced 
+            // objects of it will not be deleted in the next round of the 
+            // loop because the method for getting database entries deletes 
+            // also the objects (by calling reset and destroy to the given 
+            // pointer array) by default.
+            permissionTempList.Close();
+            }
+        
+        parentUidList.Close();
+        time.HomeTime();
+        
+        // supported IMSI information is provided by rights client
+        TRAP( err, err = iRightsClient.GetSupportedIndividualsL( individuals ) );
+        
+        // Filter expired parent and child rights from the list
+        // Index defines the index of the list to be operated (next)
+        for ( count = permissionList.Count() ; count > 0; count-- )
+            {
+            if ( permissionList[count - 1]->Expired( time ) ) 
+                {
+                permissionList.Remove( count - 1 );
+                }
+            else if ( !( permissionList[count - 1]->Valid( 
+                    time, individuals, reason ) ) )
+                {
+                if ( reason & EConstraintIndividual )
+                    {
+                    individualConstraintFound = ETrue;
+                    permissionList.Remove( count - 1 );
+                    }
+                }
+            }        
+        
+        individuals.ResetAndDestroy();
+        individuals.Close();
+        
+        if ( permissionList.Count() == 0 )
+            {
+            if ( individualConstraintFound )
+                {
+                SetSelectedIndividualConstraint( ETrue );
+                SetSelectedUsageAllowed( EFalse );
+                }
+            User::Leave( KErrNotFound );
+            }
+        else if ( permissionList.Count() == 1  )
+            {
+            // Keep this permission because it is the only valid (left)
+            PrepareRightsObjectL( aRights, permissionList[0] );
+            }
+        else if ( permissionList.Count() > 1 )
+            {    
+            // Compare constraints from successive items of the 
+            // permission list and update the composition permission 
+            // accordingly. 
+            CheckBetterPermissionsAndStoreCompositionLC( perm, permissionList );
+                
+            // Prepare the rights object with the composition permission
+            PrepareRightsObjectL( aRights, perm );
+            CleanupStack::PopAndDestroy( perm );   
+            }     
+        }
+        
+        CleanupStack::PopAndDestroy( 3, &permissionList ); // cleanupPerm, 
+                                                           // cleanupPerm2, 
+                                                           // parentUidList
+    }
+
+// -------------------------------------------------------------------
+// CDRMRightsMgrAppUi::CheckBetterPermissionsAndStoreCompositionLC
+// -------------------------------------------------------------------
+//
+void CDRMRightsMgrAppUi::CheckBetterPermissionsAndStoreCompositionLC( 
+            CDRMPermission*& aCompositionPermission,
+            RPointerArray<CDRMPermission>& aList )
+    {       
+    
+    TBool firstBetter( EFalse );
+    TUint i, j;
+    
+    if ( aList.Count() <= 0 )
+        {
+        User::Leave( KErrArgument );
+        }
+    
+    // create permission if needed and set the first item
+    // in the permission list as the reference permission.
+    if ( !aCompositionPermission )
+        {
+        aCompositionPermission = CDRMPermission::NewL();
+        }
+         
+    CleanupStack::PushL( aCompositionPermission );
+    aCompositionPermission->DuplicateL( *aList[0] );
+    
+    // The double loop goes through the permissions and associated 
+    // constraints beginning from the second entry in the permission list. 
+    for ( i = 1; i < aList.Count(); i++ )
+        {
+        // Enumeration for TIntent from Content Access Framework used
+        for ( j = EPlay; j < EPause; j++ )
+            { 
+            switch ( j )
+                {
+                case EPlay:
+                    {
+                    // The constraint from the permission in the list
+                    // is set to composition permission if it is better
+                    // than the "old" best or reference permission.
+                    firstBetter = BetterPermission( *aList[i]->iPlay,
+                            *aCompositionPermission->iPlay );
+                    if ( firstBetter )
+                        {
+                        aCompositionPermission->iPlay->DuplicateL( 
+                                *aList[i]->iPlay );
+                        }
+                    break;
+                    }
+                case EView:
+                    {
+                    firstBetter = BetterPermission( *aList[i]->iDisplay, 
+                            *aCompositionPermission->iDisplay );
+                    if ( firstBetter )
+                        {
+                        aCompositionPermission->iDisplay->DuplicateL( 
+                                *aList[i]->iDisplay );
+                        }
+                    break;
+                    }
+                case EExecute:
+                    {
+                    firstBetter = BetterPermission( *aList[i]->iExecute,
+                            *aCompositionPermission->iExecute );
+                    if ( firstBetter )
+                        {
+                        aCompositionPermission->iExecute->DuplicateL(
+                                *aList[i]->iExecute );
+                        }
+                    break;
+                    }
+                case EPrint:
+                    {
+                    firstBetter = BetterPermission( *aList[i]->iPrint,
+                            *aCompositionPermission->iPrint );
+                    if ( firstBetter )
+                        {
+                        aCompositionPermission->iPrint->DuplicateL( 
+                                *aList[i]->iPrint );
+                        }
+                    break;
+                    }
+                default:
+                    {
+                    User::Leave( KErrArgument );
+                    }
+                }
+            }
+        }        
+    }                     
+
+// -----------------------------------------------------------------------------
+// CDrmRightsMgrAppUi::BetterPermission
+// -----------------------------------------------------------------------------
+TBool CDRMRightsMgrAppUi::BetterPermission( const CDRMConstraint& aNewOne,
+                                            const CDRMConstraint& aOldOne )
+        {
+        // Check Order:
+        // 1. Full
+        // 2. Start End, closest end time first
+        // 3. Interval, shortest first
+        // 4. Accumulated, shortest first
+        // 5. Timed Counter, least counters first, longest time first
+        // 6. Counter, least counters first or the first one found
+
+        const TTime nullTime = Time::NullTTime();
+        TTime oldTime = nullTime;
+        TTime newTime = nullTime;
+        TTime oldTimePos = nullTime;
+        TTime newTimePos = nullTime;
+        TTime trustedTime = nullTime;
+        
+        // 1. Full
+        // If the old or new one is the ultimate one, don't bother to
+        // check anything else.
+        if ( aOldOne.iActiveConstraints == EConstraintNone )
+            {
+            return EFalse;
+            }
+
+        if ( aNewOne.iActiveConstraints == EConstraintNone )
+            {
+            return ETrue;
+            }
+
+        // 2. Start & End Time
+        // Choose the one with the closest end time first
+        // All RO's to this check are already checked to be valid
+        // ActiveIntervals Also hit this spot
+        
+        trustedTime.HomeTime();
+            
+        // First get the start and end times from the intervals if they are active or inactive:
+        if ( aOldOne.iActiveConstraints & EConstraintInterval )
+            {
+            if( aOldOne.iIntervalStart == nullTime )
+                {
+                oldTimePos = trustedTime;
+                oldTimePos += TTimeIntervalSeconds( aOldOne.iInterval );
+                }
+            else
+                {
+                oldTime = aOldOne.iIntervalStart;
+                oldTime += TTimeIntervalSeconds( aOldOne.iInterval );
+                }
+            }
+
+        if( aNewOne.iActiveConstraints & EConstraintInterval )
+            {
+            if( aNewOne.iIntervalStart == nullTime )
+                {
+                newTimePos = trustedTime;
+                newTimePos += TTimeIntervalSeconds( aNewOne.iInterval );
+                }
+            else
+                {
+                newTime = aNewOne.iIntervalStart;
+                newTime += TTimeIntervalSeconds( aNewOne.iInterval );
+                }
+            }
+
+        if ( aOldOne.iActiveConstraints & EConstraintEndTime || oldTime != nullTime )
+            {
+            oldTime = EndTime( oldTime, aOldOne.iEndTime );
+
+            if ( aNewOne.iActiveConstraints & EConstraintEndTime || newTime != nullTime )
+                {
+                newTime = EndTime( newTime, aNewOne.iEndTime );
+
+                if( newTime != oldTime )
+                    {
+                    return ( newTime < oldTime );
+                    }
+                }
+            else
+                {
+                return EFalse;
+                }
+            }
+        else if ( aNewOne.iActiveConstraints & EConstraintEndTime || newTime != nullTime )
+            {
+            return ETrue;
+            }
+
+        // 3. Inactive Intervals:
+        // Choose the one with the interval ending first:
+        // Continue here if the no SE's exist or SE's are the same
+        if( aOldOne.iActiveConstraints & EConstraintInterval )
+            {
+            if( aNewOne.iActiveConstraints & EConstraintInterval )
+                {
+                oldTimePos = EndTime( oldTime, oldTimePos );
+                newTimePos = EndTime( newTime, newTimePos );
+
+                if( oldTimePos != newTimePos )
+                    {
+                    return ( newTimePos < oldTimePos );
+                    }
+                }
+            else
+                {
+                if( aNewOne.iActiveConstraints & EConstraintAccumulated ||
+                    aNewOne.iActiveConstraints & EConstraintTimedCounter ||
+                    aNewOne.iActiveConstraints & EConstraintCounter )
+                    {
+                    return EFalse;
+                    }
+                else
+                    {
+                    return ETrue;
+                    }
+                }
+            }
+        else if( aNewOne.iActiveConstraints & EConstraintInterval )
+            {
+            if( aOldOne.iActiveConstraints & EConstraintAccumulated ||
+                aOldOne.iActiveConstraints & EConstraintTimedCounter ||
+                aOldOne.iActiveConstraints & EConstraintCounter )
+                {
+                return ETrue;
+                }
+            else
+                {
+                return EFalse;
+                }
+            }
+
+        // 4. Accumulated:
+        // Choose the shortest accumulated first
+        // Continue here if SE's or intervals do not exist or they are the same
+        if( aOldOne.iActiveConstraints & EConstraintAccumulated )
+            {
+            if( aNewOne.iActiveConstraints & EConstraintAccumulated )
+                {
+                if( aNewOne.iAccumulatedTime != aOldOne.iAccumulatedTime )
+                    {
+                    return ( aNewOne.iAccumulatedTime < aOldOne.iAccumulatedTime );
+                    }
+                }
+            else
+                {
+                if( aNewOne.iActiveConstraints & EConstraintTimedCounter ||
+                    aNewOne.iActiveConstraints & EConstraintCounter )
+                    {
+                    return EFalse;
+                    }
+                else
+                    {
+                    return ETrue;
+                    }
+                }
+            }
+        else if( aNewOne.iActiveConstraints & EConstraintAccumulated )
+            {
+            if( aOldOne.iActiveConstraints & EConstraintTimedCounter ||
+                aOldOne.iActiveConstraints & EConstraintCounter )
+                {
+                return ETrue;
+                }
+            else
+                {
+                return EFalse;
+                }
+            }
+
+
+        // 5. Timed Counter
+        // Choose the one with least counters first. If there is an equal number of counters
+        // left, use the one with the longest time
+        // Continue here if SE's or intervals or accumulateds do not exist or they are the same
+        if( aOldOne.iActiveConstraints & EConstraintTimedCounter )
+            {
+            if( aNewOne.iActiveConstraints & EConstraintTimedCounter )
+                {
+                if( aNewOne.iTimedCounter == aOldOne.iTimedCounter )
+                    {
+                    if( aNewOne.iTimedInterval != aOldOne.iTimedInterval )
+                        {
+                        return ( aNewOne.iTimedInterval < aOldOne.iTimedInterval );
+                        }
+                    else
+                        {
+                        if( aNewOne.iActiveConstraints & EConstraintCounter )
+                            {
+
+                            }
+                        }
+                    }
+                else
+                    {
+                    return ( aNewOne.iTimedCounter < aOldOne.iTimedCounter );
+                    }
+
+                }
+            else
+                {
+                if( aNewOne.iActiveConstraints & EConstraintCounter )
+                    {
+                    return EFalse;
+                    }
+                else
+                    {
+                    return ETrue;
+                    }
+                }
+            }
+        else if( aNewOne.iActiveConstraints & EConstraintTimedCounter )
+            {
+            if( aOldOne.iActiveConstraints & EConstraintCounter )
+                {
+                return ETrue;
+                }
+            else
+                {
+                return EFalse;
+                }
+            }
+
+        // 6. Counter
+        // Choose the one with least counters:
+        // if they are the same choose the first one.
+        // Continue here if SE's or intervals or accumulateds or timed counters
+        // do not exist or they are the same
+        if( aOldOne.iActiveConstraints & EConstraintCounter )
+            {
+            if( aNewOne.iActiveConstraints & EConstraintCounter )
+                {
+                return ( aNewOne.iCounter < aOldOne.iCounter );
+                }
+            else
+                {
+                return ETrue;
+                }
+            }
+
+        // If all else fails use the old one:
+        return EFalse;
+        }
+
 // End of File
--- a/commondrm/drmrightsmanagerui/src/DRMRightsMgrDetailsContainer.cpp	Wed Apr 14 16:15:06 2010 +0300
+++ b/commondrm/drmrightsmanagerui/src/DRMRightsMgrDetailsContainer.cpp	Tue Apr 27 16:56:11 2010 +0300
@@ -841,9 +841,7 @@
                                     TInt aIntYrs, TInt aIntMon, TInt aIntDay,
                                     TInt aIntHrs, TInt aIntMin, TInt aIntSec )
     {
-    // Only the first meaningful data will be shown
-    TInt numOfData = 0;
-
+    
     CDesCArrayFlat* strings = new ( ELeave ) CDesCArrayFlat( 1 );
     CleanupStack::PushL( strings );
 
--- a/commondrm/drmutility/src/DrmUiHandlingImpl.cpp	Wed Apr 14 16:15:06 2010 +0300
+++ b/commondrm/drmutility/src/DrmUiHandlingImpl.cpp	Tue Apr 27 16:56:11 2010 +0300
@@ -3828,21 +3828,8 @@
             KDRMUtilityDebugPanicCode ) );
     _LIT( KMarker, "\x00" );
 
-    RPointerArray<CDRMPermission> uriList;
     TPtr ptr( NULL, 0 );
-
     TInt localId( 0 );
-    TInt err( KErrNone );
-
-        TRAP( err, iOmaClient.GetDBEntriesL( *aUrl, uriList ) );
-
-    if ( uriList.Count() == 1 )
-        {
-        localId = ( uriList[0] )->iUniqueID;
-        }
-
-    uriList.ResetAndDestroy();
-    uriList.Close();
 
     // MaxInt will fit into 10 characters
     HBufC* localIDBuf( HBufC::NewLC( KIntegerMaxLen ) );
--- a/omadrm/drmengine/group/CryptoPrep.flm	Wed Apr 14 16:15:06 2010 +0300
+++ b/omadrm/drmengine/group/CryptoPrep.flm	Tue Apr 27 16:56:11 2010 +0300
@@ -1,4 +1,4 @@
-# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
 # All rights reserved.
 # This component and the accompanying materials are made available
 # under the terms of the License "Eclipse Public License v1.0"
@@ -21,6 +21,11 @@
 
 crypto_files:=$(wildcard $(EXTENSION_ROOT)/../drmengine/drmcrypto/CMLA/*.cpp)
 
+
+GUARD:=done_$(call sanitise,$(CLEANTARGETS))
+ifeq ($($(GUARD)),)
+$(GUARD):=1
+
 BITMAP :: $(CREATABLEPATH)
 
 ifeq ($(crypto_files),)
@@ -29,6 +34,8 @@
 	$(GNUCP) $(CREATABLEPATH)/../CMLA/CmlaCrypto.cpp $(CREATABLEPATH)/cmlacrypto.cpp
 endif
 	$(GNUCP) $(CREATABLEPATH)/../src/OmaCrypto.cpp $(CREATABLEPATH)/omacrypto.cpp
+	$(GNUCHMOD) u+w $(CREATABLEPATH)/cmlacrypto.cpp
+	$(GNUCHMOD) u+w $(CREATABLEPATH)/omacrypto.cpp
 
 # Create dirs
 $(call makepath,$(CREATABLEPATH))
@@ -36,3 +43,11 @@
 ## Clean up
 $(eval $(call GenerateStandardCleanTarget,$(CLEANTARGETS)))
 
+## What
+$(eval $(call whatmacro,$(CLEANTARGETS)))
+
+
+else
+$(info <debug>$(PLATFORM) $(CFG), up-to-date $(CLEANTARGETS)</debug>)
+
+endif
--- a/omadrm/drmengine/keystorage/src/DrmStdKeyStorage.cpp	Wed Apr 14 16:15:06 2010 +0300
+++ b/omadrm/drmengine/keystorage/src/DrmStdKeyStorage.cpp	Tue Apr 27 16:56:11 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -211,7 +211,7 @@
     iFileMan = CFileMan::NewL(iFs);
 
 #ifdef __DRM_OMA2
-    SelectDefaultRootL();
+    TRAP_IGNORE( SelectDefaultRootL() ); // Allow startup anyway.
 #endif
 
     iDeviceSpecificKey.Copy(KDefaultKey);
--- a/omadrm/drmengine/server/inc/DRMActiveDeletion.h	Wed Apr 14 16:15:06 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,140 +0,0 @@
-/*
-* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Active object handling "Delete Expired Permission"
-*
-*/
-
-
-#ifndef DRMACTIVEDELETION_H
-#define DRMACTIVEDELETION_H
-
-// INCLUDES
-
-#include <e32base.h>
-
-// CONSTANTS
-
-// MACROS
-
-// DATA TYPES
-
-// FORWARD DECLARATIONS
-class CDRMRightsDB;
-class CDRMDbSession;                                                         
-
-// FUNCTION PROTOTYPES
-
-// CLASS DECLARATION
-
-/**
-*  CDRMActiveDeletion implements expired rights cleanup callback
-*  for drm rights database
-*
-*  @lib RightsServer.exe
-*  @since 3.0
-*/
-NONSHARABLE_CLASS( CDRMActiveDeletion ) : public CActive
-    {
-    public: // Constructors and destructor
-        
-        /**
-        * NewL
-        *
-        * Creates an instance of the CDRMRightCleaner class and returns a pointer
-        * to it
-        *
-        * @since    3.0
-        * @param    aFs : Open file server session
-        * @param    aDatabase : CDRMRightsDB object
-        * @param    aStatus : The request status to complete when the operation is 
-        *                     fully done
-        * @param    aDatabasePath : full pathname of the database path
-        * @param    aTime : Time to check expiration against 
-        *
-        * @return   Functional CDRMActiveDeletion object, Function leaves if an error
-        *           occurs.
-        */
-        static CDRMActiveDeletion* NewLC( const RMessagePtr2& aMessage,
-                                          CDRMDbSession& aSession );
-          
-        /**
-        * Destructor
-        */
-        virtual ~CDRMActiveDeletion();
-
-    public: // New functions    
-
-        /**
-        * ActivateL
-        * 
-        * Activates the object by adding it to scheduler etc.
-        *
-        * @since    3.0
-        * @return   None
-        *
-        */      
-        void ActivateL( const TTime& aSecureTime,
-                        CDRMRightsDB& aDb );
-         
-    protected:
-    
-        /**
-        * Default Constructor - First phase.
-        */
-        CDRMActiveDeletion( const RMessagePtr2& aMessage,
-                            CDRMDbSession& aSession ); 
-        
-        /**
-        * From CActive: RunL.
-        */
-        void RunL();
-
-        /**
-        * From CActive: DoCancel performs cancel
-        */        
-        void DoCancel();
-      
-        /**
-        * From CActive: RunError checks the errors from RunL.
-        */
-        // void RunError();                        
-                        
-    private:
-        /**
-        * Default Constructor - First phase. Prevented.
-        */
-        CDRMActiveDeletion(); 
-    
-        /**
-        * Assignment operator - Prevented
-        */
-        CDRMActiveDeletion& operator =( const CDRMActiveDeletion& );    
-    
-        /**
-        * Copy constructor - Prevented
-        */
-        CDRMActiveDeletion( const CDRMActiveDeletion& );                
-     
-    private:
-        // The message.
-        const RMessagePtr2& iMessage;
-        CDRMDbSession& iSession;
-    
-        // The instane doing the deletion.
-        CActive* iActiveOperation;
-    };
-
-#endif      // DRMACTIVEDELETION_H   
-            
-// End of File
--- a/omadrm/drmengine/server/src/DRMActiveDeletion.cpp	Wed Apr 14 16:15:06 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,148 +0,0 @@
-/*
-* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Implementation of the parent storage for Decision Making Machine
-*
-*/
-
-
-// INCLUDE FILES
-#include "drmactivedeletion.h"
-#include "drmrightsdb.h"
-#include "drmrightscleaner.h"
-#include "drmdbsession.h"
-
-// EXTERNAL DATA STRUCTURES
-
-// EXTERNAL FUNCTION PROTOTYPES  
-
-// CONSTANTS
-
-// MACROS
-
-// LOCAL CONSTANTS AND MACROS
-
-// MODULE DATA STRUCTURES
-
-// LOCAL FUNCTION PROTOTYPES
-
-// FORWARD DECLARATIONS
-
-
-// ============================= LOCAL FUNCTIONS ===============================
-
-    
-// ============================ MEMBER FUNCTIONS ===============================
-
-// -----------------------------------------------------------------------------
-// CDRMActiveDeletion::NewLC
-//
-// Two-phase constructor.
-// -----------------------------------------------------------------------------
-//
-CDRMActiveDeletion* CDRMActiveDeletion::NewLC( const RMessagePtr2& aMessage,
-                                               CDRMDbSession& aSession )
-    {
-    CDRMActiveDeletion* self = new( ELeave ) CDRMActiveDeletion( aMessage,
-                                                                 aSession );
-    CleanupStack::PushL( self );
-    
-    return self;
-    }
-
-// -----------------------------------------------------------------------------
-// CDRMActiveDeletion::~CDRMActiveDeletion
-//
-// Destructor.
-// -----------------------------------------------------------------------------
-//
-CDRMActiveDeletion::~CDRMActiveDeletion()
-    {
-    if ( iActiveOperation )
-        {
-        // Construction was successful, but 
-        // something has went wrong.
-
-        iActiveOperation->Cancel(); 
-        iMessage.Complete( KErrCancel );
-        }
-    }
-    
-// -----------------------------------------------------------------------------
-// CDRMActiveDeletion::ActivateL
-//
-// Activate the thing by issuing a request to the DB and executing it also.
-// -----------------------------------------------------------------------------
-//
-void CDRMActiveDeletion::ActivateL( const TTime& aTime,
-                                    CDRMRightsDB& aDb )
-    {
-    CActiveScheduler::Add( this );
-    
-    CDRMRightsCleaner* cleaner = 
-        aDb.DeleteExpiredPermissionsL( aTime, iStatus );
-    CleanupStack::PushL( cleaner );
-    cleaner->ExecuteCleanupLD();
-    CleanupStack::Pop();
-    
-    SetActive();
-    iActiveOperation = cleaner;    
-    }
-
-// -----------------------------------------------------------------------------
-// CDRMActiveDeletion::RunL
-//
-// Handles the completition of the request.
-// -----------------------------------------------------------------------------
-//
-void CDRMActiveDeletion::RunL()
-    {
-    // All done.
-    iMessage.Complete( iStatus.Int() );
-    
-    // iActiveOperation deletes itself.
-    iActiveOperation = NULL;
-    
-    Deque();
-    
-    iSession.AsyncOperationDone();
-    }
-    
-// -----------------------------------------------------------------------------
-// CDRMActiveDeletion::DoCancel
-//
-// Cancels the operation.
-// -----------------------------------------------------------------------------
-//
-void CDRMActiveDeletion::DoCancel()
-    {
-    iActiveOperation->Cancel();
-    iActiveOperation = NULL;
-    }
-
-// -----------------------------------------------------------------------------
-// CDRMActiveDeletion::CDRMActiveDeletion
-//
-// Constructor.
-// -----------------------------------------------------------------------------
-//
-CDRMActiveDeletion::CDRMActiveDeletion( const RMessagePtr2& aMessage,
-                                        CDRMDbSession& aSession ):
-CActive( EPriorityLow ),
-iMessage( aMessage ),
-iSession( aSession )
-    {
-    // Nothing
-    }
-    
-// End of file
--- a/omadrm/drmengine/server/src/DRMRightsClientStub.cpp	Wed Apr 14 16:15:06 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,253 +0,0 @@
-/*
-* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Client side class implementation
-*
-*/
-
-
-// INCLUDE FILES
-#include <s32file.h>
-#include "DRMRightsClient.h"
-#include "DRMClientServer.h"
-#ifdef _DRM_TESTING
-#include "logfile.h"
-#endif
-
-// EXTERNAL DATA STRUCTURES
-// EXTERNAL FUNCTION PROTOTYPES  
-#ifdef CLIENT_STARTS_SERVER
-extern TInt DRMServerStarter();
-#endif
-
-// ============================ MEMBER FUNCTIONS ===============================
-
-// -----------------------------------------------------------------------------
-// RDRMRightsClient::RDRMRightsClient
-// C++ default constructor can NOT contain any code, that
-// might leave.
-// -----------------------------------------------------------------------------
-//
-EXPORT_C RDRMRightsClient::RDRMRightsClient() :
-    iPtr( NULL )
-    {
-    }
-    
-// -----------------------------------------------------------------------------
-// RDRMRightsClient::~RDRMRightsClient
-// Destructor.
-// -----------------------------------------------------------------------------
-//
-EXPORT_C RDRMRightsClient::~RDRMRightsClient()
-    {
-    }    
-
-// -----------------------------------------------------------------------------
-// RDRMRightsClient::Connect
-// Opens connection to the server.
-// -----------------------------------------------------------------------------
-//
-EXPORT_C TInt RDRMRightsClient::Connect()
-    {
-    return KErrNone;
-    }
-
-// -----------------------------------------------------------------------------
-// RDRMRightsClient::Close
-// Closes the connection to the server.
-// -----------------------------------------------------------------------------
-//
-EXPORT_C void RDRMRightsClient::Close() 
-    {
-    }
-
-// -----------------------------------------------------------------------------
-// RDRMRightsClient::AddRecord
-// Add a new entry to the rights database.
-// -----------------------------------------------------------------------------
-//
-EXPORT_C TInt RDRMRightsClient::AddRecord( const TDesC8& aCEK, // Content encryption key
-                                  // The rights object which is to be added
-                                  const CDRMPermission& aRightsObject, 
-                                  const TDesC8& aCID, // Content-ID 
-                                  TDRMUniqueID& aID ) // Unique ID, out-parameter
-    {
-    return KErrNone;
-    }
-
-
-// -----------------------------------------------------------------------------
-// RDRMRightsClient::GetDBEntriesL
-// Get a file name from the server. The file contains the rights objects,
-// which are then converted to RPointerArray.
-// -----------------------------------------------------------------------------
-//
-EXPORT_C void RDRMRightsClient::GetDBEntriesL( const TDesC8& aId,
-                                      RPointerArray< CDRMPermission >& aRightsList )
-    {
-    }
-
-// -----------------------------------------------------------------------------
-// RDRMRightsClient::GetDbEntryL
-// Get a single RO from the server.
-// -----------------------------------------------------------------------------
-//
-EXPORT_C CDRMPermission* RDRMRightsClient::GetDbEntryL( const TDesC8& aContentID,
-                                                 const TDRMUniqueID& aUniqueID )
-    {
-    CDRMPermission* object = new (ELeave) CDRMPermission;
-    object->iUniqueID = aUniqueID;
-    return object;
-    }
-
-// -----------------------------------------------------------------------------
-// RDRMRightsClient::DeleteDbEntry
-// Deletes all rights objects associated with the given UID.
-// -----------------------------------------------------------------------------
-//
-EXPORT_C TInt RDRMRightsClient::DeleteDbEntry( const TDesC8& aContentID )
-    {
-    return KErrNone;
-    }
-
-// -----------------------------------------------------------------------------
-// RDRMRightsClient::DeleteDbEntry
-// Delete a single rights object identified by given parameters.
-// -----------------------------------------------------------------------------
-//
-EXPORT_C TInt RDRMRightsClient::DeleteDbEntry( const TDesC8& aContentID,
-                                      const TDRMUniqueID& aUniqueID )
-    {
-    return KErrNone;
-    }
-
-// -----------------------------------------------------------------------------
-// RDRMRightsClient::ExportContentIDList
-// Overloaded method: requests all content IDs to be put to a file. 
-// Assumes that the given descriptor represents a buffer large enough to
-// contain the file name.
-// -----------------------------------------------------------------------------
-//
-EXPORT_C TInt RDRMRightsClient::ExportContentIDList( TDes& aFileName )
-    {
-    return KErrNone;
-    }
-
-// -----------------------------------------------------------------------------
-// RDRMRightsClient::ExportContentIDList
-// Overloaded method: requests all content IDs to be put to a file, 
-// and then converts the file into RPointerArray.
-// -----------------------------------------------------------------------------
-//
-EXPORT_C TInt RDRMRightsClient::ExportContentIDList( RPointerArray< HBufC8 >& aCIDList )
-    {
-    return KErrNone;
-    }
-
-
-// -----------------------------------------------------------------------------
-// RDRMRightsClient::GetDecryptionKey
-// Fetches the decryption key from the server.
-// Uses TR mechanisms. Uses asynchronous C/S call.
-// -----------------------------------------------------------------------------
-//
-EXPORT_C TInt RDRMRightsClient::GetDecryptionKey( const TInt aIntent,
-                                        const TDesC8& aContentID,
-                                        const TBool aUpdate,
-                                        TDes8& aKey )
-    {
-    aKey.Copy(_L("0000000000000000"));
-    return KErrNone;
-    }
-
-// -----------------------------------------------------------------------------
-// RDRMRightsClient::CheckRights
-// Checks if appropriate rights exist for a certain content ID.
-// -----------------------------------------------------------------------------
-//
-EXPORT_C TInt RDRMRightsClient::CheckRights( const TInt aIntent,
-                                    const TDesC8& aContentID )
-    {
-    return KErrNone;
-    }
-
-// -----------------------------------------------------------------------------
-// RDRMRightsClient::Count
-// Returns the amount of unique content IDs in the database.
-// If an error occurs, a negative value is returned (Symbian OS / DRM 3 specific
-// error code).
-// -----------------------------------------------------------------------------
-//
-EXPORT_C TInt RDRMRightsClient::Count()
-    {
-    return 1;
-    }
-
-// -----------------------------------------------------------------------------
-// RDRMRightsClient::DeleteAll
-// Empties the database.
-// -----------------------------------------------------------------------------
-//
-EXPORT_C TInt RDRMRightsClient::DeleteAll()
-	{
-	return KErrNone;
-	}
-
-
-// -----------------------------------------------------------------------------
-// RDRMRightsClient::Consume()
-// Consume the right with specific intent and contentID
-// -----------------------------------------------------------------------------
-//
-EXPORT_C TInt RDRMRightsClient::Consume( const TInt aIntent, const TDesC8& aContentID, const TInt aActionIntent )
-	{
-	return KErrNone;
-	}
-
-// -----------------------------------------------------------------------------
-// RDRMRightsClient::CalculatePadding
-// Calculate the padding from a data block and a certain content ID.
-// -----------------------------------------------------------------------------
-//
-EXPORT_C TInt RDRMRightsClient::CalculatePadding(
-    const TDesC8& aContentID,
-    const TDesC8& aLastTwoDataBlocks)
-    {
-    return 0;
-    }
-
-// -----------------------------------------------------------------------------
-// RDRMRightsClient::FileToListL
-// Converts the given file into an array.
-// -----------------------------------------------------------------------------
-//
-void RDRMRightsClient::FileToListL( RFs& aFs,
-                                   const TDesC& aFileName,
-                                   RPointerArray< CDRMPermission >& aList )
-    {
-    }
-
-// -----------------------------------------------------------------------------
-// RDRMRightsClient::URIFileToArrayL
-// Converts the given file into an array.
-// -----------------------------------------------------------------------------
-//
-void RDRMRightsClient::URIFileToArrayL( RFs& aFs,
-                                       const TDesC& aFile,
-                                       RPointerArray< HBufC8 >& aList )
-    {
-    }
-
-// ========================== OTHER EXPORTED FUNCTIONS =========================
-
-//  End of File  
--- a/omadrm/drmengine/server/src/DRMServerStarter.cpp	Wed Apr 14 16:15:06 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,167 +0,0 @@
-/*
-* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  This file is used only if RDRMRightsClient starts the
-*                DRM Rights Database server. 
-*
-*/
-
-// INCLUDE FILES
-#include   <e32std.h>
-#include    <e32uid.h>
-#include <f32file.h>
-
-#ifdef RD_MULTIPLE_DRIVE
-#include <DriveInfo.h>
-#endif
-
-#include "drmengineclientserver.h"
-
-// EXTERNAL DATA STRUCTURES
-// EXTERNAL FUNCTION PROTOTYPES  
-// CONSTANTS
-#ifdef __WINS__
-LOCAL_C const TUint KServerMinHeapSize =  0x1000;  
-LOCAL_C const TUint KServerMaxHeapSize = 0x300000; 
-_LIT( KRightsServerFile, "RightsServer" );
-#else
-
-#ifdef RD_MULTIPLE_DRIVE
-_LIT( KRightsServerFile, "%c:\\RightsServer.exe" );
-#else
-_LIT( KRightsServerFile, "e:\\RightsServer.exe" );
-#endif
-#endif
-
-// MACROS
-// LOCAL CONSTANTS AND MACROS
-// MODULE DATA STRUCTURES
-// LOCAL FUNCTION PROTOTYPES
-LOCAL_C TInt CreateServer( void );
-
-// FORWARD DECLARATIONS
-
-// ============================= LOCAL FUNCTIONS ===============================
-
-// -----------------------------------------------------------------------------
-// CreateServer launches the DRM Rights server [process (THUMB/ARMI)|thread (WINS)]. 
-// Returns: KErrNone: No errors.
-//          <KErrNone: Symbian wide error code.
-// -----------------------------------------------------------------------------
-//
-LOCAL_C TInt CreateServer( void )
-    {
-    TInt error = KErrNone;
-    
-        RProcess server;
-        
-#ifndef RD_MULTIPLE_DRIVE
-    
-        error = server.Create( KRightsServerFile, 
-                               KNullDesC );
-    
-#else //RD_MULTIPLE_DRIVE
-        
-        RFs fs;
-        TInt driveNumber( -1 );
-        TChar driveLetter;
-        DriveInfo::GetDefaultDrive( DriveInfo::EDefaultMassStorage, driveNumber );
-        
-        error = fs.Connect();
-        if( error != KErrNone )
-            {
-            fs.Close();
-            return error;
-            }
-        
-        fs.DriveToChar( driveNumber, driveLetter );
-        fs.Close();
-	
-        TFileName rightsServerFile;
-        rightsServerFile.Format( KRightsServerFile, (TUint)driveLetter );
-    
-        error = server.Create( rightsServerFile, 
-                               KNullDesC );
-    
-#endif
-        
-        if ( !error )
-            {
-            // Give some time to the process to start.
-            User::After( 1000 );
-            
-        // Kick the server up & running.
-        server.Resume();
-            
-        // Local handle not needed anymore.
-        server.Close();
-        }
-        
-    return error;
-    }
-    
-// ============================ MEMBER FUNCTIONS ===============================
-    
-// ========================== OTHER EXPORTED FUNCTIONS =========================
-    
-// -----------------------------------------------------------------------------
-// DRMServerStarter starts the actual server.
-// Returns: KErrNone: All went OK, no errors.
-//          <KErrNone: Symbian wide error code.
-// -----------------------------------------------------------------------------
-//
-EXPORT_C TInt DRMServerStarter()
-    {
-    RSemaphore semaphore;
-    TFindServer server( DRMEngine::KServerName );
-    TFullName name;
-    
-    // Check if the server is already running.
-    TInt error = server.Next( name );
-    
-    if ( !error )
-        {
-        // Yep, it's already running.
-        return KErrNone;
-        }
-
-    error = semaphore.CreateGlobal( DRMEngine::KDRMSemaphore,   // name
-                                    0 ,              // count
-                                    EOwnerThread ); // owner
-    
-    if ( error == KErrAlreadyExists )
-        {
-        error = semaphore.OpenGlobal( DRMEngine::KDRMSemaphore );
-        }
-        
-    if ( !error )
-        {
-        error = CreateServer();
-        if ( !error )
-            {
-            // Wait until server has done all its things.
-            semaphore.Wait();
-            
-            // Signal the (possible) next one waiting in line. Server
-            // only signals the semaphore once but there might be several
-            // clients waiting for this semaphore, in theory.
-            semaphore.Signal();
-            }
-        
-        // Semaphore can be destroyed.
-        semaphore.Close();
-        }
-        
-    return error; 
-    }
-//  End of File
--- a/omadrm/drmengine/server/src/drmcrypto.c	Wed Apr 14 16:15:06 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,687 +0,0 @@
-/*
-* Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  DRM Crypto functionality
-*
-*/
-
-
-
-/*
-
-            DRMCrypto
-            --------------------------
-
-            SW module - ANSI C
-
-Location:           -
-
-Filename:           drmcrypto.c
-
-Document code:      -
-
-/* ------------------------------------------------------------------------- */
-
-/*  1    ABSTRACT
-    1.1    Module type
-    1.2    Functional description
-    1.3    Notes
-
-    2    CONTENTS
-
-    3    GLOSSARY
-
-    4    REFERENCES
-
-    5    EXTERNAL RESOURCES
-    5.1    Mandatory include files
-    5.2    Library include files
-    5.3    Interface include files
-
-    6    LOCAL DEFINITIONS
-    6.1    Local include files
-    6.2    Local constants
-    6.3    Local macros
-    6.3.1    dummy_message_type
-    6.3.2    generate_connection_address
-    6.4    Local data types
-    6.5    Local data structures
-    6.6    Local function prototypes
-
-    7    MODULE CODE
-    7.1     DRMCrypto_Encrypt
-	7.2	    DRMCrypto_Decrypt
-	7.3		DRMCrypto_EncryptRightsDb
-	7.4		DRMCrypto_DecryptRightsVDb
-	7.5		DRMCrypto_AddPadding
-	7.6		DRMCrypto_RemovePadding
-	7.7		DRMCrypto_GenerateKey
-	7.8		DRMCrypto_GenerateIV
-
-
-
-
-
-*/
-
-
-/*  3    GLOSSARY
-		 -
-*/
-
-/*  4    REFERENCES
-
-    Specification reference
-
-    DRM Engine Crypto Interface Specification
-
-
-    Design reference
-
-    -
-
-    Module test specification reference
-
-    -
-*/
-#ifndef C_DRMCRYPTO_CFILE
-#define C_DRMCRYPTO_CFILE
-
-/*  5    EXTERNAL RESOURCES */
-
-/*  5.1    Mandatory include files */
-
-/*  5.2    Library include files */
-
-/*  5.3    Interface include files */
-#include "drmcrypto.h"
-#include "drmenv.h" /* for DRMEnv_GetRandom */
-
-/*  6    LOCAL DEFINITIONS */
-
-/*  6.1    Local include files */
-
-#include "aes_if.h"
-
-/*  6.2    Local constants */
-#define	KEYSEED_NUMBER_OF_INT32		4
-#define KEYSEED_LENGTH				16
-/*  6.3    Local macros */
-
-/*  6.4    Local data types */
-
-/*  6.5    Local data structures */
-
-/*  6.6    Local function prototypes */
-
-/*  7    MODULE CODE */
-
-
-/* ========================================================================= */
-
-/*  7.1 */
-
-/* Functional description
- *
- * Encrypt data using specified algorithm
- *
- *
- * Parameters
- *
- * Cipher type
- *
- cType
- *
- * Pointer to encryption key
- *
- pszKey
- *
- * Encryption key length in bytes
- *
- iKeyLen
- *
- * Pointer to initializer vector of encryption
- *
- pszIV
- *
- * Pointer to data to be encrypted
- *
- pszIn
- *
- * Pointer to encrypted data.
- * It can be same pointer as pszOut.
- *
- pszOut
- *
- * Length in bytes of content to be encrypted.
- *
- iInLen
- *
- * Cipher type(AES encryption modes).
- *		AES_MODE_CBC ... AES_MODE_ECB
- *
- uiParameters
- *
- * Return values
- *
- * If encryption is OK, return DRM_ENG_OK, 
- * otherwize DRM_ENG_ERROR.
- */
-
-/* ---------------------------------------------------------------------- */
-
-#ifdef	ENCRYPT_USED
-uint8 DRMCrypto_Encrypt( 
-		  CipherType				cType, 
-		  uint8*					pszKey, 
-		  uint16					iKeyLen,
-		  uint8*					pszIV,
-		  uint8*					pszIn,
-		  uint8*					pszOut,
-		  uint32					iInLen, 
-		  CipherParamType			uiParameters	)
-	{
-	/* Data structures */
-
-	/* return code
-	 */
-	uint8 ret = 0;
-
-	/* AES encryption mode
-	 */
-	uint8 iMode = 0;
-
-	/*  Code  */
-
-	/* check parameter */
-	if( !pszKey || !pszIV || !pszIn || !pszOut )
-		{
-		return DRM_ENG_INVALID_PARAM;
-		}
-
-	/* Convert uiParameters to inner interface type
-	 */
-	if( uiParameters ==  AES_MODE_CBC)
-		{
-		iMode = AES_CBC;
-		}
-	else if( uiParameters ==  AES_MODE_ECB)
-		{
-		iMode = AES_ECB;
-		}
-	else 
-		{
-		DEBUG("Crypto Error: invalid uiParameters!")
-		return DRM_ENG_ERROR;
-		}
-
-	if( cType == CIPHER_AES )
-		{
-		ret = AESEncrypt( (uint32*)pszKey, (uint16)(iKeyLen*8), (uint32*)pszIV, 
-						  (uint32*)pszIn, (uint32*)pszOut, iInLen, iMode );
-		if( ret==AES_CRYPTO_OK ) 
-			{
-			return DRM_ENG_OK;
-			}
-		else if( ret == AES_CRYPTO_ERR_MEMORY )
-			{
-			return DRM_ENG_MEM_ERROR;
-			}
-		else 
-			{
-			DEBUGD("Crypto Error: AES Encryption Error ", ret)
-			return DRM_ENG_ERROR;
-			}
-		}
-	else
-		{
-		return DRM_ENG_ERROR;
-		}
-	}
-#endif /* #ifdef	ENCRYPT_USED */
-
-
-/*  7.2 */
-
-/* Functional description
- *
- * Decrypt data using specified algorithm.
- *
- *
- * Parameters
- *
- * Cipher type
- *
- cType
- *
- * Pointer to encryption key
- *
- pszKey
- *
- * Encryption key length in bytes
- *
- iKeyLen
- *
- * Pointer to initializer vector of encryption
- *
- pszIV
- *
- * Pointer to encrypted data which is to be decrypted
- *
- pszIn
- *
- * Pointer to decrypted content.
- * It can be same pointer as pszOut.
- *
- pszOut
- *
- * Length in bytes of content to be decrypted.
- *
- iInLen
- *
- * Cipher type(AES encryption modes).
- *		AES_MODE_CBC ... AES_MODE_ECB
- *
- uiParameters
- *
- * Return values
- *
- * If decryption is OK, return DRM_ENG_OK, 
- * otherwize DRM_ENG_ERROR.
- */
-
-/* ---------------------------------------------------------------------- */
-
-
-uint8 DRMCrypto_Decrypt( 
-		  CipherType				cType,
-		  uint8*					pszKey, 
-          uint16					iKeyLen,
-		  uint8*					pszIV,
-		  uint8*					pszIn,
-		  uint8*					pszOut,
-		  uint32					iInLen,
-		  CipherParamType			uiParameters	)
-	{
-	/* Data structures */
-
-	/* return code
-	 */
-	uint8 ret = 0;
-
-	/* AES encryption mode
-	 */
-	uint8 iMode = 0;
-
-	/* Aligned buffer for Key
-	 */
-	/* uint32*			pKeyAligned=NULL; */
-
-	/* Aligned buffer for IV
-	 */
-	/* uint32*			pIVAligned=NULL; */
-
-	/* Aligned buffer for Input data
-	 */
-	/* uint32*			pInAligned=NULL; */
-
-	/* Byte stream pointer
-	 */
-	/* uint8* pBytes = NULL; */
-
-	/*  Code  */
-
-	/* check parameter */
-	if( !pszKey || !pszIV || !pszIn || !pszOut )
-		{
-		return DRM_ENG_INVALID_PARAM;
-		}
-
-	/* Convert uiParameters to inner interface type
-	 */
-	if( uiParameters ==  AES_MODE_CBC)
-		{
-		iMode = AES_CBC;
-		}
-	else if( uiParameters ==  AES_MODE_ECB)
-		{
-		iMode = AES_ECB;
-		}
-	else 
-		{
-		DEBUG("Crypto Error: invalid uiParameters !")
-		return DRM_ENG_ERROR;
-		}
-
-	if( cType == CIPHER_AES )
-		{
-			
-			ret = AESDecrypt( (uint32*)pszKey, (uint16)(iKeyLen*8), (uint32*)pszIV, 
-							  (uint32*)pszIn,  (uint32*)pszOut, iInLen, iMode );
-
-		if( ret==AES_CRYPTO_OK ) 
-			{
-			ret = DRM_ENG_OK;
-			}
-		else if( ret == AES_CRYPTO_ERR_MEMORY )
-			{
-			ret = DRM_ENG_MEM_ERROR;
-			}
-		else 
-			{
-			DEBUGD("Crypto Error: AES Decryption Error ", ret)
-			ret = DRM_ENG_ERROR;
-			}
-		}
-	else
-		{
-		ret = DRM_ENG_ERROR;
-		}
-
-	return ret;
-	}
-
-
-/*  7.5 */
-
-/* Functional description
- *
- * Adds padding bytes at the end of data.
- *
- *
- * Parameters
- *
- * Pointer to pointer to data.
- * IN: points to data before adding padding bytes.
- * OUT: points to data with added padding bytes.
- * Memory used by input data will be freed inside this function.
- * New memory will be allocated for output data.
- *
- ppData
- *
- * Pointer to data length in bytes
- * IN:  pointer to length of data with padding.
- * OUT: points to length of data without padding.
- *
- pDataLen
- *
- * Cipher block size. 
- * Max 256
- *
- CipBlockSize
- *
- * Specifies used padding method.
- *      PADDING_PKCS7
- *
- uiPaddingMethod
- *
- * Return values
- *
- * If operation is OK, return DRM_ENG_OK, 
- * otherwize DRM_ENG_ERROR.
- */
-
-/* ---------------------------------------------------------------------- */
-
-
-uint8 DRMCrypto_AddPadding(
-		  uint8**				ppData, 
-		  uint32*				pDataLen,
-		  uint8					CipBlockSize,
-		  PaddingMethodType		uiPaddingMethod	)
-	{
-	/* Data structures */
-
-	/* Number of bytes to add to data
-	 */
-	uint8	padSize=0;
-
-	/* Address of input data
-	 */
-	uint8	*pDataIn;
-
-	/* Iterator
-	 */
-	uint16	i;
-
-	/* return code */
-	uint8 ret = DRM_ENG_OK;
-
-
-	/*  Code  */
-
-	/* check parameter */
-	if( !ppData || !pDataLen )
-		{
-		return DRM_ENG_INVALID_PARAM;
-		}
-
-	if( uiPaddingMethod == PADDING_PKCS7)
-		{
-		/* calculate padding size
-		 */
-		padSize = (uint8)( CipBlockSize-( *pDataLen % CipBlockSize ) );
-	
-		/* record input data address
-		 */
-		pDataIn = *ppData;
-
-		/* allocate memory
-		 */
-		*ppData = (uint8*)DRM_BLOCK_ALLOC( *pDataLen+padSize ) ;
-		if( !(*ppData) )
-			{
-			return DRM_ENG_MEM_ERROR;
-			}
-
-		/* copy data
-		 */
-		DRM_BLOCK_COPY( *ppData, pDataIn, *pDataLen  );
-
-		/* free memory for input data
-		 */
-		DRM_BLOCK_DEALLOC( pDataIn);
-
-		/* add padding
-		 */
-		for( i=0; i<padSize; i++)
-			*( (uint8*)(*ppData) + *pDataLen +i) = padSize;
-
-		/* calculate new data length:
-		 */
-		*pDataLen = *pDataLen+padSize;
-
-		return	DRM_ENG_OK;
-		}
-	else
-		{
-		DEBUG( "Cypto Error: invalid uiPaddingMethod !" )
-		ret = DRM_ENG_ERROR;
-		}
-
-	return ret;
-	}
-
-
-
-/*  7.6 */
-
-/* Functional description
- *
- * Remove padding bytes from data.
- *
- *
- * Parameters
- *
- * Pointer to pointer to data(with padding bytes).
- * IN: points to data with padding bytes.
- * OUT: points to data without padding bytes.
- *
- ppData
- *
- * Pointer to data length in bytes
- * IN:  points to length of data with padding.
- * OUT: points to length of data without padding.
- *
- pDataLen
- *
- * Specifies used padding method.
- *      PADDING_PKCS7
- *
- uiPaddingMethod
- *
- * Return values
- *
- * If operation is OK, return DRM_ENG_OK, 
- * otherwize DRM_ENG_ERROR.
- */
-
-/* ---------------------------------------------------------------------- */
-
-
-uint8 DRMCrypto_RemovePadding(
-		  uint8**				ppData, 
-		  uint32*				pDataLen,
-		  PaddingMethodType		uiPaddingMethod	)
-	{
-	/* Data structures */
-
-	/* Number of bytes of padding data
-	 */
-	uint8	padSize=0;
-
-		/* return code */
-	uint8 ret = DRM_ENG_OK;
-
-	/*  Code  */
-
-	/* check parameter */
-	if( !ppData || !pDataLen )
-		{
-		return DRM_ENG_INVALID_PARAM;
-		}
-
-	if( uiPaddingMethod == PADDING_PKCS7)
-		{
-		/* calculate padding size
-		 * padding size is equal to last byte value of data
-		 */
-		padSize = *( (*ppData) + (*pDataLen) -1);
-
-		if( padSize<1 || padSize>CRYPTO_BLOCK_SIZE )
-			{
-			DEBUG("Padding Size wrong!")
-			return DRM_ENG_ERROR;
-			}
-
-		/* calculate new data length:
-		 */
-		*pDataLen = *pDataLen-padSize;
-
-		return	DRM_ENG_OK;
-		}
-	else
-		{
-		DEBUG( "Cypto Error: invalid uiPaddingMethod !" )
-		ret = DRM_ENG_ERROR;
-		}
-
-	return ret;
-	}
-
-
-/*  7.8 */
-
-/* Functional description
- *
- * Generates an initialization vector for cipher CBC mode. 
- *
- *
- * Parameters
- *
- * Lenght of the IV to be generated in bits. Must be a value between 1-16.
- *
- ivLen
- *
- *
- * Pointer to pointer to the generated IV.
- *
- ppIV
- *
- *
- * Return values
- *
- * If operation is OK, return DRM_ENG_OK, 
- * otherwize DRM_ENG_ERROR.
- */
-
-/* ---------------------------------------------------------------------- */
-
-uint8 DRMCrypto_GenerateIV(uint32 ivLen, uint8 **ppIV)
-	{
-	/* Data structures */
-
-	/* return code	 */
-	uint8	ret=DRM_ENG_OK;
-
-	/* seed */
-	uint8* pSeed=NULL;
-
-	/*  Code  */
-	
-	/* check parameter */
-	if( ppIV == NULL || ivLen == 0 || ivLen > 16)
-		{
-		return DRM_ENG_INVALID_PARAM;
-		}
-
-	/* allocate memory for IV */
-	*ppIV = DRM_BLOCK_ALLOC( ivLen );
-	
-	if( !(*ppIV) )
-		{
-		return DRM_ENG_MEM_ERROR;
-		}
-
-	/* generate random number as seed */
-	pSeed = DRM_BLOCK_ALLOC( KEYSEED_LENGTH );
-	if( !pSeed )
-		{
-		ret = DRM_ENG_MEM_ERROR;
-		}
-	else
-		{
-		ret = DRMEnv_GetRandom( (uint32*)pSeed, KEYSEED_NUMBER_OF_INT32 );
-		TRANSLATE_ERROR_CODE( ret );
-		}
-
-	/* generate IV by seed */
-	if( ret == DRM_ENG_OK )
-		{
-		/* Just copy the seed as IV. */
-		DRM_BLOCK_COPY(*ppIV, pSeed, ivLen<KEYSEED_LENGTH?ivLen:KEYSEED_LENGTH );
-		}
-	else /* free memory */
-		{
-		DRM_BLOCK_DEALLOC( *ppIV );
-		}
-
-	/* free memory */
-	DRM_BLOCK_DEALLOC( pSeed );
-
-	return ret;
-	}
-
-#endif /* #ifndef C_DRMCRYPTO_CFILE */
-/* End of File */
-
--- a/omadrm/drmhelper/src/DRMHelperClient.cpp	Wed Apr 14 16:15:06 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,613 +0,0 @@
-/*
-* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Implementation of the Helper Client session functionality 
-*
-*/
-
-
-// INCLUDE FILES
-#include <e32std.h>
-#include <e32math.h>
-#include <drmcommon.h>
-#include "DRMHelperCommon.h"
-#include "DRMHelperClient.h"
-
-
-// LOCAL CONSTANTS AND MACROS
-// Number of message slots to reserve for this client server session.
-// Since we only communicate synchronously here, we never have any
-// outstanding asynchronous requests.
-LOCAL_C const TUint KDefaultMessageSlots = 0;
-LOCAL_C const TUid KServerUid3 = {0x101F6DC5};
-
-#ifdef __WINS__
-LOCAL_C const TUint KServerMinHeapSize =  0x1000;  //  4K
-LOCAL_C const TUint KServerMaxHeapSize = 0x10000;  // 64K
-#endif
-
-// ============================ LOCAL FUNCTIONS ===============================
-#ifdef _DRM_TESTING
-LOCAL_C void WriteLogL( const TDesC8& text , RFs &aFs );
-LOCAL_C void WriteFileL( const TDesC8& text , RFs &aFs , const TDesC& aName );
-LOCAL_C void CreateLogL();
-LOCAL_C void WriteL( const TDesC& aText );
-LOCAL_C void WriteL( const TDesC8& aText );
-LOCAL_C void WriteCurrentTimeL();
-#endif
-
-
-LOCAL_C TInt FromFileNameToUri(const TDesC16& aFileName , HBufC8*& aContentUri );
-LOCAL_C TInt CheckExpiration( const TDesC8& aUri , TTime& aEndTime , TInt& aCountLeft );
-LOCAL_C TInt StartServer();
-LOCAL_C TInt CreateServerProcess();
-
-
-
-// ============================ MEMBER FUNCTIONS ===============================
-
-// -----------------------------------------------------------------------------
-// RDRMHelperClient::RDRMHelperClient
-// C++ default constructor can NOT contain any code, that
-// might leave.
-// -----------------------------------------------------------------------------
-//
-EXPORT_C RDRMHelperClient::RDRMHelperClient()
-:   RSessionBase()
-    {
-    // No implementation required
-    }
-
-// -----------------------------------------------------------------------------
-// RDRMHelperClient::Connect
-// 
-// Connect to the server session
-// -----------------------------------------------------------------------------
-//
-EXPORT_C TInt RDRMHelperClient::Connect()
-    {
-#ifdef _DRM_TESTING
-    TRAPD( err , CreateLogL() );
-    if (err)
-        {
-        return err;
-        }
-    TRAP( err , WriteL(_L("Connect")) );
-    if (err)
-        {
-        return err;
-        }
-    TRAP( err , WriteCurrentTimeL() );
-    if (err)
-        {
-        return err;
-        }
-#endif
-    TInt error = StartServer();
-
-    if (KErrNone == error)
-        {
-
-        error = CreateSession(KDRMHelperServerName,
-                              Version(),
-                              KDefaultMessageSlots);
-        }
-    return error;
-    }
-
-// -----------------------------------------------------------------------------
-// RDRMHelperClient::Version
-// 
-// return server version
-// -----------------------------------------------------------------------------
-//
-EXPORT_C TVersion RDRMHelperClient::Version() const
-    {
-    return(TVersion(KDRMHSMajorVersionNumber,
-                    KDRMHSMinorVersionNumber,
-                    KDRMHSBuildVersionNumber));
-    }
-
-// -----------------------------------------------------------------------------
-// RDRMHelperClient::SetAutomated
-// 
-// Register one content uri to the helper server
-// -----------------------------------------------------------------------------
-//
-EXPORT_C TInt RDRMHelperClient::SetAutomated( const TDesC8& aUri , const TInt& aType ) const
-    {
-    TInt temp = aType;
-    TPtrC8 descriptor(aUri);
-
-    // This call waits for the server to complete the request before 
-    // proceeding. 
-    return SendReceive(ERegister, TIpcArgs( &descriptor, temp ) );
-    }
-
-// -----------------------------------------------------------------------------
-// RDRMHelperClient::SetAutomated
-// 
-// Register one file to the helper server
-// -----------------------------------------------------------------------------
-//
-EXPORT_C TInt RDRMHelperClient::SetAutomated( const TDesC16& aFileName , const TInt& aType ) const
-    {
-    TInt temp = aType;
-    TPtrC8 descriptor( NULL , 0 );
-   
-    descriptor.Set( reinterpret_cast<const TUint8*>( aFileName.Ptr() ), aFileName.Length()*2);
-
-    // This call waits for the server to complete the request before 
-    // proceeding. 
-    return SendReceive(ERegisterFile, TIpcArgs( &descriptor, temp ) );
-    }
-
-// -----------------------------------------------------------------------------
-// RDRMHelperClient::RemoveAutomated
-// 
-// Register one content uri to the helper server
-// -----------------------------------------------------------------------------
-//
-EXPORT_C TInt RDRMHelperClient::RemoveAutomated( const TDesC8& aUri , const TInt& aType ) const
-    {
-    TInt temp = aType;
-    TPtrC8 descriptor(aUri);
-
-    // This call waits for the server to complete the request before 
-    // proceeding.
-    return SendReceive(ERemove, TIpcArgs( &descriptor, temp ) );
-    }
-
-// -----------------------------------------------------------------------------
-// RDRMHelperClient::RemoveAutomated
-// 
-// Register one file to the helper server
-// -----------------------------------------------------------------------------
-//
-EXPORT_C TInt RDRMHelperClient::RemoveAutomated( const TDesC16& aFileName , const TInt& aType ) const
-    {
-    TInt temp = aType;
-    TPtrC8 descriptor( NULL , 0 );
-
-    descriptor.Set( reinterpret_cast<const TUint8*>( aFileName.Ptr() ), aFileName.Length()*2);
-
-    // This call waits for the server to complete the request before 
-    // proceeding. 
-    return SendReceive(ERemoveFile, TIpcArgs( &descriptor ) );
-    }
-
-// -----------------------------------------------------------------------------
-// RDRMHelperClient::IndicateIdle
-// 
-// Register one file to the helper server
-// -----------------------------------------------------------------------------
-//
-EXPORT_C TInt RDRMHelperClient::IndicateIdle() const
-    {
-    return SendReceive(EIndicateIdle, TIpcArgs());
-    }
-
-
-// -----------------------------------------------------------------------------
-// RDRMHelperClient::CanSetAutomated
-// 
-// Register one content uri to the helper server
-// -----------------------------------------------------------------------------
-//
-EXPORT_C TInt RDRMHelperClient::CanSetAutomated( const TDesC8& aUri , TBool& aValue ) const
-    {
-    TTime endTime;
-    TTime temp;
-    TInt countsLeft = 0;
-    TInt err = 0;
-    temp.Set( KNullDate );
-    endTime.Set( KNullDate );
-
-    err = CheckExpiration( aUri , endTime , countsLeft );
-    if ( endTime != temp )
-        {
-        aValue = ETrue;
-        }
-    else
-        {
-        aValue = EFalse;
-        }
-    return err;
-    }
-
-// -----------------------------------------------------------------------------
-// RDRMHelperClient::CanSetAutomated
-// 
-// Register one file to the helper server
-// -----------------------------------------------------------------------------
-//
-EXPORT_C TInt RDRMHelperClient::CanSetAutomated( const TDesC16& aFileName , TBool& aValue ) const
-    {
-    HBufC8* contentUri = NULL;
-    TInt err = 0;
-    err = FromFileNameToUri( aFileName , contentUri );
-    if (err)
-        {
-        return err;
-        }
-    err = CanSetAutomated( contentUri->Des() , aValue );
-    delete contentUri;
-    return err;
-    }
-
-
-// -----------------------------------------------------------------------------
-// RDRMHelperClient::IsAutomated
-// 
-// Register one content uri to the helper server
-// -----------------------------------------------------------------------------
-//
-EXPORT_C TInt RDRMHelperClient::IsAutomated( const TDesC8& aUri , TInt& aType , TBool& aIs ) 
-    {
-    TPtr8 type( reinterpret_cast< TUint8* >( &aType ),
-               0, 
-               sizeof( TInt ) );
-    TPtr8 flag( reinterpret_cast< TUint8* >( &aIs ),
-               0, 
-               sizeof( TInt ) );
-
-    TPtrC8 descriptor(aUri);
-
-    // This call waits for the server to complete the request before 
-    // proceeding. 
-    return SendReceive(EIsRegistered, TIpcArgs( &type, &descriptor, &flag ) );
-    }
-
-// -----------------------------------------------------------------------------
-// RDRMHelperClient::IsAutomated
-// 
-// Register one file to the helper server
-// -----------------------------------------------------------------------------
-//
-EXPORT_C TInt RDRMHelperClient::IsAutomated( const TDesC16& aFileName , TInt& aType , TBool& aIs ) 
-    {
-    TPtr8 type( reinterpret_cast< TUint8* >( &aType ),
-               0, 
-               sizeof( TInt ) );
-    TPtr8 flag( reinterpret_cast< TUint8* >( &aIs ),
-               0, 
-               sizeof( TInt ) );
-
-    TPtrC8 descriptor( NULL , 0 );
-
-    
-    descriptor.Set( reinterpret_cast<const TUint8*>( aFileName.Ptr() ), aFileName.Length()*2);
-
-    // This call waits for the server to complete the request before 
-    // proceeding. 
-    return SendReceive(EIsRegisteredFile, TIpcArgs( &type, &descriptor, &flag ) );
-
-    }
-
-
-
-// ============================= LOCAL FUNCTIONS ===============================
-// -----------------------------------------------------------------------------
-// StartServer
-// 
-// Start the helper server
-// -----------------------------------------------------------------------------
-//
-LOCAL_C TInt StartServer()
-    {
-
-#ifdef _DRM_TESTING
-    TRAPD( err , WriteL(_L("StartServer")) );
-    if (err)
-        {
-        return err;
-        }
-    TRAP( err , WriteCurrentTimeL() );
-    if (err)
-        {
-        return err;
-        }
-#endif
-    TInt result = 0;
-
-    TFindServer findHelperServer(KDRMHelperServerName);
-    TFullName name;
-
-    result = findHelperServer.Next(name);
-    if (result == KErrNone)
-        {
-        // Server already running
-        return KErrNone;
-        }
-
-    RSemaphore semaphore;       
-    result = semaphore.CreateGlobal(KDRMHelperServerSemaphoreName, 0);
-    if (result != KErrNone)
-        {
-        return  result;
-        }
-
-    result = CreateServerProcess();
-    if (result != KErrNone)
-        {
-        semaphore.Close(); 
-        return  result;
-        }
-
-    semaphore.Wait();
-    semaphore.Close();       
-
-    return  KErrNone;
-    }
-
-LOCAL_C TInt CreateServerProcess()
-    {
-#ifdef _DRM_TESTING
-    TRAPD( err , WriteL(_L("CreateServerProcess")) );
-    if (err)
-        {
-        return err;
-        }
-    TRAP( err , WriteCurrentTimeL() );
-    if (err)
-        {
-        return err;
-        }
-#endif
-    TInt result;
-
-    const TUidType serverUid(KNullUid, KNullUid, KServerUid3);
-
-#ifdef __WINS__
-
-    RLibrary lib;
-    result = lib.Load( KDRMHSServerFileName , serverUid );
-    if (result != KErrNone)
-        {
-        return  result;
-        }
-
-#ifdef _DRM_TESTING
-    TRAP( err , WriteL(_L("library is loaded")) );
-    if (err)
-        {
-        return err;
-        }
-    TRAP( err , WriteCurrentTimeL() );
-    if (err)
-        {
-        return err;
-        }
-#endif
-
-    //  Get the WinsMain function
-    TLibraryFunction functionWinsMain = lib.Lookup(1);
-
-    //  Call it and cast the result to a thread function
-    TThreadFunction serverThreadFunction = reinterpret_cast<TThreadFunction>(functionWinsMain());
-
-    TName threadName(KDRMHelperServerName);
-
-    // Append a random number to make it unique
-    threadName.AppendNum(Math::Random(), EHex);
-
-    RThread server;
-
-    result = server.Create(threadName,   // create new server thread
-                             serverThreadFunction, // thread's main function
-                             KDefaultStackSize,
-                             NULL,
-                             &lib,
-                             NULL,
-                             KServerMinHeapSize,
-                             KServerMaxHeapSize,
-                             EOwnerProcess);
-
-
-
-    lib.Close();    // if successful, server thread has handle to library now
-
-    if (result != KErrNone)
-        {
-        return  result;
-        }
-#ifdef _DRM_TESTING
-    TRAP( err , WriteL(_L("server thread is created")) );
-    if (err)
-        {
-        return err;
-        }
-    TRAP( err , WriteCurrentTimeL() );
-    if (err)
-        {
-        return err;
-        }
-#endif
-    server.SetPriority(EPriorityMore);
-
-
-#else
-
-    RProcess server;
-    result = server.Create( KDRMHSServerFileName, KNullDesC, serverUid);
-    if (result != KErrNone)
-        {
-        return  result;
-        }
-#ifdef _DRM_TESTING
-    TRAP( err , WriteL(_L("server thread is created")) );
-    if (err)
-        {
-        return err;
-        }
-    TRAP( err , WriteCurrentTimeL() );
-    if (err)
-        {
-        return err;
-        }
-#endif
-
-#endif
-
-    server.Resume();
-    server.Close();
-
-    return  KErrNone;
-    }
-
-LOCAL_C TInt FromFileNameToUri(const TDesC16& aFileName , HBufC8*& aContentUri )
-    {
-    DRMAuthenticated* c = NULL;
-    DRMCommon::TContentProtection protection;
-    HBufC8* mimeType = NULL;
-    TUint dataLen = 0;
-    TRAPD(err , c = DRMAuthenticated::NewL());
-    if (err)
-        {
-        return err;
-        }
-    err = c->GetFileInfo(
-        aFileName,
-        protection,
-        mimeType,
-        aContentUri,
-        dataLen);
-    delete mimeType;
-    if (err)
-        {
-        delete aContentUri;
-        aContentUri = NULL;
-        }
-    return err;
-    }
-
-
-LOCAL_C TInt CheckExpiration( const TDesC8& aUri , TTime& aEndTime , TInt& aCountLeft )
-    {
-    DRMAuthenticated* c = NULL;
-    CDRMRights* right = NULL;
-    TRAPD( err  , c = DRMAuthenticated::NewL() );
-    if (err)
-        {
-        return err;
-        }
-    err = c->GetActiveRights( aUri , 
-        DRMCommon::EPlay | DRMCommon::EExecute | DRMCommon::EPrint | DRMCommon::EDisplay , 
-        right );
-    if (!err)
-        {
-        err = right->GetExpirationDetails(
-            DRMCommon::EPlay | DRMCommon::EExecute | DRMCommon::EPrint | DRMCommon::EDisplay,
-            aEndTime,
-            aCountLeft);
-        }
-    delete right;
-    delete c;
-    return err;
-    }
-
-#ifdef _DRM_TESTING
-
-LOCAL_C void WriteLogL( const TDesC8& text , RFs &aFs )
-    {
-    _LIT( KLogFile , "c:\\HSClientLog.txt" );
-    WriteFileL( text , aFs , KLogFile );
-    }
-
-LOCAL_C void WriteFileL( const TDesC8& text , RFs &aFs , const TDesC& aName )
-    {
-    RFile file;
-    TInt size;
-    User::LeaveIfError( file.Open( aFs, aName , EFileWrite ) );
-    CleanupClosePushL( file );
-    User::LeaveIfError( file.Size( size ) );
-    User::LeaveIfError( file.Write( size, text ) );
-    CleanupStack::PopAndDestroy(); //file
-    }
-
-LOCAL_C void CreateLogL()
-    {
-    RFs fs;
-    User::LeaveIfError(fs.Connect());
-    CleanupClosePushL(fs);
-    RFile file;
-    User::LeaveIfError( file.Replace( fs , _L("c:\\HSClientLog.txt") , EFileWrite ) );
-    file.Close();
-    CleanupStack::PopAndDestroy(); //fs
-    }
-
-LOCAL_C void WriteL( const TDesC& aText )
-    {
-    RFs fs;
-    User::LeaveIfError( fs.Connect() );
-    CleanupClosePushL(fs);
-    HBufC8* text = HBufC8::NewLC(1000);
-    TPtr8 textptr(text->Des() );
-    textptr.Append( aText );
-    textptr.Append( _L("\r\n") );
-    WriteLogL(textptr , fs);
-    CleanupStack::PopAndDestroy(text);
-    CleanupStack::PopAndDestroy(); //fs
-    }
-
-LOCAL_C void WriteL( const TDesC8& aText )
-    {
-    RFs fs;
-    User::LeaveIfError( fs.Connect() );
-    CleanupClosePushL(fs);
-    HBufC8* text = HBufC8::NewLC(1000);
-    TPtr8 textptr(text->Des() );
-    textptr.Append( aText );
-    textptr.Append( _L8("\r\n") );
-    WriteLogL(textptr , fs);
-    CleanupStack::PopAndDestroy(text);
-    CleanupStack::PopAndDestroy(); //fs
-    }
-
-
-LOCAL_C void WriteCurrentTimeL()
-    {
-    RFs fs;
-    User::LeaveIfError( fs.Connect() );
-    CleanupClosePushL(fs);
-    HBufC8* text = HBufC8::NewLC(100);
-    TPtr8 textptr(text->Des() );
-// Date and Time display
-    TTime time;
-    time.HomeTime();
-    TBuf<256> dateString;
-    _LIT(KDate,"%*E%*D%X%*N%*Y %1 %2 '%3");
-    time.FormatL(dateString,KDate);
-    textptr.Append(_L( "\r\n\t\tData:\t" ) );
-    textptr.Append( dateString );
-    _LIT(KTime,"%-B%:0%J%:1%T%:2%S%:3%+B");
-    time.FormatL(dateString,KTime);
-    textptr.Append(_L( "\r\n\t\tTime:\t" ) );
-    textptr.Append( dateString );
-    textptr.Append(_L( "\r\n" ) );
-    textptr.Append(_L( "\r\n" ) );
-    WriteLogL(textptr , fs);
-    CleanupStack::PopAndDestroy(text);
-    CleanupStack::PopAndDestroy(); //fs
-    }
-#endif
-
-// ========================== OTHER EXPORTED FUNCTIONS =========================
-
-// Epoc DLL entry point, return that everything is ok
-GLDEF_C TInt E32Dll(TDllReason)
-    {
-    return KErrNone;
-    }
-
-//  End of File
--- a/omadrm/drmlicensemanager/src/LMSecurity.cpp	Wed Apr 14 16:15:06 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,104 +0,0 @@
-/*
-* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Encryption/Decryption support functions
-*
-*/
-
-
-// INCLUDE FILES
-#include <e32std.h>
-#include <e32base.h>
-#include <e32math.h>
-#include <s32buf.h>
-#include <s32crypt.h>
-
-#include "LMSecurity.h"
-#include "LMSecurityEncrypt.h"
-#include "LMSecurityDecrypt.h"
-
-// ============================ MEMBER FUNCTIONS ===============================
-
-// -----------------------------------------------------------------------------
-// CLMSecurity::NewEncryptL
-// Return a new encryptor
-// -----------------------------------------------------------------------------
-//
-CSecurityEncryptBase* CLMSecurity::NewEncryptL(
-    const TDesC8& init) const
-    {
-    return new CLMSecurityEncrypt(init);
-    };
-
-// -----------------------------------------------------------------------------
-// CLMSecurity::NewDecryptL
-// Return a new decryptor
-// -----------------------------------------------------------------------------
-//
-CSecurityDecryptBase* CLMSecurity::NewDecryptL(
-    const TDesC8& init) const
-    {
-    return new CLMSecurityDecrypt(init);
-    };
-
-// -----------------------------------------------------------------------------
-// CLMSecurity::SetL
-// Password functions not supported (handled via the encrypt/decrypt classes)
-// -----------------------------------------------------------------------------
-//
-void CLMSecurity::SetL(
-    const TDesC& /* aOldPassword */,
-    const TDesC& /* aNewPassword */)
-    {
-    };
-
-// -----------------------------------------------------------------------------
-// CLMSecurity::SecurityData
-// Password functions not supported (handled via the encrypt/decrypt classes)
-// -----------------------------------------------------------------------------
-//
-TPtrC8 CLMSecurity::SecurityData() const
-    {
-    return TPtrC8(0, 0);
-    };
-
-// -----------------------------------------------------------------------------
-// CLMSecurity::PrepareL
-// Password functions not supported (handled via the encrypt/decrypt classes)
-// -----------------------------------------------------------------------------
-//
-void CLMSecurity::PrepareL(
-    const TDesC& /* aPassword */)
-    {
-    };
-
-// -----------------------------------------------------------------------------
-// CLMSecurity::IsEnabled
-// Password functions not supported (handled via the encrypt/decrypt classes)
-// -----------------------------------------------------------------------------
-//
-TInt CLMSecurity::IsEnabled() const
-    {
-    return ETrue;
-    };
-
-// -----------------------------------------------------------------------------
-// CLMSecurity::SetEnabledL
-// Password functions not supported (handled via the encrypt/decrypt classes)
-// -----------------------------------------------------------------------------
-//
-void CLMSecurity::SetEnabledL(
-    const TDesC& /* aPassword */,
-    TBool /* aIsEnabled */)
-    {
-    };
--- a/omadrm/drmlicensemanager/src/LMSecurityDecrypt.cpp	Wed Apr 14 16:15:06 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-/*
-* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Encryption/Decryption support functions
-*
-*/
-
-
-// INCLUDE FILES
-#include <e32std.h>
-#include <e32base.h>
-#include <e32math.h>
-#include <s32buf.h>
-#include <s32crypt.h>
-
-#include "LMSecurity.h"
-#include "LMSecurityDecrypt.h"
-
-// ============================ MEMBER FUNCTIONS ===============================
-
-// -----------------------------------------------------------------------------
-// ?classname::?member_function
-// ?implementation_description
-// -----------------------------------------------------------------------------
-//
-CLMSecurityDecrypt::CLMSecurityDecrypt(
-    const TDesC8& init)
-    {
-    TPckg<TUint> p(0);
-
-    p.Copy(init);
-    iKey = p();
-    Math::Rand(iKey);
-    }
-
-// -----------------------------------------------------------------------------
-// ?classname::?member_function
-// ?implementation_description
-// -----------------------------------------------------------------------------
-//
-TInt CLMSecurityDecrypt::DecryptL(
-    TDes8& aOutput,
-    const TDesC8& aInput)
-    {
-    TInt i;
-    TUint8* ptr;
-
-    ptr = const_cast<TUint8*>(aOutput.Ptr());
-    for (i = 0; i < aInput.Size(); i++)
-        {
-        ptr[i] = static_cast<TUint8>(aInput[i] ^ Math::Rand(iKey));
-        }
-    aOutput.SetLength(aInput.Size());
-    return aInput.Size();
-    }
--- a/omadrm/drmlicensemanager/src/LMSecurityEncrypt.cpp	Wed Apr 14 16:15:06 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-/*
-* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Encryption/Decryption support functions
-*
-*/
-
-
-// INCLUDE FILES
-#include <e32std.h>
-#include <e32base.h>
-#include <e32math.h>
-#include <s32buf.h>
-#include <s32crypt.h>
-
-#include "LMSecurity.h"
-#include "LMSecurityEncrypt.h"
-
-// ============================ MEMBER FUNCTIONS ===============================
-
-// -----------------------------------------------------------------------------
-// CLMSecurityEncrypt::CLMSecurityEncrypt
-// Initialize the random key stream from a constant
-// -----------------------------------------------------------------------------
-//
-CLMSecurityEncrypt::CLMSecurityEncrypt(
-    const TDesC8& init)
-    {
-    TPckg<TUint> p(0);
-
-    p.Copy(init);
-    iKey = p();
-    Math::Rand(iKey);
-    }
-
-// -----------------------------------------------------------------------------
-// CLMSecurityEncrypt::EncryptL
-// Encrypt using the key stream
-// -----------------------------------------------------------------------------
-//
-TInt CLMSecurityEncrypt::EncryptL(
-    TDes8& aOutput,
-    const TDesC8& aInput)
-    {
-    TInt i;
-    TUint8* ptr;
-
-    ptr = const_cast<TUint8*>(aOutput.Ptr());
-    for (i = 0; i < aInput.Size(); i++)
-        {
-        ptr[i] = static_cast<TUint8>(aInput[i] ^ Math::Rand(iKey));
-        }
-    aOutput.SetLength(aInput.Size());
-    return aInput.Size();
-    }
-
-// -----------------------------------------------------------------------------
-// CLMSecurityEncrypt::CompleteL
-// Final encryption
-// -----------------------------------------------------------------------------
-//
-TInt CLMSecurityEncrypt::CompleteL(
-    TDes8& aOutput,
-    const TDesC8& aInput)
-    {
-    return EncryptL(aOutput, aInput);
-    }
--- a/omadrm/drmplugins/drmudtmodule/bwinscw/DrmUdtModuleU.DEF	Wed Apr 14 16:15:06 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-EXPORTS
-	??1CDrmUdtHandler@@UAE@XZ @ 1 NONAME ; CDrmUdtHandler::~CDrmUdtHandler(void)
-	?DoUserDataTransferL@CDrmUdtHandler@@QAEXABVTDesC8@@0PAVMDrmUdtObserver@@AAVTRequestStatus@@@Z @ 2 NONAME ; void CDrmUdtHandler::DoUserDataTransferL(class TDesC8 const &, class TDesC8 const &, class MDrmUdtObserver *, class TRequestStatus &)
-	?NewL@CDrmUdtHandler@@SAPAV1@XZ @ 3 NONAME ; class CDrmUdtHandler * CDrmUdtHandler::NewL(void)
-	?SetPreferredIap@CDrmUdtHandler@@QAEXK@Z @ 4 NONAME ; void CDrmUdtHandler::SetPreferredIap(unsigned long)
-
--- a/omadrm/drmplugins/drmudtmodule/eabi/DrmUdtModuleU.DEF	Wed Apr 14 16:15:06 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-EXPORTS
-	_ZN14CDrmUdtHandler15SetPreferredIapEm @ 1 NONAME
-	_ZN14CDrmUdtHandler19DoUserDataTransferLERK6TDesC8S2_P15MDrmUdtObserverR14TRequestStatus @ 2 NONAME
-	_ZN14CDrmUdtHandler4NewLEv @ 3 NONAME
-	_ZTI11CDrmUdtConn @ 4 NONAME ; #<TI>#
-	_ZTI14CDrmUdtHandler @ 5 NONAME ; #<TI>#
-	_ZTV11CDrmUdtConn @ 6 NONAME ; #<VT>#
-	_ZTV14CDrmUdtHandler @ 7 NONAME ; #<VT>#
-
--- a/omadrm/drmplugins/drmudtmodule/group/DrmUdtModule.mmp	Wed Apr 14 16:15:06 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-/*
-* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  ?Description
-*
-*/
-
-
-#include <platform_paths.hrh>
-
-TARGET      DrmUdtModule.dll
-TARGETTYPE  DLL
-UID         0x1000008D 0x10205CAB
-CAPABILITY  CAP_GENERAL_DLL DRM
-VENDORID    VID_DEFAULT
-
-SOURCEPATH  ../src 
-SOURCE      DrmUdtHandler.cpp
-SOURCE      DrmUdtConn.cpp
-
-USERINCLUDE     ../inc
-USERINCLUDE     ../../../../omadrm/drmengine/RoapStorage/inc
-USERINCLUDE     ../../../../omadrm/drmengine/Utils/inc
-USERINCLUDE	    ../../../../inc   // ADo level inc dir
-
-// Default system include paths for middleware layer modules.
-MW_LAYER_SYSTEMINCLUDE
-SYSTEMINCLUDE /epoc32/include/http
-SYSTEMINCLUDE /epoc32/include/ecom
-
-LIBRARY     euser.lib
-LIBRARY     estor.lib
-LIBRARY     efsrv.lib    
-LIBRARY     commdb.lib
-LIBRARY     bafl.lib 
-LIBRARY     esock.lib
-LIBRARY     http.lib     
-LIBRARY     inetprotutil.lib
-LIBRARY	    apmime.lib
-LIBRARY     random.lib
-LIBRARY     hash.lib
-LIBRARY     etel.lib
-LIBRARY	    etelmm.lib
-LIBRARY     flogger.lib
-LIBRARY     DrmServerInterfaces.lib
-
-#if defined(ARMCC)
-deffile ../eabi/ 
-#elif defined( WINSCW )
-deffile ../bwinscw/ 
-#elif defined( WINS )
-deffile ../bwins/ 
-#else
-deffile ../bmarm/ 
-#endif
-
-SMPSAFE
--- a/omadrm/drmplugins/drmudtmodule/inc/DrmUdtConn.h	Wed Apr 14 16:15:06 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-/*
-* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  ?Description
-*
-*/
-
-
-#ifndef DRM_UDT_CONN_H
-#define DRM_UDT_CONN_H
-
-// INCLUDES
-
-#include <e32base.h>
-#include <es_sock.h>
-#include <CommDbConnPref.h>
-
-
-// FORWARD DECLARATIONS
-class MDrmUdtObserver;
-
-// CLASS DECLARATION
-
-class CDrmUdtConn : public CActive
-    {
-    public:     // Constructors and destructor.
-
-        static CDrmUdtConn* NewL();
-
-        CDrmUdtConn();
-
-        ~CDrmUdtConn();
-
-    public:     // new methods
-
-        void ConnectL( TUint32 aIap,
-                       MDrmUdtObserver* aObserver,
-                       TRequestStatus* aStatus );
-
-        void Close();
-
-        TBool IsConnected( TUint32& aIap );
-
-        RSocketServ& SocketServ();
-
-        RConnection& Conn();
-
-    private:
-
-        enum TState
-            {
-            EInit,
-            EConnecting,
-            EConnected
-            };
-
-    private:    // Constructors and destructor.
-
-        void ConstructL();
-
-    private:  // from CActive
-
-        virtual void DoCancel();
-
-        virtual void RunL();
-
-        virtual TInt RunError( TInt aError );
-
-    private:    // new methods
-
-        void DoClose();
-
-        void Done();
-
-    private:    // data
-
-        RSocketServ iSocketServ;
-        RConnection iConnection;
-        TState iState;
-        TRequestStatus* iParentStatus;
-        TCommDbConnPref iConnPref;
-        MDrmUdtObserver* iObserver;
-    };
-
-#endif /* def CONNECTION_H */
--- a/omadrm/drmplugins/drmudtmodule/src/DrmUdtConn.cpp	Wed Apr 14 16:15:06 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,311 +0,0 @@
-/*
-* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  ?Description
-*
-*/
-
-
-// INCLUDE FILES
-
-#include "DrmUdtConn.h"
-#include "DrmUdtObserver.h"
-
-#include <CommDbConnPref.h>
-#include <commdb.h>
-#include <cdblen.h>
-#include <es_enum.h>
-
-// #include <ApSelect.h> // for checking APs
-
-#ifdef _DEBUG
-#define LOGGING
-#endif
-
-#define LOGGING
-
-#ifdef LOGGING
-_LIT(KLogDir, "DRM");
-_LIT(KLogName, "UDT.log");
-#include "flogger.h"
-#define LOG(string) \
-	RFileLogger::Write(KLogDir, KLogName, \
-		EFileLoggingModeAppend, string);
-#define LOGHEX(buffer) \
-	RFileLogger::HexDump(KLogDir, KLogName, \
-		EFileLoggingModeAppend, _S(""), _S(""), \
-		buffer.Ptr(), buffer.Length());
-#else
-#define LOG
-#define LOGHEX        
-#endif
-
-// ================= MEMBER FUNCTIONS =======================
-
-// ---------------------------------------------------------
-// CDrmUdtConn::NewL()
-// ---------------------------------------------------------
-//
-CDrmUdtConn* CDrmUdtConn::NewL()
-    {
-    LOG( _L("CDrmUdtConn::NewL") );
-    CDrmUdtConn* conn = new (ELeave) CDrmUdtConn();
-    CleanupStack::PushL( conn );
-    conn->ConstructL();
-    CleanupStack::Pop( conn );
-    return conn;
-    }
-
-// ---------------------------------------------------------
-// CDrmUdtConn::~CDrmUdtConn()
-// ---------------------------------------------------------
-//
-CDrmUdtConn::~CDrmUdtConn()
-    {
-    LOG( _L("CDrmUdtConn::~CDrmUdtConn") );
-    Cancel();
-    iConnection.Close();
-    iSocketServ.Close();
-    }
-
-// ---------------------------------------------------------
-// CDrmUdtConn::ConnectL()
-// ---------------------------------------------------------
-//
-void CDrmUdtConn::ConnectL( TUint32 aIap,
-                            MDrmUdtObserver* aObserver,
-                            TRequestStatus* aStatus )
-    { 
-    LOG( _L("CDrmUdtConn::ConnectL") );
-    
-    iObserver = aObserver;
-    
-    if ( iState == EInit )
-        {
-        // Not connected. Attach to existing connection, or create new one if
-        // allowed.
-        iStatus = KErrGeneral;
-
-        // Make this part atomic by pushing closes on the stack.
-        User::LeaveIfError( iSocketServ.Connect() );
-        CleanupClosePushL<RSocketServ>( iSocketServ );
-        User::LeaveIfError( iConnection.Open( iSocketServ ) );
-        CleanupClosePushL<RConnection>( iConnection );
-                
-        TConnectionInfoBuf connInfo;
-        TUint count;
-        User::LeaveIfError( iConnection.EnumerateConnections( count ) );
-        TUint i;
-        if ( count )
-            {
-            // Select from existing connections. Try to make AP match.
-            for ( i = count; i; i-- )
-                {
-                // Note: GetConnectionInfo expects 1-based index.
-                User::LeaveIfError( iConnection.GetConnectionInfo( i, connInfo ) );
-                if ( aIap == 0 || connInfo().iIapId == aIap )
-                    {
-                    // "Accept any" or AP match. Attach to this one.
-                    break;
-                    }
-                }
-            if ( !i )
-                {
-                // No AP match, select AP with largest index.
-                User::LeaveIfError
-                    ( iConnection.GetConnectionInfo( count, connInfo ) );
-                }
-            User::LeaveIfError
-                ( iConnection.Attach( connInfo, RConnection::EAttachTypeNormal ) );
-            iState = EConnected;
-            iStatus = KErrNone;
-            }
-        else
-            {
-            // No existing connections, create new one.
-#ifdef __WINS__
-            // WINS connection creation does not work if preferences are given.
-            // Defaults are to be used always.
-            iConnection.Start( iStatus );
-#else
-            // Note: the TCommDbConnPref must NOT be stack variable.
-            // It must persist until completion of RConnection::Start().
-            iConnPref.SetDirection( ECommDbConnectionDirectionOutgoing );
-            iConnPref.SetDialogPreference( ECommDbDialogPrefPrompt );
-            iConnPref.SetBearerSet( ECommDbBearerCSD | ECommDbBearerWcdma );
-            // New connection is always created with user-selected AP;
-            // so 0 is used instead of aIap.
-            iConnPref.SetIapId( 0 );
-            iConnection.Start( iConnPref, iStatus );
-#endif
-            if ( iObserver )
-                {
-                iObserver->ConnectionStartedL();
-                }
-
-            iState = EConnecting;
-            SetActive();    // The only path with a real async request.
-            }
-        CleanupStack::Pop( 2 ); // closing iConn and iSockServ
-        // End of atomic part.
-        }
-    else
-        {
-        // Not expecting this to be called in other states.
-        }
-
-    iParentStatus = aStatus;
-    *iParentStatus = KRequestPending;
-
-    if ( !IsActive() )
-        {
-        // Unless we have an outstanding connect request (iConn.Start),
-        // we are done.
-        User::RequestComplete( iParentStatus, iStatus.Int() );
-        iParentStatus = NULL;
-        }
-    }
-
-// ---------------------------------------------------------
-// CDrmUdtConn::Close()
-// ---------------------------------------------------------
-//
-void CDrmUdtConn::Close()
-    {
-    LOG( _L("CDrmUdtConn::Close") );
-    Cancel();
-    iConnection.Close();
-    iSocketServ.Close();
-    iState = EInit;
-    }
-
-// ---------------------------------------------------------
-// CDrmUdtConn::IsConnected()
-// ---------------------------------------------------------
-//
-TBool CDrmUdtConn::IsConnected( TUint32& aIap )
-    {
-    LOG( _L("CDrmUdtConn::IsConnected") );
-    TBool connected( EFalse );
-    if( iState == EConnected )
-        {
-        TBuf<KCommsDbSvrMaxColumnNameLength * 2 + 1> iapId;
-        _LIT( KFormatIapId, "%S\\%S" );
-        TPtrC iap( IAP );
-        TPtrC id( COMMDB_ID );
-        iapId.Format( KFormatIapId, &iap, &id );
-        TInt err = iConnection.GetIntSetting( iapId, aIap );
-        connected = err ? EFalse : ETrue;
-        }
-    return connected;
-    }
-
-// ---------------------------------------------------------
-// CDrmUdtConn::CConnection()
-// ---------------------------------------------------------
-//
-CDrmUdtConn::CDrmUdtConn()
-: CActive( CActive::EPriorityStandard ),
-  iState( EInit )
-    {
-    LOG( _L("CDrmUdtConn::CDrmUdtConn") );
-    CActiveScheduler::Add( this );
-    }
-
-// ---------------------------------------------------------
-// CDrmUdtConn::ConstructL()
-// ---------------------------------------------------------
-//
-void CDrmUdtConn::ConstructL()
-    {
-    LOG( _L("CDrmUdtConn::ConstructL") );
-    /*
-    TUint32 APs( 0 );
-    CCommsDatabase* commsdb = CCommsDatabase::NewL( EDatabaseTypeIAP );
-    CleanupStack::PushL( commsdb );
-    CApSelect* apSel = CApSelect::NewLC (
-        *commsdb,
-        KEApIspTypeAll,
-        EApBearerTypeAll,
-        KEApSortUidAscending );
-    APs = apSel->Count();
-    CleanupStack::PopAndDestroy( 2 );
-    if ( !APs )
-        {
-        // No AP defined
-        User::Leave( KErrRoapGeneral );
-        }
-     */
-    }
-
-// ---------------------------------------------------------
-// CDrmUdtConn::DoCancel()
-// ---------------------------------------------------------
-//
-void CDrmUdtConn::DoCancel()
-    {
-    LOG( _L("CDrmUdtConn::DoCancel") );
-    iConnection.Close();
-    iSocketServ.Close();
-    User::RequestComplete( iParentStatus, KErrCancel );
-    }
-
-// ---------------------------------------------------------
-// CDrmUdtConn::RunL()
-// ---------------------------------------------------------
-//
-void CDrmUdtConn::RunL()
-    {
-    LOG( _L("CDrmUdtConn::RunL") );
-    User::LeaveIfError( iStatus.Int() );    // Handle errors in RunError().
-
-    iState = EConnected;
-    User::RequestComplete( iParentStatus, iStatus.Int() );
-    iParentStatus = NULL;
-    }
-
-// ---------------------------------------------------------
-// CDrmUdtConn::RunError()
-// ---------------------------------------------------------
-//
-TInt CDrmUdtConn::RunError( TInt  /*aError*/ )
-    {
-    LOG( _L("CDrmUdtConn::RunError") );
-    iConnection.Close();
-    iSocketServ.Close();
-    iState = EInit;
-    User::RequestComplete( iParentStatus, iStatus.Int() );
-    iParentStatus = NULL;
-    return KErrNone;
-    }
-
-// ---------------------------------------------------------
-// CRoapConnection::Conn()
-// ---------------------------------------------------------
-//
-RSocketServ& CDrmUdtConn::SocketServ()
-    {
-    LOG( _L("CDrmUdtConn::SocketServ") );
-    return iSocketServ;
-    }
-
-// ---------------------------------------------------------
-// CRoapConnection::Conn()
-// ---------------------------------------------------------
-//
-RConnection& CDrmUdtConn::Conn()
-    {
-    LOG( _L("CDrmUdtConn::Conn") );
-    return iConnection;
-    }
-
--- a/omadrm/drmplugins/drmudtmodule/src/DrmUdtHandler.cpp	Wed Apr 14 16:15:06 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1228 +0,0 @@
-/*
-* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Implementation of the User Data Transfer module
-*
-*/
-
-
-// INCLUDE FILES
-#include "DrmUdtHandler.h"
-#include "DrmUdtConn.h"
-#include "RoapStorageClient.h"
-#include "DrmRightsClient.h"
-#include "DrmUdtObserver.h"
-
-#include <hash.h>
-#include <stringpool.h>
-#include <http/thttphdrval.h>
-#include <etelmm.h> 
-#include <mmtsy_names.h>
-
-#ifdef _DEBUG
-#define LOGGING
-#endif
-
-#define LOGGING
-
-#ifdef LOGGING
-_LIT(KLogDir, "DRM");
-_LIT(KLogName, "UDT.log");
-#include "flogger.h"
-#define LOG(string) \
-	RFileLogger::Write(KLogDir, KLogName, \
-		EFileLoggingModeAppend, string);
-#define LOGINT(string, val) \
-	RFileLogger::WriteFormat(KLogDir, KLogName, \
-		EFileLoggingModeAppend, string, val);
-#define LOGHEX(buffer) \
-	RFileLogger::HexDump(KLogDir, KLogName, \
-		EFileLoggingModeAppend, _S(""), _S(""), \
-		buffer.Ptr(), buffer.Length());
-#else
-#define LOG
-#define LOGHEX        
-#endif
-
-using namespace Roap;
-
-// ================= CONSTANTS ======================
-
-// The time out value in HTTP, 30 sec
-LOCAL_D const TInt KUdtTimeoutValue = 30000000;
-
-LOCAL_D const TInt KMaxSerNumLength = 64;
-LOCAL_D const TInt KRdbKeyLength = 256;
-LOCAL_D const TInt KVersionSize = 1;
-LOCAL_D const TInt KMessageIdSize = 1;
-LOCAL_D const TInt KLengthSize = 4;
-LOCAL_D const TInt KSignatureLength = 128;
-
-LOCAL_D const TInt KVersion = 0;
-
-LOCAL_D const TInt KPadding255 = 1;
-
-_LIT8( KUdtContentType, "application/binary" );
-
-// UDT message identifiers
-LOCAL_D const TUint8 KUdtRequestId = 0;
-LOCAL_D const TUint8 KUdtResponseId = 1;
-LOCAL_D const TUint8 KStatusResponseId = 3;
-LOCAL_D const TUint8 KErrorResponseId = 4;
-LOCAL_D const TUint8 KServerErrorValue = 0;
-LOCAL_D const TUint8 KClientErrorValue = 1;
-
-
-LOCAL_D const TInt KUdtResponseSize = 129;
-
-NONSHARABLE_STRUCT( TUnloadModule )
-    {
-    RTelServer* iServer;
-    const TDesC* iName;
-    };
-
-// ================= LOCAL FUNCTIONS =========================
-
-LOCAL_C void WriteIntToBlock( TInt aValue, TDes8& aBlock, TInt aOffset )
-    {
-    aBlock.SetLength(4);
-    aBlock[aOffset] =     (aValue & 0xff000000) >> 24;
-    aBlock[aOffset + 1] = (aValue & 0x00ff0000) >> 16;
-    aBlock[aOffset + 2] = (aValue & 0x0000ff00) >> 8;
-    aBlock[aOffset + 3] = (aValue & 0x000000ff);
-    }
-
-template<class S>
-void PointerArrayResetDestroyAndClose(TAny* aPtr)
-    {
-    (reinterpret_cast<RPointerArray<S>*>(aPtr))->ResetAndDestroy();
-    (reinterpret_cast<RPointerArray<S>*>(aPtr))->Close();
-    }
-    
-LOCAL_C void DoUnloadPhoneModule( TAny* aAny )
-    {
-    __ASSERT_DEBUG( aAny, User::Invariant() );
-    TUnloadModule* module = ( TUnloadModule* ) aAny;
-    module->iServer->UnloadPhoneModule( *( module->iName ) );
-    } 
-
-// ================= MEMBER FUNCTIONS =======================
-
-// ---------------------------------------------------------
-// CDrmUdtHandler::NewL()
-// ---------------------------------------------------------
-//
-EXPORT_C CDrmUdtHandler* CDrmUdtHandler::NewL( )
-    {
-    LOG( _L("CDrmUdtHandler:NewL:") );
-    CDrmUdtHandler* handler = new( ELeave ) CDrmUdtHandler();
-    CleanupStack::PushL( handler );
-    handler->ConstructL();
-    CleanupStack::Pop( handler );
-    return handler;
-    }
-
-// ---------------------------------------------------------
-// CDrmUdtHandler::~CDrmUdtModule()
-// ---------------------------------------------------------
-//
-CDrmUdtHandler::~CDrmUdtHandler()
-    {
-    LOG( _L("CDrmUdtHandler::~CDrmUdtHandler") );
-    Cancel();
-	iSession.Close();
-	delete iConnection;
-	delete iUri;
-	delete iTimeout;
-    delete iOneTimePassword;
-    delete iUdtRequest;
-    delete iUdtResponse;
-    }
-    
-// ---------------------------------------------------------
-// CDrmUdtHandler::ConstructL()
-// ---------------------------------------------------------
-//
-void CDrmUdtHandler::ConstructL() 
-    {
-    LOG( _L("CDrmUdtHandler::ConstructL") );
-    iConnection = CDrmUdtConn::NewL();
-    iTimeout = CPeriodic::NewL( CActive::EPriorityUserInput );
-    iRequestType = EUdtRequest;
-    iUdtError = EUdtOk;
-    iStateInfo.iState = TUdtStateInfo::EUdtNotStarted;
-    iStateInfo.iProgress = 0;
-    iStateInfo.iError = EUdtOk;
-    }
-    
-// -----------------------------------------------------------------------------
-// CDrmUdtHandler::DoUserDataTransferL()
-// -----------------------------------------------------------------------------
-//
-EXPORT_C void CDrmUdtHandler::DoUserDataTransferL( const TDesC8& aOneTimePassword,
-                                                   const TDesC8& aServiceUrl,
-                                                   MDrmUdtObserver* aObserver,
-                                                   TRequestStatus& aStatus )
-    {
-    LOG( _L("CDrmUdtHandler::DoUserDataTransferL") );
-    __ASSERT_ALWAYS( iState == EInit, User::Invariant() );
-    
-    /*
-    1. fetch original RDB data from the rights client (serial number and key)
-    2. create UDT package with the original RDB data, the one time password,
-       our serial number and our certificate
-    3. open a connection to the service URL
-    4. do a POST to the service URL, sending our UDT package
-    5. receive the anwser with the re-encrypted RDB key
-    6. tell the rights client to do a restore, using the re-encrypted RDB key
-    7. do a POST to the service URL, sendind a success or error notification
-    */
-
-    iOneTimePassword = aOneTimePassword.AllocLC();
-    iUri = aServiceUrl.AllocL();
-    iObserver = aObserver;
-    
-    LOG( _L8("Password: ") );
-    LOG( aOneTimePassword );
-    LOG( _L8("URL: ") );
-    LOG( aServiceUrl );
-    
-    iParentStatus = &aStatus;    
-    *iParentStatus = KRequestPending;
-    iState = EStart;
-    TRequestStatus* ownStatus = &iStatus;    
-    *ownStatus = KRequestPending;
-    iRequestType = EUdtRequest;
-    
-    SetActive();
-    User::RequestComplete( ownStatus, KErrNone );      
-    CleanupStack::Pop(); // iOneTimePassword    
-    }
-    
-// ---------------------------------------------------------
-// CDrmUdtHandler::SetPreferredIap()
-// ---------------------------------------------------------
-EXPORT_C void CDrmUdtHandler::SetPreferredIap( TUint32 aPreferredIap )
-    {
-    LOG( _L("CDrmUdtHandler::SetPreferredIap") );
-    iPreferredIap = aPreferredIap;
-    }    
-
-// ---------------------------------------------------------
-// CDrmUdtHandler::DoCancel()
-// ---------------------------------------------------------
-//
-void CDrmUdtHandler::DoCancel()
-    {
-    LOG( _L("CDrmUdtHandler::DoCancel") );
-    switch ( iState )
-        {
-        case EStart:
-        case EConnect:
-            {
-            iConnection->Cancel();
-            break;
-            }
-        case EResponseReceived:
-            {
-            iTransaction.Close();
-            SelfComplete( iError );
-            break;
-            }
-        default:
-            {
-            break;
-            }
-        }
-	iError = KErrCancel;
-	Complete();
-    }
-
-// ---------------------------------------------------------
-// CDrmUdtHandler::RunL()
-// ---------------------------------------------------------
-//
-void CDrmUdtHandler::RunL()
-    {
-    LOG( _L("CDrmUdtHandler::RunL") );
-    User::LeaveIfError( iStatus.Int() );
-
-    switch ( iState )
-        {
-        case EStart:
-            {
-            ConnectL();
-            break;
-            }        
-        case EConnect:
-            {
-            CreateSessionL();
-            break;
-            }
-        case ESendMessage:
-            {
-            SendUdtMessageL();
-            break;
-            }
-        case EResponseReceived:
-            {
-            ResponseReceivedL();
-            break;
-            }
-        case EComplete:
-            {
-            iState = EInit;
-    		Complete();
-            break;
-            }
-        case EInit:
-        default:
-            {
-            break;
-            }
-        }
-    }
-
-// ---------------------------------------------------------
-// CDrmUdtHandler::RunError()
-// ---------------------------------------------------------
-//
-TInt CDrmUdtHandler::RunError( TInt aError )
-    {
-    LOG( _L("CDrmUdtHandler::RunError") );
-    iError = aError;
-    iState = EInit;
-    Complete();
-    return KErrNone;
-    }
-
-// ---------------------------------------------------------
-// CDrmUdtHandler::ConnectL()
-// ---------------------------------------------------------
-//
-void CDrmUdtHandler::ConnectL()
-    {
-    LOG( _L("CDrmUdtHandler::ConnectL") );
-    __ASSERT_ALWAYS( iState == EStart, User::Invariant() );
-    
-    iConnection->ConnectL( iPreferredIap, iObserver, &iStatus );
-    iState = EConnect;
-    iError = EUdtOk;
-    SetActive();
-    }
-
-// ---------------------------------------------------------
-// CDrmUdtHandler::CreateSessionL()
-// ---------------------------------------------------------
-//
-void CDrmUdtHandler::CreateSessionL()
-    {
-    LOG( _L("CDrmUdtHandler::CreateSessionL") );
-    __ASSERT_ALWAYS( iState == EConnect, User::Invariant() );
-    
-    TUint32 ap;
-
-    if( !iConnection->IsConnected( ap ) )
-        {
-        User::Leave( KErrGeneral );
-        }
-    
-    iSession.Close();
-    iSession.OpenL();
-
-    RStringPool strPool = iSession.StringPool();
-
-    // Remove first session properties just in case.
-    RHTTPConnectionInfo connInfo = iSession.ConnectionInfo();
-    
-    // Clear RConnection and Socket Server instances
-    connInfo.RemoveProperty(strPool.StringF(HTTP::EHttpSocketServ,RHTTPSession::GetTable()));
-    connInfo.RemoveProperty(strPool.StringF(HTTP::EHttpSocketConnection,RHTTPSession::GetTable()));
-    
-#ifdef __WINS__    
-    // Clear the proxy settings
-    RStringF proxy;
-    proxy = strPool.OpenFStringL(_L8("172.22.168.15"));
-    connInfo.SetPropertyL
-        ( 
-        strPool.StringF( HTTP::EProxyAddress, RHTTPSession::GetTable() ), 
-        THTTPHdrVal( proxy ) 
-        );
-    proxy.Close();
-    connInfo.SetPropertyL
-        ( 
-        strPool.StringF( HTTP::EProxyUsage, RHTTPSession::GetTable() ), 
-        THTTPHdrVal( strPool.StringF(HTTP::EUseProxy, RHTTPSession::GetTable() ) )
-        );
-
-#else
-    THTTPHdrVal proxyUsage(strPool.StringF(HTTP::EUseProxy,RHTTPSession::GetTable()));
-    connInfo.RemoveProperty(strPool.StringF(HTTP::EProxyUsage,RHTTPSession::GetTable()));
-    connInfo.RemoveProperty(strPool.StringF(HTTP::EProxyAddress,RHTTPSession::GetTable()));
-#endif
-
-    connInfo.SetPropertyL
-        (
-        strPool.StringF( HTTP::EHttpSocketServ, RHTTPSession::GetTable() ),
-        THTTPHdrVal( iConnection->SocketServ().Handle() )
-        );
-
-    connInfo.SetPropertyL
-        ( 
-        strPool.StringF( HTTP::EHttpSocketConnection, RHTTPSession::GetTable() ), 
-        THTTPHdrVal( REINTERPRET_CAST( TInt, &iConnection->Conn() ) )
-        );
-
-    InstallHttpFiltersL();
-
-    // Complete requests
-    TRequestStatus* ownStatus = &iStatus;    
-    *ownStatus = KRequestPending;
-    iState = ESendMessage;
-    SetActive();
-    User::RequestComplete( ownStatus, KErrNone );
-    }
-
-
-// ---------------------------------------------------------
-// CDrmUdtModule::InstallHttpFilters()
-// ---------------------------------------------------------
-//
-void CDrmUdtHandler::InstallHttpFiltersL()
-    {
-    LOG( _L("CDrmUdtHandler::InstallHttpFiltersL") );
- // CHttpUAProfFilterInterface::InstallFilterL( iSession );
- // CHttpCookieFilter::InstallFilterL( iSession );
- // InstallAuthenticationL( iSession );
- // CHttpFilterProxyInterface::InstallFilterL( iSession );
-    }
-
-
-// ---------------------------------------------------------
-// CDrmUdtHandler::SendUdtMessageL()
-// ---------------------------------------------------------
-//
-void CDrmUdtHandler::SendUdtMessageL()
-    {
-    LOG( _L("CDrmUdtHandler::SendUdtMessageL") );
-    __ASSERT_ALWAYS( iState == ESendMessage, User::Invariant() );
-    
-    TUriParser8 uri;
-    
-    if ( iRequestType == EUdtRequest )
-        {
-        CreateUdtRequestL();
-        }
-    else if( iRequestType == EStatusNotification )
-        {
-        CreateStatusNotificationL();
-        }
-    
-    User::LeaveIfError( uri.Parse( *iUri ) );
-    RStringF POST;
-    POST = iSession.StringPool().StringF( HTTP::EPOST, RHTTPSession::GetTable() );
-    iTransaction = iSession.OpenTransactionL( uri, *this, POST );
-
-    // Set required headers
-    RHTTPHeaders hdrs = iTransaction.Request().GetHeaderCollection();
-    
-    SetHeaderL(hdrs, HTTP::EAccept, KUdtContentType() );
-    
-    SetHeaderL(hdrs, HTTP::EContentType, KUdtContentType() );
-    
-    // Add request body
-    MHTTPDataSupplier* ds = this;
-    iTransaction.Request().SetBody(*ds);
-    
-    iTransaction.SubmitL();
-
-    iState = EResponseReceived;
-    iStatus = KRequestPending;
-    SetActive();
-
-    iTimeout->Cancel();
-    iTimeout->Start( KUdtTimeoutValue,
-    				 KUdtTimeoutValue,
-    				 TCallBack( StaticTimeOut,this ) );
-    }
-    
-    
-// ---------------------------------------------------------
-// CDrmUdtHandler::CreateUdtRequestL()
-// ---------------------------------------------------------
-//    
-void CDrmUdtHandler::CreateUdtRequestL()
-    {
-    RRoapStorageClient client;
-    RPointerArray< HBufC8 > certChain;
-    TCleanupItem listCleanup( PointerArrayResetDestroyAndClose< HBufC8 >,
-        &certChain );
-    HBufC8* certBlock;
-    TInt i;
-    TInt n;
-    TPtr8 ptr( NULL, 0 );
-    TBuf8< sizeof ( TUint32 ) > intBuf;
-    TBuf8< KMaxSerNumLength > targetSer;
-    TBuf8< KRdbKeyLength > rdb_data;
-    TBuf8< KSignatureLength > hash;
-    HBufC8* signature = NULL;
-    TInt udtVersion;
-    CSHA1* hasher = NULL;
-    
-    LOG( _L("CDrmUdtHandler::CreateUdtRequestL") );
-    delete iUdtRequest;
-    
-    if ( iObserver )
-        {
-        iStateInfo.iState = TUdtStateInfo::EUdtReguest;
-        iStateInfo.iProgress = 0;
-        iObserver->UdtProgressInfoL( iStateInfo );
-        }
-    
-    hasher = CSHA1::NewL();
-    CleanupStack::PushL( hasher );
-    User::LeaveIfError( client.Connect() );
-    CleanupClosePushL( client );
-    client.SelectTrustedRootL( KNullDesC8 );
-
-    LOG( _L("  Getting cert chain") );
-    User::LeaveIfError( client.GetDeviceCertificateChainL( certChain ) );
-    CleanupStack::PushL( listCleanup );
-
-    LOG( _L("  Getting UDT data") );
-    ReadUdtDataL( targetSer, udtVersion, rdb_data );
-
-    LOG(_L8("RDB data:"));    
-    LOGHEX(rdb_data)
-    
-    n = 0;
-    for ( i = 0; i < certChain.Count(); i++ )
-        {
-        n = n + KLengthSize + certChain[i]->Size();
-        }
-    certBlock = HBufC8::NewL( n );
-    CleanupStack::PushL( certBlock );
-    ptr.Set( certBlock->Des() );
-    for ( i = 0; i < certChain.Count(); i++ )
-        {
-        WriteIntToBlock( certChain[i]->Size(), intBuf, 0 );
-        ptr.Append( intBuf );
-        ptr.Append( *certChain[i] );
-        }
-
-    n = KVersionSize + 
-        KMessageIdSize + 
-        KLengthSize + 
-        iOneTimePassword->Size() + 
-        KLengthSize +
-        certBlock->Size() + 
-        KLengthSize +
-        targetSer.Size() +
-        rdb_data.Size() + 
-        KLengthSize + 
-        KSignatureLength;
-        
-    iUdtRequest = HBufC8::NewL( n );
-    ptr.Set( iUdtRequest->Des() );
-    WriteIntToBlock( n - (KVersionSize + KMessageIdSize + 
-                     KLengthSize + KSignatureLength), intBuf, 0 );
-    
-    ptr.Append( KVersion );             // 1. version
-    ptr.Append( KUdtRequestId );        // 2. request id
-    ptr.Append( intBuf );               // 3. request length
-    ptr.Append( *iOneTimePassword );    // 4. password
-    WriteIntToBlock( certBlock->Size(), intBuf, 0 );
-    ptr.Append( intBuf );               // 5. ceritificate block length
-    ptr.Append( *certBlock );           // 6. ceritificate block
-    WriteIntToBlock( targetSer.Size(), intBuf, 0 );
-    ptr.Append( intBuf );               // 7. serial number length
-    ptr.Append( targetSer );            // 8. original serial number
-    ptr.Append( rdb_data );             // 9. RDB data
-    WriteIntToBlock( udtVersion, intBuf, 0 );
-    ptr.Append( intBuf );               // 10. UDT key version
-    
-    hasher->Update( ptr );
-    hash.Append( 0 );
-    hash.Append( KPadding255 );
-    for ( i = 2; i < KSignatureLength - SHA1_HASH - 1; i++ )
-        {
-        hash.Append( 255 );
-        }
-    hash.Append( 0 );
-    hash.Append( hasher->Final() );
-    LOG(_L8("Hash:"));
-    LOGHEX(hash);
-    client.RsaSignL( hash, signature );
-    CleanupStack::PushL(signature);
-    ptr.Append( *signature );           // 11. signature
-    LOG(_L8("Signature:"));
-    LOGHEX((*signature));
-    
-    CleanupStack::PopAndDestroy( 5 );   // certBlock, listCleanup,
-                                        // client, hasher, signature
-    if ( iObserver )
-        {
-        iStateInfo.iState = TUdtStateInfo::EUdtReguest;
-        iStateInfo.iProgress += 20;
-        iObserver->UdtProgressInfoL( iStateInfo );
-        }
-        
-    LOG(_L8("Request:"));
-    LOGHEX((*iUdtRequest));
-    }
-    
-    
-// ---------------------------------------------------------
-// CDrmUdtHandler::CreateStatusNotificationL()
-// ---------------------------------------------------------
-//    
-void CDrmUdtHandler::CreateStatusNotificationL()
-    {
-    LOG( _L("CDrmUdtHandler::CreateStatusNotificationL") );
-    
-    if ( iObserver )
-        {
-        iStateInfo.iState = TUdtStateInfo::EUdtStatusNotification;
-        iStateInfo.iProgress += 20;
-        iObserver->UdtProgressInfoL( iStateInfo );
-        }
-    
-    delete iUdtRequest;
-    iUdtRequest = NULL;
-    iUdtRequest = HBufC8::NewL(64);
-    TPtr8 ptr = iUdtRequest->Des();
-    ptr.Append(0);
-    ptr.Append(2);
-    ptr.Append(*iOneTimePassword);
-    iUdtError == EUdtOk ? ptr.Append(1) : ptr.Append(0);
-    }
-    
-    
-// ---------------------------------------------------------
-// CDrmUdtHandler::ResponseReceivedL()
-// ---------------------------------------------------------
-//    
-void CDrmUdtHandler::ResponseReceivedL()
-    {
-    LOG( _L("CDrmUdtHandler::ResponseReceivedL") );
-    __ASSERT_ALWAYS( iState == EResponseReceived, User::Invariant() );
-    __ASSERT_ALWAYS( iUdtResponse, User::Invariant() );
-    
-    TPtrC8 udtRespPtr( *iUdtResponse );
-    HBufC8* origDBKey = NULL;
-    TPtrC8 origDBKeyPtr( KNullDesC8 );
-    RDRMRightsClient rightsClient;
-    TInt error = EUdtOk;
-        
-    LOGHEX((*iUdtResponse));
-    
-    // check response type
-    switch ( udtRespPtr[1] )
-        {
-        case KUdtResponseId:
-            {
-            if ( iObserver )
-                {
-                iStateInfo.iState = TUdtStateInfo::EUdtKeyRestore;
-                iStateInfo.iProgress += 20;
-                iObserver->UdtProgressInfoL( iStateInfo );
-                }
-            
-            if ( udtRespPtr.Length() < KUdtResponseSize )
-                {
-                User::Leave( KErrCorrupt );
-                }
-            origDBKeyPtr.Set( udtRespPtr.Mid( 2 ) );
-            origDBKey = origDBKeyPtr.AllocLC();
-            
-            iUdtError = rightsClient.Connect();
-            CleanupClosePushL( rightsClient );
-            
-            if ( !iUdtError )
-                {
-                iUdtError = rightsClient.InitiateUdt( origDBKeyPtr );
-                }
-         
-            CleanupStack::PopAndDestroy( 2 ); // origDBKey, rightsClient
-            
-            iRequestType = EStatusNotification;
-            iState = ESendMessage;
-            iStatus = KRequestPending;
-            SetActive();
-            SelfComplete( KErrNone );
-            break;
-            }
-        case KStatusResponseId:
-            {
-            if ( iObserver )
-                {
-                iStateInfo.iState = TUdtStateInfo::EUdtStatusNotification;
-                iStateInfo.iProgress += 20;
-                iObserver->UdtProgressInfoL( iStateInfo );
-                }
-            
-            iState = EComplete;
-            iStatus = KRequestPending;
-            SetActive();
-            
-            if ( iUdtError )
-                {
-                error = EUdtKeyRestoreFailed;
-                iUdtError = EUdtOk;
-                }
-            SelfComplete( error );
-            break;
-            }
-        case KErrorResponseId:
-            {
-            if ( udtRespPtr.Length() >= 3 && udtRespPtr[2] == KClientErrorValue )
-                {
-                error = EUdtClientError;
-                }
-            else
-                {
-                error = EUdtServerError;
-                }
-            
-            iState = EComplete;
-            iStatus = KRequestPending;            
-            SetActive();
-            SelfComplete( error );
-            break;
-            }
-        default:
-            {
-            User::Leave( KErrNotSupported );
-            }
-        }  
-    }
-    
-// ---------------------------------------------------------
-// CDrmUdtHandler::SetHeaderL()
-// ---------------------------------------------------------
-//
-void CDrmUdtHandler::SetHeaderL(RHTTPHeaders aHeaders, TInt aHdrField, const TDesC8& aHdrValue)
-	{
-    LOG( _L("CDrmUdtHandler::SetHeaderL") );
-    RStringF valStr = iSession.StringPool().OpenFStringL(aHdrValue);
-    THTTPHdrVal val(valStr);
-    aHeaders.SetFieldL(iSession.StringPool().StringF(aHdrField,RHTTPSession::GetTable()), val);
-    valStr.Close();
-	}
-    
-
-// ---------------------------------------------------------
-// CDrmUdtHandler::Complete()
-// ---------------------------------------------------------
-//
-void CDrmUdtHandler::Complete()
-    {
-    LOG( _L("CDrmUdtHandler::Complete") );
-    
-    delete iUri;
-    iUri = NULL;
-    delete iUdtResponse;
-    iUdtResponse = NULL;
-    delete iUdtRequest;
-    iUdtRequest = NULL;
-    delete iOneTimePassword;
-    iOneTimePassword = NULL;
-    
-    if( iTimeout )
-    	{
-    	iTimeout->Cancel();
-    	}
-    	
-    if ( iObserver )
-        {
-        iStateInfo.iState = TUdtStateInfo::EUdtComplete;
-        iStateInfo.iProgress = 100;
-        iStateInfo.iError = iError;
-        TRAPD(ignore, iObserver->UdtProgressInfoL( iStateInfo ));
-        }  
-    
-    User::RequestComplete( iParentStatus, iError );
-    iParentStatus = NULL;
-    }
-
-
-// ---------------------------------------------------------
-// CDrmUdtHandler::CDrmUdtModule()
-// ---------------------------------------------------------
-//
-CDrmUdtHandler::CDrmUdtHandler(): CActive( CActive::EPriorityStandard )
-    {
-    LOG( _L("CDrmUdtHandler::CDrmUdtHandler") );
-    CActiveScheduler::Add( this );
-    }
-
-
-// ---------------------------------------------------------
-// CDrmUdtHandler::SelfComplete()
-// ---------------------------------------------------------
-//
-void CDrmUdtHandler::SelfComplete( TInt aResult )
-    {
-    LOG( _L("CDrmUdtHandler::SelfComplete") );
-    if ( iStatus == KRequestPending )
-        {
-        TRequestStatus* ownStatus = &iStatus;
-        User::RequestComplete( ownStatus, aResult );
-        }
-    else
-        {
-        if ( aResult != KErrNone )
-            {
-            iStatus = aResult;
-            }
-        }
-    }
-
-
-// ---------------------------------------------------------
-// CDrmUdtHandler::MHFRunL()
-// ---------------------------------------------------------
-//
-void CDrmUdtHandler::MHFRunL( RHTTPTransaction  /*aTransaction */, 
-								const THTTPEvent& aEvent )
-    {
-    LOGINT( _L("CDrmUdtHandler::MHFRunL: %d"), aEvent.iStatus );
-    iTimeout->Cancel();
-    iTimeout->Start( KUdtTimeoutValue,
-    				 KUdtTimeoutValue, 
-    				 TCallBack( StaticTimeOut,this ) );    				 
-
-    switch ( aEvent.iStatus )
-        {
-        case THTTPEvent::EGotResponseHeaders:
-            {
-            HandleResponseHeadersL( iTransaction.Response() );
-            break;
-            }
-
-        case THTTPEvent::EGotResponseBodyData:
-            {
-            TInt ret( KErrNone );
-            MHTTPDataSupplier* body = iTransaction.Response().Body();
-            TPtrC8 ptr;
-            body->GetNextDataPart( ptr );
-			ret = AppendResponseData( ptr );
-            body->ReleaseData();
-            User::LeaveIfError( ret );
-            break;
-            }
-
-        case THTTPEvent::EFailed:
-            {
-            if ( iError == KErrNone )
-                {
-                iError = EUdtServerError;
-                }
-        	iTransaction.Close();
-            SelfComplete( iError );
-            break;
-            }
-
-        case THTTPEvent::ESucceeded:
-            {        
-            iTransaction.Close();
-            SelfComplete( iError );
-            break;
-            }
-
-        case THTTPEvent::ERedirectRequiresConfirmation:
-            {
-            iTransaction.SubmitL();
-            }
-
-        default:
-            {
-            if( aEvent.iStatus == KErrHttpRedirectUseProxy )
-                {
-                }
-            else
-                {                
-                User::LeaveIfError( aEvent.iStatus );
-                }
-            break;
-            }
-        }
-
-    }
-
-// ---------------------------------------------------------
-// CDrmUdtHandler::MHFRunError()
-// ---------------------------------------------------------
-//
-TInt CDrmUdtHandler::MHFRunError (
-        TInt aError,
-        RHTTPTransaction /* aTransaction */,
-        const THTTPEvent& /* aEvent */
-        )
-    {
-    LOG( _L("CDrmUdtHandler::MHFRunError") );
-    iTransaction.Close();
-    iError = aError;
-    SelfComplete( iError );
-    return KErrNone;
-    }
-
-// ---------------------------------------------------------
-// CDrmUdtHandler::HandleResponseHeadersL()
-// ---------------------------------------------------------
-//
-void CDrmUdtHandler::HandleResponseHeadersL( RHTTPResponse aHttpResponse )
-    {
-    LOG( _L("CDrmUdtHandler::HandleResponseHeadersL") );
-    RHTTPHeaders headers = aHttpResponse.GetHeaderCollection();
-    
-    TInt httpCode = aHttpResponse.StatusCode();
-    TBool status;
-    
-    status = CheckHttpCode( httpCode );
-    
-    if ( status )
-    	{
-        RStringF contentTypeStr;
-        THTTPHdrVal contentTypeVal;
-        TPtrC8 ptrContentType(KNullDesC8);
-		RStringPool srtPool;
-		srtPool = iSession.StringPool();
-        
-        contentTypeStr = srtPool.StringF( HTTP::EContentType, RHTTPSession::GetTable() );										
-    	User::LeaveIfError( headers.GetField( contentTypeStr, 0, contentTypeVal ) );
-    	
-    	if ( contentTypeVal.StrF().DesC().CompareF( KUdtContentType() ) != KErrNone )
-    	    {
-			User::Leave( KErrNotSupported );
-    	    }
-       
-    	}
-    if ( aHttpResponse.HasBody() )
-        {
-        TInt dataSize = aHttpResponse.Body()->OverallDataSize();
-        if ( dataSize >= 0 )
-            {
-            HBufC8* buf = HBufC8::NewL( dataSize );
-            delete iUdtResponse;
-            iUdtResponse = buf;
-            }
-        }
-    }
-     
-// ---------------------------------------------------------
-// CDrmUdtHandler::CheckHttpCode()
-// ---------------------------------------------------------
-//
-TBool CDrmUdtHandler::CheckHttpCode( TInt aHttpStatus )
-	{
-	LOGINT(_L("CDrmUdtHandler::CheckHttpCode: %d"), aHttpStatus);
-    if ( HTTPStatus::IsInformational( aHttpStatus ) )
-        {
-        // 1xx
-        // Informational messages.
-        iError = EUdtServerError;
-        return EFalse;  
-        }
-    else if ( aHttpStatus == HTTPStatus::EOk ||
-              aHttpStatus == HTTPStatus::ENonAuthoritativeInfo )
-        {
-        // 200 OK
-        // 203 Non-Authoritative Information
-        iError = EUdtOk;
-        return ETrue;        
-        }
-    else if ( HTTPStatus::IsSuccessful( aHttpStatus ) )
-        {
-        // 2xx
-        // Success codes without an usable body.
-        iError = EUdtServerError;
-        return EFalse; 
-        }
-    else if ( aHttpStatus == HTTPStatus::EUnauthorized ||
-              aHttpStatus == HTTPStatus::EProxyAuthenticationRequired )
-        {
-        // 401 Unauthorized
-        // 407 Proxy authentication required
-        iError = EUdtInvalidServerAddress;
-        return EFalse; 
-        }
-    else if ( aHttpStatus == HTTPStatus::ENotFound ||
-              aHttpStatus == HTTPStatus::EGone )
-        {
-        // 404 Not found
-        // 410 Gone
-        iError = EUdtInvalidServerAddress;
-        return EFalse; 
-        }
-    else if ( HTTPStatus::IsClientError( aHttpStatus ) )
-        {
-        // 4xx
-        iError = EUdtInvalidServerAddress;
-        return EFalse; 
-        }
-    else if ( aHttpStatus == HTTPStatus::EHTTPVersionNotSupported )
-        {
-        // 505 HTTP Version Not Supported
-        iError = EUdtServerError;
-        return EFalse; 
-        }
-    else if ( HTTPStatus::IsServerError( aHttpStatus ) )
-        {
-        // 5xx
-        iError = EUdtServerError;
-        return EFalse; 
-        }
-    else 
-        {
-        // Everything else.
-        iError = EUdtServerError;
-        }
-    return EFalse; 
-	}
-
-
-// ---------------------------------------------------------
-// CDrmUdtModule::AppendResponseData()
-// ---------------------------------------------------------
-//
-TInt CDrmUdtHandler::AppendResponseData( const TDesC8& aDataChunk )
-    {
-    LOG( _L("CDrmUdtHandler::AppendResponseData") );
-    TInt needed = iUdtResponse->Des().Length() + aDataChunk.Length();
-    if ( iUdtResponse->Des().MaxLength() < needed )
-        {
-        HBufC8* buf = iUdtResponse->ReAlloc( needed );
-        if ( buf )
-            {
-            iUdtResponse = buf;
-            }
-        else
-            {
-            return KErrNoMemory;
-            }
-        }
-    iUdtResponse->Des().Append( aDataChunk );
-    return KErrNone;
-    }
-    
-// -----------------------------------------------------------------------------
-// CDrmUdtHandler::StaticTimeOut()
-// -----------------------------------------------------------------------------
-//
-TInt CDrmUdtHandler::StaticTimeOut( TAny* aPointer )
-    {  
-    LOG( _L("CDrmUdtHandler::StaticTimeOut") );
-    CDrmUdtHandler* itself = STATIC_CAST(CDrmUdtHandler*, aPointer);
-    if(itself)
-        {
-        itself->TimeOut();
-        }
-    return KErrNone;
-    }
- 
-    
-// -----------------------------------------------------------------------------
-// CDrmUdtHandler::TimeOut()
-// -----------------------------------------------------------------------------
-//
-void CDrmUdtHandler::TimeOut()
-    {
-    LOG( _L("CDrmUdtHandler::TimeOut") );
-    iTransaction.Close();
-    iError = KErrTimedOut;
-    SelfComplete( iError );
-    }
-
-
-// ---------------------------------------------------------
-// CDrmUdtHandler::GetNextDataPart()
-// ---------------------------------------------------------
-//
-TBool CDrmUdtHandler::GetNextDataPart( TPtrC8& aDataPart )
-    {
-    LOG( _L("CDrmUdtHandler::GetNextDataPart") );
-    aDataPart.Set( iUdtRequest->Des() );
-    return ETrue;
-    }
-
-// ---------------------------------------------------------
-// CDrmUdtHandler::ReleaseData()
-// ---------------------------------------------------------
-//
-void CDrmUdtHandler::ReleaseData()
-    {
-    LOG( _L("CDrmUdtHandler::ReleaseData") );
-    }
-
-// ---------------------------------------------------------
-// CDrmUdtHandler::OverallDataSize()
-// ---------------------------------------------------------
-//
-TInt CDrmUdtHandler::OverallDataSize()
-    {
-    LOG( _L("CDrmUdtHandler::OverallDataSize") );
-    return iUdtRequest->Des().Size();
-    }
-
-// ---------------------------------------------------------
-// CDrmUdtHandler::Reset()
-// ---------------------------------------------------------
-//
-TInt CDrmUdtHandler::Reset()
-    {
-    LOG( _L("CDrmUdtHandler::Reset") );
-    return KErrNone;
-    }
-
-// ---------------------------------------------------------
-// CDrmUdtHandler::ReadUdtDataL
-//
-// ---------------------------------------------------------
-//
-void CDrmUdtHandler::ReadUdtDataL(
-    TDes8& aTargetSerialNumber,
-    TInt& aUdtKeyVersion,
-    TDes8& aEncryptedRdbData )
-    {
-    RDRMRightsClient rightsClient;
-    HBufC* serialNum = NULL;
-
-    LOG( _L("CDrmUdtHandler::ReadUdtDataL") );
-    User::LeaveIfError( rightsClient.Connect() );
-    CleanupClosePushL( rightsClient );
-    serialNum = SerialNumberL();
-    
-    aTargetSerialNumber.Copy( *serialNum );
-
-    aUdtKeyVersion = 0;
-    User::LeaveIfError( rightsClient.GetUdtData( aEncryptedRdbData ) );
-    if( !aEncryptedRdbData.Length() )
-        {
-        User::Leave( KErrNotFound );
-        }
-    CleanupStack::PopAndDestroy(); // rightsClient
-    }
-    
-// ---------------------------------------------------------
-// CDrmUdtHandler::ReadUdtDataL
-//
-// ---------------------------------------------------------
-//    
-HBufC* CDrmUdtHandler::SerialNumberL()
-    {
-    TInt error( KErrNone );
-    TInt count( 0 );
-    TInt count2( 0 );
-    TUint32 caps( 0 );
-    HBufC* imei = NULL;
-
-#ifndef __WINS__
-    LOG( _L("CDrmUdtHandler::SerialNumberL") );
-
-    RTelServer etelServer;
-    RMobilePhone phone;
-    
-    for ( TUint8 i = 0; i < 3; ++i )
-        {
-        error = etelServer.Connect();
-        if ( error )
-            {
-            User::After( TTimeIntervalMicroSeconds32( 100000 ) );
-            }
-        }
-    
-    User::LeaveIfError( error );
-    CleanupClosePushL( etelServer );
-
-    LOG( _L("  Connected to ETEL") );
-    
-    User::LeaveIfError( etelServer.LoadPhoneModule( KMmTsyModuleName ) );
-    
-    LOG( _L("  Phone Module loaded") );
-
-    TUnloadModule unload;
-    unload.iServer = &etelServer;
-    unload.iName = &KMmTsyModuleName;
-    
-    TCleanupItem item( DoUnloadPhoneModule, &unload );
-    CleanupStack::PushL( item );
-    
-    User::LeaveIfError( etelServer.EnumeratePhones( count ) );
-    
-    LOG( _L("  Phones enumerated") );
-
-    for ( count2 = 0; count2 < count; ++count2 )
-        {
-        RTelServer::TPhoneInfo phoneInfo;
-        User::LeaveIfError( etelServer.GetTsyName( count2, phoneInfo.iName ) );
-        
-        LOG( _L("    Got TSY module") );
-        LOG( phoneInfo.iName );
-        if ( phoneInfo.iName.CompareF( KMmTsyModuleName ) == 0 )
-            {
-            User::LeaveIfError( etelServer.GetPhoneInfo( count2, phoneInfo ) );
-            LOG( _L("    Got phone info") );
-            User::LeaveIfError( phone.Open( etelServer, phoneInfo.iName ) );
-            LOG( _L("    Opened phone") );
-            CleanupClosePushL( phone );
-            break;
-            }
-        }
-        
-    if ( count2 == count )
-        {
-        // Not found.
-        LOG( _L("  No phone found") );
-        User::Leave( KErrNotFound );
-        }
-    
-    LOG( _L("  Got phone") );
-
-    User::LeaveIfError( phone.GetIdentityCaps( caps ) );
-
-    LOG( _L("  Got Caps") );
-
-    if ( caps & RMobilePhone::KCapsGetSerialNumber )
-        {
-        RMobilePhone::TMobilePhoneIdentityV1 id;
-        TRequestStatus status;
-        
-        phone.GetPhoneId( status, id );
-        User::WaitForRequest( status );
-        
-        User::LeaveIfError( status.Int() );
-        
-        imei = id.iSerialNumber.AllocL();
-        
-        LOG( _L("  Got serial number") );
-
-        CleanupStack::PopAndDestroy( 3 ); // phone, item, etelServer
-        
-        return imei;
-        }
-    
-    User::Leave( KErrNotFound );
-    
-    // Never happens...
-    return imei;
-
-#else
-    _LIT( KDefaultSerialNumber, "123456789123456789" );
-    imei = KDefaultSerialNumber().AllocL();
-        
-    return imei;
-#endif
-    }
- 
-
--- a/omadrm/group/bld.inf	Wed Apr 14 16:15:06 2010 +0300
+++ b/omadrm/group/bld.inf	Tue Apr 27 16:56:11 2010 +0300
@@ -41,37 +41,6 @@
 ../drmplugins/drmromtm/loc/RoMtmUi.loc MW_LAYER_LOC_EXPORT_PATH( romtmui.loc )
 
 
-// CMLA RnD keys
-../drmengine/keystorage/data/CMLA/DevicePrivateKey.der /epoc32/winscw/c/private/101F51F2/PKI/96b7db19a4d05a4bc8e3a51c885088e679354469/DevicePrivateKey.der
-../drmengine/keystorage/data/CMLA/DeviceCert.der /epoc32/winscw/c/private/101F51F2/PKI/96b7db19a4d05a4bc8e3a51c885088e679354469/DeviceCert.der
-../drmengine/keystorage/data/CMLA/SigningCert00.der /epoc32/winscw/c/private/101F51F2/PKI/96b7db19a4d05a4bc8e3a51c885088e679354469/SigningCert00.der
-../drmengine/keystorage/data/CMLA/SigningCert01.der /epoc32/winscw/c/private/101F51F2/PKI/96b7db19a4d05a4bc8e3a51c885088e679354469/SigningCert01.der
-
-../drmengine/keystorage/data/CMLA/DevicePrivateKey.der /epoc32/release/winscw/udeb/z/private/101F51F2/PKI/96b7db19a4d05a4bc8e3a51c885088e679354469/DevicePrivateKey.der
-../drmengine/keystorage/data/CMLA/DeviceCert.der /epoc32/release/winscw/udeb/z/private/101F51F2/PKI/96b7db19a4d05a4bc8e3a51c885088e679354469/DeviceCert.der
-../drmengine/keystorage/data/CMLA/SigningCert00.der /epoc32/release/winscw/udeb/z/private/101F51F2/PKI/96b7db19a4d05a4bc8e3a51c885088e679354469/SigningCert00.der
-../drmengine/keystorage/data/CMLA/SigningCert01.der /epoc32/release/winscw/udeb/z/private/101F51F2/PKI/96b7db19a4d05a4bc8e3a51c885088e679354469/SigningCert01.der
-
-../drmengine/keystorage/data/CMLA/DevicePrivateKey.der /epoc32/release/winscw/urel/z/private/101F51F2/PKI/96b7db19a4d05a4bc8e3a51c885088e679354469/DevicePrivateKey.der
-../drmengine/keystorage/data/CMLA/DeviceCert.der /epoc32/release/winscw/urel/z/private/101F51F2/PKI/96b7db19a4d05a4bc8e3a51c885088e679354469/DeviceCert.der
-../drmengine/keystorage/data/CMLA/SigningCert00.der /epoc32/release/winscw/urel/z/private/101F51F2/PKI/96b7db19a4d05a4bc8e3a51c885088e679354469/SigningCert00.der
-../drmengine/keystorage/data/CMLA/SigningCert01.der /epoc32/release/winscw/urel/z/private/101F51F2/PKI/96b7db19a4d05a4bc8e3a51c885088e679354469/SigningCert01.der
-
-../drmengine/keystorage/data/CMLA/DevicePrivateKey.der /epoc32/data/z/private/101F51F2/PKI/96b7db19a4d05a4bc8e3a51c885088e679354469/DevicePrivateKey.der
-../drmengine/keystorage/data/CMLA/DeviceCert.der /epoc32/data/z/private/101F51F2/PKI/96b7db19a4d05a4bc8e3a51c885088e679354469/DeviceCert.der
-../drmengine/keystorage/data/CMLA/SigningCert00.der /epoc32/data/z/private/101F51F2/PKI/96b7db19a4d05a4bc8e3a51c885088e679354469/SigningCert00.der
-../drmengine/keystorage/data/CMLA/SigningCert01.der /epoc32/data/z/private/101F51F2/PKI/96b7db19a4d05a4bc8e3a51c885088e679354469/SigningCert01.der
-
-// Default UDT Key
-#ifdef __DRM_USER_DATA_TRANSFER
-../drmengine/keystorage/data/UdtCertificate.der /epoc32/winscw/c/private/101F51F2/PKI/UdtCertificate.der
-
-../drmengine/keystorage/data/UdtCertificate.der /epoc32/release/winscw/udeb/z/private/101F51F2/PKI/UdtCertificate.der
-../drmengine/keystorage/data/UdtCertificate.der /epoc32/release/winscw/urel/z/private/101F51F2/PKI/UdtCertificate.der
-
-../drmengine/keystorage/data/UdtCertificate.der /epoc32/data/z/private/101F51F2/PKI/UdtCertificate.der
-#endif
-
 // backup_registration.xml
 ../drmengine/group/backup_registration.xml /epoc32/winscw/c/private/101F51F2/backup_registration.xml
 ../drmengine/group/backup_registration.xml /epoc32/data/z/private/101F51F2/backup_registration.xml
@@ -127,10 +96,6 @@
 ../drmengine/group/DcfRepSrv.mmp
 ../drmengine/group/ROAPHandler.mmp
 
-#ifdef __DRM_USER_DATA_TRANSFER
-../drmplugins/drmudtmodule/group/DrmUdtModule.mmp
-#endif
-
 
 // DRMService API
 ../drmengine/group/DrmServiceAPI.mmp
--- a/omadrm/rom/DRM5.iby	Wed Apr 14 16:15:06 2010 +0300
+++ b/omadrm/rom/DRM5.iby	Tue Apr 27 16:56:11 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -57,17 +57,12 @@
 file=ABI_DIR\BUILD_DIR\DrmServerInterfaces.DLL      SHARED_LIB_DIR\DrmServerInterfaces.DLL
 file=ABI_DIR\BUILD_DIR\DrmParsers.DLL               SHARED_LIB_DIR\DrmParsers.DLL
 
-// DRM Rights server 
+// DRM Rights server
 file=ABI_DIR\BUILD_DIR\RightsServer.EXE             PROGRAMS_DIR\RightsServer.EXE
 
 // DRM Service API
 file=ABI_DIR\BUILD_DIR\DrmServiceAPI.dll            SHARED_LIB_DIR\DrmServiceAPI.dll
 
-// DRM UDT Module
-#ifdef __DRM_USER_DATA_TRANSFER
-file=ABI_DIR\BUILD_DIR\DRMUDTMODULE.DLL                SHARED_LIB_DIR\DRMUDTMODULE.DLL
-#endif
-
 // DRM recognizer for protected contents
 #ifdef __DRM
 //S60_INTEGRATION file=ABI_DIR\BUILD_DIR\RECDRM.DLL         RECOGNISERS_DIR\RECDRM.DLL
@@ -76,7 +71,7 @@
 ECOM_PLUGIN(RECDRM.DLL,101F51F4.RSC)
 
 // RFS exclude list
-data=DATAZ_\private\102073ea\excludes\101F51F2.exc	private\102073ea\excludes\101F51F2.exc
+data=DATAZ_\private\102073ea\excludes\101F51F2.exc      private\102073ea\excludes\101F51F2.exc
 
 #endif
 
@@ -142,23 +137,11 @@
 // #include <DRMEncryptor.iby>
 // #include <DRMEncryptorResources.iby>
 
-// Default CMLA RnD Test Keys
-
-data=ZPRIVATE\101F51F2\PKI\96b7db19a4d05a4bc8e3a51c885088e679354469\DevicePrivateKey.der PRIVATE\101F51F2\PKI\96b7db19a4d05a4bc8e3a51c885088e679354469\DevicePrivateKey.der
-data=ZPRIVATE\101F51F2\PKI\96b7db19a4d05a4bc8e3a51c885088e679354469\DeviceCert.der PRIVATE\101F51F2\PKI\96b7db19a4d05a4bc8e3a51c885088e679354469\DeviceCert.der
-data=ZPRIVATE\101F51F2\PKI\96b7db19a4d05a4bc8e3a51c885088e679354469\SigningCert00.der PRIVATE\101F51F2\PKI\96b7db19a4d05a4bc8e3a51c885088e679354469\SigningCert00.der
-data=ZPRIVATE\101F51F2\PKI\96b7db19a4d05a4bc8e3a51c885088e679354469\SigningCert01.der PRIVATE\101F51F2\PKI\96b7db19a4d05a4bc8e3a51c885088e679354469\SigningCert01.der
+// Backup registration
+data=ZPRIVATE\101F51F2\backup_registration.xml  PRIVATE\101F51F2\backup_registration.xml
 
-// Default UDT key
-#ifdef __DRM_USER_DATA_TRANSFER
-data=ZPRIVATE\101F51F2\PKI\UdtCertificate.der	PRIVATE\101F51F2\PKI\UdtCertificate.der
-#endif
-
-// Backup registration
-data=ZPRIVATE\101F51F2\backup_registration.xml	PRIVATE\101F51F2\backup_registration.xml
-
-// SIS stub for agent upgrades	
-data=ZSYSTEM\Install\OmaDrm_Stub.SIS			\system\install\OmaDrm_Stub.SIS
+// SIS stub for agent upgrades
+data=ZSYSTEM\Install\OmaDrm_Stub.SIS                    \system\install\OmaDrm_Stub.SIS
 
 #endif // DRM
 #endif // __DRM5_IBY__