menucontentsrv/srvsrc/mcsdrmobserver.cpp
changeset 0 79c6a41cd166
equal deleted inserted replaced
-1:000000000000 0:79c6a41cd166
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  The API supports attributes not present in MCS from SAT Api
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "mcsdrmobserver.h"
       
    20 
       
    21 // ============================ MEMBER FUNCTIONS =============================
       
    22 
       
    23 // ---------------------------------------------------------------------------
       
    24 // Creates an instance of CMcsDrmObserver
       
    25 // ---------------------------------------------------------------------------
       
    26 //
       
    27 CMcsDrmObserver* CMcsDrmObserver::NewL( 
       
    28 	MMcsDrmObserver& aObserver, 
       
    29     const TDesC& aDRMContentId,
       
    30     TUid aUid,
       
    31     TDRMEventType aDRMEventType )
       
    32 	{
       
    33 	CMcsDrmObserver* self = new (ELeave) 
       
    34 		CMcsDrmObserver( aObserver, aUid, aDRMEventType );
       
    35     CleanupStack::PushL( self );
       
    36     self->ConstructL( aDRMContentId );
       
    37     CleanupStack::Pop( self );
       
    38     
       
    39     return self;
       
    40 	}
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // Destructor
       
    44 // ---------------------------------------------------------------------------
       
    45 //
       
    46 CMcsDrmObserver::~CMcsDrmObserver()
       
    47 	{
       
    48 	UnRegisterEventObserver();
       
    49 	delete iDRMNotifier;
       
    50 	iContentId.Close();
       
    51 	}
       
    52 
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 // 
       
    56 // ---------------------------------------------------------------------------
       
    57 //
       
    58 CMcsDrmObserver::CMcsDrmObserver( 
       
    59 	MMcsDrmObserver& aObserver,
       
    60 	TUid aUid,
       
    61 	TDRMEventType aDRMEventType ):
       
    62 	iObserver( aObserver ),
       
    63 	iAppUid( aUid ),
       
    64 	iDRMEventType( aDRMEventType )
       
    65 	{
       
    66 	
       
    67 	}
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // CMcsDrmObserver::ConstructL
       
    71 // S2nd phase constructor.
       
    72 // -----------------------------------------------------------------------------
       
    73 //
       
    74 void CMcsDrmObserver::ConstructL( 
       
    75 		const TDesC& aDRMContentId )
       
    76 	{
       
    77 	iContentId.CreateL( aDRMContentId.Length() );
       
    78 	iContentId.Copy( aDRMContentId );
       
    79 	iDRMNotifier = CDRMNotifier::NewL();
       
    80 	RegisterEventObserverL();
       
    81 	}
       
    82 	
       
    83 
       
    84 // ---------------------------------------------------------------------------
       
    85 // 
       
    86 // ---------------------------------------------------------------------------
       
    87 //
       
    88 void CMcsDrmObserver::RegisterEventObserverL()
       
    89 	{
       
    90 	iDRMNotifier->RegisterEventObserverL( *this, iDRMEventType, iContentId );
       
    91 	}
       
    92 // ---------------------------------------------------------------------------
       
    93 // 
       
    94 // ---------------------------------------------------------------------------
       
    95 //
       
    96 TUid CMcsDrmObserver::Uid()
       
    97 	{
       
    98 	return iAppUid;
       
    99 	}
       
   100 
       
   101 // ---------------------------------------------------------------------------
       
   102 // 
       
   103 // ---------------------------------------------------------------------------
       
   104 //
       
   105 void CMcsDrmObserver::UnRegisterEventObserver()
       
   106 	{
       
   107 	TRAP_IGNORE(iDRMNotifier->UnRegisterEventObserverL( *this, iDRMEventType, iContentId ));
       
   108 	}
       
   109 
       
   110 // ---------------------------------------------------------------------------
       
   111 // 
       
   112 // ---------------------------------------------------------------------------
       
   113 //
       
   114 void CMcsDrmObserver::HandleEventL( MDRMEvent* /*aEvent*/ )
       
   115 	{
       
   116 	iObserver.HandleDrmEvent( iAppUid );
       
   117 	}
       
   118 
       
   119 // End of File