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