Esempio n. 1
0
LOCAL_C void TestDeleteStoreOperationL()
	{
	CMsgsTestUtils::SetDriveL(EDriveC);

	CSessionObserver* ob = new(ELeave)CSessionObserver;
	CleanupStack::PushL(ob);

	// Set session in observer
	CMsvSession* session = CMsvSession::OpenAsyncL(*ob);
	ob->iSession = session; 
	CleanupStack::PushL(session);
	
	CActiveScheduler::Start();
	test(ob->iType==MMsvSessionObserver::EMsvServerReady);

	CTestActive* active = new(ELeave)CTestActive;
	CleanupStack::PushL(active);
	
	// Test Delete MailStore 
	active->StartL();
	CMsvOperation* operation = NULL;
	TDriveUnit unit =(EDriveD);
	operation = session->DeleteStoreL(unit, active->iStatus);
	test(operation->Mtm() == KUidMsvServerMtm);
	CleanupStack::PushL(operation);
	
    CActiveScheduler::Start();
    
    //Retrieve progress 
	TPckgBuf<TMsvCopyProgress> package;
	package.Copy(operation->ProgressL());
	test((package().iError == KErrNone) || (package().iError == KErrPathNotFound)) ;
	
	CleanupStack::PopAndDestroy(4);	
	}
LOCAL_C void SendSmtpMessageL()
	{
	CTestActive* testActive = new (ELeave) CTestActive();
	CleanupStack::PushL(testActive);
	testUtils->iMsvEntry->SetEntryL(KMsvGlobalOutBoxIndexEntryId);
	testUtils->InstantiateSmtpClientMtmL();
	CMsvEntrySelection* sendSel = testUtils->iMsvEntry->ChildrenL();
	CleanupStack::PushL(sendSel);
	TInt count = sendSel->Count();
	test(count >= 1);
	testUtils->Printf(KMsgSend, count);
	testUtils->iSmtpClientMtm->SetCurrentEntryL(testUtils->iMsvSession->GetEntryL(KMsvGlobalOutBoxIndexEntryId));
	CMsvOperation* msvOperation = testUtils->iSmtpClientMtm->Entry().CopyL(*sendSel, smtpService, testActive->iStatus);
	CleanupStack::PushL(msvOperation);
	testActive->StartL();
	CActiveScheduler::Start();
	//check progress
    testUtils->Printf(KMsgCompleted, testActive->iStatus.Int()); 
	CMsvEntrySelection* sendSelc = testUtils->iMsvEntry->ChildrenL();
	TInt noOfMessages = sendSelc->Count();
	// Check Whether the mails in Outbox is Zero (i.e. mails has been sent..).
    test(noOfMessages == 0);
  	delete sendSelc;
 	TImSmtpProgress temp;	
	TPckgC<TImSmtpProgress> paramPack(temp);
	const TDesC8& progBuf = msvOperation->ProgressL();
	paramPack.Set(progBuf);
	TImSmtpProgress progress = paramPack();	
	testUtils->Printf(KProgressError, progress.Error()); 
	test(progress.Error()==0);
	CleanupStack::PopAndDestroy(3,testActive); //msvOperation,sendsel,testActive
	}
EXPORT_C void CSchSendTestUtils::ChangeMessageTimeL(TMsvId aMessage, TTime aTime)
	{
	iMsvEntry->SetEntryL(aMessage);
	TMsvEntry entry = iMsvEntry->Entry();
	iRTest<<entry.iDate<<aTime;
	entry.iDate = aTime;

	CMsvOperationWait* wait = CMsvOperationWait::NewLC();
	wait->Start();
	CMsvOperation*  opert = iMsvEntry->ChangeL(entry, wait->iStatus);
	CleanupStack::PushL(opert);
	CActiveScheduler::Start(); // operation complete
	entry = iMsvEntry->Entry();
	iRTest<<entry.iDate;

	TMsvLocalOperationProgress details;
	TPckgC<TMsvLocalOperationProgress> package(details);	
	package.Set(opert->ProgressL());

	if(wait->iStatus.Int()!=KErrNone)
		User::Leave(wait->iStatus.Int());

	//TInt err = package().iError;
	//if(err != KErrNone);
	//	User::Leave(package().iError);

	CleanupStack::PopAndDestroy(2);//opert, wait
	}
Esempio n. 4
0
CMsvOperation* CTextMtmClient::ForwardL(TMsvId aForwardEntryId, TMsvPartList aPartList, 
										TRequestStatus& aCompletionStatus)
// Create forwarded message 
// Destination folder is aForwardEntryL
//
	{
	__ASSERT_DEBUG(iMsvEntry!=NULL,gPanic(ETxtcNoCMsvEntrySet));
	__ASSERT_DEBUG(iMsvEntry->Entry().iType.iUid == KUidMsvMessageEntryValue, gPanic(ETxtcEntryTypeNotSupported));
	__ASSERT_DEBUG(iMsvEntry->Entry().iServiceId == KMsvLocalServiceIndexEntryId, gPanic(ETxtcInvalidServiceId));
	
	// Create the forwarded index entry
	TMsvEntry forwardEntry;
	forwardEntry.iMtm = KUidMsgTypeText;
	forwardEntry.iServiceId = Entry().Entry().iServiceId;
	forwardEntry.iType = KUidMsvMessageEntry;
	forwardEntry.iDetails.Set(iMsvEntry->Entry().iDetails);				
	forwardEntry.iSize = iMsvEntry->Entry().iSize;	
	if(aPartList&KMsvMessagePartDate)
		forwardEntry.iDate.HomeTime();
	if(aPartList&KMsvMessagePartDescription)
		forwardEntry.iDescription.Set(iMsvEntry->Entry().iDescription);		

	// Get CMsvEntry for destination (parent)
	CMsvEntry* cEntry = CMsvEntry::NewL(Session(), aForwardEntryId, TMsvSelectionOrdering());
	CleanupStack::PushL(cEntry);
	// Synchronously create new child
	CMsvOperationActiveSchedulerWait* wait = CMsvOperationActiveSchedulerWait::NewLC();
	CMsvOperation* opert = cEntry->CreateL(forwardEntry, wait->iStatus);
	CleanupStack::PushL(opert);
	wait->Start();
	User::LeaveIfError(opert->iStatus.Int());
	// Check result
	TPckgBuf<TMsvLocalOperationProgress> progressPack;
    progressPack.Copy(opert->ProgressL());
	TMsvLocalOperationProgress progress = progressPack();
	User::LeaveIfError(progress.iError);
	CleanupStack::PopAndDestroy(2);	// opert, wait

	// Get CMsvEntry for new entry
	TMsvId forwardId=progress.iId;
	cEntry->SetEntryL(forwardId);
	
	// Populate new forwarded message with Body text
	if(aPartList&KMsvMessagePartBody)
		{
		CMsvStore* store=cEntry->EditStoreL();
		CleanupStack::PushL(store);
		StoreBodyL(*store);				// Current context is original message
		store->CommitL();
		CleanupStack::PopAndDestroy();	// store
		}

	CleanupStack::PopAndDestroy(); // cEntry
		
	// Request was performed synchronously, so return a completed operation object
	return CMsvCompletedOperation::NewL(Session(), KUidMsgTypeText, progressPack, 
		KMsvNullIndexEntryId, aCompletionStatus);
	}
Esempio n. 5
0
LOCAL_C void TestStoreExistsL()
	{
	CMsgsTestUtils::SetDriveL(EDriveC);
	
	//Check that message store exists on the drive at this stage
	CSessionObserver* ob = new(ELeave)CSessionObserver;
	CleanupStack::PushL(ob);
       
	// Set session in observer
	CMsvSession* session = CMsvSession::OpenAsyncL(*ob);
	ob->iSession = session; 
	CleanupStack::PushL(session);
    
	CActiveScheduler::Start();
	test(ob->iType==MMsvSessionObserver::EMsvServerReady);
	
	CTestActive* active = new(ELeave)CTestActive;
	CleanupStack::PushL(active);
     
	// Test Copy MailStore 
	active->StartL();
	CMsvOperation* operation = NULL;
	TDriveUnit unit = EDriveD;
	operation = session->CopyStoreL(unit, active->iStatus);
	test(operation->Mtm() == KUidMsvServerMtm);
	CleanupStack::PushL(operation);
	
	CActiveScheduler::Start();
	
	//Retrieve progress 
	//Should retrun KErrAlreadyExists
	TPckgBuf<TMsvCopyProgress> package;
	package.Copy(operation->ProgressL());
	test(package().iError == KErrAlreadyExists);
		
	//delete session;
	CleanupStack::PopAndDestroy(4, ob);
	
	CMsgsTestUtils::WaitForServerClose();
		
  	}
EXPORT_C TMsvId CSchSendTestUtils::CreateMessageLC(TMsvEntry& aEntry, TMsvId aDestFolder, TTime aSendTime, TBool aOffPeak)
	{
	//Make a TMsvEntry
	iMsvEntry->SetEntryL(aDestFolder);
	aEntry.iType = KUidMsvMessageEntry;
	aEntry.iMtm = KSchSendTestMtmUid;
	
	aEntry.iServiceId = KMsvLocalServiceIndexEntryId;

	aEntry.iDate = aSendTime;
	aEntry.SetOffPeak(aOffPeak);

	//Create the entry in the server

	CMsvOperationWait* wait = CMsvOperationWait::NewLC();
	wait->Start();
	CMsvOperation*  opert = iMsvEntry->CreateL(aEntry, wait->iStatus);
	CleanupStack::PushL(opert);
	CActiveScheduler::Start(); // operation complete

	//Find out the ID of the entry we made
	TMsvLocalOperationProgress details;
	TPckgC<TMsvLocalOperationProgress> package(details);	
	package.Set(opert->ProgressL());

	if(wait->iStatus.Int()!=KErrNone)
		User::Leave(wait->iStatus.Int());

	if(package().iError!=KErrNone)
		User::Leave(package().iError);
	
	*(TMsvId*)&aEntry = package().iId;
	TMsvId testMsvId = aEntry.Id();

	CleanupStack::PopAndDestroy(2);//opert, wait
	iMsvSession->CleanupEntryPushL(testMsvId);

	return testMsvId;
	}
Esempio n. 7
0
LOCAL_C void CreateEntry(TMsvEntry& aNewEntry, CMsvEntry& aClientEntry, TInt aError, CEntryObserver& aObserver)
{
    CTestActive* active = new (ELeave) CTestActive;
    CleanupStack::PushL(active);
    active->StartL();
    aObserver.Start();
    CMsvOperation*  opert = aClientEntry.CreateL(aNewEntry, active->iStatus);
    CActiveScheduler::Start(); // operation complete
    CActiveScheduler::Start(); // cEntry changed
    test(opert->iStatus.Int()==KErrNone);
    test(opert->Mtm()==KUidMsvLocalServiceMtm);
    test(opert->Service()==KMsvLocalServiceIndexEntryId);
    TMsvLocalOperationProgress details;
    TPckgC<TMsvLocalOperationProgress> package(details);
    package.Set(opert->ProgressL());
    test(package().iType==TMsvLocalOperationProgress::ELocalNew);
    test(package().iTotalNumberOfEntries==1);
    test(package().iError==aError);
    if (aError)
    {
        test(package().iNumberCompleted==0);
        test(package().iNumberFailed==1);
    }
    else
    {
        test(package().iNumberCompleted==1);
        test(package().iNumberFailed==0);
        TTestMsvEntry* ptr = (TTestMsvEntry*)&aNewEntry;
        ptr->SetId(package().iId);
        ptr->SetParent(aClientEntry.EntryId());
        if (aNewEntry.iType==KUidMsvServiceEntry)
            aNewEntry.iServiceId = aNewEntry.Id();
    }
    test(package().iNumberRemaining==0);
    delete opert;
    opert=NULL;
    CleanupStack::PopAndDestroy(); // active
}
Esempio n. 8
0
/* Test to check the new API
** CopyStoreL(TInt aDrive, TMsvOp aOperationId, TRequestStatus& aStatus) 
*/
LOCAL_C void TestCopyStoreOperationL()
	{
	CMsgsTestUtils::SetDriveL(EDriveC);
    
	CSessionObserver* ob = new(ELeave)CSessionObserver;
	CleanupStack::PushL(ob);
       
	// Set session in observer
	CMsvSession* session = CMsvSession::OpenAsyncL(*ob);
	ob->iSession = session; 
	CleanupStack::PushL(session);
    
	CActiveScheduler::Start();
	test(ob->iType==MMsvSessionObserver::EMsvServerReady);
	
	//Create an entry in the mail
	
	CMsvEntry* entry=session->GetEntryL(KMsvDraftEntryId);
	CleanupStack::PushL(entry);
	// create entry to work under
	TMsvEntry folder;
	folder.iType = KUidMsvFolderEntry;
	folder.iMtm = KUidMsvLocalServiceMtm;
	folder.iServiceId = KMsvLocalServiceIndexEntryId;
	_LIT(KTestDescription,"A Description");
	_LIT(KTestDetails,"A Details");
	folder.iDescription.Set(KTestDescription);
	folder.iDetails.Set(KTestDetails);
	entry->CreateL(folder);
	entry->SetEntryL(folder.Id());
	CMsvStore* store=entry->EditStoreL();
	CleanupStack::PushL(store);
	RMsvWriteStream stream;
	stream.AssignLC(*store,TUid::Uid(0x1000));
	stream.WriteL(KTestDescription);
	stream.CommitL();
	store->CommitL();
	CleanupStack::PopAndDestroy(3);
            
	CTestActive* active = new(ELeave)CTestActive;
	CleanupStack::PushL(active);
     
	// Test Copy MailStore 
	active->StartL();
	CMsvOperation* operation = NULL;
	TDriveUnit unit =(EDriveD);
	operation = session->CopyStoreL(unit, active->iStatus);
	test(operation->Mtm() == KUidMsvServerMtm);
	CleanupStack::PushL(operation);
	
	CActiveScheduler::Start();
	
	//Retrieve progress 
	TPckgBuf<TMsvCopyProgress> package;
	package.Copy(operation->ProgressL());
	test(package().iError == KErrNone);
		
	//delete session;
	CleanupStack::PopAndDestroy(4);
		
	//Check that both the source and destination
	//MailStore directory structure is same
	
	CMsgsTestUtils::WaitForServerClose();
	
	CDir 		 *srcDir;
	CDir 	     *destDir;
	_LIT(intro, "Testing the directory structure");
	_LIT(KEntryname,"%S");
	
	theUtils->Printf(intro);
	
	TFileName dest = unit.Name();
	dest.Append(KMsvDefaultFolder2);

	User::LeaveIfError(theUtils->FileSession().GetDir(dest, KEntryAttDir|KEntryAttNormal, ESortByName, destDir));
	
	unit =EDriveC;
	TFileName src = unit.Name();
	src.Append(KMsvDefaultFolder2);

	User::LeaveIfError(theUtils->FileSession().GetDir(src, KEntryAttDir|KEntryAttNormal, ESortByName, srcDir));
	
	TInt counter=0;
	TEntry srcEntry;
	TEntry destEntry;

	while (counter<srcDir->Count())
		{
		srcEntry = (*srcDir)[counter];
		destEntry = (*destDir)[counter];
		//Check the sizes 
		test(srcEntry.iSize == destEntry.iSize);
		//Check the names
		test(srcEntry.iName == destEntry.iName);
		//Print out the names on the log
		theUtils->Printf(KEntryname,&(srcEntry.iName));
		counter++;
		}
		
	delete srcDir;
	delete destDir;
	
	}
Esempio n. 9
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);
}