216 |
288 |
217 // --------------------------------------------------------------------------- |
289 // --------------------------------------------------------------------------- |
218 // Gets the menu item from engine using the setting properties as filter |
290 // Gets the menu item from engine using the setting properties as filter |
219 // --------------------------------------------------------------------------- |
291 // --------------------------------------------------------------------------- |
220 // |
292 // |
221 TMenuItem CMCSPluginData::CreateMenuItemL( RPointerArray<HSPluginSettingsIf::CPropertyMap>& aProperties ) |
293 CMCSData* CMCSPluginData::GetMenuDataL( RPointerArray<HSPluginSettingsIf::CPropertyMap>& aProperties ) |
|
294 { |
|
295 TPtrC8 type; |
|
296 TPtrC8 uid; |
|
297 TPtrC8 view; |
|
298 TPtrC8 param; |
|
299 |
|
300 // first we need to check the item type |
|
301 for ( TInt i = 0; i < aProperties.Count(); i++ ) |
|
302 { |
|
303 if ( aProperties[i]->Name() == KProperNameType ) |
|
304 { |
|
305 type.Set( aProperties[i]->Value()); |
|
306 } |
|
307 else if( aProperties[i]->Name() == KProperNameUid) |
|
308 { |
|
309 uid.Set( aProperties[i]->Value()); |
|
310 } |
|
311 else if( aProperties[i]->Name() == KProperNameView) |
|
312 { |
|
313 view.Set( aProperties[i]->Value()); |
|
314 } |
|
315 else if( aProperties[i]->Name() == KProperNameParam ) |
|
316 { |
|
317 param.Set( aProperties[i]->Value()); |
|
318 } |
|
319 } |
|
320 CMCSData* data = new ( ELeave ) CMCSData(); |
|
321 CleanupStack::PushL( data ); |
|
322 if( type == KProperValueBookmark ) |
|
323 { |
|
324 GetBkmDataL( view, param, *data ); |
|
325 } |
|
326 else if( type == KProperValueFolder ) |
|
327 { |
|
328 GetFolderData( param, *data ); |
|
329 } |
|
330 else if( type == KProperValueMailbox ) |
|
331 { |
|
332 GetMailboxDataL( uid, param, *data ); |
|
333 } |
|
334 else |
|
335 { |
|
336 GetMCSDataL( aProperties, *data ); |
|
337 } |
|
338 CleanupStack::Pop( data ); |
|
339 return data; |
|
340 } |
|
341 |
|
342 // --------------------------------------------------------------------------- |
|
343 // Creates bookmark data item. |
|
344 // --------------------------------------------------------------------------- |
|
345 // |
|
346 void CMCSPluginData::GetBkmDataL( const TDesC8& aView, const TDesC8& aParam, CMCSData& aData ) |
|
347 { |
|
348 TMenuItem item; |
|
349 item.SetType( KMenuTypeUrl ); |
|
350 aData.SetMenuItem( item ); |
|
351 |
|
352 HBufC* view( NULL ); |
|
353 view = AiUtility::CopyToBufferL( view, aView ); |
|
354 CleanupStack::PushL( view ); |
|
355 aData.SetValueL( *view ); |
|
356 CleanupStack::PopAndDestroy( view ); |
|
357 |
|
358 HBufC* param( NULL ); |
|
359 param = AiUtility::CopyToBufferL( param, aParam ); |
|
360 CleanupStack::PushL( param ); |
|
361 aData.SetNameL( *param ); |
|
362 CleanupStack::PopAndDestroy( param ); |
|
363 } |
|
364 |
|
365 // --------------------------------------------------------------------------- |
|
366 // Creates folder data item. |
|
367 // --------------------------------------------------------------------------- |
|
368 // |
|
369 void CMCSPluginData::GetFolderData( const TDesC8& aParam, CMCSData& aData ) |
|
370 { |
|
371 // In folder case, we have to extract id from |
|
372 // param attribute and return item with this id |
|
373 // convert id to integer |
|
374 TInt id; |
|
375 TLex8 lextmp( aParam); |
|
376 lextmp.Val( id ); |
|
377 |
|
378 TMenuItem item; |
|
379 item.SetType( KMenuTypeFolder ); |
|
380 item.SetId( id ); |
|
381 aData.SetMenuItem( item ); |
|
382 } |
|
383 |
|
384 // --------------------------------------------------------------------------- |
|
385 // Creates mailbox data item. |
|
386 // --------------------------------------------------------------------------- |
|
387 // |
|
388 void CMCSPluginData::GetMailboxDataL( const TDesC8& aUid, const TDesC8& aParam, CMCSData& aData ) |
|
389 { |
|
390 TInt id( KErrNotFound ); |
|
391 TLex8 lextmp( aUid); |
|
392 lextmp.Val( id ); |
|
393 |
|
394 TMenuItem item; |
|
395 item.SetType( KMenuTypeMailbox ); |
|
396 item.SetId( id ); |
|
397 aData.SetMenuItem( item ); |
|
398 |
|
399 HBufC* param( NULL ); |
|
400 param = AiUtility::CopyToBufferL( param, aParam ); |
|
401 CleanupStack::PushL( param ); |
|
402 |
|
403 aData.SetNameL( *param ); |
|
404 |
|
405 CleanupStack::PopAndDestroy( param ); |
|
406 } |
|
407 |
|
408 // --------------------------------------------------------------------------- |
|
409 // Gets data item from MCS |
|
410 // --------------------------------------------------------------------------- |
|
411 // |
|
412 void CMCSPluginData::GetMCSDataL( RPointerArray<HSPluginSettingsIf::CPropertyMap>& aProperties, |
|
413 CMCSData& aData) |
222 { |
414 { |
223 CMenuFilter* filter = CMenuFilter::NewLC(); |
415 CMenuFilter* filter = CMenuFilter::NewLC(); |
224 |
416 |
225 // Exclude 'view' and 'param' attributes from search criteria by default |
417 // Exclude 'view' and 'param' attributes from search criteria by default |
226 // Criterias will be added to filter if setting defines them |
418 // Criterias will be added to filter if setting defines them |
227 filter->DoNotHaveAttributeL( KMenuAttrView ); |
419 filter->DoNotHaveAttributeL( KMenuAttrView ); |
228 filter->DoNotHaveAttributeL( KMenuAttrParam ); |
420 filter->DoNotHaveAttributeL( KMenuAttrParam ); |
229 TBool isFolder = EFalse; |
421 |
230 |
|
231 // first, we need to check if the item is folder |
|
232 for ( TInt i = 0; i < aProperties.Count(); i++ ) |
|
233 { |
|
234 if ( aProperties[i]->Name() == KProperNameType ) |
|
235 { |
|
236 if ( aProperties[i]->Value() == KProperValueFolder ) |
|
237 { |
|
238 isFolder = ETrue; |
|
239 } |
|
240 break; |
|
241 } |
|
242 } |
|
243 |
|
244 // then add all property/value pairs to the filter |
422 // then add all property/value pairs to the filter |
245 for ( TInt i = 0; i < aProperties.Count(); i++ ) |
423 for ( TInt i = 0; i < aProperties.Count(); i++ ) |
246 { |
424 { |
247 |
|
248 // skip the type property |
425 // skip the type property |
249 if( aProperties[i]->Name() == KProperNameType ) |
426 if( aProperties[i]->Name() == KProperNameType ) |
250 { |
427 { |
251 continue; |
428 continue; |
252 } |
429 } |
258 value = AiUtility::CopyToBufferL( value, aProperties[i]->Value() ); |
435 value = AiUtility::CopyToBufferL( value, aProperties[i]->Value() ); |
259 CleanupStack::PushL( value ); |
436 CleanupStack::PushL( value ); |
260 |
437 |
261 if ( value->Length() != 0 ) |
438 if ( value->Length() != 0 ) |
262 { |
439 { |
263 // in case of folder, we just have to extract |
440 filter->HaveAttributeL( *name, *value ); |
264 // id from param attribute and return item with this id |
|
265 if ( aProperties[i]->Name() == KProperNameParam && isFolder ) |
|
266 { |
|
267 TMenuItem item; |
|
268 // convert id to integer |
|
269 TInt id; |
|
270 TLex16 lextmp( value->Ptr() ); |
|
271 lextmp.Val( id ); |
|
272 item.SetType( KMenuTypeFolder ); |
|
273 item.SetId( id ); |
|
274 |
|
275 CleanupStack::PopAndDestroy( value ); |
|
276 CleanupStack::PopAndDestroy( name ); |
|
277 CleanupStack::PopAndDestroy( filter ); |
|
278 |
|
279 return item; |
|
280 } |
|
281 else |
|
282 { |
|
283 // otherwise, we just add name/value into filter |
|
284 filter->HaveAttributeL( *name, *value ); |
|
285 } |
|
286 } |
441 } |
287 CleanupStack::PopAndDestroy( value ); |
442 CleanupStack::PopAndDestroy( value ); |
288 CleanupStack::PopAndDestroy( name ); |
443 CleanupStack::PopAndDestroy( name ); |
289 } |
444 } |
290 |
445 |
291 // locked property excluded from search pattern |
446 // locked property excluded from search pattern |
292 filter->DoNotHaveAttributeL( KMenuAttrLocked ); |
447 filter->DoNotHaveAttributeL( KMenuAttrLocked ); |
293 |
448 |
294 TMenuItem item = iEngine.FindMenuItemL( *filter ); |
449 TMenuItem item = iEngine.FindMenuItemL( *filter ); |
295 CleanupStack::PopAndDestroy( filter ); |
450 CleanupStack::PopAndDestroy( filter ); |
296 return item; |
451 aData.SetMenuItem( item ); |
297 } |
452 } |
298 |
453 |
299 // --------------------------------------------------------------------------- |
454 // --------------------------------------------------------------------------- |
300 // Returns menu item for given index |
455 // Returns menu item for given index |
301 // --------------------------------------------------------------------------- |
456 // --------------------------------------------------------------------------- |
302 // |
457 // |
303 TMCSData& CMCSPluginData::DataItemL( TInt aIndex ) |
458 CMCSData& CMCSPluginData::DataItemL( TInt aIndex ) |
304 { |
459 { |
305 if( aIndex < 0 || aIndex >= iData.Count()) |
460 if( aIndex < 0 || aIndex >= iData.Count()) |
306 { |
461 { |
307 User::Leave( KErrArgument ); |
462 User::Leave( KErrArgument ); |
308 } |
463 } |
309 return iData[aIndex]; |
464 return *iData[aIndex]; |
310 } |
465 } |
311 |
466 |
312 // --------------------------------------------------------------------------- |
467 // --------------------------------------------------------------------------- |
313 // Replaces menuitem in data instance |
468 // Save the undefined item. |
314 // --------------------------------------------------------------------------- |
469 // --------------------------------------------------------------------------- |
315 // |
470 // |
316 void CMCSPluginData::ReplaceMenuItemL( const TInt& aIndex, TMenuItem& aMenuItem ) |
471 void CMCSPluginData::SaveUndefinedItemL( const TInt& aIndex ) |
317 { |
|
318 TMCSData& data = iData[aIndex]; |
|
319 data.SetMenuItem( aMenuItem ); |
|
320 data.SetDirty( ETrue ); |
|
321 } |
|
322 |
|
323 // --------------------------------------------------------------------------- |
|
324 // Save the setting persistently to HSPS |
|
325 // TODO HSPS setting api should be changed so that items and properties can |
|
326 // be added/removed dynamically. Now widgetconfiguration.xml must have all the |
|
327 // properties for every item even though property is not used. |
|
328 // It makes this function more compolicated. |
|
329 // --------------------------------------------------------------------------- |
|
330 // |
|
331 void CMCSPluginData::SaveSettingsL( const TInt& aIndex, CMenuItem& aMenuItem ) |
|
332 { |
472 { |
333 RPointerArray<CItemMap> settingItems; |
473 RPointerArray<CItemMap> settingItems; |
334 CleanupClosePushL( settingItems ); |
474 CleanupClosePushL( settingItems ); |
335 iPluginSettings->GetSettingsL( iInstanceUid, settingItems ); |
475 iPluginSettings->GetSettingsL( iInstanceUid, settingItems ); |
336 if ( aIndex >= 0 && aIndex < settingItems.Count() ) |
476 if ( aIndex >= 0 && aIndex < settingItems.Count() ) |
337 { |
477 { |
338 TBool exists( EFalse ); |
478 CItemMap* itemMap = settingItems[ aIndex ]; |
339 CItemMap* itemMap = settingItems[aIndex]; |
|
340 RPointerArray<HSPluginSettingsIf::CPropertyMap> properties; |
479 RPointerArray<HSPluginSettingsIf::CPropertyMap> properties; |
341 properties = itemMap->Properties(); |
480 properties = itemMap->Properties(); |
342 for ( TInt i= 0; i < properties.Count(); i++ ) |
481 for ( TInt i = 0; i < properties.Count(); i++ ) |
343 { |
482 { |
344 if ( properties[i]->Name() == KProperNameType ) |
483 if ( properties[ i ]->Name() == KProperNameType ) |
345 { |
484 { |
346 TPtrC type = aMenuItem.Type(); |
485 properties[ i ]->SetValueL( KProperValueAppl ); |
347 if ( type == KMenuTypeUrl ) |
|
348 { |
|
349 properties[i]->SetValueL( KProperValueBookmark ); |
|
350 } |
|
351 else |
|
352 { |
|
353 properties[i]->SetValueL( KProperValueAppl ); |
|
354 } |
|
355 } |
486 } |
356 else if ( properties[i]->Name() == KProperNameUid ) |
487 else if ( properties[ i ]->Name() == KProperNameUid ) |
357 { |
488 { |
358 TPtrC uid = aMenuItem.GetAttributeL( KMenuAttrUid, exists ); |
489 properties[ i ]->SetValueL( KMenuAttrUndefUid ); |
359 if ( exists ) |
|
360 { |
|
361 HBufC8* uid8( NULL ); |
|
362 uid8 = AiUtility::CopyToBufferL( uid8, uid ); |
|
363 CleanupStack::PushL( uid8 ); |
|
364 properties[i]->SetValueL( *uid8 ); |
|
365 CleanupStack::PopAndDestroy( uid8 ); |
|
366 } |
|
367 else |
|
368 { |
|
369 properties[i]->SetValueL( KNullDesC8 ); |
|
370 } |
|
371 } |
490 } |
372 else if ( properties[i]->Name() == KProperNameView ) |
491 else if ( properties[ i ]->Name() == KProperNameView ) |
373 { |
492 { |
374 TPtrC view = aMenuItem.GetAttributeL( KMenuAttrView, exists ); |
493 properties[ i ]->SetValueL( KNullDesC8 ); |
375 if ( exists ) |
|
376 { |
|
377 HBufC8* view8( NULL ); |
|
378 view8 = AiUtility::CopyToBufferL( view8, view ); |
|
379 CleanupStack::PushL( view8 ); |
|
380 properties[i]->SetValueL( *view8 ); |
|
381 CleanupStack::PopAndDestroy( view8 ); |
|
382 } |
|
383 else |
|
384 { |
|
385 properties[i]->SetValueL( KNullDesC8 ); |
|
386 } |
|
387 } |
494 } |
388 else if ( properties[i]->Name() == KProperNameParam ) |
495 else if ( properties[ i ]->Name() == KProperNameParam ) |
389 { |
496 { |
390 TPtrC param = aMenuItem.GetAttributeL( KMenuAttrParam, exists ); |
497 properties[ i ]->SetValueL( KNullDesC8 ); |
391 if ( exists ) |
|
392 { |
|
393 HBufC8* param8( NULL ); |
|
394 param8 = AiUtility::CopyToBufferL( param8, param ); |
|
395 CleanupStack::PushL( param8 ); |
|
396 properties[i]->SetValueL( *param8 ); |
|
397 CleanupStack::PopAndDestroy( param8 ); |
|
398 } |
|
399 else |
|
400 { |
|
401 properties[i]->SetValueL( KNullDesC8 ); |
|
402 } |
|
403 } |
498 } |
404 } |
499 else if ( properties[ i ]->Name() == KProperNameLocked ) |
405 } |
500 { |
406 // ETrue tells that changes are stored also to plugin reference |
501 properties[i]->SetValueL( KNullDesC8 ); |
|
502 } |
|
503 } |
|
504 } |
|
505 // ETrue tells that modified settings are stored also to plugin reference |
407 iPluginSettings->SetSettingsL( iInstanceUid, settingItems, ETrue ); |
506 iPluginSettings->SetSettingsL( iInstanceUid, settingItems, ETrue ); |
408 CleanupStack::PopAndDestroy( &settingItems ); |
507 CleanupStack::Pop( &settingItems ); |
409 } |
508 settingItems.ResetAndDestroy(); |
410 |
509 |
411 // --------------------------------------------------------------------------- |
510 } |
412 // Gets MCS Plugin folder ID. This hidden folder in matrixmenudata.xml is used |
511 |
413 // for storing run-time generated menuitems |
512 // End of file |
414 // --------------------------------------------------------------------------- |
|
415 // |
|
416 TInt CMCSPluginData::GetMCSPluginFolderIdL() |
|
417 { |
|
418 TInt folderId; |
|
419 |
|
420 _LIT( KMCSFolder, "mcsplugin_folder" ); |
|
421 |
|
422 CMenuItem* item( NULL ); |
|
423 CMenuFilter* filter = CMenuFilter::NewL(); |
|
424 CleanupStack::PushL( filter ); |
|
425 filter->SetType( KMenuTypeFolder ); |
|
426 filter->HaveAttributeL( KMenuAttrLongName, KMCSFolder ); |
|
427 |
|
428 const TInt rootId = iMenu.RootFolderL(); |
|
429 RArray<TMenuItem> itemArray; |
|
430 CleanupClosePushL( itemArray ); |
|
431 iMenu.GetItemsL( itemArray, rootId, filter, ETrue ); |
|
432 if ( itemArray.Count() > 0 ) |
|
433 { |
|
434 item = CMenuItem::OpenL( iMenu, itemArray[0] ); |
|
435 folderId = item->Id(); |
|
436 } |
|
437 else |
|
438 { |
|
439 folderId = iMenu.RootFolderL(); |
|
440 } |
|
441 CleanupStack::PopAndDestroy( &itemArray ); |
|
442 CleanupStack::PopAndDestroy( filter ); |
|
443 |
|
444 delete item; |
|
445 |
|
446 return folderId; |
|
447 } |
|
448 |
|
449 // --------------------------------------------------------------------------- |
|
450 // Creates runtime generated menuitems (bookmarks/mailboxes if they |
|
451 // it does not exist yet in MCS. If they do, their ref_count is incremented. |
|
452 // Called during Plugin startup. |
|
453 // --------------------------------------------------------------------------- |
|
454 // |
|
455 void CMCSPluginData::CreateRuntimeMenuItemsL() |
|
456 { |
|
457 |
|
458 // start mailboxes observing and get the number of |
|
459 // mailboxes defined in the device |
|
460 |
|
461 TMsvId entryID = KMsvRootIndexEntryIdValue; |
|
462 CMsvEntry* rootEntry = iMsvSession->GetEntryL( entryID ); |
|
463 TInt mailboxCount = rootEntry->Count(); |
|
464 CleanupStack::PushL( rootEntry ); |
|
465 |
|
466 RPointerArray<CItemMap> settings; |
|
467 TCleanupItem settingsCleanupItem( ItemMapArrayCleanupFunc, &settings ); |
|
468 CleanupStack::PushL( settingsCleanupItem ); |
|
469 iPluginSettings->GetSettingsL( iInstanceUid, settings ); |
|
470 |
|
471 RFavouritesSession bookmarkSess; |
|
472 RFavouritesDb bookmarkDb; |
|
473 |
|
474 User::LeaveIfError( bookmarkSess.Connect() ); |
|
475 User::LeaveIfError( bookmarkDb.Open( bookmarkSess, KBrowserBookmarks )); |
|
476 |
|
477 TInt count = settings.Count(); |
|
478 for( TInt i = 0; i < count; i++ ) |
|
479 { |
|
480 CItemMap* itemMap = settings[i]; |
|
481 RPointerArray<HSPluginSettingsIf::CPropertyMap>& properties |
|
482 = itemMap->Properties(); |
|
483 |
|
484 TPtrC8 uid8, type, param8; |
|
485 |
|
486 for( TInt j = 0; j < properties.Count(); j++ ) |
|
487 { |
|
488 |
|
489 if( properties[j]->Name() == KProperNameType ) |
|
490 { |
|
491 type.Set( properties[j]->Value() ); |
|
492 } |
|
493 else if ( properties[j]->Name() == KProperNameUid ) |
|
494 { |
|
495 uid8.Set( properties[j]->Value() ); |
|
496 } |
|
497 else if ( properties[j]->Name() == KProperNameParam ) |
|
498 { |
|
499 param8.Set( properties[j]->Value() ); |
|
500 } |
|
501 } |
|
502 |
|
503 if( type == KProperValueBookmark ) |
|
504 { |
|
505 |
|
506 // The shortcut is a bookmark |
|
507 TMenuItem menuItem = CreateMenuItemL( properties ); |
|
508 |
|
509 CActiveSchedulerWait* wait = |
|
510 new ( ELeave ) CActiveSchedulerWait; |
|
511 CleanupStack::PushL( wait ); |
|
512 |
|
513 if( menuItem.Id() == 0 ) |
|
514 { |
|
515 TLex8 uidLex( uid8.Mid( 1, uid8.Length() - 2 ) ); |
|
516 TUint32 id; |
|
517 uidLex.Val(id, EHex); |
|
518 |
|
519 CFavouritesItem* bkmItem = CFavouritesItem::NewLC(); |
|
520 TInt bcount = bookmarkDb.Get( TInt32( id ), *bkmItem ); |
|
521 |
|
522 HBufC *uid( NULL ); |
|
523 uid = AiUtility::CopyToBufferL( uid, uid8 ); |
|
524 CleanupStack::PushL( uid ); |
|
525 |
|
526 CMenuItem* newItem = CMenuItem::CreateL( iMenu, |
|
527 KMenuTypeUrl, |
|
528 GetMCSPluginFolderIdL(), |
|
529 0 ); |
|
530 CleanupStack::PushL( newItem ); |
|
531 |
|
532 newItem->SetAttributeL( KMenuAttrUid, *uid ); |
|
533 newItem->SetAttributeL( KMenuAttrLongName, bkmItem->Name() ); |
|
534 newItem->SetAttributeL( KMenuAttrIconFile, KMenuIconFile ); |
|
535 newItem->SetAttributeL( KMenuAttrIconId, KMenuBookmarkIconId ); |
|
536 newItem->SetAttributeL( KMenuAttrMaskId, KMenuBookmarkMaskId ); |
|
537 newItem->SetAttributeL( KMenuAttrRefcount, KInitialRefCount ); |
|
538 newItem->SetAttributeL( KUrl , bkmItem->Url() ); |
|
539 |
|
540 CMenuOperation* op = newItem->SaveL( iSaveWatcher->iStatus ); |
|
541 |
|
542 iSaveWatcher->StopAndWatch( op, wait ); |
|
543 |
|
544 // Start the nested scheduler loop. |
|
545 wait->Start(); |
|
546 |
|
547 SaveSettingsL( i, *newItem ); |
|
548 |
|
549 CleanupStack::PopAndDestroy( newItem ); |
|
550 CleanupStack::PopAndDestroy( uid ); |
|
551 CleanupStack::PopAndDestroy( bkmItem ); |
|
552 } |
|
553 else |
|
554 { |
|
555 CMenuItem* item = CMenuItem::OpenL( iMenu, menuItem ); |
|
556 CleanupStack::PushL( item ); |
|
557 if ( iEngine.UpdateMenuItemsRefCountL( item, 1 ) > 0 ) |
|
558 { |
|
559 CMenuOperation* op = item->SaveL( iSaveWatcher->iStatus ); |
|
560 iSaveWatcher->StopAndWatch( op, wait ); |
|
561 // Start the nested scheduler loop. |
|
562 wait->Start(); |
|
563 SaveSettingsL( i, *item ); |
|
564 } |
|
565 CleanupStack::PopAndDestroy( item ); |
|
566 } |
|
567 |
|
568 CleanupStack::PopAndDestroy( wait ); |
|
569 wait = NULL; |
|
570 } |
|
571 |
|
572 else if ( uid8 == KMailboxUid8 && mailboxCount > 0 ) |
|
573 { |
|
574 // The shortcut is a Mailbox |
|
575 |
|
576 TMenuItem menuItem = CreateMenuItemL( properties ); |
|
577 |
|
578 CActiveSchedulerWait* wait = |
|
579 new ( ELeave ) CActiveSchedulerWait; |
|
580 CleanupStack::PushL( wait ); |
|
581 |
|
582 if ( menuItem.Id() == 0 ) |
|
583 { |
|
584 // mailbox menuitem does not exist yet. We have to create it |
|
585 // first, we try to find its ID among existing mailboxes:bì |
|
586 |
|
587 // extract Mailbox ID from HSPS |
|
588 TInt pos = param8.Locate( TChar( ':' ) ) + 1; |
|
589 TPtrC8 mailboxId8 = param8.Mid( pos ); |
|
590 |
|
591 HBufC *mailboxId( NULL ); |
|
592 mailboxId = AiUtility::CopyToBufferL( mailboxId, mailboxId8 ); |
|
593 CleanupStack::PushL( mailboxId ); |
|
594 |
|
595 // compare ID with existing mailboxes |
|
596 rootEntry->SetSortTypeL( TMsvSelectionOrdering( |
|
597 KMsvGroupByType | KMsvGroupByStandardFolders, |
|
598 EMsvSortByDetailsReverse, ETrue ) ); |
|
599 |
|
600 TBuf<255> boxId; |
|
601 TBool found = EFalse; |
|
602 TInt index = rootEntry->Count(); |
|
603 |
|
604 while ( !found && --index >= 0 ) |
|
605 { |
|
606 const TMsvEntry& tentry = ( *rootEntry )[ index ]; |
|
607 if ( tentry.iMtm.iUid == KMCSCmailMtmUidValue ) |
|
608 { |
|
609 boxId.Num( tentry.Id() ); |
|
610 if ( boxId == *mailboxId ) |
|
611 { |
|
612 found = ETrue; |
|
613 } |
|
614 } |
|
615 } |
|
616 |
|
617 CleanupStack::PopAndDestroy( mailboxId ); |
|
618 |
|
619 // mailbox still exists in Mail application |
|
620 // we have to create a new menuitem |
|
621 if ( found ) |
|
622 { |
|
623 |
|
624 // get the mailbox name |
|
625 const TMsvEntry& tentry = ( *rootEntry )[ index ]; |
|
626 TPtrC name = tentry.iDetails; |
|
627 |
|
628 HBufC *param( NULL ); |
|
629 param = AiUtility::CopyToBufferL( param, param8 ); |
|
630 CleanupStack::PushL( param ); |
|
631 |
|
632 // create a new menuitem with ref_count 1 |
|
633 CMenuItem* newItem = CMenuItem::CreateL( iMenu, |
|
634 KMenuTypeShortcut, |
|
635 GetMCSPluginFolderIdL(), |
|
636 0 ); |
|
637 CleanupStack::PushL( newItem ); |
|
638 |
|
639 // mailbox is a shortcut item with "mailbox:mailboxID" parameter |
|
640 newItem->SetAttributeL( KMenuAttrUid, KMailboxUid ); |
|
641 newItem->SetAttributeL( KMenuAttrLongName, name ); |
|
642 newItem->SetAttributeL( KMenuAttrParameter, *param ); |
|
643 newItem->SetAttributeL( KMenuAttrRefcount, KInitialRefCount ); |
|
644 |
|
645 // setting icon for the shortcut |
|
646 newItem->SetAttributeL( KMenuAttrIconFile, KMenuIconFile ); |
|
647 newItem->SetAttributeL( KMenuAttrIconId, KMenuMailboxIconId ); |
|
648 newItem->SetAttributeL( KMenuAttrMaskId, KMenuMailboxMaskId ); |
|
649 |
|
650 CMenuOperation* op = newItem->SaveL( iSaveWatcher->iStatus ); |
|
651 iSaveWatcher->StopAndWatch( op, wait ); |
|
652 |
|
653 // Start the nested scheduler loop. |
|
654 wait->Start(); |
|
655 |
|
656 SaveSettingsL( i, *newItem ); |
|
657 |
|
658 CleanupStack::PopAndDestroy( newItem ); |
|
659 CleanupStack::PopAndDestroy( param ); |
|
660 } |
|
661 } |
|
662 else |
|
663 { |
|
664 // mailbox menu item already exists -> increment ref_count by 1 |
|
665 CMenuItem* item = CMenuItem::OpenL( iMenu, menuItem ); |
|
666 CleanupStack::PushL( item ); |
|
667 if ( iEngine.UpdateMenuItemsRefCountL( item, 1 ) > 0 ) |
|
668 { |
|
669 CMenuOperation* op = item->SaveL( iSaveWatcher->iStatus ); |
|
670 iSaveWatcher->StopAndWatch( op, wait ); |
|
671 |
|
672 // Start the nested scheduler loop. |
|
673 wait->Start(); |
|
674 SaveSettingsL( i, *item ); |
|
675 } |
|
676 CleanupStack::PopAndDestroy( item ); |
|
677 } |
|
678 CleanupStack::PopAndDestroy( wait ); |
|
679 wait = NULL; |
|
680 |
|
681 } |
|
682 } |
|
683 CleanupStack::PopAndDestroy(); // settingsCleanupItem |
|
684 CleanupStack::PopAndDestroy( rootEntry ); |
|
685 } |
|
686 |
|
687 // --------------------------------------------------------------------------- |
|
688 // From class MMsvSessionObserver. |
|
689 // Handles an event from the message server. |
|
690 // --------------------------------------------------------------------------- |
|
691 // |
|
692 void CMCSPluginData::HandleSessionEventL( |
|
693 TMsvSessionEvent /*aEvent*/, |
|
694 TAny* /*aArg1*/, |
|
695 TAny* /*aArg2*/, |
|
696 TAny* /*aArg3*/ ) |
|
697 { |
|
698 |
|
699 } |
|