void CTestImapFetchBody::CreateMessageStructureL(TMsvId aId)
	{
	//message root entry
	TMsvEntry entry1;
	entry1.iType = KUidMsvMessageEntry;
	entry1.iServiceId = KMsvLocalServiceIndexEntryId;
	entry1.iMtm = KUidMsgTypeIMAP4;
	iServerEntry->SetEntry(aId);
	iServerEntry->CreateEntry(entry1);
	iServerEntry->SetEntry(entry1.Id());
	iMsvMessageEntry=entry1.Id();

	//folder entry
	TMsvEntry folder;
	folder.iType = KUidMsvFolderEntry;
	folder.iMtm = KUidMsvLocalServiceMtm;
	folder.iServiceId = KMsvLocalServiceIndexEntryId;
	iServerEntry->SetEntry(iMsvMessageEntry);
	iServerEntry->CreateEntry(folder);
	iServerEntry->SetEntry(folder.Id());
	iFolderId=folder.Id();

	//body entry
	TMsvEntry bodyentry;
	bodyentry.iType = KUidMsvEmailTextEntry;
	bodyentry.iServiceId = KMsvLocalServiceIndexEntryId;
	bodyentry.iMtm = KUidMsgTypeIMAP4;
	bodyentry.iDetails.Set(KBodyDetails);
	iServerEntry->SetEntry(iFolderId);
	iServerEntry->CreateEntry(bodyentry);
	iServerEntry->SetEntry(bodyentry.Id());
	iBodyMessageEntry=bodyentry.Id();	
	}
Esempio n. 2
0
// -----------------------------------------------------------------------------
// CWPMessage::StoreMsgL
// -----------------------------------------------------------------------------
//
void CWPMessage::StoreMsgL()
    {
    FLOG( _L( "CWPMessage::StoreMsgL" ) );
    
    // create an invisible blank entry 
    TMsvEntry entry;
    PrepareEntryLC( entry ); // details on cleanup stack
    entry.iBioType = iBioUID.iUid;
    entry.iMtm = KUidBIOMessageTypeMtm;
    
    // Look up and set the description
    FLOG( _L( "CWPMessage::StoreMsgL 1" ) );
    
    TInt index;
    CBIODatabase* bioDB = CBIODatabase::NewLC( iSession->FileSession() );
    FLOG( _L( "CWPMessage::StoreMsgL 2" ) );
    TRAPD( err, bioDB->GetBioIndexWithMsgIDL( iBioUID, index ) );
    if (err ==KErrNone)
        {
        FLOG( _L( "CWPMessage::StoreMsgL 3" ) );
        HBufC* description = bioDB->BifReader(index).Description().AllocL();
        FLOG( _L( "CWPMessage::StoreMsgL 4" ) );
        entry.iDescription.Set(*description);
        FLOG( _L( "CWPMessage::StoreMsgL 5" ) );
        CleanupStack::PopAndDestroy();  // bioDB
        CleanupStack::PushL( description );
        }
    else
        {
        FTRACE(RDebug::Print(_L(" CWPMessage::StoreMsgL err (%d)"), err));
        CleanupStack::PopAndDestroy();  // bioDB
        }
        
    FLOG( _L( "CWPMessage::StoreMsgL 6" ) );
    // Store entry in inbox
    CMsvEntry* msvEntry = iSession->GetEntryL( KMsvGlobalInBoxIndexEntryId );
    FLOG( _L( "CWPMessage::StoreMsgL 7" ) );
    CleanupStack::PushL(msvEntry);
    msvEntry->CreateL(entry);
    msvEntry->Session().CleanupEntryPushL(entry.Id());
    msvEntry->SetEntryL(entry.Id());
    FLOG( _L( "CWPMessage::StoreMsgL 8" ) );
    // Save the message
    CMsvStore* store = msvEntry->EditStoreL();
    CleanupStack::PushL(store);
    FLOG( _L( "CWPMessage::StoreMsgL 9" ) );
    iMessage->StoreL( *store );
    store->CommitL();
    
    // Complete processing the message
    PostprocessEntryL( *msvEntry, entry );

    CleanupStack::PopAndDestroy(); //store
    msvEntry->Session().CleanupEntryPop(); //entry
    CleanupStack::PopAndDestroy(3); //description, details, msvEntry
    FLOG( _L( "CWPMessage::StoreMsgL Done" ) );
    }
Esempio n. 3
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
	}
void CSmsReplyToStep::CreateMessageL()
	{
	INFO_PRINTF1(_L("Creating message..."));
	
	TMsvEntry entry;
	entry.SetVisible(ETrue); 
	entry.SetInPreparation(ETrue); 
	entry.iServiceId = iTestUtils->iSmsServiceId; 
	entry.iType = KUidMsvMessageEntry; 
	entry.iMtm = KUidMsgTypeSMS; 
	entry.iDate.HomeTime(); 
	entry.iSize = 0; 
	entry.iDescription.Set(KNullDesC); 
	entry.iDetails.Set(KNullDesC); 
	entry.SetSendingState(KMsvSendStateScheduled);

	// Create the SMS header object...
	CSmsHeader* header = CSmsHeader::NewL(CSmsPDU::ESmsSubmit, *iTestUtils->iRichText);
	CleanupStack::PushL(header);
	
	// Set the body text...
	iTestUtils->iRichText->Reset();
	iTestUtils->iRichText->InsertL(0, KMessageData);
	
	// Copy the message settings...
	header->SetSmsSettingsL(*iTestUtils->iServiceSettings); 
	
	// Set the service centre
	TInt defaultIndex = iTestUtils->iServiceSettings->DefaultServiceCenter();
	header->SetServiceCenterAddressL(iTestUtils->iServiceSettings->GetServiceCenter(defaultIndex).Address());

	// Set recipient - ask derived class
	SetRecipientsL(*header);
	
	// Update entry description and details...
	CArrayPtrFlat<CSmsNumber>& recipient = header->Recipients();
	entry.iDetails.Set(recipient[0]->Address());
	entry.iDescription.Set(iTestUtils->iRichText->Read(0, iTestUtils->iServiceSettings->DescriptionLength()));
	entry.SetInPreparation(EFalse);
	
	// Create the entry - set context to the global outbox.
	iTestUtils->iMsvEntry->SetEntryL(KMsvGlobalOutBoxIndexEntryId);
	iTestUtils->iMsvEntry->CreateL(entry);

	// Create new store and save header information 
	iTestUtils->iMsvEntry->SetEntryL(entry.Id()); 
	CMsvStore* store = iTestUtils->iMsvEntry->EditStoreL(); 
	CleanupStack::PushL(store); 
	header->StoreL(*store);
	store->StoreBodyTextL(*iTestUtils->iRichText);
	store->CommitL(); 
	CleanupStack::PopAndDestroy(2, header); 
	
	iMessageId = entry.Id();

	}
Esempio n. 5
0
// -----------------------------------------------------------------------------
// CWPMessage::StoreMsgL
// -----------------------------------------------------------------------------
//
void CWPMessage::StoreMsgL( TInt aResource )
    {
    FLOG( _L( "CWPMessage::StoreMsgL(aResource)" ) );
    
    // create an invisible blank entry 
    TMsvEntry entry;
    PrepareEntryLC( entry ); // details on cleanup stack
    entry.iMtm = KUidMsgTypeSMS;     

    // Store entry in inbox
    CMsvEntry* msvEntry = iSession->GetEntryL(KMsvGlobalInBoxIndexEntryId);
    CleanupStack::PushL(msvEntry);
    msvEntry->CreateL(entry);
    msvEntry->Session().CleanupEntryPushL(entry.Id());
    msvEntry->SetEntryL(entry.Id());

    // Save the message body
    CMsvStore* store = msvEntry->EditStoreL();
    CleanupStack::PushL(store);
    CParaFormatLayer* paraFormat = CParaFormatLayer::NewL();
    CleanupStack::PushL( paraFormat );
    CCharFormatLayer* charFormat = CCharFormatLayer::NewL();
    CleanupStack::PushL( charFormat );
    CRichText* body = CRichText::NewL( paraFormat, charFormat );
    CleanupStack::PushL( body );
    HBufC* text = LoadStringLC( aResource );
    body->InsertL( body->DocumentLength(), *text );
    store->StoreBodyTextL( *body );

    // Store the actual message for post-mortem analysis
    iMessage->StoreL( *store );

    // Save the SMS header and create a description field
    CSmsHeader* header = CSmsHeader::NewL( CSmsPDU::ESmsDeliver, *body );
    CleanupStack::PushL( header );
    TBuf<KSmsDescriptionLength> description;

    CSmsGetDetDescInterface* smsPlugin = CSmsGetDetDescInterface::NewL();
    CleanupStack::PushL( smsPlugin );
    smsPlugin->GetDescription( header->Message(), description );
    CleanupStack::PopAndDestroy( smsPlugin );

    entry.iDescription.Set( description );
    header->StoreL( *store );
    store->CommitL();
    CleanupStack::PopAndDestroy( 5 ); // header, text, body, charformat, paraFormat

    // Complete processing the message
    PostprocessEntryL( *msvEntry, entry );

    CleanupStack::PopAndDestroy(); //store
    msvEntry->Session().CleanupEntryPop(); //entry
    CleanupStack::PopAndDestroy(2); //details, msvEntry
    }
Esempio n. 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
	}
/**
ConstructL()
Used to ensure that MMsvAttachmentManager is not destroyed until we want it to be.
To do this we need to preserve certain objects of CImEmailMessage, which if disappeared
would invalidate MMsvAttachmentManager. But this should be deleted in a controlled manner.

@param aSession
An object of type CMsvSession object.

@param aEntry
An object of type TMsvEntry used to get the entry ID. 
*/
void CAttachmentItem::ConstructL(CMsvSession& aSession, TMsvEntry aEntry)
	{
	iMsvEntry = aSession.GetEntryL(aEntry.Id());

	iMsvEntry->SetEntryL(aEntry.Id());
	iEmailMsg = CImEmailMessage::NewL(*iMsvEntry);
		
	CMsvOperationActiveSchedulerWait* waiter = CMsvOperationActiveSchedulerWait::NewLC();
 	iEmailMsg->GetAttachmentsListL(waiter->iStatus, aEntry.Id(),
								   CImEmailMessage::EAllAttachments, 
								   CImEmailMessage::EThisMessageOnly);
	waiter->Start();

	CleanupStack::PopAndDestroy(1, waiter); //waiter		
	}
// -----------------------------------------------------------------------------
// CMmsAdapterMsvApi::FindUserFolderL
// -----------------------------------------------------------------------------
//    
TBool CMmsAdapterMsvApi::FindUserFolderL( TMsvId aFolder, TPtrC& aName, TTime& aDate )
    {
    TBool found( EFalse );
    
    CMsvEntry* entry = iSession.GetEntryL( KMsvMyFoldersEntryIdValue );
    CleanupStack::PushL( entry );
     
    CMsvEntrySelection* selection = entry->ChildrenL();
    CleanupStack::PushL( selection );
    
    TMsvId serviceId;
    TMsvEntry entryT;

    for ( TInt i = 0; i < selection->Count(); i++ )
        {
        User::LeaveIfError( iSession.GetEntry( selection->At( i ), serviceId, entryT ) );
        
        if ( !entryT.Deleted() && entryT.iType == KUidMsvFolderEntry && entryT.Id() == aFolder )
            {
            found = ETrue;
            aDate = entryT.iDate;
            aName.Set( entryT.iDetails );
            break;
            }
        }
    
    CleanupStack::PopAndDestroy( selection );
    CleanupStack::PopAndDestroy( entry ); 
    
    return found;        
    }
void CBulkCommitServerMtm::ConstructL()
	{	
	// Get the entry id for the bulkcommit service entry.
	User::LeaveIfError(iServerEntry->SetEntry(KMsvRootIndexEntryId));
	CMsvEntrySelection* sel = new (ELeave) CMsvEntrySelection();
	CleanupStack::PushL(sel);
	User::LeaveIfError(iServerEntry->GetChildrenWithMtm(KUidBulkCommitTestMtm, *sel));
	TInt count = sel->Count();
	if( count > 1 )	// should only be one service entry
		{
		User::Leave(KErrCorrupt);
		}
	if( count == 0 )
		{
		// Create the settings
		TMsvEntry serviceEntry;
		serviceEntry.iType= KUidMsvServiceEntry;
		serviceEntry.iMtm = KUidBulkCommitTestMtm;

		User::LeaveIfError(iServerEntry->CreateEntry(serviceEntry));
		iServiceId = serviceEntry.Id();		
		}
	else
		{
		iServiceId = sel->At(0);
		}
	CleanupStack::PopAndDestroy(sel);	
	}
void CPopsTestHarness::DoLocalCopyTestL()
// Test copying a message locally.  ie create a message in the Drafts folder
// and copy it to a local sub folder
	{
	// Create the Message in the Drafts Folder
	iTestUtils->CreateMessageL(KTestMsgPath, KMsvDraftEntryId, KMsvDraftEntryId);
	CMsvServerEntry* serverEntry = iTestUtils->iServerEntry;
	serverEntry->SetEntry(KMsvDraftEntryId);
	CMsvEntrySelection* newMessageList = new (ELeave)CMsvEntrySelection();
	CleanupStack::PushL(newMessageList);
	serverEntry->GetChildren(*newMessageList);
	TMsvId newMessageId = (*newMessageList)[0];

	// Create  a local folder under the Drafts folder
	TMsvEntry parentEntry = serverEntry->Entry();
	TMsvEntry newFolder;
	newFolder.SetStandardFolder(ETrue);
	newFolder.iDetails.Set(KSubFolder);
	newFolder.iType.iUid=KUidMsvFolderEntryValue;
	newFolder.iMtm=parentEntry.iMtm;
	newFolder.iServiceId = parentEntry.iServiceId;
	serverEntry->CreateEntry(newFolder);

	// Fill the Disk Space and attempt to do the Copy
	FillDiskL();

	// Copy the message into the new LOCAL Sub-Folder
	CTestActive* active = new(ELeave) CTestActive;
	CleanupStack::PushL(active);
	serverEntry->CopyEntryL(newMessageId, newFolder.Id(), active->iStatus);
	active->StartL();
	CActiveScheduler::Start();

	CleanupStack::PopAndDestroy(2); // newMessageList, active
	}
// -----------------------------------------------------------------------------
// CMmsAdapterMsvApi::FindUserFolderL
// -----------------------------------------------------------------------------
//    
TBool CMmsAdapterMsvApi::FindUserFolderL( const TDesC& aName, TMsvId& aFolder )
    {
    CMsvEntry* entry = iSession.GetEntryL( KMsvMyFoldersEntryIdValue );
    CleanupStack::PushL( entry );
     
    CMsvEntrySelection* selection = entry->ChildrenL();
    CleanupStack::PushL( selection );
    
    TBool found( EFalse );
    TMsvId serviceId;
    TMsvEntry entryT;

    for ( TInt i = 0; i < selection->Count(); i++ )
        {
        User::LeaveIfError( iSession.GetEntry( selection->At( i ), serviceId, entryT ) );
        
        if ( !entryT.Deleted() && entryT.iType == KUidMsvFolderEntry && 
            aName.Compare(entryT.iDescription) == 0 )
            {
            found = ETrue;
            aFolder = entryT.Id();
            break;
            }
        }
    
    CleanupStack::PopAndDestroy( selection );
    CleanupStack::PopAndDestroy( entry );
    
    return found;           
    }
Esempio n. 12
0
/**
Creates a new entry as a child of the current context.

Ownership of the created entry is given to the process with the specified SID.

The parent ID and entry ID are set by the Message Server.

@param	aEntry
Index entry value for the new entry

@param	aOwnerId
The SID of the process that will own the create entry.

@param aBulk
A boolean value to indicate whether this is part of a bulk operation. (ETrue = bulk)

@return
KErrNone - success; KErrNoMemory - a memory allocation failed;
KErrNotSupported - aEntry is invalid
*/
EXPORT_C TInt CMsvServerEntry::CreateEntry(TMsvEntry& aEntry, TSecureId aOwnerId, TBool aBulk)
	{
	__ASSERT_DEBUG(iEntry.Id()!=KMsvNullIndexEntryId, PanicServer(EMsvEntryWithNoContext2));
	aEntry.SetParent(iEntry.Id());
	__ASSERT_DEBUG(MsvUtils::ValidEntry(aEntry, ETrue), PanicServer(EMsvBadEntryContents));

	// if valid - try to create the new child
	TInt error;
	if (iEntry.Id()==KMsvNullIndexEntryId || !MsvUtils::ValidEntry(aEntry, ETrue))
		error = KErrNotSupported;
	else
		{
		error = iServer.AddEntry(aEntry, aOwnerId, ETrue, aBulk);

		// if the child was created,then notify everyone, otherwise reset the parent
		if (error)
			aEntry.SetParent(KMsvNullIndexEntryId);
		else
			{
			if (!aBulk)
				{
				iServer.NotifyChanged(EMsvEntriesCreated, aEntry.Id(), aEntry.Parent());
				}
			iEntry.SetOwner(ETrue);
			}
		}

	return error;
	}
/**
GetMessagePartIndexL()
Retrieves the part index id for the email identified by aEntry

@param aEntry
A valid email identifier

@param aUid
An identifier tfor the type of message part to be retrieved

@return
TMsvId - message part identifier
*/
TMsvId CT_MsgComparePopEmailMsgs::GetMessagePartIndexL(TMsvEntry& aEntry, TUid aUid)
	{
	static TBool msgPartFound = EFalse;	
	TMsvId msgPartId = 0;
	CMsvEntry*	baseEntry  = iSharedDataPOP.iSession->GetEntryL(aEntry.Id());
	CleanupStack::PushL(baseEntry);
	CMsvEntrySelection*	selection =  baseEntry->ChildrenL();
	CleanupStack::PushL(selection);
	TInt count = selection->Count();
	TInt ind1;
	CMsvEntry* entry = iSharedDataPOP.iSession->GetEntryL(KMsvRootIndexEntryId);
	CleanupStack::PushL(entry);
	for (ind1=0, msgPartFound=EFalse; ind1 < count; ind1++)
		{
		if(msgPartFound)
			{
			break;
			}		
		TMsvId	childId  = selection->At(ind1);
		entry->SetEntryL(childId);

		if (entry->Entry().iType  == aUid)
			{
			msgPartId = childId;
			break;
			}
		else if (entry->Entry().iType  == KUidMsvFolderEntry)
			{
			TMsvEntry ent = entry->Entry();
			msgPartId = GetMessagePartIndexL(ent, aUid);
			}
		}
	CleanupStack::PopAndDestroy(3, baseEntry);  // entry,selection,baseEntry
	return msgPartId;
	}
Esempio n. 14
0
LOCAL_C void InitL()
	{
	// Connect to the file system...
	gFs.Connect();

	// Connect to the Message Server...
	pObserver = new (ELeave) CObserver();
	CleanupStack::PushL(pObserver);
	pSession = CMsvSession::OpenSyncL(*pObserver);
	CleanupStack::PushL(pSession);
	
	// Create a test entry with some dummy values so the Message Server
	// will not panic when the entry is created in the message store...
	pContext = CMsvEntry::NewL(*pSession, KMsvGlobalInBoxIndexEntryId, TMsvSelectionOrdering());
	CleanupStack::PushL(pContext);
	TMsvEntry testEntry;
	TUid entryMtm;
	entryMtm.iUid = 11;
	testEntry.iMtm = entryMtm;
	testEntry.iServiceId = pContext->OwningService();
	testEntry.iType = KUidMsvMessageEntry;
	
	// Create the entry in the message store and set the current context to it...
	pContext->CreateL(testEntry);
	gTestEntryId = testEntry.Id();
	pContext->SetEntryL(gTestEntryId);
	}
Esempio n. 15
0
/*
-----------------------------------------------------------------------------
----------------------------------------------------------------------------
*/
void CMailBoxContainer::GetFoldersL(void)
{
	iFolderArray.ResetAndDestroy();
	
	if(iSession)
	{	
		
		CMsvEntry *localServiceEntry = iSession->GetEntryL(KMsvLocalServiceIndexEntryId);
		CleanupStack::PushL(localServiceEntry);
		CMsvEntrySelection *folders = localServiceEntry->ChildrenWithTypeL(KUidMsvFolderEntry);
		CleanupStack::PushL(folders);

		for (TInt i = 0;i <  folders->Count();i++)
		{
			TMsvEntry ExtraFolder = localServiceEntry->ChildDataL((*folders)[i]);
			
			CMailFldItem* NewIttem = new(ELeave)CMailFldItem();
			CleanupStack::PushL(NewIttem);
			
			NewIttem->iTitle = ExtraFolder.iDetails.AllocL();
			NewIttem->iMscId = 	ExtraFolder.Id();

			CleanupStack::Pop();//NewIttem
			iFolderArray.Append(NewIttem);
		}
		
		CleanupStack::PopAndDestroy(2); // localServiceEntry, folders
	
	
		AddEmailFoldersL(iSession);
	}
}
Esempio n. 16
0
/*
-----------------------------------------------------------------------------
----------------------------------------------------------------------------
*/
void CMailBoxContainer::AddEmailFoldersL(CMsvSession* aSession)
{
	if(aSession)
	{	
		CMsvEntry *localServiceEntry = aSession->GetEntryL(KMsvRootIndexEntryId);//KMsvLocalServiceIndexEntryId);
		CleanupStack::PushL(localServiceEntry);
		CMsvEntrySelection *folders = localServiceEntry->ChildrenL();
		CleanupStack::PushL(folders);

		if(folders->Count() > 1) // first is local folder
		{
			for (TInt i = 1;i <  folders->Count();i++)
			{
				TMsvEntry ExtraFolder = localServiceEntry->ChildDataL((*folders)[i]);
				
				CMailFldItem* NewIttem = new(ELeave)CMailFldItem();
				CleanupStack::PushL(NewIttem);
					
				NewIttem->iTitle = ExtraFolder.iDetails.AllocL();
				NewIttem->iMscId = 	ExtraFolder.Id();
			
				CleanupStack::Pop();//NewIttem
				iFolderArray.Append(NewIttem);
			}
		}
		
		CleanupStack::PopAndDestroy(2); // localServiceEntry, folders
	}
}
Esempio n. 17
0
void CT_CMsvSession::TestIncPcSyncCountL()
	{
	TInt error = KErrGeneral;
	INFO_PRINTF1(_L("Testing: Increment PC Sync Count -- 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;
	TRAP(error, iSession->IncPcSyncCountL(*selection);)
Esempio n. 18
0
void CPigeonServerMtm::ConstructL()
{
    iScheduleSend = CPigeonScheduledSend::NewL(*iServerEntry);

    // Get the entry id for the pigeon service entry.
    User::LeaveIfError(iServerEntry->SetEntry(KMsvRootIndexEntryId));
    CMsvEntrySelection* sel = new (ELeave) CMsvEntrySelection();
    CleanupStack::PushL(sel);
    User::LeaveIfError(iServerEntry->GetChildrenWithMtm(KUidMsgTypePigeon, *sel));
    TInt count = sel->Count();
    if( count > 1 )	// should only be one service entry
        User::Leave(KErrCorrupt);
    if( count == 0 )
    {
        // Create the settings
        TMsvEntry serviceEntry;
        serviceEntry.iType= KUidMsvServiceEntry;
        serviceEntry.iMtm = KUidMsgTypePigeon;

        User::LeaveIfError(iServerEntry->CreateEntry(serviceEntry));
        iServiceId = serviceEntry.Id();
    }
    else
    {
        iServiceId = sel->At(0);
    }
    CleanupStack::PopAndDestroy(sel);
    User::LeaveIfError(iServerEntry->SetEntry(KMsvNullIndexEntryId));
    iHeapFailure = EFalse;
}
Esempio n. 19
0
void CEmailNotificationParser::ParseL(TRequestStatus& aStatus, const TDesC& aSms)
    {
    TMsvEntry entry = iEntry.Entry();   //  Get the generic stuff
    iEntryId = entry.Id();              //  store the TMsvId

    __ASSERT_DEBUG((entry.MtmData3() == 0 || entry.MtmData3() == 1),
                            User::Panic(_L("ENP-DLL"),KErrCorrupt));
    //  Already parsed....
    if(entry.MtmData3() == 1)
        {
        iReport = &aStatus;
        User::RequestComplete(iReport, KErrNone);
        }
    //  not parsed
    else if(entry.MtmData3() == 0)
        {
        if (iSmsBuf != NULL)
            {
            delete iSmsBuf;
            iSmsBuf = NULL;
            }
        iSmsBuf = aSms.AllocL();            // Allocate new HBufC object
        ChangeStateL(EUnfoldMessage);       //Set to initial request
        aStatus = KRequestPending;
        iReport = &aStatus;
        }
    else
        {
        User::Leave(KErrNotSupported);
        }
    }
Esempio n. 20
0
/**
Tells the scheduler that sending is complete.

This function must be called when a message that had previously been scheduled 
is either sent or has failed. This function:

1. Deletes the TMsvEntryScheduleData associated with the message

2. Sets the Scheduled flag to EFalse

3. If required, calls ChangeEntry() on the message server entry

Note: SendingCompleteL() does not change the sending state of each message, 
nor delete each message from the task scheduler.

@param aEntry 
The message which was either successfully sent or which failed (all the 
attempts) to send. It is not a precondition that the message has already 
been scheduled on the task scheduler.

@param aChangeEntry 
If aChangeEntry is ETrue then SendingCompleteL() will call 
CMsvServerEntry::ChangeEntry() to update the message on the message server. 

@panic ScheduleSend-DLL 24
The server entry is not set to the correct entry.
Debug build only.
*/
EXPORT_C void CMsvScheduleSend::SendingCompleteL(TMsvEntry& aEntry, const TBool aChangeEntry)
	{
	__ASSERT_DEBUG(iServerEntry.Entry().Id() == aEntry.Id(), gPanic(EServerEntryNotSetToCorrectEntry));

	CMsvScheduledEntry* schEntry = GetMessageL(aEntry.Id());
	CleanupStack::PushL(schEntry);

	SendingCompleteL(*schEntry, EFalse);
	schEntry->Entry(aEntry);

	if (aChangeEntry)
		{
		User::LeaveIfError(iServerEntry.ChangeEntry(aEntry));
		}

	CleanupStack::PopAndDestroy(); //schEntry
	}
Esempio n. 21
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"));
	}
// ---------------------------------------------------------
// GetOutboxEntries()
// Outgoing Pending message/messages
// ---------------------------------------------------------
TInt MsgStoreHandler::GetOutboxEntriesL(MsgInfo& aFailedIndicatorData,
    MsgInfo& aPendingIndicatorData)
{
    CMsvEntry* rootEntry = iMsvSession->GetEntryL(KMsvGlobalOutBoxIndexEntryId);
    CMsvEntrySelection* messages = rootEntry->ChildrenL();

    TInt failedMessageCount = 0;
    TInt pendingMessageCount = 0;

    for (TInt i = 0; i < messages->Count(); ++i) {
        TMsvEntry entry = rootEntry->ChildDataL(messages->At(i));
        if ((entry.iMtm != KSenduiMtmSmsUid) && (entry.iMtm != KSenduiMtmMmsUid)) {
            continue;
        }

        if (entry.SendingState() == KMsvSendStateFailed) {
            ++failedMessageCount;
        }
        else {
            ++pendingMessageCount;
        }

        if (entry.SendingState() == KMsvSendStateFailed) {
            ProcessIndicatorDataL(entry.Id(), aFailedIndicatorData);
        }
        else {
            ProcessIndicatorDataL(entry.Id(), aPendingIndicatorData);
        }
       
    }

    aFailedIndicatorData.mFromSingle = (failedMessageCount > 1) ? false : true;
    aPendingIndicatorData.mFromSingle = (pendingMessageCount > 1) ? false : true;
    aFailedIndicatorData.mIndicatorType = FailedIndicatorPlugin;
    aPendingIndicatorData.mIndicatorType = PendingIndicatorPlugin;
    aFailedIndicatorData.mMsgCount = failedMessageCount;
    aPendingIndicatorData.mMsgCount = pendingMessageCount;

    return KErrNone;
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// 
void CIpsSosAOImapPopLogic::HandleMsvSessionEventL(
     MMsvSessionObserver::TMsvSessionEvent aEvent, 
     TAny* aArg1, TAny* aArg2, TAny* /*aArg3*/ )
    {
    FUNC_LOG;
    switch( aEvent )
        {
        case MMsvSessionObserver::EMsvEntriesCreated:
            handleEntriesCreatedL(aArg1);
            break;
        case MMsvSessionObserver::EMsvEntriesChanged:
            {
            TMsvId parent = (*(TMsvId*) (aArg2));
            //we check that parent is the root. if not, it cannot be an 
            //event from service, thus can't be from connection change..
            if ( parent == KMsvRootIndexEntryId )
                {
                const CMsvEntrySelection* selection = 
                    static_cast<CMsvEntrySelection*>( aArg1 );
                
                TMsvEntry tEntry;
                TMsvId service;
                if ( selection->Count() )
                    {
                    iSession.GetEntry( selection->At(0), service, tEntry );
                    }
                
                if ( !tEntry.Connected() )
                    {
                    SendCommandToSpecificMailboxL( 
                            tEntry.Id(), 
                            CIpsSosAOMBoxLogic::ECommandClearDoNotDisconnect );
                    }
                }
            }
            break;
        case MMsvSessionObserver::EMsvEntriesDeleted:
            {
            TMsvId parent = (*(TMsvId*) (aArg2));
            //we check that parent is the root. if not, it cannot be an 
            //event indicating deleted mailbox entry
            if ( parent == KMsvRootIndexEntryId )
                {
                RemoveOrphanLogicsL();
                }
            }
            break;
        case MMsvSessionObserver::EMsvEntriesMoved:
        default:
            break;
        };
    }
Esempio n. 24
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();
    }
Esempio n. 25
0
EXPORT_C TMsvId CMsvTestUtils::CreateServiceL(const TUid aMtm, TBool aReadOnly, TBool aVisible)
	{
	TMsvId id = 0;
	TMsvEntry entry;
	entry.iMtm = aMtm;
	entry.iType = KUidMsvServiceEntry;
	entry.SetReadOnly(aReadOnly);
	entry.SetVisible(aVisible);
	
	SetEntryL(KMsvRootIndexEntryId);
	CreateEntryL(entry);
	id = entry.Id();
	SetEntryL(id);
	return id;
	}
Esempio n. 26
0
TVerdict CTestUTCSort::TestSortingL()
	{
	
	TVerdict result=EPass;
	//create ordering objects
	TMsvSelectionOrdering ordering;	
	ordering.SetSorting(EMsvSortByDate);
	
	//sort the gloabl inbox by date
	CMsvEntry* inboxEntry = CMsvEntry::NewL(*iSession, KMsvDraftEntryIdValue,ordering);
	CleanupStack::PushL(inboxEntry);
	
	//retrieve the children of the inbox
	CMsvEntrySelection* msvEntrySelection;
	msvEntrySelection=inboxEntry->ChildrenL();
	CleanupStack::PushL(msvEntrySelection);
	
	CMsvEntry* child;
	TMsvEntry childDetails;
	TBuf<45> dateTimeString;
	
	//look at the id of each child and test its id, these should
	//be in the order the entries were created.
	for(TInt i=0;i<KNumEmailMessages;++i)
		{
		child=iSession->GetEntryL((*msvEntrySelection)[i]);
		childDetails=child->Entry();
		delete child;

		//print the time of the entry to the log file		
		dateTimeString.Zero();
		FormatDateTime(dateTimeString,childDetails.iDate); 
		INFO_PRINTF2(_L("%S"),&dateTimeString);
				
		if(childDetails.Id()!=iTMsvIdList->At(i))
			{
			ERR_PRINTF1(_L("Entries in wrong order"));	
			result=EFail;
			break;
			}
		}

	CleanupStack::PopAndDestroy(msvEntrySelection);
	CleanupStack::PopAndDestroy(inboxEntry);

	return result;
	
	}
Esempio n. 27
0
TBool CTxtiMtmUiData::CanCreateEntryL(const TMsvEntry& aParent, TMsvEntry& aNewEntry, 
									  TInt& aReasonResourceId) const
	{
	__ASSERT_ALWAYS(aNewEntry.iMtm==KUidMsgTypeText, Panic(ETxtiMtmUdWrongMtm));
	__ASSERT_ALWAYS(aNewEntry.iType!=KUidMsvAttachmentEntry, Panic(ETxtiMtmUdAttachmentsNotSupported));

	aReasonResourceId=0;
	// --- Can create services if they are off root ---
	if (aNewEntry.iType == KUidMsvServiceEntry)
		return (aParent.Id() == KMsvRootIndexEntryIdValue);

	// --- Can create messages in local folders ---
	if (aNewEntry.iType == KUidMsvMessageEntry)
		return (aParent.iMtm.iUid == KMsvLocalServiceIndexEntryIdValue);

	return KErrNotSupported;
	}
TMsvId TestUniDataModelVCalPlugin::SetBIOServiceIdL()
{
		//  Haven't found an entry so create a BIO Message service:
		TMsvEntry bioServiceEntry;
		bioServiceEntry.iMtm = KUidBIOMessageTypeMtm;
		bioServiceEntry.iType = KUidMsvServiceEntry;
		bioServiceEntry.SetVisible(EFalse);
		bioServiceEntry.iDate.UniversalTime();
		bioServiceEntry.iDescription.Set(_L("BIO Message Service ")); // Is there such a thing?
		bioServiceEntry.iDetails.Set(_L("BIO Message Service"));

		TMsvId newBIOServiceId;

		iMsvEntry->SetEntryL(KMsvRootIndexEntryId);
		iMsvEntry->CreateL(bioServiceEntry); // Needs to be a child of the root!
		newBIOServiceId = bioServiceEntry.Id();

    return newBIOServiceId;
}
Esempio n. 29
0
EXPORT_C void CMsvTestUtils::DisplayChildL(const TMsvEntry& entry)
	{
	_LIT(KSpace, " ");
	_LIT(KQuote, "\"");
	HBufC* buf = HBufC::NewLC(entry.iDetails.Length() + entry.iDescription.Length() + 100);
	TPtr temp(buf->Des());
	temp.AppendFormat(_L("%7.7d"), entry.Id());
	temp.Append(KSpace);

	switch (entry.iType.iUid)
		{
		case KUidMsvServiceEntryValue:
			temp.Append(_L("Serv"));
			break;
		case KUidMsvRootEntryValue:
			temp.Append(_L("Root"));
			break;
		case KUidMsvFolderEntryValue:
			temp.Append(_L("Fold"));
			break;
		case KUidMsvMessageEntryValue:
			temp.Append(_L("Mesg"));
			break;
		case KUidMsvAttachmentEntryValue:
			temp.Append(_L("Atch"));
			break;
		default:
			temp.Append(_L("Othr"));
			break;
		}

	temp.Append(KSpace);
	temp.Append(KQuote);
	temp.Append(entry.iDetails);
	temp.Append(KQuote);
	temp.Append(_L(" Mtm: "));
	temp.AppendNum((TInt) entry.iMtm.iUid);
	temp.Append(_L(" Des: "));
	temp.Append(entry.iDescription.Left(10));

	iRTest.Printf(temp);
	CleanupStack::PopAndDestroy(buf);
	}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
void CIpsSosAOImapPopLogic::handleEntriesCreatedL(const TAny* aArg1)
    {
    FUNC_LOG;
    TMsvEntry entry;
    getFirstEntryFromSelectionL(static_cast<const CMsvEntrySelection*>(aArg1), entry);

    if( entry.iMtm==KSenduiMtmImap4Uid || entry.iMtm==KSenduiMtmPop3Uid)
        {
        // handling imap4 or pop3 entry
        if(entry.iType.iUid==KUidMsvServiceEntryValue)
            {
            // new mailbox has been created, starting sync for it
            User::After(KMailboxCreatedTimeout); // sleep for 0.5 sec; guarantees that mailbox is fully set up, and message server ready to serve it
            RefreshMailboxListL();
            SendCommandToSpecificMailboxL( entry.Id(), CIpsSosAOMBoxLogic::ECommandStart );
            SendCommandToSpecificMailboxL( entry.Id(), CIpsSosAOMBoxLogic::ECommandStartSync );
            }
        }
    }