browserutilities/downloadmgr/DownloadMgrUiLib/Inc/CUserInteractionsUtils.h
changeset 0 dd21522fd290
child 16 a359256acfc6
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2002-2004 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 the License "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:  Supports user interaction dialogs for downloads, etc.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CUSERINTERACTIONSUTILS_H
       
    21 #define CUSERINTERACTIONSUTILS_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <E32DEF.H>
       
    26 #include <e32std.h>
       
    27 #include <apparc.h>
       
    28 #include <HttpDownloadMgrCommon.h>
       
    29 #include <vwsdef.h>
       
    30 #include <AknServerApp.h>
       
    31 #include "CDownloadUtils.h"
       
    32 #include <AknTaskList.h>
       
    33 
       
    34 // FORWARD DECLARATIONS
       
    35 class RHttpDownload;
       
    36 class CDocumentHandler;
       
    37 class MDownloadHandlerObserver;
       
    38 class CDownloadMgrUiBase;
       
    39 class MDownloadMgrUiLibRegModel;
       
    40 class CCoeEnv;
       
    41 class CAknFileSelectionDialog;
       
    42 class CAknMemorySelectionDialog;
       
    43 class CAknInformationNote;
       
    44 class CBrowserDialogsProvider;
       
    45 class CAknSoftNotifier;
       
    46 class CErrorUI;
       
    47 class CAknQueryDialog;
       
    48 class CDownloadMgrUiDownloadsList;
       
    49 
       
    50 // CONSTANTS
       
    51 LOCAL_D const TInt KMinLength = 1024;
       
    52 
       
    53 /// Active object priority. Must be greater than HTTP fw's active objects'.
       
    54 LOCAL_C const TInt KUiLibAOPriority = CActive::EPriorityStandard + 2;
       
    55 
       
    56 //TODO: it will be replaced when DocumentHandler will introduce a new API to get PDAppsUids (from DocConstants.h temp)
       
    57 // Progressive Download App Uids
       
    58 const TInt KDocPDAppUidList[] = 
       
    59     { 
       
    60     0x102824CD, // Lightweight Player application.
       
    61     0x102072C3  // Music Player application.
       
    62     };    
       
    63 // Amount of elements in KDocProgDlAppUidList array.
       
    64 const TInt KDocPDAppUidCount = sizeof( KDocPDAppUidList ) / sizeof ( TInt );
       
    65 
       
    66 
       
    67 // CLASS DECLARATION
       
    68 
       
    69 /**
       
    70 *  Supports user interaction dialogs for downloads, etc.
       
    71 */
       
    72 NONSHARABLE_CLASS( CUserInteractionsUtils ) : public CDownloadUtils,
       
    73                                               private MAknServerAppExitObserver
       
    74     {
       
    75     public:  // Constructors and destructor
       
    76         
       
    77         /**
       
    78         * Two-phased constructor.
       
    79         * &param aDMgrUiBase Reference to UI base functionality.
       
    80         */
       
    81         static CUserInteractionsUtils* NewL( CDownloadMgrUiBase& aDMgrUiBase, 
       
    82                                              MDownloadMgrUiLibRegModel& aRegistryModel );
       
    83         
       
    84         /**
       
    85         * Destructor.
       
    86         */
       
    87         virtual ~CUserInteractionsUtils();
       
    88 
       
    89     public: // New functions
       
    90 
       
    91         /**
       
    92         * Show error notification.
       
    93         * @param aDownload The actual download
       
    94         * @param aErrorId The DMgr specific error id.
       
    95         * @return -
       
    96         */
       
    97         void ShowErrorNoteL( RHttpDownload& aDownload, TInt32 aErrorId );
       
    98 
       
    99         /**
       
   100         * Show error notification.
       
   101         * @param aErrorId The DMgr specific error id.
       
   102         * @return -
       
   103         */
       
   104         void ShowErrorNoteL( TInt aErrorId );
       
   105 
       
   106         /**
       
   107         * Check if the download can be resumed after a fail.
       
   108         * @param aDownload The actual download.
       
   109         * @param aErrorId The DMgr specific error id.
       
   110         * @return True/False.
       
   111         */
       
   112         TBool IsRecoverableFailL( RHttpDownload& aDownload, TInt32 aErrorId ) const;
       
   113 
       
   114         /**
       
   115         * Handle downloaded content: open viewer application embedded.
       
   116         * @param aDownload The actual download
       
   117         * @param aHandlerObserver Handler application observer pointer.
       
   118         * @return None. Content is handled successfully.
       
   119         */
       
   120         void HandleContentL( RHttpDownload& aDownload, 
       
   121                              MDownloadHandlerObserver& aHandlerObserver );
       
   122 
       
   123         /**
       
   124         * Save (move) downloaded content.
       
   125         * @param aDownload The actual download
       
   126         * @return Content saved or not.
       
   127         */
       
   128         TBool SaveContentL( RHttpDownload& aDownload );
       
   129 
       
   130         /**
       
   131         * Save (move) downloaded content to where user selects.
       
   132         * @param aDownload The actual download
       
   133         * @return Content saved or not.
       
   134         */
       
   135         TBool SaveContentWithPathSelectionL( RHttpDownload& aDownload );
       
   136 
       
   137         /**
       
   138         * Cancel the memory selection dialog.
       
   139         * @return None.
       
   140         */
       
   141         void CancelMemorySelectionDialog();
       
   142 
       
   143         /**
       
   144         * Cancel the file selection dialog.
       
   145         * @return None.
       
   146         */
       
   147         void CancelFileSelectionDialog();
       
   148 
       
   149         /**
       
   150         * Delete the download with user confirmation.
       
   151         * @param aDownload The actual download
       
   152         * @return Deleted or not.
       
   153         */
       
   154         TBool DeleteWithUserConfirmL( RHttpDownload& aDownload );
       
   155 
       
   156         /**
       
   157         * Cancel the delete confirmation dialog.
       
   158         * @return None.
       
   159         */
       
   160         void CancelDeleteConfirmationDialog();
       
   161 
       
   162         /**
       
   163         * Cancel the download with user confirmation. In fact it deletes the download.
       
   164         * @param aDownload The actual download
       
   165         * @return Deleted or not.
       
   166         */
       
   167         TBool CancelWithUserConfirmL( RHttpDownload& aDownload );
       
   168         
       
   169         /**
       
   170         * Cancel the download with user confirmation. In fact it deletes the download.
       
   171         * @param aDownload The actual download
       
   172         * @return Deleted or not.
       
   173         */
       
   174         TBool CancelAllWithUserConfirmL( RHttpDownload& aDownload );
       
   175 
       
   176         /**
       
   177         * Cancel the cancel confirmation dialog.
       
   178         * @return None.
       
   179         */
       
   180         void CancelCancelConfirmationDialog();
       
   181 
       
   182         /**
       
   183         * Show media removed notification.
       
   184         * @return None.
       
   185         */
       
   186         void ShowMediaRemovedNoteL();
       
   187 
       
   188         /**
       
   189         * Cancel media removed notification.
       
   190         * @return None.
       
   191         */
       
   192         void CancelMediaRemovedNote();
       
   193 
       
   194         /**
       
   195         * Ask HTTP authentication credentials from user.
       
   196         * @return Continue: yes/no.
       
   197         */
       
   198         TBool GetAndSetHttpAuthCredentialsL( RHttpDownload& aDownload );
       
   199 
       
   200         /**
       
   201         * Ask proxy authentication credentials from user.
       
   202         * @return Continue: yes/no.
       
   203         */
       
   204         TBool GetAndSetProxyAuthCredentialsL( RHttpDownload& aDownload );
       
   205 
       
   206         /**
       
   207         * Cancel HTTP and proxy credentials queries.
       
   208         * @return None.
       
   209         */
       
   210         void CancelCredentialsQueries();
       
   211 
       
   212         /**
       
   213         * Display security warning. User can cancel the query.
       
   214         * @return Continue: yes/no.
       
   215         */
       
   216         TBool DisplaySecurityWarningL();
       
   217 
       
   218         /**
       
   219         * Cancel security warning.
       
   220         * @return None.
       
   221         */
       
   222         void CancelSecurityWarning();
       
   223 
       
   224         /**
       
   225         * Browser setting: need security warning?
       
   226         * @return True if needed.
       
   227         */
       
   228         TBool BrowserSettingSecWarningL();
       
   229 
       
   230         /**
       
   231         * Initialize the stand-alone soft notification.
       
   232         * @return -
       
   233         */
       
   234         void InitializeSoftNotifStndL( TVwsViewId aViewId, 
       
   235                                  TUid aCustomMessageId, 
       
   236                                  const TDesC8& aViewActivationMsg ) const;
       
   237 
       
   238         /**
       
   239         * Initialize the embedded soft notification.
       
   240         * @return -
       
   241         */
       
   242         void InitializeSoftNotifEmbL( TVwsViewId aViewId, 
       
   243                                 TUid aCustomMessageId, 
       
   244                                 const TDesC8& aViewActivationMsg ) const;
       
   245 
       
   246         /**
       
   247         * Cancel the stand-alone soft notification. Leaving fn.!
       
   248         * @return -
       
   249         */
       
   250         void CancelSoftNotifStndL( TVwsViewId aViewId, 
       
   251                                   TUid aCustomMessageId, 
       
   252                                   const TDesC8& aViewActivationMsg ) const;
       
   253 
       
   254         /**
       
   255         * Cancel the embedded soft notification. Leaving fn.!
       
   256         * @return -
       
   257         */
       
   258         void CancelSoftNotifEmbL( TVwsViewId aViewId, 
       
   259                                  TUid aCustomMessageId, 
       
   260                                  const TDesC8& aViewActivationMsg ) const;
       
   261 
       
   262         /**
       
   263         * Cancel all dialogs shown by CUserInteractionsUtils.
       
   264         * @return None.
       
   265         */
       
   266         void CancelAllDialogs();
       
   267 
       
   268         /**
       
   269         * Display an information note with no buttons.
       
   270         * @param aDialogResourceId Resource id of note to display.
       
   271         * @param aPromptResourceId Resource id of the prompt.
       
   272         */
       
   273         static void InfoNoteL( TInt aDialogResourceId, const TInt aPromptResourceId );
       
   274 
       
   275         /**
       
   276         * Display an information note with no buttons.
       
   277         * @param aDialogResourceId Resource id of note to display.
       
   278         * @param aPrompt Prompt to display.
       
   279         */
       
   280         static void InfoNoteL( TInt aDialogResourceId, const TDesC& aPrompt );
       
   281 
       
   282         /**
       
   283         * Is something using the UI?
       
   284         * @return yes/no.
       
   285         */
       
   286         TBool IsUiBusy() const;
       
   287 
       
   288         /**
       
   289         * Is the DocHandler running?.
       
   290         * @return yes/no.
       
   291         */
       
   292         TBool IsDocHandlerRunning() const;
       
   293 
       
   294         /**
       
   295         * Check if the download is DRM DCF and corrupted.
       
   296         * @param aDownload The actual download
       
   297         * @return ETrue/EFalse
       
   298         */
       
   299         TBool IsCorruptedDcfL( RHttpDownload& aDownload ) const;
       
   300 
       
   301         /**
       
   302         * Check if the MIME type is correct in DRM DCF.
       
   303         * @param aDownload The actual download
       
   304         * @return ETrue/EFalse
       
   305         */
       
   306         TBool IsBadMimeInDcfL( RHttpDownload& aDownload ) const;
       
   307 
       
   308         /**
       
   309         * Indicate to Utils, that the download has been deleted.
       
   310         * @param aDownload The actual download.
       
   311         * @return -
       
   312         */
       
   313         void DownloadHasBeenDeleted( RHttpDownload* aDownload );
       
   314 
       
   315         /**
       
   316         * Launch application for PD playing.
       
   317         * @param aDownload The actual download 
       
   318         * @return void 
       
   319         */
       
   320         void LaunchPdAppL( RHttpDownload& aDownload, const TBool aProgressively );
       
   321 
       
   322         /**
       
   323         * Query if the phone is a 3G network.
       
   324         * @return ETrue if the phone is in 3G network.
       
   325         */
       
   326         TBool IsNetworkPdCompatibleL() const;
       
   327 
       
   328         /**
       
   329         * Sends a message to the PD applications (MP, VP )
       
   330         * before browser exits
       
   331         */
       
   332         void SendMsgTerminateToPdAppsL();
       
   333 
       
   334 		/**
       
   335 		* Checks if the WLAN is available
       
   336 		*/
       
   337         TBool GetWlanAvailabilityL() const;
       
   338 
       
   339 
       
   340 #ifdef __DMGR_PD_TESTHARNESS
       
   341         /**
       
   342         * Launch test application for PD playing.
       
   343         */
       
   344         void TestLaunchPdAppL( RHttpDownload& aDownload );
       
   345 #endif
       
   346 
       
   347         /**
       
   348         * Check if several conditions are met for Progressive Playback
       
   349         */
       
   350         TBool CanLaunchAsProgDownload( RHttpDownload& aDownload, CDownloadMgrUiDownloadsList& dlList, TBool isOma2Dl );
       
   351 
       
   352         /**
       
   353         * Update saved file to DCFRepository  
       
   354         */
       
   355         void UpdateDCFRepositoryL( const TDesC& aFileName );
       
   356         
       
   357         /**
       
   358         * To Know if its a COD DL  
       
   359         */
       
   360         TBool IsCodDownload();
       
   361 
       
   362     protected: // Constructors
       
   363 
       
   364         /**
       
   365         * C++ default constructor.
       
   366         */
       
   367         CUserInteractionsUtils( CDownloadMgrUiBase& aDMgrUiBase, 
       
   368                                 MDownloadMgrUiLibRegModel& aRegistryModel );
       
   369 
       
   370         /**
       
   371         * By default Symbian 2nd phase constructor is private.
       
   372         */
       
   373         void ConstructL();
       
   374 
       
   375     protected: // From MAknServerAppExitObserver
       
   376 
       
   377         void HandleServerAppExit( TInt aReason );
       
   378 
       
   379     private: // file operations
       
   380     
       
   381         /**
       
   382         * Checks for existence of aFileName and modifies it to avoid 
       
   383         * collisions when saving downloaded content to filesystem.
       
   384         * @param aFileName The filename selected by user, including path
       
   385         * @return None
       
   386         */
       
   387         void EnsureUniqueFileNameL( TPtr& aFileName );
       
   388 
       
   389         /**
       
   390         * Modifies aFileName to include suffix similar to "(0x)".
       
   391         * @param aFileName The filename selected by user, including path
       
   392         * @param aCounter number of times filename has been modified
       
   393         * @return TBool was new name genearated successfully
       
   394         */
       
   395         TBool GenerateNewNameL( TPtr& aFileName, TInt& aCounter );
       
   396 
       
   397         /**
       
   398         * Performs a simple check for existence of aFileName.
       
   399         * @param aFileName The filename selected by user, including path
       
   400         * @return TBool indicating if file exists
       
   401         */
       
   402         TBool IsDuplicateL( const TPtrC& aFileName );
       
   403         
       
   404     private: // Data
       
   405 
       
   406         CCoeEnv& iCoeEnv; ///< Reference to CONE environment.
       
   407         CDownloadMgrUiBase& iDMgrUiBase; ///< Reference to UI base functionality.
       
   408         MDownloadMgrUiLibRegModel& iRegistryModel;
       
   409         CDocumentHandler* iDocHandler; ///< Owned.
       
   410         TBool iDocHandlerUsesTheUi; ///< Is the DocH doing something?
       
   411         MDownloadHandlerObserver* iHandlerObserver; ///< Not owned.
       
   412         RHttpDownload* iHandledDownload; ///< Not owned. Passed to iHandlerObserver.
       
   413         CAknMemorySelectionDialog* iMemSelectionDialog; ///< Ownership depends.
       
   414         CAknFileSelectionDialog* iFileSelectionDialog; ///< Ownership depends.
       
   415         CAknInformationNote* iMediaRemovedNote; ///< Ownership depends.
       
   416         CBrowserDialogsProvider* iDialogsProv; ///< Owned.
       
   417         CAknSoftNotifier* iSoftNotifier; ///< Owned.
       
   418         CErrorUI* iErrorUi; ///< Owned.
       
   419         CAknQueryDialog* iDeleteConfirmDlg; ///< Owned.
       
   420         CAknQueryDialog* iCancelConfirmDlg; ///< Owned.
       
   421 
       
   422 		// Filename suffix formatters
       
   423         HBufC* iUnderTenFormatter;  // (Own)
       
   424         HBufC* iOverTenFormatter;   // (Own)
       
   425         TUint iSearchChar;
       
   426         TBool iCodDownload;
       
   427     };
       
   428 
       
   429 #endif /* CUSERINTERACTIONSUTILS_H */