omadrm/drmengine/notifier/src/DRMNotifierSession.cpp
changeset 23 493788a4a8a4
parent 2 76350b5be3d8
child 49 69d8e75812b7
equal deleted inserted replaced
5:79d62d1d7957 23:493788a4a8a4
    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 		RDebug::Printf(">>> [%s] %d", _S8(__PRETTY_FUNCTION__), aMessage.Function());
   206     #ifdef _DEBUG
       
   207     RDebug::Printf(">>> [%s] %d", _S8(__PRETTY_FUNCTION__), aMessage.Function());
       
   208     #endif
       
   209 
   207     switch ( aMessage.Function() )
   210     switch ( aMessage.Function() )
   208         {
   211         {
   209         case ENotifyClients:
   212         case ENotifyClients:
   210             NotifyClientsL( aMessage );
   213             NotifyClientsL( aMessage );
   211             break;
   214             break;
   278     // 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
   279     if( iMessageQueue.Count() )
   282     if( iMessageQueue.Count() )
   280         {
   283         {
   281         NotifyL( iMessageQueue[0], ETrue );
   284         NotifyL( iMessageQueue[0], ETrue );
   282         }
   285         }
   283  
   286 
   284     // Message complete will be set elsewhere.
   287     // Message complete will be set elsewhere.
   285     // All done.
   288     // All done.
   286     }
   289     }
   287 
   290 
   288 // -----------------------------------------------------------------------------
   291 // -----------------------------------------------------------------------------
   319         }
   322         }
   320     iContentIDList.Reset();
   323     iContentIDList.Reset();
   321 
   324 
   322     iIsInStorage = EFalse;
   325     iIsInStorage = EFalse;
   323 
   326 
   324 	iIsListening = EFalse;
   327     iIsListening = EFalse;
   325 	
   328 
   326 	if ( !iListener.IsNull() )
   329     if ( !iListener.IsNull() )
   327 		{
   330         {
   328 		iListener.Complete( KErrCancel );
   331         iListener.Complete( KErrCancel );
   329 		}
   332         }
   330 	
   333 
   331     aMessage.Complete( KErrNone );
   334     aMessage.Complete( KErrNone );
   332     }
   335     }
   333 // -----------------------------------------------------------------------------
   336 // -----------------------------------------------------------------------------
   334 // CDRMNotifierSession::RegisterURIL
   337 // CDRMNotifierSession::RegisterURIL
   335 // 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
   336 // it to the database.
   339 // it to the database.
   337 // -----------------------------------------------------------------------------
   340 // -----------------------------------------------------------------------------
   338 //
   341 //
   339 void CDRMNotifierSession::RegisterL( const RMessage2& aMessage )
   342 void CDRMNotifierSession::RegisterL( const RMessage2& aMessage )
   340     {
   343     {
   356     aMessage.Complete( KErrNone );
   359     aMessage.Complete( KErrNone );
   357     }
   360     }
   358 
   361 
   359 // -----------------------------------------------------------------------------
   362 // -----------------------------------------------------------------------------
   360 // CDRMNotifierSession::UnRegisterURIL
   363 // CDRMNotifierSession::UnRegisterURIL
   361 // 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
   362 // it to the database.
   365 // it to the database.
   363 // -----------------------------------------------------------------------------
   366 // -----------------------------------------------------------------------------
   364 //
   367 //
   365 void CDRMNotifierSession::UnRegisterL( const RMessage2& aMessage )
   368 void CDRMNotifierSession::UnRegisterL( const RMessage2& aMessage )
   366     {
   369     {
   482     {
   485     {
   483     LOG( _L8( "NotifyL" ) );
   486     LOG( _L8( "NotifyL" ) );
   484     TPtr8 data( reinterpret_cast<TUint8*>(&aMessage->iEventType),
   487     TPtr8 data( reinterpret_cast<TUint8*>(&aMessage->iEventType),
   485                 sizeof(TDRMEventType),
   488                 sizeof(TDRMEventType),
   486                 sizeof(TDRMEventType));
   489                 sizeof(TDRMEventType));
   487     TPtr8 event( aMessage->iMessageData, DRMNotifier::KDRMSizeOfMessage, 
   490     TPtr8 event( aMessage->iMessageData, DRMNotifier::KDRMSizeOfMessage,
   488                  DRMNotifier::KDRMSizeOfMessage );
   491                  DRMNotifier::KDRMSizeOfMessage );
   489 
   492 
   490     iListener.WriteL(0, event);
   493     iListener.WriteL(0, event);
   491     iListener.WriteL(1, data);
   494     iListener.WriteL(1, data);
   492 
   495 
   519         }
   522         }
   520     return EFalse;
   523     return EFalse;
   521     }
   524     }
   522 
   525 
   523 // ========================== OTHER EXPORTED FUNCTIONS =========================
   526 // ========================== OTHER EXPORTED FUNCTIONS =========================
   524 //  End of File  
   527 //  End of File