replace nsIEnumerator with nsISimpleEnumerator

This commit is contained in:
bienvenu%netscape.com 1999-08-26 04:41:07 +00:00
Родитель 380e4ad580
Коммит 57247bc224
28 изменённых файлов: 354 добавлений и 422 удалений

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

@ -49,8 +49,8 @@ interface nsIMsgFolder : nsIFolder {
void AddUnique(in nsISupports element);
void ReplaceElement(in nsISupports element, in nsISupports newElement);
nsIEnumerator GetMessages();
nsIEnumerator GetThreads();
nsISimpleEnumerator GetMessages();
nsISimpleEnumerator GetThreads();
nsIMsgThread GetThreadForMessage(in nsIMessage message);
boolean HasMessage(in nsIMessage message);
nsIEnumerator GetVisibleSubFolders();

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

@ -43,6 +43,6 @@ interface nsIMsgThread : nsISupports {
void MarkChildRead(in boolean bRead);
nsIEnumerator EnumerateMessages(in nsMsgKey parent);
nsISimpleEnumerator EnumerateMessages(in nsMsgKey parent);
};

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

@ -233,36 +233,28 @@ NS_IMETHODIMP nsMessageViewDataSource::GetTargets(nsIRDFResource* source,
if(mShowThreads)
{
nsCOMPtr<nsIEnumerator> threads;
nsCOMPtr<nsISimpleEnumerator> threads;
rv = folder->GetThreads(getter_AddRefs(threads));
if (NS_FAILED(rv)) return rv;
nsMessageViewThreadEnumerator * threadEnumerator =
new nsMessageViewThreadEnumerator(threads, folder);
if(!threadEnumerator)
return NS_ERROR_OUT_OF_MEMORY;
nsAdapterEnumerator* cursor =
new nsAdapterEnumerator(threadEnumerator);
if (cursor == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(cursor);
*targets = cursor;
NS_ADDREF(threadEnumerator);
*targets = threadEnumerator;
rv = NS_OK;
}
else
{
nsCOMPtr<nsIEnumerator> messages;
nsCOMPtr<nsISimpleEnumerator> messages;
rv = folder->GetMessages(getter_AddRefs(messages));
if (NS_FAILED(rv)) return rv;
nsMessageViewMessageEnumerator * messageEnumerator =
new nsMessageViewMessageEnumerator(messages, mShowStatus);
if(!messageEnumerator)
return NS_ERROR_OUT_OF_MEMORY;
nsAdapterEnumerator* cursor =
new nsAdapterEnumerator(messageEnumerator);
if (cursor == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(cursor);
*targets = cursor;
NS_ADDREF(messageEnumerator);
*targets = messageEnumerator;
rv = NS_OK;
}
}
@ -279,7 +271,7 @@ NS_IMETHODIMP nsMessageViewDataSource::GetTargets(nsIRDFResource* source,
rv = msgfolder->GetThreadForMessage(message, getter_AddRefs(thread));
if(NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIEnumerator> messages;
nsCOMPtr<nsISimpleEnumerator> messages;
nsMsgKey msgKey;
message->GetMessageKey(&msgKey);
thread->EnumerateMessages(msgKey, getter_AddRefs(messages));
@ -289,12 +281,8 @@ NS_IMETHODIMP nsMessageViewDataSource::GetTargets(nsIRDFResource* source,
new nsMessageViewMessageEnumerator(converter, mShowStatus);
if(!messageEnumerator)
return NS_ERROR_OUT_OF_MEMORY;
nsAdapterEnumerator* cursor =
new nsAdapterEnumerator(messageEnumerator);
if (cursor == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(cursor);
*targets = cursor;
NS_ADDREF(messageEnumerator);
*targets = messageEnumerator;
rv = NS_OK;
}
@ -424,7 +412,7 @@ NS_IMETHODIMP nsMessageViewDataSource::ArcLabelsOut(nsIRDFResource* source,
if(thread && NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIEnumerator> messages;
nsCOMPtr<nsISimpleEnumerator> messages;
nsMsgKey msgKey;
message->GetMessageKey(&msgKey);
thread->EnumerateMessages(msgKey, getter_AddRefs(messages));
@ -435,7 +423,9 @@ NS_IMETHODIMP nsMessageViewDataSource::ArcLabelsOut(nsIRDFResource* source,
if(!messageEnumerator)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(messageEnumerator);
if(NS_SUCCEEDED(messageEnumerator->First()))
PRBool hasMore = PR_FALSE;
if(NS_SUCCEEDED(messageEnumerator->HasMoreElements(&hasMore)) && hasMore)
arcs->AppendElement(kNC_MessageChild);
NS_IF_RELEASE(messageEnumerator);
}
@ -782,9 +772,9 @@ PRBool nsMessageViewDataSource::IsThreadsFirstMessage(nsIMsgThread *thread, nsIM
////////////////////////// nsMessageViewMessageEnumerator //////////////////
NS_IMPL_ISUPPORTS(nsMessageViewMessageEnumerator, nsCOMTypeInfo<nsIEnumerator>::GetIID())
NS_IMPL_ISUPPORTS(nsMessageViewMessageEnumerator, nsCOMTypeInfo<nsISimpleEnumerator>::GetIID())
nsMessageViewMessageEnumerator::nsMessageViewMessageEnumerator(nsIEnumerator *srcEnumerator,
nsMessageViewMessageEnumerator::nsMessageViewMessageEnumerator(nsISimpleEnumerator *srcEnumerator,
PRUint32 showStatus)
{
NS_INIT_REFCNT();
@ -798,58 +788,33 @@ nsMessageViewMessageEnumerator::~nsMessageViewMessageEnumerator()
//member variables are nsCOMPtr's.
}
/** First will reset the list. will return NS_FAILED if no items
*/
NS_IMETHODIMP nsMessageViewMessageEnumerator::First(void)
{
nsresult rv = mSrcEnumerator->First();
if(NS_SUCCEEDED(rv))
{
//See if the first item meets the criteria. If not, find next item.
nsCOMPtr<nsISupports> currentItem;
rv = CurrentItem(getter_AddRefs(currentItem));
if(NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIMessage> message(do_QueryInterface(currentItem, &rv));
if(NS_SUCCEEDED(rv))
{
PRBool meetsCriteria;
rv = MeetsCriteria(message, &meetsCriteria);
if(NS_SUCCEEDED(rv) && !meetsCriteria)
rv = Next();
}
}
}
return rv;
}
/** Next will advance the list. will return failed if already at end
*/
NS_IMETHODIMP nsMessageViewMessageEnumerator::Next(void)
NS_IMETHODIMP nsMessageViewMessageEnumerator::GetNext(nsISupports **aItem)
{
if (!aItem)
return NS_ERROR_NULL_POINTER;
nsresult rv = SetAtNextItem();
if (NS_SUCCEEDED(rv) && mCurMsg)
{
*aItem = mCurMsg;
NS_ADDREF(*aItem);
}
NS_ASSERTION(NS_SUCCEEDED(rv),"getnext shouldn't fail");
return rv;
}
/** CurrentItem will return the CurrentItem item it will fail if the list is empty
/** GetNext will return the next item it will fail if the list is empty
* @param aItem return value
*/
NS_IMETHODIMP nsMessageViewMessageEnumerator::CurrentItem(nsISupports **aItem)
{
nsresult rv = mSrcEnumerator->CurrentItem(aItem);
return rv;
}
/** return if the collection is at the end. that is the beginning following a call to Prev
* and it is the end of the list following a call to next
* @param aItem return value
*/
NS_IMETHODIMP nsMessageViewMessageEnumerator::IsDone()
NS_IMETHODIMP nsMessageViewMessageEnumerator::HasMoreElements(PRBool *aResult)
{
nsresult rv = mSrcEnumerator->IsDone();
return rv;
return mSrcEnumerator->HasMoreElements(aResult);
}
//This function sets mSrcEnumerator at the next item that fits
@ -861,11 +826,12 @@ nsresult nsMessageViewMessageEnumerator::SetAtNextItem()
nsCOMPtr<nsISupports> currentItem;
nsCOMPtr<nsIMessage> message;
while(mSrcEnumerator->IsDone() != NS_OK)
PRBool hasMore = PR_FALSE;
while(NS_SUCCEEDED(mSrcEnumerator->HasMoreElements(&hasMore)) && hasMore)
{
mSrcEnumerator->Next();
rv = mSrcEnumerator->GetNext(getter_AddRefs(currentItem));
PRBool successful = PR_FALSE;
rv = mSrcEnumerator->CurrentItem(getter_AddRefs(currentItem));
if(NS_FAILED(rv))
break;
@ -877,7 +843,11 @@ nsresult nsMessageViewMessageEnumerator::SetAtNextItem()
if(NS_SUCCEEDED(rv) & meetsCriteria)
successful = PR_TRUE;
}
if(successful) return NS_OK;
if(successful)
{
mCurMsg = do_QueryInterface(currentItem, &rv);
return rv;
}
}
return NS_ERROR_FAILURE;
@ -913,15 +883,16 @@ nsresult nsMessageViewMessageEnumerator::MeetsCriteria(nsIMessage *message, PRBo
////////////////////////// nsMessageViewThreadEnumerator //////////////////
NS_IMPL_ISUPPORTS(nsMessageViewThreadEnumerator, nsCOMTypeInfo<nsIEnumerator>::GetIID())
NS_IMPL_ISUPPORTS(nsMessageViewThreadEnumerator, nsCOMTypeInfo<nsISimpleEnumerator>::GetIID())
nsMessageViewThreadEnumerator::nsMessageViewThreadEnumerator(nsIEnumerator *threads,
nsMessageViewThreadEnumerator::nsMessageViewThreadEnumerator(nsISimpleEnumerator *threads,
nsIMsgFolder *srcFolder)
{
NS_INIT_REFCNT();
mThreads = do_QueryInterface(threads);
mFolder = do_QueryInterface(srcFolder);
mNeedToPrefetch = PR_TRUE;
}
nsMessageViewThreadEnumerator::~nsMessageViewThreadEnumerator()
@ -929,44 +900,38 @@ nsMessageViewThreadEnumerator::~nsMessageViewThreadEnumerator()
//member variables are nsCOMPtr's
}
/** First will reset the list. will return NS_FAILED if no items
/** Next will advance the list. will return failed if already at end
*/
NS_IMETHODIMP nsMessageViewThreadEnumerator::First(void)
NS_IMETHODIMP nsMessageViewThreadEnumerator::GetNext(nsISupports **aItem)
{
//Get the first thread and first message for that thread.
nsresult rv = mThreads->First();
nsresult rv = NS_OK;
if(!mMessages)
return NS_ERROR_FAILURE;
if (mNeedToPrefetch)
rv = Prefetch();
if (NS_SUCCEEDED(rv) && mMessages)
rv = mMessages->GetNext(aItem);
// NS_ASSERTION(NS_SUCCEEDED(rv),"getnext shouldn't fail");
mNeedToPrefetch = PR_TRUE;
return rv;
}
nsresult nsMessageViewThreadEnumerator::Prefetch()
{
nsresult rv = NS_OK;
//then check to see if the there are no more messages in last thread
//Get the next thread
rv = mThreads->GetNext(getter_AddRefs(mCurThread));
if(NS_SUCCEEDED(rv))
{
rv = GetMessagesForCurrentThread();
mNeedToPrefetch = PR_FALSE;
}
return rv;
}
/** Next will advance the list. will return failed if already at end
*/
NS_IMETHODIMP nsMessageViewThreadEnumerator::Next(void)
{
nsresult rv;
if(!mMessages)
return NS_ERROR_FAILURE;
//Get the next thread
rv = mThreads->Next();
if(NS_SUCCEEDED(rv))
rv = GetMessagesForCurrentThread();
return rv;
}
/** CurrentItem will return the CurrentItem item it will fail if the list is empty
* @param aItem return value
*/
NS_IMETHODIMP nsMessageViewThreadEnumerator::CurrentItem(nsISupports **aItem)
{
if(!mMessages)
return NS_ERROR_FAILURE;
//return the current message
nsresult rv = mMessages->CurrentItem(aItem);
else
mMessages = nsnull;
return rv;
}
@ -974,36 +939,41 @@ NS_IMETHODIMP nsMessageViewThreadEnumerator::CurrentItem(nsISupports **aItem)
* and it is the end of the list following a call to next
* @param aItem return value
*/
NS_IMETHODIMP nsMessageViewThreadEnumerator::IsDone()
NS_IMETHODIMP nsMessageViewThreadEnumerator::HasMoreElements(PRBool *aResult)
{
if (!aResult)
return NS_ERROR_NULL_POINTER;
nsresult rv = NS_OK;
if (mNeedToPrefetch)
Prefetch();
//First check to see if there are no more threads
nsresult rv = mThreads->IsDone();
//then check to see if the there are no more messages in last thread
if(rv == NS_OK && mMessages)
rv = mMessages->IsDone();
if (mMessages)
rv = mMessages->HasMoreElements(aResult);
else
*aResult = nsnull;
return rv;
}
nsresult nsMessageViewThreadEnumerator::GetMessagesForCurrentThread()
{
nsCOMPtr<nsISupports> currentItem;
nsCOMPtr<nsIMsgThread> thread;
nsresult rv = mThreads->CurrentItem(getter_AddRefs(currentItem));
if(NS_SUCCEEDED(rv))
nsresult rv = NS_OK;
if(mCurThread)
{
thread = do_QueryInterface(currentItem, &rv);
thread = do_QueryInterface(mCurThread, &rv);
if(NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIEnumerator> msgHdrs;
nsCOMPtr<nsISimpleEnumerator> msgHdrs;
rv = thread->EnumerateMessages(nsMsgKey_None, getter_AddRefs(msgHdrs));
nsMessageFromMsgHdrEnumerator *messages;
NS_NewMessageFromMsgHdrEnumerator(msgHdrs, mFolder, &messages);
mMessages = do_QueryInterface(messages, &rv);
NS_IF_RELEASE(messages);
if(NS_SUCCEEDED(rv))
rv = mMessages->First();
}
}
else
mMessages = nsnull;
return rv;
}

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

@ -191,17 +191,17 @@ protected:
};
class nsMessageViewMessageEnumerator: public nsIEnumerator
class nsMessageViewMessageEnumerator: public nsISimpleEnumerator
{
public:
NS_DECL_ISUPPORTS
nsMessageViewMessageEnumerator(nsIEnumerator *srcEnumerator, PRUint32 showStatus);
nsMessageViewMessageEnumerator(nsISimpleEnumerator *srcEnumerator, PRUint32 showStatus);
virtual ~nsMessageViewMessageEnumerator();
NS_DECL_NSIENUMERATOR
NS_DECL_NSISIMPLEENUMERATOR
protected:
nsresult SetAtNextItem();
@ -209,30 +209,35 @@ protected:
protected:
nsCOMPtr<nsIEnumerator> mSrcEnumerator;
nsCOMPtr<nsISimpleEnumerator> mSrcEnumerator;
nsCOMPtr<nsISupports> mCurMsg;
nsCOMPtr<nsISupports> mCurThread;
PRUint32 mShowStatus;
};
class nsMessageViewThreadEnumerator: public nsIEnumerator
class nsMessageViewThreadEnumerator: public nsISimpleEnumerator
{
public:
NS_DECL_ISUPPORTS
nsMessageViewThreadEnumerator(nsIEnumerator *srcEnumerator, nsIMsgFolder *srcFolder);
nsMessageViewThreadEnumerator(nsISimpleEnumerator *srcEnumerator, nsIMsgFolder *srcFolder);
virtual ~nsMessageViewThreadEnumerator();
NS_DECL_NSIENUMERATOR
NS_DECL_NSISIMPLEENUMERATOR
protected:
nsresult GetMessagesForCurrentThread();
nsresult Prefetch();
protected:
nsCOMPtr<nsIEnumerator> mThreads;
nsCOMPtr<nsIEnumerator> mMessages;
nsCOMPtr<nsISimpleEnumerator> mThreads;
nsCOMPtr<nsISimpleEnumerator> mMessages;
nsCOMPtr<nsISupports> mCurThread;
nsCOMPtr<nsIMsgFolder> mFolder;
PRBool mNeedToPrefetch;
};
#endif

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

@ -285,17 +285,13 @@ NS_IMETHODIMP nsMsgFolderDataSource::GetTargets(nsIRDFResource* source,
}
else if ((kNC_MessageChild == property))
{
nsCOMPtr<nsIEnumerator> messages;
nsCOMPtr<nsISimpleEnumerator> messages;
rv = folder->GetMessages(getter_AddRefs(messages));
if (NS_SUCCEEDED(rv))
{
nsAdapterEnumerator* cursor =
new nsAdapterEnumerator(messages);
if (cursor == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(cursor);
*targets = cursor;
*targets = messages;
NS_ADDREF(*targets);
rv = NS_OK;
}
}
@ -959,16 +955,19 @@ nsresult
nsMsgFolderDataSource::createFolderMessageNode(nsIMsgFolder *folder,
nsIRDFNode **target)
{
nsCOMPtr<nsIEnumerator> messages;
nsCOMPtr<nsISimpleEnumerator> messages;
nsresult rv = folder->GetMessages(getter_AddRefs(messages));
if (NS_SUCCEEDED(rv) && rv != NS_RDF_CURSOR_EMPTY) {
rv = messages->First();
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsISupports> firstMessage;
rv = messages->CurrentItem(getter_AddRefs(firstMessage));
if (NS_SUCCEEDED(rv)) {
rv = firstMessage->QueryInterface(nsCOMTypeInfo<nsIRDFNode>::GetIID(), (void**)target);
}
PRBool hasMore = PR_FALSE;
rv = messages->HasMoreElements(&hasMore);
if (NS_SUCCEEDED(rv) && hasMore)
{
nsCOMPtr<nsISupports> firstMessage;
rv = messages->GetNext(getter_AddRefs(firstMessage));
if (NS_SUCCEEDED(rv))
{
rv = firstMessage->QueryInterface(nsCOMTypeInfo<nsIRDFNode>::GetIID(), (void**)target);
}
}
}
return rv == NS_OK ? NS_OK : NS_RDF_NO_VALUE;

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

@ -65,7 +65,7 @@ nsMsgDBFolder::~nsMsgDBFolder(void)
}
}
NS_IMETHODIMP nsMsgDBFolder::GetThreads(nsIEnumerator** threadEnumerator)
NS_IMETHODIMP nsMsgDBFolder::GetThreads(nsISimpleEnumerator** threadEnumerator)
{
nsresult rv = GetDatabase();

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

@ -39,7 +39,7 @@ public:
nsMsgDBFolder(void);
virtual ~nsMsgDBFolder(void);
NS_IMETHOD GetThreads(nsIEnumerator** threadEnumerator);
NS_IMETHOD GetThreads(nsISimpleEnumerator** threadEnumerator);
NS_IMETHOD GetThreadForMessage(nsIMessage *message, nsIMsgThread **thread);
NS_IMETHOD HasMessage(nsIMessage *message, PRBool *hasMessage);
NS_IMETHOD GetCharset(PRUnichar * *aCharset);

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

@ -270,14 +270,14 @@ NS_IMETHODIMP nsMsgFolder::GetParent(nsIFolder **parent)
}
NS_IMETHODIMP
nsMsgFolder::GetMessages(nsIEnumerator* *result)
nsMsgFolder::GetMessages(nsISimpleEnumerator* *result)
{
// XXX should this return an empty enumeration?
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsMsgFolder::GetThreads(nsIEnumerator ** threadEnumerator)
nsMsgFolder::GetThreads(nsISimpleEnumerator ** threadEnumerator)
{
// XXX should this return an empty enumeration?
return NS_ERROR_FAILURE;

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

@ -91,8 +91,8 @@ public:
NS_IMETHOD AddUnique(nsISupports* element);
NS_IMETHOD ReplaceElement(nsISupports* element, nsISupports* newElement);
NS_IMETHOD GetVisibleSubFolders(nsIEnumerator* *result);
NS_IMETHOD GetMessages(nsIEnumerator* *result);
NS_IMETHOD GetThreads(nsIEnumerator ** threadEnumerator);
NS_IMETHOD GetMessages(nsISimpleEnumerator* *result);
NS_IMETHOD GetThreads(nsISimpleEnumerator ** threadEnumerator);
NS_IMETHOD GetThreadForMessage(nsIMessage *message, nsIMsgThread **thread);
NS_IMETHOD HasMessage(nsIMessage *message, PRBool *hasMessage);

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

@ -79,9 +79,9 @@ nsresult ReleaseMessageServiceFromURI(const char *uri, nsIMsgMessageService *mes
}
NS_IMPL_ISUPPORTS(nsMessageFromMsgHdrEnumerator, nsCOMTypeInfo<nsIEnumerator>::GetIID())
NS_IMPL_ISUPPORTS(nsMessageFromMsgHdrEnumerator, nsCOMTypeInfo<nsISimpleEnumerator>::GetIID())
nsMessageFromMsgHdrEnumerator::nsMessageFromMsgHdrEnumerator(nsIEnumerator *srcEnumerator,
nsMessageFromMsgHdrEnumerator::nsMessageFromMsgHdrEnumerator(nsISimpleEnumerator *srcEnumerator,
nsIMsgFolder *folder)
{
NS_INIT_REFCNT();
@ -96,25 +96,15 @@ nsMessageFromMsgHdrEnumerator::~nsMessageFromMsgHdrEnumerator()
//member variables are nsCOMPtr's
}
NS_IMETHODIMP nsMessageFromMsgHdrEnumerator::First(void)
{
return mSrcEnumerator->First();
}
NS_IMETHODIMP nsMessageFromMsgHdrEnumerator::Next(void)
{
return mSrcEnumerator->Next();
}
NS_IMETHODIMP nsMessageFromMsgHdrEnumerator::CurrentItem(nsISupports **aItem)
NS_IMETHODIMP nsMessageFromMsgHdrEnumerator::GetNext(nsISupports **aItem)
{
nsCOMPtr<nsISupports> currentItem;
nsCOMPtr<nsIMsgDBHdr> msgDBHdr;
nsCOMPtr<nsIMessage> message;
nsresult rv;
rv = mSrcEnumerator->CurrentItem(getter_AddRefs(currentItem));
rv = mSrcEnumerator->GetNext(getter_AddRefs(currentItem));
if(NS_SUCCEEDED(rv))
{
msgDBHdr = do_QueryInterface(currentItem, &rv);
@ -127,19 +117,21 @@ NS_IMETHODIMP nsMessageFromMsgHdrEnumerator::CurrentItem(nsISupports **aItem)
if(NS_SUCCEEDED(rv))
{
*aItem = message;
currentItem = do_QueryInterface(message);
*aItem = currentItem;
NS_ADDREF(*aItem);
}
NS_ASSERTION(NS_SUCCEEDED(rv),"getnext shouldn't fail");
return rv;
}
NS_IMETHODIMP nsMessageFromMsgHdrEnumerator::IsDone(void)
NS_IMETHODIMP nsMessageFromMsgHdrEnumerator::HasMoreElements(PRBool *aResult)
{
return mSrcEnumerator->IsDone();
return mSrcEnumerator->HasMoreElements(aResult);
}
nsresult NS_NewMessageFromMsgHdrEnumerator(nsIEnumerator *srcEnumerator,
nsresult NS_NewMessageFromMsgHdrEnumerator(nsISimpleEnumerator *srcEnumerator,
nsIMsgFolder *folder,
nsMessageFromMsgHdrEnumerator **messageEnumerator)
{

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

@ -36,22 +36,22 @@ NS_MSG_BASE nsresult ReleaseMessageServiceFromURI(const char *uri, nsIMsgMessage
//An enumerator for converting nsIMsgHdrs to nsIMessages.
class NS_MSG_BASE nsMessageFromMsgHdrEnumerator: public nsIEnumerator
class NS_MSG_BASE nsMessageFromMsgHdrEnumerator: public nsISimpleEnumerator
{
protected:
nsCOMPtr<nsIEnumerator> mSrcEnumerator;
nsCOMPtr<nsISimpleEnumerator> mSrcEnumerator;
nsCOMPtr<nsIMsgFolder> mFolder;
public:
NS_DECL_ISUPPORTS
nsMessageFromMsgHdrEnumerator(nsIEnumerator *srcEnumerator, nsIMsgFolder *folder);
nsMessageFromMsgHdrEnumerator(nsISimpleEnumerator *srcEnumerator, nsIMsgFolder *folder);
nsMessageFromMsgHdrEnumerator(){} //Default constructor that does nothing so nsComPtr will work.
virtual ~nsMessageFromMsgHdrEnumerator();
NS_DECL_NSIENUMERATOR
NS_DECL_NSISIMPLEENUMERATOR
};
NS_MSG_BASE nsresult NS_NewMessageFromMsgHdrEnumerator(nsIEnumerator *srcEnumerator,
NS_MSG_BASE nsresult NS_NewMessageFromMsgHdrEnumerator(nsISimpleEnumerator *srcEnumerator,
nsIMsgFolder *folder,
nsMessageFromMsgHdrEnumerator **messageEnumerator);

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

@ -2141,6 +2141,7 @@ nsMsgGetExtensionFromFileURL(nsString aUrl)
}
ERROR_OUT:
PR_FREEIF(url);
if (url)
nsAllocator::Free(url);
return nsnull;
}

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

@ -410,8 +410,8 @@ HackUpAURIToPlayWith(void)
if (!folder)
return nsnull;
nsIEnumerator *enumerator;
rv = folder->GetMessages(&enumerator);
nsCOMPtr <nsISimpleEnumerator> enumerator;
rv = folder->GetMessages(getter_AddRefs(enumerator));
if (NS_FAILED(rv) || (!enumerator))
{
// RICHIE - Possible bug that will bite us in this hack...
@ -419,38 +419,27 @@ HackUpAURIToPlayWith(void)
return nsnull;
}
enumerator->First();
if (enumerator->IsDone() == NS_OK)
{
NS_IF_RELEASE(enumerator);
PRBool hasMore = PR_FALSE;
rv = enumerator->HasMoreElements(&hasMore);
if (!NS_SUCCEEDED(rv) || !hasMore)
return nsnull;
}
nsCOMPtr<nsISupports> currentItem;
rv = enumerator->CurrentItem(getter_AddRefs(currentItem));
rv = enumerator->GetNext(getter_AddRefs(currentItem));
if (NS_FAILED(rv))
{
NS_IF_RELEASE(enumerator);
return nsnull;
}
nsCOMPtr<nsIMessage> message;
message = do_QueryInterface(currentItem);
if (!message)
{
NS_IF_RELEASE(enumerator);
return nsnull;
}
nsCOMPtr<nsIRDFResource> myRDFNode;
myRDFNode = do_QueryInterface(message, &rv);
if (NS_FAILED(rv) || (!myRDFNode))
{
NS_IF_RELEASE(enumerator);
return nsnull;
}
NS_IF_RELEASE(enumerator);
char *tURI;
myRDFNode->GetValue(&tURI);
nsString workURI(tURI);

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

@ -83,7 +83,6 @@ nsMsgSendLater::nsMsgSendLater()
mHackTempFileSpec = nsnull;
mOutFile = nsnull;
mEnumerator = nsnull;
mFirstTime = PR_TRUE;
mTotalSentSuccessfully = 0;
mTotalSendCount = 0;
mMessageFolder = nsnull;
@ -399,8 +398,6 @@ SendOperationListener::OnStopSending(const char *aMsgID, nsresult aStatus, const
if (NS_FAILED(ret) || (!(mSendLater->mEnumerator)))
mSendLater->mEnumerator = nsnull; // just to be sure!
// Do the first call next time through!
mSendLater->mFirstTime = PR_TRUE;
}
++(mSendLater->mTotalSentSuccessfully);
@ -540,23 +537,9 @@ nsMsgSendLater::StartNextMailFileSend()
nsresult rv;
char *aMessageURI = nsnull;
//
// Now, go to the next entry and check where we are in the
// enumerator!
//
if (mFirstTime)
{
mFirstTime = PR_FALSE;
if (mEnumerator)
mEnumerator->First();
}
else
{
if (mEnumerator)
mEnumerator->Next();
}
PRBool hasMore = PR_FALSE;
if ( (!mEnumerator) || (mEnumerator->IsDone() == NS_OK) )
if ( (!mEnumerator) || !NS_SUCCEEDED(mEnumerator->HasMoreElements(&hasMore)) || !hasMore )
{
// Call any listeners on this operation and then exit cleanly
#ifdef NS_DEBUG
@ -568,7 +551,7 @@ nsMsgSendLater::StartNextMailFileSend()
nsCOMPtr<nsISupports> currentItem;
rv = mEnumerator->CurrentItem(getter_AddRefs(currentItem));
rv = mEnumerator->GetNext(getter_AddRefs(currentItem));
if (NS_FAILED(rv))
{
return rv;
@ -732,7 +715,6 @@ nsMsgSendLater::SendUnsentMessages(nsIMsgIdentity *identity,
return NS_ERROR_FAILURE;
}
mFirstTime = PR_TRUE;
return StartNextMailFileSend();
}

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

@ -115,10 +115,9 @@ public:
// counters and things for enumeration
PRUint32 mTotalSentSuccessfully;
PRUint32 mTotalSendCount;
nsIEnumerator *mEnumerator;
nsISimpleEnumerator *mEnumerator;
nsIMsgIdentity *mIdentity;
nsCOMPtr<nsIMsgFolder> mMessageFolder;
PRBool mFirstTime;
// Private Information
private:

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

@ -27,7 +27,7 @@
interface nsIDBChangeListener;
interface nsIMsgDBHdr;
interface nsIEnumerator;
interface nsISimpleEnumerator;
interface nsIMsgThread;
interface nsIDBFolderInfo;
@ -77,8 +77,8 @@ interface nsIMsgDatabase : nsIDBChangeAnnouncer {
[noscript] void ListAllKeys(in nsMsgKeyArrayRef outputKeys);
nsIEnumerator EnumerateMessages();
nsIEnumerator EnumerateThreads();
nsISimpleEnumerator EnumerateMessages();
nsISimpleEnumerator EnumerateThreads();
nsIMsgThread GetThreadContainingMsgHdr(in nsIMsgDBHdr msgHdr) ;

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

@ -89,14 +89,10 @@ public:
NS_IMETHOD CopyHdrFromExistingHdr(nsMsgKey key, nsIMsgDBHdr *existingHdr, nsIMsgDBHdr **newHdr);
NS_IMETHOD AddNewHdrToDB(nsIMsgDBHdr *newHdr, PRBool notify);
#if HAVE_INT_ENUMERATORS
NS_IMETHOD EnumerateKeys(nsIEnumerator* *outputKeys);
#else
NS_IMETHOD ListAllKeys(nsMsgKeyArray &outputKeys);
#endif
NS_IMETHOD EnumerateMessages(nsIEnumerator* *result);
NS_IMETHOD EnumerateUnreadMessages(nsIEnumerator* *result);
NS_IMETHOD EnumerateThreads(nsIEnumerator* *result);
NS_IMETHOD EnumerateMessages(nsISimpleEnumerator* *result);
NS_IMETHOD EnumerateUnreadMessages(nsISimpleEnumerator* *result);
NS_IMETHOD EnumerateThreads(nsISimpleEnumerator* *result);
// this might just be for debugging - we'll see.
nsresult ListAllThreads(nsMsgKeyArray *threadIds);

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

@ -53,7 +53,7 @@ public:
NS_IMETHOD RemoveChildAt(PRInt32 index);
NS_IMETHOD RemoveChildHdr(nsIMsgDBHdr *child, nsIDBChangeAnnouncer *announcer);
NS_IMETHOD MarkChildRead(PRBool bRead);
NS_IMETHOD EnumerateMessages(nsMsgKey parent, nsIEnumerator* *result);
NS_IMETHOD EnumerateMessages(nsMsgKey parent, nsISimpleEnumerator* *result);
NS_IMETHOD GetRootHdr(PRInt32 *resultIndex, nsIMsgDBHdr **result);
// non-interface methods

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

@ -1398,13 +1398,15 @@ NS_IMETHODIMP nsMsgDatabase::MarkAllRead(nsMsgKeyArray *thoseMarked)
//ListContext *listContext = NULL;
PRInt32 numChanged = 0;
nsIEnumerator* hdrs;
nsISimpleEnumerator* hdrs;
rv = EnumerateMessages(&hdrs);
if (NS_FAILED(rv))
return rv;
for (hdrs->First(); hdrs->IsDone() != NS_OK; hdrs->Next())
PRBool hasMore = PR_FALSE;
while (NS_SUCCEEDED(rv = hdrs->HasMoreElements(&hasMore)) && (hasMore == PR_TRUE))
{
rv = hdrs->CurrentItem((nsISupports**)&pHeader);
rv = hdrs->GetNext((nsISupports**)&pHeader);
NS_ASSERTION(NS_SUCCEEDED(rv), "nsMsgDBEnumerator broken");
if (NS_FAILED(rv))
break;
@ -1438,7 +1440,7 @@ NS_IMETHODIMP nsMsgDatabase::MarkReadByDate (PRTime startDate, PRTime endDate, n
//ListContext *listContext = NULL;
PRInt32 numChanged = 0;
nsIEnumerator* hdrs;
nsISimpleEnumerator* hdrs;
rv = EnumerateMessages(&hdrs);
if (NS_FAILED(rv))
return rv;
@ -1446,9 +1448,11 @@ NS_IMETHODIMP nsMsgDatabase::MarkReadByDate (PRTime startDate, PRTime endDate, n
nsTime t_startDate(startDate);
nsTime t_endDate(endDate);
for (hdrs->First(); hdrs->IsDone() != NS_OK; hdrs->Next())
PRBool hasMore = PR_FALSE;
while (NS_SUCCEEDED(rv = hdrs->HasMoreElements(&hasMore)) && (hasMore == PR_TRUE))
{
rv = hdrs->CurrentItem((nsISupports**)&pHeader);
rv = hdrs->GetNext((nsISupports**)&pHeader);
NS_ASSERTION(NS_SUCCEEDED(rv), "nsMsgDBEnumerator broken");
if (NS_FAILED(rv)) break;
@ -1568,12 +1572,12 @@ NS_IMETHODIMP nsMsgDatabase::GetFirstNew(nsMsgKey *result)
////////////////////////////////////////////////////////////////////////////////
class nsMsgDBEnumerator : public nsIEnumerator {
class nsMsgDBEnumerator : public nsISimpleEnumerator {
public:
NS_DECL_ISUPPORTS
// nsIEnumerator methods:
NS_DECL_NSIENUMERATOR
// nsISimpleEnumerator methods:
NS_DECL_NSISIMPLEENUMERATOR
// nsMsgDBEnumerator methods:
typedef nsresult (*nsMsgDBEnumeratorFilter)(nsIMsgDBHdr* hdr, void* closure);
@ -1583,10 +1587,13 @@ public:
virtual ~nsMsgDBEnumerator();
protected:
nsresult GetRowCursor();
nsresult PrefetchNext();
nsMsgDatabase* mDB;
nsIMdbTableRowCursor* mRowCursor;
nsIMsgDBHdr* mResultHdr;
PRBool mDone;
PRBool mNextPrefetched;
nsMsgDBEnumeratorFilter mFilter;
void* mClosure;
};
@ -1598,6 +1605,7 @@ nsMsgDBEnumerator::nsMsgDBEnumerator(nsMsgDatabase* db,
{
NS_INIT_REFCNT();
NS_ADDREF(mDB);
mNextPrefetched = PR_FALSE;
}
nsMsgDBEnumerator::~nsMsgDBEnumerator()
@ -1608,9 +1616,9 @@ nsMsgDBEnumerator::~nsMsgDBEnumerator()
NS_IF_RELEASE(mResultHdr);
}
NS_IMPL_ISUPPORTS(nsMsgDBEnumerator, nsIEnumerator::GetIID())
NS_IMPL_ISUPPORTS(nsMsgDBEnumerator, nsISimpleEnumerator::GetIID())
NS_IMETHODIMP nsMsgDBEnumerator::First(void)
nsresult nsMsgDBEnumerator::GetRowCursor()
{
nsresult rv = 0;
mDone = PR_FALSE;
@ -1618,18 +1626,43 @@ NS_IMETHODIMP nsMsgDBEnumerator::First(void)
if (!mDB || !mDB->m_mdbAllMsgHeadersTable)
return NS_ERROR_NULL_POINTER;
mDB->m_mdbAllMsgHeadersTable->GetTableRowCursor(mDB->GetEnv(), -1, &mRowCursor);
if (NS_FAILED(rv)) return rv;
return Next();
rv = mDB->m_mdbAllMsgHeadersTable->GetTableRowCursor(mDB->GetEnv(), -1, &mRowCursor);
return rv;
}
NS_IMETHODIMP nsMsgDBEnumerator::Next(void)
NS_IMETHODIMP nsMsgDBEnumerator::GetNext(nsISupports **aItem)
{
if (!aItem)
return NS_ERROR_NULL_POINTER;
nsresult rv;
if (!mNextPrefetched)
rv = PrefetchNext();
if (NS_SUCCEEDED(rv))
{
if (mResultHdr)
{
*aItem = mResultHdr;
NS_ADDREF(mResultHdr);
mNextPrefetched = PR_FALSE;
}
}
return rv;
}
nsresult nsMsgDBEnumerator::PrefetchNext()
{
nsresult rv = NS_OK;
nsIMdbRow* hdrRow;
mdb_pos rowPos;
PRUint32 flags;
if (!mRowCursor)
{
rv = GetRowCursor();
if (!NS_SUCCEEDED(rv))
return rv;
}
do {
NS_IF_RELEASE(mResultHdr);
mResultHdr = nsnull;
@ -1658,28 +1691,30 @@ NS_IMETHODIMP nsMsgDBEnumerator::Next(void)
flags = 0;
}
while (mFilter && mFilter(mResultHdr, mClosure) != NS_OK && !(flags & MSG_FLAG_EXPUNGED));
return rv;
}
NS_IMETHODIMP nsMsgDBEnumerator::CurrentItem(nsISupports **aItem)
{
if (mResultHdr) {
*aItem = mResultHdr;
NS_ADDREF(mResultHdr);
if (mResultHdr)
{
mNextPrefetched = PR_TRUE;
return NS_OK;
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMsgDBEnumerator::IsDone(void)
NS_IMETHODIMP nsMsgDBEnumerator::HasMoreElements(PRBool *aResult)
{
return mDone ? NS_OK : NS_COMFALSE;
if (!aResult)
return NS_ERROR_NULL_POINTER;
if (!mNextPrefetched)
PrefetchNext();
*aResult = !mDone;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP
nsMsgDatabase::EnumerateMessages(nsIEnumerator* *result)
nsMsgDatabase::EnumerateMessages(nsISimpleEnumerator* *result)
{
nsMsgDBEnumerator* e = new nsMsgDBEnumerator(this, nsnull, nsnull);
if (e == nsnull)
@ -1690,29 +1725,6 @@ nsMsgDatabase::EnumerateMessages(nsIEnumerator* *result)
}
#if HAVE_INT_ENUMERATORS
NS_IMETHODIMP nsMsgDatabase::EnumerateKeys(nsIEnumerator* *result)
{
nsISupportsArray* keys;
nsresult rv = NS_NewISupportsArray(&keys);
if (NS_FAILED(rv)) return rv;
nsIMdbTableRowCursor *rowCursor;
rv = m_mdbAllMsgHeadersTable->GetTableRowCursor(GetEnv(), -1, &rowCursor);
while (NS_SUCCEEDED(rv)) {
mdbOid outOid;
mdb_pos outPos;
rv = rowCursor->NextRowOid(GetEnv(), &outOid, &outPos);
if (NS_FAILED(rv)) return rv;
if (outPos < 0) // is this right?
break;
keys->AppendElement(outOid.mOid_Id);
}
return keys->Enumerate(result);
}
#else
// resulting output array is sorted by key.
NS_IMETHODIMP nsMsgDatabase::ListAllKeys(nsMsgKeyArray &outputKeys)
{
@ -1738,16 +1750,15 @@ NS_IMETHODIMP nsMsgDatabase::ListAllKeys(nsMsgKeyArray &outputKeys)
outputKeys.QuickSort();
return err;
}
#endif
class nsMsgDBThreadEnumerator : public nsIEnumerator
class nsMsgDBThreadEnumerator : public nsISimpleEnumerator
{
public:
NS_DECL_ISUPPORTS
// nsIEnumerator methods:
NS_DECL_NSIENUMERATOR
// nsISimpleEnumerator methods:
NS_DECL_NSISIMPLEENUMERATOR
// nsMsgDBEnumerator methods:
typedef nsresult (*nsMsgDBThreadEnumeratorFilter)(nsIMsgThread* hdr, void* closure);
@ -1757,10 +1768,13 @@ public:
virtual ~nsMsgDBThreadEnumerator();
protected:
nsresult GetTableCursor(void);
nsresult PrefetchNext();
nsMsgDatabase* mDB;
nsIMdbPortTableCursor* mTableCursor;
nsIMsgThread* mResultThread;
PRBool mDone;
PRBool mNextPrefetched;
nsMsgDBThreadEnumeratorFilter mFilter;
void* mClosure;
};
@ -1772,6 +1786,7 @@ nsMsgDBThreadEnumerator::nsMsgDBThreadEnumerator(nsMsgDatabase* db,
{
NS_INIT_REFCNT();
NS_ADDREF(mDB);
mNextPrefetched = PR_FALSE;
}
nsMsgDBThreadEnumerator::~nsMsgDBThreadEnumerator()
@ -1781,9 +1796,9 @@ nsMsgDBThreadEnumerator::~nsMsgDBThreadEnumerator()
NS_RELEASE(mDB);
}
NS_IMPL_ISUPPORTS(nsMsgDBThreadEnumerator, nsIEnumerator::GetIID())
NS_IMPL_ISUPPORTS(nsMsgDBThreadEnumerator, nsISimpleEnumerator::GetIID())
NS_IMETHODIMP nsMsgDBThreadEnumerator::First(void)
nsresult nsMsgDBThreadEnumerator::GetTableCursor(void)
{
nsresult rv = 0;
@ -1795,14 +1810,41 @@ NS_IMETHODIMP nsMsgDBThreadEnumerator::First(void)
if (NS_FAILED(rv))
return rv;
return Next();
return NS_OK;
}
NS_IMETHODIMP nsMsgDBThreadEnumerator::Next(void)
NS_IMETHODIMP nsMsgDBThreadEnumerator::GetNext(nsISupports **aItem)
{
if (!aItem)
return NS_ERROR_NULL_POINTER;
*aItem = nsnull;
nsresult rv = NS_OK;
if (!mNextPrefetched)
PrefetchNext();
if (NS_SUCCEEDED(rv))
{
if (mResultThread)
{
*aItem = mResultThread;
NS_ADDREF(mResultThread);
mNextPrefetched = PR_FALSE;
}
}
return rv;
}
nsresult nsMsgDBThreadEnumerator::PrefetchNext()
{
nsresult rv;
nsIMdbTable *table = nsnull;
if (!mTableCursor)
{
rv = GetTableCursor();
if (!NS_SUCCEEDED(rv))
return rv;
}
while (PR_TRUE)
{
NS_IF_RELEASE(mResultThread);
@ -1837,27 +1879,26 @@ NS_IMETHODIMP nsMsgDBThreadEnumerator::Next(void)
else
break;
}
return rv;
}
NS_IMETHODIMP nsMsgDBThreadEnumerator::CurrentItem(nsISupports **aItem)
{
if (mResultThread)
{
*aItem = mResultThread;
NS_ADDREF(mResultThread);
mNextPrefetched = PR_TRUE;
return NS_OK;
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMsgDBThreadEnumerator::IsDone(void)
NS_IMETHODIMP nsMsgDBThreadEnumerator::HasMoreElements(PRBool *aResult)
{
return mDone ? NS_OK : NS_COMFALSE;
if (!aResult)
return NS_ERROR_NULL_POINTER;
if (!mNextPrefetched)
PrefetchNext();
*aResult = !mDone;
return NS_OK;
}
NS_IMETHODIMP
nsMsgDatabase::EnumerateThreads(nsIEnumerator* *result)
nsMsgDatabase::EnumerateThreads(nsISimpleEnumerator* *result)
{
nsMsgDBThreadEnumerator* e = new nsMsgDBThreadEnumerator(this, nsnull, nsnull);
if (e == nsnull)
@ -1917,7 +1958,7 @@ nsMsgUnreadFilter(nsIMsgDBHdr* msg, void* closure)
}
NS_IMETHODIMP
nsMsgDatabase::EnumerateUnreadMessages(nsIEnumerator* *result)
nsMsgDatabase::EnumerateUnreadMessages(nsISimpleEnumerator* *result)
{
nsMsgDBEnumerator* e = new nsMsgDBEnumerator(this, nsMsgUnreadFilter, this);
if (e == nsnull)
@ -2673,13 +2714,15 @@ nsresult nsMsgDatabase::ListAllThreads(nsMsgKeyArray *threadIds)
nsresult rv;
nsMsgThread *pThread;
nsIEnumerator* threads;
nsISimpleEnumerator* threads;
rv = EnumerateThreads(&threads);
if (NS_FAILED(rv))
return rv;
for (threads->First(); threads->IsDone() != NS_OK; threads->Next())
PRBool hasMore = PR_FALSE;
while (NS_SUCCEEDED(rv = threads->HasMoreElements(&hasMore)) && (hasMore == PR_TRUE))
{
rv = threads->CurrentItem((nsISupports**)&pThread);
rv = threads->GetNext((nsISupports**)&pThread);
NS_ASSERTION(NS_SUCCEEDED(rv), "nsMsgDBEnumerator broken");
if (NS_FAILED(rv))
break;
@ -2731,20 +2774,10 @@ nsresult nsMsgDatabase::DumpContents()
nsMsgKey key;
PRUint32 i;
#ifdef HAVE_INT_ENUMERATORS
nsIEnumerator* keys;
nsresult rv = EnumerateKeys(&keys);
if (NS_FAILED(rv)) return rv;
for (keys->First(); keys->IsDone != NS_OK; keys->Next()) {
rv = keys->CurrentItem((nsISupports**)&key);
NS_ASSERTION(NS_SUCCEEDED(rv), "nsMsgDBEnumerator broken");
if (NS_FAILED(rv)) break;
#else
nsMsgKeyArray keys;
nsresult rv = ListAllKeys(keys);
for (i = 0; i < keys.GetSize(); i++) {
key = keys[i];
#endif /* HAVE_INT_ENUMERATORS */
nsIMsgDBHdr *msg = NULL;
rv = GetMsgHdrForKey(key, &msg);
nsMsgHdr* msgHdr = NS_STATIC_CAST(nsMsgHdr*, msg); // closed system, cast ok
@ -2784,23 +2817,25 @@ nsresult nsMsgDatabase::DumpMsgChildren(nsIMsgDBHdr *msgHdr)
nsresult nsMsgDatabase::DumpThread(nsMsgKey threadId)
{
nsresult ret = NS_OK;
nsresult rv = NS_OK;
nsIMsgThread *thread = nsnull;
thread = GetThreadForThreadId(threadId);
if (thread)
{
nsIEnumerator *enumerator = nsnull;
nsISimpleEnumerator *enumerator = nsnull;
ret = thread->EnumerateMessages(nsMsgKey_None, &enumerator);
if (NS_SUCCEEDED(ret) && enumerator)
rv = thread->EnumerateMessages(nsMsgKey_None, &enumerator);
if (NS_SUCCEEDED(rv) && enumerator)
{
for (enumerator->First(); enumerator->IsDone() != NS_OK; enumerator->Next())
PRBool hasMore = PR_FALSE;
while (NS_SUCCEEDED(rv = enumerator->HasMoreElements(&hasMore)) && (hasMore == PR_TRUE))
{
nsIMsgDBHdr *pMessage = nsnull;
ret = enumerator->CurrentItem((nsISupports**)&pMessage);
NS_ASSERTION(NS_SUCCEEDED(ret), "nsMsgDBEnumerator broken");
if (NS_FAILED(ret))
rv = enumerator->GetNext((nsISupports**)&pMessage);
NS_ASSERTION(NS_SUCCEEDED(rv), "nsMsgDBEnumerator broken");
if (NS_FAILED(rv))
break;
#ifdef DEBUG_bienvenu
@ -2821,7 +2856,7 @@ nsresult nsMsgDatabase::DumpThread(nsMsgKey threadId)
}
}
return ret;
return rv;
}
#endif /* DEBUG */

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

@ -79,7 +79,7 @@ nsresult nsMsgHdr::InitCachedValues()
err = GetUInt32Column(m_mdb->m_threadParentColumnToken, &m_threadParent);
if (NS_SUCCEEDED(err))
m_numReferences = (PRUint16) uint32Value;
if (NS_SUCCEEDED(err))
m_cachedValuesInitialized = PR_TRUE;
}
@ -427,8 +427,8 @@ NS_IMETHODIMP nsMsgHdr::GetStatusOffset(PRUint32 *result)
NS_IMETHODIMP nsMsgHdr::SetPriority(nsMsgPriority priority)
{
m_priority = priority;
return NS_OK;
SetUInt32Column((PRUint32) priority, m_mdb->m_priorityColumnToken);
return NS_OK;
}
NS_IMETHODIMP nsMsgHdr::GetPriority(nsMsgPriority *result)
@ -436,7 +436,10 @@ NS_IMETHODIMP nsMsgHdr::GetPriority(nsMsgPriority *result)
if (!result)
return NS_ERROR_NULL_POINTER;
*result = m_priority;
PRUint32 priority = 0;
nsresult res = GetUInt32Column(m_mdb->m_priorityColumnToken, &priority);
*result = (nsMsgPriority) priority;
return NS_OK;
}
@ -465,7 +468,6 @@ NS_IMETHODIMP nsMsgHdr::GetLineCount(PRUint32 *result)
NS_IMETHODIMP nsMsgHdr::SetPriority(const char *priority)
{
// m_priority = MSG_GetPriorityFromString(priority);
nsMsgPriority priorityVal = nsMsgPriorityNormal;
// NS_MsgGetPriorityFromString will return normal in case of error,

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

@ -487,12 +487,12 @@ PRBool nsMsgThread::TryReferenceThreading(nsIMsgDBHdr *newHeader)
}
class nsMsgThreadEnumerator : public nsIEnumerator {
class nsMsgThreadEnumerator : public nsISimpleEnumerator {
public:
NS_DECL_ISUPPORTS
// nsIEnumerator methods:
NS_DECL_NSIENUMERATOR
// nsISimpleEnumerator methods:
NS_DECL_NSISIMPLEENUMERATOR
// nsMsgThreadEnumerator methods:
typedef nsresult (*nsMsgThreadEnumeratorFilter)(nsIMsgDBHdr* hdr, void* closure);
@ -503,6 +503,9 @@ public:
virtual ~nsMsgThreadEnumerator();
protected:
nsresult Prefetch();
nsIMdbTableRowCursor* mRowCursor;
nsCOMPtr <nsIMsgDBHdr> mResultHdr;
nsMsgThread* mThread;
@ -510,6 +513,7 @@ protected:
nsMsgKey mFirstMsgKey;
PRInt32 mChildIndex;
PRBool mDone;
PRBool mNeedToPrefetch;
nsMsgThreadEnumeratorFilter mFilter;
void* mClosure;
};
@ -523,6 +527,7 @@ nsMsgThreadEnumerator::nsMsgThreadEnumerator(nsMsgThread *thread, nsMsgKey start
mThreadParentKey = startKey;
mChildIndex = 0;
mThread = thread;
mNeedToPrefetch = PR_TRUE;
mFirstMsgKey = nsMsgKey_None;
nsresult rv = mThread->GetRootHdr(nsnull, getter_AddRefs(mResultHdr));
@ -589,19 +594,8 @@ nsMsgThreadEnumerator::~nsMsgThreadEnumerator()
NS_RELEASE(mThread);
}
NS_IMPL_ISUPPORTS(nsMsgThreadEnumerator, nsIEnumerator::GetIID())
NS_IMPL_ISUPPORTS(nsMsgThreadEnumerator, nsISimpleEnumerator::GetIID())
NS_IMETHODIMP nsMsgThreadEnumerator::First(void)
{
nsresult rv = NS_OK;
if (!mThread)
return NS_ERROR_NULL_POINTER;
rv = Next();
NS_ASSERTION(mThreadParentKey != nsMsgKey_None || NS_SUCCEEDED(rv), "first failed, can't have that");
return rv;
}
PRInt32 nsMsgThreadEnumerator::MsgKeyFirstChildIndex(nsMsgKey inMsgKey)
{
@ -643,7 +637,25 @@ PRInt32 nsMsgThreadEnumerator::MsgKeyFirstChildIndex(nsMsgKey inMsgKey)
return firstChildIndex;
}
NS_IMETHODIMP nsMsgThreadEnumerator::Next(void)
NS_IMETHODIMP nsMsgThreadEnumerator::GetNext(nsISupports **aItem)
{
if (!aItem)
return NS_ERROR_NULL_POINTER;
nsresult rv = NS_OK;
if (mNeedToPrefetch)
rv = Prefetch();
if (NS_SUCCEEDED(rv) && mResultHdr)
{
*aItem = mResultHdr;
NS_ADDREF(*aItem);
mNeedToPrefetch = PR_TRUE;
}
return rv;
}
nsresult nsMsgThreadEnumerator::Prefetch()
{
nsresult rv=NS_OK; // XXX or should this default to an error?
mResultHdr = nsnull;
@ -694,28 +706,21 @@ NS_IMETHODIMP nsMsgThreadEnumerator::Next(void)
printf("next for %ld = %ld\n", mThreadParentKey, debugMsgKey);
#endif
return rv;
return rv;
}
NS_IMETHODIMP nsMsgThreadEnumerator::CurrentItem(nsISupports **aItem)
NS_IMETHODIMP nsMsgThreadEnumerator::HasMoreElements(PRBool *aResult)
{
if (!aItem)
if (!aResult)
return NS_ERROR_NULL_POINTER;
if (mResultHdr) {
*aItem = mResultHdr;
NS_ADDREF(*aItem);
return NS_OK;
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP nsMsgThreadEnumerator::IsDone(void)
{
return mDone ? NS_OK : NS_COMFALSE;
if (mNeedToPrefetch)
Prefetch();
*aResult = !mDone;
return NS_OK;
}
NS_IMETHODIMP nsMsgThread::EnumerateMessages(nsMsgKey parentKey, nsIEnumerator* *result)
NS_IMETHODIMP nsMsgThread::EnumerateMessages(nsMsgKey parentKey, nsISimpleEnumerator* *result)
{
nsresult ret = NS_OK;
nsMsgThreadEnumerator* e = new nsMsgThreadEnumerator(this, parentKey, nsnull, nsnull);

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

@ -286,13 +286,12 @@ NS_IMETHODIMP nsNewsDatabase::GetLowWaterArticleNum(nsMsgKey *key)
nsresult rv;
nsMsgHdr *pHeader;
nsCOMPtr<nsIEnumerator> hdrs;
nsCOMPtr<nsISimpleEnumerator> hdrs;
rv = EnumerateMessages(getter_AddRefs(hdrs));
if (NS_FAILED(rv))
return rv;
hdrs->First();
rv = hdrs->CurrentItem((nsISupports**)&pHeader);
rv = hdrs->GetNext((nsISupports**)&pHeader);
NS_ASSERTION(NS_SUCCEEDED(rv), "nsMsgDBEnumerator broken");
if (NS_FAILED(rv))
return rv;

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

@ -189,6 +189,7 @@ NS_IMETHODIMP nsImapMailFolder::GetPath(nsIFileSpec** aPathName)
NS_IMETHODIMP nsImapMailFolder::Enumerate(nsIEnumerator* *result)
{
#if 0
nsresult rv = NS_OK;
nsIEnumerator* folders;
nsIEnumerator* messages;
@ -198,6 +199,9 @@ NS_IMETHODIMP nsImapMailFolder::Enumerate(nsIEnumerator* *result)
if (NS_FAILED(rv)) return rv;
return NS_NewConjoiningEnumerator(folders, messages,
(nsIBidirectionalEnumerator**)result);
#endif
NS_ASSERTION(PR_FALSE, "obsolete, right?");
return NS_ERROR_FAILURE;
}
nsresult nsImapMailFolder::AddDirectorySeparator(nsFileSpec &path)
@ -410,7 +414,7 @@ nsresult nsImapMailFolder::GetDatabase()
return folderOpen;
}
NS_IMETHODIMP nsImapMailFolder::GetMessages(nsIEnumerator* *result)
NS_IMETHODIMP nsImapMailFolder::GetMessages(nsISimpleEnumerator* *result)
{
nsresult rv = NS_ERROR_NULL_POINTER;
PRBool selectFolder = PR_FALSE;
@ -447,7 +451,7 @@ NS_IMETHODIMP nsImapMailFolder::GetMessages(nsIEnumerator* *result)
if(NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIEnumerator> msgHdrEnumerator;
nsCOMPtr<nsISimpleEnumerator> msgHdrEnumerator;
nsMessageFromMsgHdrEnumerator *messageEnumerator = nsnull;
rv = NS_ERROR_UNEXPECTED;
if (mDatabase)

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

@ -96,16 +96,16 @@ public:
NS_DECL_ISUPPORTS_INHERITED
// nsICollection methods:
NS_IMETHOD Enumerate(nsIEnumerator* *result);
// nsICollection methods
NS_IMETHOD Enumerate(nsIEnumerator **result);
// nsIFolder methods:
NS_IMETHOD GetSubFolders(nsIEnumerator* *result);
// nsIMsgFolder methods:
NS_IMETHOD AddUnique(nsISupports* element);
NS_IMETHOD ReplaceElement(nsISupports* element, nsISupports* newElement);
NS_IMETHOD GetMessages(nsIEnumerator* *result);
NS_IMETHOD GetMessages(nsISimpleEnumerator* *result);
NS_IMETHOD CreateSubfolder(const char *folderName);

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

@ -294,6 +294,7 @@ nsresult nsMsgLocalMailFolder::ParseFolder(nsFileSpec& path)
NS_IMETHODIMP
nsMsgLocalMailFolder::Enumerate(nsIEnumerator* *result)
{
#if 0
nsresult rv;
// local mail folders contain both messages and folders:
@ -305,6 +306,9 @@ nsMsgLocalMailFolder::Enumerate(nsIEnumerator* *result)
if (NS_FAILED(rv)) return rv;
return NS_NewConjoiningEnumerator(folders, messages,
(nsIBidirectionalEnumerator**)result);
#endif
NS_ASSERTION(PR_FALSE, "isn't this obsolete?");
return NS_ERROR_FAILURE;
}
nsresult
@ -457,13 +461,13 @@ nsresult nsMsgLocalMailFolder::GetDatabase()
}
NS_IMETHODIMP
nsMsgLocalMailFolder::GetMessages(nsIEnumerator* *result)
nsMsgLocalMailFolder::GetMessages(nsISimpleEnumerator* *result)
{
nsresult rv = GetDatabase();
if(NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIEnumerator> msgHdrEnumerator;
nsCOMPtr<nsISimpleEnumerator> msgHdrEnumerator;
nsMessageFromMsgHdrEnumerator *messageEnumerator = nsnull;
rv = mDatabase->EnumerateMessages(getter_AddRefs(msgHdrEnumerator));
if(NS_SUCCEEDED(rv))

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

@ -83,7 +83,7 @@ public:
// nsIMsgFolder methods:
NS_IMETHOD AddUnique(nsISupports* element);
NS_IMETHOD ReplaceElement(nsISupports* element, nsISupports* newElement);
NS_IMETHOD GetMessages(nsIEnumerator* *result);
NS_IMETHOD GetMessages(nsISimpleEnumerator* *result);
NS_IMETHOD CreateSubfolder(const char *folderName);

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

@ -255,7 +255,7 @@ NS_IMETHODIMP
nsMsgNewsFolder::Enumerate(nsIEnumerator **result)
{
nsresult rv = NS_OK;
#if 0
// for now, news folders contain both messages and folders
// server is a folder, and it contains folders
// newsgroup is a folder, and it contains messages
@ -270,7 +270,9 @@ nsMsgNewsFolder::Enumerate(nsIEnumerator **result)
if (NS_FAILED(rv)) return rv;
return NS_NewConjoiningEnumerator(folders, messages,
(nsIBidirectionalEnumerator**)result);
return NS_OK;
#endif
NS_ASSERTION(PR_FALSE, "obsolete, right?");
return NS_ERROR_FAILURE;
}
nsresult
@ -377,7 +379,7 @@ nsresult nsMsgNewsFolder::GetDatabase()
}
NS_IMETHODIMP
nsMsgNewsFolder::GetMessages(nsIEnumerator* *result)
nsMsgNewsFolder::GetMessages(nsISimpleEnumerator* *result)
{
#ifdef DEBUG_NEWS
printf("nsMsgNewsFolder::GetMessages(%s)\n",mURI);
@ -409,68 +411,16 @@ nsMsgNewsFolder::GetMessages(nsIEnumerator* *result)
number_to_show = 0;
}
if (number_to_show) {
rv = GetDatabase();
rv = GetDatabase();
*result = nsnull;
if(NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIEnumerator> msgHdrEnumerator;
nsMessageFromMsgHdrEnumerator *messageEnumerator = nsnull;
rv = mDatabase->EnumerateMessages(getter_AddRefs(msgHdrEnumerator));
nsCOMPtr <nsISupportsArray> shortlist;
if(NS_SUCCEEDED(rv)) {
NS_NewISupportsArray(getter_AddRefs(shortlist));
PRInt32 total = 0;
for (msgHdrEnumerator->First(); NS_FAILED(msgHdrEnumerator->IsDone()); msgHdrEnumerator->Next()) {
total++;
}
#ifdef DEBUG_NEWS
printf("total = %d\n",total);
#endif
PRInt32 count = 0;
for (msgHdrEnumerator->First(); NS_FAILED(msgHdrEnumerator->IsDone()); msgHdrEnumerator->Next()) {
if (count >= (total - number_to_show)) {
nsCOMPtr<nsISupports> i;
rv = msgHdrEnumerator->CurrentItem(getter_AddRefs(i));
if (NS_FAILED(rv)) return rv;
shortlist->AppendElement(i);
#ifdef DEBUG_NEWS
printf("not skipping %d\n", count);
#endif
}
#ifdef DEBUG_NEWS
else {
printf("skipping %d\n", count);
}
#endif
count++;
}
if (NS_SUCCEEDED(rv)) {
nsCOMPtr <nsIBidirectionalEnumerator> enumerator;
rv = NS_NewISupportsArrayEnumerator(shortlist, getter_AddRefs(enumerator));
if (NS_SUCCEEDED(rv)) {
rv = NS_NewMessageFromMsgHdrEnumerator(enumerator,
this, &messageEnumerator);
*result = messageEnumerator;
}
}
}
}
}
else {
rv = GetDatabase();
*result = nsnull;
if(NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIEnumerator> msgHdrEnumerator;
nsMessageFromMsgHdrEnumerator *messageEnumerator = nsnull;
rv = mDatabase->EnumerateMessages(getter_AddRefs(msgHdrEnumerator));
if(NS_SUCCEEDED(rv))
rv = NS_NewMessageFromMsgHdrEnumerator(msgHdrEnumerator, this, &messageEnumerator);
*result = messageEnumerator;
}
if(NS_SUCCEEDED(rv)) {
nsCOMPtr<nsISimpleEnumerator> msgHdrEnumerator;
nsMessageFromMsgHdrEnumerator *messageEnumerator = nsnull;
rv = mDatabase->EnumerateMessages(getter_AddRefs(msgHdrEnumerator));
if(NS_SUCCEEDED(rv))
rv = NS_NewMessageFromMsgHdrEnumerator(msgHdrEnumerator, this, &messageEnumerator);
*result = messageEnumerator;
}
rv = GetNewMessages();

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

@ -52,7 +52,7 @@ public:
// nsIMsgFolder methods:
NS_IMETHOD AddUnique(nsISupports* element);
NS_IMETHOD ReplaceElement(nsISupports* element, nsISupports* newElement);
NS_IMETHOD GetMessages(nsIEnumerator* *result);
NS_IMETHOD GetMessages(nsISimpleEnumerator* *result);
NS_IMETHOD CreateSubfolder(const char *folderName);