author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 21:19:17 +0300 | |
branch | RCL_3 |
changeset 27 | 34937ec34dac |
parent 26 | 5b3385a43d68 |
permissions | -rw-r--r-- |
26 | 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)); |
|
27
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
534 |
CleanupStack::PushL(progressText); |
26 | 535 |
// construct progress dialog |
27
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
536 |
iProgressDialog = new (ELeave) CAknProgressDialog( |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
537 |
(REINTERPRET_CAST(CEikDialog**,&iProgressDialog))); |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
538 |
iProgressDialog->PrepareLC(R_GLX_PROGRESS_NOTE); |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
539 |
if (aCommandId == EGlxCmdRename) |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
540 |
{ |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
541 |
iProgressDialog->ButtonGroupContainer().SetCommandSetL( |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
542 |
R_AVKON_SOFTKEYS_EMPTY); |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
543 |
} |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
544 |
iProgressDialog->SetTextL(*progressText); |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
545 |
iProgressDialog->SetCallback(this); |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
546 |
|
26 | 547 |
// pick up progress info so that progress notification can be later updated |
27
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
548 |
iProgressInfo = iProgressDialog->GetProgressInfoL(); |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
549 |
|
26 | 550 |
// launch the note |
27
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
551 |
iProgressDialog->RunLD(); |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
552 |
CleanupStack::PopAndDestroy(progressText); |
34937ec34dac
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
26
diff
changeset
|
553 |
} |
26 | 554 |
|
555 |
// ----------------------------------------------------------------------------- |
|
556 |
// DismissProgressNoteL |
|
557 |
// ----------------------------------------------------------------------------- |
|
558 |
// |
|
559 |
void CGlxMpxCommandCommandHandler::DismissProgressNoteL() |
|
560 |
{ |
|
561 |
TRACER("CGlxMpxCommandCommandHandler::DismissProgressNoteL"); |
|
562 |
// Close the progress note, if displayed |
|
563 |
if (iProgressDialog) |
|
564 |
{ |
|
565 |
iProgressDialog->MakeVisible(EFalse); |
|
566 |
iProgressDialog->ProcessFinishedL(); |
|
567 |
iProgressDialog = NULL; |
|
568 |
iProgressInfo = NULL; |
|
569 |
} |
|
570 |
} |
|
571 |
||
572 |
// ----------------------------------------------------------------------------- |
|
573 |
// Remove MediaList Observer |
|
574 |
// ----------------------------------------------------------------------------- |
|
575 |
// |
|
576 |
void CGlxMpxCommandCommandHandler::RemoveMediaListObserver() |
|
577 |
{ |
|
578 |
TRACER("CGlxMpxCommandCommandHandler::RemoveMediaListObserver"); |
|
579 |
MGlxMediaList& mediaList = MediaList(); |
|
580 |
mediaList.RemoveMediaListObserver(this); |
|
581 |
} |
|
582 |
||
583 |
// ----------------------------------------------------------------------------- |
|
584 |
// Show a completion note |
|
585 |
// ----------------------------------------------------------------------------- |
|
586 |
// |
|
587 |
void CGlxMpxCommandCommandHandler::CompletionNoteL() const |
|
588 |
{ |
|
589 |
TRACER("CGlxMpxCommandCommandHandler::CompletionNoteL"); |
|
590 |
// Get completion note text |
|
591 |
HBufC* noteText = CompletionTextL(); |
|
592 |
if ( noteText ) |
|
593 |
{ |
|
594 |
CleanupStack::PushL(noteText); |
|
595 |
GlxGeneralUiUtilities::ShowConfirmationNoteL(*noteText, ETrue); |
|
596 |
CleanupStack::PopAndDestroy(noteText); |
|
597 |
} |
|
598 |
} |
|
599 |
||
600 |
// ----------------------------------------------------------------------------- |
|
601 |
// HandleItemAddedL |
|
602 |
// ----------------------------------------------------------------------------- |
|
603 |
// |
|
604 |
EXPORT_C void CGlxMpxCommandCommandHandler::HandleItemAddedL(TInt /*aStartIndex*/, TInt /*aEndIndex*/, MGlxMediaList* /*aList*/) |
|
605 |
{ |
|
606 |
// Do nothing |
|
607 |
} |
|
608 |
||
609 |
// ----------------------------------------------------------------------------- |
|
610 |
// HandleMediaL |
|
611 |
// ----------------------------------------------------------------------------- |
|
612 |
// |
|
613 |
EXPORT_C void CGlxMpxCommandCommandHandler::HandleMediaL(TInt /*aListIndex*/, MGlxMediaList* /*aList*/) |
|
614 |
{ |
|
615 |
// Do nothing |
|
616 |
} |
|
617 |
||
618 |
// ----------------------------------------------------------------------------- |
|
619 |
// HandleItemRemovedL |
|
620 |
// ----------------------------------------------------------------------------- |
|
621 |
// |
|
622 |
EXPORT_C void CGlxMpxCommandCommandHandler::HandleItemRemovedL(TInt /*aStartIndex*/, TInt /*aEndIndex*/, MGlxMediaList* /*aList*/) |
|
623 |
{ |
|
624 |
// Do nothing |
|
625 |
} |
|
626 |
||
627 |
// ----------------------------------------------------------------------------- |
|
628 |
// HandleItemModifiedL |
|
629 |
// ----------------------------------------------------------------------------- |
|
630 |
// |
|
631 |
EXPORT_C void CGlxMpxCommandCommandHandler::HandleItemModifiedL(const RArray<TInt>& /*aItemIndexes*/, |
|
632 |
MGlxMediaList* /*aList*/) |
|
633 |
{ |
|
634 |
// Do nothing |
|
635 |
} |
|
636 |
||
637 |
// ----------------------------------------------------------------------------- |
|
638 |
// HandleAttributesAvailableL |
|
639 |
// ----------------------------------------------------------------------------- |
|
640 |
// |
|
641 |
EXPORT_C void CGlxMpxCommandCommandHandler::HandleAttributesAvailableL(TInt /*aItemIndex*/, |
|
642 |
const RArray<TMPXAttribute>& /*aAttributes*/, MGlxMediaList* /*aList*/) |
|
643 |
{ |
|
644 |
// Do nothing |
|
645 |
} |
|
646 |
||
647 |
// ----------------------------------------------------------------------------- |
|
648 |
// HandleFocusChangedL |
|
649 |
// ----------------------------------------------------------------------------- |
|
650 |
// |
|
651 |
EXPORT_C void CGlxMpxCommandCommandHandler::HandleFocusChangedL(NGlxListDefs::TFocusChangeType /*aType*/, |
|
652 |
TInt /*aNewIndex*/, TInt /*aOldIndex*/, MGlxMediaList* /*aList*/) |
|
653 |
{ |
|
654 |
// Do nothing |
|
655 |
} |
|
656 |
||
657 |
// ----------------------------------------------------------------------------- |
|
658 |
// HandleItemSelectedL |
|
659 |
// ----------------------------------------------------------------------------- |
|
660 |
// |
|
661 |
EXPORT_C void CGlxMpxCommandCommandHandler::HandleItemSelectedL(TInt /*aIndex*/, |
|
662 |
TBool /*aSelected*/, MGlxMediaList* /*aList*/) |
|
663 |
{ |
|
664 |
// Do nothing |
|
665 |
} |
|
666 |
||
667 |
// ----------------------------------------------------------------------------- |
|
668 |
// HandleMessageL |
|
669 |
// ----------------------------------------------------------------------------- |
|
670 |
// |
|
671 |
EXPORT_C void CGlxMpxCommandCommandHandler::HandleMessageL(const CMPXMessage& aMessage, |
|
672 |
MGlxMediaList* aList) |
|
673 |
{ |
|
674 |
TRACER("CGlxMpxCommandCommandHandler::HandleMessageL"); |
|
675 |
if ((aMessage.IsSupported(KMPXMessageGeneralId) && |
|
676 |
(aMessage.IsSupported(KMPXCommandGeneralSessionId)))) |
|
677 |
{ |
|
678 |
TInt msgId = aMessage.ValueTObjectL<TInt>(KMPXMessageGeneralId); |
|
679 |
TAny* sessionId = aMessage.ValueTObjectL<TAny*>(KMPXCommandGeneralSessionId); |
|
680 |
||
681 |
TInt error = KErrNone; |
|
682 |
// Check if this is a progress message and intended for this object |
|
683 |
if ( KMPXMessageContentIdProgress == msgId && static_cast<TAny*>(this) == sessionId ) |
|
684 |
{ |
|
685 |
// Update progress note |
|
686 |
iProgressComplete = UpdateProgressL(aMessage, error); |
|
687 |
} |
|
688 |
else |
|
689 |
{ |
|
690 |
// This is not a progress message - let deriving class handle |
|
691 |
error = DoHandleMessageL(aMessage, *aList); |
|
692 |
} |
|
693 |
||
694 |
// Check if ready to exit, i.e., to close progress note, and allow user |
|
695 |
// to select another menu option |
|
696 |
TryExitL(error); |
|
697 |
} |
|
698 |
} |
|
699 |
||
700 |
// ----------------------------------------------------------------------------- |
|
701 |
// HandleMessageL |
|
702 |
// ----------------------------------------------------------------------------- |
|
703 |
// |
|
704 |
EXPORT_C void CGlxMpxCommandCommandHandler::HandleCommandCompleteL(TAny* aSessionId, |
|
705 |
CMPXCommand* aCommandResult, TInt aError, MGlxMediaList* aList) |
|
706 |
{ |
|
707 |
TRACER("CGlxMpxCommandCommandHandler::HandleCommandCompleteL"); |
|
708 |
// Unmark all medialist items. Exit Multiple marking mode upon command completion |
|
709 |
iAppUi->ProcessCommandL(EGlxCmdEndMultipleMarking); |
|
710 |
||
711 |
///@todo Enforce a single command request at a time on the media list. |
|
712 |
DoHandleCommandCompleteL(aSessionId, aCommandResult, aError, aList); |
|
713 |
iProgressComplete = ETrue; |
|
714 |
TryExitL(aError); |
|
715 |
} |
|
716 |
||
717 |
// ----------------------------------------------------------------------------- |
|
718 |
// DialogDismissedL |
|
719 |
// ----------------------------------------------------------------------------- |
|
720 |
// |
|
721 |
EXPORT_C void CGlxMpxCommandCommandHandler::DialogDismissedL(TInt /*aButtonId*/) |
|
722 |
{ |
|
723 |
TRACER("CGlxMpxCommandCommandHandler::DialogDismissedL"); |
|
724 |
if (!iProgressComplete) |
|
725 |
{ |
|
726 |
// Remove as media list observer |
|
727 |
MGlxMediaList& mediaList = MediaList(); |
|
728 |
mediaList.CancelCommand(); |
|
729 |
mediaList.RemoveMediaListObserver(this); |
|
730 |
} |
|
731 |
} |
|
732 |
||
733 |
//----------------------------------------------------------------------------- |
|
734 |
// DoActivateL |
|
735 |
//----------------------------------------------------------------------------- |
|
736 |
// |
|
737 |
EXPORT_C void CGlxMpxCommandCommandHandler::DoActivateL(TInt /*aViewId*/) |
|
738 |
{ |
|
739 |
// Do nothing |
|
740 |
} |
|
741 |
||
742 |
// ----------------------------------------------------------------------------- |
|
743 |
// Deactivate - Deactivate this command handler |
|
744 |
// ----------------------------------------------------------------------------- |
|
745 |
// |
|
746 |
EXPORT_C void CGlxMpxCommandCommandHandler::Deactivate() |
|
747 |
{ |
|
748 |
TRACER("CGlxMpxCommandCommandHandler::Deactivate"); |
|
749 |
// Close the progress note, if displayed |
|
750 |
if (iProgressDialog) |
|
751 |
{ |
|
752 |
TRAP_IGNORE(DismissProgressNoteL()); |
|
753 |
} |
|
754 |
} |
|
755 |
||
756 |
// ----------------------------------------------------------------------------- |
|
757 |
// CreateImageViewerInstanceL |
|
758 |
// ----------------------------------------------------------------------------- |
|
759 |
// |
|
760 |
void CGlxMpxCommandCommandHandler::CreateImageViewerInstanceL() |
|
761 |
{ |
|
762 |
TRACER("CGlxMpxCommandCommandHandler::CreateImageViewerInstanceL"); |
|
763 |
iImageViewerInstance = CGlxImageViewerManager::InstanceL(); |
|
764 |
__ASSERT_ALWAYS(iImageViewerInstance, Panic(EGlxPanicNullPointer)); |
|
765 |
} |
|
766 |
||
767 |
// ----------------------------------------------------------------------------- |
|
768 |
// DeleteImageViewerInstance |
|
769 |
// ----------------------------------------------------------------------------- |
|
770 |
// |
|
771 |
void CGlxMpxCommandCommandHandler::DeleteImageViewerInstance() |
|
772 |
{ |
|
773 |
TRACER("CGlxMpxCommandCommandHandler::DeleteImageViewerInstance"); |
|
774 |
if ( iImageViewerInstance ) |
|
775 |
{ |
|
776 |
iImageViewerInstance->DeleteInstance(); |
|
777 |
} |
|
778 |
} |