Add ability to display a message given just a message number. We take this number (which is not a key or ID) and get the array of message keys from the db. We then extract the key corresponding to the number passed in. This interface function is used primarily to make debuggin easier where we don't have a message key or message ID lying around...

This commit is contained in:
mscott%netscape.com 1999-03-08 02:12:50 +00:00
Родитель fce5b65dd1
Коммит 7213b94e8d
3 изменённых файлов: 44 добавлений и 0 удалений

Просмотреть файл

@ -77,6 +77,14 @@ public:
NS_IMETHOD DisplayMessage(const nsFilePath& aMailboxPath, nsMsgKey aMessageKey, const char * aMessageID,
nsISupports * aDisplayConsumer, nsIUrlListener * aUrlListener, nsIURL ** aURL) = 0;
/////////////////////////////////////////////////////////////////////////////////////////////
// This is more of a convience function for testing purposes. We want to able to say: display
// message number 'n' in this mailbox without having to go out and get the key for message number
// 'n'. this function simply makes that possible.
/////////////////////////////////////////////////////////////////////////////////////////////
NS_IMETHOD DisplayMessageNumber(const nsFilePath& aMailboxPath, PRUint32 aMessageNumber,
nsISupports * aDisplayConsumer, nsIUrlListener * aUrlListener, nsIURL ** aURL) = 0;
};
#endif /* nsIMailboxService_h___ */

Просмотреть файл

@ -27,6 +27,8 @@
#include "nsMailboxUrl.h"
#include "nsMailboxProtocol.h"
#include "nsMailDatabase.h"
#include "nsMsgKeyArray.h"
nsMailboxService::nsMailboxService()
{
@ -118,3 +120,34 @@ nsresult nsMailboxService::DisplayMessage(const nsFilePath& aMailboxPath, nsMsgK
return rv;
}
nsresult nsMailboxService::DisplayMessageNumber(const nsFilePath& aMailboxPath, PRUint32 aMessageNumber, nsISupports * aDisplayConsumer,
nsIUrlListener * aUrlListener, nsIURL ** aURL)
{
nsMsgKeyArray msgKeys;
nsresult rv = NS_OK;
// extract the message key for this message number and turn around and call the other displayMessage method on it...
nsMailDatabase * mailDb = nsnull;
rv = nsMailDatabase::Open((nsFilePath&) aMailboxPath, PR_FALSE, &mailDb);
if (NS_SUCCEEDED(rv) && mailDb)
{
// extract the message key array
mailDb->ListAllKeys(msgKeys);
if (aMessageNumber < msgKeys.GetSize())
{
nsMsgKey msgKey = msgKeys[aMessageNumber];
// okay, we have the msgKey so let's get rid of our db state...
mailDb->Release();
mailDb = nsnull;
rv = DisplayMessage(aMailboxPath, msgKey, nsnull, aDisplayConsumer, aUrlListener, aURL);
}
else
rv = NS_ERROR_FAILURE;
}
if (mailDb) // in case we slipped through the cracks without releasing the db...
mailDb->Release();
return rv;
}

Просмотреть файл

@ -54,6 +54,9 @@ public:
NS_IMETHOD DisplayMessage(const nsFilePath& aMailboxPath, nsMsgKey aMessageKey, const char * aMessageID,
nsISupports * aDisplayConsumer, nsIUrlListener * aUrlListener, nsIURL ** aURL);
NS_IMETHOD DisplayMessageNumber(const nsFilePath& aMailboxPath, PRUint32 aMessageNumber, nsISupports * aDisplayConsumer,
nsIUrlListener * aUrlListener, nsIURL ** aURL);
////////////////////////////////////////////////////////////////////////////////////////
// End suppport for the nsIMailboxService Interface
////////////////////////////////////////////////////////////////////////////////////////