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: Delete command handler
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
/**
|
|
22 |
* @internal reviewed 06/06/2007 by Dave Schofield
|
|
23 |
*/
|
|
24 |
|
|
25 |
#include "glxcommandhandlernewmedia.h"
|
|
26 |
|
|
27 |
#include <AknUtils.h>
|
|
28 |
#include <badesca.h>
|
|
29 |
#include <bautils.h>
|
|
30 |
#include <glxattributecontext.h>
|
|
31 |
#include <glxattributeretriever.h>
|
|
32 |
#include <glxcollectiongeneraldefs.h>
|
|
33 |
#include <glxcommandfactory.h>
|
|
34 |
#include <glxcommandhandlers.hrh>
|
|
35 |
#include <glxfetchcontextremover.h>
|
|
36 |
#include <glxgeneraluiutilities.h>
|
|
37 |
#include <glxpanic.h>
|
|
38 |
#include <glxtracer.h>
|
|
39 |
#include <glxresourceutilities.h> // for CGlxResourceUtilities
|
|
40 |
#include <glxsetappstate.h>
|
|
41 |
#include <glxtextentrypopup.h>
|
|
42 |
#include <glxuistd.h>
|
|
43 |
#include <glxuiutilities.rsg>
|
|
44 |
#include <mglxmedialist.h>
|
|
45 |
#include <mpxcollectionpath.h>
|
|
46 |
#include <mpxcommonframeworkdefs.h>
|
|
47 |
#include <StringLoader.h>
|
|
48 |
#include <glxmediageneraldefs.h> // for KMaxMediaPopupTextLength
|
|
49 |
#include <data_caging_path_literals.hrh>
|
|
50 |
#include <glxuiutilities.rsg>
|
|
51 |
#include <e32const.h> //For TDigitType
|
|
52 |
|
|
53 |
const TInt KMaxNumberLength = 10;
|
|
54 |
|
|
55 |
_LIT(KOpenBracket, "(");
|
|
56 |
_LIT(KCloseBracket, ")");
|
|
57 |
_LIT(KFileNameFormatString, "(%+02u)");
|
|
58 |
|
|
59 |
// ---------------------------------------------------------------------------
|
|
60 |
// Two-phased constructor.
|
|
61 |
// ---------------------------------------------------------------------------
|
|
62 |
//
|
|
63 |
EXPORT_C CGlxCommandHandlerNewMedia* CGlxCommandHandlerNewMedia::NewL(
|
|
64 |
MGlxMediaListProvider* aMediaListProvider, const TDesC& aFileName)
|
|
65 |
{
|
|
66 |
TRACER("CGlxCommandHandlerNewMedia* CGlxCommandHandlerNewMedia::NewL");
|
|
67 |
CGlxCommandHandlerNewMedia* self = new (ELeave) CGlxCommandHandlerNewMedia(
|
|
68 |
aMediaListProvider);
|
|
69 |
CleanupStack::PushL(self);
|
|
70 |
self->ConstructL(aFileName);
|
|
71 |
CleanupStack::Pop(self);
|
|
72 |
return self;
|
|
73 |
}
|
|
74 |
|
|
75 |
// ---------------------------------------------------------------------------
|
|
76 |
// C++ default constructor can NOT contain any code, that
|
|
77 |
// might leave.
|
|
78 |
// ---------------------------------------------------------------------------
|
|
79 |
//
|
|
80 |
CGlxCommandHandlerNewMedia::CGlxCommandHandlerNewMedia(MGlxMediaListProvider* aMediaListProvider)
|
|
81 |
: CGlxMpxCommandCommandHandler(aMediaListProvider)
|
|
82 |
{
|
|
83 |
// Don't do anything.
|
|
84 |
}
|
|
85 |
|
|
86 |
// -----------------------------------------------------------------------------
|
|
87 |
// CGlxCommandHandlerNewMedia::DoHandleCommandCompleteL
|
|
88 |
// -----------------------------------------------------------------------------
|
|
89 |
//
|
|
90 |
void CGlxCommandHandlerNewMedia::DoHandleCommandCompleteL(TAny* /*aSessionId*/, CMPXCommand* aCommandResult,
|
|
91 |
TInt aError, MGlxMediaList* /*aList*/)
|
|
92 |
{
|
|
93 |
TRACER("CGlxCommandHandlerNewMedia::DoHandleCommandCompleteL");
|
|
94 |
if (aError == KErrNone && aCommandResult && aCommandResult->IsSupported(KMPXMediaGeneralId))
|
|
95 |
{
|
|
96 |
iNewMediaId = TGlxMediaId(aCommandResult->ValueTObjectL<TMPXItemId>(KMPXMediaGeneralId));
|
|
97 |
iOkToExit = EFalse; // wait for media id to be added to the list
|
|
98 |
// (unless we are using iSchedulerWait)
|
|
99 |
}
|
|
100 |
|
|
101 |
if (iSchedulerWait && aError != KErrAlreadyExists )
|
|
102 |
{
|
|
103 |
// if iSchedulerWait exists then we know the command is being executed from
|
|
104 |
// the ExecuteLD() method.
|
|
105 |
iNewMediaCreationError = aError;
|
|
106 |
iSchedulerWait->AsyncStop();
|
|
107 |
}
|
|
108 |
}
|
|
109 |
|
|
110 |
// -----------------------------------------------------------------------------
|
|
111 |
// CGlxCommandHandlerNewMedia::OkToExit
|
|
112 |
// -----------------------------------------------------------------------------
|
|
113 |
//
|
|
114 |
EXPORT_C TBool CGlxCommandHandlerNewMedia::OkToExit() const
|
|
115 |
{
|
|
116 |
return iOkToExit;
|
|
117 |
}
|
|
118 |
|
|
119 |
// ---------------------------------------------------------------------------
|
|
120 |
// Symbian 2nd phase constructor can leave.
|
|
121 |
// ---------------------------------------------------------------------------
|
|
122 |
//
|
|
123 |
void CGlxCommandHandlerNewMedia::ConstructL(const TDesC& aFileName)
|
|
124 |
{
|
|
125 |
TRACER("CGlxCommandHandlerNewMedia::ConstructL()");
|
|
126 |
iFileNameAlreadyExists = EFalse;
|
|
127 |
|
|
128 |
iResourceOffset = CCoeEnv::Static()->AddResourceFileL(aFileName);
|
|
129 |
|
|
130 |
iAsyncFocuser = new (ELeave) CGlxAsyncFocuser(this);
|
|
131 |
// Add supported command
|
|
132 |
TCommandInfo info(EGlxCmdAddMedia);
|
|
133 |
// Filter out static items
|
|
134 |
AddCommandL(info);
|
|
135 |
}
|
|
136 |
|
|
137 |
// ---------------------------------------------------------------------------
|
|
138 |
// Destructor
|
|
139 |
// ---------------------------------------------------------------------------
|
|
140 |
//
|
|
141 |
EXPORT_C CGlxCommandHandlerNewMedia::~CGlxCommandHandlerNewMedia()
|
|
142 |
{
|
|
143 |
TRACER("CGlxCommandHandlerNewMedia::~CGlxCommandHandlerNewMedia()");
|
|
144 |
if ( iResourceOffset )
|
|
145 |
{
|
|
146 |
CCoeEnv::Static()->DeleteResourceFile(iResourceOffset);
|
|
147 |
}
|
|
148 |
|
|
149 |
delete iSchedulerWait;
|
|
150 |
delete iAsyncFocuser;
|
|
151 |
delete iNewMediaItemTitle;
|
|
152 |
}
|
|
153 |
|
|
154 |
// ---------------------------------------------------------------------------
|
|
155 |
// CGlxCommandHandlerNewMedia::ExecuteLD()
|
|
156 |
// ---------------------------------------------------------------------------
|
|
157 |
//
|
|
158 |
EXPORT_C TInt CGlxCommandHandlerNewMedia::ExecuteLD(TGlxMediaId& aNewMediaId)
|
|
159 |
{
|
|
160 |
TRACER("CGlxCommandHandlerNewMedia::ExecuteLD");
|
|
161 |
CleanupStack::PushL(this);
|
|
162 |
iSchedulerWait = new (ELeave) CActiveSchedulerWait();
|
|
163 |
|
|
164 |
CGlxMpxCommandCommandHandler::ExecuteL( EGlxCmdAddMedia );
|
|
165 |
if (iNewMediaCreationError == KErrNone)
|
|
166 |
{
|
|
167 |
// The user pressed OK on the dialog. We need to wait for DoHandleCommandComplete()
|
|
168 |
iSchedulerWait->Start();
|
|
169 |
|
|
170 |
if (iNewMediaCreationError == KErrNone)
|
|
171 |
{
|
|
172 |
aNewMediaId = iNewMediaId;
|
|
173 |
}
|
|
174 |
}
|
|
175 |
|
|
176 |
TInt error = iNewMediaCreationError;
|
|
177 |
CleanupStack::PopAndDestroy(this);
|
|
178 |
return error;
|
|
179 |
}
|
|
180 |
|
|
181 |
// ---------------------------------------------------------------------------
|
|
182 |
// Create an add to container command
|
|
183 |
// ---------------------------------------------------------------------------
|
|
184 |
//
|
|
185 |
CMPXCommand* CGlxCommandHandlerNewMedia::CreateCommandL(TInt /*aCommandId*/,
|
|
186 |
MGlxMediaList& aMediaList, TBool& /*aConsume*/) const
|
|
187 |
{
|
|
188 |
TRACER("CGlxCommandHandlerNewMedia::CreateCommandL");
|
|
189 |
iOkToExit = ETrue;
|
|
190 |
|
|
191 |
CMPXCollectionPath* path = aMediaList.PathLC( NGlxListDefs::EPathParent );
|
|
192 |
CMPXCommand* command = NULL;
|
|
193 |
|
|
194 |
TBuf <KMaxMediaPopupTextLength> defaultNewMediaItemTitle;
|
|
195 |
|
|
196 |
TRAPD(error, TitlesL(TGlxMediaId(path->Id(0)), defaultNewMediaItemTitle));
|
|
197 |
if(error != KErrNone)
|
|
198 |
{
|
|
199 |
iNewMediaCreationError = KErrCancel;
|
|
200 |
CleanupStack::PopAndDestroy(path);
|
|
201 |
return command;
|
|
202 |
}
|
|
203 |
|
|
204 |
HBufC* mediaPopupTitle = StringLoader::LoadLC(R_GLX_PROMPT_NAME);
|
|
205 |
if(iFileNameAlreadyExists)
|
|
206 |
{
|
|
207 |
iFileNameAlreadyExists = EFalse ;
|
|
208 |
}
|
|
209 |
else
|
|
210 |
{
|
|
211 |
delete iNewMediaItemTitle;
|
|
212 |
iNewMediaItemTitle = NULL;
|
|
213 |
iNewMediaItemTitle = GenerateNewMediaItemTitleL(defaultNewMediaItemTitle, aMediaList);
|
|
214 |
}
|
|
215 |
TPtr newMediaItemTitleDes = iNewMediaItemTitle->Des();
|
|
216 |
|
|
217 |
CGlxTextEntryPopup* dialog = CGlxTextEntryPopup::NewL(*mediaPopupTitle, newMediaItemTitleDes);
|
|
218 |
if(dialog->ExecuteLD() == EEikBidOk)
|
|
219 |
{
|
|
220 |
command = TGlxCommandFactory::AddContainerCommandLC(*iNewMediaItemTitle, path->Id(0));
|
|
221 |
CleanupStack::Pop(command);
|
|
222 |
}
|
|
223 |
else
|
|
224 |
{
|
|
225 |
iNewMediaCreationError = KErrCancel;
|
|
226 |
}
|
|
227 |
|
|
228 |
CleanupStack::PopAndDestroy(mediaPopupTitle);
|
|
229 |
CleanupStack::PopAndDestroy(path);
|
|
230 |
return command;
|
|
231 |
}
|
|
232 |
|
|
233 |
|
|
234 |
// ---------------------------------------------------------------------------
|
|
235 |
// CGlxCommandHandlerNewMedia::HandleErrorL
|
|
236 |
// ---------------------------------------------------------------------------
|
|
237 |
//
|
|
238 |
void CGlxCommandHandlerNewMedia::HandleErrorL(TInt aError)
|
|
239 |
{
|
|
240 |
TRACER("CGlxCommandHandlerNewMedia::HandleErrorL");
|
|
241 |
if (aError == KErrAlreadyExists && iNewMediaItemTitle)
|
|
242 |
{
|
|
243 |
HBufC* info = StringLoader::LoadLC(R_GLX_NAME_ALREADY_USED, *iNewMediaItemTitle);
|
|
244 |
GlxGeneralUiUtilities::ShowInfoNoteL(*info, ETrue);
|
|
245 |
CleanupStack::PopAndDestroy(info);
|
|
246 |
iFileNameAlreadyExists = ETrue ;
|
|
247 |
// As the new Item name already existing , re-execute the command to show entry pop-up
|
|
248 |
CGlxMpxCommandCommandHandler::ExecuteL( EGlxCmdAddMedia );
|
|
249 |
if (iSchedulerWait && iNewMediaCreationError == KErrCancel )
|
|
250 |
{
|
|
251 |
// if iSchedulerWait exists then we know the command is being executed from
|
|
252 |
// the ExecuteLD() method.
|
|
253 |
// Stop the schedulerwait loop if dialog is cancelled after starting the schedulerwait loop
|
|
254 |
iSchedulerWait->AsyncStop();
|
|
255 |
}
|
|
256 |
}
|
|
257 |
else
|
|
258 |
{
|
|
259 |
// Use default error handler
|
|
260 |
CGlxMpxCommandCommandHandler::HandleErrorL(aError);
|
|
261 |
}
|
|
262 |
}
|
|
263 |
|
|
264 |
// -----------------------------------------------------------------------------
|
|
265 |
// BypassFiltersForExecute
|
|
266 |
// -----------------------------------------------------------------------------
|
|
267 |
//
|
|
268 |
EXPORT_C TBool CGlxCommandHandlerNewMedia::BypassFiltersForExecute() const
|
|
269 |
{
|
|
270 |
TRACER("CGlxCommandHandlerNewMedia::BypassFiltersForExecute()");
|
|
271 |
// if iSchedulerWait exists then we know the command is being executed from
|
|
272 |
// the ExecuteLD() method and filtering is not required.
|
|
273 |
return iSchedulerWait != NULL;
|
|
274 |
}
|
|
275 |
|
|
276 |
|
|
277 |
// ---------------------------------------------------------------------------
|
|
278 |
// TitlesL fetches the 'media popup title' and 'default new media item title'
|
|
279 |
// from the collection.
|
|
280 |
// ---------------------------------------------------------------------------
|
|
281 |
//
|
|
282 |
|
|
283 |
void CGlxCommandHandlerNewMedia::TitlesL(const TGlxMediaId aCollectionId,
|
|
284 |
TDes& aDefaultNewMediaItemTitle) const
|
|
285 |
{
|
|
286 |
TRACER("CGlxCommandHandlerNewMedia::TitlesL");
|
|
287 |
CMPXCollectionPath* path = CMPXCollectionPath::NewL();
|
|
288 |
CleanupStack::PushL(path);
|
|
289 |
MGlxMediaList* rootList = MGlxMediaList::InstanceL(*path);
|
|
290 |
CleanupClosePushL(*rootList);
|
|
291 |
|
|
292 |
TGlxSpecificIdIterator iter(KGlxIdSpaceIdRoot, aCollectionId);
|
|
293 |
CGlxAttributeContext* attributeContext =
|
|
294 |
new (ELeave) CGlxAttributeContext(&iter);
|
|
295 |
CleanupStack::PushL(attributeContext);
|
|
296 |
attributeContext->AddAttributeL(
|
|
297 |
KGlxMediaCollectionPluginSpecificDefaultMediaTitle);
|
|
298 |
rootList->AddContextL(attributeContext, KGlxFetchContextPriorityBlocking);
|
|
299 |
|
|
300 |
TGlxFetchContextRemover contextRemover(attributeContext, *rootList);
|
|
301 |
// put to cleanupstack as cleanupstack is emptied before stack objects
|
|
302 |
// are deleted
|
|
303 |
CleanupClosePushL(contextRemover);
|
|
304 |
User::LeaveIfError(GlxAttributeRetriever::RetrieveL(*attributeContext,
|
|
305 |
*rootList, ETrue));
|
|
306 |
// context off the list
|
|
307 |
CleanupStack::PopAndDestroy(&contextRemover);
|
|
308 |
|
|
309 |
TInt index = rootList->Index(KGlxIdSpaceIdRoot, aCollectionId);
|
|
310 |
|
|
311 |
__ASSERT_DEBUG(index != KErrNotFound, Panic(EGlxPanicRequiredItemNotFound));
|
|
312 |
|
|
313 |
TGlxMedia item = rootList->Item(index);
|
|
314 |
|
|
315 |
const CGlxMedia* media = item.Properties();
|
|
316 |
if (media)
|
|
317 |
{
|
|
318 |
aDefaultNewMediaItemTitle.Copy(media->ValueText(
|
|
319 |
KGlxMediaCollectionPluginSpecificDefaultMediaTitle).Left(
|
|
320 |
KMaxMediaPopupTextLength));
|
|
321 |
}
|
|
322 |
|
|
323 |
CleanupStack::PopAndDestroy(attributeContext);
|
|
324 |
CleanupStack::PopAndDestroy(rootList);
|
|
325 |
CleanupStack::PopAndDestroy(path);
|
|
326 |
}
|
|
327 |
|
|
328 |
// ---------------------------------------------------------------------------
|
|
329 |
// TitlesL fetches the 'media popup title' and 'default new media item title'
|
|
330 |
// from the collection.
|
|
331 |
// ---------------------------------------------------------------------------
|
|
332 |
//
|
|
333 |
HBufC* CGlxCommandHandlerNewMedia::GenerateNewMediaItemTitleL(
|
|
334 |
const TDesC& aDefaultNewMediaItemTitle, MGlxMediaList& aList) const
|
|
335 |
{
|
|
336 |
TRACER("CGlxCommandHandlerNewMedia::GenerateNewMediaItemTitleL");
|
|
337 |
TGlxSequentialIterator iter;
|
|
338 |
CGlxAttributeContext* attributeContext =
|
|
339 |
new (ELeave) CGlxAttributeContext(&iter);
|
|
340 |
CleanupStack::PushL(attributeContext);
|
|
341 |
attributeContext->AddAttributeL(KMPXMediaGeneralTitle);
|
|
342 |
aList.AddContextL(attributeContext, KGlxFetchContextPriorityBlocking);
|
|
343 |
TGlxFetchContextRemover contextRemover(attributeContext, aList);
|
|
344 |
// put to cleanupstack as cleanupstack is emptied before stack objects
|
|
345 |
// are deleted
|
|
346 |
CleanupClosePushL(contextRemover);
|
|
347 |
User::LeaveIfError(GlxAttributeRetriever::RetrieveL(*attributeContext,
|
|
348 |
aList, EFalse));
|
|
349 |
// context off the list
|
|
350 |
CleanupStack::PopAndDestroy(&contextRemover);
|
|
351 |
CleanupStack::PopAndDestroy(attributeContext);
|
|
352 |
|
|
353 |
RArray<TInt> numbers;
|
|
354 |
CleanupClosePushL(numbers);
|
|
355 |
|
|
356 |
TInt count = aList.Count();
|
|
357 |
for (TInt i = 0; i < count; i++)
|
|
358 |
{
|
|
359 |
TGlxMedia item = aList.Item(i);
|
|
360 |
const CGlxMedia* media = item.Properties();
|
|
361 |
if (media)
|
|
362 |
{
|
|
363 |
const TDesC& title = media->ValueText(KMPXMediaGeneralTitle);
|
|
364 |
|
|
365 |
TInt length = aDefaultNewMediaItemTitle.Length();
|
|
366 |
if (title.Left(length).Compare(aDefaultNewMediaItemTitle) == 0)
|
|
367 |
{
|
|
368 |
if (length == title.Length())
|
|
369 |
{
|
|
370 |
numbers.InsertInOrderL(0); // special case
|
|
371 |
}
|
|
372 |
else if (title.Length() > length + KOpenBracket().Length()
|
|
373 |
+ KCloseBracket().Length())
|
|
374 |
{
|
|
375 |
TInt pos = length;
|
|
376 |
length = KOpenBracket().Length();
|
|
377 |
|
|
378 |
if (title.Mid(pos, length).Compare(KOpenBracket) == 0
|
|
379 |
&& title.Right(KCloseBracket().Length()).Compare(
|
|
380 |
KCloseBracket) == 0)
|
|
381 |
{
|
|
382 |
pos += length;
|
|
383 |
length = title.Length() - pos
|
|
384 |
- KCloseBracket().Length();
|
|
385 |
if (length > 0)
|
|
386 |
{
|
|
387 |
HBufC* num = title.Mid(pos, length).AllocLC();
|
|
388 |
TPtr numPtr = num->Des();
|
|
389 |
//Change to Western numeric for determining next numeral
|
|
390 |
AknTextUtils::ConvertDigitsTo(numPtr,EDigitTypeWestern);
|
|
391 |
TLex lex(numPtr);
|
|
392 |
TInt val = 0;
|
|
393 |
if (lex.Val(val) == KErrNone)
|
|
394 |
{
|
|
395 |
numbers.InsertInOrderL(val);
|
|
396 |
}
|
|
397 |
CleanupStack::PopAndDestroy(num);
|
|
398 |
}
|
|
399 |
}
|
|
400 |
}
|
|
401 |
|
|
402 |
}
|
|
403 |
}
|
|
404 |
}
|
|
405 |
|
|
406 |
TInt nextNumber = 0;
|
|
407 |
count = numbers.Count();
|
|
408 |
for (TInt i = 0; i < count; i++)
|
|
409 |
{
|
|
410 |
if (numbers[i] == nextNumber)
|
|
411 |
{
|
|
412 |
nextNumber++;
|
|
413 |
}
|
|
414 |
else
|
|
415 |
{
|
|
416 |
break;
|
|
417 |
}
|
|
418 |
}
|
|
419 |
|
|
420 |
CleanupStack::PopAndDestroy(&numbers);
|
|
421 |
|
|
422 |
TInt defaultTitleLength = aDefaultNewMediaItemTitle.Length()
|
|
423 |
+ KFileNameFormatString().Length() + KCloseBracket().Length()
|
|
424 |
+ KMaxNumberLength;
|
|
425 |
// If the default title length is bigger than KMaxMediaPopupTextLength,
|
|
426 |
// make sure we allocate enough space for it.
|
|
427 |
TInt titleLength = defaultTitleLength > KMaxMediaPopupTextLength ?
|
|
428 |
defaultTitleLength
|
|
429 |
: KMaxMediaPopupTextLength;
|
|
430 |
HBufC* newMediaItemTitle = HBufC::NewL(titleLength);
|
|
431 |
TPtr newMediaItemTitleDes = newMediaItemTitle->Des();
|
|
432 |
newMediaItemTitleDes.Append(aDefaultNewMediaItemTitle);
|
|
433 |
|
|
434 |
if (nextNumber > 0)
|
|
435 |
{
|
|
436 |
newMediaItemTitleDes.AppendFormat(KFileNameFormatString, nextNumber);
|
|
437 |
//Change numeric according to current input language here
|
|
438 |
AknTextUtils::ConvertDigitsTo(newMediaItemTitleDes,
|
|
439 |
AknTextUtils::TextEditorDigitType());
|
|
440 |
}
|
|
441 |
else
|
|
442 |
{
|
|
443 |
// 0 is a special case, return "New Media", not "New Media (0)"
|
|
444 |
}
|
|
445 |
|
|
446 |
return newMediaItemTitle;
|
|
447 |
}
|
|
448 |
|
|
449 |
// -----------------------------------------------------------------------------
|
|
450 |
// SetFocusL()
|
|
451 |
// -----------------------------------------------------------------------------
|
|
452 |
//
|
|
453 |
void CGlxCommandHandlerNewMedia::SetFocusL(TInt aIndex)
|
|
454 |
{
|
|
455 |
TRACER("CGlxCommandHandlerNewMedia::SetFocusL");
|
|
456 |
iOkToExit = ETrue;
|
|
457 |
MediaList().SetFocusL(NGlxListDefs::EAbsolute, aIndex);
|
|
458 |
TryExitL(KErrNone);
|
|
459 |
}
|
|
460 |
|
|
461 |
// -----------------------------------------------------------------------------
|
|
462 |
// HandleItemAddedL
|
|
463 |
// -----------------------------------------------------------------------------
|
|
464 |
//
|
|
465 |
EXPORT_C void CGlxCommandHandlerNewMedia::HandleItemAddedL(TInt aStartIndex,
|
|
466 |
TInt aEndIndex, MGlxMediaList* aList)
|
|
467 |
{
|
|
468 |
TRACER("CGlxCommandHandlerNewMedia::HandleItemAddedL");
|
|
469 |
if (aList == &MediaList() && iNewMediaId != KGlxCollectionRootId)
|
|
470 |
{
|
|
471 |
for (TInt i = aStartIndex; i <= aEndIndex; i++)
|
|
472 |
{
|
|
473 |
if (aList->Item(i).Id() == iNewMediaId)
|
|
474 |
{
|
|
475 |
// calls CGlxCommandHandlerNewMedia::SetFocusL asynchronously
|
|
476 |
iAsyncFocuser->SetFocus(i);
|
|
477 |
break;
|
|
478 |
}
|
|
479 |
}
|
|
480 |
}
|
|
481 |
}
|
|
482 |
|
|
483 |
// -----------------------------------------------------------------------------
|
|
484 |
// Constructor
|
|
485 |
// -----------------------------------------------------------------------------
|
|
486 |
//
|
|
487 |
CGlxCommandHandlerNewMedia::CGlxAsyncFocuser::
|
|
488 |
CGlxAsyncFocuser(CGlxCommandHandlerNewMedia* aGlxCommandHandlerNewMedia)
|
|
489 |
: CActive(KMaxTInt), iGlxCommandHandlerNewMedia(aGlxCommandHandlerNewMedia)
|
|
490 |
// The active object has the maximum possible priority to prevent
|
|
491 |
// other active objects running before it. (Unless they too are
|
|
492 |
// scheduled to run and have the maximum possible priority
|
|
493 |
{
|
|
494 |
TRACER("CGlxCommandHandlerNewMedia::CGlxAsyncFocuser::CGlxAsyncFocuser");
|
|
495 |
__ASSERT_DEBUG(aGlxCommandHandlerNewMedia, Panic(EGlxPanicNullPointer));
|
|
496 |
CActiveScheduler::Add(this);
|
|
497 |
}
|
|
498 |
|
|
499 |
// -----------------------------------------------------------------------------
|
|
500 |
// Destructor
|
|
501 |
// -----------------------------------------------------------------------------
|
|
502 |
//
|
|
503 |
CGlxCommandHandlerNewMedia::CGlxAsyncFocuser::
|
|
504 |
~CGlxAsyncFocuser()
|
|
505 |
{
|
|
506 |
TRACER("CGlxCommandHandlerNewMedia::CGlxAsyncFocuser::~CGlxAsyncFocuser()");
|
|
507 |
Cancel();
|
|
508 |
}
|
|
509 |
|
|
510 |
// -----------------------------------------------------------------------------
|
|
511 |
// RunL
|
|
512 |
// -----------------------------------------------------------------------------
|
|
513 |
//
|
|
514 |
void CGlxCommandHandlerNewMedia::CGlxAsyncFocuser::RunL()
|
|
515 |
{
|
|
516 |
TRACER("CGlxCommandHandlerNewMedia::CGlxAsyncFocuser::RunL()");
|
|
517 |
iGlxCommandHandlerNewMedia->SetFocusL(iFocusIndex);
|
|
518 |
}
|
|
519 |
|
|
520 |
// -----------------------------------------------------------------------------
|
|
521 |
// DoCancel
|
|
522 |
// -----------------------------------------------------------------------------
|
|
523 |
//
|
|
524 |
void CGlxCommandHandlerNewMedia::CGlxAsyncFocuser::DoCancel()
|
|
525 |
{
|
|
526 |
// No need to do anything
|
|
527 |
// CActive::Cancel() will wait for the request to complete
|
|
528 |
}
|
|
529 |
|
|
530 |
// -----------------------------------------------------------------------------
|
|
531 |
// SetFocusL
|
|
532 |
// -----------------------------------------------------------------------------
|
|
533 |
//
|
|
534 |
void CGlxCommandHandlerNewMedia::CGlxAsyncFocuser::SetFocus(TInt aIndex)
|
|
535 |
{
|
|
536 |
TRACER("CGlxCommandHandlerNewMedia::CGlxAsyncFocuser::SetFocus()");
|
|
537 |
iFocusIndex = aIndex;
|
|
538 |
TRequestStatus* requestStatus = &iStatus;
|
|
539 |
User::RequestComplete(requestStatus,KErrNone);
|
|
540 |
SetActive();
|
|
541 |
}
|