wmdrm/camese/wmdrmdladefaulthttpplugin/inc/wmdrmdladefaultlicacq.h
changeset 0 95b198f216e5
equal deleted inserted replaced
-1:000000000000 0:95b198f216e5
       
     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:  WMDRM DLA Default Http License Acquisition
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_WMDRMDLADEFAULTLICACQ_H
       
    20 #define C_WMDRMDLADEFAULTLICACQ_H
       
    21 
       
    22 #include "wmdrmdlabrowserobserver.h"
       
    23 #include "wmdrmdladefaulthttpmanagerobserver.h"
       
    24 
       
    25 class CWmDrmDlaDefaultHttpPlugin;
       
    26 class CWmDrmDlaUiNotifier;
       
    27 class CWmDrmDlaDefaultHttpManager;
       
    28 class CWmDrmDlaBrowserViewHandler;
       
    29 class CHTTPFormEncoder;
       
    30 
       
    31 /**
       
    32  * WMDRM DLA Default Http License Acquisition
       
    33  * Reference implementation to demonstrate how to handle license acquisition
       
    34  * with the MS test site.
       
    35  * 
       
    36  * @lib wmdrmdladefaulthttpplugin.lib
       
    37  * @since S60 v9.1
       
    38  */
       
    39 NONSHARABLE_CLASS( CWmDrmDlaDefaultLicAcq ) 
       
    40     : public CBase, 
       
    41       public MWmDrmDlaBrowserObserver,
       
    42       public MWmDrmDlaDefaltHttpManagerObserver
       
    43     {
       
    44 
       
    45 public:
       
    46 
       
    47     static CWmDrmDlaDefaultLicAcq* NewL( CWmDrmDlaDefaultHttpPlugin* aPlugin );
       
    48     ~CWmDrmDlaDefaultLicAcq();
       
    49 
       
    50     /**
       
    51      * Check if file is supported by this plugin
       
    52      *
       
    53      * @param aFile WMDRM file
       
    54      * @param aUiNotifer If file is supported, contains initialized UI Notifier
       
    55      *                   upon completion. Will be deleted by the caller after 
       
    56      *                   the plugin has been deleted.
       
    57      * @return ETrue if file is supported by this plugin
       
    58      * @leave with standard Symbian error code in case of error
       
    59      */
       
    60      TBool SupportedFileL( const RFile& aFile, 
       
    61                            CWmDrmDlaUiNotifier*& aUiNotifier );
       
    62 
       
    63     /**
       
    64      * Check if DRM Header is supported by this plugin
       
    65      *
       
    66      * @param aHeader DRM Header
       
    67      * @param aUiNotifer If header is supported, contains initialized UI
       
    68      *                   Notifier upon completion. Will be deleted by the
       
    69      *                   caller after the plugin has been deleted.
       
    70      * @return ETrue if header is supported by this plugin
       
    71      * @leave with standard Symbian error code in case of error
       
    72      */
       
    73     TBool SupportedDrmHeaderL( const TDesC8& aHeader, 
       
    74                                CWmDrmDlaUiNotifier*& aUiNotifier );
       
    75 
       
    76     /**
       
    77      * Check if license acquisition should be silent for this file
       
    78      *
       
    79      * @param aFile WMDRM file
       
    80      * @return ETrue if file is supported by this plugin
       
    81      * @leave with standard Symbian error code in case of error
       
    82      */
       
    83     TBool SilentL( const RFile& aFile );
       
    84 
       
    85     /**
       
    86      * Process DRM Header. This method is used only to pass DRM Header to the
       
    87      * plugin. The framework does not require the plugin to do anything 
       
    88      *
       
    89      * @param aDrmHeader DRM Header
       
    90      * @leave with standard Symbian error code in case of fatal error (the 
       
    91      * framework does not proceed with license acquisition if this method
       
    92      * leaves)
       
    93      */
       
    94     void ProcessDrmHeaderL( const TDesC8& aDrmHeader );
       
    95 
       
    96     /**
       
    97      * Acquire License. 
       
    98      *
       
    99      * @param aLicenseChallenge License challenge based on which license
       
   100      *                          will be acquired.
       
   101      * @param aLicenseServerUrl URL where license challenge is sent
       
   102      * @param aStatus Request status, will contain error code upon completion
       
   103      * including but not limited to:
       
   104      * - KErrCancel if user cancelled the license acquisition at any point
       
   105      * - KErrCommsBreak if network connection was lost during communication 
       
   106      *                  with server
       
   107      * - KErrGeneral if unspecified error happened
       
   108      */
       
   109     void AcquireLicense( const TDesC8& aLicenseChallenge, 
       
   110                          HBufC* aLicenseServerUrl,
       
   111                          TRequestStatus& aStatus );
       
   112 
       
   113     /**
       
   114      * Get downloaded License. 
       
   115      *
       
   116      * @leave standard Symbian error code in case of error.
       
   117      * @return Buffer containing license data. Will be deleted by the caller.
       
   118      */
       
   119     HBufC8* GetLicenseResponseL();
       
   120 
       
   121     /**
       
   122      * Send license storage status. 
       
   123      *
       
   124      * @param aTid Transaction ID parsed from the license response, can be NULL
       
   125      * @param aUrl URL where license storage status is sent
       
   126      * @param aError License storage status.
       
   127      * @param aStatus Request status, will contain error code upon completion
       
   128      * including but not limited to:
       
   129      * - KErrCommsBreak if network connection was lost during communication
       
   130      *                  with server
       
   131      * - KErrGeneral if unspecified error happened
       
   132      */
       
   133     void SendLicenseStorageStatus( HBufC8* aTid, const TDesC& aUrl,
       
   134                                    TInt aError, TRequestStatus& aStatus );
       
   135     
       
   136     /**
       
   137      * Send error code to server if drm header parsing failed.
       
   138      *
       
   139      * @param   aErrorUrl   URL where error code is sent
       
   140      * @param   aError      Error code
       
   141      * @param aStatus Request status, will contain error code upon completion
       
   142      * including but not limited to:
       
   143      * - KErrCommsBreak if network connection was lost during communication
       
   144      *                  with server
       
   145      * - KErrGeneral if unspecified error happened
       
   146      */
       
   147     void SendDrmHeaderError( const TDesC& aErrorUrl, TInt aError, 
       
   148                              TRequestStatus& aStatus );
       
   149 
       
   150     /**
       
   151      * Get content url. Called only if framework fails to parse content URL 
       
   152      * from the license response. Needs to be implemented only if the supported
       
   153      * service uses non-standard way to pass the Content URL, otherwise this
       
   154      * can return NULL.
       
   155      *
       
   156      * @return Content URL, can be NULL. Will be deleted by the caller.
       
   157      */
       
   158     HBufC* GetContentUrlL();
       
   159 
       
   160     /**
       
   161      * Get HTML data returned by license server. 
       
   162      *
       
   163      * @return HTML data, can be NULL. Will be deleted by the caller.
       
   164      */
       
   165     HBufC* GetHtmlDataL();
       
   166 
       
   167     /*
       
   168      * Cancel license acquisition
       
   169      */
       
   170     void CancelLicenseAcquisition();
       
   171 
       
   172     /**
       
   173      * Sets the IAP to be used in the HTTP transactions
       
   174      *
       
   175      * @param   aIapId  Internet Access Point id
       
   176      */
       
   177     void SetIapId( TInt aIapId );
       
   178 
       
   179 public: // From MWmDrmDlaBrowserObserver
       
   180     
       
   181     const TDesC& PostUrlL();
       
   182     const TDesC8& PostContentTypeL();
       
   183     const TDesC8& PostDataL();
       
   184     const TDesC8& PostContentDataBoundaryL();
       
   185     TInt IapId();
       
   186     void LicenseResponseReceived( const TDesC8& aLicenseResponse );
       
   187     void BrowserExit( TInt aError );
       
   188 
       
   189 private: // From MWmDrmDlaDefaltHttpManagerObserver
       
   190     
       
   191     TBool OnGetUsernamePasswordL( HBufC8*& aUsername, HBufC8*& aPassword );
       
   192     void OnResponseHeadersL( const RHTTPResponse& aResponse, 
       
   193                              const RHTTPHeaders& aHeaders,
       
   194                              const RStringPool& aStringPool, 
       
   195                              TInt aHttpStatus );
       
   196     void OnResponseBodyDataL( const TPtrC8 aDataChunk );
       
   197     void OnTransactionComplete( TInt aSystemError );
       
   198     
       
   199 private:
       
   200 
       
   201     CWmDrmDlaDefaultLicAcq( CWmDrmDlaDefaultHttpPlugin* aPlugin );
       
   202     void ConstructL();
       
   203     
       
   204     void CompleteClientRequest( TInt aError );
       
   205     
       
   206     void AcquireLicenseL();
       
   207     void SendLicenseStorageStatusL( const TDesC8& aTid, TInt aError );
       
   208     TInt MakeHRESULT( TInt aError );
       
   209     void SendHRESULTL( const TDesC8& aUrl, const TDesC8& aHeaderField, 
       
   210                        TInt aHRESULT );
       
   211     
       
   212     void HandleRedirectionHeadersL( const RHTTPHeaders& aHeaders,
       
   213                                     const RStringPool& aStringPool );
       
   214     void HandleLicenseAcquistionHeaders( const RHTTPHeaders& aHeaders,
       
   215                                          const RStringPool& aStringPool );
       
   216     
       
   217     void LaunchBrowserViewL();
       
   218     
       
   219     static TInt Redirection( TAny* aPtr );
       
   220     
       
   221 private: // data
       
   222     
       
   223     enum TLicAcqState
       
   224         {
       
   225         ENotActive,
       
   226         ESendingLicenseChallenge,
       
   227         ENonSilentLicenseAcquisition,
       
   228         ERedirection,
       
   229         ESendingStorageStatus,
       
   230         EBrowserView
       
   231         };
       
   232     
       
   233     TLicAcqState iState;
       
   234     CWmDrmDlaDefaultHttpManager* iHttpManager;
       
   235     CHTTPFormEncoder* iFormEncoder;
       
   236     CIdle* iIdle;
       
   237     CWmDrmDlaBrowserViewHandler* iBrowserViewHandler;
       
   238     TInt iHttpStatus;
       
   239     TBool iNonSilent;
       
   240     HBufC8* iLicenseChallenge;
       
   241     HBufC8* iPostData;
       
   242     HBufC8* iLicenseResponse;
       
   243     HBufC* iLicenseServerUrl16;
       
   244     HBufC8* iLicenseServerUrl;
       
   245     HBufC* iHtmlData;
       
   246     
       
   247     //Not owned
       
   248     CWmDrmDlaDefaultHttpPlugin* iPlugin;
       
   249     TRequestStatus* iClientStatus;
       
   250     
       
   251     };
       
   252 
       
   253 #endif // C_WMDRMDLADEFAULTLICACQ_H