Beispiel #1
0
/* 
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
void CFakeSMSSender::FinalizeMessageL(TMsvId aEntryId,const TDesC& aBody,const TDesC& aRecipientName,TTime aMsgTime)
{
 	CMsvEntry* entry = iMsvSession->GetEntryL(aEntryId);
    CleanupStack::PushL(entry);
	
	TMsvEntry newEntry(entry->Entry());              // This represents an entry in the Message Server index
   	newEntry.SetInPreparation(EFalse);                       // a flag that this message is in preparation
	newEntry.iDetails.Set(aRecipientName);
	newEntry.SetUnread(ETrue);
	newEntry.iDate = aMsgTime;
	newEntry.SetReadOnly(ETrue);				

	CMsvStore* srore = entry->EditStoreL();
	CleanupStack::PushL(srore);
	if(srore)
	{		
		CParaFormatLayer* paraFormatLayer = CParaFormatLayer::NewL();
		CleanupStack::PushL(paraFormatLayer);
		CCharFormatLayer* charFormatLayer = CCharFormatLayer::NewL();
		CleanupStack::PushL(charFormatLayer);
		CRichText* messageBodyContent = CRichText::NewL(paraFormatLayer, charFormatLayer);
		CleanupStack::PushL(messageBodyContent);
					
		messageBodyContent->InsertL(0,aBody);
		
		srore->StoreBodyTextL(*messageBodyContent);
		srore->CommitL();
			
		CleanupStack::PopAndDestroy(3); // messageBodyContent, charFormatLayer,paraFormatLayer

		if(aBody.Length() > 50)
			newEntry.iDescription.Set(aBody.Left(50));
		else
			newEntry.iDescription.Set(aBody);
	}
	
	CleanupStack::PopAndDestroy(srore);
	
	entry->ChangeL(newEntry);	
	entry->MoveL(aEntryId,KMsvGlobalInBoxIndexEntryId);

	CleanupStack::PopAndDestroy(entry);
}
void CMtfTestActionMoveSelection::ExecuteActionL()
	{
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionMoveSelection);
	CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession>(TestCase(),ActionParameters().Parameter(0));
	CMsvEntrySelection* paramSelection = ObtainParameterReferenceL<CMsvEntrySelection>(TestCase(),ActionParameters().Parameter(1));
	TMsvId paramTargetId      = ObtainValueParameterL<TMsvId>(TestCase(),ActionParameters().Parameter(2));

	TInt count = paramSelection->Count();
	if (count == 0)
		User::Leave(KErrArgument);

	TMsvId entryId = (*paramSelection)[0];

	CMsvEntry* entry = CMsvEntry::NewL(*paramSession,entryId,TMsvSelectionOrdering());
	CleanupStack::PushL(entry);
	entry->SetEntryL(entryId);
	entry->SetEntryL(entry->Entry().Parent());
	iOperation = entry->MoveL(*paramSelection,paramTargetId,iStatus);
	CleanupStack::PopAndDestroy(entry);
	CActiveScheduler::Add(this);
	SetActive();
	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionMoveSelection);
	}
Beispiel #3
0
/*
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
TBool CSMSSender::MoveMessageEntryL(TMsvId aTarget)
    {
    ASSERT(iMtm);

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

    if (msvEntry.Parent() != aTarget)
        {
        TMsvSelectionOrdering sort;
        sort.SetShowInvisibleEntries(ETrue);    // we want to also handle the invisible entries
        // Take a handle to the parent entry
        CMsvEntry* parentEntry = CMsvEntry::NewL(iMtm->Session(), msvEntry.Parent(), sort);
        CleanupStack::PushL(parentEntry);

        // Move original from the parent to the new location
        iOperation = parentEntry->MoveL(msvEntry.Id(), aTarget, iStatus);

        CleanupStack::PopAndDestroy(parentEntry);
        SetActive();

        return ETrue;
        }
    return EFalse;
    }
void CTestPerformanceM::TestMoveMultipleEntry()
{
    _LIT(KFunction, "TestMoveMultipleEntry");
    INFO_PRINTF1(KFunction);

    TSecureId owner = 0x999;
    TUint32 start, stop;
    TMsvEntry entry;
    CMsvEntry* parent = NULL;
    TMsvLocalOperationProgress progress = TMsvLocalOperationProgress();
    CMsvEntrySelection* entries = new(ELeave) CMsvEntrySelection;
    TReal64 diff = 0;

    iServerSide = EFalse;

    INFO_PRINTF1(_L("<b>CLIENT SIDE</b>"));
    TInt frequency;
    HAL::Get(HALData::EFastCounterFrequency, frequency);
    INFO_PRINTF2(_L("<b>FastCounter frequency: %d</b>"), frequency);

    parent = iTestUtils->iMsvSession->GetEntryL(KMsvDraftEntryId);

    //[1]. Move entries from Drafts to Outbox, and back again, and so on.
    for(TInt index = 0; index < 10; ++index)
    {
        TMsvEntry entry;
        entry.SetId((TMsvId)20000+index);
        entry.SetParent(KMsvDraftEntryId);
        entry.iType = KUidMsvMessageEntry;
        entry.iMtm = KUidMsvMessageEntry;
        entry.iServiceId = KMsvLocalServiceIndexEntryId;
        parent->CreateL(entry);
        entries->AppendL(entry.iId);
    }
    parent->SetEntryNoCheckL(KMsvDraftEntryId); //bring to cache
    start = User::FastCounter();
    parent->MoveL(*entries, KMsvGlobalOutBoxIndexEntryId, progress); //iTestActive->iStatus);
    stop = User::FastCounter();
    diff = (TReal64)(stop-start)/frequency;
    INFO_PRINTF3(_L("---Time taken to MOVE %d entries from Drafts which has 10 entries: <b>%f sec</b>"), 10, diff);
    MY_ASSERT_EQUALS(entries->Count(), 10);

    parent->SetEntryL(KMsvGlobalOutBoxIndexEntryId);
    for(TInt index = 0; index < 90; ++index)
    {
        TMsvEntry entry;
        entry.SetId((TMsvId)21000+index);
        entry.SetParent(KMsvGlobalOutBoxIndexEntryId);
        entry.iType = KUidMsvMessageEntry;
        entry.iMtm = KUidMsvMessageEntry;
        entry.iServiceId = KMsvLocalServiceIndexEntryId;
        parent->CreateL(entry);
        entries->AppendL(entry.iId);
    }
    parent->SetEntryNoCheckL(KMsvGlobalOutBoxIndexEntryId); //bring to cache
    start = User::FastCounter();
    parent->MoveL(*entries, KMsvDraftEntryId, progress);
    stop = User::FastCounter();
    diff = (TReal64)(stop-start)/frequency;
    INFO_PRINTF3(_L("---Time taken to MOVE %d entries from Outbox which has 100 entries: <b>%f sec</b>"), 100, diff);
    MY_ASSERT_EQUALS(entries->Count(), 100);

    parent->SetEntryL(KMsvDraftEntryId);
    for(TInt index = 0; index < 400; ++index)
    {
        TMsvEntry entry;
        entry.SetId((TMsvId)22000+index);
        entry.SetParent(KMsvDraftEntryId);
        entry.iType = KUidMsvMessageEntry;
        entry.iMtm = KUidMsvMessageEntry;
        entry.iServiceId = KMsvLocalServiceIndexEntryId;
        parent->CreateL(entry);
        entries->AppendL(entry.iId);
    }
    start = User::FastCounter();
    parent->MoveL(*entries, KMsvGlobalOutBoxIndexEntryId, progress);
    stop = User::FastCounter();
    diff = (TReal64)(stop-start)/frequency;
    INFO_PRINTF3(_L("---Time taken to MOVE %d entries from Drafts which has 500 entries: <b>%f sec</b>"), 500, diff);
    MY_ASSERT_EQUALS(entries->Count(), 500);

    parent->SetEntryL(KMsvGlobalOutBoxIndexEntryId);
    for(TInt index = 0; index < 500; ++index)
    {
        TMsvEntry entry;
        entry.SetId((TMsvId)22000+index);
        entry.SetParent(KMsvGlobalOutBoxIndexEntryId);
        entry.iType = KUidMsvMessageEntry;
        entry.iMtm = KUidMsvMessageEntry;
        entry.iServiceId = KMsvLocalServiceIndexEntryId;
        parent->CreateL(entry);
        entries->AppendL(entry.iId);
    }
    start = User::FastCounter();
    parent->MoveL(*entries, KMsvDraftEntryId, progress);
    stop = User::FastCounter();
    diff = (TReal64)(stop-start)/frequency;
    INFO_PRINTF3(_L("---Time taken to MOVE %d entries from Outbox which has 1000 entries: <b>%f sec</b>"), 1000, diff);
    MY_ASSERT_EQUALS(entries->Count(), 1000);

    parent->SetEntryL(KMsvDraftEntryId);
    for(TInt index = 0; index < 500; ++index)
    {
        TMsvEntry entry;
        entry.SetId((TMsvId)23000+index);
        entry.SetParent(KMsvDraftEntryId);
        entry.iType = KUidMsvMessageEntry;
        entry.iMtm = KUidMsvMessageEntry;
        entry.iServiceId = KMsvLocalServiceIndexEntryId;
        parent->CreateL(entry);
        entries->AppendL(entry.iId);
    }
    start = User::FastCounter();
    parent->MoveL(*entries, KMsvGlobalOutBoxIndexEntryId, progress);
    stop = User::FastCounter();
    diff = (TReal64)(stop-start)/frequency;
    INFO_PRINTF3(_L("---Time taken to MOVE %d entries from Drafts which has 1500 entries: <b>%f sec</b>"), 1500, diff);
    MY_ASSERT_EQUALS(entries->Count(), 1500);

    parent->SetEntryL(KMsvGlobalOutBoxIndexEntryId);
    for(TInt index = 0; index < 500; ++index)
    {
        TMsvEntry entry;
        entry.SetId((TMsvId)24000+index);
        entry.SetParent(KMsvGlobalOutBoxIndexEntryId);
        entry.iType = KUidMsvMessageEntry;
        entry.iMtm = KUidMsvMessageEntry;
        entry.iServiceId = KMsvLocalServiceIndexEntryId;
        parent->CreateL(entry);
        entries->AppendL(entry.iId);
    }
    start = User::FastCounter();
    parent->MoveL(*entries, KMsvDraftEntryId, progress);
    stop = User::FastCounter();
    diff = (TReal64)(stop-start)/frequency;
    INFO_PRINTF3(_L("---Time taken to MOVE %d entries from Outbox which has 2000 entries: <b>%f sec</b>"), 2000, diff);
    MY_ASSERT_EQUALS(entries->Count(), 2000);

    parent->SetEntryL(KMsvDraftEntryId);
    for(TInt index = 0; index < 500; ++index)
    {
        TMsvEntry entry;
        entry.SetId((TMsvId)25000+index);
        entry.SetParent(KMsvDraftEntryId);
        entry.iType = KUidMsvMessageEntry;
        entry.iMtm = KUidMsvMessageEntry;
        entry.iServiceId = KMsvLocalServiceIndexEntryId;
        parent->CreateL(entry);
        entries->AppendL(entry.iId);
    }
    start = User::FastCounter();
    parent->MoveL(*entries, KMsvGlobalOutBoxIndexEntryId, progress);
    stop = User::FastCounter();
    diff = (TReal64)(stop-start)/frequency;
    INFO_PRINTF3(_L("---Time taken to MOVE %d entries from Drafts which has 2500 entries: <b>%f sec</b>"), 2500, diff);
    MY_ASSERT_EQUALS(entries->Count(), 2500);

    parent->SetEntryL(KMsvGlobalOutBoxIndexEntryId);
    for(TInt index = 0; index < 500; ++index)
    {
        TMsvEntry entry;
        entry.SetId((TMsvId)26000+index);
        entry.SetParent(KMsvGlobalOutBoxIndexEntryId);
        entry.iType = KUidMsvMessageEntry;
        entry.iMtm = KUidMsvMessageEntry;
        entry.iServiceId = KMsvLocalServiceIndexEntryId;
        parent->CreateL(entry);
        entries->AppendL(entry.iId);
    }
    start = User::FastCounter();
    parent->MoveL(*entries, KMsvDraftEntryId, progress);
    stop = User::FastCounter();
    diff = (TReal64)(stop-start)/frequency;
    INFO_PRINTF3(_L("---Time taken to MOVE %d entries from Outbox which has 3000 entries: <b>%f sec</b>"), 3000, diff);
    MY_ASSERT_EQUALS(entries->Count(), 3000);
    delete entries;

    iServerSide = ETrue;
}
Beispiel #5
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);
}
// -----------------------------------------------------------------------------
// CMessageMonitorPlugin::HandleMsgMovedL
// -----------------------------------------------------------------------------
//
void CMessageMonitorPlugin::HandleMsgMovedL( const TMsvId aFolderId1, 
											 const TMsvId aFolderId2, 
								   			 const CMsvEntrySelection& aSelection )
	{
	
	
	
	WRITELOG("ENTER CMessageMonitorPlugin::HandleMsgMovedL");
	
	TInt count( aSelection.Count() );
	// cycle through every message in the CMsvEntrySelection
	for ( TInt i=0; i < count; ++i )
		{
		TMsvId msgId = aSelection[i];
		WRITELOG1("msgId: %d", msgId );					
		
		TMsvId service = 0;
        TMsvEntry entry;
		TInt err = iMsvSession->GetEntry( msgId, service, entry );

        // if we have a message and it has been moved from the outbox to the sent 
        // items, and it is a valid message
        if ( ( !err ) &&
            ( KUidMsvMessageEntry == entry.iType ) &&
            ( KMsvSentEntryId == aFolderId1 ) &&
            ( KMsvGlobalOutBoxIndexEntryId == aFolderId2 ) && 
            ( IsValidMessageTypeL( entry, *iMsvSession ) ) )
            {            
            HBufC* uri = CreateUriL( entry.iMtm, msgId );
            CleanupStack::PushL( uri );
            CHarvesterData* hd = CHarvesterData::NewL( uri );
            CleanupStack::Pop( uri );
            hd->SetEventType( EHarvesterAdd );
            hd->SetTakeSnapshot( EFalse );
            hd->SetBinary( EFalse );
            iMonitorPluginObserver->MonitorEvent( hd );
            }
            
               
#ifdef __WINSCW__
		else if (!err && KMsvDraftEntryId == aFolderId2 && KMsvGlobalOutBoxIndexEntryId == aFolderId1 )
			{
		    if( entry.iMtm.iUid != KUidMsgTypeMultimedia.iUid )
		        {
                CClientMtmRegistry* clientMtmReg;
                clientMtmReg = CClientMtmRegistry::NewL(*iMsvSession);
                CleanupStack::PushL(clientMtmReg);
            
                CSmsClientMtm* smsMtm = static_cast<CSmsClientMtm*>(clientMtmReg->NewMtmL(KUidMsgTypeSMS)); 
                CleanupStack::PushL(smsMtm);
                smsMtm->SwitchCurrentEntryL( msgId );
            
                TMsvSelectionOrdering selection;
                selection.SetShowInvisibleEntries(ETrue);
            
                CMsvEntry* parentEntry = CMsvEntry::NewL( smsMtm->Session(),
                    smsMtm->Entry().Entry().Parent(), selection );
             
                CleanupStack::PushL(parentEntry);
                // Move the message
                TRAP_IGNORE( parentEntry->MoveL( msgId, KMsvSentEntryId ) );
                CleanupStack::PopAndDestroy(3,clientMtmReg); // parentEntry
		        }
			}
#endif             
		
        }
	WRITELOG("END CMessageMonitorPlugin::HandleMsgMovedL");	        
	}