예제 #1
0
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);
	}
int MsgStoreHandler::GetUnreadMessageCountL()
{
    //Create  the query/operation object
    CMsvSearchSortOperation *operation = CMsvSearchSortOperation::NewL(*iMsvSession);
    CleanupStack::PushL(operation);
    CMsvSearchSortQuery *query = CMsvSearchSortQuery::NewL();
    CleanupStack::PushL(query);

    //set the query options
    query->SetParentId(KMsvGlobalInBoxIndexEntryId);
    query->SetResultType(EMsvResultAsTMsvEntry);
    query->AddSearchOptionL(EMsvUnreadMessages, ETrue);
    CleanupStack::Pop(query);

    CMsvOperationWait* wait = CMsvOperationWait::NewLC();
    //ownership of Query transferred to Operation  
    operation->RequestL(query, EFalse, wait->iStatus);
    wait->Start();
    CActiveScheduler::Start();

    //Get No of entries
    int count = operation->GetResultCountL();
    CleanupStack::PopAndDestroy(2, operation);

    return count;
}
예제 #3
0
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
	}
예제 #4
0
TMsvId CFakeSMSSender::CreateNewMessageL(TTime aMsgTime)
{
    CMsvEntry* Draftentry = CMsvEntry::NewL(*iMsvSession, KMsvDraftEntryIdValue ,TMsvSelectionOrdering());
  	CleanupStack::PushL(Draftentry);

    CMsvOperationWait* wait = CMsvOperationWait::NewLC();
    wait->Start();
    
	TMsvEntry newEntry;              // This represents an entry in the Message Server index
    newEntry.iMtm = KUidMsgTypeSMS;                         // message type is SMS
 	newEntry.iType = KUidMsvMessageEntry; //KUidMsvServiceEntry                  // this defines the type of the entry: message 
 	newEntry.iServiceId = KMsvLocalServiceIndexEntryId; //    // ID of local service (containing the standard folders)
   	newEntry.iDate = aMsgTime;                              // set the date of the entry to home time
	newEntry.SetInPreparation(ETrue);                       // a flag that this message is in preparation
	newEntry.SetReadOnly(EFalse);					
		
	CMsvOperation* oper = Draftentry->CreateL(newEntry,wait->iStatus);
    CleanupStack::PushL(oper);
    CActiveScheduler::Start();

    while( wait->iStatus.Int() == KRequestPending )
    {
        CActiveScheduler::Start();
    }

    
    // ...and keep track of the progress of the create operation.
    TMsvLocalOperationProgress progress = McliUtils::GetLocalProgressL(*oper);
    User::LeaveIfError(progress.iError);
//	Draftentry->MoveL(progress.iId,KMsvGlobalInBoxIndexEntryId);

	CleanupStack::PopAndDestroy(3);//Draftentry,wait,oper
	
    return progress.iId;
 }
예제 #5
0
LOCAL_C void TestNotifyBug2L()
	{
	CDummyObserver* ob = new(ELeave)CDummyObserver;
	CleanupStack::PushL(ob);

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

	// Create the first CMsvEntry sitting on drafts
	CMsvEntry* cEntry1 = CMsvEntry::NewL(*session, KMsvDraftEntryId, TMsvSelectionOrdering(0, EMsvSortByNone, ETrue));
	CleanupStack::PushL(cEntry1);

	// Add an observer to the first CMsvEntry
	CEntryObserver* eOb1 = new(ELeave)CEntryObserver;
	CleanupStack::PushL(eOb1);
	cEntry1->AddObserverL(*eOb1);

	// Create another CMsvEntry sitting on drafts
	CMsvEntry* cEntry2 = CMsvEntry::NewL(*session, KMsvDraftEntryId, TMsvSelectionOrdering());
	CleanupStack::PushL(cEntry2);

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

	// Wait for create notification to be received by the first CMsvEntry
	eOb1->Start();
	CActiveScheduler::Start();

	// Change the entry in drafts
	// This queues a change notification in the server
	// It is waiting to be handled by all the observers
	cEntry2->SetEntryL(entry.Id());
	cEntry2->ChangeL(entry);
	cEntry2->SetEntryL(KMsvDraftEntryId);

	// Start an asynchronous delete using the second CMsvEntry
	CMsvOperationWait* wait = CMsvOperationWait::NewLC();
	wait->Start();
	CMsvOperation* op = cEntry2->DeleteL(entry.Id(), wait->iStatus);
	CleanupStack::PushL(op);

	// The first CMsvEntry is out of date because it hasn't been told that the entry has been deleted from drafts yet
	// Switching the CMsvEntry in and out of drafts forces it to be up to date
	// But there is still a change notification waiting to be handled
	cEntry1->SetEntryL(KMsvRootIndexEntryId);
	cEntry1->SetEntryL(KMsvDraftEntryId);

	// The first CMsvEntry is now up to date, but in the next CActiveScheduler::Start() it receives a change notification
	// for a child that doesn't exist
	CActiveScheduler::Start();

	CleanupStack::PopAndDestroy(7); // op, wait, cEntry2, eOb1, cEntry1, session, ob
	}
예제 #6
0
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"));
	}
예제 #7
0
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;
	}