omadrm/drmengine/notifier/src/DRMNotifierClient.cpp
changeset 23 493788a4a8a4
parent 0 95b198f216e5
equal deleted inserted replaced
5:79d62d1d7957 23:493788a4a8a4
    18 
    18 
    19 
    19 
    20 // INCLUDE FILES
    20 // INCLUDE FILES
    21 #include    "DRMNotifierClient.h"
    21 #include    "DRMNotifierClient.h"
    22 #include "drmnotifierclientserver.h"
    22 #include "drmnotifierclientserver.h"
    23 #include "drmrightsclient.h"
    23 #include "DRMRightsClient.h"
    24 // EXTERNAL DATA STRUCTURES
    24 // EXTERNAL DATA STRUCTURES
    25 // EXTERNAL FUNCTION PROTOTYPES  
    25 // EXTERNAL FUNCTION PROTOTYPES
    26 // CONSTANTS
    26 // CONSTANTS
    27 // MACROS
    27 // MACROS
    28 // LOCAL CONSTANTS AND MACROS
    28 // LOCAL CONSTANTS AND MACROS
    29 // MODULE DATA STRUCTURES
    29 // MODULE DATA STRUCTURES
    30 // LOCAL FUNCTION PROTOTYPES
    30 // LOCAL FUNCTION PROTOTYPES
    36 // RDRMNotifierClient::RDRMNotifierClient
    36 // RDRMNotifierClient::RDRMNotifierClient
    37 // C++ default constructor can NOT contain any code, that
    37 // C++ default constructor can NOT contain any code, that
    38 // might leave.
    38 // might leave.
    39 // -----------------------------------------------------------------------------
    39 // -----------------------------------------------------------------------------
    40 //
    40 //
    41 RDRMNotifierClient::RDRMNotifierClient(TDRMEventType* aEventType, TDRMEventType* aEventTypeWait, 
    41 RDRMNotifierClient::RDRMNotifierClient(TDRMEventType* aEventType, TDRMEventType* aEventTypeWait,
    42                                        TPtr8* aPtr, TPtr8* aWaitPtr) :
    42                                        TPtr8* aPtr, TPtr8* aWaitPtr) :
    43     iEventType( aEventType ),
    43     iEventType( aEventType ),
    44     iEventTypeWait( aEventTypeWait ),
    44     iEventTypeWait( aEventTypeWait ),
    45     iData( aPtr ),
    45     iData( aPtr ),
    46     iWaitData( aWaitPtr ),
    46     iWaitData( aWaitPtr ),
    47     numdata( 0 )
    47     numdata( 0 )
    48     {
    48     {
    49    // Nothing
    49    // Nothing
    50     }
    50     }
    51     
    51 
    52 // Destructor
    52 // Destructor
    53 RDRMNotifierClient::~RDRMNotifierClient()
    53 RDRMNotifierClient::~RDRMNotifierClient()
    54     {
    54     {
    55     Close();
    55     Close();
    56     }
    56     }
    62 // (other items were commented in a header).
    62 // (other items were commented in a header).
    63 // -----------------------------------------------------------------------------
    63 // -----------------------------------------------------------------------------
    64 //
    64 //
    65 TInt RDRMNotifierClient::Connect( void )
    65 TInt RDRMNotifierClient::Connect( void )
    66     {
    66     {
    67     const TVersion requiredVersion( 
    67     const TVersion requiredVersion(
    68         DRMNotifier::KServerMajorVersion,
    68         DRMNotifier::KServerMajorVersion,
    69         DRMNotifier::KServerMinorVersion,
    69         DRMNotifier::KServerMinorVersion,
    70         DRMNotifier::KServerBuildVersion );
    70         DRMNotifier::KServerBuildVersion );
    71     
    71 
    72     TInt ret = KErrNotFound;
    72     TInt ret = KErrNotFound;
    73     TUint8 count( 0 );
    73     TUint8 count( 0 );
    74     TUint8 cont( 1 );
    74     TUint8 cont( 1 );
    75     
    75 
    76     do
    76     do
    77         {
    77         {
    78         ret = CreateSession( DRMNotifier::KServerName,
    78         ret = CreateSession( DRMNotifier::KServerName,
    79                              requiredVersion,
    79                              requiredVersion,
    80                              KMaxMessageSlots );
    80                              KMaxMessageSlots );
    89                 ret = RDRMRightsClient::StartServer();
    89                 ret = RDRMRightsClient::StartServer();
    90                 }
    90                 }
    91             }
    91             }
    92         }
    92         }
    93     while ( cont && ( count < 2 ) );
    93     while ( cont && ( count < 2 ) );
    94     
    94 
    95     return ret;
    95     return ret;
    96     }
    96     }
    97 
    97 
    98 // -----------------------------------------------------------------------------
    98 // -----------------------------------------------------------------------------
    99 // RDRMNotifierClient::Close
    99 // RDRMNotifierClient::Close
   100 // Closes the connection to the server
   100 // Closes the connection to the server
   101 // (other items were commented in a header).
   101 // (other items were commented in a header).
   102 // -----------------------------------------------------------------------------
   102 // -----------------------------------------------------------------------------
   103 //
   103 //
   104 void RDRMNotifierClient::Close() 
   104 void RDRMNotifierClient::Close()
   105     {
   105     {
   106     RHandleBase::Close();
   106     RHandleBase::Close();
   107     }
   107     }
   108 
   108 
   109 
   109 
   111 // RDRMNotifierClient::SendEvent
   111 // RDRMNotifierClient::SendEvent
   112 // Sends an event to the client, asynchronous
   112 // Sends an event to the client, asynchronous
   113 // (other items were commented in a header).
   113 // (other items were commented in a header).
   114 // -----------------------------------------------------------------------------
   114 // -----------------------------------------------------------------------------
   115 //
   115 //
   116 void RDRMNotifierClient::SendEvent(TRequestStatus& aStatus) 
   116 void RDRMNotifierClient::SendEvent(TRequestStatus& aStatus)
   117     {
   117     {
   118     // Send the message.
   118     // Send the message.
   119     SendReceive( DRMNotifier::ENotifyClients, TIpcArgs(iData, *iEventType),
   119     SendReceive( DRMNotifier::ENotifyClients, TIpcArgs(iData, *iEventType),
   120 		aStatus );
   120         aStatus );
   121     };
   121     };
   122 
   122 
   123 // -----------------------------------------------------------------------------
   123 // -----------------------------------------------------------------------------
   124 // RDRMNotifierClient::WaitForCompletion
   124 // RDRMNotifierClient::WaitForCompletion
   125 // Waits for the notifications from the server, asynchronous
   125 // Waits for the notifications from the server, asynchronous
   126 // (other items were commented in a header).
   126 // (other items were commented in a header).
   127 // -----------------------------------------------------------------------------
   127 // -----------------------------------------------------------------------------
   128 //
   128 //
   129 void RDRMNotifierClient::WaitForCompletion(TRequestStatus& aStatus) 
   129 void RDRMNotifierClient::WaitForCompletion(TRequestStatus& aStatus)
   130     {   
   130     {
   131     numdata.Set(reinterpret_cast<TUint8*>(iEventTypeWait),sizeof(TDRMEventType),sizeof(TDRMEventType));
   131     numdata.Set(reinterpret_cast<TUint8*>(iEventTypeWait),sizeof(TDRMEventType),sizeof(TDRMEventType));
   132         
   132 
   133     // Send the message.
   133     // Send the message.
   134     SendReceive( DRMNotifier::ERecieveNotification, TIpcArgs(iWaitData, &numdata),
   134     SendReceive( DRMNotifier::ERecieveNotification, TIpcArgs(iWaitData, &numdata),
   135 		aStatus );
   135         aStatus );
   136     };
   136     };
   137 
   137 
   138 // -----------------------------------------------------------------------------
   138 // -----------------------------------------------------------------------------
   139 // RDRMNotifierClient::RegisterForType
   139 // RDRMNotifierClient::RegisterForType
   140 // Registeres a type to the server, synchronous
   140 // Registeres a type to the server, synchronous
   141 // (other items were commented in a header).
   141 // (other items were commented in a header).
   142 // -----------------------------------------------------------------------------
   142 // -----------------------------------------------------------------------------
   143 //
   143 //
   144 void RDRMNotifierClient::RegisterForType( TDRMEventType aEventType, 
   144 void RDRMNotifierClient::RegisterForType( TDRMEventType aEventType,
   145                                           HBufC8* aURI )
   145                                           HBufC8* aURI )
   146     {
   146     {
   147     TPckg<TInt> eventType(0);
   147     TPckg<TInt> eventType(0);
   148     eventType.Set(reinterpret_cast<TUint8*>(&aEventType),sizeof(TDRMEventType),sizeof(TDRMEventType));
   148     eventType.Set(reinterpret_cast<TUint8*>(&aEventType),sizeof(TDRMEventType),sizeof(TDRMEventType));
   149 
   149 
   153         TPtr8 uriPkg(dataptr,aURI->Size(),aURI->Size());
   153         TPtr8 uriPkg(dataptr,aURI->Size(),aURI->Size());
   154 
   154 
   155         // Send the message.
   155         // Send the message.
   156         SendReceive( DRMNotifier::ERegisterURI, TIpcArgs(&uriPkg, &eventType));
   156         SendReceive( DRMNotifier::ERegisterURI, TIpcArgs(&uriPkg, &eventType));
   157         }
   157         }
   158     else 
   158     else
   159         {
   159         {
   160         // Send the message.
   160         // Send the message.
   161         SendReceive( DRMNotifier::ERegister, TIpcArgs(&eventType));
   161         SendReceive( DRMNotifier::ERegister, TIpcArgs(&eventType));
   162         }
   162         }
   163     }
   163     }
   166 // RDRMNotifierClient::UnRegisterFromType
   166 // RDRMNotifierClient::UnRegisterFromType
   167 // Unregisteres a type from the server, synchronous
   167 // Unregisteres a type from the server, synchronous
   168 // (other items were commented in a header).
   168 // (other items were commented in a header).
   169 // -----------------------------------------------------------------------------
   169 // -----------------------------------------------------------------------------
   170 //
   170 //
   171 void RDRMNotifierClient::UnRegisterFromType( TDRMEventType aEventType, 
   171 void RDRMNotifierClient::UnRegisterFromType( TDRMEventType aEventType,
   172                                              HBufC8* aURI)
   172                                              HBufC8* aURI)
   173     {
   173     {
   174     TPckg<TInt> eventType(0);
   174     TPckg<TInt> eventType(0);
   175     eventType.Set(reinterpret_cast<TUint8*>(&aEventType),sizeof(TDRMEventType),sizeof(TDRMEventType));
   175     eventType.Set(reinterpret_cast<TUint8*>(&aEventType),sizeof(TDRMEventType),sizeof(TDRMEventType));
   176 
   176 
   180         TPtr8 uriPkg(dataptr,aURI->Size(),aURI->Size());
   180         TPtr8 uriPkg(dataptr,aURI->Size(),aURI->Size());
   181 
   181 
   182         // Send the message.
   182         // Send the message.
   183         SendReceive( DRMNotifier::EUnRegisterURI, TIpcArgs(&uriPkg, &eventType));
   183         SendReceive( DRMNotifier::EUnRegisterURI, TIpcArgs(&uriPkg, &eventType));
   184         }
   184         }
   185     else 
   185     else
   186         {
   186         {
   187         // Send the message.
   187         // Send the message.
   188         SendReceive( DRMNotifier::EUnRegister, TIpcArgs(&eventType));
   188         SendReceive( DRMNotifier::EUnRegister, TIpcArgs(&eventType));
   189         }
   189         }
   190     }
   190     }
   200     {
   200     {
   201     // Send the message.
   201     // Send the message.
   202     SendReceive( DRMNotifier::ECancelNotification);
   202     SendReceive( DRMNotifier::ECancelNotification);
   203     };
   203     };
   204 
   204 
   205 //  End of File  
   205 //  End of File