inc/DrmUtilityDmgrWrapper.h
branchRCL_3
changeset 72 1481bf457703
parent 71 1221b68b8a5f
equal deleted inserted replaced
71:1221b68b8a5f 72:1481bf457703
     1 /*
     1 /*
     2 * Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2007 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 <f32file.h> // RFs
    22 #include <downloadmgrclient.h>
    23 #include <RoapObserver.h> // Roap::MRoapObserver
    23 #include <AknProgressDialog.h>
    24 #include <AknProgressDialog.h> // MAknProgressDialogCallback CAknProgressDialog
    24 #include <eikprogi.h>
    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;
       
    44 
    25 
    45 /**
    26 /**
    46 * Environment gate function
    27 * Environment gate function
    47 *
    28 *
    48 * @since S60 v5.0
    29 * @since S60 v5.0
    67 *  Class for downloading ROAP triggers
    48 *  Class for downloading ROAP triggers
    68 *
    49 *
    69 *  @lib DrmUtilityDmgrWrapper
    50 *  @lib DrmUtilityDmgrWrapper
    70 *  @since S60 v5.0
    51 *  @since S60 v5.0
    71 */
    52 */
    72 class CDrmUtilityDmgrWrapper :
    53 class CDrmUtilityDmgrWrapper : CBase,
    73     public CActive,
    54     public MHttpDownloadMgrObserver,
    74     public Roap::MRoapObserver,
       
    75     public MDrmUtilityDmgrWrapper,
    55     public MDrmUtilityDmgrWrapper,
    76     public MProgressDialogCallback
    56     public MProgressDialogCallback
    77     {
    57     {
    78 private:
       
    79 
    58 
    80     enum TDownloadState
       
    81         {
       
    82         EInit,
       
    83         EGetMeteringTrigger,
       
    84         ESaveMeteringTrigger,
       
    85         EMeteringReportSubmit,
       
    86         EGetPrUrlTrigger,
       
    87         ESavePrUrlTrigger,
       
    88         EPrRoapRequest,
       
    89         EComplete
       
    90         };
       
    91 public:
    59 public:
    92 
    60 
    93     static CDrmUtilityDmgrWrapper* NewL();
    61     static CDrmUtilityDmgrWrapper* NewL();
    94 
    62 
    95     static CDrmUtilityDmgrWrapper* NewLC();
    63     static CDrmUtilityDmgrWrapper* NewLC();
   106     void DownloadAndHandleRoapTriggerL( const HBufC8* aUrl,
    74     void DownloadAndHandleRoapTriggerL( const HBufC8* aUrl,
   107         CCoeEnv& aCoeEnv );
    75         CCoeEnv& aCoeEnv );
   108 
    76 
   109     HBufC8* GetErrorUrlL();
    77     HBufC8* GetErrorUrlL();
   110 
    78 
   111 // From Roap::MRoapObserver
    79 
   112     /**
    80     // from base class MHttpDownloadMgrObserver
   113     * ConnectionConfL
       
   114     * @return ETrue: the network can be establish
       
   115     *         EFalse: the ROAP transaction is canceled
       
   116     *
       
   117     * @leave  System wide error code */
       
   118     TBool ConnectionConfL();
       
   119 
    81 
   120     /**
    82     /**
   121     * ContactRiConfL
    83     * From MHttpDownloadMgrObserver.
   122     * @return ETrue: the user consent is achieved
    84     * Handle download manager events
   123     *         EFalse: the user consent is not achieved
       
   124     *
    85     *
   125     * @leave  System wide error code */
    86     * @param aDownload the download
   126     TBool ContactRiConfL();
    87     * @param aEvent the event
   127 
    88     */
   128     /**
    89     void HandleDMgrEventL( RHttpDownload& aDownload, THttpDownloadEvent aEvent );
   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 );
       
   236 
    90 
   237 public: // Call back methods of MAknProgressDialogCallback
    91 public: // Call back methods of MAknProgressDialogCallback
   238 
    92 
   239     /**
    93     /**
   240     * ProgressDialog call back method.
    94     * ProgressDialog call back method.
   241     * Get's called when a dialog is dismissed.
    95     * Get's called when a dialog is dismissed.
   242     *
    96     *
   243     * @param aButtonId ID of the button pressed
    97     * @param aButtonId ID of the button pressed
   244     */
    98     */
   245     void DialogDismissedL( TInt aButtonId );
    99     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 );
       
   254 
   100 
   255 protected:
   101 protected:
   256     //from Cactive
       
   257     virtual void DoCancel();
       
   258 
   102 
   259     virtual void RunL();
       
   260 
       
   261     virtual TInt RunError( TInt aError );
       
   262 private:
   103 private:
   263 
   104 
   264     /**
   105     /**
   265     * C++ default constructor.
   106     * C++ default constructor.
   266     */
   107     */
   269     void ConstructL();
   110     void ConstructL();
   270 
   111 
   271     /**
   112     /**
   272     * Set the browser default access point to be used
   113     * Set the browser default access point to be used
   273     */
   114     */
       
   115     void SetDefaultAccessPointL();
   274 
   116 
       
   117     void DoDownloadAndHandleRoapTriggerL( const HBufC8* aUrl );
   275 
   118 
   276     void ShowProgressNoteL( );
   119     void ShowProgressNoteL( );
   277 
   120 
   278     void RemoveProgressNoteL( );
   121     void RemoveProgressNoteL( );
   279 
   122 
   280     void DoConnectL( TDownloadState aNextState );
   123     void HandlePostResponseUrlL();
   281 
   124 
   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 );
       
   291 
   125 
   292 private: // data
   126 private: // data
   293 
   127 
   294     /**
   128     /**
   295     * Download manager session
   129     * Download manager session
   296     */
   130     */
   297     WRT::DownloadManager* iDlMgr;
   131     RHttpDownloadMgr iDlMgr;
   298 
   132 
   299     /**
       
   300      * Download instance needs to be stored for handling signal slot mechanism
       
   301      */
       
   302     WRT::Download* iDownload;
       
   303     
       
   304     /**
   133     /**
   305     * Used to make downloads synchronous
   134     * Used to make downloads synchronous
   306     */
   135     */
   307     CActiveSchedulerWait iWait;
   136     CActiveSchedulerWait iWait;
   308 
   137 
   309     /**
   138     /**
   310     * to store information on download
   139     * to store information on download
   311     */
   140     */
   312     TBool iDownloadSuccess;
   141     TBool iDownloadSuccess;
   313     TBool iConnectionError;
   142     TBool iConnectionError;
   314 
       
   315     /**
       
   316     * trigger URL
       
   317     */
       
   318     HBufC8* iTriggerUrl;
       
   319 
       
   320     /**
       
   321     * trigger buffer
       
   322     */
       
   323     HBufC8* iTriggerBuf;
       
   324 
   143 
   325     TBool iDialogDismissed;
   144     TBool iDialogDismissed;
   326 
   145 
   327     /**
   146     /**
   328     * Progess note dialog and progress info
   147     * Progess note dialog and progress info
   350     /**
   169     /**
   351     * Post response url for ROAP prUrl
   170     * Post response url for ROAP prUrl
   352     */
   171     */
   353     HBufC8* iPostResponseUrl;
   172     HBufC8* iPostResponseUrl;
   354 
   173 
   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; 
       
   371     };
   174     };
   372 
   175 
   373 #endif // CDRMUTILITYDMGRWRAPPER_H
   176 #endif // CDRMUTILITYDMGRWRAPPER_H