wmdrm/camese/wmdrmdla/inc/wmdrmdlahttplicacqpluginfw.h
changeset 0 95b198f216e5
equal deleted inserted replaced
-1:000000000000 0:95b198f216e5
       
     1 /*
       
     2 * Copyright (c) 2008-2009 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:  HTTP plugin framework interface for WMDRM DLA
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_WMDRMDLAHTTPLICACQPLUGINFW_H
       
    20 #define C_WMDRMDLAHTTPLICACQPLUGINFW_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <f32file.h>
       
    24 #include <wmdrmdlatypes.h>
       
    25 #include <wmdrmdlacancelobserver.h>
       
    26 
       
    27 class CWmDrmDlaHttpPluginIf;
       
    28 class CWmDrmDlaUiNotifier;
       
    29 class CWmDrmDlaParser;
       
    30 
       
    31 /**
       
    32  *  Implementation class for WMDRM DLA HTTP License Acquisition FW
       
    33  *  @since S60 v9.1
       
    34  */
       
    35 NONSHARABLE_CLASS( CWmDrmDlaHttpLicAcqPluginFw ) 
       
    36     : public CActive, public MWmDrmDlaCancelObserver
       
    37     {
       
    38 
       
    39 public:
       
    40 
       
    41     static CWmDrmDlaHttpLicAcqPluginFw* NewL();
       
    42     static CWmDrmDlaHttpLicAcqPluginFw* NewLC();    
       
    43 
       
    44     /**
       
    45     * Destructor.
       
    46     */
       
    47     virtual ~CWmDrmDlaHttpLicAcqPluginFw();
       
    48 
       
    49     /**
       
    50      * Checks if license acquisition for file is silent
       
    51      *
       
    52      * @param   aFile wmdrm file
       
    53      * @return  ETrue if license acquisition is silent
       
    54      * @leave   KErrNotFound if there is no handler for the file
       
    55      */
       
    56     TBool SilentL( const RFile& aFile );
       
    57 
       
    58     /**
       
    59      * Acquire license for given WMDRM file
       
    60      *
       
    61      * @param   aFile wmdrm file
       
    62      * @param   aContentUrl contains content URL on completion. Can be NULL.
       
    63      * If it's not NULL, it must be freed by caller.  
       
    64      * @param   aHtmlData contains HTML data returned by license server
       
    65      *                    on completion. Can be NULL.
       
    66      * If it's not NULL, it must be freed by caller.  
       
    67      * @param   aStatus Request status. On completion contains the error code.
       
    68      */
       
    69     void AcquireLicense( const RFile& aFile, HBufC*& aContentUrl, 
       
    70                          HBufC*& aHtmlData, TRequestStatus& aStatus );
       
    71 
       
    72     /**
       
    73      * Acquire license based on DRM Header
       
    74      *
       
    75      * @param   aDrmHeader DRM Header
       
    76      * @param   aErrorUrl URL where error code is sent. Can be NULL.
       
    77      * @param   aContentUrl contains content URL on completion. Can be NULL.
       
    78      * If it's not NULL, it must be freed by caller.  
       
    79      * @param   aHtmlData contains HTML data returned by license server
       
    80      *                    on completion. Can be NULL.
       
    81      * If it's not NULL, it must be freed by caller.  
       
    82      * @param   aStatus Request status. On completion contains the error code.
       
    83      */
       
    84     void AcquireLicenseFromDrmHeader( const TDesC8& aDrmHeader, 
       
    85                                       HBufC* aErrorUrl,
       
    86                                       HBufC*& aContentUrl, 
       
    87                                       HBufC*& aHtmlData, 
       
    88                                       TRequestStatus& aStatus );
       
    89 
       
    90     /*
       
    91      * Cancels license acquisition
       
    92      */
       
    93     void CancelLicenseAcquisition();
       
    94     
       
    95     /**
       
    96      * Sets the IAP to be used in the HTTP transactions
       
    97      *
       
    98      * @param   aIapId  Internet Access Point id
       
    99      */
       
   100     void SetIapId( TInt aIapId );
       
   101 
       
   102 protected:
       
   103 
       
   104     // from base class CActive
       
   105 
       
   106     /**
       
   107     * From CActive Cancels async request.
       
   108     */
       
   109     void DoCancel();
       
   110 
       
   111     /**
       
   112     * From CActive Called when async request completes.
       
   113     */
       
   114     void RunL();
       
   115     
       
   116     /**
       
   117     * From CActive Called if RunL leaves.
       
   118     */
       
   119     TInt RunError( TInt aError );
       
   120 
       
   121 public: // from MWmDrmDlaCancelObserver
       
   122     
       
   123     void UserCancellation();
       
   124     
       
   125 private:
       
   126 
       
   127     CWmDrmDlaHttpLicAcqPluginFw();
       
   128     void ConstructL();
       
   129     
       
   130     void CompleteSelf();
       
   131     void CompleteClientRequest( TInt aError );
       
   132     void Reset();
       
   133     
       
   134     TBool SilentHandlerL( const RFile& aFile );
       
   135     void ResolvingHttpPluginFromDRMHeaderHandlerL();
       
   136     void ResolvingHttpPluginFromFileHandleHandlerL();
       
   137     void RetrievingDRMHeaderFromFileHandleHandler();
       
   138     void ProcessingDRMHeaderHandler();
       
   139     void SendingDRMHeaderErrorHandler( TInt aError );
       
   140     void SentDRMHeaderErrorHandlerL();
       
   141     void RetrievingChallengeHandler();
       
   142     void RetrievingLicenseHandler();
       
   143     void AddingLicenseHandlerL();
       
   144     void ProcessingLicenseHandler();
       
   145     void SendingLicenseStorageStatusHandler();
       
   146     void SentLicenseStorageStatusHandler();
       
   147     void LicensingCompleteL();
       
   148     
       
   149     void ResolveHttpPluginL( const RFile& aFile );
       
   150     void ResolveHttpPluginL( const TDesC8& aDrmHeader );
       
   151     
       
   152     void ParseDrmHeaderL( const TDesC8& aDrmHeader, 
       
   153                           HBufC*& aLicenseServerUrl );
       
   154     void ParseLicenseResponseL( const TDesC8& aLicenseResponse, 
       
   155                                 HBufC8*& aTid, HBufC*& aContentUrl );
       
   156     
       
   157     void HandleErrorL( TInt aError );
       
   158     
       
   159     static TInt AsyncCancel( TAny* aPtr );
       
   160 
       
   161 private: // data
       
   162 
       
   163     enum THttpLicAcqPluginFwState
       
   164         {
       
   165         EIdle = 0,
       
   166         EResolvingHttpPluginFromDRMHeader,
       
   167         EResolvingHttpPluginFromFileHandle,
       
   168         ERetrievingDRMHeaderFromFileHandle,
       
   169         EProcessingDRMHeader,
       
   170         ESentDRMHeaderError,
       
   171         ERetrievingChallenge,
       
   172         ERetrievingLicense,
       
   173         EAddingLicense,
       
   174         EProcessingLicense,
       
   175         ESendingLicenseStorageStatus,
       
   176         ESentLicenseStorageStatus,
       
   177         ELicensingComplete
       
   178         };
       
   179 
       
   180     THttpLicAcqPluginFwState iState;
       
   181     CWmDrmDlaHttpPluginIf* iHttpPlugin;
       
   182     CWmDrmDlaUiNotifier* iUiNotifier;
       
   183     CWmDrmDlaParser* iDlaParser;
       
   184     CActiveSchedulerWait* iWait;
       
   185     CIdle* iIdle;
       
   186     TInt iIapId;
       
   187     TBool iSilentInitialised;
       
   188     
       
   189     HBufC8* iDrmHeader;
       
   190     HBufC* iLicenseServerUrl;
       
   191     HBufC8* iLicenseChallenge;
       
   192     HBufC8* iLicenseResponse;
       
   193     
       
   194     //Not owned
       
   195     HBufC* iErrorUrl;
       
   196     const RFile* iFile;
       
   197     HBufC** iContentUrl;
       
   198     HBufC** iHtmlData;
       
   199     TRequestStatus* iClientStatus;
       
   200     
       
   201     };
       
   202 
       
   203 
       
   204 #endif // C_WMDRMDLAHTTPLICACQPLUGINFW_H