omadrm/drmhelper/src/ConsumeData.cpp
changeset 23 493788a4a8a4
parent 0 95b198f216e5
equal deleted inserted replaced
5:79d62d1d7957 23:493788a4a8a4
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 // INCLUDE FILES
    19 // INCLUDE FILES
    20 #include <e32std.h>
    20 #include <e32std.h>
    21 #include "consumedata.h"
    21 #include "ConsumeData.h"
    22 
    22 
    23 // LOCAL CONSTANTS AND MACROS
    23 // LOCAL CONSTANTS AND MACROS
    24 
    24 
    25 // ============================ MEMBER FUNCTIONS ===============================
    25 // ============================ MEMBER FUNCTIONS ===============================
    26 
    26 
    30 // -----------------------------------------------------------------------------
    30 // -----------------------------------------------------------------------------
    31 //
    31 //
    32 CConsumeData::CConsumeData() : CBase()
    32 CConsumeData::CConsumeData() : CBase()
    33     {
    33     {
    34     }
    34     }
    35     
    35 
    36 // -----------------------------------------------------------------------------
    36 // -----------------------------------------------------------------------------
    37 // CConsumeData::~ConsumeData
    37 // CConsumeData::~ConsumeData
    38 // C++ default destructor
    38 // C++ default destructor
    39 // -----------------------------------------------------------------------------
    39 // -----------------------------------------------------------------------------
    40 //    
    40 //
    41 CConsumeData::~CConsumeData()
    41 CConsumeData::~CConsumeData()
    42     {
    42     {
    43     // If the connection is still open call finish
    43     // If the connection is still open call finish
    44     if( iConnectionStatus && iContentURI8 ) 
    44     if( iConnectionStatus && iContentURI8 )
    45         {
    45         {
    46         iRdb.Consume( ContentAccess::EStop, *iContentURI8 );    
    46         iRdb.Consume( ContentAccess::EStop, *iContentURI8 );
    47         }
    47         }
    48     
    48 
    49     // Close the connection to the server:
    49     // Close the connection to the server:
    50     iRdb.Close();
    50     iRdb.Close();
    51     
    51 
    52     // Reset the connection status
    52     // Reset the connection status
    53     iConnectionStatus = EFalse;
    53     iConnectionStatus = EFalse;
    54         
    54 
    55     // Delete the content id
    55     // Delete the content id
    56     if( iContentURI8 )
    56     if( iContentURI8 )
    57         {
    57         {
    58         delete iContentURI8;
    58         delete iContentURI8;
    59         iContentURI8 = NULL;    
    59         iContentURI8 = NULL;
    60         }
    60         }
    61     }
    61     }
    62     
    62 
    63 
    63 
    64 // -----------------------------------------------------------------------------
    64 // -----------------------------------------------------------------------------
    65 // CConsumeData::NewLC
    65 // CConsumeData::NewLC
    66 // 2-phase constructor
    66 // 2-phase constructor
    67 // -----------------------------------------------------------------------------
    67 // -----------------------------------------------------------------------------
    71     CConsumeData* self = new (ELeave) CConsumeData();
    71     CConsumeData* self = new (ELeave) CConsumeData();
    72     CleanupStack::PushL( self );
    72     CleanupStack::PushL( self );
    73     self->ConstructL( aUri );
    73     self->ConstructL( aUri );
    74     return self;
    74     return self;
    75     }
    75     }
    76     
    76 
    77 // -----------------------------------------------------------------------------
    77 // -----------------------------------------------------------------------------
    78 // CConsumeData::NewL
    78 // CConsumeData::NewL
    79 // 2-phase constructor
    79 // 2-phase constructor
    80 // -----------------------------------------------------------------------------
    80 // -----------------------------------------------------------------------------
    81 //
    81 //
    82 CConsumeData* CConsumeData::NewL( const TDesC8& aUri )
    82 CConsumeData* CConsumeData::NewL( const TDesC8& aUri )
    83     {
    83     {
    84     CConsumeData* self = NewLC( aUri );
    84     CConsumeData* self = NewLC( aUri );
    85     CleanupStack::Pop( self );
    85     CleanupStack::Pop( self );
    86     return self;        
    86     return self;
    87     }    
    87     }
    88 
    88 
    89 // -----------------------------------------------------------------------------
    89 // -----------------------------------------------------------------------------
    90 // CConsumeData::Consume
    90 // CConsumeData::Consume
    91 // -----------------------------------------------------------------------------
    91 // -----------------------------------------------------------------------------
    92 //
    92 //
    93 TInt CConsumeData::Consume( const ContentAccess::TIntent& aIntent )
    93 TInt CConsumeData::Consume( const ContentAccess::TIntent& aIntent )
    94     {
    94     {
    95     TInt retVal = KErrNone;
    95     TInt retVal = KErrNone;
    96     
    96 
    97     if( !iConnectionStatus )
    97     if( !iConnectionStatus )
    98         {
    98         {
    99         return KErrNotReady;    
    99         return KErrNotReady;
   100         }
   100         }
   101         
   101 
   102     retVal = iRdb.Consume( aIntent, *iContentURI8 );
   102     retVal = iRdb.Consume( aIntent, *iContentURI8 );
   103 
   103 
   104     if( aIntent == ContentAccess::EStop )
   104     if( aIntent == ContentAccess::EStop )
   105         {
   105         {
   106         iRdb.Close();
   106         iRdb.Close();
   107         iConnectionStatus = EFalse;    
   107         iConnectionStatus = EFalse;
   108         }
   108         }
   109         
   109 
   110     return retVal;    
   110     return retVal;
   111     }
   111     }
   112 // -----------------------------------------------------------------------------
   112 // -----------------------------------------------------------------------------
   113 // CConsumeData::CompareUri
   113 // CConsumeData::CompareUri
   114 // -----------------------------------------------------------------------------
   114 // -----------------------------------------------------------------------------
   115 //
   115 //
   116 TInt CConsumeData::CompareUri( const TDesC8& aUri ) const
   116 TInt CConsumeData::CompareUri( const TDesC8& aUri ) const
   117     {
   117     {
   118     if( !iContentURI8 )
   118     if( !iContentURI8 )
   119         {
   119         {
   120         return KErrNotReady;    
   120         return KErrNotReady;
   121         }
   121         }
   122         
   122 
   123     return iContentURI8->Des().Compare( aUri );
   123     return iContentURI8->Des().Compare( aUri );
   124     }
   124     }
   125 
   125 
   126 // -----------------------------------------------------------------------------
   126 // -----------------------------------------------------------------------------
   127 // CConsumeData::ConstructL
   127 // CConsumeData::ConstructL
   133     // Connect the rights client
   133     // Connect the rights client
   134     User::LeaveIfError( iRdb.Connect() );
   134     User::LeaveIfError( iRdb.Connect() );
   135 
   135 
   136     // Set the connection status
   136     // Set the connection status
   137     iConnectionStatus = ETrue;
   137     iConnectionStatus = ETrue;
   138     
   138 
   139     // copy the url for internal use
   139     // copy the url for internal use
   140     iContentURI8 = aUri.AllocL();    
   140     iContentURI8 = aUri.AllocL();
   141     }
   141     }
   142 
   142 
   143 // ========================== OTHER EXPORTED FUNCTIONS =========================
   143 // ========================== OTHER EXPORTED FUNCTIONS =========================
   144 
   144 
   145 
   145