|
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: Media List Command Handler |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include <e32base.h> |
|
22 |
|
23 #include "glxmpxcommandcommandhandler.h" |
|
24 |
|
25 #include <AknProgressDialog.h> |
|
26 #include <bautils.h> |
|
27 #include <data_caging_path_literals.hrh> |
|
28 #include <eikprogi.h> |
|
29 #include <mpxmediageneraldefs.h> |
|
30 #include <mpxmessagegeneraldefs.h> |
|
31 #include <mpxmessageprogressdefs.h> |
|
32 #include <mpxcommandgeneraldefs.h> |
|
33 #include <StringLoader.h> |
|
34 |
|
35 #include <glxgeneraluiutilities.h> |
|
36 #include <mglxmedialist.h> |
|
37 #include <glxfetchcontextremover.h> |
|
38 #include <glxmedialistiterator.h> |
|
39 #include <glxattributecontext.h> |
|
40 #include <glxattributeretriever.h> |
|
41 #include <glxuistd.h> |
|
42 #include <glxuiutilities.rsg> |
|
43 #include <glxcommandhandlers.hrh> |
|
44 #include <glxresourceutilities.h> // for CGlxResourceUtilities |
|
45 |
|
46 /// @todo Move elsewhere |
|
47 const TInt KGlxMaxNoteLength = 256; |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // ConstructL |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 EXPORT_C CGlxMpxCommandCommandHandler:: |
|
54 CGlxMpxCommandCommandHandler(MGlxMediaListProvider* aMediaListProvider, TBool aHasToolbarItem) |
|
55 : CGlxMediaListCommandHandler(aMediaListProvider, aHasToolbarItem) |
|
56 { |
|
57 iAppUi = static_cast< CAknAppUi* >( CCoeEnv::Static()->AppUi() ); |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // Destructor |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 EXPORT_C CGlxMpxCommandCommandHandler::~CGlxMpxCommandCommandHandler() |
|
65 { |
|
66 // cancel command if running |
|
67 if (iProgressComplete) |
|
68 { |
|
69 // MediaList().Cancel(); |
|
70 } |
|
71 |
|
72 delete iProgressDialog; |
|
73 |
|
74 if ( iResourceOffset ) |
|
75 { |
|
76 CCoeEnv::Static()->DeleteResourceFile(iResourceOffset); |
|
77 } |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // DoExecuteL |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 EXPORT_C TBool CGlxMpxCommandCommandHandler::DoExecuteL(TInt aCommandId, |
|
85 MGlxMediaList& aList) |
|
86 { |
|
87 // reset progress complete flag |
|
88 iProgressComplete = EFalse; |
|
89 |
|
90 // deriving class consumes command by default |
|
91 TBool consume = ETrue; |
|
92 TInt selectionCount = aList.SelectionCount(); |
|
93 const TGlxMedia& focusedMedia = aList.Item(aList.FocusIndex()); |
|
94 // show confirmation note |
|
95 consume = ConfirmationNoteL(aCommandId, aList); |
|
96 |
|
97 // Check if the selected / focused file(s)s have been deleted from |
|
98 // another application while the confirmation note is displayed |
|
99 if (((selectionCount > 0) && (aList.SelectionCount() == 0)) || |
|
100 ((selectionCount == 0) && |
|
101 (focusedMedia.Id() != aList.Item(aList.FocusIndex()).Id()))) |
|
102 { |
|
103 // All the selected / focused item(s) have been deleted, |
|
104 // do not allow the command to execute. |
|
105 consume = EFalse; |
|
106 } |
|
107 |
|
108 if ( consume ) |
|
109 { |
|
110 // get a command object from the deriving class. |
|
111 // Allow deriving class modify the consume value, even without |
|
112 // creating a commmand (in case it wants to filter out a command) |
|
113 CMPXCommand* command = CreateCommandL(aCommandId, aList, consume); |
|
114 |
|
115 if (command) |
|
116 { |
|
117 CleanupStack::PushL(command); |
|
118 |
|
119 if ( CommandInfo(aCommandId).iStopAnimationForExecution ) |
|
120 { |
|
121 // Stop GIF animation |
|
122 iAppUi->ProcessCommandL(EGlxCmdDisableAnimations); |
|
123 iAnimationStopped = ETrue; |
|
124 } |
|
125 |
|
126 // Add the pointer of this command handler as session id into the message |
|
127 // This can be used to ensure that this object is the intended recipient |
|
128 // of a message |
|
129 command->SetTObjectValueL<TAny*>(KMPXCommandGeneralSessionId, |
|
130 static_cast<TAny*>(this)); |
|
131 |
|
132 aList.AddMediaListObserverL(this); |
|
133 |
|
134 // @todo TRAP this? |
|
135 aList.CommandL(*command); |
|
136 |
|
137 // raise progress note. Note will be closed when complete message received |
|
138 ProgressNoteL(aCommandId); |
|
139 |
|
140 CleanupStack::PopAndDestroy(command); |
|
141 } |
|
142 } |
|
143 |
|
144 return consume; |
|
145 } |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // TryExitL |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 EXPORT_C void CGlxMpxCommandCommandHandler::TryExitL(TInt aErrorCode) |
|
152 { |
|
153 // any error will abort the command execution |
|
154 if ( KErrNone != aErrorCode ) |
|
155 { |
|
156 // error received. Close progress note |
|
157 DismissProgressNoteL(); |
|
158 |
|
159 // Remove medialist observer |
|
160 RemoveMediaListObserver(); |
|
161 |
|
162 // handle error |
|
163 HandleErrorL(aErrorCode); |
|
164 } |
|
165 else if (iProgressComplete) |
|
166 { |
|
167 // ask deriving class if it is ready to exit (i.e., to close progress note). |
|
168 // (It may be waiting for another message, etc.) |
|
169 if (OkToExit()) |
|
170 { |
|
171 // close progress note |
|
172 DismissProgressNoteL(); |
|
173 |
|
174 // Remove medialist observer |
|
175 RemoveMediaListObserver(); |
|
176 |
|
177 // show completion note |
|
178 CompletionNoteL(); |
|
179 } |
|
180 } |
|
181 } |
|
182 |
|
183 |
|
184 // ----------------------------------------------------------------------------- |
|
185 // Default implementation shows an error note |
|
186 // ----------------------------------------------------------------------------- |
|
187 // |
|
188 EXPORT_C void CGlxMpxCommandCommandHandler::HandleErrorL(TInt aErrorCode) |
|
189 { |
|
190 // show error note |
|
191 GlxGeneralUiUtilities::ShowErrorNoteL(aErrorCode); |
|
192 } |
|
193 |
|
194 // ----------------------------------------------------------------------------- |
|
195 // Update progress |
|
196 // ----------------------------------------------------------------------------- |
|
197 // |
|
198 TBool CGlxMpxCommandCommandHandler::UpdateProgressL(const CMPXMessage& aMessage, |
|
199 TInt& aError) |
|
200 { |
|
201 TBool isComplete = EFalse; |
|
202 |
|
203 // should not receive any progress messages after progress is completed |
|
204 __ASSERT_DEBUG(!iProgressComplete, Panic(EGlxPanicIllegalState)); |
|
205 |
|
206 /// @todo remove progress update error handling |
|
207 TMPXAttribute currentCountAttr(KMPXMessageContentIdProgress, EMPXMessageProgressCurrentCount); |
|
208 TMPXAttribute totalCountAttr(KMPXMessageContentIdProgress, EMPXMessageProgressTotalCount); |
|
209 if ( ( KErrNone == aError ) && (aMessage.IsSupported(currentCountAttr)) |
|
210 && (aMessage.IsSupported(totalCountAttr) ) ) |
|
211 { |
|
212 // get current and total count from the message |
|
213 TInt currentValue = aMessage.ValueTObjectL<TInt>(currentCountAttr); |
|
214 TInt total= aMessage.ValueTObjectL<TInt>(totalCountAttr); |
|
215 |
|
216 // update progress bar if not complete yet, otherwise remember completion |
|
217 if ( currentValue < total ) |
|
218 { |
|
219 // Progress info construction may have failed, but command was issued before |
|
220 if (iProgressInfo) |
|
221 { |
|
222 iProgressInfo->SetFinalValue(total); |
|
223 iProgressInfo->SetAndDraw(currentValue); |
|
224 } |
|
225 } |
|
226 else |
|
227 { |
|
228 isComplete = ETrue; |
|
229 |
|
230 if ( iAnimationStopped ) |
|
231 { |
|
232 // Restart animation |
|
233 iAppUi->ProcessCommandL(EGlxCmdEnableAnimations); |
|
234 iAnimationStopped = EFalse; |
|
235 } |
|
236 } |
|
237 } |
|
238 |
|
239 return isComplete; |
|
240 } |
|
241 |
|
242 // ----------------------------------------------------------------------------- |
|
243 // Default implementation of advanced command handling does nothing |
|
244 // ----------------------------------------------------------------------------- |
|
245 // |
|
246 EXPORT_C void CGlxMpxCommandCommandHandler::DoHandleCommandCompleteL(TAny* /*aSessionId*/, |
|
247 CMPXCommand* /*aCommandResult*/, TInt /*aError*/, MGlxMediaList* /*aList*/) |
|
248 { |
|
249 } |
|
250 |
|
251 |
|
252 // ----------------------------------------------------------------------------- |
|
253 // Default implementation of advanced message handling does nothing |
|
254 // ----------------------------------------------------------------------------- |
|
255 // |
|
256 EXPORT_C TInt CGlxMpxCommandCommandHandler::DoHandleMessageL(const CMPXMessage& /*aMessage*/, |
|
257 MGlxMediaList& /*aList*/) |
|
258 { |
|
259 return KErrNone; |
|
260 } |
|
261 |
|
262 // ----------------------------------------------------------------------------- |
|
263 // Default implementation DoHandleItemAddedL does not do anything |
|
264 // ----------------------------------------------------------------------------- |
|
265 // |
|
266 EXPORT_C void CGlxMpxCommandCommandHandler::DoHandleItemAddedL(TInt /*aStartIndex*/, |
|
267 TInt /*aEndIndex*/, MGlxMediaList* /*aList*/) |
|
268 { |
|
269 } |
|
270 |
|
271 // ----------------------------------------------------------------------------- |
|
272 // Default implementation is always ready to exit |
|
273 // ----------------------------------------------------------------------------- |
|
274 // |
|
275 EXPORT_C TBool CGlxMpxCommandCommandHandler::OkToExit() const |
|
276 { |
|
277 return ETrue; |
|
278 } |
|
279 |
|
280 // ----------------------------------------------------------------------------- |
|
281 // Show confirmation note |
|
282 // ----------------------------------------------------------------------------- |
|
283 // |
|
284 EXPORT_C TBool CGlxMpxCommandCommandHandler::ConfirmationNoteL(TInt aCommandId, |
|
285 MGlxMediaList& aMediaList) const |
|
286 { |
|
287 TInt selectionCount = aMediaList.SelectionCount(); |
|
288 |
|
289 // If media list is not empty, treat focused item as selected |
|
290 // At this point can assume that the command was disabled |
|
291 // if static items were not supported |
|
292 if ( selectionCount == 0 && aMediaList.Count() > 0 ) |
|
293 { |
|
294 selectionCount = 1; |
|
295 } |
|
296 |
|
297 // Show confirmation note |
|
298 TBool confirmed = EFalse; |
|
299 if ( selectionCount == 1 ) |
|
300 { |
|
301 confirmed = ConfirmationNoteSingleL(aCommandId, aMediaList); |
|
302 } |
|
303 else |
|
304 { |
|
305 confirmed = ConfirmationNoteMultipleL(aCommandId, aMediaList); |
|
306 } |
|
307 |
|
308 return confirmed; |
|
309 } |
|
310 |
|
311 // ----------------------------------------------------------------------------- |
|
312 // So confirmation note if a single item is selected |
|
313 // ----------------------------------------------------------------------------- |
|
314 // |
|
315 EXPORT_C TBool CGlxMpxCommandCommandHandler::ConfirmationNoteSingleL(TInt aCommandId, |
|
316 MGlxMediaList& aMediaList) const |
|
317 { |
|
318 // if no confirmation note shown, assume command is confirmed |
|
319 TBool confirmed = ETrue; |
|
320 |
|
321 // get confirmation note text for single selection |
|
322 HBufC* noteText = ConfirmationTextL(aCommandId, EFalse); // EFalse for single selection |
|
323 if ( noteText ) |
|
324 { |
|
325 CleanupStack::PushL(noteText); |
|
326 |
|
327 // Retrieve title string for selected item from the collection plugin |
|
328 |
|
329 // create fetch context |
|
330 TGlxSelectionIterator iterator; |
|
331 iterator.SetRange(1); |
|
332 CGlxAttributeContext* attributeContext = new(ELeave) CGlxAttributeContext(&iterator); |
|
333 CleanupStack::PushL(attributeContext); |
|
334 attributeContext->AddAttributeL(KMPXMediaGeneralTitle); |
|
335 |
|
336 // add context to media list |
|
337 aMediaList.AddContextL(attributeContext, KGlxFetchContextPriorityLow); |
|
338 |
|
339 // TGlxContextRemover will remove the context when it goes out of scope |
|
340 // Used here to avoid a trap and still have safe cleanup |
|
341 TGlxFetchContextRemover contextRemover(attributeContext, aMediaList); |
|
342 // put to cleanupstack as cleanupstack is emptied before stack objects |
|
343 // are deleted |
|
344 CleanupClosePushL( contextRemover); |
|
345 // retrieve title attribute |
|
346 TInt err = GlxAttributeRetriever::RetrieveL(*attributeContext, aMediaList, EFalse); |
|
347 // context off the list |
|
348 CleanupStack::PopAndDestroy( &contextRemover ); |
|
349 |
|
350 if ( err == KErrNone ) |
|
351 { |
|
352 // use iterator to get the index of the right item |
|
353 iterator.SetToFirst(&aMediaList); |
|
354 const CGlxMedia* media = aMediaList.Item(iterator++).Properties(); |
|
355 |
|
356 // noteText has a place for a title string in it |
|
357 const TDesC& itemName = media->ValueText(KMPXMediaGeneralTitle); |
|
358 |
|
359 TBuf<KGlxMaxNoteLength> text; |
|
360 StringLoader::Format(text, *noteText, -1, itemName); |
|
361 |
|
362 // show popup |
|
363 confirmed = GlxGeneralUiUtilities::ConfirmQueryL(R_GLX_QUERY_YES_NO, text); |
|
364 } |
|
365 // (else) If error, assume confirmed anyway |
|
366 |
|
367 CleanupStack::PopAndDestroy(attributeContext); |
|
368 CleanupStack::PopAndDestroy(noteText); |
|
369 } |
|
370 return confirmed; |
|
371 } |
|
372 |
|
373 // ----------------------------------------------------------------------------- |
|
374 // Confirmation note if multiple items are selected |
|
375 // ----------------------------------------------------------------------------- |
|
376 // |
|
377 EXPORT_C TBool CGlxMpxCommandCommandHandler::ConfirmationNoteMultipleL(TInt aCommandId, |
|
378 MGlxMediaList& aMediaList) const |
|
379 { |
|
380 // if no confirmation note shown, assume command is confirmed |
|
381 TBool confirmed = ETrue; |
|
382 |
|
383 // get confirmation note text for multiselection |
|
384 HBufC* noteText = ConfirmationTextL(aCommandId, ETrue); // ETrue for Multiselection |
|
385 if ( noteText ) |
|
386 { |
|
387 CleanupStack::PushL(noteText); |
|
388 |
|
389 // string has a place for number in it, and that number should be populated with selected |
|
390 // item count |
|
391 TInt count = aMediaList.SelectionCount(); |
|
392 |
|
393 TBuf<KGlxMaxNoteLength> text; |
|
394 GlxGeneralUiUtilities::FormatString(text, *noteText, -1, count, ETrue); |
|
395 |
|
396 // show popup |
|
397 confirmed = GlxGeneralUiUtilities::ConfirmQueryL(R_GLX_QUERY_YES_NO, text); |
|
398 |
|
399 CleanupStack::PopAndDestroy(noteText); |
|
400 } |
|
401 return confirmed; |
|
402 } |
|
403 |
|
404 // ----------------------------------------------------------------------------- |
|
405 // Default implementation returns null, and no confirmation note will be shown |
|
406 // ----------------------------------------------------------------------------- |
|
407 // |
|
408 EXPORT_C HBufC* CGlxMpxCommandCommandHandler::ConfirmationTextL(TInt /*aCommandId*/, |
|
409 TBool /*aMultiSelection*/) const |
|
410 { |
|
411 return NULL; |
|
412 } |
|
413 |
|
414 // ----------------------------------------------------------------------------- |
|
415 // Return default progress string |
|
416 // ----------------------------------------------------------------------------- |
|
417 // |
|
418 EXPORT_C HBufC* CGlxMpxCommandCommandHandler::ProgressTextL(TInt /*aCommandId*/) const |
|
419 { |
|
420 // Lazy construction for resource file |
|
421 if (iResourceOffset == 0) |
|
422 { |
|
423 // Load resource file |
|
424 TParse parse; |
|
425 parse.Set(KGlxUiUtilitiesResource, &KDC_APP_RESOURCE_DIR, NULL); |
|
426 TFileName resourceFile; |
|
427 resourceFile.Append(parse.FullName()); |
|
428 CGlxResourceUtilities::GetResourceFilenameL(resourceFile); |
|
429 |
|
430 // Store resource offset as member variable, so don't have to trap the |
|
431 // leaving calls here |
|
432 iResourceOffset = CCoeEnv::Static()->AddResourceFileL(resourceFile); |
|
433 } |
|
434 |
|
435 // get progress note string |
|
436 return StringLoader::LoadL( R_GLX_PROGRESS_GENERAL ); |
|
437 } |
|
438 |
|
439 // ----------------------------------------------------------------------------- |
|
440 // Default implementation returns null, and no completion note will be shown |
|
441 // ----------------------------------------------------------------------------- |
|
442 // |
|
443 EXPORT_C HBufC* CGlxMpxCommandCommandHandler::CompletionTextL() const |
|
444 { |
|
445 return NULL; |
|
446 } |
|
447 |
|
448 // ----------------------------------------------------------------------------- |
|
449 // ProgressNoteL |
|
450 // ----------------------------------------------------------------------------- |
|
451 // |
|
452 void CGlxMpxCommandCommandHandler::ProgressNoteL(TInt aCommandId) |
|
453 { |
|
454 //MGlxMediaList& mediaList = MediaList(); |
|
455 |
|
456 // get progress note |
|
457 HBufC* progressText = ProgressTextL(aCommandId); |
|
458 __ASSERT_DEBUG(progressText, Panic(EGlxPanicNullDescriptor)); |
|
459 CleanupStack::PushL(progressText); |
|
460 // construct progress dialog |
|
461 iProgressDialog = new(ELeave)CAknProgressDialog( |
|
462 (REINTERPRET_CAST(CEikDialog**,&iProgressDialog))); |
|
463 iProgressDialog->PrepareLC(R_GLX_PROGRESS_NOTE); |
|
464 iProgressDialog->SetTextL(*progressText); |
|
465 iProgressDialog->SetCallback(this); |
|
466 |
|
467 // pick up progress info so that progress notification can be later updated |
|
468 iProgressInfo = iProgressDialog->GetProgressInfoL(); |
|
469 |
|
470 // launch the note |
|
471 iProgressDialog->RunLD(); |
|
472 CleanupStack::PopAndDestroy(progressText); |
|
473 } |
|
474 |
|
475 // ----------------------------------------------------------------------------- |
|
476 // DismissProgressNoteL |
|
477 // ----------------------------------------------------------------------------- |
|
478 // |
|
479 void CGlxMpxCommandCommandHandler::DismissProgressNoteL() |
|
480 { |
|
481 // Close the progress note, if displayed |
|
482 if (iProgressDialog) |
|
483 { |
|
484 iProgressDialog->ProcessFinishedL(); |
|
485 iProgressDialog = NULL; |
|
486 iProgressInfo = NULL; |
|
487 } |
|
488 } |
|
489 |
|
490 // ----------------------------------------------------------------------------- |
|
491 // Remove MediaList Observer |
|
492 // ----------------------------------------------------------------------------- |
|
493 // |
|
494 void CGlxMpxCommandCommandHandler::RemoveMediaListObserver() |
|
495 { |
|
496 MGlxMediaList& mediaList = MediaList(); |
|
497 mediaList.RemoveMediaListObserver(this); |
|
498 } |
|
499 |
|
500 // ----------------------------------------------------------------------------- |
|
501 // Show a completion note |
|
502 // ----------------------------------------------------------------------------- |
|
503 // |
|
504 void CGlxMpxCommandCommandHandler::CompletionNoteL() const |
|
505 { |
|
506 // Get completion note text |
|
507 HBufC* noteText = CompletionTextL(); |
|
508 if ( noteText ) |
|
509 { |
|
510 CleanupStack::PushL(noteText); |
|
511 GlxGeneralUiUtilities::ShowConfirmationNoteL(*noteText, ETrue); |
|
512 CleanupStack::PopAndDestroy(noteText); |
|
513 } |
|
514 } |
|
515 |
|
516 // ----------------------------------------------------------------------------- |
|
517 // HandleItemAddedL |
|
518 // ----------------------------------------------------------------------------- |
|
519 // |
|
520 EXPORT_C void CGlxMpxCommandCommandHandler::HandleItemAddedL(TInt /*aStartIndex*/, TInt /*aEndIndex*/, MGlxMediaList* /*aList*/) |
|
521 { |
|
522 // Do nothing |
|
523 } |
|
524 |
|
525 // ----------------------------------------------------------------------------- |
|
526 // HandleMediaL |
|
527 // ----------------------------------------------------------------------------- |
|
528 // |
|
529 EXPORT_C void CGlxMpxCommandCommandHandler::HandleMediaL(TInt /*aListIndex*/, MGlxMediaList* /*aList*/) |
|
530 { |
|
531 // Do nothing |
|
532 } |
|
533 |
|
534 // ----------------------------------------------------------------------------- |
|
535 // HandleItemRemovedL |
|
536 // ----------------------------------------------------------------------------- |
|
537 // |
|
538 EXPORT_C void CGlxMpxCommandCommandHandler::HandleItemRemovedL(TInt /*aStartIndex*/, TInt /*aEndIndex*/, MGlxMediaList* /*aList*/) |
|
539 { |
|
540 // Do nothing |
|
541 } |
|
542 |
|
543 // ----------------------------------------------------------------------------- |
|
544 // HandleItemModifiedL |
|
545 // ----------------------------------------------------------------------------- |
|
546 // |
|
547 EXPORT_C void CGlxMpxCommandCommandHandler::HandleItemModifiedL(const RArray<TInt>& /*aItemIndexes*/, |
|
548 MGlxMediaList* /*aList*/) |
|
549 { |
|
550 // Do nothing |
|
551 } |
|
552 |
|
553 // ----------------------------------------------------------------------------- |
|
554 // HandleAttributesAvailableL |
|
555 // ----------------------------------------------------------------------------- |
|
556 // |
|
557 EXPORT_C void CGlxMpxCommandCommandHandler::HandleAttributesAvailableL(TInt /*aItemIndex*/, |
|
558 const RArray<TMPXAttribute>& /*aAttributes*/, MGlxMediaList* /*aList*/) |
|
559 { |
|
560 // Do nothing |
|
561 } |
|
562 |
|
563 // ----------------------------------------------------------------------------- |
|
564 // HandleFocusChangedL |
|
565 // ----------------------------------------------------------------------------- |
|
566 // |
|
567 EXPORT_C void CGlxMpxCommandCommandHandler::HandleFocusChangedL(NGlxListDefs::TFocusChangeType /*aType*/, |
|
568 TInt /*aNewIndex*/, TInt /*aOldIndex*/, MGlxMediaList* /*aList*/) |
|
569 { |
|
570 // Do nothing |
|
571 } |
|
572 |
|
573 // ----------------------------------------------------------------------------- |
|
574 // HandleItemSelectedL |
|
575 // ----------------------------------------------------------------------------- |
|
576 // |
|
577 EXPORT_C void CGlxMpxCommandCommandHandler::HandleItemSelectedL(TInt /*aIndex*/, |
|
578 TBool /*aSelected*/, MGlxMediaList* /*aList*/) |
|
579 { |
|
580 // Do nothing |
|
581 } |
|
582 |
|
583 // ----------------------------------------------------------------------------- |
|
584 // HandleMessageL |
|
585 // ----------------------------------------------------------------------------- |
|
586 // |
|
587 EXPORT_C void CGlxMpxCommandCommandHandler::HandleMessageL(const CMPXMessage& aMessage, |
|
588 MGlxMediaList* aList) |
|
589 { |
|
590 if ((aMessage.IsSupported(KMPXMessageGeneralId) && |
|
591 (aMessage.IsSupported(KMPXCommandGeneralSessionId)))) |
|
592 { |
|
593 TInt msgId = aMessage.ValueTObjectL<TInt>(KMPXMessageGeneralId); |
|
594 TAny* sessionId = aMessage.ValueTObjectL<TAny*>(KMPXCommandGeneralSessionId); |
|
595 |
|
596 TInt error = KErrNone; |
|
597 // Check if this is a progress message and intended for this object |
|
598 if ( KMPXMessageContentIdProgress == msgId && static_cast<TAny*>(this) == sessionId ) |
|
599 { |
|
600 // Update progress note |
|
601 iProgressComplete = UpdateProgressL(aMessage, error); |
|
602 } |
|
603 else |
|
604 { |
|
605 // This is not a progress message - let deriving class handle |
|
606 error = DoHandleMessageL(aMessage, *aList); |
|
607 } |
|
608 |
|
609 // Check if ready to exit, i.e., to close progress note, and allow user |
|
610 // to select another menu option |
|
611 TryExitL(error); |
|
612 } |
|
613 } |
|
614 |
|
615 // ----------------------------------------------------------------------------- |
|
616 // HandleMessageL |
|
617 // ----------------------------------------------------------------------------- |
|
618 // |
|
619 EXPORT_C void CGlxMpxCommandCommandHandler::HandleCommandCompleteL(TAny* aSessionId, |
|
620 CMPXCommand* aCommandResult, TInt aError, MGlxMediaList* aList) |
|
621 { |
|
622 // Unmark all medialist items. Exit Multiple marking mode upon command completion |
|
623 iAppUi->ProcessCommandL(EGlxCmdEndMultipleMarking); |
|
624 |
|
625 ///@todo Enforce a single command request at a time on the media list. |
|
626 DoHandleCommandCompleteL(aSessionId, aCommandResult, aError, aList); |
|
627 iProgressComplete = ETrue; |
|
628 TryExitL(aError); |
|
629 } |
|
630 |
|
631 // ----------------------------------------------------------------------------- |
|
632 // DialogDismissedL |
|
633 // ----------------------------------------------------------------------------- |
|
634 // |
|
635 EXPORT_C void CGlxMpxCommandCommandHandler::DialogDismissedL(TInt /*aButtonId*/) |
|
636 { |
|
637 if (!iProgressComplete) |
|
638 { |
|
639 // Remove as media list observer |
|
640 MGlxMediaList& mediaList = MediaList(); |
|
641 mediaList.CancelCommand(); |
|
642 mediaList.RemoveMediaListObserver(this); |
|
643 } |
|
644 } |
|
645 |
|
646 //----------------------------------------------------------------------------- |
|
647 // DoActivateL |
|
648 //----------------------------------------------------------------------------- |
|
649 // |
|
650 EXPORT_C void CGlxMpxCommandCommandHandler::DoActivateL(TInt /*aViewId*/) |
|
651 { |
|
652 // Do nothing |
|
653 } |
|
654 |
|
655 // ----------------------------------------------------------------------------- |
|
656 // Deactivate - Deactivate this command handler |
|
657 // ----------------------------------------------------------------------------- |
|
658 // |
|
659 EXPORT_C void CGlxMpxCommandCommandHandler::Deactivate() |
|
660 { |
|
661 // Close the progress note, if displayed |
|
662 if (iProgressDialog) |
|
663 { |
|
664 TRAP_IGNORE(DismissProgressNoteL()); |
|
665 } |
|
666 } |