omadrm/drmengine/notifier/src/DRMNotifierSession.cpp
branchRCL_3
changeset 18 8a03a285ab14
parent 17 e16d72588c28
child 71 1221b68b8a5f
equal deleted inserted replaced
17:e16d72588c28 18:8a03a285ab14
    17 
    17 
    18 
    18 
    19 // INCLUDE FILES
    19 // INCLUDE FILES
    20 #include <s32file.h>
    20 #include <s32file.h>
    21 #include <f32file.h>
    21 #include <f32file.h>
    22 #include "drmcommon.h"
    22 #include "DRMCommon.h"
    23 #include "DRMNotifierSession.h"
    23 #include "DRMNotifierSession.h"
    24 #include "DRMNotifierServer.h"
    24 #include "DRMNotifierServer.h"
    25 #include "drmnotifierclientserver.h"
    25 #include "drmnotifierclientserver.h"
    26 #include <e32test.h>
    26 #include <e32test.h>
    27 
    27 
    28 // NAMESPACES
    28 // NAMESPACES
    29 using namespace DRMNotifier;
    29 using namespace DRMNotifier;
    30 
    30 
    31 // EXTERNAL DATA STRUCTURES
    31 // EXTERNAL DATA STRUCTURES
    32 // EXTERNAL FUNCTION PROTOTYPES  
    32 // EXTERNAL FUNCTION PROTOTYPES
    33 // CONSTANTS
    33 // CONSTANTS
    34 
    34 
    35 
    35 
    36 // MACROS
    36 // MACROS
    37 #ifdef _DRM_TESTING
    37 #ifdef _DRM_TESTING
    68 // -----------------------------------------------------------------------------
    68 // -----------------------------------------------------------------------------
    69 // CDRMNotifierSession::NewLC
    69 // CDRMNotifierSession::NewLC
    70 // Two-phased constructor.
    70 // Two-phased constructor.
    71 // -----------------------------------------------------------------------------
    71 // -----------------------------------------------------------------------------
    72 //
    72 //
    73 CDRMNotifierSession* CDRMNotifierSession::NewL( CDRMMessageStorage* aStorage) 
    73 CDRMNotifierSession* CDRMNotifierSession::NewL( CDRMMessageStorage* aStorage)
    74     {
    74     {
    75     CDRMNotifierSession* self = new( ELeave ) CDRMNotifierSession( aStorage );
    75     CDRMNotifierSession* self = new( ELeave ) CDRMNotifierSession( aStorage );
    76     CleanupStack::PushL( self );
    76     CleanupStack::PushL( self );
    77     self->ConstructL();
    77     self->ConstructL();
    78     CleanupStack::Pop(); // self
    78     CleanupStack::Pop(); // self
   100         }
   100         }
   101 
   101 
   102     for( i = 0; i < iMessageQueue.Count(); i++ )
   102     for( i = 0; i < iMessageQueue.Count(); i++ )
   103         {
   103         {
   104         if( this->iStorage ) // coverity check
   104         if( this->iStorage ) // coverity check
   105             {    
   105             {
   106             iStorage->UpdateMessage(iMessageQueue[i]);
   106             iStorage->UpdateMessage(iMessageQueue[i]);
   107             }
   107             }
   108         }
   108         }
   109 
   109 
   110     iMessageQueue.Reset();
   110     iMessageQueue.Reset();
   157 //
   157 //
   158 void CDRMNotifierSession::ServiceL( const RMessage2& aMessage )
   158 void CDRMNotifierSession::ServiceL( const RMessage2& aMessage )
   159     {
   159     {
   160     LOG( _L8( "ServiceL called" ) );
   160     LOG( _L8( "ServiceL called" ) );
   161     // Trap possible errors...
   161     // Trap possible errors...
   162     
   162 
   163     TRAPD( error, DispatchL( aMessage ) );
   163     TRAPD( error, DispatchL( aMessage ) );
   164     
   164 
   165     if ( error )
   165     if ( error )
   166         {
   166         {
   167         LOG( _L8( "DispatcL threw an exception" ) );
   167         LOG( _L8( "DispatcL threw an exception" ) );
   168         // ...and complete the request in case of an error.
   168         // ...and complete the request in case of an error.
   169         aMessage.Complete( error );
   169         aMessage.Complete( error );
   177 // -----------------------------------------------------------------------------
   177 // -----------------------------------------------------------------------------
   178 // CDRMNotifierSession::CDRMNotifierSession
   178 // CDRMNotifierSession::CDRMNotifierSession
   179 // Default constructor.
   179 // Default constructor.
   180 // -----------------------------------------------------------------------------
   180 // -----------------------------------------------------------------------------
   181 //
   181 //
   182 CDRMNotifierSession::CDRMNotifierSession( CDRMMessageStorage* aStorage ) : 
   182 CDRMNotifierSession::CDRMNotifierSession( CDRMMessageStorage* aStorage ) :
   183     // Base class' constructor is called first.
   183     // Base class' constructor is called first.
   184     iStorage( aStorage )
   184     iStorage( aStorage )
   185     {
   185     {
   186     // Nothing.
   186     // Nothing.
   187     }
   187     }
   195     {
   195     {
   196     }
   196     }
   197 
   197 
   198 // -----------------------------------------------------------------------------
   198 // -----------------------------------------------------------------------------
   199 // CDRMNotifierSession::DispatchL
   199 // CDRMNotifierSession::DispatchL
   200 // Checks which command the user requested, and forwards the request to 
   200 // Checks which command the user requested, and forwards the request to
   201 // appropriate private method. This helps to keep the code more readable.
   201 // appropriate private method. This helps to keep the code more readable.
   202 // -----------------------------------------------------------------------------
   202 // -----------------------------------------------------------------------------
   203 //
   203 //
   204 void CDRMNotifierSession::DispatchL( const RMessage2& aMessage ) 
   204 void CDRMNotifierSession::DispatchL( const RMessage2& aMessage )
   205     {
   205     {
   206     #ifdef _DEBUG
   206     #ifdef _DEBUG
   207 	RDebug::Printf(">>> [%s] %d", _S8(__PRETTY_FUNCTION__), aMessage.Function());
   207     RDebug::Printf(">>> [%s] %d", _S8(__PRETTY_FUNCTION__), aMessage.Function());
   208     #endif
   208     #endif
   209     	
   209 
   210     switch ( aMessage.Function() )
   210     switch ( aMessage.Function() )
   211         {
   211         {
   212         case ENotifyClients:
   212         case ENotifyClients:
   213             NotifyClientsL( aMessage );
   213             NotifyClientsL( aMessage );
   214             break;
   214             break;
   281     // Check if there are any notifications in queue if so process first one
   281     // Check if there are any notifications in queue if so process first one
   282     if( iMessageQueue.Count() )
   282     if( iMessageQueue.Count() )
   283         {
   283         {
   284         NotifyL( iMessageQueue[0], ETrue );
   284         NotifyL( iMessageQueue[0], ETrue );
   285         }
   285         }
   286  
   286 
   287     // Message complete will be set elsewhere.
   287     // Message complete will be set elsewhere.
   288     // All done.
   288     // All done.
   289     }
   289     }
   290 
   290 
   291 // -----------------------------------------------------------------------------
   291 // -----------------------------------------------------------------------------
   322         }
   322         }
   323     iContentIDList.Reset();
   323     iContentIDList.Reset();
   324 
   324 
   325     iIsInStorage = EFalse;
   325     iIsInStorage = EFalse;
   326 
   326 
   327 	iIsListening = EFalse;
   327     iIsListening = EFalse;
   328 	
   328 
   329 	if ( !iListener.IsNull() )
   329     if ( !iListener.IsNull() )
   330 		{
   330         {
   331 		iListener.Complete( KErrCancel );
   331         iListener.Complete( KErrCancel );
   332 		}
   332         }
   333 	
   333 
   334     aMessage.Complete( KErrNone );
   334     aMessage.Complete( KErrNone );
   335     }
   335     }
   336 // -----------------------------------------------------------------------------
   336 // -----------------------------------------------------------------------------
   337 // CDRMNotifierSession::RegisterURIL
   337 // CDRMNotifierSession::RegisterURIL
   338 // Get the information from the client, construct a rights object, and add 
   338 // Get the information from the client, construct a rights object, and add
   339 // it to the database.
   339 // it to the database.
   340 // -----------------------------------------------------------------------------
   340 // -----------------------------------------------------------------------------
   341 //
   341 //
   342 void CDRMNotifierSession::RegisterL( const RMessage2& aMessage )
   342 void CDRMNotifierSession::RegisterL( const RMessage2& aMessage )
   343     {
   343     {
   359     aMessage.Complete( KErrNone );
   359     aMessage.Complete( KErrNone );
   360     }
   360     }
   361 
   361 
   362 // -----------------------------------------------------------------------------
   362 // -----------------------------------------------------------------------------
   363 // CDRMNotifierSession::UnRegisterURIL
   363 // CDRMNotifierSession::UnRegisterURIL
   364 // Get the information from the client, construct a rights object, and add 
   364 // Get the information from the client, construct a rights object, and add
   365 // it to the database.
   365 // it to the database.
   366 // -----------------------------------------------------------------------------
   366 // -----------------------------------------------------------------------------
   367 //
   367 //
   368 void CDRMNotifierSession::UnRegisterL( const RMessage2& aMessage )
   368 void CDRMNotifierSession::UnRegisterL( const RMessage2& aMessage )
   369     {
   369     {
   485     {
   485     {
   486     LOG( _L8( "NotifyL" ) );
   486     LOG( _L8( "NotifyL" ) );
   487     TPtr8 data( reinterpret_cast<TUint8*>(&aMessage->iEventType),
   487     TPtr8 data( reinterpret_cast<TUint8*>(&aMessage->iEventType),
   488                 sizeof(TDRMEventType),
   488                 sizeof(TDRMEventType),
   489                 sizeof(TDRMEventType));
   489                 sizeof(TDRMEventType));
   490     TPtr8 event( aMessage->iMessageData, DRMNotifier::KDRMSizeOfMessage, 
   490     TPtr8 event( aMessage->iMessageData, DRMNotifier::KDRMSizeOfMessage,
   491                  DRMNotifier::KDRMSizeOfMessage );
   491                  DRMNotifier::KDRMSizeOfMessage );
   492 
   492 
   493     iListener.WriteL(0, event);
   493     iListener.WriteL(0, event);
   494     iListener.WriteL(1, data);
   494     iListener.WriteL(1, data);
   495 
   495 
   522         }
   522         }
   523     return EFalse;
   523     return EFalse;
   524     }
   524     }
   525 
   525 
   526 // ========================== OTHER EXPORTED FUNCTIONS =========================
   526 // ========================== OTHER EXPORTED FUNCTIONS =========================
   527 //  End of File  
   527 //  End of File