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