397 } |
397 } |
398 return alreadyAssociated; |
398 return alreadyAssociated; |
399 } |
399 } |
400 |
400 |
401 // --------------------------------------------------------------------------- |
401 // --------------------------------------------------------------------------- |
402 // CMailCpsSettings::DissociateWidgetFromSetting |
402 // CMailCpsSettings::DissociateWidgetFromSettingL |
403 // --------------------------------------------------------------------------- |
403 // --------------------------------------------------------------------------- |
404 // |
404 // |
405 void CMailCpsSettings::DissociateWidgetFromSetting( const TDesC& aContentId ) |
405 void CMailCpsSettings::DissociateWidgetFromSettingL( const TDesC& aContentId ) |
406 { |
406 { |
407 FUNC_LOG; |
407 FUNC_LOG; |
408 TUint32 key(0); |
408 TUint32 key(0); |
409 TUint32 mailboxKey(0); |
409 TUint32 mailboxKey(0); |
410 |
410 |
|
411 RemoveFromContentIdListL( aContentId ); |
|
412 |
411 for (TInt i = 0; i < KMaxMailboxCount; i++) |
413 for (TInt i = 0; i < KMaxMailboxCount; i++) |
412 { |
414 { |
413 TBuf<KMaxDescLen> value; |
415 TBuf<KMaxDescLen> value; |
414 TUint32 tempKey(KCMailWidgetContentIdBase+i); |
416 TUint32 tempKey(KCMailWidgetContentIdBase+i); |
415 iCenRep->Get( tempKey, value ); |
417 iCenRep->Get( tempKey, value ); |
416 TInt result = value.Compare(aContentId); |
418 TInt result = value.Compare(aContentId); |
417 if (!result) |
419 if (!result) |
427 |
429 |
428 // --------------------------------------------------------------------------- |
430 // --------------------------------------------------------------------------- |
429 // CMailCpsSettings::GetContentId |
431 // CMailCpsSettings::GetContentId |
430 // --------------------------------------------------------------------------- |
432 // --------------------------------------------------------------------------- |
431 // |
433 // |
432 TInt CMailCpsSettings::GetContentId( TInt aMailboxId, TInt aId, TDes16& aValue ) |
434 void CMailCpsSettings::GetContentId( TInt aMailboxId, TInt aNext, TDes16& aValue ) |
433 { |
435 { |
434 FUNC_LOG; |
436 FUNC_LOG; |
435 TBool cidFound(EFalse); |
|
436 TInt ret(0); |
|
437 TInt found(0); |
437 TInt found(0); |
438 for (TInt i = 0; i < KMaxMailboxCount; i++) |
438 for (TInt i = 0; i < KMaxMailboxCount; i++) |
439 { |
439 { |
440 TInt value; |
440 TInt value; |
441 TUint32 mailboxKey(KCMailMailboxIdBase+i); |
441 TUint32 mailboxKey(KCMailMailboxIdBase+i); |
442 iCenRep->Get( mailboxKey, value ); |
442 iCenRep->Get( mailboxKey, value ); |
443 if (aMailboxId == value) |
443 if (aMailboxId == value) |
444 { |
444 { |
445 found++; |
445 found++; |
446 if ( !cidFound && found == aId ) |
446 if ( found == aNext ) |
447 { |
447 { |
448 iCenRep->Get( KCMailWidgetContentIdBase+i, aValue ); |
448 iCenRep->Get( KCMailWidgetContentIdBase+i, aValue ); |
449 cidFound = ETrue; |
449 break; |
450 } |
450 } |
451 else if ( cidFound && found == aId + 1 ) |
451 } |
452 { |
452 } |
453 // There is more widgets with same mailbox accounts. |
|
454 ret = aId + 1; |
|
455 break; |
|
456 } |
|
457 } |
|
458 } |
|
459 // if there is more than one mailbox with different cid return id of next mailbox |
|
460 return ret; |
|
461 } |
453 } |
462 |
454 |
463 // --------------------------------------------------------------------------- |
455 // --------------------------------------------------------------------------- |
464 // CMailCpsSettings::IsSelected |
456 // CMailCpsSettings::IsSelected |
465 // --------------------------------------------------------------------------- |
457 // --------------------------------------------------------------------------- |
597 iMailClient.ListMailBoxes( TFSMailMsgId(), mailboxarray ); |
589 iMailClient.ListMailBoxes( TFSMailMsgId(), mailboxarray ); |
598 TInt ret = mailboxarray.Count(); |
590 TInt ret = mailboxarray.Count(); |
599 return ret; |
591 return ret; |
600 } |
592 } |
601 |
593 |
|
594 // --------------------------------------------------------------------------- |
|
595 // CMailCpsSettings::FindFromContentIdListL |
|
596 // --------------------------------------------------------------------------- |
|
597 // |
|
598 TBool CMailCpsSettings::FindFromContentIdListL( const TDesC& aContentId ) |
|
599 { |
|
600 FUNC_LOG; |
|
601 TBool ret(EFalse); |
|
602 |
|
603 TBuf<KMaxDescLen> cid; |
|
604 cid.Copy(KStartSeparator); |
|
605 cid.Append(aContentId); |
|
606 cid.Append(KEndSeparator); |
|
607 |
|
608 TBuf<KMaxDescLen> value; |
|
609 TUint32 key(KCMailContentIdList); |
|
610 iCenRep->Get( key, value ); |
|
611 |
|
612 TInt result = value.Find(cid); |
|
613 |
|
614 if (result >= 0) |
|
615 { |
|
616 ret = ETrue; |
|
617 } |
|
618 |
|
619 return ret; |
|
620 } |
|
621 |
|
622 // --------------------------------------------------------------------------- |
|
623 // CMailCpsSettings::AddToContentIdListL |
|
624 // --------------------------------------------------------------------------- |
|
625 // |
|
626 void CMailCpsSettings::AddToContentIdListL( const TDesC& aContentId ) |
|
627 { |
|
628 FUNC_LOG; |
|
629 TBuf<KMaxDescLen> value; |
|
630 |
|
631 TUint32 key(KCMailContentIdList); |
|
632 iCenRep->Get( key, value ); |
|
633 |
|
634 value.Append(KStartSeparator); |
|
635 value.Append(aContentId); |
|
636 value.Append(KEndSeparator); |
|
637 |
|
638 iCenRep->Set( key, value ); |
|
639 } |
|
640 |
|
641 // --------------------------------------------------------------------------- |
|
642 // CMailCpsSettings::RemoveFromContentIdListL |
|
643 // --------------------------------------------------------------------------- |
|
644 // |
|
645 void CMailCpsSettings::RemoveFromContentIdListL( const TDesC& aContentId ) |
|
646 { |
|
647 FUNC_LOG; |
|
648 TBuf<KMaxDescLen> cid; |
|
649 cid.Copy(KStartSeparator); |
|
650 cid.Append(aContentId); |
|
651 cid.Append(KEndSeparator); |
|
652 |
|
653 TBuf<KMaxDescLen> value; |
|
654 TUint32 key(KCMailContentIdList); |
|
655 iCenRep->Get( key, value ); |
|
656 |
|
657 TInt result = value.Find(cid); |
|
658 if (result >= 0) |
|
659 { |
|
660 value.Delete(result, cid.Length()); |
|
661 iCenRep->Set( key, value ); |
|
662 } |
|
663 } |