inc/DrmUtilityDmgrWrapper.h
branchRCL_3
changeset 26 1221b68b8a5f
parent 13 a20e54f39dd4
child 27 1481bf457703
equal deleted inserted replaced
25:50c53e893c3f 26:1221b68b8a5f
     1 /*
     1 /*
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    17 
    17 
    18 
    18 
    19 #ifndef CDRMUTILITYDMGRWRAPPER_H
    19 #ifndef CDRMUTILITYDMGRWRAPPER_H
    20 #define CDRMUTILITYDMGRWRAPPER_H
    20 #define CDRMUTILITYDMGRWRAPPER_H
    21 
    21 
    22 #include <downloadmgrclient.h>
    22 #include <f32file.h> // RFs
    23 #include <AknProgressDialog.h>
    23 #include <RoapObserver.h> // Roap::MRoapObserver
    24 #include <eikprogi.h>
    24 #include <AknProgressDialog.h> // MAknProgressDialogCallback CAknProgressDialog
       
    25 
       
    26 // download apis
       
    27 #include <downloadmanager.h>
       
    28 #include <download.h>
       
    29 #include <downloadevent.h>
       
    30 
       
    31 namespace Roap
       
    32     {
       
    33     class CRoapEng;
       
    34     }
       
    35 
       
    36 namespace DRM
       
    37     {
       
    38     class CDrmUtilityConnection;
       
    39     }
       
    40 class CDRMRights;
       
    41 class CEikProgressInfo;
       
    42 class DrmUtilityEventHandler;
       
    43 class QDrmUtilityDmgrEventHandler;
    25 
    44 
    26 /**
    45 /**
    27 * Environment gate function
    46 * Environment gate function
    28 *
    47 *
    29 * @since S60 v5.0
    48 * @since S60 v5.0
    48 *  Class for downloading ROAP triggers
    67 *  Class for downloading ROAP triggers
    49 *
    68 *
    50 *  @lib DrmUtilityDmgrWrapper
    69 *  @lib DrmUtilityDmgrWrapper
    51 *  @since S60 v5.0
    70 *  @since S60 v5.0
    52 */
    71 */
    53 class CDrmUtilityDmgrWrapper : CBase,
    72 class CDrmUtilityDmgrWrapper :
    54     public MHttpDownloadMgrObserver,
    73     public CActive,
       
    74     public Roap::MRoapObserver,
    55     public MDrmUtilityDmgrWrapper,
    75     public MDrmUtilityDmgrWrapper,
    56     public MProgressDialogCallback
    76     public MProgressDialogCallback
    57     {
    77     {
    58 
    78 private:
       
    79 
       
    80     enum TDownloadState
       
    81         {
       
    82         EInit,
       
    83         EGetMeteringTrigger,
       
    84         ESaveMeteringTrigger,
       
    85         EMeteringReportSubmit,
       
    86         EGetPrUrlTrigger,
       
    87         ESavePrUrlTrigger,
       
    88         EPrRoapRequest,
       
    89         EComplete
       
    90         };
    59 public:
    91 public:
    60 
    92 
    61     static CDrmUtilityDmgrWrapper* NewL();
    93     static CDrmUtilityDmgrWrapper* NewL();
    62 
    94 
    63     static CDrmUtilityDmgrWrapper* NewLC();
    95     static CDrmUtilityDmgrWrapper* NewLC();
    74     void DownloadAndHandleRoapTriggerL( const HBufC8* aUrl,
   106     void DownloadAndHandleRoapTriggerL( const HBufC8* aUrl,
    75         CCoeEnv& aCoeEnv );
   107         CCoeEnv& aCoeEnv );
    76 
   108 
    77     HBufC8* GetErrorUrlL();
   109     HBufC8* GetErrorUrlL();
    78 
   110 
    79 
   111 // From Roap::MRoapObserver
    80     // from base class MHttpDownloadMgrObserver
   112     /**
    81 
   113     * ConnectionConfL
    82     /**
   114     * @return ETrue: the network can be establish
    83     * From MHttpDownloadMgrObserver.
   115     *         EFalse: the ROAP transaction is canceled
    84     * Handle download manager events
   116     *
    85     *
   117     * @leave  System wide error code */
    86     * @param aDownload the download
   118     TBool ConnectionConfL();
    87     * @param aEvent the event
   119 
    88     */
   120     /**
    89     void HandleDMgrEventL( RHttpDownload& aDownload, THttpDownloadEvent aEvent );
   121     * ContactRiConfL
       
   122     * @return ETrue: the user consent is achieved
       
   123     *         EFalse: the user consent is not achieved
       
   124     *
       
   125     * @leave  System wide error code */
       
   126     TBool ContactRiConfL();
       
   127 
       
   128     /**
       
   129     * TransIdConfL
       
   130     * @return ETrue: the user consent is achieved
       
   131     *         EFalse: the user consent is not achieved
       
   132     *
       
   133     * @leave  System wide error code */
       
   134 
       
   135     TBool TransIdConfL();
       
   136 
       
   137     /**
       
   138     * RightsObjectDetailsL
       
   139     *
       
   140     * The function is called after successful completion of RO acquisition
       
   141     * protocol. The passes information about stored rights objects to the
       
   142     * observer.
       
   143     *
       
   144     * @since  3.0
       
   145     * @param aRightsList: A list of pointers to rights objects.
       
   146     *                     Contents of aRightsList are owend by ROAP engine
       
   147     *
       
   148     * @leave  System wide error code */
       
   149     void RightsObjectDetailsL( const RPointerArray<CDRMRights>& aRightsList );
       
   150 
       
   151     /**
       
   152     * ContentDownloadInfoL
       
   153     *
       
   154     * The function is called when the ROAP engine notices that it is about to
       
   155     * receive a multipart content as a ROAP response. The method must return via
       
   156     * out-parameter the path to a temp folder where the content is saved during
       
   157     * download. The name that is used as filename when saving the content to
       
   158     * the appropriate palce and the maximum size of the content (a safety upper limit)
       
   159     * must also be provided via out-parameters.
       
   160     *
       
   161     * @since 3.0
       
   162     * @param aTempFolder: (out-param) The path of the temp folder, or KNullDesC
       
   163     * @param aContentName: (out-param) The name of the content, or KNullDesC (defaut name is used)
       
   164     * @param aMaxSize: (out-param) The maximum size of the content, or -1 if not known
       
   165     *
       
   166     * @leave System wide error code */
       
   167 
       
   168     void ContentDownloadInfoL( TPath& aTempFolder,
       
   169             TFileName& aContentName,
       
   170             TInt& aMaxSize );
       
   171 
       
   172     /**
       
   173     * ContentDetailsL
       
   174     *
       
   175     * The function is called when the ROAP engine has received a DCF content (together
       
   176     * with a ROAP response) The ROAP engine saves the DCF to the appropriate location
       
   177     * and gives out the information about the saved DCF file by calling this method
       
   178     *
       
   179     * @since 3.0
       
   180     * @param aPath: The path andf the filename of the saved DCF file
       
   181     * @param aType: The plain MIME type of the saved DCF file
       
   182     * @param aAppUid: The handler app UID of the saved DCF file
       
   183     *
       
   184     * @leave System wide error code */
       
   185 
       
   186     void ContentDetailsL( const TDesC& aPath,
       
   187             const TDesC8& aType,
       
   188             const TUid& aAppUid );
       
   189 
       
   190     /**
       
   191     * RoapProgressInfoL
       
   192     *
       
   193     * The function provides progress information about ROAP processing to the
       
   194     * observer
       
   195     *
       
   196     * @since  3.0
       
   197     * @param aProgressInfo: An integer value representing the state of
       
   198     *                       ROAP processing, counting in bytes
       
   199     *
       
   200     * @leave  System wide error code */
       
   201 
       
   202     void RoapProgressInfoL( const TInt aProgressInfo );
       
   203 
       
   204     /**
       
   205     * ErrorUrlL
       
   206     *
       
   207     * The function is called in ROAP error case and it provides an error URL
       
   208     * for the caller. The calling entity should send an HTTP GET request to
       
   209     * the URL which should then return an HTML page.
       
   210     *
       
   211     * @since  3.0
       
   212     * @param aErrorUrl: The error URL
       
   213     *
       
   214     *
       
   215     * @leave  System wide error code */
       
   216 
       
   217     void ErrorUrlL( const TDesC8& aErrorUrl );
       
   218 
       
   219     /**
       
   220     * PostResponseUrlL
       
   221     *
       
   222     * The function is called if handled ROAP metering report response
       
   223     * contains PostResponseURL extension. The calling entity should send
       
   224     * an HTTP GET request to the URL, which should return ROAP trigger,
       
   225     * download descriptor or multipart message containing both
       
   226     * download descriptor and ROAP trigger.
       
   227     *
       
   228     * @since  3.2
       
   229     * @param aPostResponseUrl: The URL to be fetched
       
   230     *                          after handling ROAP metering response
       
   231     *                          with PostResponseURL extension.
       
   232     *
       
   233     *
       
   234     * @leave  System wide error code */
       
   235     void PostResponseUrlL( const TDesC8& aPostResponseUrl );
    90 
   236 
    91 public: // Call back methods of MAknProgressDialogCallback
   237 public: // Call back methods of MAknProgressDialogCallback
    92 
   238 
    93     /**
   239     /**
    94     * ProgressDialog call back method.
   240     * ProgressDialog call back method.
    95     * Get's called when a dialog is dismissed.
   241     * Get's called when a dialog is dismissed.
    96     *
   242     *
    97     * @param aButtonId ID of the button pressed
   243     * @param aButtonId ID of the button pressed
    98     */
   244     */
    99     void DialogDismissedL( TInt aButtonId );
   245     void DialogDismissedL( TInt aButtonId );
       
   246     
       
   247     /**
       
   248 	* Handle download manager events
       
   249 	*
       
   250 	* @param aEvent the event
       
   251 	*/
       
   252             
       
   253     void HandleDownloadEventL( WRT::DownloadEvent* aEvent );
   100 
   254 
   101 protected:
   255 protected:
   102 
   256     //from Cactive
       
   257     virtual void DoCancel();
       
   258 
       
   259     virtual void RunL();
       
   260 
       
   261     virtual TInt RunError( TInt aError );
   103 private:
   262 private:
   104 
   263 
   105     /**
   264     /**
   106     * C++ default constructor.
   265     * C++ default constructor.
   107     */
   266     */
   110     void ConstructL();
   269     void ConstructL();
   111 
   270 
   112     /**
   271     /**
   113     * Set the browser default access point to be used
   272     * Set the browser default access point to be used
   114     */
   273     */
   115     void SetDefaultAccessPointL();
   274 
   116 
       
   117     void DoDownloadAndHandleRoapTriggerL( const HBufC8* aUrl );
       
   118 
   275 
   119     void ShowProgressNoteL( );
   276     void ShowProgressNoteL( );
   120 
   277 
   121     void RemoveProgressNoteL( );
   278     void RemoveProgressNoteL( );
   122 
   279 
   123     void HandlePostResponseUrlL();
   280     void DoConnectL( TDownloadState aNextState );
   124 
   281 
       
   282     void DoDownloadRoapTriggerL( TDownloadState aNextState );
       
   283 
       
   284     void DoSaveRoapTriggerL( TDownloadState aNextState );
       
   285 
       
   286     void DoHandleRoapTriggerL( TDownloadState aNextState );
       
   287 
       
   288     void CompleteToState( TDownloadState aNextState, TInt aError );
       
   289     
       
   290     void ProcessDownloadEventL( WRT::Download& aDownload, WRT::DownloadEvent& aEvent );
   125 
   291 
   126 private: // data
   292 private: // data
   127 
   293 
   128     /**
   294     /**
   129     * Download manager session
   295     * Download manager session
   130     */
   296     */
   131     RHttpDownloadMgr iDlMgr;
   297     WRT::DownloadManager* iDlMgr;
   132 
   298 
       
   299     /**
       
   300      * Download instance needs to be stored for handling signal slot mechanism
       
   301      */
       
   302     WRT::Download* iDownload;
       
   303     
   133     /**
   304     /**
   134     * Used to make downloads synchronous
   305     * Used to make downloads synchronous
   135     */
   306     */
   136     CActiveSchedulerWait iWait;
   307     CActiveSchedulerWait iWait;
   137 
   308 
   138     /**
   309     /**
   139     * to store information on download
   310     * to store information on download
   140     */
   311     */
   141     TBool iDownloadSuccess;
   312     TBool iDownloadSuccess;
   142     TBool iConnectionError;
   313     TBool iConnectionError;
       
   314 
       
   315     /**
       
   316     * trigger URL
       
   317     */
       
   318     HBufC8* iTriggerUrl;
       
   319 
       
   320     /**
       
   321     * trigger buffer
       
   322     */
       
   323     HBufC8* iTriggerBuf;
   143 
   324 
   144     TBool iDialogDismissed;
   325     TBool iDialogDismissed;
   145 
   326 
   146     /**
   327     /**
   147     * Progess note dialog and progress info
   328     * Progess note dialog and progress info
   169     /**
   350     /**
   170     * Post response url for ROAP prUrl
   351     * Post response url for ROAP prUrl
   171     */
   352     */
   172     HBufC8* iPostResponseUrl;
   353     HBufC8* iPostResponseUrl;
   173 
   354 
       
   355     /**
       
   356     * IAP (from ROAP or from UI)
       
   357     */
       
   358     TUint32 iIapId;
       
   359 
       
   360     TDownloadState iState;
       
   361 
       
   362     Roap::CRoapEng* iRoapEng;
       
   363 
       
   364     RFs iFs;
       
   365 
       
   366     HBufC* iFileName;
       
   367 
       
   368     DRM::CDrmUtilityConnection* iConnection;
       
   369     
       
   370     QDrmUtilityDmgrEventHandler* iDrmUtilityDmgrEventHandler; 
   174     };
   371     };
   175 
   372 
   176 #endif // CDRMUTILITYDMGRWRAPPER_H
   373 #endif // CDRMUTILITYDMGRWRAPPER_H