whitespace cleanup, no bug, r/sr=me

This commit is contained in:
bienvenu%nventure.com 2003-09-11 02:30:17 +00:00
Родитель fb71c773cf
Коммит be51e4ae64
2 изменённых файлов: 259 добавлений и 252 удалений

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

@ -1048,201 +1048,201 @@ nsresult nsNNTPProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer)
nsCOMPtr <nsINNTPNewsgroupPost> message; nsCOMPtr <nsINNTPNewsgroupPost> message;
rv = m_runningURL->GetMessageToPost(getter_AddRefs(message)); rv = m_runningURL->GetMessageToPost(getter_AddRefs(message));
if (NS_SUCCEEDED(rv) && message) if (NS_SUCCEEDED(rv) && message)
{ {
m_typeWanted = NEWS_POST; m_typeWanted = NEWS_POST;
NS_MsgSACopy(&m_path, ""); NS_MsgSACopy(&m_path, "");
} }
else else
if (m_messageID || (m_key != nsMsgKey_None)) if (m_messageID || (m_key != nsMsgKey_None))
{ {
/* /*
news-message://HOST/GROUP#key news-message://HOST/GROUP#key
news://HOST/MESSAGE_ID news://HOST/MESSAGE_ID
not sure about these: not sure about these:
news:MESSAGE_ID news:MESSAGE_ID
news:/GROUP/MESSAGE_ID (useless) news:/GROUP/MESSAGE_ID (useless)
news://HOST/GROUP/MESSAGE_ID (useless) news://HOST/GROUP/MESSAGE_ID (useless)
*/ */
if (cancel) if (cancel)
m_typeWanted = CANCEL_WANTED; m_typeWanted = CANCEL_WANTED;
else else
m_typeWanted = ARTICLE_WANTED; m_typeWanted = ARTICLE_WANTED;
}
else if (!commandSpecificData.IsEmpty())
{
if (PL_strstr (commandSpecificData.get(), "?newgroups"))
/* news://HOST/?newsgroups
news:/GROUP/?newsgroups (useless)
news:?newsgroups (default host)
*/
m_typeWanted = NEW_GROUPS;
else
{
if (PL_strstr(commandSpecificData.get(), "?list-pretty"))
{
m_typeWanted = PRETTY_NAMES_WANTED;
m_commandSpecificData = ToNewCString(commandSpecificData);
}
else if (PL_strstr(commandSpecificData.get(), "?profile"))
{
m_typeWanted = PROFILE_WANTED;
m_commandSpecificData = ToNewCString(commandSpecificData);
}
else if (PL_strstr(commandSpecificData.get(), "?list-ids"))
{
m_typeWanted = IDS_WANTED;
m_commandSpecificData = ToNewCString(commandSpecificData);
rv = m_nntpServer->FindGroup(group.get(), getter_AddRefs(m_newsFolder));
if (!m_newsFolder) goto FAIL;
}
else
{
m_typeWanted = SEARCH_WANTED;
m_commandSpecificData = ToNewCString(commandSpecificData);
nsUnescape(m_commandSpecificData);
m_searchData = m_commandSpecificData;
rv = m_nntpServer->FindGroup(group.get(), getter_AddRefs(m_newsFolder));
if (!m_newsFolder) goto FAIL;
}
}
}
else if (!group.IsEmpty())
{
/* news:GROUP
news:/GROUP
news://HOST/GROUP
*/
if (PL_strchr(group.get(),'*')) {
// getting all the newsgroups on the server, for subscribe dialog
m_typeWanted = LIST_WANTED;
} }
else else if (!commandSpecificData.IsEmpty())
{ {
if (m_nntpServer) if (PL_strstr (commandSpecificData.get(), "?newgroups"))
/* news://HOST/?newsgroups
news:/GROUP/?newsgroups (useless)
news:?newsgroups (default host)
*/
m_typeWanted = NEW_GROUPS;
else
{ {
PRBool containsGroup = PR_TRUE; if (PL_strstr(commandSpecificData.get(), "?list-pretty"))
rv = m_nntpServer->ContainsNewsgroup(group.get(),&containsGroup);
if (NS_FAILED(rv)) goto FAIL;
if (!containsGroup)
{ {
// We have the name of a newsgroup which we're not subscribed to, m_typeWanted = PRETTY_NAMES_WANTED;
// the next step is to ask the user whether we should subscribe to it. m_commandSpecificData = ToNewCString(commandSpecificData);
nsCOMPtr<nsIPrompt> dialog;
if (m_msgWindow)
m_msgWindow->GetPromptDialog(getter_AddRefs(dialog));
if (!dialog)
{
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
wwatch->GetNewPrompter(nsnull, getter_AddRefs(dialog));
}
nsXPIDLString statusString, confirmText;
nsCOMPtr<nsIStringBundle> bundle;
nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID);
// to handle non-ASCII newsgroup names, we store them internally as escaped.
// decode and unescape the newsgroup name so we'll display a proper name.
nsXPIDLString unescapedName;
rv = NS_MsgDecodeUnescapeURLPath(group.get(), getter_Copies(unescapedName));
NS_ENSURE_SUCCESS(rv,rv);
bundleService->CreateBundle(NEWS_MSGS_URL, getter_AddRefs(bundle));
const PRUnichar *formatStrings[1] = { unescapedName.get() };
rv = bundle->FormatStringFromName(NS_LITERAL_STRING("autoSubscribeText").get(),
formatStrings, 1,
getter_Copies(confirmText));
NS_ENSURE_SUCCESS(rv,rv);
PRBool confirmResult = PR_FALSE;
rv = dialog->Confirm(nsnull, confirmText, &confirmResult);
NS_ENSURE_SUCCESS(rv, rv);
if (confirmResult)
{
rv = m_nntpServer->SubscribeToNewsgroup(group.get());
containsGroup = PR_TRUE;
}
else {
// XXX FIX ME
// the way news is current written, we've already opened the socket
// and initialized the connection.
//
// until that is fixed, when the user cancels an autosubscribe, we've got to close it and clean up after ourselves
//
// see bug http://bugzilla.mozilla.org/show_bug.cgi?id=108293
// another problem, autosubscribe urls are ending up as cache entries
// because the default action on nntp urls is ActionFetchArticle
//
// see bug http://bugzilla.mozilla.org/show_bug.cgi?id=108294
if (m_runningURL)
FinishMemCacheEntry(PR_FALSE); // cleanup mem cache entry
return CloseConnection();
}
} }
else if (PL_strstr(commandSpecificData.get(), "?profile"))
// If we have a group (since before, or just subscribed), set the m_newsFolder.
if (containsGroup)
{ {
m_typeWanted = PROFILE_WANTED;
m_commandSpecificData = ToNewCString(commandSpecificData);
}
else if (PL_strstr(commandSpecificData.get(), "?list-ids"))
{
m_typeWanted = IDS_WANTED;
m_commandSpecificData = ToNewCString(commandSpecificData);
rv = m_nntpServer->FindGroup(group.get(), getter_AddRefs(m_newsFolder));
if (!m_newsFolder) goto FAIL;
}
else
{
m_typeWanted = SEARCH_WANTED;
m_commandSpecificData = ToNewCString(commandSpecificData);
nsUnescape(m_commandSpecificData);
m_searchData = m_commandSpecificData;
rv = m_nntpServer->FindGroup(group.get(), getter_AddRefs(m_newsFolder)); rv = m_nntpServer->FindGroup(group.get(), getter_AddRefs(m_newsFolder));
if (!m_newsFolder) goto FAIL; if (!m_newsFolder) goto FAIL;
} }
} }
m_typeWanted = GROUP_WANTED;
} }
} else if (!group.IsEmpty())
else {
// news: or news://HOST /* news:GROUP
m_typeWanted = READ_NEWS_RC; news:/GROUP
news://HOST/GROUP
// if this connection comes from the cache, we need to initialize the */
// load group here, by generating the start request notification. nsMsgProtocol::OnStartRequest if (PL_strchr(group.get(),'*')) {
// ignores the first parameter (which is supposed to be the channel) so we'll pass in null. // getting all the newsgroups on the server, for subscribe dialog
if (m_fromCache) m_typeWanted = LIST_WANTED;
nsMsgProtocol::OnStartRequest(nsnull, aURL); }
else
/* At this point, we're all done parsing the URL, and know exactly {
what we want to do with it. if (m_nntpServer)
*/ {
PRBool containsGroup = PR_TRUE;
rv = m_nntpServer->ContainsNewsgroup(group.get(),&containsGroup);
if (NS_FAILED(rv)) goto FAIL;
if (!containsGroup)
{
// We have the name of a newsgroup which we're not subscribed to,
// the next step is to ask the user whether we should subscribe to it.
nsCOMPtr<nsIPrompt> dialog;
if (m_msgWindow)
m_msgWindow->GetPromptDialog(getter_AddRefs(dialog));
if (!dialog)
{
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
wwatch->GetNewPrompter(nsnull, getter_AddRefs(dialog));
}
nsXPIDLString statusString, confirmText;
nsCOMPtr<nsIStringBundle> bundle;
nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID);
// to handle non-ASCII newsgroup names, we store them internally as escaped.
// decode and unescape the newsgroup name so we'll display a proper name.
nsXPIDLString unescapedName;
rv = NS_MsgDecodeUnescapeURLPath(group.get(), getter_Copies(unescapedName));
NS_ENSURE_SUCCESS(rv,rv);
bundleService->CreateBundle(NEWS_MSGS_URL, getter_AddRefs(bundle));
const PRUnichar *formatStrings[1] = { unescapedName.get() };
rv = bundle->FormatStringFromName(NS_LITERAL_STRING("autoSubscribeText").get(),
formatStrings, 1,
getter_Copies(confirmText));
NS_ENSURE_SUCCESS(rv,rv);
PRBool confirmResult = PR_FALSE;
rv = dialog->Confirm(nsnull, confirmText, &confirmResult);
NS_ENSURE_SUCCESS(rv, rv);
if (confirmResult)
{
rv = m_nntpServer->SubscribeToNewsgroup(group.get());
containsGroup = PR_TRUE;
}
else {
// XXX FIX ME
// the way news is current written, we've already opened the socket
// and initialized the connection.
//
// until that is fixed, when the user cancels an autosubscribe, we've got to close it and clean up after ourselves
//
// see bug http://bugzilla.mozilla.org/show_bug.cgi?id=108293
// another problem, autosubscribe urls are ending up as cache entries
// because the default action on nntp urls is ActionFetchArticle
//
// see bug http://bugzilla.mozilla.org/show_bug.cgi?id=108294
if (m_runningURL)
FinishMemCacheEntry(PR_FALSE); // cleanup mem cache entry
return CloseConnection();
}
}
// If we have a group (since before, or just subscribed), set the m_newsFolder.
if (containsGroup)
{
rv = m_nntpServer->FindGroup(group.get(), getter_AddRefs(m_newsFolder));
if (!m_newsFolder) goto FAIL;
}
}
m_typeWanted = GROUP_WANTED;
}
}
else
// news: or news://HOST
m_typeWanted = READ_NEWS_RC;
// if this connection comes from the cache, we need to initialize the
// load group here, by generating the start request notification. nsMsgProtocol::OnStartRequest
// ignores the first parameter (which is supposed to be the channel) so we'll pass in null.
if (m_fromCache)
nsMsgProtocol::OnStartRequest(nsnull, aURL);
/* At this point, we're all done parsing the URL, and know exactly
what we want to do with it.
*/
#ifdef UNREADY_CODE #ifdef UNREADY_CODE
#ifndef NO_ARTICLE_CACHEING #ifndef NO_ARTICLE_CACHEING
/* Turn off caching on all news entities, except articles. */ /* Turn off caching on all news entities, except articles. */
/* It's very important that this be turned off for CANCEL_WANTED; /* It's very important that this be turned off for CANCEL_WANTED;
for the others, I don't know what cacheing would cause, but for the others, I don't know what cacheing would cause, but
it could only do harm, not good. */ it could only do harm, not good. */
if(m_typeWanted != ARTICLE_WANTED) if(m_typeWanted != ARTICLE_WANTED)
#endif #endif
ce->format_out = CLEAR_CACHE_BIT (ce->format_out); ce->format_out = CLEAR_CACHE_BIT (ce->format_out);
#endif #endif
FAIL: FAIL:
if (NS_FAILED(rv)) if (NS_FAILED(rv))
{
AlertError(rv, nsnull);
return rv;
}
else
{
if (!m_socketIsOpen)
{ {
m_nextStateAfterResponse = m_nextState; AlertError(rv, nsnull);
m_nextState = NNTP_RESPONSE; return rv;
} }
rv = nsMsgProtocol::LoadUrl(aURL, aConsumer); else
} {
if (!m_socketIsOpen)
return rv; {
m_nextStateAfterResponse = m_nextState;
m_nextState = NNTP_RESPONSE;
}
rv = nsMsgProtocol::LoadUrl(aURL, aConsumer);
}
return rv;
} }

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

@ -169,7 +169,8 @@ nsMsgNewsFolder::CreateSubFolders(nsFileSpec &path)
rv = GetIsServer(&isNewsServer); rv = GetIsServer(&isNewsServer);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
if (isNewsServer) { if (isNewsServer)
{
nsCOMPtr<nsINntpIncomingServer> nntpServer; nsCOMPtr<nsINntpIncomingServer> nntpServer;
rv = GetNntpServer(getter_AddRefs(nntpServer)); rv = GetNntpServer(getter_AddRefs(nntpServer));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
@ -180,7 +181,8 @@ nsMsgNewsFolder::CreateSubFolders(nsFileSpec &path)
rv = LoadNewsrcFileAndCreateNewsgroups(); rv = LoadNewsrcFileAndCreateNewsgroups();
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
} }
else { else
{
// is not a host, so it has no newsgroups. (what about categories??) // is not a host, so it has no newsgroups. (what about categories??)
rv = NS_OK; rv = NS_OK;
} }
@ -299,11 +301,13 @@ nsMsgNewsFolder::Enumerate(nsIEnumerator **result)
nsresult nsresult
nsMsgNewsFolder::AddDirectorySeparator(nsFileSpec &path) nsMsgNewsFolder::AddDirectorySeparator(nsFileSpec &path)
{ {
nsresult rv = NS_OK; nsresult rv = NS_OK;
if (PL_strcmp(mURI, kNewsRootURI) == 0) { if (PL_strcmp(mURI, kNewsRootURI) == 0)
// don't concat the full separator with .sbd {
// don't concat the full separator with .sbd
} }
else { else
{
nsAutoString sep; nsAutoString sep;
#if 0 #if 0
rv = nsGetNewsFolderSeparator(sep); rv = nsGetNewsFolderSeparator(sep);
@ -321,7 +325,7 @@ nsMsgNewsFolder::AddDirectorySeparator(nsFileSpec &path)
path = nsFilePath(str); path = nsFilePath(str);
} }
return rv; return rv;
} }
NS_IMETHODIMP NS_IMETHODIMP
@ -329,7 +333,8 @@ nsMsgNewsFolder::GetSubFolders(nsIEnumerator* *result)
{ {
nsresult rv; nsresult rv;
if (!mInitialized) { if (!mInitialized)
{
// do this first, so we make sure to do it, even on failure. // do this first, so we make sure to do it, even on failure.
// see bug #70494 // see bug #70494
mInitialized = PR_TRUE; mInitialized = PR_TRUE;
@ -777,7 +782,8 @@ nsMsgNewsFolder::UpdateSummaryFromNNTPInfo(PRInt32 oldest, PRInt32 youngest, PRI
char *setStr = nsnull; char *setStr = nsnull;
/* First, mark all of the articles now known to be expired as read. */ /* First, mark all of the articles now known to be expired as read. */
if (oldest > 1) { if (oldest > 1)
{
nsXPIDLCString oldSet; nsXPIDLCString oldSet;
mReadSet->Output(getter_Copies(oldSet)); mReadSet->Output(getter_Copies(oldSet));
mReadSet->AddRange(1, oldest - 1); mReadSet->AddRange(1, oldest - 1);
@ -789,27 +795,25 @@ nsMsgNewsFolder::UpdateSummaryFromNNTPInfo(PRInt32 oldest, PRInt32 youngest, PRI
/* Now search the newsrc line and figure out how many of these messages are marked as unread. */ /* Now search the newsrc line and figure out how many of these messages are marked as unread. */
/* make sure youngest is a least 1. MSNews seems to return a youngest of 0. */ /* make sure youngest is a least 1. MSNews seems to return a youngest of 0. */
if (youngest == 0) { if (youngest == 0)
youngest = 1; youngest = 1;
}
PRInt32 unread = mReadSet->CountMissingInRange(oldest, youngest); PRInt32 unread = mReadSet->CountMissingInRange(oldest, youngest);
NS_ASSERTION(unread >= 0,"CountMissingInRange reported unread < 0"); NS_ASSERTION(unread >= 0,"CountMissingInRange reported unread < 0");
if (unread < 0) { if (unread < 0)
// servers can send us stuff like "211 0 41 40 nz.netstatus" // servers can send us stuff like "211 0 41 40 nz.netstatus"
// we should handle it gracefully. // we should handle it gracefully.
unread = 0; unread = 0;
}
if (unread > total) { if (unread > total)
{
/* This can happen when the newsrc file shows more unread than exist in the group (total is not necessarily `end - start'.) */ /* This can happen when the newsrc file shows more unread than exist in the group (total is not necessarily `end - start'.) */
unread = total; unread = total;
PRInt32 deltaInDB = mNumTotalMessages - mNumUnreadMessages; PRInt32 deltaInDB = mNumTotalMessages - mNumUnreadMessages;
//PRint32 deltaInDB = m_totalInDB - m_unreadInDB; //PRint32 deltaInDB = m_totalInDB - m_unreadInDB;
/* if we know there are read messages in the db, subtract that from the unread total */ /* if we know there are read messages in the db, subtract that from the unread total */
if (deltaInDB > 0) { if (deltaInDB > 0)
unread -= deltaInDB; unread -= deltaInDB;
}
} }
mNumUnreadMessages = unread; mNumUnreadMessages = unread;
@ -820,13 +824,11 @@ nsMsgNewsFolder::UpdateSummaryFromNNTPInfo(PRInt32 oldest, PRInt32 youngest, PRI
#endif #endif
//Need to notify listeners that total count changed. //Need to notify listeners that total count changed.
if(oldTotalMessages != mNumTotalMessages) { if(oldTotalMessages != mNumTotalMessages)
NotifyIntPropertyChanged(kTotalMessagesAtom, oldTotalMessages, mNumTotalMessages); NotifyIntPropertyChanged(kTotalMessagesAtom, oldTotalMessages, mNumTotalMessages);
}
if(oldUnreadMessages != mNumUnreadMessages) { if(oldUnreadMessages != mNumUnreadMessages)
NotifyIntPropertyChanged(kTotalUnreadMessagesAtom, oldUnreadMessages, mNumUnreadMessages); NotifyIntPropertyChanged(kTotalUnreadMessagesAtom, oldUnreadMessages, mNumUnreadMessages);
}
nsCRT::free(setStr); nsCRT::free(setStr);
setStr = nsnull; setStr = nsnull;
@ -846,13 +848,11 @@ NS_IMETHODIMP nsMsgNewsFolder::UpdateSummaryTotals(PRBool force)
if (NS_SUCCEEDED(ret)) if (NS_SUCCEEDED(ret))
{ {
//Need to notify listeners that total count changed. //Need to notify listeners that total count changed.
if(oldTotalMessages != mNumTotalMessages) { if(oldTotalMessages != mNumTotalMessages)
NotifyIntPropertyChanged(kTotalMessagesAtom, oldTotalMessages, mNumTotalMessages); NotifyIntPropertyChanged(kTotalMessagesAtom, oldTotalMessages, mNumTotalMessages);
}
if(oldUnreadMessages != mNumUnreadMessages) { if(oldUnreadMessages != mNumUnreadMessages)
NotifyIntPropertyChanged(kTotalUnreadMessagesAtom, oldUnreadMessages, mNumUnreadMessages); NotifyIntPropertyChanged(kTotalUnreadMessagesAtom, oldUnreadMessages, mNumUnreadMessages);
}
FlushToFolderCache(); FlushToFolderCache();
} }
@ -891,7 +891,7 @@ NS_IMETHODIMP nsMsgNewsFolder::GetSizeOnDisk(PRUint32 *size)
NS_IMETHODIMP NS_IMETHODIMP
nsMsgNewsFolder::DeleteMessages(nsISupportsArray *messages, nsIMsgWindow *aMsgWindow, nsMsgNewsFolder::DeleteMessages(nsISupportsArray *messages, nsIMsgWindow *aMsgWindow,
PRBool deleteStorage, PRBool isMove, PRBool deleteStorage, PRBool isMove,
nsIMsgCopyServiceListener* listener, PRBool allowUndo) nsIMsgCopyServiceListener* listener, PRBool allowUndo)
{ {
nsresult rv = NS_OK; nsresult rv = NS_OK;
@ -902,7 +902,8 @@ nsMsgNewsFolder::DeleteMessages(nsISupportsArray *messages, nsIMsgWindow *aMsgWi
rv = messages->Count(&count); rv = messages->Count(&count);
NS_ENSURE_SUCCESS(rv,rv); NS_ENSURE_SUCCESS(rv,rv);
if (count != 1) { if (count != 1)
{
nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv); nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
@ -918,7 +919,8 @@ nsMsgNewsFolder::DeleteMessages(nsISupportsArray *messages, nsIMsgWindow *aMsgWi
rv = aMsgWindow->GetPromptDialog(getter_AddRefs(dialog)); rv = aMsgWindow->GetPromptDialog(getter_AddRefs(dialog));
NS_ENSURE_SUCCESS(rv,rv); NS_ENSURE_SUCCESS(rv,rv);
if (dialog) { if (dialog)
{
rv = dialog->Alert(nsnull, (const PRUnichar *) alertText); rv = dialog->Alert(nsnull, (const PRUnichar *) alertText);
NS_ENSURE_SUCCESS(rv,rv); NS_ENSURE_SUCCESS(rv,rv);
} }
@ -959,7 +961,7 @@ nsMsgNewsFolder::DeleteMessages(nsISupportsArray *messages, nsIMsgWindow *aMsgWi
cancelURL += escapedMessageID; cancelURL += escapedMessageID;
cancelURL += "?cancel"; cancelURL += "?cancel";
PR_FREEIF(escapedMessageID); PR_Free(escapedMessageID);
nsXPIDLCString messageURI; nsXPIDLCString messageURI;
rv = GetUriForMsg(msgHdr, getter_Copies(messageURI)); rv = GetUriForMsg(msgHdr, getter_Copies(messageURI));
@ -989,10 +991,9 @@ nsresult nsMsgNewsFolder::GetNewsMessages(nsIMsgWindow *aMsgWindow, PRBool aGetO
rv = GetIsServer(&isNewsServer); rv = GetIsServer(&isNewsServer);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
if (isNewsServer) { if (isNewsServer)
// get new messages only works on a newsgroup, not a news server // get new messages only works on a newsgroup, not a news server
return NS_OK; return NS_OK;
}
nsCOMPtr <nsINntpService> nntpService = do_GetService(NS_NNTPSERVICE_CONTRACTID, &rv); nsCOMPtr <nsINntpService> nntpService = do_GetService(NS_NNTPSERVICE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv,rv); NS_ENSURE_SUCCESS(rv,rv);
@ -1023,10 +1024,9 @@ nsMsgNewsFolder::LoadNewsrcFileAndCreateNewsgroups()
rv = mNewsrcFilePath->Exists(&exists); rv = mNewsrcFilePath->Exists(&exists);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
if (!exists) { if (!exists)
// it is ok for the newsrc file to not exist yet // it is ok for the newsrc file to not exist yet
return NS_OK; return NS_OK;
}
char *buffer = nsnull; char *buffer = nsnull;
rv = mNewsrcFilePath->OpenStreamForReading(); rv = mNewsrcFilePath->OpenStreamForReading();
@ -1034,11 +1034,12 @@ nsMsgNewsFolder::LoadNewsrcFileAndCreateNewsgroups()
PRInt32 numread = 0; PRInt32 numread = 0;
if (NS_FAILED(m_newsrcInputStream.GrowBuffer(NEWSRC_FILE_BUFFER_SIZE))) { if (NS_FAILED(m_newsrcInputStream.GrowBuffer(NEWSRC_FILE_BUFFER_SIZE)))
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
}
while (1) { while (1)
{
buffer = m_newsrcInputStream.GetBuffer(); buffer = m_newsrcInputStream.GetBuffer();
rv = mNewsrcFilePath->Read(&buffer, NEWSRC_FILE_BUFFER_SIZE, &numread); rv = mNewsrcFilePath->Read(&buffer, NEWSRC_FILE_BUFFER_SIZE, &numread);
NS_ENSURE_SUCCESS(rv,rv); NS_ENSURE_SUCCESS(rv,rv);
@ -1076,9 +1077,8 @@ nsMsgNewsFolder::HandleNewsrcLine(char* line, PRUint32 line_size)
line[line_size] = 0; line[line_size] = 0;
if ((line[0] == 'o' || line[0] == 'O') && if ((line[0] == 'o' || line[0] == 'O') &&
!PL_strncasecmp (line, "options", 7)) { !PL_strncasecmp (line, "options", 7))
return RememberLine(line); return RememberLine(line);
}
char *s = nsnull; char *s = nsnull;
char *setStr = nsnull; char *setStr = nsnull;
@ -1088,18 +1088,16 @@ nsMsgNewsFolder::HandleNewsrcLine(char* line, PRUint32 line_size)
if ((*s == ':') || (*s == '!')) if ((*s == ':') || (*s == '!'))
break; break;
if (*s == 0) { if (*s == 0)
/* What is this?? Well, don't just throw it away... */ /* What is this?? Well, don't just throw it away... */
return RememberLine(line); return RememberLine(line);
}
PRBool subscribed = (*s == ':'); PRBool subscribed = (*s == ':');
setStr = s+1; setStr = s+1;
*s = '\0'; *s = '\0';
if (*line == '\0') { if (*line == '\0')
return 0; return 0;
}
// previous versions of Communicator poluted the // previous versions of Communicator poluted the
// newsrc files with articles // newsrc files with articles
@ -1120,12 +1118,12 @@ nsMsgNewsFolder::HandleNewsrcLine(char* line, PRUint32 line_size)
// So lines like this in a newsrc file should be ignored: // So lines like this in a newsrc file should be ignored:
// 3746EF3F.6080309@netscape.com: // 3746EF3F.6080309@netscape.com:
// 3746EF3F.6080309%40netscape.com: // 3746EF3F.6080309%40netscape.com:
if (PL_strstr(line,"@") || PL_strstr(line,"%40")) { if (PL_strstr(line,"@") || PL_strstr(line,"%40"))
// skipping, it contains @ or %40 // skipping, it contains @ or %40
subscribed = PR_FALSE; subscribed = PR_FALSE;
}
if (subscribed) { if (subscribed)
{
// we're subscribed, so add it // we're subscribed, so add it
nsCOMPtr <nsIMsgFolder> child; nsCOMPtr <nsIMsgFolder> child;
@ -1145,15 +1143,14 @@ nsMsgNewsFolder::HandleNewsrcLine(char* line, PRUint32 line_size)
nsresult nsresult
nsMsgNewsFolder::RememberUnsubscribedGroup(const char *newsgroup, const char *setStr) nsMsgNewsFolder::RememberUnsubscribedGroup(const char *newsgroup, const char *setStr)
{ {
if (newsgroup) { if (newsgroup)
{
mUnsubscribedNewsgroupLines += newsgroup; mUnsubscribedNewsgroupLines += newsgroup;
mUnsubscribedNewsgroupLines += "! "; mUnsubscribedNewsgroupLines += "! ";
if (setStr) { if (setStr)
mUnsubscribedNewsgroupLines += setStr; mUnsubscribedNewsgroupLines += setStr;
} else
else {
mUnsubscribedNewsgroupLines += MSG_LINEBREAK; mUnsubscribedNewsgroupLines += MSG_LINEBREAK;
}
} }
return NS_OK; return NS_OK;
} }
@ -1178,11 +1175,13 @@ NS_IMETHODIMP nsMsgNewsFolder::GetGroupUsername(char **aGroupUsername)
NS_ENSURE_ARG_POINTER(aGroupUsername); NS_ENSURE_ARG_POINTER(aGroupUsername);
nsresult rv; nsresult rv;
if (mGroupUsername) { if (mGroupUsername)
{
*aGroupUsername = nsCRT::strdup(mGroupUsername); *aGroupUsername = nsCRT::strdup(mGroupUsername);
rv = NS_OK; rv = NS_OK;
} }
else { else
{
rv = NS_ERROR_FAILURE; rv = NS_ERROR_FAILURE;
} }
@ -1193,9 +1192,8 @@ NS_IMETHODIMP nsMsgNewsFolder::SetGroupUsername(const char *aGroupUsername)
{ {
PR_FREEIF(mGroupUsername); PR_FREEIF(mGroupUsername);
if (aGroupUsername) { if (aGroupUsername)
mGroupUsername = nsCRT::strdup(aGroupUsername); mGroupUsername = nsCRT::strdup(aGroupUsername);
}
return NS_OK; return NS_OK;
} }
@ -1205,11 +1203,13 @@ NS_IMETHODIMP nsMsgNewsFolder::GetGroupPassword(char **aGroupPassword)
NS_ENSURE_ARG_POINTER(aGroupPassword); NS_ENSURE_ARG_POINTER(aGroupPassword);
nsresult rv; nsresult rv;
if (mGroupPassword) { if (mGroupPassword)
{
*aGroupPassword = nsCRT::strdup(mGroupPassword); *aGroupPassword = nsCRT::strdup(mGroupPassword);
rv = NS_OK; rv = NS_OK;
} }
else { else
{
rv = NS_ERROR_FAILURE; rv = NS_ERROR_FAILURE;
} }
@ -1220,9 +1220,8 @@ NS_IMETHODIMP nsMsgNewsFolder::SetGroupPassword(const char *aGroupPassword)
{ {
PR_FREEIF(mGroupPassword); PR_FREEIF(mGroupPassword);
if (aGroupPassword) { if (aGroupPassword)
mGroupPassword = nsCRT::strdup(aGroupPassword); mGroupPassword = nsCRT::strdup(aGroupPassword);
}
return NS_OK; return NS_OK;
} }
@ -1251,7 +1250,8 @@ nsresult nsMsgNewsFolder::CreateNewsgroupUrlForSignon(const char *inUriStr, cons
rv = url->GetPort(&port); rv = url->GetPort(&port);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
if (port <= 0) { if (port <= 0)
{
nsCOMPtr<nsIMsgIncomingServer> server; nsCOMPtr<nsIMsgIncomingServer> server;
rv = GetServer(getter_AddRefs(server)); rv = GetServer(getter_AddRefs(server));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
@ -1260,12 +1260,7 @@ nsresult nsMsgNewsFolder::CreateNewsgroupUrlForSignon(const char *inUriStr, cons
rv = server->GetIsSecure(&isSecure); rv = server->GetIsSecure(&isSecure);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
if (isSecure) { rv = url->SetPort((isSecure) ? SECURE_NEWS_PORT: NEWS_PORT);
rv = url->SetPort(SECURE_NEWS_PORT);
}
else {
rv = url->SetPort(NEWS_PORT);
}
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
} }
@ -1339,14 +1334,16 @@ nsMsgNewsFolder::GetGroupPasswordWithUI(const PRUnichar * aPromptMessage, const
NS_ENSURE_ARG_POINTER(aGroupPassword); NS_ENSURE_ARG_POINTER(aGroupPassword);
if (!mGroupPassword) { if (!mGroupPassword)
{
// prompt the user for the password // prompt the user for the password
nsCOMPtr<nsIAuthPrompt> dialog; nsCOMPtr<nsIAuthPrompt> dialog;
#ifdef DEBUG_seth #ifdef DEBUG_seth
NS_ASSERTION(aMsgWindow,"no msg window"); NS_ASSERTION(aMsgWindow,"no msg window");
#endif #endif
if (aMsgWindow) { if (aMsgWindow)
{
nsCOMPtr<nsIDocShell> docShell; nsCOMPtr<nsIDocShell> docShell;
rv = aMsgWindow->GetRootDocShell(getter_AddRefs(docShell)); rv = aMsgWindow->GetRootDocShell(getter_AddRefs(docShell));
@ -1358,7 +1355,8 @@ nsMsgNewsFolder::GetGroupPasswordWithUI(const PRUnichar * aPromptMessage, const
dialog = do_GetInterface(webShell, &rv); dialog = do_GetInterface(webShell, &rv);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
} }
else { else
{
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
if (wwatch) if (wwatch)
wwatch->GetNewAuthPrompter(0, getter_AddRefs(dialog)); wwatch->GetNewAuthPrompter(0, getter_AddRefs(dialog));
@ -1367,7 +1365,8 @@ nsMsgNewsFolder::GetGroupPasswordWithUI(const PRUnichar * aPromptMessage, const
} }
NS_ASSERTION(dialog,"we didn't get a net prompt"); NS_ASSERTION(dialog,"we didn't get a net prompt");
if (dialog) { if (dialog)
{
nsXPIDLString uniGroupPassword; nsXPIDLString uniGroupPassword;
PRBool okayValue = PR_TRUE; PRBool okayValue = PR_TRUE;
@ -1407,14 +1406,16 @@ nsMsgNewsFolder::GetGroupUsernameWithUI(const PRUnichar * aPromptMessage, const
NS_ENSURE_ARG_POINTER(aGroupUsername); NS_ENSURE_ARG_POINTER(aGroupUsername);
if (!mGroupUsername) { if (!mGroupUsername)
{
// prompt the user for the username // prompt the user for the username
nsCOMPtr<nsIAuthPrompt> dialog; nsCOMPtr<nsIAuthPrompt> dialog;
#ifdef DEBUG_seth #ifdef DEBUG_seth
NS_ASSERTION(aMsgWindow,"no msg window"); NS_ASSERTION(aMsgWindow,"no msg window");
#endif #endif
if (aMsgWindow) { if (aMsgWindow)
{
// prompt the user for the password // prompt the user for the password
nsCOMPtr<nsIDocShell> docShell; nsCOMPtr<nsIDocShell> docShell;
rv = aMsgWindow->GetRootDocShell(getter_AddRefs(docShell)); rv = aMsgWindow->GetRootDocShell(getter_AddRefs(docShell));
@ -1424,7 +1425,8 @@ nsMsgNewsFolder::GetGroupUsernameWithUI(const PRUnichar * aPromptMessage, const
dialog = do_GetInterface(webShell, &rv); dialog = do_GetInterface(webShell, &rv);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
} }
else { else
{
nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID)); nsCOMPtr<nsIWindowWatcher> wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
if (wwatch) if (wwatch)
wwatch->GetNewAuthPrompter(0, getter_AddRefs(dialog)); wwatch->GetNewAuthPrompter(0, getter_AddRefs(dialog));
@ -1433,7 +1435,8 @@ nsMsgNewsFolder::GetGroupUsernameWithUI(const PRUnichar * aPromptMessage, const
} }
NS_ASSERTION(dialog,"we didn't get a net prompt"); NS_ASSERTION(dialog,"we didn't get a net prompt");
if (dialog) { if (dialog)
{
nsXPIDLString uniGroupUsername; nsXPIDLString uniGroupUsername;
PRBool okayValue = PR_TRUE; PRBool okayValue = PR_TRUE;
@ -1490,7 +1493,8 @@ nsMsgNewsFolder::GetNewsrcLine(char **newsrcLine)
nsXPIDLCString setStr; nsXPIDLCString setStr;
if (mReadSet) { if (mReadSet) {
mReadSet->Output(getter_Copies(setStr)); mReadSet->Output(getter_Copies(setStr));
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv))
{
newsrcLineStr += " "; newsrcLineStr += " ";
newsrcLineStr += setStr; newsrcLineStr += setStr;
newsrcLineStr += MSG_LINEBREAK; newsrcLineStr += MSG_LINEBREAK;
@ -1557,7 +1561,8 @@ nsMsgNewsFolder::GetAsciiName(char **asciiName)
{ {
nsresult rv; nsresult rv;
NS_ENSURE_ARG_POINTER(asciiName); NS_ENSURE_ARG_POINTER(asciiName);
if (!mAsciiName) { if (!mAsciiName)
{
nsXPIDLString name; nsXPIDLString name;
rv = GetName(getter_Copies(name)); rv = GetName(getter_Copies(name));
NS_ENSURE_SUCCESS(rv,rv); NS_ENSURE_SUCCESS(rv,rv);
@ -1800,7 +1805,8 @@ NS_IMETHODIMP nsMsgNewsFolder::GetPersistElided(PRBool *aPersistElided)
// persist the open / closed state, if not a server // persist the open / closed state, if not a server
// this doesn't matter right now, but it will if we ever add categories // this doesn't matter right now, but it will if we ever add categories
if (!isNewsServer) { if (!isNewsServer)
{
*aPersistElided = PR_TRUE; *aPersistElided = PR_TRUE;
return NS_OK; return NS_OK;
} }
@ -1838,7 +1844,8 @@ nsMsgNewsFolder::SetFilterList(nsIMsgFilterList *aFilterList)
NS_IMETHODIMP NS_IMETHODIMP
nsMsgNewsFolder::GetFilterList(nsIMsgWindow *aMsgWindow, nsIMsgFilterList **aResult) nsMsgNewsFolder::GetFilterList(nsIMsgWindow *aMsgWindow, nsIMsgFilterList **aResult)
{ {
if (!mFilterList) { if (!mFilterList)
{
nsCOMPtr<nsIFileSpec> thisFolder; nsCOMPtr<nsIFileSpec> thisFolder;
nsresult rv = GetPath(getter_AddRefs(thisFolder)); nsresult rv = GetPath(getter_AddRefs(thisFolder));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);