/**
  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();
	}
Exemple #2
0
  globalDirObject(openLogin &lin, cgiScript & script):objectBase(lin,script)
  {
    string sqlGroups, sqlMailGroups, sqlUsers;
    if( lin.SiteAdmin() )
    {
      sqlGroups = "select id, name from groups order by name";
      sqlMailGroups = "select mg.id, g.name || ' - ' || mg.name as name from mail_groups mg "
                      "inner join groups g on g.id = mg.group_id order by g.name, mg.name";
      sqlUsers = "select u.id , g.name || ' - ' || u.first || ' ' || u.last as name "
                 "from users u inner join groups g on g.id = u.group_id";

    }
    else
    {
      sqlMailGroups = "select id, name from mail_groups where group_id = ";
      sqlMailGroups += lin.GroupId();
      sqlMailGroups += " order by name";
      sqlUsers = "select id ,  first || ' ' || last as name "
                 "from users where group_id = ";
      sqlUsers += lin.GroupId();
    }
    // add fields
    addField( "id", pgLongOid );
    addField( "group_id", pgLongOid );
    addField( "mail_group_id", pgVarCharArrayOid );
    addField( "mailto_id", pgLongOid );
    addField( "ex_first", pgVarCharArrayOid );
    addField( "ex_last", pgVarCharArrayOid );
    addField( "ex_phone_number", pgVarCharArrayOid );
    addField( "ex_email", pgVarCharArrayOid );
    addField( "comments", pgVarCharArrayOid );
    addField( "created", pgTimestampOid );
    addField( "created_by", pgLongOid );
    addField( "modified", pgTimestampOid );
    addField( "modified_by", pgLongOid );

    // add controls
    addControl( "id", staticEntry( "id", "24" ) );
    if( lin.SiteAdmin() )
    {
      addControl( "group_id", cmboEntry( "group_id",
                                         sqlGroups,
                                         "Select a group: " ) );
    }
    else
    {
      addControl( "group_id",hiddenEntry( "group_id" ) );
    }
    addControl( "mail_group_id", cmboEntry( "mail_group_id",
                                  sqlMailGroups,
                                  "Select a mail group: " ) );
    addControl( "mailto_id", cmboEntry( "mailto_id",
                                         sqlUsers,
                                         "Select an employee: " ) );
    addControl( "ex_first", textEntry( "ex_first", "24" ) );
    addControl( "ex_last", textEntry( "ex_last", "24" ) );
    addControl( "ex_phone_number", textEntry( "ex_phone_number", "16" ) );
    addControl( "ex_email", emailEntry( "ex_email", "32" ) );
    addControl( "comments", areaEntry( "comments" ) );
    addControl( "created", staticEntry( "created", "24" ) );
    addControl( "modified", staticEntry( "modified", "24" ) );

    // set name
    setName("global_directory");
  }
void CImPop3TransferMessage::StartL(TMsvId aSourceMessage, TMsvId aDestFolder, TImPop3TransferMethod aTransferMethod, TRequestStatus& aStatus)
	{
	iSourceMessage = aSourceMessage;
	iDestFolder = aDestFolder;
	iTransferMethod = aTransferMethod;
	iReportStatus = &aStatus;

	User::LeaveIfError(iEntry.SetEntry(aSourceMessage));
	TMsvEntry entry = iEntry.Entry();

	HBufC* details = HBufC::NewLC(entry.iDetails.Size());
	(*details) = entry.iDetails;
	HBufC* description = HBufC::NewLC(entry.iDescription.Size());
	(*description) = entry.iDescription;

	TFileName mailDirectory;
	mailDirectory.Append('a' + MessageServer::CurrentDriveL(iEntry.FileSession()));
	mailDirectory.Append(KPop3DriveSeparator);
	mailDirectory.Append(KMsvDefaultFolder2);
	
	// Get the store filename from the source message
	TFileName sourceStoreFilename = mailDirectory;
	User::LeaveIfError(iEntry.SetEntry(aSourceMessage));

	TBool storeFound = iEntry.HasStoreL();
	if (storeFound)
		{
		MsvUtils::ConstructEntryName(iEntry.Entry().iServiceId, iEntry.Entry().Id(), sourceStoreFilename, MsvUtils::EStore);	
		}

	// Create a message entry in the destination folder
	iEntry.SetEntry(aDestFolder);
	TMsvEmailEntry emailEntry(entry);
	emailEntry.SetVisible(ETrue);
	emailEntry.iDetails.Set(details->Des());
	emailEntry.iDescription.Set(description->Des());
	emailEntry.SetDisconnectedOperation(ENoDisconnectedOperations);
  
	User::LeaveIfError(iEntry.CreateEntry(emailEntry));
	iCopiedMessageId = emailEntry.Id();

	User::LeaveIfError(iEntry.SetEntry(emailEntry.Id()));
	TMsvId newEntry = emailEntry.Id();

	// Get the serviceId of the service the destination ID is located in.
	TMsvId destinationServiceId = iEntry.OwningService();

	if (storeFound)
		{
		// Get the name that the destination file should be copied to
		TFileName destinationStoreFilename = mailDirectory;
		MsvUtils::ConstructEntryName(destinationServiceId, iEntry.Entry().Id(), destinationStoreFilename, MsvUtils::EStore);
		CFileMan* fileMan = CFileMan::NewL(iEntry.FileSession());
		CleanupStack::PushL(fileMan);
		User::LeaveIfError(fileMan->Copy(sourceStoreFilename, destinationStoreFilename, CFileMan::ERecurse|CFileMan::EOverWrite));
		CleanupStack::PopAndDestroy(); // fileMan

		// This change entry isn't actually changing anything.
		// However the store contains a hidden stream created by the Message Server.
		// This is used to rebuild the index if it's corrupted
		// Calling ChangeEntry will make sure the stream is updated correctly
		iEntry.ChangeEntry(iEntry.Entry());
		}

	// Move all child entries from under the remote entry to the new entry
	User::LeaveIfError(iEntry.SetEntry(aSourceMessage));
	CMsvEntrySelection* childEntries = new (ELeave) CMsvEntrySelection;
	CleanupStack::PushL(childEntries);
	User::LeaveIfError(iEntry.GetChildren(*childEntries));
	if (childEntries->Count() > 0)
		{
		if (iTransferMethod == EImPop3CopyTransfer)
			// If we are in disconnected mode then we really want to copy the
			// entries, however if we are not then we want to move them.
			// This is because the only reason there are entries under the
			// service is because the remote server does not support the TOP
			// command.
			{
			iStatus = KRequestPending;
			iEntry.CopyEntriesL(*childEntries, newEntry, iStatus);
			SetActive();
			}
		else
			{
			iStatus = KRequestPending;
			iEntry.MoveEntriesL(*childEntries, newEntry, iStatus);
			SetActive();
			}
		}
	else
		{
		iStatus = KRequestPending;
		SetActive();
		TRequestStatus* status = &iStatus;
		User::RequestComplete(status, KErrNone);
		}

	CleanupStack::PopAndDestroy(); // childEntries

	CleanupStack::PopAndDestroy(2); // description, details

	}