|
1 /* |
|
2 * Copyright (c) 2008-2009 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: MPX Command generating Command Handler |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef __C_GLXMPXCOMMANDCOMMANDHANDLER_H__ |
|
22 #define __C_GLXMPXCOMMANDCOMMANDHANDLER_H__ |
|
23 |
|
24 #include <AknProgressDialog.h> |
|
25 #include <e32base.h> |
|
26 #include <mpxcommand.h> |
|
27 #include <mpxmessage.h> |
|
28 #include "glxmedialistcommandhandler.h" |
|
29 |
|
30 class MGlxMediaList; |
|
31 class MGlxMediaListProvider; |
|
32 class CAknAppUi; |
|
33 class CGlxImageViewerManager; |
|
34 |
|
35 /** |
|
36 * @class CGlxMpxCommandCommandHandler |
|
37 * |
|
38 * Command handler that creates and issues an MPXCommand |
|
39 * |
|
40 * @ingroup glx_group_command_handlers |
|
41 * |
|
42 * @lib glxviewbase.lib |
|
43 */ |
|
44 class CGlxMpxCommandCommandHandler : public CGlxMediaListCommandHandler, |
|
45 public MGlxMediaListObserver, public MProgressDialogCallback |
|
46 { |
|
47 public: |
|
48 /** |
|
49 * Constructor |
|
50 * @param aMediaListProvider The owner of the media list to use |
|
51 */ |
|
52 IMPORT_C CGlxMpxCommandCommandHandler(MGlxMediaListProvider* aMediaListProvider, TBool aHasToolbarItem = EFalse ); |
|
53 |
|
54 /** |
|
55 * Destructor |
|
56 */ |
|
57 IMPORT_C virtual ~CGlxMpxCommandCommandHandler(); |
|
58 |
|
59 protected: // API for deriving classes |
|
60 /** |
|
61 * Attempts to "exit" the command handler |
|
62 * (Exit means closing the progress note and allowing user to do something.) |
|
63 * The command handler will exit if |
|
64 * - progress is complete <b>and</b> deriving class returns ETrue from OkToExit |
|
65 * - aErrorCode is not KErrNone |
|
66 * |
|
67 * Usually deriving classes never need to call this. This is called |
|
68 * automatically after receiving a collection message. Only call if the |
|
69 * completion can happen (= the result of OkToExit() call changes) based |
|
70 * on another event than collection message. |
|
71 * |
|
72 * @param aErrorCode Error code. Shows an error note if other than KErrNone |
|
73 */ |
|
74 IMPORT_C void TryExitL(TInt aErrorCode); |
|
75 |
|
76 /** |
|
77 * See @ref CGlxCommandHandler::DoActivateL |
|
78 * Default implementation does nothing |
|
79 */ |
|
80 IMPORT_C virtual void DoActivateL( TInt aViewId ); |
|
81 |
|
82 /** |
|
83 * Called when the owning view is deactivated |
|
84 */ |
|
85 IMPORT_C virtual void Deactivate(); |
|
86 |
|
87 /** |
|
88 * Handles error |
|
89 * Default implementation shows an error note |
|
90 */ |
|
91 IMPORT_C virtual void HandleErrorL(TInt aErrorCode); |
|
92 |
|
93 /** |
|
94 * Creates a command object, and decides whether to consume the command. |
|
95 * @param aList Media list to which the command will be issued. |
|
96 * @param aConsume Set this to false, if the command |
|
97 * id should not be consumed. Default value is true. |
|
98 * @return command object If NULL returned, no MPX command will be issued, |
|
99 * but the command id may still be consumed, depending |
|
100 * on the value of aDoNotConsume |
|
101 * Caller gets ownership of the command object. |
|
102 */ |
|
103 virtual CMPXCommand* CreateCommandL(TInt aCommandId, MGlxMediaList& aList, |
|
104 TBool& aConsume) const = 0; |
|
105 |
|
106 /** |
|
107 * Handles a message other than progress message. |
|
108 * Deriving classes can override this to receive and handle messages |
|
109 * from media list (i.e., from MPX server) |
|
110 * The default implementation does not do anything. |
|
111 * @return Error code. If other than KErrNone, the command handler |
|
112 * closes the progress note and shows an error note. |
|
113 */ |
|
114 IMPORT_C virtual TInt DoHandleMessageL(const CMPXMessage& aMessage, |
|
115 MGlxMediaList& aList); |
|
116 |
|
117 /** |
|
118 * Called by HandleCommandCompleteL() to allow derived classes |
|
119 * to perform processing specific to individual command handlers. |
|
120 * The defalut implementation does not do anything. |
|
121 * |
|
122 */ |
|
123 IMPORT_C virtual void DoHandleCommandCompleteL(TAny* aSessionId, |
|
124 CMPXCommand* aCommandResult, TInt aError, MGlxMediaList* aList); |
|
125 |
|
126 /** |
|
127 * Called by HandleCommandCompleteL() to allow derived classes |
|
128 * to perform processing specific to individual command handlers. |
|
129 * The defalut implementation does not do anything. |
|
130 * |
|
131 */ |
|
132 IMPORT_C virtual void DoHandleItemAddedL(TInt aStartIndex, TInt aEndIndex, MGlxMediaList* aList); |
|
133 |
|
134 /** |
|
135 * Called to check if the deriving class is ready and progress note |
|
136 * can be closed. The deriving class may be expecting a message (etc) after |
|
137 * the last progress notification is received, and by overriding |
|
138 * this class, they can wait for that info. |
|
139 * Default implementation returns ETrue. |
|
140 * @return ETrue if command handler is ready exit |
|
141 */ |
|
142 IMPORT_C virtual TBool OkToExit() const; |
|
143 |
|
144 /** |
|
145 * Creates and returns confirmation note text |
|
146 * Deriving class can override this to get a confirmation note shown |
|
147 * before execution |
|
148 * @param aCommandId Id of the command that is about to be executed |
|
149 * @param aMultiSelection ETrue when more than one item is selected |
|
150 * @return New descriptor with confirmation note |
|
151 * If single selection, the descriptor must contain %U, which |
|
152 * will be populated with the title of the selected/focused item |
|
153 * If multiselection, the descriptor must contain %N, which |
|
154 * will be populated with the number of selected items |
|
155 * Or return NULL, in which case no note will be shown and the command |
|
156 * is simply executed. |
|
157 * Caller gets ownership of the descriptor. |
|
158 * Default implementation returns NULL. |
|
159 */ |
|
160 IMPORT_C virtual HBufC* ConfirmationTextL(TInt aCommandId, TBool aMultiSelection) const; |
|
161 |
|
162 /** |
|
163 * Creates and returns progress note text |
|
164 * Deriving class can override this to customise the progress note |
|
165 * @return New descriptor with progress text |
|
166 * Or return NULL, in which case default progress text will be |
|
167 * used |
|
168 * Default implementation returns default progress note |
|
169 * Caller gets ownership of the descriptor. |
|
170 */ |
|
171 IMPORT_C virtual HBufC* ProgressTextL(TInt aCommandId) const; |
|
172 |
|
173 /** |
|
174 * Creates and returns completion note text |
|
175 * Deriving class can override this to show a completion note |
|
176 * @return New descriptor with completion text |
|
177 * Or return NULL, in which case the note will not be shown |
|
178 * Default implementation returns NULL |
|
179 * Caller gets ownership of the descriptor. |
|
180 */ |
|
181 IMPORT_C virtual HBufC* CompletionTextL() const; |
|
182 |
|
183 private: |
|
184 /** See @ref CGlxMediaListCommandHandler::DoExecuteL */ |
|
185 IMPORT_C virtual TBool DoExecuteL(TInt aCommandId, MGlxMediaList& aList); |
|
186 |
|
187 /** |
|
188 * Launch a confirmation note (single or multiple depending on media list selection) |
|
189 * Declared as virtual to allow deriving class to show non-media list dependent |
|
190 * confirmation note, etc. |
|
191 * @return ETrue if the user confirms, EFalse if user cancels |
|
192 */ |
|
193 IMPORT_C virtual TBool ConfirmationNoteL(TInt aCommandId, MGlxMediaList& aMediaList) const; |
|
194 |
|
195 /** |
|
196 * Launch a confirmation note (single) |
|
197 * @return ETrue if the user confirms |
|
198 */ |
|
199 TBool ConfirmationNoteSingleL(TInt aCommandId, MGlxMediaList& aMediaList) const; |
|
200 |
|
201 /** |
|
202 * Launch a confirmation note (multiple) |
|
203 * @return ETrue if the user confirms |
|
204 */ |
|
205 TBool ConfirmationNoteMultipleL(TInt aCommandId, MGlxMediaList& aMediaList) const; |
|
206 |
|
207 /** |
|
208 * Launch a progress note |
|
209 */ |
|
210 void ProgressNoteL(TInt aCommandId); |
|
211 |
|
212 /** |
|
213 * Update progress based on message |
|
214 * @param aMessage message with progress info |
|
215 * @param aError extracts an error code from message and returns in this argument |
|
216 * @param ETrue if progress complete. EFalse if note |
|
217 */ |
|
218 TBool UpdateProgressL(const CMPXMessage& aMessage, TInt& aError); |
|
219 |
|
220 /** |
|
221 * Dismiss the active progress note |
|
222 */ |
|
223 void DismissProgressNoteL(); |
|
224 |
|
225 /** |
|
226 * Show a completion note |
|
227 */ |
|
228 void CompletionNoteL() const; |
|
229 |
|
230 /** |
|
231 * Remove medialist observer |
|
232 */ |
|
233 void RemoveMediaListObserver(); |
|
234 |
|
235 /** |
|
236 * Creates the image viewer instance, if not created already. |
|
237 */ |
|
238 void CreateImageViewerInstanceL(); |
|
239 |
|
240 /** |
|
241 * Deletes the image viewer instance, if created already. |
|
242 */ |
|
243 void DeleteImageViewerInstance(); |
|
244 |
|
245 protected: // From MGlxMediaListObserver |
|
246 /// See @ref MGlxMediaListObserver::HandleItemAddedL |
|
247 IMPORT_C void HandleItemAddedL(TInt aStartIndex, TInt aEndIndex, MGlxMediaList* aList); |
|
248 |
|
249 /// See @ref MGlxMediaListObserver::HandleMediaL |
|
250 IMPORT_C void HandleMediaL(TInt aListIndex, MGlxMediaList* aList); |
|
251 |
|
252 /// See @ref MGlxMediaListObserver::HandleItemRemovedL |
|
253 IMPORT_C void HandleItemRemovedL(TInt aStartIndex, TInt aEndIndex, MGlxMediaList* aList); |
|
254 |
|
255 /// See @ref MGlxMediaListObserver::HandleItemModifiedL |
|
256 IMPORT_C void HandleItemModifiedL(const RArray<TInt>& aItemIndexes, MGlxMediaList* aList); |
|
257 |
|
258 /// See @ref MGlxMediaListObserver::HandleAttributesAvailableL |
|
259 IMPORT_C void HandleAttributesAvailableL(TInt aItemIndex, |
|
260 const RArray<TMPXAttribute>& aAttributes, MGlxMediaList* aList); |
|
261 |
|
262 /// See @ref MGlxMediaListObserver::HandleFocusChangedL |
|
263 IMPORT_C void HandleFocusChangedL(NGlxListDefs::TFocusChangeType aType, TInt aNewIndex, TInt aOldIndex, MGlxMediaList* aList); |
|
264 |
|
265 /// See @ref MGlxMediaListObserver::HandleItemSelectedL |
|
266 IMPORT_C void HandleItemSelectedL(TInt aIndex, TBool aSelected, MGlxMediaList* aList); |
|
267 |
|
268 /// See @ref MGlxMediaListObserver::HandleMessageL |
|
269 IMPORT_C void HandleMessageL(const CMPXMessage& aMessage, MGlxMediaList* aList); |
|
270 |
|
271 /// See @ref MGlxMediaListObserver::HandleCommandCompleteL |
|
272 IMPORT_C void HandleCommandCompleteL(TAny* aSessionId, CMPXCommand* aCommandResult, TInt aError, MGlxMediaList* aList); |
|
273 |
|
274 public: // from MProgressDialogCallback |
|
275 IMPORT_C void DialogDismissedL(TInt aButtonId); |
|
276 |
|
277 private: |
|
278 /// Progress dialog |
|
279 CAknProgressDialog* iProgressDialog; |
|
280 |
|
281 // Progress info for the progress dialog |
|
282 CEikProgressInfo* iProgressInfo; |
|
283 |
|
284 // CEikProgressInfo does not store whether progress is complete, so store here |
|
285 TBool iProgressComplete; |
|
286 |
|
287 // Resource offset |
|
288 mutable TInt iResourceOffset; |
|
289 |
|
290 /// Whether the GIF animation is currently halted |
|
291 TBool iAnimationStopped; |
|
292 |
|
293 /// The AppUI. Not owned |
|
294 CAknAppUi* iAppUi; |
|
295 |
|
296 // For image viewer, not own |
|
297 CGlxImageViewerManager* iImageViewerInstance; |
|
298 }; |
|
299 |
|
300 #endif // __C_GLXMPXCOMMANDCOMMANDHANDLER_H__ |