--- a/mailnews/base/src/nsMsgBiffManager.cpp
+++ b/mailnews/base/src/nsMsgBiffManager.cpp
@@ -163,34 +163,34 @@ NS_IMETHODIMP nsMsgBiffManager::Observe(
mBiffTimer->InitWithFuncCallback(OnBiffTimer, (void*)this, 10000,
nsITimer::TYPE_ONE_SHOT);
}
return NS_OK;
}
NS_IMETHODIMP nsMsgBiffManager::AddServerBiff(nsIMsgIncomingServer *server)
{
+ NS_ENSURE_ARG_POINTER(server);
+
PRInt32 biffMinutes;
nsresult rv = server->GetBiffMinutes(&biffMinutes);
- if (NS_FAILED(rv))
- return rv;
+ NS_ENSURE_SUCCESS(rv, rv);
// Don't add if biffMinutes isn't > 0
if (biffMinutes > 0)
{
PRInt32 serverIndex = FindServer(server);
// Only add it if it hasn't been added already.
if (serverIndex == -1)
{
nsBiffEntry biffEntry;
biffEntry.server = server;
rv = SetNextBiffTime(biffEntry, PR_Now());
- if (NS_FAILED(rv))
- return rv;
+ NS_ENSURE_SUCCESS(rv, rv);
AddBiffEntry(biffEntry);
SetupNextBiff();
}
}
return NS_OK;
}
@@ -213,16 +213,18 @@ NS_IMETHODIMP nsMsgBiffManager::ForceBif
NS_IMETHODIMP nsMsgBiffManager::ForceBiffAll()
{
return NS_OK;
}
NS_IMETHODIMP nsMsgBiffManager::OnServerLoaded(nsIMsgIncomingServer *server)
{
+ NS_ENSURE_ARG_POINTER(server);
+
bool doBiff = false;
nsresult rv = server->GetDoBiff(&doBiff);
if (NS_SUCCEEDED(rv) && doBiff)
rv = AddServerBiff(server);
return rv;
}
@@ -262,18 +264,17 @@ nsresult nsMsgBiffManager::AddBiffEntry(
PR_LOG(MsgBiffLogModule, PR_LOG_ALWAYS, ("inserting biff entry at %d\n", i));
mBiffArray.InsertElementAt(i, biffEntry);
return NS_OK;
}
nsresult nsMsgBiffManager::SetNextBiffTime(nsBiffEntry &biffEntry, PRTime currentTime)
{
nsIMsgIncomingServer *server = biffEntry.server;
- if (!server)
- return NS_ERROR_FAILURE;
+ NS_ENSURE_TRUE(server, NS_ERROR_FAILURE);
PRInt32 biffInterval;
nsresult rv = server->GetBiffMinutes(&biffInterval);
NS_ENSURE_SUCCESS(rv, rv);
// Add biffInterval, converted in microseconds, to current time.
// Force 64-bit multiplication.
PRTime chosenTimeInterval = biffInterval * 60000000LL;
--- a/mailnews/base/src/nsMsgSearchDBView.cpp
+++ b/mailnews/base/src/nsMsgSearchDBView.cpp
@@ -198,18 +198,18 @@ void nsMsgSearchDBView::InternalClose()
m_threadsTable.Clear();
m_hdrsTable.Clear();
nsMsgGroupView::InternalClose();
m_folders.Clear();
}
NS_IMETHODIMP nsMsgSearchDBView::GetCellText(PRInt32 aRow, nsITreeColumn* aCol, nsAString& aValue)
{
- if (!IsValidIndex(aRow))
- return NS_MSG_INVALID_DBVIEW_INDEX;
+ NS_ENSURE_TRUE(IsValidIndex(aRow), NS_MSG_INVALID_DBVIEW_INDEX);
+ NS_ENSURE_ARG_POINTER(aCol);
const PRUnichar* colID;
aCol->GetIdConst(&colID);
// the only thing we contribute is location; dummy rows have no location, so
// bail in that case. otherwise, check if we are dealing with 'location'.
// location, need to check for "lo" not just "l" to avoid "label" column
if (!(m_flags[aRow] & MSG_VIEW_FLAG_DUMMY) &&
colID[0] == 'l' && colID[1] == 'o')
@@ -411,16 +411,17 @@ nsresult nsMsgSearchDBView::GetMsgHdrFor
rv = db->GetMsgHdrForKey(m_keys[index], msgHdr);
}
return rv;
}
NS_IMETHODIMP nsMsgSearchDBView::GetFolderForViewIndex(nsMsgViewIndex index, nsIMsgFolder **aFolder)
{
NS_ENSURE_ARG_POINTER(aFolder);
+
if (index == nsMsgViewIndex_None || index >= (PRUint32) m_folders.Count())
return NS_MSG_INVALID_DBVIEW_INDEX;
NS_IF_ADDREF(*aFolder = m_folders[index]);
return *aFolder ? NS_OK : NS_ERROR_NULL_POINTER;
}
nsresult nsMsgSearchDBView::GetDBForViewIndex(nsMsgViewIndex index, nsIMsgDatabase **db)
{
@@ -744,17 +745,16 @@ nsMsgSearchDBView::OnNewSearch()
{
PRInt32 oldSize = GetSize();
PRInt32 count = m_dbToUseList.Count();
for(PRInt32 j = 0; j < count; j++)
m_dbToUseList[j]->RemoveListener(this);
m_dbToUseList.Clear();
-
m_folders.Clear();
m_keys.Clear();
m_levels.Clear();
m_flags.Clear();
m_totalMessagesInView = 0;
// needs to happen after we remove the keys, since RowCountChanged() will call our GetRowCount()
if (mTree)
@@ -1078,17 +1078,16 @@ nsMsgSearchDBView::GetMessageId(nsACStri
}
NS_IMETHODIMP
nsMsgSearchDBView::OnStopCopy(nsresult aStatus)
{
if (NS_SUCCEEDED(aStatus))
{
mCurIndex++;
- PRUint32 numFolders = 0;
if (mCurIndex < (PRUint32) m_uniqueFoldersSelected.Count())
{
nsCOMPtr<nsIMsgWindow> msgWindow(do_QueryReferent(mMsgWindowWeak));
ProcessRequestsInOneFolder(msgWindow);
}
}
return NS_OK;
}
@@ -1285,16 +1284,18 @@ nsMsgViewIndex nsMsgSearchDBView::FindHd
// This method looks for the XF thread that corresponds to this message hdr,
// first by looking up the message id, then references, and finally, if subject
// threading is turned on, the subject.
nsresult nsMsgSearchDBView::GetXFThreadFromMsgHdr(nsIMsgDBHdr *msgHdr,
nsIMsgThread **pThread,
bool *foundByMessageId)
{
+ NS_ENSURE_ARG_POINTER(pThread);
+
nsCAutoString messageId;
msgHdr->GetMessageId(getter_Copies(messageId));
*pThread = nsnull;
m_threadsTable.Get(messageId, pThread);
// The caller may want to know if we found the thread by the msgHdr's
// messageId
if (foundByMessageId)
*foundByMessageId = *pThread != nsnull;
@@ -1347,24 +1348,26 @@ nsresult nsMsgSearchDBView::AddRefToHash
return NS_OK;
return m_threadsTable.Put(reference, thread);
}
nsresult nsMsgSearchDBView::AddMsgToHashTables(nsIMsgDBHdr *msgHdr,
nsIMsgThread *thread)
{
+ NS_ENSURE_ARG_POINTER(msgHdr);
+
PRUint16 numReferences = 0;
nsresult rv;
msgHdr->GetNumReferences(&numReferences);
for (PRInt32 i = 0; i < numReferences; i++)
{
nsCAutoString reference;
-
+
msgHdr->GetStringReference(i, reference);
if (reference.IsEmpty())
break;
rv = AddRefToHash(reference, thread);
NS_ENSURE_SUCCESS(rv, rv);
}
@@ -1384,16 +1387,18 @@ nsresult nsMsgSearchDBView::AddMsgToHash
nsresult nsMsgSearchDBView::RemoveRefFromHash(nsCString &reference)
{
m_threadsTable.Remove(reference);
return NS_OK;
}
nsresult nsMsgSearchDBView::RemoveMsgFromHashTables(nsIMsgDBHdr *msgHdr)
{
+ NS_ENSURE_ARG_POINTER(msgHdr);
+
PRUint16 numReferences = 0;
nsresult rv = NS_OK;
msgHdr->GetNumReferences(&numReferences);
for (PRInt32 i = 0; i < numReferences; i++)
{
nsCAutoString reference;
@@ -1435,21 +1440,23 @@ NS_IMETHODIMP nsMsgSearchDBView::GetThre
// if not threaded, use the real thread.
nsCOMPtr<nsIMsgDatabase> msgDB;
nsresult rv = GetDBForHeader(msgHdr, getter_AddRefs(msgDB));
NS_ENSURE_SUCCESS(rv, rv);
return msgDB->GetThreadContainingMsgHdr(msgHdr, pThread);
}
nsresult
-nsMsgSearchDBView::ListIdsInThread(nsIMsgThread *threadHdr,
- nsMsgViewIndex startOfThreadViewIndex,
+nsMsgSearchDBView::ListIdsInThread(nsIMsgThread *threadHdr,
+ nsMsgViewIndex startOfThreadViewIndex,
PRUint32 *pNumListed)
{
- NS_ENSURE_ARG(threadHdr);
+ NS_ENSURE_ARG_POINTER(threadHdr);
+ NS_ENSURE_ARG_POINTER(pNumListed);
+
// these children ids should be in thread order.
PRUint32 i;
nsMsgViewIndex viewIndex = startOfThreadViewIndex + 1;
*pNumListed = 0;
PRUint32 numChildren;
threadHdr->GetNumChildren(&numChildren);
NS_ASSERTION(numChildren, "Empty thread in view/db");
old mode 100755
new mode 100644
--- a/mailnews/base/src/nsMsgXFVirtualFolderDBView.cpp
+++ b/mailnews/base/src/nsMsgXFVirtualFolderDBView.cpp
@@ -319,16 +319,18 @@ nsMsgXFVirtualFolderDBView::OnSearchHit(
m_totalMessagesInView++;
return NS_OK;
}
NS_IMETHODIMP
nsMsgXFVirtualFolderDBView::OnSearchDone(nsresult status)
{
+ NS_ENSURE_TRUE(m_viewFolder, NS_ERROR_NOT_INITIALIZED);
+
// handle any non verified hits we haven't handled yet.
if (NS_SUCCEEDED(status) && !m_doingQuickSearch && status != NS_MSG_SEARCH_INTERRUPTED)
UpdateCacheAndViewForPrevSearchedFolders(nsnull);
m_doingSearch = false;
//we want to set imap delete model once the search is over because setting next
//message after deletion will happen before deleting the message and search scope
//can change with every search.
@@ -397,18 +399,17 @@ nsMsgXFVirtualFolderDBView::OnNewSearch(
// to use the search results cache, we'll need to iterate over the scopes in the
// search session, calling getNthSearchScope for i = 0; i < searchSession.countSearchScopes; i++
// and for each folder, then open the db and pull out the cached hits, add them to the view.
// For each hit in a new folder, we'll then clean up the stale hits from the previous folder(s).
PRInt32 scopeCount;
nsCOMPtr<nsIMsgSearchSession> searchSession = do_QueryReferent(m_searchSession);
- if (!searchSession)
- return NS_OK; // just ignore
+ NS_ENSURE_TRUE(searchSession, NS_OK); // just ignore
nsCOMPtr<nsIMsgDBService> msgDBService = do_GetService(NS_MSGDB_SERVICE_CONTRACTID);
searchSession->CountSearchScopes(&scopeCount);
// Figure out how many search terms the virtual folder has.
nsCOMPtr<nsIMsgDatabase> virtDatabase;
nsCOMPtr<nsIDBFolderInfo> dbFolderInfo;
nsresult rv = m_viewFolder->GetDBFolderInfoAndDB(getter_AddRefs(dbFolderInfo), getter_AddRefs(virtDatabase));
NS_ENSURE_SUCCESS(rv, rv);
old mode 100755
new mode 100644
--- a/mailnews/extensions/bayesian-spam-filter/src/nsBayesianFilter.cpp
+++ b/mailnews/extensions/bayesian-spam-filter/src/nsBayesianFilter.cpp
@@ -1102,23 +1102,21 @@ NS_IMETHODIMP TokenStreamListener::GetPr
{
return NS_ERROR_NOT_IMPLEMENTED;
}
/* void onStartRequest (in nsIRequest aRequest, in nsISupports aContext); */
NS_IMETHODIMP TokenStreamListener::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext)
{
mLeftOverCount = 0;
- if (!mTokenizer)
- return NS_ERROR_OUT_OF_MEMORY;
+ NS_ENSURE_TRUE(mTokenizer, NS_ERROR_OUT_OF_MEMORY);
if (!mBuffer)
{
mBuffer = new char[mBufferSize];
- if (!mBuffer)
- return NS_ERROR_OUT_OF_MEMORY;
+ NS_ENSURE_TRUE(mBuffer, NS_ERROR_OUT_OF_MEMORY);
}
// get the url for the channel and set our nsIMsgHeaderSink on it so we get notified
// about the headers and attachments
nsCOMPtr<nsIChannel> channel (do_QueryInterface(aRequest));
if (channel)
{
@@ -1146,18 +1144,17 @@ NS_IMETHODIMP TokenStreamListener::OnDat
}
// mBuffer is supposed to be allocated in onStartRequest. But something
// is causing that to not happen, so as a last-ditch attempt we'll
// do it here.
if (!mBuffer)
{
mBuffer = new char[mBufferSize];
- if (!mBuffer)
- return NS_ERROR_OUT_OF_MEMORY;
+ NS_ENSURE_TRUE(mBuffer, NS_ERROR_OUT_OF_MEMORY);
}
char* buffer = mBuffer;
rv = aInputStream->Read(buffer + mLeftOverCount, readCount, &readCount);
if (NS_FAILED(rv))
break;
if (readCount == 0) {
@@ -1189,17 +1186,17 @@ NS_IMETHODIMP TokenStreamListener::OnDat
if (mLeftOverCount)
memmove(buffer, buffer + consumedCount, mLeftOverCount);
} else {
/* didn't find a delimiter, keep the whole buffer around. */
mLeftOverCount = totalCount;
if (totalCount >= (mBufferSize / 2)) {
PRUint32 newBufferSize = mBufferSize * 2;
char* newBuffer = new char[newBufferSize];
- if (!newBuffer) return NS_ERROR_OUT_OF_MEMORY;
+ NS_ENSURE_TRUE(newBuffer, NS_ERROR_OUT_OF_MEMORY);
memcpy(newBuffer, mBuffer, mLeftOverCount);
delete[] mBuffer;
mBuffer = newBuffer;
mBufferSize = newBufferSize;
}
}
}
@@ -1422,16 +1419,17 @@ private:
nsCOMPtr<nsIMsgWindow> mMsgWindow;
PRInt32 mNumMessagesToClassify;
PRInt32 mCurMessageToClassify; // 0-based index
char **mMessageURIs;
};
nsresult nsBayesianFilter::tokenizeMessage(const char* aMessageURI, nsIMsgWindow *aMsgWindow, TokenAnalyzer* aAnalyzer)
{
+ NS_ENSURE_ARG_POINTER(aMessageURI);
nsCOMPtr <nsIMsgMessageService> msgService;
nsresult rv = GetMessageServiceFromURI(nsDependentCString(aMessageURI), getter_AddRefs(msgService));
NS_ENSURE_SUCCESS(rv, rv);
aAnalyzer->setSource(aMessageURI);
return msgService->StreamMessage(aMessageURI, aAnalyzer->mTokenListener,
aMsgWindow, nsnull, true /* convert data */,
@@ -1876,34 +1874,32 @@ NS_IMETHODIMP nsBayesianFilter::GetShoul
*aShouldDownloadAllHeaders = false;
return NS_OK;
}
/* void classifyMessage (in string aMsgURL, in nsIJunkMailClassificationListener aListener); */
NS_IMETHODIMP nsBayesianFilter::ClassifyMessage(const char *aMessageURL, nsIMsgWindow *aMsgWindow, nsIJunkMailClassificationListener *aListener)
{
MessageClassifier* analyzer = new MessageClassifier(this, aListener, aMsgWindow, 1, &aMessageURL);
- if (!analyzer)
- return NS_ERROR_OUT_OF_MEMORY;
+ NS_ENSURE_TRUE(analyzer, NS_ERROR_OUT_OF_MEMORY);
TokenStreamListener *tokenListener = new TokenStreamListener(analyzer);
- if (!tokenListener)
- return NS_ERROR_OUT_OF_MEMORY;
+ NS_ENSURE_TRUE(tokenListener, NS_ERROR_OUT_OF_MEMORY);
analyzer->setTokenListener(tokenListener);
return tokenizeMessage(aMessageURL, aMsgWindow, analyzer);
}
/* void classifyMessages (in unsigned long aCount, [array, size_is (aCount)] in string aMsgURLs, in nsIJunkMailClassificationListener aListener); */
NS_IMETHODIMP nsBayesianFilter::ClassifyMessages(PRUint32 aCount, const char **aMsgURLs, nsIMsgWindow *aMsgWindow, nsIJunkMailClassificationListener *aListener)
{
+ NS_ENSURE_ARG_POINTER(aMsgURLs);
+
TokenAnalyzer* analyzer = new MessageClassifier(this, aListener, aMsgWindow, aCount, aMsgURLs);
- if (!analyzer)
- return NS_ERROR_OUT_OF_MEMORY;
+ NS_ENSURE_TRUE(analyzer, NS_ERROR_OUT_OF_MEMORY);
TokenStreamListener *tokenListener = new TokenStreamListener(analyzer);
- if (!tokenListener)
- return NS_ERROR_OUT_OF_MEMORY;
+ NS_ENSURE_TRUE(tokenListener, NS_ERROR_OUT_OF_MEMORY);
analyzer->setTokenListener(tokenListener);
return tokenizeMessage(aMsgURLs[0], aMsgWindow, analyzer);
}
nsresult nsBayesianFilter::setAnalysis(Token& token, PRUint32 aTraitIndex,
double aDistance, double aProbability)
{
PRUint32 nextLink = token.mAnalysisLink;
@@ -1995,22 +1991,20 @@ NS_IMETHODIMP nsBayesianFilter::Classify
proTraits.SetCapacity(aTraitCount);
antiTraits.SetCapacity(aTraitCount);
}
proTraits.AppendElements(aProTraits, aTraitCount);
antiTraits.AppendElements(aAntiTraits, aTraitCount);
MessageClassifier* analyzer = new MessageClassifier(this, aJunkListener,
aTraitListener, nsnull, proTraits, antiTraits, aMsgWindow, aCount, aMsgURIs);
- if (!analyzer)
- return NS_ERROR_OUT_OF_MEMORY;
+ NS_ENSURE_TRUE(analyzer, NS_ERROR_OUT_OF_MEMORY);
TokenStreamListener *tokenListener = new TokenStreamListener(analyzer);
- if (!tokenListener)
- return NS_ERROR_OUT_OF_MEMORY;
+ NS_ENSURE_TRUE(tokenListener, NS_ERROR_OUT_OF_MEMORY);
analyzer->setTokenListener(tokenListener);
return tokenizeMessage(aMsgURIs[0], aMsgWindow, analyzer);
}
class MessageObserver : public TokenAnalyzer {
public:
MessageObserver(nsBayesianFilter* filter,
@@ -2058,21 +2052,21 @@ NS_IMETHODIMP nsBayesianFilter::SetMsgTr
oldTraits.SetCapacity(aOldCount);
if (aNewCount > kTraitAutoCapacity)
newTraits.SetCapacity(aNewCount);
oldTraits.AppendElements(aOldTraits, aOldCount);
newTraits.AppendElements(aNewTraits, aNewCount);
MessageObserver* analyzer = new MessageObserver(this, oldTraits,
newTraits, aJunkListener, aTraitListener);
- if (!analyzer)
- return NS_ERROR_OUT_OF_MEMORY;
+ NS_ENSURE_TRUE(analyzer, NS_ERROR_OUT_OF_MEMORY);
+
TokenStreamListener *tokenListener = new TokenStreamListener(analyzer);
- if (!tokenListener)
- return NS_ERROR_OUT_OF_MEMORY;
+ NS_ENSURE_TRUE(tokenListener, NS_ERROR_OUT_OF_MEMORY);
+
analyzer->setTokenListener(tokenListener);
return tokenizeMessage(aMsgURI, aMsgWindow, analyzer);
}
// set new message classifications for a message
void nsBayesianFilter::observeMessage(
Tokenizer& tokenizer,
const char* messageURL,
@@ -2192,22 +2186,20 @@ NS_IMETHODIMP nsBayesianFilter::SetMessa
oldClassifications.AppendElement(kGoodTrait);
if (aNewClassification == nsIJunkMailPlugin::JUNK)
newClassifications.AppendElement(kJunkTrait);
else if (aNewClassification == nsIJunkMailPlugin::GOOD)
newClassifications.AppendElement(kGoodTrait);
MessageObserver* analyzer = new MessageObserver(this, oldClassifications,
newClassifications, aListener, nsnull);
- if (!analyzer)
- return NS_ERROR_OUT_OF_MEMORY;
+ NS_ENSURE_TRUE(analyzer, NS_ERROR_OUT_OF_MEMORY);
TokenStreamListener *tokenListener = new TokenStreamListener(analyzer);
- if (!tokenListener)
- return NS_ERROR_OUT_OF_MEMORY;
+ NS_ENSURE_TRUE(tokenListener, NS_ERROR_OUT_OF_MEMORY);
analyzer->setTokenListener(tokenListener);
return tokenizeMessage(aMsgURL, aMsgWindow, analyzer);
}
NS_IMETHODIMP nsBayesianFilter::ResetTrainingData()
{
if (mCorpus)
@@ -2221,22 +2213,20 @@ NS_IMETHODIMP nsBayesianFilter::DetailMe
{
nsAutoTArray<PRUint32, 1> proTraits;
nsAutoTArray<PRUint32, 1> antiTraits;
proTraits.AppendElement(aProTrait);
antiTraits.AppendElement(aAntiTrait);
MessageClassifier* analyzer = new MessageClassifier(this, nsnull,
nsnull, aDetailListener, proTraits, antiTraits, aMsgWindow, 1, &aMsgURI);
- if (!analyzer)
- return NS_ERROR_OUT_OF_MEMORY;
+ NS_ENSURE_TRUE(analyzer, NS_ERROR_OUT_OF_MEMORY);
TokenStreamListener *tokenListener = new TokenStreamListener(analyzer);
- if (!tokenListener)
- return NS_ERROR_OUT_OF_MEMORY;
+ NS_ENSURE_TRUE(tokenListener, NS_ERROR_OUT_OF_MEMORY);
analyzer->setTokenListener(tokenListener);
return tokenizeMessage(aMsgURI, aMsgWindow, analyzer);
}
// nsIMsgCorpus implementation
NS_IMETHODIMP nsBayesianFilter::CorpusCounts(PRUint32 aTrait,
--- a/mailnews/extensions/mailviews/src/nsMsgMailViewList.cpp
+++ b/mailnews/extensions/mailviews/src/nsMsgMailViewList.cpp
@@ -66,54 +66,58 @@ NS_IMPL_QUERY_INTERFACE1(nsMsgMailView,
nsMsgMailView::~nsMsgMailView()
{
if (mViewSearchTerms)
mViewSearchTerms->Clear();
}
NS_IMETHODIMP nsMsgMailView::GetMailViewName(PRUnichar ** aMailViewName)
{
- *aMailViewName = ToNewUnicode(mName);
+ NS_ENSURE_ARG_POINTER(aMailViewName);
+
+ *aMailViewName = ToNewUnicode(mName);
return NS_OK;
}
NS_IMETHODIMP nsMsgMailView::SetMailViewName(const PRUnichar * aMailViewName)
{
mName = aMailViewName;
return NS_OK;
}
NS_IMETHODIMP nsMsgMailView::GetPrettyName(PRUnichar ** aMailViewName)
{
+ NS_ENSURE_ARG_POINTER(aMailViewName);
+
nsresult rv = NS_OK;
if (!mBundle)
{
nsCOMPtr<nsIStringBundleService> bundleService =
mozilla::services::GetStringBundleService();
NS_ENSURE_TRUE(bundleService, NS_ERROR_UNEXPECTED);
bundleService->CreateBundle("chrome://messenger/locale/mailviews.properties",
getter_AddRefs(mBundle));
}
NS_ENSURE_TRUE(mBundle, NS_ERROR_FAILURE);
// see if mName has an associated pretty name inside our string bundle and if so, use that as the pretty name
// otherwise just return mName
if (mName.EqualsLiteral(kDefaultViewPeopleIKnow))
- rv = mBundle->GetStringFromName(NS_LITERAL_STRING("mailViewPeopleIKnow").get(), aMailViewName);
+ rv = mBundle->GetStringFromName(NS_LITERAL_STRING("mailViewPeopleIKnow").get(), aMailViewName);
else if (mName.EqualsLiteral(kDefaultViewRecent))
- rv = mBundle->GetStringFromName(NS_LITERAL_STRING("mailViewRecentMail").get(), aMailViewName);
+ rv = mBundle->GetStringFromName(NS_LITERAL_STRING("mailViewRecentMail").get(), aMailViewName);
else if (mName.EqualsLiteral(kDefaultViewFiveDays))
- rv = mBundle->GetStringFromName(NS_LITERAL_STRING("mailViewLastFiveDays").get(), aMailViewName);
+ rv = mBundle->GetStringFromName(NS_LITERAL_STRING("mailViewLastFiveDays").get(), aMailViewName);
else if (mName.EqualsLiteral(kDefaultViewNotJunk))
- rv = mBundle->GetStringFromName(NS_LITERAL_STRING("mailViewNotJunk").get(), aMailViewName);
+ rv = mBundle->GetStringFromName(NS_LITERAL_STRING("mailViewNotJunk").get(), aMailViewName);
else if (mName.EqualsLiteral(kDefaultViewHasAttachments))
- rv = mBundle->GetStringFromName(NS_LITERAL_STRING("mailViewHasAttachments").get(), aMailViewName);
+ rv = mBundle->GetStringFromName(NS_LITERAL_STRING("mailViewHasAttachments").get(), aMailViewName);
else
- *aMailViewName = ToNewUnicode(mName);
+ *aMailViewName = ToNewUnicode(mName);
return rv;
}
NS_IMETHODIMP nsMsgMailView::GetSearchTerms(nsISupportsArray ** aSearchTerms)
{
NS_ENSURE_ARG_POINTER(aSearchTerms);
NS_IF_ADDREF(*aSearchTerms = mViewSearchTerms);
@@ -155,28 +159,30 @@ NS_IMPL_QUERY_INTERFACE1(nsMsgMailViewLi
nsMsgMailViewList::~nsMsgMailViewList()
{
}
NS_IMETHODIMP nsMsgMailViewList::GetMailViewCount(PRUint32 * aCount)
{
+ NS_ENSURE_ARG_POINTER(aCount);
+
if (m_mailViews)
m_mailViews->Count(aCount);
else
*aCount = 0;
return NS_OK;
}
NS_IMETHODIMP nsMsgMailViewList::GetMailViewAt(PRUint32 aMailViewIndex, nsIMsgMailView ** aMailView)
{
NS_ENSURE_ARG_POINTER(aMailView);
NS_ENSURE_TRUE(m_mailViews, NS_ERROR_FAILURE);
-
+
PRUint32 mailViewCount;
m_mailViews->Count(&mailViewCount);
NS_ENSURE_TRUE(mailViewCount >= aMailViewIndex, NS_ERROR_FAILURE);
return m_mailViews->QueryElementAt(aMailViewIndex, NS_GET_IID(nsIMsgMailView),
(void **)aMailView);
}
@@ -186,55 +192,61 @@ NS_IMETHODIMP nsMsgMailViewList::AddMail
NS_ENSURE_TRUE(m_mailViews, NS_ERROR_FAILURE);
m_mailViews->AppendElement(static_cast<nsISupports*>(aMailView));
return NS_OK;
}
NS_IMETHODIMP nsMsgMailViewList::RemoveMailView(nsIMsgMailView * aMailView)
{
+ NS_ENSURE_ARG_POINTER(aMailView);
+ NS_ENSURE_TRUE(m_mailViews, NS_ERROR_FAILURE);
+
m_mailViews->RemoveElement(static_cast<nsISupports*>(aMailView));
return NS_OK;
}
NS_IMETHODIMP nsMsgMailViewList::CreateMailView(nsIMsgMailView ** aMailView)
{
NS_ENSURE_ARG_POINTER(aMailView);
nsMsgMailView * mailView = new nsMsgMailView;
NS_ENSURE_TRUE(mailView, NS_ERROR_OUT_OF_MEMORY);
- NS_IF_ADDREF(*aMailView = mailView);
+ NS_IF_ADDREF(*aMailView = mailView);
return NS_OK;
}
NS_IMETHODIMP nsMsgMailViewList::Save()
{
// brute force...remove all the old filters in our filter list, then we'll re-add our current
// list
nsCOMPtr<nsIMsgFilter> msgFilter;
- PRUint32 numFilters;
- mFilterList->GetFilterCount(&numFilters);
+ PRUint32 numFilters = 0;
+ if (mFilterList)
+ mFilterList->GetFilterCount(&numFilters);
while (numFilters)
{
mFilterList->RemoveFilterAt(numFilters - 1);
numFilters--;
}
// now convert our mail view list into a filter list and save it
ConvertMailViewListToFilterList();
// now save the filters to our file
- return mFilterList->SaveToDefaultFile();
+ return mFilterList ? mFilterList->SaveToDefaultFile() : NS_ERROR_FAILURE;
}
nsresult nsMsgMailViewList::ConvertMailViewListToFilterList()
{
PRUint32 mailViewCount = 0;
- m_mailViews->Count(&mailViewCount);
+
+ if (m_mailViews)
+ m_mailViews->Count(&mailViewCount);
nsCOMPtr<nsIMsgMailView> mailView;
nsCOMPtr<nsIMsgFilter> newMailFilter;
nsString mailViewName;
for (PRUint32 index = 0; index < mailViewCount; index++)
{
GetMailViewAt(index, getter_AddRefs(mailView));
if (!mailView)
continue;
--- a/mailnews/imap/src/nsImapService.cpp
+++ b/mailnews/imap/src/nsImapService.cpp
@@ -818,24 +818,28 @@ NS_IMETHODIMP nsImapService::CopyMessage
}
NS_IMETHODIMP nsImapService::Search(nsIMsgSearchSession *aSearchSession,
nsIMsgWindow *aMsgWindow,
nsIMsgFolder *aMsgFolder,
const char *aSearchUri)
{
NS_ENSURE_ARG_POINTER(aSearchUri);
+ NS_ENSURE_ARG_POINTER(aMsgFolder);
+ nsresult rv;
nsCOMPtr<nsIImapUrl> imapUrl;
- nsCOMPtr <nsIUrlListener> urlListener = do_QueryInterface(aSearchSession);
+ nsCOMPtr <nsIUrlListener> urlListener = do_QueryInterface(aSearchSession, &rv);
+ NS_ENSURE_SUCCESS(rv, rv);
+
nsCAutoString urlSpec;
char hierarchyDelimiter = GetHierarchyDelimiter(aMsgFolder);
- nsresult rv = CreateStartOfImapUrl(EmptyCString(), getter_AddRefs(imapUrl),
- aMsgFolder, urlListener, urlSpec,
- hierarchyDelimiter);
+ rv = CreateStartOfImapUrl(EmptyCString(), getter_AddRefs(imapUrl),
+ aMsgFolder, urlListener, urlSpec,
+ hierarchyDelimiter);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIMsgMailNewsUrl> msgurl (do_QueryInterface(imapUrl));
msgurl->SetMsgWindow(aMsgWindow);
msgurl->SetSearchSession(aSearchSession);
rv = SetImapUrlSink(aMsgFolder, imapUrl);
if (NS_SUCCEEDED(rv))
@@ -861,67 +865,66 @@ NS_IMETHODIMP nsImapService::Search(nsIM
rv = mailNewsUrl->SetSpec(urlSpec);
if (NS_SUCCEEDED(rv))
rv = GetImapConnectionAndLoadUrl(imapUrl, nsnull, nsnull);
}
return rv;
}
// just a helper method to break down imap message URIs....
-nsresult nsImapService::DecomposeImapURI(const nsACString &aMessageURI,
- nsIMsgFolder **aFolder,
+nsresult nsImapService::DecomposeImapURI(const nsACString &aMessageURI,
+ nsIMsgFolder **aFolder,
nsACString &aMsgKey)
{
nsMsgKey msgKey;
nsresult rv = DecomposeImapURI(aMessageURI, aFolder, &msgKey);
- NS_ENSURE_SUCCESS(rv,rv);
-
- if (msgKey)
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ if (msgKey)
{
nsCAutoString messageIdString;
messageIdString.AppendInt(msgKey);
aMsgKey = messageIdString;
}
return rv;
}
// just a helper method to break down imap message URIs....
-nsresult nsImapService::DecomposeImapURI(const nsACString &aMessageURI,
- nsIMsgFolder **aFolder,
+nsresult nsImapService::DecomposeImapURI(const nsACString &aMessageURI,
+ nsIMsgFolder **aFolder,
nsMsgKey *aMsgKey)
{
NS_ENSURE_ARG_POINTER(aFolder);
NS_ENSURE_ARG_POINTER(aMsgKey);
-
+
nsCAutoString folderURI;
nsresult rv = nsParseImapMessageURI(PromiseFlatCString(aMessageURI).get(),
folderURI, aMsgKey, nsnull);
- NS_ENSURE_SUCCESS(rv,rv);
-
+ NS_ENSURE_SUCCESS(rv, rv);
+
nsCOMPtr <nsIRDFService> rdf = do_GetService("@mozilla.org/rdf/rdf-service;1",&rv);
- NS_ENSURE_SUCCESS(rv,rv);
-
+ NS_ENSURE_SUCCESS(rv, rv);
+
nsCOMPtr<nsIRDFResource> res;
rv = rdf->GetResource(folderURI, getter_AddRefs(res));
- NS_ENSURE_SUCCESS(rv,rv);
-
+ NS_ENSURE_SUCCESS(rv, rv);
+
nsCOMPtr<nsIMsgFolder> msgFolder = do_QueryInterface(res);
- if (!msgFolder)
- return NS_ERROR_FAILURE;
-
+ NS_ENSURE_TRUE(msgFolder, NS_ERROR_FAILURE);
+
msgFolder.swap(*aFolder);
-
+
return NS_OK;
}
-NS_IMETHODIMP nsImapService::SaveMessageToDisk(const char *aMessageURI,
- nsIFile *aFile,
- bool aAddDummyEnvelope,
- nsIUrlListener *aUrlListener,
+NS_IMETHODIMP nsImapService::SaveMessageToDisk(const char *aMessageURI,
+ nsIFile *aFile,
+ bool aAddDummyEnvelope,
+ nsIUrlListener *aUrlListener,
nsIURI **aURL,
bool canonicalLineEnding,
nsIMsgWindow *aMsgWindow)
{
nsCOMPtr<nsIMsgFolder> folder;
nsCOMPtr<nsIImapUrl> imapUrl;
nsCAutoString msgKey;
@@ -2859,44 +2862,45 @@ NS_IMETHODIMP nsImapService::NewChannel(
return rv;
}
NS_IMETHODIMP nsImapService::SetDefaultLocalPath(nsILocalFile *aPath)
{
NS_ENSURE_ARG_POINTER(aPath);
return NS_SetPersistentFile(PREF_MAIL_ROOT_IMAP_REL, PREF_MAIL_ROOT_IMAP, aPath);
-}
+}
NS_IMETHODIMP nsImapService::GetDefaultLocalPath(nsILocalFile **aResult)
{
NS_ENSURE_ARG_POINTER(aResult);
*aResult = nsnull;
-
+
bool havePref;
- nsCOMPtr<nsILocalFile> localFile;
+ nsCOMPtr<nsILocalFile> localFile;
nsresult rv = NS_GetPersistentFile(PREF_MAIL_ROOT_IMAP_REL,
PREF_MAIL_ROOT_IMAP,
NS_APP_IMAP_MAIL_50_DIR,
havePref,
getter_AddRefs(localFile));
NS_ENSURE_SUCCESS(rv, rv);
+ NS_ENSURE_TRUE(localFile, NS_ERROR_FAILURE);
bool exists;
rv = localFile->Exists(&exists);
if (NS_SUCCEEDED(rv) && !exists)
rv = localFile->Create(nsIFile::DIRECTORY_TYPE, 0775);
NS_ENSURE_SUCCESS(rv, rv);
-
- if (!havePref || !exists)
+
+ if (!havePref || !exists)
{
rv = NS_SetPersistentFile(PREF_MAIL_ROOT_IMAP_REL, PREF_MAIL_ROOT_IMAP, localFile);
NS_ASSERTION(NS_SUCCEEDED(rv), "Failed to set root dir pref.");
}
-
+
localFile.swap(*aResult);
return NS_OK;
}
NS_IMETHODIMP nsImapService::GetServerIID(nsIID **aServerIID)
{
*aServerIID = new nsIID(NS_GET_IID(nsIImapIncomingServer));
return NS_OK;