void CMsvServerEntry::RunL() // // // { __ASSERT_DEBUG(iEntryState != EMsvIdle, PanicServer(EMsvServerEntryIdle)); __ASSERT_DEBUG(iCopyMove, PanicServer(EMsvCopyMoveCompletionMissing)); if (iCopyMove->CompletedIds().Count() > 0) { switch (iEntryState) { case EMsvMoving: { iServer.NotifyChanged(EMsvEntriesMoved, iCopyMove->CompletedIds(), iCopyMove->TargetId(), iEntry.Id()); TMsvEntry* pEntry; TInt err = KErrNone; err = iServer.IndexAdapter().GetEntry(iEntry.Id(), pEntry); if (err ==KErrNone) iEntry.SetOwner(pEntry->Owner()); break; } case EMsvCopying: { const CMsvEntrySelection& newEntries = static_cast<CMsvCopyEntries*>(iCopyMove)->NewEntryIds(); iServer.NotifyChanged(EMsvEntriesCreated, newEntries, iCopyMove->TargetId()); if (iCompletedSelection) { iCompletedSelection->Reset(); TInt count = newEntries.Count(); while (count--) iCompletedSelection->AppendL(newEntries[count]); } else if (iCompletedEntryId) *iCompletedEntryId = newEntries[0]; break; } default: break; } } delete iCopyMove; iCopyMove = NULL; iEntryState = EMsvIdle; User::RequestComplete(iObserverStatus, iStatus.Int()); }
EXPORT_C TInt CMsvServerEntry::DeleteEntry(TMsvId aId) // // Deletes the child of the current context recursively. // /** Deletes a child entry of the context. The delete works recursively through all the descendants. If a child or any descendant is locked by another client, then no entries are deleted. @param aId The ID of the entry to delete @return KErrNone if successful, KErrAccessDenied if the entry or a descendant was locked by another client, KErrInUse if the store or a file associated with the entry is open, or KErrNotFound if the entry is not a child of the context. */ { __ASSERT_DEBUG(iEntry.Id()!=KMsvNullIndexEntryId, PanicServer(EMsvEntryWithNoContext4)); __ASSERT_DEBUG(aId!=iEntry.Id(), PanicServer(EMsvDeletingCurrentContext)); // only delete children if (!IsAChild(aId)) return KErrNotFound; // get the total selection of entries to be deleted CMsvEntrySelection* movedEntries=NULL; CMsvEntrySelection* deletedEntries=NULL; TRAPD(error, DoDeleteEntryL(aId, deletedEntries, movedEntries)); // notify server of the deletions & moves if (deletedEntries && movedEntries && (deletedEntries->Count() || movedEntries->Count())) { if (deletedEntries->Count()) iServer.NotifyChanged(EMsvEntriesDeleted, *deletedEntries, iEntry.Id()); if (movedEntries->Count()) iServer.NotifyChanged(EMsvEntriesMoved, *movedEntries, KMsvDeletedEntryFolderEntryId, iEntry.Id()); // need to remove owner flag if has no children TMsvEntry* pEntry; TInt err = KErrNone; err = iServer.IndexAdapter().GetEntry(iEntry.Id(), pEntry); if (err ==KErrNone) iEntry.SetOwner(pEntry->Owner()); } delete movedEntries; delete deletedEntries; return error; }
EXPORT_C TInt CMsvServerEntry::DeleteEntries(CMsvEntrySelection& aSelection) // // Deletes the children of the current context in the selection recursively // Returns the children that could not be fully deleted in the selection // /** Deletes a selection of child entries. The delete works recursively through all the descendants. If a child or any descendant is locked by another client, then no entries are deleted. @param aSelection The entries to delete. On return, contains the children that could not be fully deleted @return KErrNone if successful, KErrAccessDenied if the entry or a descendant was locked by another client, KErrInUse if the store or a file associated with the entry is open, or KErrNotFound if the entry is not a child of the context. */ { __ASSERT_DEBUG(iEntry.Id()!=KMsvNullIndexEntryId, PanicServer(EMsvEntryWithNoContext4)); CMsvEntrySelection* deleted = NULL; CMsvEntrySelection* moved = NULL; TRAPD(error, DoDeleteEntriesL(aSelection, deleted, moved)); if (moved && deleted) { // Notify server of the deletions & moves if (deleted->Count()) iServer.NotifyChanged(EMsvEntriesDeleted, *deleted, iEntry.Id()); if (moved->Count()) iServer.NotifyChanged(EMsvEntriesMoved, *moved, KMsvDeletedEntryFolderEntryId, iEntry.Id()); // need to remove owner flag if has no children TMsvEntry* pEntry; TInt err = KErrNone; err = iServer.IndexAdapter().GetEntry(iEntry.Id(), pEntry); if (err ==KErrNone) iEntry.SetOwner(pEntry->Owner()); } delete moved; delete deleted; return error; }
EXPORT_C TInt CMsvServerEntry::MoveEntryWithinService(TMsvId aId, TMsvId aDestination) // // Moves the child of the current context // /** Moves a child of the context to under another entry. All descendants will be moved as well. The destination must belong to the same service as the context. If an error occurs, no changes are made. For pre-Unicode releases see the synchronous overload of MoveEntry(). @param aId The ID of the entry to move @param aDestination The ID of new parent @return KErrNone if successful, KErrArgument if the destination is a child of aId, KErrInUse if the store or a file associated with the entry is open, KErrNotFound if the aId is not a child of the context KErrPathNotFound, if the destination does not exist. */ { __ASSERT_DEBUG(iEntry.Id()!=KMsvNullIndexEntryId, PanicServer(EMsvEntryWithNoContext10)); // only move children if (!IsAChild(aId)) return KErrNotFound; // check for moving into its current parent if (aDestination==iEntry.Id()) return KErrNone; TRAPD(error, DoMoveEntryL(aId, aDestination)); // notify server of the move if (error==KErrNone) { iServer.NotifyChanged(EMsvEntriesMoved, aId, aDestination, iEntry.Id()); // need to remove owner flag if has no children TMsvEntry* pEntry; TInt err = KErrNone; err = iServer.IndexAdapter().GetEntry(iEntry.Id(), pEntry); if (err==KErrNone) iEntry.SetOwner(pEntry->Owner()); } return error; }
EXPORT_C TInt CMsvServerEntry::MoveEntriesWithinService(CMsvEntrySelection& aSelection, TMsvId aDestination) // // // /** Moves a child of the context to under another entry. All descendants will be moved as well. The destination must belong to the same service as the context. @param aSelection The entries to move. On return, contains the children that could not be fully moved. @param aDestination The ID of new parent @return KErrNone if successful, KErrArgument if the destination is a child of aSelection entry, KErrInUse if the store or a file associated with an entry is open, KErrNotFound if an aSelection entry is not a child of the context the, or KErrPathNotFound if the destination does not exist. */ { __ASSERT_DEBUG(iEntry.Id()!=KMsvNullIndexEntryId, PanicServer(EMsvEntryWithNoContext10)); CMsvEntrySelection* moved = NULL; TRAPD(error, DoMoveEntriesL(aSelection, aDestination, moved)); if (moved && moved->Count()) { iServer.NotifyChanged(EMsvEntriesMoved, *moved, aDestination, iEntry.Id()); // need to remove owner flag if has no children TMsvEntry* pEntry; TInt err = KErrNone; err = iServer.IndexAdapter().GetEntry(iEntry.Id(), pEntry); if (err==KErrNone) iEntry.SetOwner(pEntry->Owner()); } delete moved; return error; }