185 iNotifier.Notify( 0, |
185 iNotifier.Notify( 0, |
186 RMenuNotifier::EItemsAddedRemoved | |
186 RMenuNotifier::EItemsAddedRemoved | |
187 RMenuNotifier::EItemsReordered | |
187 RMenuNotifier::EItemsReordered | |
188 RMenuNotifier::EItemAttributeChanged, |
188 RMenuNotifier::EItemAttributeChanged, |
189 iNotifyWatcher->iStatus ); |
189 iNotifyWatcher->iStatus ); |
190 |
|
191 iNotifyWatcher->WatchNotify( this ); |
190 iNotifyWatcher->WatchNotify( this ); |
192 } |
191 } |
193 } |
192 } |
194 |
193 |
195 // --------------------------------------------------------------------------- |
194 // --------------------------------------------------------------------------- |
273 // CMCSPluginEngine::ItemIconL |
272 // CMCSPluginEngine::ItemIconL |
274 // Returns MCS default icon if attribute is 'icon' else parses the |
273 // Returns MCS default icon if attribute is 'icon' else parses the |
275 // skin definition from attribute and sets attributes to aMenuItem. |
274 // skin definition from attribute and sets attributes to aMenuItem. |
276 // --------------------------------------------------------------------------- |
275 // --------------------------------------------------------------------------- |
277 // |
276 // |
278 CGulIcon* CMCSPluginEngine::ItemIconL( CMenuItem& aMenuItem, |
277 CGulIcon* CMCSPluginEngine::ItemIconL( CMenuItem* aMenuItem, |
279 const TDesC& aAttr ) |
278 const TDesC& aAttr ) |
280 { |
279 { |
|
280 |
281 CMenuItem* menuItem; |
281 CMenuItem* menuItem; |
282 |
282 |
283 TInt id = aMenuItem.Id(); |
283 // check if item exists in MCS |
284 |
284 if ( aMenuItem ) |
285 // because the flags might have changed, we have |
285 { |
286 // to get a fresh copy of menu item from Menu Server |
286 TInt id = aMenuItem->Id(); |
287 CMenuItem* mi = CMenuItem::OpenL( iMenu, id ); |
287 |
288 TUint32 flags = mi->Flags(); |
288 // because the flags might have changed, we have |
289 delete mi; |
289 // to get a fresh copy of menu item from Menu Server |
290 |
290 CMenuItem* mi = CMenuItem::OpenL( iMenu, id ); |
291 TUint32 isHidden = flags & TMenuItem::EHidden; |
291 TUint32 flags = mi->Flags(); |
292 TUint32 isMissing = flags & TMenuItem::EMissing; |
292 delete mi; |
293 |
293 |
294 if ( iUndefinedItem && ( isHidden || isMissing ) ) |
294 TUint32 isHidden = flags & TMenuItem::EHidden; |
295 { |
295 TUint32 isMissing = flags & TMenuItem::EMissing; |
|
296 |
|
297 if ( iUndefinedItem && ( isHidden || isMissing ) ) |
|
298 { |
|
299 menuItem = iUndefinedItem; |
|
300 } |
|
301 else |
|
302 { |
|
303 menuItem = aMenuItem; |
|
304 } |
|
305 } |
|
306 else |
|
307 { |
|
308 // item not found in MCS. Use Undefined Icon |
296 menuItem = iUndefinedItem; |
309 menuItem = iUndefinedItem; |
297 } |
|
298 else |
|
299 { |
|
300 menuItem = &aMenuItem; |
|
301 } |
310 } |
302 |
311 |
303 CAknIcon* icon( NULL ); |
312 CAknIcon* icon( NULL ); |
304 CGulIcon* gIcon( NULL ); |
313 CGulIcon* gIcon( NULL ); |
305 TBool exists( ETrue ); |
314 TBool exists( ETrue ); |
339 // --------------------------------------------------------------------------- |
348 // --------------------------------------------------------------------------- |
340 // CMCSPluginEngine::ItemTextL |
349 // CMCSPluginEngine::ItemTextL |
341 // Returns text string for the given attribute |
350 // Returns text string for the given attribute |
342 // --------------------------------------------------------------------------- |
351 // --------------------------------------------------------------------------- |
343 // |
352 // |
344 TPtrC CMCSPluginEngine::ItemTextL( CMenuItem& aMenuItem, const TDesC& aAttr ) |
353 TPtrC CMCSPluginEngine::ItemTextL( CMenuItem* aMenuItem, const TDesC& aAttr ) |
345 { |
354 { |
346 // if item is hidden or missing (mmc card removed) |
355 |
347 // use "Undefined" text instead |
|
348 CMenuItem* menuItem; |
356 CMenuItem* menuItem; |
349 |
357 |
350 TInt id = aMenuItem.Id(); |
358 // check if item exists in MCS |
351 |
359 if ( aMenuItem ) |
352 // because the flags might have changed, we have |
360 { |
353 // to get a fresh copy of the menu item from Menu Server |
361 TInt id = aMenuItem->Id(); |
354 CMenuItem* mi = CMenuItem::OpenL( iMenu, id ); |
362 |
355 TUint32 flags = mi->Flags(); |
363 // because the flags might have changed, we have |
356 delete mi; |
364 // to get a fresh copy of the menu item from Menu Server |
357 |
365 CMenuItem* mi = CMenuItem::OpenL( iMenu, id ); |
358 TUint32 isHidden = flags & TMenuItem::EHidden; |
366 TUint32 flags = mi->Flags(); |
359 TUint32 isMissing = flags & TMenuItem::EMissing; |
367 delete mi; |
360 |
368 |
361 if ( iUndefinedItem && ( isHidden || isMissing ) ) |
369 TUint32 isHidden = flags & TMenuItem::EHidden; |
362 { |
370 TUint32 isMissing = flags & TMenuItem::EMissing; |
|
371 |
|
372 // if item is hidden or missing (mmc card removed) |
|
373 // use "Undefined" text instead |
|
374 if ( iUndefinedItem && ( isHidden || isMissing ) ) |
|
375 { |
|
376 menuItem = iUndefinedItem; |
|
377 } |
|
378 else |
|
379 { |
|
380 menuItem = aMenuItem; |
|
381 } |
|
382 } |
|
383 else |
|
384 { |
|
385 // item not found in MCS. Use "Undefined" text |
363 menuItem = iUndefinedItem; |
386 menuItem = iUndefinedItem; |
364 } |
387 } |
365 else |
388 |
366 { |
|
367 menuItem = &aMenuItem; |
|
368 } |
|
369 |
|
370 TBool exists( KErrNotFound ); |
389 TBool exists( KErrNotFound ); |
371 |
390 |
372 TPtrC name( menuItem->GetAttributeL( aAttr, exists ) ); |
391 TPtrC name( menuItem->GetAttributeL( aAttr, exists ) ); |
373 |
392 |
374 if ( exists ) |
393 if ( exists ) |
391 HBufC* temp = StringLoader::LoadLC( R_MCS_DISABLE_OPEN_ITEM ); |
410 HBufC* temp = StringLoader::LoadLC( R_MCS_DISABLE_OPEN_ITEM ); |
392 |
411 |
393 CAknNoteDialog* dialog = new (ELeave) CAknNoteDialog( |
412 CAknNoteDialog* dialog = new (ELeave) CAknNoteDialog( |
394 CAknNoteDialog::EConfirmationTone, |
413 CAknNoteDialog::EConfirmationTone, |
395 CAknNoteDialog::ENoTimeout ); |
414 CAknNoteDialog::ENoTimeout ); |
|
415 CleanupStack::PushL( dialog ); |
396 dialog->SetTextL( temp->Des() ); |
416 dialog->SetTextL( temp->Des() ); |
397 dialog->ExecuteDlgLD( R_MCS_DISABLE_OPEN_ITEM_DLG ); |
417 dialog->ExecuteDlgLD( R_MCS_DISABLE_OPEN_ITEM_DLG ); |
398 |
418 CleanupStack::Pop( dialog ); |
399 CleanupStack::PopAndDestroy( temp ); |
419 CleanupStack::PopAndDestroy( temp ); |
400 return; |
420 return; |
401 } |
421 } |
402 |
422 |
403 if( iWatcher->IsActive()) |
423 if( iWatcher->IsActive()) |
405 return; |
425 return; |
406 } |
426 } |
407 |
427 |
408 TMCSData& dataItem( iPluginData->DataItemL( aIndex ) ); |
428 TMCSData& dataItem( iPluginData->DataItemL( aIndex ) ); |
409 |
429 |
410 CMenuItem* item( CMenuItem::OpenL( iMenu, dataItem.MenuItem().Id() ) ); |
430 CMenuItem* item = NULL; |
|
431 TRAP_IGNORE( item = CMenuItem::OpenL( iMenu, dataItem.MenuItem().Id() ) ); |
|
432 |
|
433 // item does not exist at all in MCS |
|
434 if ( item == NULL ) |
|
435 { |
|
436 HBufC* temp = StringLoader::LoadLC( R_MCS_DISABLE_OPEN_ITEM_MISSING ); |
|
437 |
|
438 CAknNoteDialog* dialog = new (ELeave) CAknNoteDialog( |
|
439 CAknNoteDialog::EConfirmationTone, |
|
440 CAknNoteDialog::ENoTimeout ); |
|
441 CleanupStack::PushL( dialog ); |
|
442 dialog->SetTextL( temp->Des() ); |
|
443 dialog->ExecuteDlgLD( R_MCS_DISABLE_OPEN_ITEM_DLG ); |
|
444 CleanupStack::Pop( dialog ); |
|
445 CleanupStack::PopAndDestroy( temp ); |
|
446 temp = NULL; |
|
447 |
|
448 return; |
|
449 } |
|
450 |
411 CleanupStack::PushL( item ); |
451 CleanupStack::PushL( item ); |
412 |
|
413 |
452 |
414 TBool attrExists = ETrue; |
453 TBool attrExists = ETrue; |
415 |
454 |
416 TPtrC uid = item->GetAttributeL( KMenuAttrUid, attrExists ); |
455 TPtrC uid = item->GetAttributeL( KMenuAttrUid, attrExists ); |
417 |
456 |
418 // trying to run non-existing application ( that was replaced by "Undefined" app ) |
457 // trying to run hidden or missing application (e.g. unistalled app |
419 // OR trying to run hidden or missing application (e.g. unistalled app |
|
420 // or app on MMC which was removed ) |
458 // or app on MMC which was removed ) |
421 // -> We display a note for a user that this is not possible¨ |
459 // -> We display a note for a user that this is not possible¨ |
422 TUint32 isHidden = item->Flags() & TMenuItem::EHidden; |
460 TUint32 isHidden = item->Flags() & TMenuItem::EHidden; |
423 TUint32 isMissing = item->Flags() & TMenuItem::EMissing; |
461 TUint32 isMissing = item->Flags() & TMenuItem::EMissing; |
424 |
462 |
429 HBufC* temp = StringLoader::LoadLC( R_MCS_DISABLE_OPEN_ITEM_MISSING ); |
467 HBufC* temp = StringLoader::LoadLC( R_MCS_DISABLE_OPEN_ITEM_MISSING ); |
430 |
468 |
431 CAknNoteDialog* dialog = new (ELeave) CAknNoteDialog( |
469 CAknNoteDialog* dialog = new (ELeave) CAknNoteDialog( |
432 CAknNoteDialog::EConfirmationTone, |
470 CAknNoteDialog::EConfirmationTone, |
433 CAknNoteDialog::ENoTimeout ); |
471 CAknNoteDialog::ENoTimeout ); |
|
472 CleanupStack::PushL( dialog ); |
434 dialog->SetTextL( temp->Des() ); |
473 dialog->SetTextL( temp->Des() ); |
435 dialog->ExecuteDlgLD( R_MCS_DISABLE_OPEN_ITEM_DLG ); |
474 dialog->ExecuteDlgLD( R_MCS_DISABLE_OPEN_ITEM_DLG ); |
|
475 CleanupStack::Pop( dialog ); |
436 CleanupStack::PopAndDestroy( temp ); |
476 CleanupStack::PopAndDestroy( temp ); |
437 temp = NULL; |
477 temp = NULL; |
438 |
478 |
439 return; |
479 return; |
440 } |
480 } |
565 { |
605 { |
566 TInt count( iPluginData->DataCount() ); |
606 TInt count( iPluginData->DataCount() ); |
567 |
607 |
568 for ( TInt i = 0; i < count; i++ ) |
608 for ( TInt i = 0; i < count; i++ ) |
569 { |
609 { |
570 TMCSData& data( iPluginData->DataItemL(i) ); |
610 TMCSData& data( iPluginData->DataItemL( i ) ); |
571 data.SetDirty( ETrue ); |
611 data.SetDirty( ETrue ); |
572 |
|
573 // Check that all the data still exist is MCS, if flag is hidden or |
|
574 // missing, we have to remove data from UI |
|
575 CMenuItem* menuItem = NULL; |
|
576 |
|
577 TRAP_IGNORE ( |
|
578 menuItem = CMenuItem::OpenL( iMenu, data.MenuItem().Id() ); |
|
579 ) |
|
580 |
|
581 // item not found. Use "Undefined" item as a replacement |
|
582 if ( !menuItem ) |
|
583 { |
|
584 CleanupStack::PushL( menuItem ); |
|
585 iPluginData->ReplaceMenuItemL( i, iUndefinedItemHeader ); |
|
586 iPluginData->SaveSettingsL( i, *iUndefinedItem ); |
|
587 CleanupStack::Pop( menuItem ); |
|
588 } |
|
589 |
|
590 delete menuItem; |
|
591 menuItem = NULL; |
|
592 } |
612 } |
593 |
613 |
594 // Notification must be activated again |
614 // Notification must be activated again |
595 iNotifyWatcher->Cancel(); |
615 iNotifyWatcher->Cancel(); |
596 |
616 |
835 |
855 |
836 // --------------------------------------------------------------------------- |
856 // --------------------------------------------------------------------------- |
837 // Creates bookmark menu item if it does not exist |
857 // Creates bookmark menu item if it does not exist |
838 // --------------------------------------------------------------------------- |
858 // --------------------------------------------------------------------------- |
839 // |
859 // |
840 void CMCSPluginEngine::CreateBkmMenuItemsL() |
860 void CMCSPluginEngine::CreateRuntimeMenuItemsL() |
841 { |
861 { |
842 iPluginData->CreateBkmMenuItemsL(); |
862 iPluginData->CreateRuntimeMenuItemsL(); |
843 } |
863 } |
844 |
864 |
845 // End of file |
865 // End of file |
846 |
866 |