void CMtfTestActionDeleteEntry::ExecuteActionL()
	{
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionDeleteEntry);
	CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0));
	TMsvId paramEntryId = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1));

	CMsvEntry* entry = CMsvEntry::NewL(*paramSession,paramEntryId,TMsvSelectionOrdering());
	CleanupStack::PushL(entry);
	entry->SetEntryL(paramEntryId);
	entry->SetEntryL(entry->Entry().Parent());

	if (entry->OwningService() == KMsvLocalServiceIndexEntryId)
		{
		entry->DeleteL(paramEntryId);
		DeleteParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1));
		TestCase().ActionCompletedL(*this);
		}
	else
		{
		iOperation = entry->DeleteL(paramEntryId,iStatus);
		SetActive();
		}
	CleanupStack::PopAndDestroy(entry);
	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionDeleteEntry);
	}
void CScheduleTestActive::HandleSessionEventL(TMsvSessionEvent eventType, TAny* p1, TAny*, TAny*)
	{
	if (iStopAtRunL) return;
	if (eventType != EMsvEntriesCreated) return;

	CMsvEntrySelection* entries = STATIC_CAST(CMsvEntrySelection*, p1);

	CMsvEntry* cEntry = iSession.GetEntryL((*entries)[0]);
	CleanupStack::PushL(cEntry);

	TMsvEntry entry(cEntry->Entry());
	
	if(entry.iDetails == KSchSendTestDetails)
		{
		iTest.Printf(_L("Scheduled message has been sent\n"));

		//We found the right message!
		CActiveScheduler::Stop();

		//Delete the new message
		CMsvOperationWait* wait = CMsvOperationWait::NewLC();
		wait->Start();
		cEntry->SetEntryL(entry.Parent());
		CMsvOperation* op = cEntry->DeleteL(entry.Id(), wait->iStatus);
		CActiveScheduler::Start();
		delete op;
		CleanupStack::PopAndDestroy(wait);
		}

	CleanupStack::PopAndDestroy(cEntry);
	}
示例#3
0
TBool CSmsFile::DeleteSentEntry(TMsvId entry)
{
    TInt err;
    // Load this entry to our mtm
    TRAP(err, iReceiveMtm->SwitchCurrentEntryL(entry));
    // probably wasn't compatible, ignore
    if (err!=KErrNone) return EFalse;
    TRAP(err, iReceiveMtm->LoadMessageL());
    // probably wasn't compatible, ignore
    if (err!=KErrNone) return EFalse;

    TMsvEntry msvEntry( (iReceiveMtm->Entry()).Entry() );

    if (msvEntry.iMtmData3 == KUidRippleVaultApp.iUid)    // this entry has been created by our app
    {
        // Taking a handle to the Sent folder...
        TMsvSelectionOrdering sort;
        sort.SetShowInvisibleEntries(ETrue);    // we want to handle also the invisible entries
        // Take a handle to the parent entry
        CMsvEntry* parentEntry = CMsvEntry::NewL(iReceiveMtm->Session(), msvEntry.Parent(), sort);
        CleanupStack::PushL(parentEntry);

        // here parentEntry is the Sent folder (must be so that we can call DeleteL)
        parentEntry->DeleteL(msvEntry.Id());

        CleanupStack::Pop();

        //if(iBillSms == 1)
        //iAppUi.CheckBillingStatus(5);

        return ETrue; // entry was deleted
    }

    return EFalse; // no entries deleted
}
/**
Delete Existing Service

@param aSession		Current Session reference
@internalTechnology
*/
void CentralRepoUtils::DeleteServiceL(CMsvSession* aSession)
	{
	TMsvId serviceId;
	TRAPD(err,TSmsUtilities::ServiceIdL(*aSession,serviceId));
	if(err !=KErrNotFound)
		{
		CMsvEntry* entry = CMsvEntry::NewL(*aSession,serviceId,TMsvSelectionOrdering());
		CleanupStack::PushL(entry);
		entry->SetEntryL(serviceId);
		entry->SetEntryL(entry->Entry().Parent());
		entry->DeleteL(serviceId);
		CleanupStack::PopAndDestroy(entry);
		}
	}
示例#5
0
/*
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
void CSMSSender::DeleteEntryL(TMsvEntry& aMsvEntry)
    {
    // Take a handle to the parent entry
    CMsvEntry* parentEntry = CMsvEntry::NewL(*iSession, aMsvEntry.Parent(), TMsvSelectionOrdering());

    CleanupStack::PushL(parentEntry);

    // here parentEntry is the Sent folder (must be so that we can call DeleteL) 
    iOperation = parentEntry->DeleteL(aMsvEntry.Id(), iStatus);

    CleanupStack::PopAndDestroy(parentEntry);

    SetActive();
    }
示例#6
0
LOCAL_C void TestReadOnlyDeletionL()
	{
	CDummyObserver* ob = new(ELeave)CDummyObserver;
	CleanupStack::PushL(ob);

	CMsvSession* session = CMsvSession::OpenSyncL(*ob);
	CleanupStack::PushL(session);

	CMsvEntry* cEntry = CMsvEntry::NewL(*session, KMsvDraftEntryId, TMsvSelectionOrdering());
	CleanupStack::PushL(cEntry);

	// Create an entry
	TMsvEntry entry;
	entry.iType = KUidMsvMessageEntry;
	entry.iMtm = KUidMsvLocalServiceMtm;
	entry.iServiceId = KMsvLocalServiceIndexEntryId;
	cEntry->CreateL(entry);

	// Generate name of attachment
	cEntry->SetEntryL(entry.Id());
	TFileName fileName;

	fileName.Append(_L("Test"));
	CMsvStore* store = cEntry->EditStoreL();
	CleanupStack::PushL(store);

	CAsyncWaiter* waiter = CAsyncWaiter::NewL();
	CleanupStack::PushL(waiter);
	CMsvAttachment* attachment = CMsvAttachment::NewL(CMsvAttachment::EMsvFile);
	CleanupStack::PushL(attachment);
	fileName.Append(_L("Test"));
	attachment->SetAttachmentNameL(fileName);
	RFile file;
	store->AttachmentManagerL().CreateAttachmentL(fileName, file, attachment, waiter->iStatus);
	CleanupStack::Pop(attachment); // ownership passed
	waiter->StartAndWait();
	User::LeaveIfError(waiter->Result());
	CleanupStack::PopAndDestroy(waiter);
	
	CleanupClosePushL(file);
	User::LeaveIfError(file.Write(_L8("some text")));
	User::LeaveIfError(file.SetAtt(KEntryAttReadOnly, KEntryAttNormal));
	CleanupStack::PopAndDestroy(2, store); // file, store

	// Now try and delete the file
	cEntry->SetEntryL(entry.Parent());
	cEntry->DeleteL(entry.Id());

	CleanupStack::PopAndDestroy(3); // cEntry, session, ob
	}
void CMtfTestActionDeletePop3Service::ExecuteActionL()
	{
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionDeletePop3Service);
	CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0));
	TMsvId paramServiceId = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1));

	CMsvEntry* entry = CMsvEntry::NewL(*paramSession,paramServiceId,TMsvSelectionOrdering());
	CleanupStack::PushL(entry);
	entry->SetEntryL(paramServiceId);
	entry->SetEntryL(entry->Entry().Parent());
	entry->DeleteL(paramServiceId);
	CleanupStack::PopAndDestroy(entry);
	DeleteParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(1));

	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionDeletePop3Service);
	TestCase().ActionCompletedL(*this);
	}
void CT_CMsvSession::TestTransferCommandL()
	{
	TInt error = KErrGeneral;
	INFO_PRINTF1(_L("Testing: Transfer Commands -- started"));
	TRAP(error, iSession = CMsvSession::OpenSyncL(*this));
	TEST(error == KErrNone);

	CMsvOperationWait* active = CMsvOperationWait::NewLC();
	
	CMsvEntry* cEntry = CMsvEntry::NewL(*iSession, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering());
	CleanupStack::PushL(cEntry);
	
	CMsvEntrySelection* selection = new(ELeave)CMsvEntrySelection;
	CleanupStack::PushL(selection);

	TInt ret = iSession->InstallMtmGroup(KDataComponentFilename);
	TEST(ret==KErrNone|| ret==KErrAlreadyExists);

	cEntry->SetEntryL(KMsvRootIndexEntryId);
	TMsvEntry service;
	service.iType=KUidMsvServiceEntry;
	service.iMtm = KUidTestServerMtmType;
	cEntry->CreateL(service);

	selection->AppendL(service.Id());
	
	TBuf8<256> progress;
	TBuf8<32> param;
	CMsvOperation* operation = NULL;	
	active->Start();
	operation = iSession->TransferCommandL(*selection, 1, param, active->iStatus);
	CActiveScheduler::Start();
	TEST(operation->iStatus.Int()==KErrNone);
	cEntry->DeleteL(service.Id());
	delete operation;
	CleanupStack::PopAndDestroy(selection);
	CleanupStack::PopAndDestroy(cEntry);
	CleanupStack::PopAndDestroy(active);
	delete iSession;
	INFO_PRINTF1(_L("Testing: Transfer Commands -- ended"));
	}
// -----------------------------------------------------------------------------
// CMmsAdapterMsvApi::DeleteUserFolderL
// -----------------------------------------------------------------------------
//
 TInt CMmsAdapterMsvApi::DeleteUserFolderL( TMsvId aUid )
    {
    TRACE_FUNC_ENTRY;
    
    CMsvEntry* entry = iSession.GetEntryL(aUid);
    CleanupStack::PushL(entry);
    
    TMsvEntry tEntry = entry->Entry();
    TMsvId parent = tEntry.Parent();        
    
    if ( tEntry.iType != KUidMsvFolderEntry || parent != KMsvMyFoldersEntryIdValue )
        {
        LOGGER_WRITE( "Not correct folder" );
        CleanupStack::PopAndDestroy(entry);
        LOGGER_LEAVEFN( "MsvApi::DeleteUserFolderL" );
        return KErrNotSupported;
        }
        
    CMsvEntrySelection* children = entry->ChildrenL();
    TInt count = children->Count();
    delete children;
    
    if ( count > 0 )
        {
        LOGGER_WRITE( "Folder not empty" );
        CleanupStack::PopAndDestroy( entry );
        LOGGER_LEAVEFN( "MsvApi::DeleteUserFolderL" );
        return KErrInUse;
        }
        
    tEntry.SetReadOnly( EFalse );
    entry->ChangeL( tEntry );
    
    entry->SetEntryL( parent );
    entry->DeleteL( aUid );
    
    CleanupStack::PopAndDestroy( entry );
    TRACE_FUNC_EXIT;
    return KErrNone;
    }   
LOCAL_C void CleanMailFolder(TMsvId aFolderId)
	{
	CDummyObserver* ob1 = new(ELeave) CDummyObserver;
	CleanupStack::PushL(ob1);

	CMsvSession* session = CMsvSession::OpenSyncL(*ob1);
	CleanupStack::PushL(session);
	
	CMsvEntry* cEntry = CMsvEntry::NewL(*session, aFolderId, 
		TMsvSelectionOrdering(KMsvNoGrouping,EMsvSortByNone,ETrue));
	CleanupStack::PushL(cEntry);
	
	CMsvEntrySelection* selection = cEntry->ChildrenL();
	CleanupStack::PushL(selection);

	TMsvLocalOperationProgress progress;
	if (selection->Count() > 0)
		{
		cEntry->DeleteL(*selection, progress);
		}

	CleanupStack::PopAndDestroy(4); // selection, cEntry, session, ob1
	}
示例#11
0
LOCAL_C void TestMultipleNotifsL()
{
    CMultipleSessionObserver* ob = new(ELeave) CMultipleSessionObserver;
    CleanupStack::PushL(ob);

    CMsvSession* session = CMsvSession::OpenSyncL(*ob);
    CleanupStack::PushL(session);

    CMsvEntry* cEntry = CMsvEntry::NewL(*session, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering());
    CleanupStack::PushL(cEntry);

    CEntryObserver* entryOb1=new (ELeave) CEntryObserver;
    CleanupStack::PushL(entryOb1);
    cEntry->AddObserverL(*entryOb1);

    CTestActive* active = new (ELeave) CTestActive;
    CleanupStack::PushL(active);

    CMsvOperation* operation;
    CMsvEntrySelection* selection;

    // create folders to work under
    TMsvEntry folder1;
    folder1.iDescription.Set(KShortDescription);
    folder1.iDetails.Set(KShortDetails);
    folder1.iType = KUidMsvFolderEntry;
    folder1.iMtm = KUidMsvLocalServiceMtm;
    folder1.iServiceId = KMsvLocalServiceIndexEntryId;

    TMsvEntry folder2;
    folder2.iDescription.Set(KShortDescription);
    folder2.iDetails.Set(KShortDetails);
    folder2.iType = KUidMsvFolderEntry;
    folder2.iMtm = KUidMsvLocalServiceMtm;
    folder2.iServiceId = KMsvLocalServiceIndexEntryId;

    TMsvEntry folder3;
    folder3.iDescription.Set(KShortDescription);
    folder3.iDetails.Set(KShortDetails);
    folder3.iType = KUidMsvFolderEntry;
    folder3.iMtm = KUidMsvLocalServiceMtm;
    folder3.iServiceId = KMsvLocalServiceIndexEntryId;

    // create all th entries
    TMsvEntry entry;
    entry.iDescription.Set(KShortDescription);
    entry.iDetails.Set(KShortDetails);
    entry.iType = KUidMsvFolderEntry;
    entry.iMtm = KUidMsvLocalServiceMtm;
    entry.iServiceId = KMsvLocalServiceIndexEntryId;

    // create folder 2 & 3
    cEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId);
    CreateEntry(folder2, *cEntry, KErrNone, *entryOb1);
    CreateEntry(folder3, *cEntry, KErrNone, *entryOb1);

    TMsvLocalOperationProgress prog;

    TInt max = 2*TMsvPackedChangeNotification::KMsvPackedChangeLimit+4;
    for (TInt count=1; count<=max; count++)
    {
        test.Printf(_L("."));

        // create another entry under folder 2
        cEntry->SetEntryL(folder2.Id());
        CreateEntry(entry, *cEntry, KErrNone, *entryOb1);

        // create folder1
        cEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId);
        CreateEntry(folder1, *cEntry, KErrNone, *entryOb1);

        // test
        cEntry->SetEntryL(folder3.Id());
        selection = cEntry->ChildrenL();
        test(selection->Count()==0);
        delete selection;

        // copy all entries to folder 3
        ob->Start(MMsvSessionObserver::EMsvEntriesCreated, folder3.Id());
        cEntry->SetEntryL(folder2.Id());
        selection = cEntry->ChildrenL();
        test(selection->Count()==count);
        active->StartL();
        operation = cEntry->CopyL(*selection, folder3.Id(), active->iStatus);
        delete selection;
        CActiveScheduler::Start(); // operation complete
        test(operation->iStatus.Int()==KErrNone);
        test(operation->Mtm()==KUidMsvLocalServiceMtm);
        test(operation->Service()==KMsvLocalServiceIndexEntryId);
        prog = McliUtils::GetLocalProgressL(*operation);
        test(prog.iTotalNumberOfEntries==count);
        test(prog.iNumberCompleted==count);
        test(prog.iNumberFailed==0);
        test(prog.iError==KErrNone);
        delete operation;
        operation=NULL;
        // test
        cEntry->SetEntryL(folder3.Id());
        selection = cEntry->ChildrenL();
        test(selection->Count()==count);
        delete selection;
        if (ob->iEvents>1)
            test(ob->iSelection.Count()>TMsvPackedChangeNotification::KMsvPackedChangeLimit);
        else if (count>TMsvPackedChangeNotification::KMsvPackedChangeLimit)
        {
            ob->Wait();
            CActiveScheduler::Start();
        }
        // test
        selection = cEntry->ChildrenL();
        test(selection->Count()==count);
        delete selection;
        if (ob->iEvents>2)
            test(ob->iSelection.Count()>2*TMsvPackedChangeNotification::KMsvPackedChangeLimit);
        else if (count>2*TMsvPackedChangeNotification::KMsvPackedChangeLimit)
        {
            ob->Wait();
            CActiveScheduler::Start();
        }
        test(ob->iSelection.Count()==count);
        ob->Finish();

        // move all entries to folder 1
        selection = cEntry->ChildrenL();
        test(selection->Count()==count);
        ob->Start(MMsvSessionObserver::EMsvEntriesMoved, folder1.Id(), folder3.Id());
        active->StartL();
        operation = cEntry->MoveL(*selection, folder1.Id(), active->iStatus);
        delete selection;
        CActiveScheduler::Start(); // operation complete
        test(operation->iStatus.Int()==KErrNone);
        test(operation->Mtm()==KUidMsvLocalServiceMtm);
        test(operation->Service()==KMsvLocalServiceIndexEntryId);
        prog = McliUtils::GetLocalProgressL(*operation);
        test(prog.iTotalNumberOfEntries==count);
        test(prog.iNumberCompleted==count);
        test(prog.iNumberFailed==0);
        test(prog.iError==KErrNone);
        delete operation;
        operation=NULL;
        cEntry->SetEntryL(folder1.Id());
        selection = cEntry->ChildrenL();
        test(selection->Count()==count);
        delete selection;
        if (ob->iEvents>1)
            test(ob->iSelection.Count()>TMsvPackedChangeNotification::KMsvPackedChangeLimit);
        else if (count>TMsvPackedChangeNotification::KMsvPackedChangeLimit)
        {
            test(ob->iEvents==1);
            ob->Wait();
            CActiveScheduler::Start();
            test(ob->iEvents==2);
        }
        if (ob->iEvents>2)
            test(ob->iSelection.Count()>2*TMsvPackedChangeNotification::KMsvPackedChangeLimit);
        else if (count>2*TMsvPackedChangeNotification::KMsvPackedChangeLimit)
        {
            test(ob->iEvents==2);
            ob->Wait();
            CActiveScheduler::Start();
            test(ob->iEvents==3);
        }
        test(ob->iSelection.Count()==count);
        ob->Finish();


        // delete them
        ob->Start(MMsvSessionObserver::EMsvEntriesDeleted, KMsvGlobalInBoxIndexEntryId);
        cEntry->SetEntryL(KMsvGlobalInBoxIndexEntryId);
        active->StartL();
        operation = cEntry->DeleteL(folder1.Id(), active->iStatus);
        CActiveScheduler::Start(); // operation complete
        test(operation->iStatus.Int()==KErrNone);
        test(operation->Mtm()==KUidMsvLocalServiceMtm);
        test(operation->Service()==KMsvLocalServiceIndexEntryId);
        prog = McliUtils::GetLocalProgressL(*operation);
        test(prog.iTotalNumberOfEntries==1);
        test(prog.iNumberFailed==0);
        test(prog.iError==KErrNone);
        delete operation;
        operation=NULL;
        if (count+1>TMsvPackedChangeNotification::KMsvPackedChangeLimit && ob->iEvents==1)
        {
            ob->Wait();
            CActiveScheduler::Start();
        }
        if (count+1>2*TMsvPackedChangeNotification::KMsvPackedChangeLimit && ob->iEvents==2)
        {
            ob->Wait();
            CActiveScheduler::Start();
        }
        test(ob->iSelection.Count()==count+1);
        ob->Finish();
    }

    test.Printf(_L("\n"));
    CleanupStack::PopAndDestroy(5);
}