void CMtfTestActionSetUserResponse::ExecuteActionL()
	{	
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionSetUserResponse);
	CMsvSession* paramSession = ObtainParameterReferenceL<CMsvSession> (TestCase(),ActionParameters().Parameter(0));	
	TInt paramUserResponse = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(1),EFalse);
	
	CMsvEntry* cEntry = CMsvEntry::NewL(*paramSession, KMsvDraftEntryId, 
						TMsvSelectionOrdering(KMsvNoGrouping,EMsvSortByNone,ETrue));
	CleanupStack::PushL(cEntry);
	
	CMsvEntrySelection* selection = cEntry->ChildrenL();
	CleanupStack::PushL(selection);

	TestCase().INFO_PRINTF2(_L("Count of Draft Folder's selection is %d"),selection->Count());
	
	if (selection->Count() == 0)
	{	
	User::Leave(KErrNotFound);
	}
	
	cEntry->SetEntryL((*selection)[0]);

	if (!paramUserResponse)
	{	
	TMsvEntry entry = cEntry->Entry();
	entry.iError = KErrCancel;
	cEntry->ChangeL(entry);
	}
	
	CleanupStack::PopAndDestroy(2);
	
	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionSetUserResponse);
	TestCase().ActionCompletedL(*this);
	}
// ----------------------------------------------------------------------------
// CIpsPlgNewChildPartFromFileOperation::PrepareMsvEntryL
// ----------------------------------------------------------------------------
//
void CIpsPlgNewChildPartFromFileOperation::PrepareMsvEntryL()
    {
    // Dig out the entry ID of the new attachment
    iMessage->GetAttachmentsListL( iEntry->Entry().Id( ), 
        CImEmailMessage::EAllAttachments, CImEmailMessage::EThisMessageOnly );
    TKeyArrayFix key( 0, ECmpTInt32 );
    CMsvEntrySelection* attachmentIds = iMessage->Selection().CopyLC();
    attachmentIds->Sort( key );
    if ( !attachmentIds->Count() )
        {
        User::Leave( KErrGeneral );
        }
    iNewAttachmentId = (*attachmentIds)[ attachmentIds->Count()-1 ];
    CleanupStack::PopAndDestroy( attachmentIds );
    
    CMsvEntry* cAtta = iMsvSession.GetEntryL( iNewAttachmentId );
    CleanupStack::PushL( cAtta );
    
    // Set filename to iDetails
    TMsvEntry tEntry = cAtta->Entry();
    tEntry.iDetails.Set(iFilePath->Des());

    // Do async
    iOperation = cAtta->ChangeL( tEntry, iStatus );
    CleanupStack::PopAndDestroy( cAtta );
    iStep = EPrepareStore; // Next step
    SetActive();
    }
// -----------------------------------------------------------------------------
// CMmsAdapterMsvApi::UpdateUserFolderL
// Updates user folder (changes name)
// -----------------------------------------------------------------------------    
TInt CMmsAdapterMsvApi::UpdateUserFolderL( TMsvId aFolder, const TDesC& aName )
    {
    TRACE_FUNC_ENTRY;
    LOGGER_WRITE_1( "aName: %S", &aName );
    
    CMsvEntry* entry = iSession.GetEntryL( aFolder );
    CleanupStack::PushL( entry );
    
    TMsvEntry tEntry = entry->Entry();
    
    if ( tEntry.iType != KUidMsvFolderEntry )
        {
        CleanupStack::PopAndDestroy( entry );
        LOGGER_WRITE( "No message folder" );
        TRACE_FUNC_EXIT;
        return KErrNotSupported;
        }
       
    tEntry.iDetails.Set( aName );   
    tEntry.iDescription.Set( aName );
    
    entry->ChangeL( tEntry );
    
    CleanupStack::PopAndDestroy( entry );
    
    TRACE_FUNC_EXIT;
    return KErrNone;
    } 
Exemplo n.º 4
0
// -----------------------------------------------------------------------------
// CWPMessage::PostprocessEntryL
// -----------------------------------------------------------------------------
//
void CWPMessage::PostprocessEntryL( CMsvEntry& aCEntry, TMsvEntry& aTEntry )
    {
    FLOG( _L( "CWPMessage::PostprocessEntryL" ) );
    
    aTEntry.SetReadOnly(EFalse);
    aTEntry.SetVisible(ETrue);
    aTEntry.SetInPreparation(EFalse);
    aCEntry.ChangeL(aTEntry);
    }
Exemplo n.º 5
0
void CMsvSendExe::UpdateEntryL(CMsvEntry& aMsvEntry, TMsvEntry& aEntry, const TSchedulerItemRef& aRef, const TTaskInfo& aInfo, const TTime& aStartTime)
	{
	CMsvStore* store = aMsvEntry.EditStoreL();
	CleanupStack::PushL(store);

	TMsvEntryScheduleData data;
	data.RestoreL(*store);

	CMsvScheduleSend::UpdateEntryAfterSchedule(aRef, aInfo, aStartTime, KMsvSendStateResend, aEntry, data);

	data.StoreL(*store);
	store->CommitL();

	CleanupStack::PopAndDestroy(store);
	aMsvEntry.ChangeL(aEntry);
	}
Exemplo n.º 6
0
void CMsvSendExe::AddTaskL(const TMsvSchedulePackage& aPackage)
	{
	CMsvEntry* cEntry = NULL;
	TRAPD(err, cEntry = iSession->GetEntryL(aPackage.iId));

	if (err != KErrNotFound)
		{
		User::LeaveIfError(err);
		CleanupStack::PushL(cEntry);

		TMsvEntry entry = cEntry->Entry();
		const TInt sendState = entry.SendingState();

		//Only send the message if sending state is Scheduled or Resend.
		if (entry.Scheduled() && (sendState == KMsvSendStateScheduled || sendState == KMsvSendStateResend))
			{
			entry.SetSendingState(KMsvSendStateWaiting);

			// Fix for DEF000924: Need to be able to send/cancel an sms while another is being sent
			if (entry.iServiceId == KMsvLocalServiceIndexEntryId && entry.iRelatedId != KMsvNullIndexEntryId)
				{
				SCHSENDLOG(  FLog(iFileName, _L("Changing service from %x to %x"), entry.iServiceId, entry.iRelatedId));
				entry.iServiceId = entry.iRelatedId;
				}
			else
				{
				SCHSENDLOG(  FLog(iFileName, _L("Not changing service from %x (related=%x)"), entry.iServiceId, entry.iRelatedId));
				}
			// End of fix

 			cEntry->ChangeL(entry);
			AddTaskL(aPackage, entry.iMtm);
			SCHSENDLOG(FLog(iFileName, _L("\t\tMsg=%d [Mtm=%d SendState=%d]"), aPackage.iId, entry.iMtm.iUid, entry.SendingState()));
			}
		else
			{
			SCHSENDLOG(FLog(iFileName, _L("\t\tIGNORING Msg=%d (Mtm=%d SendState=%d Scheduled=%d)"), aPackage.iId, entry.iMtm.iUid, sendState, entry.Scheduled()));
			}

		CleanupStack::PopAndDestroy(cEntry);
		}
	else
		{
		SCHSENDLOG(FLog(iFileName, _L("\t\tIGNORING Msg=%d: NOT FOUND"), aPackage.iId));
		}
	}
Exemplo n.º 7
0
void CMsvSendExe::FailOnError(const CMsvEntrySelection& aSelection, TInt aError)
	{
	if (iSession == NULL)
		return;

	TInt selCount = aSelection.Count();
	TInt err = KErrNone;
	CMsvEntry* cEntry = NULL;

	while (selCount--)
		{
		const TMsvId id = aSelection[selCount];
		TRAP(err, cEntry = iSession->GetEntryL(id));
		//no need for the cleanup stack

		if (err == KErrNone)
			{
			TMsvEntry entry(cEntry->Entry());
			switch (entry.SendingState())
				{
				case KMsvSendStateWaiting:
				case KMsvSendStateScheduled:
				case KMsvSendStateResend:

					if (entry.iDate < iCreated)
						{
						//Message has not been rescheduled
						entry.SetSendingState(KMsvSendStateFailed);
						entry.SetScheduled(EFalse);
						entry.SetFailed(ETrue);
						entry.iError = aError;
						TRAP(err, cEntry->ChangeL(entry)); //ignore error
						}

					break;

				default:
					break;
				}

			delete cEntry;
			cEntry = NULL;
			} //end if
		} //end while
	}
Exemplo n.º 8
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);
}
// -----------------------------------------------------------------------------
// 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;
    }   
// ----------------------------------------------------------------------------
// CIpsPlgNewChildPartFromFileOperation::PrepareStoreL
// ----------------------------------------------------------------------------
//
void CIpsPlgNewChildPartFromFileOperation::PrepareStoreL()
    {
    CMsvEntry* cAtta = iMsvSession.GetEntryL( iNewAttachmentId );
    CleanupStack::PushL( cAtta );
    TBool parentToMultipartAlternative( EFalse );
    if( cAtta->HasStoreL() )
        {
        CMsvStore* store = cAtta->EditStoreL();
        CleanupStack::PushL( store );
        CImMimeHeader* mimeHeader = CImMimeHeader::NewLC();
        
        if( store->IsPresentL( KUidMsgFileMimeHeader ) )
            {
            mimeHeader->RestoreL( *store );
            CDesC8Array& array = mimeHeader->ContentTypeParams();
            array.AppendL( KMethod );
            parentToMultipartAlternative = ETrue;
            
            if( iContentType->Des().Find( KMimeTextCalRequest ) != KErrNotFound )
                {    
                array.AppendL( KRequest );
                }
            else if( iContentType->Des().Find( KMimeTextCalResponse ) != KErrNotFound )
                {
                array.AppendL( KResponse );
                }
            else if( iContentType->Des().Find( KMimeTextCalCancel ) != KErrNotFound ) 
                {
                array.AppendL( KCancel );
                }
            else
                {
                parentToMultipartAlternative = EFalse;
                }
            mimeHeader->StoreWithoutCommitL( *store );
            store->CommitL();
            }
        
        CleanupStack::PopAndDestroy( 2, store );
        }

    if( parentToMultipartAlternative &&
        iFilePath->Find( KFileExtensionICS ) != KErrNotFound )
        {        
        TMsvEntry tAttaEntry = cAtta->Entry();
        TMsvId id = tAttaEntry.Parent();
        CMsvEntry* cParent = iMsvSession.GetEntryL( id );
        CleanupStack::PushL( cParent );
        
        TMsvEmailEntry tEntry = cParent->Entry();
        tEntry.SetMessageFolderType( EFolderTypeAlternative );
        
        // Do async again if needed

        iOperation = cParent->ChangeL( tEntry, iStatus );
        CleanupStack::PopAndDestroy( cParent );
        CleanupStack::PopAndDestroy( cAtta );
        }
    else
        {
        CleanupStack::PopAndDestroy( cAtta );
        iStatus = KRequestPending;
        TRequestStatus* status = &iStatus;
        User::RequestComplete(status,KErrNone);
        }
    iStep = EStoreMessagePart; // Next step
    SetActive();
    }
/**
  Function : doTestStepL
  Description : Sets the priority of an email message via the IMAP \Flagged flag
  @return : TVerdict - Test step result
*/
TVerdict CT_MsgSetImap4EmailPriority::doTestStepL()
	{
	INFO_PRINTF1( _L("Test Step : SetSmtpEmailPriority") );
	if (ReadIni())
		{
		TMsvId parentFolderId;
		// Local parent folder location...
		if(iLocation.Compare(_L("LOCAL"))==0)
			{
			// Retrieves the folder Id based on the local folder name read from the ini file
			parentFolderId = CT_MsgUtilsEnumConverter::FindFolderIdByName(iParentFolderName);
			if(parentFolderId == KErrNotFound)
				{
				ERR_PRINTF1(_L("Invalid local parent folder name specified"));
				SetTestStepResult(EFail);
				return TestStepResult();
				}
			INFO_PRINTF2(_L("The local parent folder Id is %d"),parentFolderId);
			}
		// Remote parent folder location...
		else if(iLocation.Compare(_L("REMOTE"))==0)
			{
			TRAPD(err,parentFolderId = CT_MsgUtils::GetRemoteFolderIdByNameL(iSharedDataIMAP.iSession, iImapAccountName, iParentFolderName));
			if(err == KErrNotFound)
				{
				ERR_PRINTF1(_L("Invalid remote parent folder name specified"));
				SetTestStepResult(EFail);
				return TestStepResult();
				}	
			INFO_PRINTF2(_L(" The remote parent folder Id is %d"),parentFolderId);
			}
		// Location Local or Remote not specified...
		else
			{
			ERR_PRINTF1(_L("Invalid parent folder location"));
			SetTestStepResult(EFail);
			return TestStepResult();
			}
			
		// Retrieves the message Id based on the message subject of the email under the given parent folder
		TMsvId	messageId;
		TRAPD(err,messageId = CT_MsgUtils::SearchMessageBySubjectL(iSharedDataIMAP.iSession, parentFolderId, iEmailSubject));
		if(err == KErrNotFound)
			{
			ERR_PRINTF1(_L("The given message is not found"));
			SetTestStepResult(EFail);
			}
		// Message found	
		else
			{
			INFO_PRINTF2(_L("The Message Id is %d"),messageId);

			// Retrieve the default Smtp service Id
			TMsvId smtpServiceId(0);
			TRAPD(err, smtpServiceId = CT_MsgUtilsCentralRepository::GetDefaultSmtpServiceIdL());
			if(err != KErrNone)
				{
				ERR_PRINTF2(_L("Failure while getting the default SMTP Service Id. Error = %d"),err);
				SetTestStepResult(EFail);
				}
			else
				{
				INFO_PRINTF2(_L("The Default Smtp Service Id is %d"),smtpServiceId);
				
				CT_MsgActive& active = Active();
				delete iOperation;
				iOperation=NULL;
				
				// Setting the current context to the parent of the mesage
				CMsvEntry*	entry = CMsvEntry::NewL(*iSharedDataIMAP.iSession, messageId, TMsvSelectionOrdering());
				CleanupStack::PushL(entry);
				
				TMsvEmailEntry emailEntry(entry->Entry());
				
				if(iEmailPriority==1)
					{
					emailEntry.SetFlaggedIMAP4Flag(ETrue);
					iOperation = entry->ChangeL(emailEntry,active.iStatus);
					active.Activate();
					CActiveScheduler::Start();
					User::LeaveIfError(active.Result());
					INFO_PRINTF1(_L("The state of the Flagged IMAP4 flag of the email is set for urgent/special attention"));
					}
				else if (iEmailPriority==0)
					{
					emailEntry.SetFlaggedIMAP4Flag(EFalse);
					iOperation = entry->ChangeL(emailEntry,active.iStatus);
					active.Activate();
					CActiveScheduler::Start();
					User::LeaveIfError(active.Result());
					INFO_PRINTF1(_L("The state of the Flagged IMAP4 flag of the email is NOT set for urgent/special attention"));
					}
				else
					{
					ERR_PRINTF1(_L("Error in setting the Flagged IMAP4 flag! Usage: 1=ETrue and 0=EFalse"));
					SetTestStepResult(EFail);
					}
					
				CleanupStack::PopAndDestroy(entry);
				}
			}
		}
	return TestStepResult();
	}
Exemplo n.º 12
0
void CBtMsgViewerUtils::GetMessagePathL(TPtr aMsgPath, const TInt aMessageId )
    {
    CMsvEntry* messageEntry = iMsvSession->GetEntryL(aMessageId);
    CleanupStack::PushL(messageEntry);
    
    TMsvEntry entry = messageEntry->Entry();
    if(entry.MtmData1() == KUidMsgTypeBtTInt32)
        {
        CMsvStore* store = messageEntry->ReadStoreL();
        CleanupStack::PushL(store);
        
        TInt attachmentCount = store->AttachmentManagerL().AttachmentCount();
        RFile attachmentFile;
        if(attachmentCount != 0)
            {
            //get file handle for the attachment & the complete path of the file
            attachmentFile = store->AttachmentManagerL().GetAttachmentFileL(0);
            CleanupClosePushL(attachmentFile);
            User::LeaveIfError(attachmentFile.FullName(aMsgPath));
            CleanupStack::PopAndDestroy(&attachmentFile);
            StoreMessageMimeTypeL(aMsgPath);
            
            //mark attachment as Read
            TMsvEntry attachEntry = messageEntry->Entry();
            attachEntry.SetUnread(EFalse);
            messageEntry->ChangeL(attachEntry);
            }
        else
            {
            CClientMtmRegistry* mtmReg = CClientMtmRegistry::NewL(*iMsvSession);
            CleanupStack::PushL(mtmReg); //1st Push
            
            CBIOClientMtm* bioClientMtm = (CBIOClientMtm*) mtmReg->NewMtmL(KBioUidValueUid);
            CleanupStack::PushL(bioClientMtm); //2nd Push
            
            bioClientMtm->SwitchCurrentEntryL(aMessageId);
            
            CMsvEntry* attachmentEntry = CMsvEntry::NewL(bioClientMtm->Session(),
                                        aMessageId,
                                        TMsvSelectionOrdering());
            CleanupStack::PushL(attachmentEntry); //3rd Push
            
            bioClientMtm->LoadMessageL();
    
            CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection;
            CleanupStack::PushL(selection); //4th Push
    
            selection->AppendL(aMessageId);
    
            TBuf8<1> aParameter;
            CMsvOperationActiveSchedulerWait* wait = CMsvOperationActiveSchedulerWait::NewLC();
            //5th Push
    
            CMsvOperation* operation = bioClientMtm->InvokeAsyncFunctionL(KBiosMtmParse, *selection,
                aParameter, wait->iStatus);
    
            wait->Start();
    
            CMsvStore* store = attachmentEntry->ReadStoreL();
            CleanupStack::PushL(store); //6th Push
            MMsvAttachmentManager& attachMan = store->AttachmentManagerL();
            
            attachmentFile = attachMan.GetAttachmentFileL(0);
            CleanupClosePushL(attachmentFile); //7th Push
            User::LeaveIfError(attachmentFile.FullName(aMsgPath));
            CleanupStack::PopAndDestroy(&attachmentFile);
            StoreMessageMimeTypeL(aMsgPath);
            
            //mark attachment as Read
            TMsvEntry attachEntry = attachmentEntry->Entry();
            attachEntry.SetUnread(EFalse);
            attachmentEntry->ChangeL(attachEntry);
            
            delete operation;
            CleanupStack::PopAndDestroy(6);
            }
        CleanupStack::PopAndDestroy(store);
        }
    else
        {
        CMsvEntry* attachmentEntry = iMsvSession->GetEntryL((*messageEntry)[0].Id());
        CleanupStack::PushL(attachmentEntry); //1st push
            
        CMsvStore* store = attachmentEntry->ReadStoreL();
        CleanupStack::PushL(store);  //2nd push
        
        TBuf<KMaxPath> attachmentName(store->AttachmentManagerL().GetAttachmentInfoL(0)->AttachmentName());
        RFs fs;
        User::LeaveIfError(fs.Connect());
        CleanupClosePushL(fs);
        TEntry entry;
        User::LeaveIfError(fs.Entry(attachmentName, entry));
        CleanupStack::PopAndDestroy(&fs);
        
        //get file handle for the attachment & the complete path of the file
        RFile attachmentFile;
        attachmentFile = store->AttachmentManagerL().GetAttachmentFileL(0);
        CleanupClosePushL(attachmentFile); //3rd Push
        User::LeaveIfError(attachmentFile.FullName(aMsgPath));
        CleanupStack::PopAndDestroy(&attachmentFile);
        StoreMessageMimeTypeL(aMsgPath);
        
        //mark attachment as Read
        TMsvEntry attachEntry = attachmentEntry->Entry();
        attachEntry.SetUnread(EFalse);
        attachmentEntry->ChangeL(attachEntry);
        
        CleanupStack::PopAndDestroy(store);
        CleanupStack::PopAndDestroy(attachmentEntry);
        }
    CleanupStack::PopAndDestroy(messageEntry);
    }