2 * Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Supports user interaction dialogs for downloads
20 #ifndef CDOWNLOADMGRUIUSERINTERACTIONS_H
21 #define CDOWNLOADMGRUIUSERINTERACTIONS_H
24 #include <cdownloadmgruibase.h>
25 #include <downloadmgrclient.h>
29 _LIT8( KDrmInnerContentTypesToLaunch, "application/java-archive application/x-java-archive x-epoc/x-sisx-app application/x-pip" );
30 _LIT8( KSisxApplication, "x-epoc/x-sisx-app application/vnd.symbian.install x-epoc/x-app268436505" );
31 _LIT8( KPipApplication, "application/x-pip" );
32 _LIT8( KWidgetMimeType, "application/x-nokia-widget" );
33 _LIT8( KSharingConfig, "application/isf.sharing.config" );
36 enum TClientAppExitType
42 // FORWARD DECLARATIONS
43 class CUserInteractionsUtils;
44 class CDownloadMgrUiLibRegistry;
45 class CAsyncEventHandlerArray;
47 class CUserInteractionsExtension;
52 * The User Interactions supports the followings:
53 * - User confirmation when content-type header arrives
54 * - Handling completed downloads
55 * - Querying HTTP authentication credentials
56 * - Querying proxy authentication credentials
57 * - Error notification
58 * - Client App termination by the User
60 * @lib Download Manager UI Lib
61 * @since Series 60 2.8
63 NONSHARABLE_CLASS( CDownloadMgrUiUserInteractions ) :
64 public CDownloadMgrUiBase,
65 public MHttpDownloadMgrObserver
67 public: // Constructors and destructor
70 * Two-phased constructor.
72 static CDownloadMgrUiUserInteractions* NewL
73 ( CDownloadMgrUiLibRegistry& aRegistryModel );
78 virtual ~CDownloadMgrUiUserInteractions();
80 public: // New functions
83 * Client Apps can call this function before exiting the application.
84 * It should be called when the user terminates the application.
85 * It opens a confirmation query.
86 * @return OK to exit? True/False. It is only a suggested value!
88 IMPORT_C TBool OkToExitL();
91 * Client Apps can call this function in the App UI's destructor.
92 * It has been made non-leavable, so it can be called without TRAP.
93 * It initializes Grouped Soft Notifications, if necessary.
94 * @param aAppUi Reference to the actual App UI.
95 * @param aExitType Exit type when this function is called.
96 * Only ETerminatedBySystem is supported.
97 * @param aViewId View ID of the view where to switch in case user chooses
98 * accept softkey in the soft notification.
99 * @param aCustomMessageId Custom message ID.
100 * @param aViewActivationMsg Custom message sent to the view in
101 * the view activation process.
102 * @return Error code or KErrNone.
104 IMPORT_C TInt PrepareToExit( CEikAppUi& aAppUi,
105 TClientAppExitType aExitType,
107 TUid aCustomMessageId,
108 const TDesC8& aViewActivationMsg );
111 * Client Apps can call this function in the App UI's destructor.
112 * It has been made non-leavable, so it can be called without TRAP.
113 * It initializes Grouped Soft Notifications, if necessary.
114 * @param aAppUid 3rd UID of the application.
115 * @param aViewId View ID that needs to be activated.
116 * @param aCustomMessageId Custom message ID.
117 * @return Error code or KErrNone.
119 IMPORT_C TInt PrepareToExit( TUint32 aAppUid,
121 TUint32 aCustomMessageId );
124 * Currently it supports handling completed download.
125 * COD download is deleted, otherwise normal behaviour, that
126 * depends on EDlAttrAction (EDoNothing/EMove/ELaunch).
127 * @param aDownload The actual download
130 IMPORT_C void HandleDownloadL( RHttpDownload& aDownload );
133 * The number of download confirmations being shown.
134 * @return Non-negative integer value.
136 TInt DownloadConfirmationsShown() const;
139 * Ask if a handler or something uses the UI, so
140 * others should postpone their tasks that require UI.
143 TBool IsUiBusy() const;
146 * Is a Cod ServiceFlow running?
149 TBool IsCodServiceFlowRunning() const;
152 * Is Cod ServiceFlow running of the given download?
153 * @param aDownload The download in question.
156 TBool IsCodServiceFlowRunning( RHttpDownload& aDownload ) const;
159 * Is a Cod ServiceFlow running?
163 TBool IsCodServiceFlowRunningL() const;
166 * Is Cod ServiceFlow running of the given download?
168 * @param aDownload The download in question.
171 TBool IsCodServiceFlowRunningL( RHttpDownload& aDownload ) const;
174 * Postpone handling the given COD download. The download is placed to a
175 * LIFO queue, and SetHandlerRunning( EFalse ) handles (restarts) the first
177 * @param aDownload The download to be postponed.
179 void PostponeCodHandlingL( RHttpDownload& aDownload );
182 * Check if the given download is postponed.
183 * @param aDownload The download in question.
184 * @return true/false.
186 TBool IsPostponed( RHttpDownload& aDownload ) const;
189 * Schedule a postponed download for running.
191 void SchedulePostponedDownloadL();
194 * To Set the flag when progressive play is Launched
196 inline void SetProgressiveDownloadLaunched( TBool aProgressiveDownloadLaunched ) {iProgressiveDownloadLaunched = aProgressiveDownloadLaunched; }
198 public: // Functions from CDownloadMgrUiBase
200 /// Attribute enumerations.
201 enum TDownloadMgrUiUserInteractionsAttr
203 EAttrSuppressDownloadConfirmation ///< TBool, default: EFalse
206 IMPORT_C virtual void GetIntAttributeL( const TUint aAttribute, TInt32& aValue );
207 IMPORT_C virtual void GetBoolAttributeL( const TUint aAttribute, TBool& aValue );
208 IMPORT_C virtual void GetStringAttributeL( const TUint aAttribute, TDes16& aValue );
209 IMPORT_C virtual void GetStringAttributeL( const TUint aAttribute, TDes8& aValue );
210 IMPORT_C virtual void SetIntAttributeL( const TUint aAttribute, TInt32 aValue );
211 IMPORT_C virtual void SetBoolAttributeL( const TUint aAttribute, TBool aValue );
212 IMPORT_C virtual void SetStringAttributeL( const TUint aAttribute, const TDesC16& aValue );
213 IMPORT_C virtual void SetStringAttributeL( const TUint aAttribute, const TDesC8& aValue );
215 protected: // Constructors
218 * C++ default constructor.
220 CDownloadMgrUiUserInteractions( CDownloadMgrUiLibRegistry& aRegistryModel );
223 * By default Symbian 2nd phase constructor is private.
227 protected: // New functions
229 // Event handler functions
232 * Wraps DoHandleCompletionWithQueryL() to ensure that only one instance
233 * of the dialog is displayed at any point in time.
234 * @param aDownload The actual download
237 void HandleCompletionWithQueryL( RHttpDownload& aDownload,
241 TBool aDrmRightsOnPhone );
243 * Handle download completion with query (wait) dialog.
244 * @param aDownload The actual download
247 void DoHandleCompletionWithQueryL( RHttpDownload& aDownload,
251 TBool aDrmRightsOnPhone );
254 * Leaving version of PrepareToExit().
257 void PrepareToExitL( CEikAppUi* aAppUi,
258 TClientAppExitType aExitType,
260 TUid aCustomMessageId,
261 const TDesC8& aViewActivationMsg );
264 * Is a stand-alone instance running from the very same application?
265 * @return True/False.
267 TBool IsStandAloneAppRunning();
270 * Delete Event Handler(s) showing download confirmation query.
271 * @param aDownload The actual download.
273 void DeleteEventHandlerShowingDlConfirmation( RHttpDownload& aDownload );
276 * Delete Event Handler(s) belonging to the given download.
277 * @param aDownload The actual download.
279 void DeleteEventHandlers( RHttpDownload& aDownload );
282 * Handle completed normal download (not COD or OMA, not DRM).
283 * @param aDownload The actual download
286 void HandleNormalDownloadL( RHttpDownload& aDownload );
289 * Check if the download is COD.
290 * @param aDownload The actual download
291 * @return ETrue/EFalse
293 TBool CodDownloadL( RHttpDownload& aDownload ) const;
295 protected: // Functions from MHttpDownloadMgrObserver
297 virtual void HandleDMgrEventL( RHttpDownload& aDownload,
298 THttpDownloadEvent aEvent );
302 CUserInteractionsExtension* iExtension; ///< Extension class, Owned.
304 CUserInteractionsUtils* iUiUtils; /**< Owned. Should be only one
305 instance in the UILib! */
306 CAsyncEventHandlerArray* iEventHandlerArray; ///< Owned.
310 TBool iProgressiveDownloadLaunched;
312 private: // Friend classes
314 friend class CUserInteractionsExtension;
317 #endif /* CDOWNLOADMGRUIUSERINTERACTIONS_H */