omadrm/drmengine/server/src/DRMRightsClient.cpp
branchRCL_3
changeset 12 8a03a285ab14
parent 0 95b198f216e5
child 16 457cd4423b8c
--- a/omadrm/drmengine/server/src/DRMRightsClient.cpp	Fri Mar 12 15:43:46 2010 +0200
+++ b/omadrm/drmengine/server/src/DRMRightsClient.cpp	Mon Mar 15 12:41:43 2010 +0200
@@ -21,16 +21,16 @@
 #include <etelmm.h>
 #include "DRMRightsClient.h"
 #include "DRMEngineClientServer.h"
-#include "DRMPermission.h"
-#include "DRMAsset.h"
+#include "DrmPermission.h"
+#include "DrmAsset.h"
 #include "drmlog.h"
 
 #ifdef __DRM_FULL
-#include "RDRMHelper.h"
+#include "rdrmhelper.h"
 #endif
 
 // EXTERNAL DATA STRUCTURES
-// EXTERNAL FUNCTION PROTOTYPES  
+// EXTERNAL FUNCTION PROTOTYPES
 // CONSTANTS
 // MACROS
 
@@ -51,45 +51,45 @@
 struct TDRMFileDeletion
     {
     TDRMFileDeletion() : iName( KNullDesC ) {};
-    ~TDRMFileDeletion() 
+    ~TDRMFileDeletion()
         {
         if ( iName.Length() )
             {
             iFs.Delete( iName );
             }
-        
+
         iFs.Close();
         }
-        
+
     RFs iFs;
     TFileName iName;
     };
 
 template< class T > struct RDRMArrayReset
     {
-    RDRMArrayReset( T& aItem ) : iItem( aItem ), 
+    RDRMArrayReset( T& aItem ) : iItem( aItem ),
                                  iCleanup( ResetAndDestroy, ( TAny* )this ) {};
     ~RDRMArrayReset() { };
-    void PushL() 
+    void PushL()
         {
         CleanupStack::PushL( iCleanup );
         };
-    
-    static void ResetAndDestroy( TAny* aSelf ) 
+
+    static void ResetAndDestroy( TAny* aSelf )
         {
-        ( ( RDRMArrayReset< T >* )( aSelf ) )->iItem.ResetAndDestroy(); 
+        ( ( RDRMArrayReset< T >* )( aSelf ) )->iItem.ResetAndDestroy();
         ( ( RDRMArrayReset< T >* )( aSelf ) )->iItem.Close();
         };
-    
-    private:        
+
+    private:
         RDRMArrayReset(); // prohibit
-    
+
     private:
         T& iItem;
         TCleanupItem iCleanup;
-        
+
     };
-    
+
 // LOCAL FUNCTION PROTOTYPES
 
 // FORWARD DECLARATIONS
@@ -108,7 +108,7 @@
     iPtr( NULL )
     {
     }
-    
+
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::~RDRMRightsClient
 // Destructor.
@@ -116,7 +116,7 @@
 //
 EXPORT_C RDRMRightsClient::~RDRMRightsClient()
     {
-    }    
+    }
 
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::Connect
@@ -126,45 +126,45 @@
 EXPORT_C TInt RDRMRightsClient::Connect()
     {
     TInt ret = KErrNone;
-    TUint8 count = 0;    
-    
-    const TVersion requiredVersion( 
+    TUint8 count = 0;
+
+    const TVersion requiredVersion(
         DRMEngine::KServerMajorVersion,
         DRMEngine::KServerMinorVersion,
         DRMEngine::KServerBuildVersion );
-    
+
     FOREVER
         {
         DRMLOG( _L( "RDRMRightsClient::Connect(): Create a new session" ) );
         ret = CreateSession( DRMEngine::KServerName,
-                             requiredVersion, 
+                             requiredVersion,
                              KMaxMessageSlots );
-                         
+
         if ( ret == KErrNotFound && count < KStartupCount )
             {
             ret = StartServer();
             if ( ret )
                 {
-                break;   
+                break;
                 }
-            
+
             ++count;
             }
         else
             {
-            break;   
+            break;
             }
         }
 
 #ifdef __DRM_FULL
-    // startup code, if it starts it starts if not it will be tried again.        
+    // startup code, if it starts it starts if not it will be tried again.
     RDRMHelper helper;
     TInt ignore = helper.Connect(); // Start HelperServer
-    helper.Close();  
-#endif        
+    helper.Close();
+#endif
 
     DRMLOG2( _L( "RDRMRightsClient::Connect(): Result: %d" ), ret );
-    
+
     return ret;
     }
 
@@ -173,7 +173,7 @@
 // Closes the connection to the server.
 // -----------------------------------------------------------------------------
 //
-EXPORT_C void RDRMRightsClient::Close() 
+EXPORT_C void RDRMRightsClient::Close()
     {
     DRMLOG( _L( "RDRMRightsClient::Close()" ) );
     RHandleBase::Close();
@@ -182,14 +182,14 @@
 EXPORT_C TInt RDRMRightsClient::StartServer()
     {
     DRMLOG( _L( "RDRMRightsClient::StartServer()" ) );
-    
+
     RSemaphore semaphore;
     RSemaphore semaphore2;
     TFindServer server( DRMEngine::KServerName );
     TFullName name;
     RProcess process;
     TInt error = KErrNone;
- 
+
     // "local" semaphore
      error = semaphore2.CreateGlobal( KRightsServerStarterSemaphore,   // name
                                     1 ,              // count
@@ -198,7 +198,7 @@
     if ( error == KErrAlreadyExists )
         {
         error = semaphore2.OpenGlobal( KRightsServerStarterSemaphore );
-        }  
+        }
 
 
     // Semaphore not created or opened, don't need to close
@@ -206,61 +206,61 @@
         {
         return error;
         }
-          
-    // Server updated semaphore      
+
+    // Server updated semaphore
     error = semaphore.CreateGlobal( DRMEngine::KDRMSemaphore,   // name
                                     0 ,              // count
                                     EOwnerThread );  // owner
-    
+
     if ( error == KErrAlreadyExists )
         {
         error = semaphore.OpenGlobal( DRMEngine::KDRMSemaphore );
-        }  
-  
+        }
+
     // Semaphore not created or opened, don't need to close
     if( error )
         {
         semaphore2.Close();
         return error;
         }
-        
+
     // Wait until server has done all its things.
     semaphore2.Wait();
-                
+
     // Check if the server is already running.
     error = server.Next( name );
-    
+
     if ( !error )
         {
         // Yep, it's already running.
         error = KErrNone;
         }
-    else 
+    else
         {
         error = process.Create( KServerFileName,
                                 KNullDesC );
-        
+
         if ( !error )
             {
             User::After( 1000 );
-            
+
             process.Resume();
             process.Close();
-            
+
             // Wait here for the server process startup to complete
             // server will signal the global semaphore
             semaphore.Wait();
             }
         }
-        
-    // Close both semaphores and signal the "local" one.    
-    semaphore.Close();         
+
+    // Close both semaphores and signal the "local" one.
+    semaphore.Close();
     semaphore2.Signal();
-    semaphore2.Close();   
-        
+    semaphore2.Close();
+
     DRMLOG2( _L( "RDRMRightsClient::StartServer(): %d" ), error );
-    return error; 
-    
+    return error;
+
     }
 
 // -----------------------------------------------------------------------------
@@ -270,21 +270,21 @@
 //
 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 
+                                  const CDRMPermission& aRightsObject,
+                                  const TDesC8& aCID, // Content-ID
                                   TDRMUniqueID& aID ) // Unique ID, out-parameter
     {
     DRMLOG( _L( "RDRMRightsClient::AddRecord" ) );
     TInt error = KErrArgument;
-    
+
     // Check the parameters.
     if ( aCEK.Length() )
         {
-        
+
         HBufC8* rightsData = NULL;
         TRAP( error, rightsData = aRightsObject.ExportL() );
         TInt size = aRightsObject.Size();
-        
+
         if ( rightsData && size > 0 )
             {
             // For C/S communications.
@@ -292,21 +292,21 @@
             TPtr8 uid( reinterpret_cast< TUint8* >( &aID ),
                        0,
                        sizeof( TDRMUniqueID ) );
-        
+
             rightsObject.Set( const_cast< TUint8* >( rightsData->Ptr() ),
                               size,
                               size );
-        
-              
+
+
             // Send the message.
-            error = SendReceive( DRMEngine::EAddRecord, 
+            error = SendReceive( DRMEngine::EAddRecord,
                              TIpcArgs( &aCID, &rightsObject, &aCEK, &uid ) );
-        
+
             delete rightsData;
             rightsData = NULL;
             }
         }
-    
+
     DRMLOG2( _L( "RDRMRightsClient::AddRecord: %d" ), error );
     return error;
     }
@@ -325,33 +325,33 @@
     TDRMUniqueID& aID ) // Unique ID, out-parameter
     {
     DRMLOG( _L( "RDRMRightsClient::AddProtectedRecord" ) );
-    
-    TInt error = KErrNone;                                                       
-    TInt message = DRMEngine::EAddProtectedRecord;                                                                                    
-    HBufC8* rightsData = NULL;                                                   
-    TInt size = aRightsObject.Size();                                            
-    TPtr8 rightsObject( NULL, 0 );                                               
-    TPtr8 uid( reinterpret_cast< TUint8* >( &aID ), 0,                           
-        sizeof( TDRMUniqueID ) );                                                
-    TPtr8 key( NULL, 0 );                                                        
-                                                                                 
-    TRAP( error, rightsData = aRightsObject.ExportL() );                                        
-    if ( !error ) 
-        {    
-        rightsObject.Set( const_cast< TUint8* >( rightsData->Ptr() ), size,          
+
+    TInt error = KErrNone;
+    TInt message = DRMEngine::EAddProtectedRecord;
+    HBufC8* rightsData = NULL;
+    TInt size = aRightsObject.Size();
+    TPtr8 rightsObject( NULL, 0 );
+    TPtr8 uid( reinterpret_cast< TUint8* >( &aID ), 0,
+        sizeof( TDRMUniqueID ) );
+    TPtr8 key( NULL, 0 );
+
+    TRAP( error, rightsData = aRightsObject.ExportL() );
+    if ( !error )
+        {
+        rightsObject.Set( const_cast< TUint8* >( rightsData->Ptr() ), size,
             size );
-                                                                            
-        if ( aDomainRecord )                                                         
+
+        if ( aDomainRecord )
             {
             message = DRMEngine::EAddDomainRecord;
-            }                                                                        
+            }
         error = SendReceive( message, TIpcArgs( &aCID, &rightsObject, &aProtectedCek, &uid ) );
 
         delete rightsData;
         rightsData = NULL;
         }
-    DRMLOG2( _L( "RDRMRightsClient::AddProtectedRecord: %d" ), error );          
-    return error; 
+    DRMLOG2( _L( "RDRMRightsClient::AddProtectedRecord: %d" ), error );
+    return error;
     }
 
 // -----------------------------------------------------------------------------
@@ -365,28 +365,28 @@
     {
     DRMLOG( _L( "RDRMRightsClient::GetDBEntries" ) );
     if( aId.Length() )
-        {   
+        {
         // Temporary file name from the server.
         TDRMFileDeletion item;
-        
+
         // Make sure that the array is empty.
         aRightsList.ResetAndDestroy();
-        
+
         // For file operations. Destructor of TDRMFileDeletion
         // deletes the file & closes the session.
-        User::LeaveIfError( item.iFs.Connect() );  
-                
-        User::LeaveIfError( SendReceive( DRMEngine::EGetEntryList, 
+        User::LeaveIfError( item.iFs.Connect() );
+
+        User::LeaveIfError( SendReceive( DRMEngine::EGetEntryList,
                                          TIpcArgs( &item.iName, &aId ) ) );
-        
+
         // Convert the file to a list.
         FileToListL( item.iFs, item.iName, aRightsList );
-        
-        DRMLOG( _L( "RDRMRightsClient::GetDBEntries ok" ) );    
-    
+
+        DRMLOG( _L( "RDRMRightsClient::GetDBEntries ok" ) );
+
         return;
         }
-    
+
     // Invalid parameter.
     User::Leave( KErrArgument );
     }
@@ -400,7 +400,7 @@
                                                  const TDRMUniqueID& aUniqueID )
     {
     DRMLOG( _L( "RDRMRightsClient::GetDbEntryL" ) );
-    
+
     CDRMPermission* permission = NULL;
     TInt size = 0;
     TPckg<TInt> package( size );
@@ -414,12 +414,12 @@
         size );
     User::LeaveIfError( SendReceive( DRMEngine::EGetPreparedData,
         TIpcArgs( &objectPkg) ) );
-    
+
     permission = CDRMPermission::NewLC();
     permission->ImportL( rightsData->Des() );
     CleanupStack::Pop(); // permission
     CleanupStack::PopAndDestroy(); // Rights data
-    
+
     DRMLOG( _L( "RDRMRightsClient::GetDbEntryL ok" ) );
     return permission;
     }
@@ -432,16 +432,16 @@
 EXPORT_C TInt RDRMRightsClient::DeleteDbEntry( const TDesC8& aContentID )
     {
     DRMLOG( _L( "RDRMRightsClient::DeleteDbEntry with CID" ) );
-    
+
     TInt error = KErrArgument;
-    
+
     // Check the parameter.
     if ( aContentID.Length() )
         {
-        return SendReceive( DRMEngine::EDeleteWithCID, 
+        return SendReceive( DRMEngine::EDeleteWithCID,
                             TIpcArgs( NULL, NULL, &aContentID ) );
         }
-    
+
     return error;
     }
 
@@ -454,26 +454,26 @@
                                                const TDRMUniqueID& aUniqueID )
     {
     DRMLOG( _L( "RDRMRightsClient::DeleteDbEntry with CID & UID" ) );
-    
+
     if ( aContentID.Length() )
         {
         // Something to do.
         // Put aUniqueID inside a descriptor.
         // Works even if its typedef is changed.
-        TPtrC8 uid( reinterpret_cast< TUint8* >( 
+        TPtrC8 uid( reinterpret_cast< TUint8* >(
                         const_cast< TDRMUniqueID* >( &aUniqueID ) ),
                     sizeof( TDRMUniqueID ) );
-        
-        return SendReceive( DRMEngine::EDeleteRO, 
+
+        return SendReceive( DRMEngine::EDeleteRO,
                             TIpcArgs( &uid, NULL, NULL, &aContentID ) );
         }
-    
+
     return KErrArgument;
     }
 
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::ExportContentIDList
-// Overloaded method: requests all content IDs to be put to a file. 
+// 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.
 // -----------------------------------------------------------------------------
@@ -481,15 +481,15 @@
 EXPORT_C TInt RDRMRightsClient::ExportContentIDList( TDes& aFileName )
     {
     DRMLOG( _L( "RDRMRightsClient::ExportContentIDLis" ) );
-    
-    return SendReceive( DRMEngine::EExportCIDs, 
+
+    return SendReceive( DRMEngine::EExportCIDs,
                         TIpcArgs( &aFileName ) );
-    
+
     }
 
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::ExportContentIDList
-// Overloaded method: requests all content IDs to be put to a file, 
+// Overloaded method: requests all content IDs to be put to a file,
 // and then converts the file into RPointerArray.
 // -----------------------------------------------------------------------------
 //
@@ -498,7 +498,7 @@
     DRMLOG( _L( "RDRMRightsClient::ExportContentIDList to array" ) );
     TFileName name;
     aCIDList.ResetAndDestroy();
-    
+
     TInt error = ExportContentIDList( name );
     if ( !error )
         {
@@ -511,14 +511,14 @@
                 {
                 aCIDList.ResetAndDestroy();
                 }
-            
+
             fs.Delete( name );
             fs.Close();
             }
         }
-    
+
     DRMLOG2( _L( "RDRMRightsClient::ExportContentIDList: %d" ), error );
-            
+
     return error;
     }
 
@@ -540,11 +540,11 @@
     SendReceive( DRMEngine::EGetKey,
         TIpcArgs( aIntent, const_cast<TDesC8*>(&aContentID), &aKey ),
         status );
-        
+
     User::WaitForRequest( status );
 
     DRMLOG2( _L( "RDRMRightsClient::GetDecryptionKey: %d" ), status.Int() );
-    
+
     return status.Int();
     }
 
@@ -560,16 +560,16 @@
     {
     TInt error = KErrNone;
     TInt size = 0;
-    
+
     TPckg<TInt> package( size );
     TPckg<TUint32> package2( aRejection );
-        
+
     DRMLOG( _L( "RDRMRightsClient::CheckRights" ) );
     error = SendReceive( DRMEngine::ECheckRights, TIpcArgs( aIntent,
         &aContentID, &package, &package2 ) );
-        
+
     DRMLOG2( _L( "RDRMRightsClient::CheckRights: %d" ), error );
-    
+
     return error;
     }
 
@@ -587,10 +587,10 @@
     TInt r;
     TInt size = 0;
     TPckg<TInt> package( size );
-    TPckg<TUint32> package2( aRejection );    
+    TPckg<TUint32> package2( aRejection );
     CDRMPermission* permission = NULL;
     HBufC8* buffer = NULL;
-    
+
     DRMLOG( _L( "RDRMRightsClient::GetActiveRightsL" ) );
     r = SendReceive( DRMEngine::ECheckRights, TIpcArgs( aIntent, &aContentID,
         &package, &package2 ) );
@@ -613,7 +613,7 @@
         {
         User::Leave( r );
         }
-    
+
     DRMLOG( _L( "RDRMRightsClient::GetActiveRightsL: done" ) );
     return permission;
     }
@@ -631,21 +631,21 @@
 
     TInt count = 0;
     TInt error = KErrNone;
-    
+
     TPtr8 ptr( reinterpret_cast< TUint8* >( &count ),
-               0, 
+               0,
                sizeof( TInt ) );
-    
-    error = SendReceive( DRMEngine::ECount, 
+
+    error = SendReceive( DRMEngine::ECount,
                          TIpcArgs( &ptr ) );
-    
+
     if ( !error )
         {
         error = count;
         }
-    
+
     DRMLOG2( _L( "RDRMRightsClient::Count: %d" ), error );
-    
+
     return error;
     }
 
@@ -657,11 +657,11 @@
 EXPORT_C TInt RDRMRightsClient::DeleteAll()
     {
     DRMLOG( _L( "RDRMRightsClient::DeleteAll" ) );
-   
-    TInt error = SendReceive( DRMEngine::EDeleteAll, TIpcArgs( NULL ) ); 
+
+    TInt error = SendReceive( DRMEngine::EDeleteAll, TIpcArgs( NULL ) );
 
     DRMLOG2( _L( "RDRMRightsClient::DeleteAll: %d" ), error  );
-    
+
     return error;
     }
 
@@ -670,13 +670,13 @@
 // Consume the right with specific intent and contentID
 // -----------------------------------------------------------------------------
 //
-EXPORT_C TInt RDRMRightsClient::Consume( const TInt aIntent, 
+EXPORT_C TInt RDRMRightsClient::Consume( const TInt aIntent,
                                          const TDesC8& aContentID )
     {
     TInt error = KErrNone;
     DRMLOG( _L( "RDRMRightsClient::Consume" ) );
-   
-    error = SendReceive( DRMEngine::EConsume, 
+
+    error = SendReceive( DRMEngine::EConsume,
                          TIpcArgs( aIntent, &aContentID ) );
 
     DRMLOG2( _L( "RDRMRightsClient::Consume: %d" ), error  );
@@ -688,13 +688,13 @@
 // Check if Consume is possibke
 // -----------------------------------------------------------------------------
 //
-EXPORT_C TInt RDRMRightsClient::CheckConsume( const TInt aIntent, 
+EXPORT_C TInt RDRMRightsClient::CheckConsume( const TInt aIntent,
                                               const TDesC8& aContentID )
     {
     TInt error = KErrNone;
     DRMLOG( _L( "RDRMRightsClient::CheckConsume" ) );
-   
-    error = SendReceive( DRMEngine::ECheckConsume, 
+
+    error = SendReceive( DRMEngine::ECheckConsume,
                          TIpcArgs( aIntent, &aContentID ) );
 
     DRMLOG2( _L( "RDRMRightsClient::CheckConsume: %d" ), error  );
@@ -717,7 +717,7 @@
 
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::
-// 
+//
 // -----------------------------------------------------------------------------
 //
 EXPORT_C TInt RDRMRightsClient::ForwardLockURI( HBufC8*& aURI )
@@ -726,20 +726,20 @@
     TBuf8< DRMEngine::KMaxOmaV1CIDLength > buf;
     TInt error = SendReceive( DRMEngine::EGetFLUri,
                               TIpcArgs( &buf ) );
-                              
+
     if ( error )
         {
         aURI = NULL;
         return error;
         }
-        
+
     aURI = buf.Alloc();
 
     if ( aURI )
         {
         return KErrNone;
         }
-        
+
     return KErrNoMemory;
     }
 
@@ -749,23 +749,23 @@
 // Add domain rights object xml representation to the rdb
 // -----------------------------------------------------------------------------
 //
-EXPORT_C TInt RDRMRightsClient::AddDomainRO( const TDesC8& aRoId, 
+EXPORT_C TInt RDRMRightsClient::AddDomainRO( const TDesC8& aRoId,
                                              const TDesC8& aXmlData )
     {
     DRMLOG( _L( "RDRMRightsClient::AddDomainRO" ) );
     TInt error = KErrArgument;
-    
+
     // Check the parameters.
     if ( aRoId.Length() && aXmlData.Length() )
-        {     
+        {
         // Send the message.
-        error = SendReceive( DRMEngine::EAddDomainRO, 
+        error = SendReceive( DRMEngine::EAddDomainRO,
                              TIpcArgs( &aRoId, &aXmlData) );
         }
-        
+
     DRMLOG2( _L( "RDRMRightsClient::AddDomainRO: %d" ), error );
-    return error;    
-    };        
+    return error;
+    };
 
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::GetDomainROL
@@ -775,37 +775,37 @@
 EXPORT_C HBufC8* RDRMRightsClient::GetDomainROL( const TDesC8& aRoId )
     {
     DRMLOG( _L( "RDRMRightsClient::GetDomainROL" ) );
-    
+
     // Check the parameter.
     if ( aRoId.Length() )
         {
         TInt size = 0;
         TPckg<TInt> package( size );
-        
+
         // Call the server. Throw an exception in case of an error.
-        User::LeaveIfError( 
-            SendReceive( DRMEngine::EGetDomainRO, 
+        User::LeaveIfError(
+            SendReceive( DRMEngine::EGetDomainRO,
                          TIpcArgs( &package, &aRoId ) ) );
 
         HBufC8* roData = HBufC8::NewMaxLC( size );
-        
+
         // Package 'object' into TPtr8.
         TPtr8 objectPkg( const_cast< TUint8* >( roData->Ptr() ),
                          size,
                          size );
 
-        User::LeaveIfError( 
-            SendReceive( DRMEngine::EGetPreparedData, 
+        User::LeaveIfError(
+            SendReceive( DRMEngine::EGetPreparedData,
                          TIpcArgs( &objectPkg) ) );
-        CleanupStack::Pop( roData ); // roData                 
+        CleanupStack::Pop( roData ); // roData
         return roData;
         }
-    
+
     User::Leave( KErrArgument );
-    
+
     // Never reached.
-    return NULL;    
-    }; 
+    return NULL;
+    };
 
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::GetDomainROL
@@ -823,7 +823,7 @@
     TInt roSize;
     TInt offset;
 
-        
+
     DRMLOG(_L("RDRMRightsClient::GetDomainRoForCidL"));
     User::LeaveIfError(SendReceive(DRMEngine::EGetDomainRoForCid,
         TIpcArgs(&aContentId, &pkg)));
@@ -839,64 +839,64 @@
         while (offset < size)
             {
             Mem::Copy( &roSize, ptr.Ptr()+offset, sizeof(TInt) );
-            offset += sizeof (TInt); 
+            offset += sizeof (TInt);
             ro = ptr.Mid(offset, roSize).AllocL();
             aRoList.Append(ro);
             offset += roSize;
             }
         CleanupStack::PopAndDestroy();
         }
-    }; 
+    };
 
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::
-// 
+//
 // -----------------------------------------------------------------------------
 //
 EXPORT_C TInt RDRMRightsClient::Encrypt( const TDesC8& aIv,
                        TPtr8& aData,
                        TBool aAddPadding )
     {
-    return SendReceive( DRMEngine::EEncrypt, 
+    return SendReceive( DRMEngine::EEncrypt,
                         TIpcArgs( &aIv, &aData, aAddPadding ) );
-    }                       
+    }
 
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::
-// 
+//
 // -----------------------------------------------------------------------------
 //
 EXPORT_C TInt RDRMRightsClient::Decrypt( const TDesC8& aIv,
                        TPtr8& aData,
                        TBool aRemovePadding )
     {
-    return SendReceive( DRMEngine::EDecrypt, 
+    return SendReceive( DRMEngine::EDecrypt,
                         TIpcArgs( &aIv, &aData, aRemovePadding ) );
-    }                         
+    }
 
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::
-// 
+//
 // -----------------------------------------------------------------------------
 //
 EXPORT_C TInt RDRMRightsClient::InitializeKey( const TDesC8& aContentId )
     {
-    return SendReceive( DRMEngine::EInitializeKey, 
+    return SendReceive( DRMEngine::EInitializeKey,
                         TIpcArgs( &aContentId ) );
     }
 
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::
-// 
+//
 // -----------------------------------------------------------------------------
 //
 EXPORT_C TInt RDRMRightsClient::InitializeGroupKey( const TDesC8& aGroupId,
                                                     const TDesC8& aGroupKey,
                                                     TEncryptionMethod aMethod )
     {
-    return SendReceive( DRMEngine::EInitializeGroupKey, 
+    return SendReceive( DRMEngine::EInitializeGroupKey,
                         TIpcArgs( &aGroupId, &aGroupKey, aMethod ) );
-    }                                            
+    }
 
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::DeleteDomainRO
@@ -906,21 +906,21 @@
 EXPORT_C TInt RDRMRightsClient::DeleteDomainRO( const TDesC8& aRoId )
     {
     DRMLOG( _L( "RDRMRightsClient::DeleteDomainRO" ) );
-    
+
     // Check the parameter.
     if ( aRoId.Length() )
         {
-        return SendReceive( DRMEngine::EDeleteDomainRO, 
+        return SendReceive( DRMEngine::EDeleteDomainRO,
                             TIpcArgs( &aRoId ) );
         }
-    
-    return KErrArgument;    
-    }; 
+
+    return KErrArgument;
+    };
 
 
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::
-// 
+//
 // -----------------------------------------------------------------------------
 //
 EXPORT_C TInt RDRMRightsClient::IsInCache( const TDesC8& aID,
@@ -930,68 +930,68 @@
     DRMLOG( _L( "RDRMRightsClient::IsInCache" ) );
     TPckgC< TTime > timePckg( aTime );
     TPckg< TBool > inCache( aInCache );
-        
+
     return SendReceive( DRMEngine::EIsInCache,
                         TIpcArgs( &aID, &timePckg, &inCache ) );
     }
-    
+
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::
-// 
+//
 // -----------------------------------------------------------------------------
 //
 EXPORT_C TInt RDRMRightsClient::IsInCache( const TDesC8& aID,
                                            TBool& aInCache )
     {
     DRMLOG( _L( "RDRMRightsClient::IsInCache" ) );
-    
+
     TPckg< TBool > inCache( aInCache );
-        
+
     return SendReceive( DRMEngine::EIsInCache,
                         TIpcArgs( &aID, NULL, &inCache ) );
     }
-    
+
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::
-// 
+//
 // -----------------------------------------------------------------------------
 //
 EXPORT_C TInt RDRMRightsClient::AddToCache( const TDesC8& aID,
                                             const TTime& aTime )
     {
     DRMLOG( _L( "RDRMRightsClient::AddToCache" ) );
-    
+
     TPckgC< TTime > timePckg( aTime );
-    
+
     return SendReceive( DRMEngine::EAddToCache,
                         TIpcArgs( &aID, &timePckg ) );
     }
 
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::
-// 
+//
 // -----------------------------------------------------------------------------
 //
 EXPORT_C TInt RDRMRightsClient::AddToCache( const TDesC8& aID )
     {
     DRMLOG( _L( "RDRMRightsClient::AddToCache" ) );
-    
+
     return SendReceive( DRMEngine::EAddToCache,
                         TIpcArgs( &aID, NULL ) );
     }
 
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::DeleteExpiredPermissions
-// 
+//
 // -----------------------------------------------------------------------------
 //
 EXPORT_C void RDRMRightsClient::DeleteExpiredPermissions( TRequestStatus& aStatus )
     {
     DRMLOG( _L( "RDRMRightsClient::DeleteExpiredPermissions" ) );
-    
+
     SendReceive( DRMEngine::EDeleteExpired, aStatus );
     }
- 
+
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::SetEstimatedArrival
 // sets the estimated RO arrival time to the given delta
@@ -1004,13 +1004,13 @@
     TInt error = KErrNone;
 
     TPckg< TTimeIntervalSeconds > delta( aDeltaSeconds );
-    
-    error = SendReceive( DRMEngine::ESetEstimatedArrival, 
+
+    error = SendReceive( DRMEngine::ESetEstimatedArrival,
                          TIpcArgs( &aContentID, &delta ) );
-    
-    return error;    
+
+    return error;
     };
-                                  
+
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::GetEstimatedArrival
 // sets the amount of time in which the RO should arrive in
@@ -1023,14 +1023,14 @@
     TInt error = KErrNone;
 
     TPckg< TTimeIntervalSeconds > delta( aDeltaSeconds );
-    
-    error = SendReceive( DRMEngine::EGetEstimatedArrival, 
+
+    error = SendReceive( DRMEngine::EGetEstimatedArrival,
                          TIpcArgs( &aContentID, &delta ) );
-    
-    return error;     
-    }; 
- 
- 
+
+    return error;
+    };
+
+
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::SetName
 // sets the name.
@@ -1043,18 +1043,18 @@
     return SendReceive( DRMEngine::ESetName,
                         TIpcArgs( &aContentID, &aName ) );
     }
-    
+
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::GetName
 // Gets the name. Two-phase operation.
 // -----------------------------------------------------------------------------
-//    
+//
 EXPORT_C TInt RDRMRightsClient::GetName( const TDesC8& aContentID,
                                          HBufC*& aName )
     {
     DRMLOG( _L( "RDRMRightsClient::GetName" ) );
     TPckgBuf< TInt > size( 0 );
-    
+
     TInt error = SendReceive( DRMEngine::EGetName,
                               TIpcArgs( &aContentID, &size ) );
     if ( !error )
@@ -1073,10 +1073,10 @@
             if ( aName )
                 {
                 TPtr data( aName->Des() );
-                            
+
                 error = SendReceive( DRMEngine::EGetWideData,
                                      TIpcArgs( &data ) );
-                
+
                 if ( error )
                     {
                     delete aName; aName = NULL;
@@ -1088,47 +1088,47 @@
                 }
             }
         }
-        
+
     return error;
     }
 
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::Cancel
 // -----------------------------------------------------------------------------
-//      
+//
 EXPORT_C void RDRMRightsClient::Cancel()
     {
     DRMLOG( _L(" RDRMRightsClient::Cancel" ) );
     SendReceive( DRMEngine::ECancel );
     }
-    
-    
+
+
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::GetUdtData
 // -----------------------------------------------------------------------------
-//   
+//
 EXPORT_C TInt RDRMRightsClient::GetUdtData( TDes8& aUdtData )
     {
     DRMLOG( _L( "RDRMRightsClient::GetUdtData" ) );
-    
+
     TInt error = SendReceive( DRMEngine::EGetUdtData,
                               TIpcArgs( &aUdtData ) );
-        
-    return error;        
-    };        
+
+    return error;
+    };
 
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::InitializeUdt
 // -----------------------------------------------------------------------------
-//   
+//
 EXPORT_C TInt RDRMRightsClient::InitiateUdt( const TDesC8& aKey )
     {
     DRMLOG( _L( "RDRMRightsClient::InitiateUdt" ) );
-    
+
     TInt error = SendReceive( DRMEngine::EInitiateUdt,
-                              TIpcArgs( &aKey ) );     
-    return error;        
-    };         
+                              TIpcArgs( &aKey ) );
+    return error;
+    };
 
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::InitOrphanedContentIdList
@@ -1138,38 +1138,38 @@
                                                       TRequestStatus& aStatus )
     {
     DRMLOG( _L( "RDRMRightsClient::ExportOrphanedContentIdList" ) );
-        
-    SendReceive( DRMEngine::EInitOrphanedList, 
+
+    SendReceive( DRMEngine::EInitOrphanedList,
                  TIpcArgs( aPerformScan ), aStatus );
-                 
-    DRMLOG( _L( "RDRMRightsClient::ExportOrphanedContentIdList done" ) );                        
+
+    DRMLOG( _L( "RDRMRightsClient::ExportOrphanedContentIdList done" ) );
     };
 
 
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::ExportOrphanedContentIdList
 // -----------------------------------------------------------------------------
-//   
+//
 EXPORT_C TInt RDRMRightsClient::ExportOrphanedContentIdList( TDes& aFileName )
     {
     DRMLOG( _L( "RDRMRightsClient::ExportOrphanedContentIdList" ) );
-    
-    return SendReceive( DRMEngine::EGetOrphanedList, 
+
+    return SendReceive( DRMEngine::EGetOrphanedList,
                         TIpcArgs( &aFileName ) );
-            
-    };        
-                 
+
+    };
+
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::ExportOrphanedContentIdList
 // -----------------------------------------------------------------------------
-//   
-EXPORT_C TInt RDRMRightsClient::ExportOrphanedContentIdList( 
+//
+EXPORT_C TInt RDRMRightsClient::ExportOrphanedContentIdList(
                         RPointerArray<HBufC8>& aContentIdList )
     {
     DRMLOG( _L( "RDRMRightsClient::ExportOrphanedContentIdList to array" ) );
     TFileName name;
     aContentIdList.ResetAndDestroy();
-    
+
     TInt error = ExportOrphanedContentIdList( name );
     if ( !error )
         {
@@ -1182,16 +1182,16 @@
                 {
                 aContentIdList.ResetAndDestroy();
                 }
-            
+
             fs.Delete( name );
             fs.Close();
             }
         }
-    
+
     DRMLOG2( _L( "RDRMRightsClient::ExportOrphanedContentIdList to array: %d" ), error );
-            
-    return error;        
-    }; 
+
+    return error;
+    };
 
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::EncodeRightsIssuerField
@@ -1201,28 +1201,28 @@
 // - base64encode(AES IV + AES encoded original field incl. padding)
 // -----------------------------------------------------------------------------
 //
-EXPORT_C TInt RDRMRightsClient::EncodeRightsIssuerField( 
+EXPORT_C TInt RDRMRightsClient::EncodeRightsIssuerField(
                                     const TDesC8& aOldValue,
                                     HBufC8*& aNewValue )
     {
     DRMLOG( _L( "RDRMRightsClient::EncodeRightsIssuerField" ) );
 
     TInt error( KErrNone );
-    
+
     TInt size( aOldValue.Length() ); // original length
     size += KDCFKeySize - ( size % KDCFKeySize ); // padding
     size += KDCFKeySize; // IV
     size += ( size + 2 ) / 3 * 4; // base64
     size += RMobilePhone::KPhoneSerialNumberSize;
     size += 3; // "flk"
-    
+
     aNewValue = HBufC8::New( size );
     if ( aNewValue )
         {
         TPtr8 des( aNewValue->Des() );
-        
+
         des = aOldValue;
-        
+
         error = SendReceive( DRMEngine::EEncodeRightsIssuerField,
                              TIpcArgs( &des ) );
         if ( error )
@@ -1235,25 +1235,25 @@
         {
         error = KErrNoMemory;
         }
-    
+
     DRMLOG2( _L( "RDRMRightsClient::EncodeRightsIssuerField> %d" ), error );
-    
+
     return error;
     }
-    
-EXPORT_C TInt RDRMRightsClient::DecodeRightsIssuerField( 
+
+EXPORT_C TInt RDRMRightsClient::DecodeRightsIssuerField(
                                     const TDesC8& aEncoded,
                                     HBufC8*& aDecoded )
     {
     DRMLOG( _L( "DRMRightsClient::DecodeRightsIssuerField" ) );
-    
+
     TInt error( KErrNone );
-    
+
     aDecoded = HBufC8::New( aEncoded.Length() );
     if ( aDecoded )
         {
         TPtr8 des( aDecoded->Des() );
-        
+
         error = SendReceive( DRMEngine::EDecodeRightsIssuerField,
                              TIpcArgs( &aEncoded,
                                       &des ) );
@@ -1272,15 +1272,15 @@
         {
         error = KErrNoMemory;
         }
-    
+
     DRMLOG2( _L( "DRMRightsClient::DecodeRightsIssuerField: error %d" ), error );
-    
+
     return error;
     }
-  
+
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::SetAuthenticationSeed
-// 
+//
 // -----------------------------------------------------------------------------
 //
 EXPORT_C TInt RDRMRightsClient::SetAuthenticationSeed( const TDesC8& aContentID,
@@ -1290,10 +1290,10 @@
     return SendReceive( DRMEngine::ESetAuthenticationSeed,
                         TIpcArgs( &aContentID, &aSeed ) );
     }
-    
+
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::GetAuthenticationSeed
-// 
+//
 // -----------------------------------------------------------------------------
 //
 EXPORT_C TInt RDRMRightsClient::GetAuthenticationSeed( const TDesC8& aContentID,
@@ -1302,7 +1302,7 @@
     DRMLOG( _L( "RDRMRightsClient::GetAuthenticationSeed" ) );
     return SendReceive( DRMEngine::EGetAuthenticationSeed,
                         TIpcArgs( &aContentID, &aSeed ) );
-    }                                                       
+    }
 
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::FileToListL
@@ -1315,52 +1315,52 @@
     {
     DRMLOG( _L( "RDRMRightsClient::FileToListL" ) );
     TInt error = KErrNone;
-    
+
     // Temporary storage.
     CDRMPermission* tmpObject;
-    
+
     // To access the file data.
     RFileReadStream fileStream;
-    
+
     // How many objects there is in the file.
     TInt size = 0;
-    
+
     // Temporary counter.
     TInt count = 0;
-    
-    
+
+
     // Open the file.
     User::LeaveIfError( fileStream.Open( aFs, aFileName, EFileRead | EFileStream ) );
     CleanupClosePushL( fileStream );
-    
+
     size = fileStream.ReadInt32L();
-    
+
     while( count < size )
         {
         // Allocate a new RO.
         tmpObject = CDRMPermission::NewL();
-        
+
         // Read the object.
         TRAP( error, tmpObject->InternalizeL( fileStream ) );
-        
+
         if ( !error )
             {
             // Add the object into the list.
             error = aList.Append( tmpObject );
             }
-        
+
         if ( error )
             {
             delete tmpObject;
             User::Leave( error );
             }
-        
-        // Now tmpObject is under responsibility of aList. 
+
+        // Now tmpObject is under responsibility of aList.
         ++count;
         }
-    
+
     // All done.
-    CleanupStack::PopAndDestroy(); // fileStream 
+    CleanupStack::PopAndDestroy(); // fileStream
     }
 
 // -----------------------------------------------------------------------------
@@ -1376,10 +1376,10 @@
     RFileReadStream stream;
     TUint16 size = 0;
     TPtr8 data( NULL, 0, 0 );
-    
+
     User::LeaveIfError( stream.Open( aFs, aFile, EFileRead | EFileStream ) );
     CleanupClosePushL( stream );
-    
+
     size = stream.ReadUint16L();
     while( size > 0 )
         {
@@ -1390,22 +1390,22 @@
         CleanupStack::Pop(); // tmp
         size = stream.ReadUint16L();
         }
-    
+
     // All read, return.
-    
+
     CleanupStack::PopAndDestroy(); // stream
     }
 
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::VerifyMacL
-// Verifies the MAC. 
+// Verifies the MAC.
 // -----------------------------------------------------------------------------
-//    
+//
 EXPORT_C TInt RDRMRightsClient::VerifyMacL(const TDesC8& aSignedInfoElement,
                                   const TDesC8& aMacValue ) const
     {
     DRMLOG( _L( "RDRMRightsClient::VerifyMacL" ) );
-    
+
     TInt error = SendReceive( DRMEngine::EVerifyMac,
                               TIpcArgs( &aSignedInfoElement, &aMacValue) );
     return error;
@@ -1416,19 +1416,19 @@
 // RDRMRightsClient::GetSupportedIndividualsL
 // retrieves the supported individuals list
 // -----------------------------------------------------------------------------
-//    
+//
 EXPORT_C TInt RDRMRightsClient::GetSupportedIndividualsL(
                                     RPointerArray<HBufC8>& aIndividuals) const
     {
     DRMLOG( _L( "RDRMRightsClient::GetSupportedIndividualsL" ) );
-    TPckgBuf< TInt > size( 0 );    
+    TPckgBuf< TInt > size( 0 );
     TInt error = SendReceive( DRMEngine::EGetSupportedIndividuals,
                               TIpcArgs( &size) );
     HBufC8* dataBuf = NULL;
     HBufC8* individual = NULL;
     TInt indivSize;
     TInt offset;
-                                  
+
     if ( !error )
         {
         if ( !size() )
@@ -1441,17 +1441,17 @@
             if ( dataBuf )
                 {
                 TPtr8 data( dataBuf->Des() );
-                            
+
                 error = SendReceive( DRMEngine::EGetPreparedData,
                                      TIpcArgs( &data ) );
-                
+
                 if ( !error )
-                    { 
+                    {
                     offset = 0;
                     while (offset < size())
                         {
                         Mem::Copy( &indivSize, data.Ptr()+offset, sizeof(TInt) );
-                        offset += sizeof (TInt); 
+                        offset += sizeof (TInt);
                         individual = data.Mid(offset, indivSize).AllocLC();
                         aIndividuals.AppendL(individual);
                         CleanupStack::Pop(); // individual
@@ -1459,16 +1459,16 @@
                         }
                     }
                 }
-            CleanupStack::PopAndDestroy();   
+            CleanupStack::PopAndDestroy();
             }
-        }                                             
+        }
     return KErrNone;
     }
-    
+
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::StopWatching
 // -----------------------------------------------------------------------------
-//    
+//
 EXPORT_C void RDRMRightsClient::StopWatching() const
     {
     SendReceive( DRMEngine::EStopWatching );
@@ -1477,7 +1477,7 @@
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::UnwrapMacAndRek
 // -----------------------------------------------------------------------------
-//    
+//
 EXPORT_C TInt RDRMRightsClient::UnwrapMacAndRek( const TDesC8& aMacAndRek,
                                                  TKeyTransportScheme aTransportScheme,
                                                  const TDesC8& aRightsIssuerId,
@@ -1486,16 +1486,16 @@
     HBufC8* data = NULL;
     TPtr8 dataPtr( NULL, 0 );
     TInt err = KErrNone;
-    
+
     data = HBufC8::New( 1 + aMacAndRek.Size() );
-    
+
     if ( data )
         {
         dataPtr.Set( data->Des() );
-        dataPtr.SetLength( 1 ); 
+        dataPtr.SetLength( 1 );
         dataPtr[0] = aTransportScheme;
         dataPtr.Append( aMacAndRek );
-    
+
         if( aDomainId.Length() )
             {
             err = SendReceive( DRMEngine::EUnwrapDomainMacAndRek, TIpcArgs( &dataPtr,
@@ -1511,18 +1511,18 @@
         delete data;
         data = NULL;
         }
-    else 
+    else
         {
         err = KErrNoMemory;
         }
-    
+
     return err;
     }
-    
+
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::GetRandomDataL
 // -----------------------------------------------------------------------------
-//    
+//
 EXPORT_C void RDRMRightsClient::GetRandomDataL( TDes8& aRandomData ) const
     {
     if( !aRandomData.Length() )
@@ -1535,7 +1535,7 @@
 // -----------------------------------------------------------------------------
 // RDRMRightsClient::GetMeteringData()
 // -----------------------------------------------------------------------------
-//    
+//
 #ifndef RD_DRM_METERING
 EXPORT_C HBufC8* RDRMRightsClient::GetMeteringDataL( const TDesC8& /*aRiId*/ )
     {
@@ -1546,24 +1546,24 @@
     {
     TInt error = KErrNone;
     HBufC8* meteringData = NULL;
-       
+
     if ( aRiId.Length() )
         {
         TInt size = 0;
         TPckg<TInt> package( size );
-        
-        error = SendReceive( DRMEngine::EGetMeteringData, 
+
+        error = SendReceive( DRMEngine::EGetMeteringData,
                            TIpcArgs( &package, &aRiId ) );
-                           
+
         if ( error == KErrNotFound )
             {
             return NULL;
             }
-            
+
         User::LeaveIfError( error );
 
         meteringData = HBufC8::NewMaxLC( size );
-        
+
         // Package 'object' into TPtr8.
         TPtr8 objectPkg( const_cast< TUint8* >( meteringData->Ptr() ),
                          size,
@@ -1571,26 +1571,26 @@
 
         User::LeaveIfError( SendReceive( DRMEngine::EGetPreparedData,
                                          TIpcArgs( &objectPkg) ) );
-        
+
         CleanupStack::Pop(); // meteringData
         return meteringData;
         }
-    
+
     User::Leave( KErrArgument );
     return NULL;
     }
 #endif //RD_DRM_METERING
- 
+
  // -----------------------------------------------------------------------------
 // RDRMRightsClient::DeleteMeteringDataL
 // -----------------------------------------------------------------------------
-//    
+//
 #ifndef RD_DRM_METERING
 EXPORT_C TInt RDRMRightsClient::DeleteMeteringDataL( const TDesC8& /*aRiId*/ )
     {
     return KErrNotSupported;
     }
-#else    	
+#else
 EXPORT_C TInt RDRMRightsClient::DeleteMeteringDataL( const TDesC8& aRiId )
     {
     if ( aRiId.Length() )
@@ -1604,9 +1604,9 @@
         return KErrArgument;
         }
     }
-#endif 
+#endif
 
 // ========================== OTHER EXPORTED FUNCTIONS =========================
-              
-    
-//  End of File  
+
+
+//  End of File