Exemplo n.º 1
0
void CMsvServerEntry::DoMoveEntriesL(CMsvEntrySelection& aSelection, TMsvId aDestination, CMsvEntrySelection*& aMoved)
	{
	__ASSERT_DEBUG(!aMoved, PanicServer(EMsvMoveSelectionNotNull));
	__ASSERT_DEBUG(aSelection.Count() > 0, PanicServer(EMsvMovingEmptySelection));

	aMoved = new(ELeave)CMsvEntrySelection;
	aMoved->SetReserveL(aSelection.Count());

	CMsvMove* move = CMsvMove::NewL(iServer);
	CleanupStack::PushL(move);

	TInt error = KErrNone;

	TInt count = aSelection.Count();
	while(count--)
		{
		TMsvId id = aSelection.At(count);
		if (!IsAChild(id))
			error = KErrNotFound;
		else
			{
			move->StartL(id, aDestination);
			aSelection.Delete(count);
			aMoved->AppendL(id);
			}
		}
	User::LeaveIfError(error);
	CleanupStack::PopAndDestroy(); // move
	}
Exemplo n.º 2
0
LOCAL_C void TestRemovingAllFilesL()
	{
	CDummyObserver ob;
	CMsvSession* session = CMsvSession::OpenSyncL(ob);
	CleanupStack::PushL(session);

	CMsvEntry* cEntry1 = CMsvEntry::NewL(*session, KMsvLocalServiceIndexEntryId, TMsvSelectionOrdering(KMsvNoGrouping, EMsvSortByNone, ETrue));
	CleanupStack::PushL(cEntry1);

	CMsvEntrySelection* selection;
	CMsvOperation* opert;
	CTestActive* active = new (ELeave) CTestActive; CleanupStack::PushL(active);

	CDir* dir;
	TFileName filename;
	TInt count;


	// delete everything under the outbox
	cEntry1->SetEntryL(KMsvGlobalOutBoxIndexEntryId);
	selection = cEntry1->ChildrenL();
	if (selection->Count())
		{
		active->StartL();
		opert = cEntry1->DeleteL(*selection, active->iStatus);
		CActiveScheduler::Start(); // operation complete
		delete opert; 
		}
	delete selection;

	// delete everything under the inbox
	cEntry1->SetEntryL(KMsvGlobalInBoxIndexEntryId);
	selection = cEntry1->ChildrenL();
	if (selection->Count())
		{
		active->StartL();
		opert = cEntry1->DeleteL(*selection, active->iStatus);
		CActiveScheduler::Start(); // operation complete
		delete opert; 
		}
	delete selection;
	
	// delete everything under the draft
	cEntry1->SetEntryL(KMsvDraftEntryId);
	selection = cEntry1->ChildrenL();
	if (selection->Count())
		{
		active->StartL();
		opert = cEntry1->DeleteL(*selection, active->iStatus);
		CActiveScheduler::Start(); // operation complete
		delete opert; 
		}
	delete selection;
	
	// delete everything under the sent
	cEntry1->SetEntryL(KMsvSentEntryId);
	selection = cEntry1->ChildrenL();
	if (selection->Count())
		{
		active->StartL();
		opert = cEntry1->DeleteL(*selection, active->iStatus);
		CActiveScheduler::Start(); // operation complete
		delete opert; 
		}
	delete selection;

	// delete everything under the local service
	cEntry1->SetEntryL(KMsvLocalServiceIndexEntryId);
	selection = cEntry1->ChildrenL();
	count=selection->Count();
	while (count--)
		{
		TMsvId id = selection->At(count);
#if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
		id = UnmaskTMsvId(id);
#endif
		if (id==KMsvGlobalOutBoxIndexEntryId || 
			id==KMsvGlobalInBoxIndexEntryId || 
			id==KMsvDraftEntryId || 
			id==KMsvSentEntryId || 
			id==KMsvDeletedEntryFolderEntryId)
			selection->Delete(count);
		}
	if (selection->Count())
		{
		active->StartL();
		opert = cEntry1->DeleteL(*selection, active->iStatus);
		CActiveScheduler::Start(); // operation complete
		delete opert; 
		}
	delete selection;

	// test
	cEntry1->SetEntryL(KMsvRootIndexEntryId);
	cEntry1->SetEntryL(KMsvLocalServiceIndexEntryId);
	selection = cEntry1->ChildrenL();
	test(selection->Count()==5);
	delete selection;


	RFs file;
	file.Connect();
	CleanupClosePushL(file);
	TPtrC driveName = TDriveUnit(MessageServer::CurrentDriveL(file)).Name();
    CleanupStack::PopAndDestroy();
	file.Close();
   	filename = driveName;
	filename.Append(KMsvDefaultFolder2);
	MsvUtils::ConstructEntryName(KMsvLocalServiceIndexEntryId, KMsvLocalServiceIndexEntryId, filename, MsvUtils::EPath);
	REPORT_IF_ERROR(theUtils->FileSession().GetDir(filename, KEntryAttMaskSupported, ESortNone, dir));
	
		test(dir->Count()==0);
	delete dir;

	// everything under the root
	cEntry1->SetEntryL(KMsvRootIndexEntryId);
	selection = cEntry1->ChildrenL();
	count=selection->Count();
	while (count--)
		{
		TMsvId id = selection->At(count);
#if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
		id = UnmaskTMsvId(id);
#endif
		if (id==KMsvLocalServiceIndexEntryId)
				selection->Delete(count);
		}
	if (selection->Count())
		{
		active->StartL();
		opert = cEntry1->DeleteL(*selection, active->iStatus);
		CActiveScheduler::Start(); // operation complete
		delete opert; 
		}
	delete selection;

#if (!defined SYMBIAN_MESSAGESTORE_USING_SQLDB)
	// check corrupt index flag was set when index file was corrupted
	TBool corrupt=session->GetAndClearIndexCorruptFlagL();
	test(corrupt!=EFalse);
#endif

	// test
	cEntry1->SetEntryL(KMsvLocalServiceIndexEntryId);
	cEntry1->SetEntryL(KMsvRootIndexEntryId);
	selection = cEntry1->ChildrenL();
	test(selection->Count()==1);
	delete selection;

	filename = driveName;
	filename.Append(KMsvDefaultFolder2);
	REPORT_IF_ERROR(theUtils->FileSession().GetDir(filename, KEntryAttMaskSupported, ESortNone, dir));
		test(dir->Count()==1); //no Index file under Mail2 folder after PREQ1189.
	delete dir;


	CleanupStack::PopAndDestroy(3); 
	}
Exemplo n.º 3
0
void CMsvServerEntry::DoDeleteEntriesL(CMsvEntrySelection& aSelection, CMsvEntrySelection*& aDeleted, CMsvEntrySelection*& aMoved)
//
//
//
	{
	__ASSERT_DEBUG(!aDeleted && !aMoved, PanicServer(EMsvDeleteAndMoveSelectionsNotNull));
	__ASSERT_DEBUG(aSelection.Count() > 0, PanicServer(EMsvDeletingEmptySelection));

	// Total entries deleted and moved
	aDeleted = new(ELeave)CMsvEntrySelection;
	aMoved = new(ELeave)CMsvEntrySelection;

	// Entries deleted when a single item is deleted
	CMsvEntrySelection* deleted = new(ELeave)CMsvEntrySelection;
	CleanupStack::PushL(deleted);

	// Entries moved when a single item is deleted
	CMsvEntrySelection* moved = new(ELeave)CMsvEntrySelection;
	CleanupStack::PushL(moved);

	CMsvEntrySelection* selection = new(ELeave)CMsvEntrySelection;
	CleanupStack::PushL(selection);

	CMsvDelete* del = CMsvDelete::NewL(iServer);
	CleanupStack::PushL(del);

	TInt firstError = KErrNone;

	TInt count = aSelection.Count();
	while(count--)
		{
		TMsvId id = aSelection.At(count);
		TInt error = KErrNone;

		// Only delete children
		if (!IsAChild(id))
			error = KErrNotFound;
		else
			{
			// Need to know maximum number of entries that might be deleted
			selection->AppendL(id);
			error = iServer.IndexAdapter().ExpandSelectionRecursively(*selection);
			if (error == KErrNone)
				{
				// Reserve space in lists
				aDeleted->SetReserveL(aDeleted->Count() + selection->Count());
				aMoved->SetReserveL(aMoved->Count() + selection->Count());
				del->StartL(id, *deleted, *moved);
				aSelection.Delete(count);

				if (deleted->Count() > 0)
					aDeleted->AppendL(deleted->Back(0), deleted->Count());

				if (moved->Count() > 0)
					aMoved->AppendL(moved->Back(0), moved->Count());
				}

			deleted->Reset();
			moved->Reset();
			selection->Reset();
			}

		// Remember error
		if (error != KErrNone && firstError == KErrNone)
			firstError = error;
		}

	User::LeaveIfError(firstError);
	CleanupStack::PopAndDestroy(4); // del, selection, moved, deleted
	}
Exemplo n.º 4
0
LOCAL_C void TestRemovingAllFilesL()
{
    CDummyObserver ob;
    CMsvSession* session = CMsvSession::OpenSyncL(ob);
    CleanupStack::PushL(session);

    CMsvEntry* cEntry1 = CMsvEntry::NewL(*session, KMsvLocalServiceIndexEntryId, TMsvSelectionOrdering(KMsvNoGrouping, EMsvSortByNone, ETrue));
    CleanupStack::PushL(cEntry1);

    CMsvEntrySelection* selection;
    CMsvOperation* opert;
    CTestActive* active = new (ELeave) CTestActive;
    CleanupStack::PushL(active);

    CDir* dir;
    TFileName filename;
    TInt count;


    // delete everything under the outbox
    cEntry1->SetEntryL(KMsvGlobalOutBoxIndexEntryId);
    selection = cEntry1->ChildrenL();
    if (selection->Count())
    {
        active->StartL();
        opert = cEntry1->DeleteL(*selection, active->iStatus);
        CActiveScheduler::Start(); // operation complete
        delete opert;
    }
    delete selection;

    // delete everything under the inbox
    cEntry1->SetEntryL(KMsvGlobalInBoxIndexEntryId);
    selection = cEntry1->ChildrenL();
    if (selection->Count())
    {
        active->StartL();
        opert = cEntry1->DeleteL(*selection, active->iStatus);
        CActiveScheduler::Start(); // operation complete
        delete opert;
    }
    delete selection;

    // delete everything under the draft
    cEntry1->SetEntryL(KMsvDraftEntryId);
    selection = cEntry1->ChildrenL();
    if (selection->Count())
    {
        active->StartL();
        opert = cEntry1->DeleteL(*selection, active->iStatus);
        CActiveScheduler::Start(); // operation complete
        delete opert;
    }
    delete selection;

    // delete everything under the sent
    cEntry1->SetEntryL(KMsvSentEntryId);
    selection = cEntry1->ChildrenL();
    if (selection->Count())
    {
        active->StartL();
        opert = cEntry1->DeleteL(*selection, active->iStatus);
        CActiveScheduler::Start(); // operation complete
        delete opert;
    }
    delete selection;

    // delete everything under the local service
    cEntry1->SetEntryL(KMsvLocalServiceIndexEntryId);
    selection = cEntry1->ChildrenL();
    count=selection->Count();
    while (count--)
    {
        TMsvId id = selection->At(count);
#if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
        id = UnmaskTMsvId(id);
#endif
        if (id==KMsvGlobalOutBoxIndexEntryId ||
                id==KMsvGlobalInBoxIndexEntryId ||
                id==KMsvDraftEntryId ||
                id==KMsvSentEntryId ||
                id==KMsvDeletedEntryFolderEntryId)
            selection->Delete(count);
    }
    if (selection->Count())
    {
        active->StartL();
        opert = cEntry1->DeleteL(*selection, active->iStatus);
        CActiveScheduler::Start(); // operation complete
        delete opert;
    }
    delete selection;

    // test
    cEntry1->SetEntryL(KMsvRootIndexEntryId);
    cEntry1->SetEntryL(KMsvLocalServiceIndexEntryId);
    selection = cEntry1->ChildrenL();
    test(selection->Count()==5);
    delete selection;
    TestNumberOfFilesInService(KMsvLocalServiceIndexEntryId,0);

    // everything under the root
    cEntry1->SetEntryL(KMsvRootIndexEntryId);
    selection = cEntry1->ChildrenL();
    count=selection->Count();
    while (count--)
    {
        TMsvId id = selection->At(count);
#if (defined SYMBIAN_MSGS_ENHANCED_REMOVABLE_MEDIA_SUPPORT)
        if (UnmaskTMsvId(id)==KMsvLocalServiceIndexEntryId)
#else
        if (id==KMsvLocalServiceIndexEntryId)
#endif
            selection->Delete(count);
    }
    if (selection->Count())
    {
        active->StartL();
        opert = cEntry1->DeleteL(*selection, active->iStatus);
        CActiveScheduler::Start(); // operation complete
        delete opert;
    }
    delete selection;

    // test
    cEntry1->SetEntryL(KMsvLocalServiceIndexEntryId);
    cEntry1->SetEntryL(KMsvRootIndexEntryId);
    selection = cEntry1->ChildrenL();
    test(selection->Count()==1);
    delete selection;

    RFs file;
    file.Connect();
    CleanupClosePushL(file);
    TPtrC driveName = TDriveUnit(MessageServer::CurrentDriveL(file)).Name();
    CleanupStack::PopAndDestroy();
    file.Close();
    filename = driveName;
    filename.Append(KMsvDefaultFolder2);
    REPORT_IF_ERROR(theUtils->FileSession().GetDir(filename, KEntryAttMaskSupported, ESortNone, dir));
    //Index File Will not be created in case of SQL
    test(dir->Count()==1);
    delete dir;

    CleanupStack::PopAndDestroy(3);
}