684 if (iProgress().iError==KErrNone) |
684 if (iProgress().iError==KErrNone) |
685 iMsvServer.NotifyChanged(iDelete==NULL ? EMsvEntriesChanged : EMsvEntriesDeleted, iId, iParent); |
685 iMsvServer.NotifyChanged(iDelete==NULL ? EMsvEntriesChanged : EMsvEntriesDeleted, iId, iParent); |
686 SetState(EMsvOperationCompleted); |
686 SetState(EMsvOperationCompleted); |
687 iMessage.Complete(KErrNone); |
687 iMessage.Complete(KErrNone); |
688 } |
688 } |
689 //********************************** |
|
690 // CMsvLocalChangeEntriesOperation |
|
691 //********************************** |
|
692 |
|
693 |
|
694 CMsvLocalChangeEntriesOperation::CMsvLocalChangeEntriesOperation(const RMessage2& aMessage, TMsvOp aId, CMsvEntrySelection* aSelection, CMsvServer& aMsvServer, TInt aMark) |
|
695 : CMsvLocalOperation(aMessage, aId, aMsvServer), iSelection(aSelection), iMark(aMark) |
|
696 { |
|
697 __DECLARE_NAME(_S("CMsvLocalChangeEntriesOperation")); |
|
698 // set up the progress |
|
699 iProgress().iType = TMsvLocalOperationProgress::ELocalChanged; |
|
700 iProgress().iTotalNumberOfEntries = iSelection->Count();; |
|
701 iProgress().iNumberRemaining = iProgress().iTotalNumberOfEntries; |
|
702 CActiveScheduler::Add(this); |
|
703 } |
|
704 |
|
705 CMsvLocalChangeEntriesOperation::~CMsvLocalChangeEntriesOperation() |
|
706 // |
|
707 // |
|
708 // |
|
709 { |
|
710 Cancel(); |
|
711 delete iSelection; |
|
712 delete iDelete; |
|
713 delete iWorkSelection1; |
|
714 delete iWorkSelection2; |
|
715 } |
|
716 |
|
717 void CMsvLocalChangeEntriesOperation::DoCancel() |
|
718 // |
|
719 // |
|
720 // |
|
721 { |
|
722 __ASSERT_DEBUG(iDelete!=NULL, PanicServer(EMsvChangeEntryBadState)); |
|
723 iDelete->Cancel(); |
|
724 iProgress().iError = KErrCancel; |
|
725 Completed(); |
|
726 } |
|
727 |
|
728 void CMsvLocalChangeEntriesOperation::RunL() |
|
729 // |
|
730 // |
|
731 // |
|
732 { |
|
733 if (iStatus.Int()==KErrNone) |
|
734 { |
|
735 iProgress().iNumberCompleted++; |
|
736 } |
|
737 else |
|
738 { |
|
739 iProgress().iNumberFailed++; |
|
740 iProgress().iError = iStatus.Int(); |
|
741 } |
|
742 |
|
743 Completed(); |
|
744 } |
|
745 |
|
746 |
|
747 void CMsvLocalChangeEntriesOperation::StartL(TSecureId aOwnerId, TBool aForcedUpdate) |
|
748 // |
|
749 // |
|
750 // |
|
751 { |
|
752 TMsvEntry* entry1; |
|
753 |
|
754 TInt count = iSelection->Count(); |
|
755 while (count--) |
|
756 { |
|
757 iMsvServer.IndexAdapter().GetEntry(iSelection->At(count),entry1); |
|
758 iId = entry1->Id(); |
|
759 iParent = entry1->Parent(); |
|
760 // check if this is actually a deletion |
|
761 if (entry1->Deleted() && entry1->PcSyncCount()==0) |
|
762 { |
|
763 iDelete = CMsvDelete::NewL(iMsvServer); |
|
764 iWorkSelection1 = new(ELeave)CMsvEntrySelection; |
|
765 iWorkSelection2 = new(ELeave)CMsvEntrySelection; |
|
766 |
|
767 iDelete->StartL(entry1->Id(), *iWorkSelection1, *iWorkSelection2, iStatus, ETrue); |
|
768 SetActive(); |
|
769 return; |
|
770 } |
|
771 } |
|
772 |
|
773 TInt error = KErrNone; |
|
774 TMsvEntry* entry; |
|
775 count = iSelection->Count(); |
|
776 while (count--) |
|
777 { |
|
778 error = iMsvServer.IndexAdapter().GetEntry(iSelection->At(count),entry); |
|
779 if (error==KErrNone) |
|
780 { |
|
781 error = iMsvServer.IndexAdapter().LockEntry(iSelection->At(count)); |
|
782 error = iMsvServer.ChangeEntry(*entry, aOwnerId, aForcedUpdate); |
|
783 error = iMsvServer.IndexAdapter().ReleaseEntry(iSelection->At(count)); // error ignored |
|
784 } |
|
785 } |
|
786 |
|
787 if (error==KErrNone) |
|
788 iProgress().iNumberCompleted++; |
|
789 else |
|
790 { |
|
791 iProgress().iNumberFailed++; |
|
792 iProgress().iError = error; |
|
793 } |
|
794 Completed(); |
|
795 } |
|
796 |
|
797 void CMsvLocalChangeEntriesOperation::Completed() |
|
798 // |
|
799 // |
|
800 // |
|
801 { |
|
802 |
|
803 if (iProgress().iError==KErrNone) |
|
804 iMsvServer.NotifyChanged(iDelete==NULL ? EMsvEntriesChanged : EMsvEntriesDeleted, iId, iParent); |
|
805 SetState(EMsvOperationCompleted); |
|
806 iMessage.Complete(KErrNone); |
|
807 } |
|
808 |
689 |
809 |
690 |
810 //********************************** |
691 //********************************** |
811 // CMsvLocalCreateOperation |
692 // CMsvLocalCreateOperation |
812 //********************************** |
693 //********************************** |