char * testString = PR_smprintf("%s%s", "mscott@dredd.mcom.com/", mailboxName); rv = nsBuildLocalMessageURI( testString, msgKey, &uri);
nsCString uriStr; char * testString = PR_smprintf("%s%s", "mailbox_message: rv = nsBuildLocalMessageURI(/* (const char *) filePath */ testString, msgKey, uriStr); uri = uriStr.ToNewCString();
nsresult nsMailboxTestDriver::OnDisplayMessage(PRBool copyMessage){	// if copyMessage is TRUE then this function is a copy message test. if false, then this 	// function is supposed to display a message.	nsresult rv = NS_OK; 	char * displayString = nsnull;	nsMsgKeyArray msgKeys;	PL_strcpy(m_userData, (const char *) m_folderSpec);	displayString = PR_smprintf("Location of mailbox folders [%s]: ", m_userData);	rv = PromptForUserDataAndBuildUrl(displayString);	PR_FREEIF(displayString); 	char * folderPath = PL_strdup(m_userData);	// now ask for the mailbox name...	PL_strcpy(m_userData, DEFAULT_MAILBOX);	displayString = PR_smprintf("Mailbox to get message from [%s]: ", m_userData);	rv = PromptForUserDataAndBuildUrl(displayString);	PR_FREEIF(displayString);	// concatenate folder name onto folder path....	char * fullFolderPath = PR_smprintf("%s%c%s", folderPath ? folderPath : "", '\\', m_userData);	char * mailboxName = PL_strdup(m_userData);	PR_FREEIF(folderPath);	// now turn this into a nsFilePath...	nsFileSpec filePath(fullFolderPath);	PR_FREEIF(fullFolderPath);	nsIMsgDatabase * mailDb = OpenDB(filePath);	if (mailDb)	{		// extract the message key array		mailDb->ListAllKeys(msgKeys);		PRUint32 numKeys = msgKeys.GetSize();		// ask the user which message they want to display...We'll do this by asking the message number		// and then looking up in the array for the message key associated with that message.		PL_strcpy(m_userData, "0");		displayString = PR_smprintf("Enter message number between %d and %d to display [%s]: ", 0, numKeys-1, m_userData);		rv = PromptForUserDataAndBuildUrl(displayString);		PR_FREEIF(displayString);		PRUint32 index = atol(m_userData);		nsMsgKey msgKey = msgKeys[index];		// okay, we have the msgKey so let's get rid of our db state...		mailDb->Close(PR_TRUE);		// mscott - hacky....sprintf up a mailbox URI to represent the message.		char * uri = nsnull;		char * testString = PR_smprintf("%s%s", "mscott@dredd.mcom.com/", mailboxName);		rv = nsBuildLocalMessageURI(/* (const char *) filePath */ testString, msgKey, &uri);		if (NS_SUCCEEDED(rv))		{			nsIMsgMessageService * messageService = nsnull;			rv = GetMessageServiceFromURI(uri, &messageService);			if (NS_SUCCEEDED(rv) && messageService)			{				nsISupports * asupport = nsnull;				QueryInterface(NS_GET_IID(nsISupports), (void **) asupport);				messageService->DisplayMessage(uri, asupport, nsnull, nsnull, nsnull);				ReleaseMessageServiceFromURI(uri, messageService);			}		}	}	else	{		printf("We were unable to open a database associated with this mailbox folder.\n");		printf("Try parsing the mailbox folder first (command 1). \n");	}	return rv;}