274 // if iSchedulerWait exists then we know the command is being executed from |
274 // if iSchedulerWait exists then we know the command is being executed from |
275 // the ExecuteLD() method and filtering is not required. |
275 // the ExecuteLD() method and filtering is not required. |
276 return iSchedulerWait != NULL; |
276 return iSchedulerWait != NULL; |
277 } |
277 } |
278 |
278 |
|
279 |
279 // --------------------------------------------------------------------------- |
280 // --------------------------------------------------------------------------- |
280 // TitlesL fetches the 'media popup title' and 'default new media item title' |
281 // TitlesL fetches the 'media popup title' and 'default new media item title' |
281 // from the collection. |
282 // from the collection. |
282 // --------------------------------------------------------------------------- |
283 // --------------------------------------------------------------------------- |
283 // |
284 // |
284 |
285 |
285 void CGlxCommandHandlerNewMedia::TitlesL(const TGlxMediaId aCollectionId, TDes& aDefaultNewMediaItemTitle) const |
286 void CGlxCommandHandlerNewMedia::TitlesL(const TGlxMediaId aCollectionId, |
286 { |
287 TDes& aDefaultNewMediaItemTitle) const |
|
288 { |
287 TRACER("CGlxCommandHandlerNewMedia::TitlesL"); |
289 TRACER("CGlxCommandHandlerNewMedia::TitlesL"); |
288 CMPXCollectionPath* path = CMPXCollectionPath::NewL(); |
290 CMPXCollectionPath* path = CMPXCollectionPath::NewL(); |
289 CleanupStack::PushL(path); |
291 CleanupStack::PushL(path); |
290 MGlxMediaList* rootList = MGlxMediaList::InstanceL(*path); |
292 MGlxMediaList* rootList = MGlxMediaList::InstanceL(*path); |
291 CleanupClosePushL(*rootList); |
293 CleanupClosePushL(*rootList); |
292 |
294 |
293 TGlxSpecificIdIterator iter(KGlxIdSpaceIdRoot, aCollectionId); |
295 TGlxSpecificIdIterator iter(KGlxIdSpaceIdRoot, aCollectionId); |
294 CGlxAttributeContext* attributeContext = new (ELeave) CGlxAttributeContext(&iter); |
296 CGlxAttributeContext* attributeContext = |
|
297 new (ELeave) CGlxAttributeContext(&iter); |
295 CleanupStack::PushL(attributeContext); |
298 CleanupStack::PushL(attributeContext); |
296 attributeContext->AddAttributeL(KGlxMediaCollectionPluginSpecificDefaultMediaTitle); |
299 attributeContext->AddAttributeL( |
|
300 KGlxMediaCollectionPluginSpecificDefaultMediaTitle); |
297 rootList->AddContextL(attributeContext, KGlxFetchContextPriorityBlocking); |
301 rootList->AddContextL(attributeContext, KGlxFetchContextPriorityBlocking); |
298 |
302 |
299 TGlxFetchContextRemover contextRemover(attributeContext, *rootList); |
303 TGlxFetchContextRemover contextRemover(attributeContext, *rootList); |
300 // put to cleanupstack as cleanupstack is emptied before stack objects |
304 // put to cleanupstack as cleanupstack is emptied before stack objects |
301 // are deleted |
305 // are deleted |
302 CleanupClosePushL( contextRemover ); |
306 CleanupClosePushL(contextRemover); |
303 User::LeaveIfError(GlxAttributeRetriever::RetrieveL(*attributeContext, *rootList, ETrue)); |
307 User::LeaveIfError(GlxAttributeRetriever::RetrieveL(*attributeContext, |
|
308 *rootList, ETrue)); |
304 // context off the list |
309 // context off the list |
305 CleanupStack::PopAndDestroy( &contextRemover ); |
310 CleanupStack::PopAndDestroy(&contextRemover); |
306 |
311 |
307 TInt index = rootList->Index(KGlxIdSpaceIdRoot, aCollectionId); |
312 TInt index = rootList->Index(KGlxIdSpaceIdRoot, aCollectionId); |
308 |
313 |
309 __ASSERT_DEBUG(index != KErrNotFound, Panic(EGlxPanicRequiredItemNotFound)); |
314 __ASSERT_DEBUG(index != KErrNotFound, Panic(EGlxPanicRequiredItemNotFound)); |
310 |
315 |
311 TGlxMedia item = rootList->Item(index); |
316 TGlxMedia item = rootList->Item(index); |
312 |
317 |
313 const CGlxMedia* media = item.Properties(); |
318 const CGlxMedia* media = item.Properties(); |
314 if (media) |
319 if (media) |
315 { |
320 { |
316 aDefaultNewMediaItemTitle.Copy(media->ValueText(KGlxMediaCollectionPluginSpecificDefaultMediaTitle).Left(KMaxMediaPopupTitleLength)); |
321 aDefaultNewMediaItemTitle.Copy(media->ValueText( |
317 } |
322 KGlxMediaCollectionPluginSpecificDefaultMediaTitle).Left( |
318 |
323 KMaxMediaPopupTitleLength)); |
319 CleanupStack::PopAndDestroy(attributeContext); |
324 } |
320 CleanupStack::PopAndDestroy(rootList); |
325 |
|
326 CleanupStack::PopAndDestroy(attributeContext); |
|
327 CleanupStack::PopAndDestroy(rootList); |
321 CleanupStack::PopAndDestroy(path); |
328 CleanupStack::PopAndDestroy(path); |
322 } |
329 } |
323 |
330 |
324 // --------------------------------------------------------------------------- |
331 // --------------------------------------------------------------------------- |
325 // TitlesL fetches the 'media popup title' and 'default new media item title' |
332 // TitlesL fetches the 'media popup title' and 'default new media item title' |
326 // from the collection. |
333 // from the collection. |
327 // --------------------------------------------------------------------------- |
334 // --------------------------------------------------------------------------- |
328 // |
335 // |
329 HBufC* CGlxCommandHandlerNewMedia::GenerateNewMediaItemTitleL |
336 HBufC* CGlxCommandHandlerNewMedia::GenerateNewMediaItemTitleL( |
330 (const TDesC& aDefaultNewMediaItemTitle, MGlxMediaList& aList) const |
337 const TDesC& aDefaultNewMediaItemTitle, MGlxMediaList& aList) const |
331 { |
338 { |
332 TRACER("CGlxCommandHandlerNewMedia::GenerateNewMediaItemTitleL"); |
339 TRACER("CGlxCommandHandlerNewMedia::GenerateNewMediaItemTitleL"); |
333 TGlxSequentialIterator iter; |
340 TGlxSequentialIterator iter; |
334 CGlxAttributeContext* attributeContext = new (ELeave) CGlxAttributeContext(&iter); |
341 CGlxAttributeContext* attributeContext = |
|
342 new (ELeave) CGlxAttributeContext(&iter); |
335 CleanupStack::PushL(attributeContext); |
343 CleanupStack::PushL(attributeContext); |
336 attributeContext->AddAttributeL(KMPXMediaGeneralTitle); |
344 attributeContext->AddAttributeL(KMPXMediaGeneralTitle); |
337 aList.AddContextL(attributeContext, KGlxFetchContextPriorityBlocking); |
345 aList.AddContextL(attributeContext, KGlxFetchContextPriorityBlocking); |
338 TGlxFetchContextRemover contextRemover(attributeContext, aList); |
346 TGlxFetchContextRemover contextRemover(attributeContext, aList); |
339 // put to cleanupstack as cleanupstack is emptied before stack objects |
347 // put to cleanupstack as cleanupstack is emptied before stack objects |
340 // are deleted |
348 // are deleted |
341 CleanupClosePushL( contextRemover ); |
349 CleanupClosePushL(contextRemover); |
342 User::LeaveIfError(GlxAttributeRetriever::RetrieveL(*attributeContext, aList, EFalse)); |
350 User::LeaveIfError(GlxAttributeRetriever::RetrieveL(*attributeContext, |
|
351 aList, EFalse)); |
343 // context off the list |
352 // context off the list |
344 CleanupStack::PopAndDestroy( &contextRemover ); |
353 CleanupStack::PopAndDestroy(&contextRemover); |
345 CleanupStack::PopAndDestroy(attributeContext); |
354 CleanupStack::PopAndDestroy(attributeContext); |
346 |
355 |
347 RArray<TInt> numbers; |
356 RArray<TInt> numbers; |
348 CleanupClosePushL(numbers); |
357 CleanupClosePushL(numbers); |
349 |
358 |
350 TInt count = aList.Count(); |
359 TInt count = aList.Count(); |
351 for (TInt i = 0; i < count; i++) |
360 for (TInt i = 0; i < count; i++) |
352 { |
361 { |
353 TGlxMedia item = aList.Item(i); |
362 TGlxMedia item = aList.Item(i); |
354 const CGlxMedia* media = item.Properties(); |
363 const CGlxMedia* media = item.Properties(); |
355 if (media) |
364 if (media) |
356 { |
365 { |
357 const TDesC& title = media->ValueText(KMPXMediaGeneralTitle); |
366 const TDesC& title = media->ValueText(KMPXMediaGeneralTitle); |
358 |
367 |
359 TInt length = aDefaultNewMediaItemTitle.Length(); |
368 TInt length = aDefaultNewMediaItemTitle.Length(); |
360 if (title.Left(length).Compare(aDefaultNewMediaItemTitle) == 0) |
369 if (title.Left(length).Compare(aDefaultNewMediaItemTitle) == 0) |
361 { |
370 { |
362 if (length == title.Length()) |
371 if (length == title.Length()) |
363 { |
372 { |
364 numbers.InsertInOrder(0); // special case |
373 numbers.InsertInOrderL(0); // special case |
365 } |
374 } |
366 else if(title.Length() > length + KOpenBracket().Length() + KCloseBracket().Length()) |
375 else if (title.Length() > length + KOpenBracket().Length() |
|
376 + KCloseBracket().Length()) |
367 { |
377 { |
368 TInt pos = length; |
378 TInt pos = length; |
369 length = KOpenBracket().Length(); |
379 length = KOpenBracket().Length(); |
370 |
380 |
371 if (title.Mid(pos, length).Compare(KOpenBracket) == 0 && |
381 if (title.Mid(pos, length).Compare(KOpenBracket) == 0 |
372 title.Right(KCloseBracket().Length()).Compare(KCloseBracket) == 0) |
382 && title.Right(KCloseBracket().Length()).Compare( |
|
383 KCloseBracket) == 0) |
373 { |
384 { |
374 pos += length; |
385 pos += length; |
375 length = title.Length() - pos - KCloseBracket().Length(); |
386 length = title.Length() - pos |
|
387 - KCloseBracket().Length(); |
376 if (length > 0) |
388 if (length > 0) |
377 { |
389 { |
378 TLex lex = title.Mid(pos, length); |
390 TLex lex = title.Mid(pos, length); |
379 TInt val = 0; |
391 TInt val = 0; |
380 if (lex.Val(val) == KErrNone) |
392 if (lex.Val(val) == KErrNone) |
381 { |
393 { |
382 numbers.InsertInOrder(val); |
394 numbers.InsertInOrderL(val); |
383 } |
395 } |
384 } |
396 } |
385 } |
397 } |
386 } |
398 } |
387 |
399 |
388 } |
400 } |
389 } |
401 } |
390 } |
402 } |
391 |
403 |
392 TInt nextNumber = 0; |
404 TInt nextNumber = 0; |
393 count = numbers.Count(); |
405 count = numbers.Count(); |
394 for (TInt i = 0; i < count; i++) |
406 for (TInt i = 0; i < count; i++) |
395 { |
407 { |
396 if (numbers[i] == nextNumber) |
408 if (numbers[i] == nextNumber) |