mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Bug #122293 --> pass in the correct # of new messages to make
the biff icon titletip for pop show the right number. r=navin sr=bienvenu
This commit is contained in:
parent
4012d3de89
commit
e450c1afd7
@ -1474,16 +1474,16 @@ PRInt32 nsPop3Protocol::GetFakeUidlTop(nsIInputStream* inputStream,
|
||||
if (!m_pop3ConData->only_uidl && message_id_token && (state == 0))
|
||||
{ /* we have not seen this message before */
|
||||
|
||||
m_pop3ConData->number_of_messages_not_seen_before++;
|
||||
m_pop3ConData->msg_info[m_pop3ConData->current_msg_to_top-1].uidl =
|
||||
PL_strdup(message_id_token);
|
||||
if (!m_pop3ConData->msg_info[m_pop3ConData->current_msg_to_top-1].uidl)
|
||||
{
|
||||
PR_FREEIF(line);
|
||||
return MK_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
else if (m_pop3ConData->only_uidl && message_id_token &&
|
||||
m_pop3ConData->number_of_messages_not_seen_before++;
|
||||
m_pop3ConData->msg_info[m_pop3ConData->current_msg_to_top-1].uidl =
|
||||
PL_strdup(message_id_token);
|
||||
if (!m_pop3ConData->msg_info[m_pop3ConData->current_msg_to_top-1].uidl)
|
||||
{
|
||||
PR_FREEIF(line);
|
||||
return MK_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
else if (m_pop3ConData->only_uidl && message_id_token &&
|
||||
!PL_strcmp(m_pop3ConData->only_uidl, message_id_token))
|
||||
{
|
||||
m_pop3ConData->last_accessed_msg = m_pop3ConData->current_msg_to_top - 1;
|
||||
@ -1516,7 +1516,7 @@ PRInt32 nsPop3Protocol::GetFakeUidlTop(nsIInputStream* inputStream,
|
||||
}
|
||||
}
|
||||
|
||||
PR_FREEIF(line);
|
||||
PR_FREEIF(line);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1545,15 +1545,15 @@ PRInt32 nsPop3Protocol::GetFakeUidlTop(nsIInputStream* inputStream,
|
||||
*/
|
||||
PRInt32 nsPop3Protocol::SendXtndXlstMsgid()
|
||||
{
|
||||
if ((m_pop3ConData->capability_flags & POP3_HAS_XTND_XLST) ||
|
||||
(m_pop3ConData->capability_flags & POP3_XTND_XLST_UNDEFINED))
|
||||
{
|
||||
m_pop3ConData->next_state_after_response = POP3_GET_XTND_XLST_MSGID;
|
||||
m_pop3ConData->pause_for_read = PR_TRUE;
|
||||
return SendData(m_url, "XTND XLST Message-Id" CRLF);
|
||||
}
|
||||
else
|
||||
return StartUseTopForFakeUidl();
|
||||
if ((m_pop3ConData->capability_flags & POP3_HAS_XTND_XLST) ||
|
||||
(m_pop3ConData->capability_flags & POP3_XTND_XLST_UNDEFINED))
|
||||
{
|
||||
m_pop3ConData->next_state_after_response = POP3_GET_XTND_XLST_MSGID;
|
||||
m_pop3ConData->pause_for_read = PR_TRUE;
|
||||
return SendData(m_url, "XTND XLST Message-Id" CRLF);
|
||||
}
|
||||
else
|
||||
return StartUseTopForFakeUidl();
|
||||
}
|
||||
|
||||
|
||||
@ -1596,8 +1596,8 @@ nsPop3Protocol::GetXtndXlstMsgid(nsIInputStream* inputStream,
|
||||
m_pop3Server->SetPop3CapabilityFlags(m_pop3ConData->capability_flags);
|
||||
}
|
||||
|
||||
PRBool pauseForMoreData = PR_FALSE;
|
||||
line = m_lineStreamBuffer->ReadNextLine(inputStream, ln, pauseForMoreData);
|
||||
PRBool pauseForMoreData = PR_FALSE;
|
||||
line = m_lineStreamBuffer->ReadNextLine(inputStream, ln, pauseForMoreData);
|
||||
|
||||
if(pauseForMoreData || !line)
|
||||
{
|
||||
@ -1615,12 +1615,12 @@ nsPop3Protocol::GetXtndXlstMsgid(nsIInputStream* inputStream,
|
||||
* list data is terminated by a ".CRLF" line
|
||||
*/
|
||||
if(!PL_strcmp(line, "."))
|
||||
{
|
||||
{
|
||||
m_pop3ConData->next_state = POP3_GET_MSG;
|
||||
m_pop3ConData->pause_for_read = PR_FALSE;
|
||||
PR_FREEIF(line);
|
||||
PR_FREEIF(line);
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
msg_num = atol(nsCRT::strtok(line, " ", &newStr));
|
||||
|
||||
@ -2908,7 +2908,7 @@ nsresult nsPop3Protocol::ProcessProtocolState(nsIURI * url, nsIInputStream * aIn
|
||||
if (!m_pop3ConData->only_uidl)
|
||||
{
|
||||
if (m_pop3ConData->only_check_for_new_mail)
|
||||
m_nsIPop3Sink->SetBiffStateAndUpdateFE(m_pop3ConData->biffstate, m_pop3ConData->number_of_messages_not_seen_before);
|
||||
m_nsIPop3Sink->SetBiffStateAndUpdateFE(m_pop3ConData->biffstate, m_pop3ConData->really_new_messages);
|
||||
/* update old style biff */
|
||||
else
|
||||
{
|
||||
@ -2920,30 +2920,31 @@ nsresult nsPop3Protocol::ProcessProtocolState(nsIURI * url, nsIInputStream * aIn
|
||||
show the message there. */
|
||||
|
||||
if (m_totalDownloadSize <= 0)
|
||||
{
|
||||
UpdateStatus(POP3_NO_MESSAGES);
|
||||
/* There are no new messages. */
|
||||
{
|
||||
UpdateStatus(POP3_NO_MESSAGES);
|
||||
/* There are no new messages. */
|
||||
}
|
||||
else
|
||||
{
|
||||
PRUnichar * statusTemplate = nsnull;
|
||||
mStringService->GetStringByID(POP3_DOWNLOAD_COUNT, &statusTemplate);
|
||||
if (statusTemplate)
|
||||
{
|
||||
PRUnichar * statusString = nsTextFormatter::smprintf(statusTemplate,
|
||||
{
|
||||
PRUnichar * statusTemplate = nsnull;
|
||||
mStringService->GetStringByID(POP3_DOWNLOAD_COUNT, &statusTemplate);
|
||||
if (statusTemplate)
|
||||
{
|
||||
PRUnichar * statusString = nsTextFormatter::smprintf(statusTemplate,
|
||||
m_pop3ConData->real_new_counter - 1,
|
||||
m_pop3ConData->really_new_messages);
|
||||
UpdateStatusWithString(statusString);
|
||||
nsTextFormatter::smprintf_free(statusString);
|
||||
nsCRT::free(statusTemplate);
|
||||
|
||||
}
|
||||
m_nsIPop3Sink->SetBiffStateAndUpdateFE(nsIMsgFolder::nsMsgBiffState_NewMail, m_pop3ConData->number_of_messages_not_seen_before);
|
||||
UpdateStatusWithString(statusString);
|
||||
nsTextFormatter::smprintf_free(statusString);
|
||||
nsCRT::free(statusTemplate);
|
||||
|
||||
}
|
||||
|
||||
m_nsIPop3Sink->SetBiffStateAndUpdateFE(nsIMsgFolder::nsMsgBiffState_NewMail, m_pop3ConData->really_new_messages);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
status = SendData(mailnewsurl, "QUIT" CRLF);
|
||||
status = SendData(mailnewsurl, "QUIT" CRLF);
|
||||
m_pop3ConData->next_state = POP3_WAIT_FOR_RESPONSE;
|
||||
m_pop3ConData->next_state_after_response = POP3_QUIT_RESPONSE;
|
||||
break;
|
||||
@ -2983,67 +2984,61 @@ nsresult nsPop3Protocol::ProcessProtocolState(nsIURI * url, nsIInputStream * aIn
|
||||
if(m_pop3ConData->msg_del_started)
|
||||
m_nsIPop3Sink->EndMailDelivery();
|
||||
|
||||
if (mailnewsurl)
|
||||
mailnewsurl->SetUrlState(PR_FALSE, NS_OK);
|
||||
|
||||
if (mailnewsurl)
|
||||
mailnewsurl->SetUrlState(PR_FALSE, NS_OK);
|
||||
m_pop3ConData->next_state = POP3_FREE;
|
||||
break;
|
||||
|
||||
case POP3_INTERRUPTED:
|
||||
SendData(mailnewsurl, "QUIT" CRLF);
|
||||
SendData(mailnewsurl, "QUIT" CRLF);
|
||||
m_pop3ConData->pause_for_read = PR_FALSE;
|
||||
m_pop3ConData->next_state = POP3_ERROR_DONE;
|
||||
break;
|
||||
break;
|
||||
|
||||
case POP3_ERROR_DONE:
|
||||
|
||||
/* write out the state */
|
||||
CommitState(PR_TRUE);
|
||||
|
||||
|
||||
if(m_pop3ConData->msg_closure)
|
||||
{
|
||||
m_nsIPop3Sink->IncorporateAbort(m_pop3ConData->only_uidl != nsnull);
|
||||
m_pop3ConData->msg_closure = NULL;
|
||||
m_nsIPop3Sink->AbortMailDelivery();
|
||||
}
|
||||
|
||||
|
||||
if(m_pop3ConData->msg_del_started)
|
||||
{
|
||||
|
||||
PRUnichar * statusTemplate = nsnull;
|
||||
mStringService->GetStringByID(POP3_DOWNLOAD_COUNT, &statusTemplate);
|
||||
if (statusTemplate)
|
||||
{
|
||||
PRUnichar * statusString = nsTextFormatter::smprintf(statusTemplate,
|
||||
m_pop3ConData->real_new_counter - 1,
|
||||
PRUnichar * statusTemplate = nsnull;
|
||||
mStringService->GetStringByID(POP3_DOWNLOAD_COUNT, &statusTemplate);
|
||||
if (statusTemplate)
|
||||
{
|
||||
PRUnichar * statusString = nsTextFormatter::smprintf(statusTemplate,
|
||||
m_pop3ConData->real_new_counter - 1,
|
||||
m_pop3ConData->really_new_messages);
|
||||
UpdateStatusWithString(statusString);
|
||||
nsTextFormatter::smprintf_free(statusString);
|
||||
nsCRT::free(statusTemplate);
|
||||
UpdateStatusWithString(statusString);
|
||||
nsTextFormatter::smprintf_free(statusString);
|
||||
nsCRT::free(statusTemplate);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PR_ASSERT (!TestFlag(POP3_PASSWORD_FAILED));
|
||||
m_nsIPop3Sink->AbortMailDelivery();
|
||||
PR_ASSERT (!TestFlag(POP3_PASSWORD_FAILED));
|
||||
m_nsIPop3Sink->AbortMailDelivery();
|
||||
}
|
||||
|
||||
if (TestFlag(POP3_PASSWORD_FAILED))
|
||||
{
|
||||
/* We got here because the password was wrong, so go
|
||||
read a new one and re-open the connection. */
|
||||
m_pop3ConData->next_state = POP3_READ_PASSWORD;
|
||||
m_pop3ConData->command_succeeded = PR_TRUE;
|
||||
status = 0;
|
||||
break;
|
||||
}
|
||||
{
|
||||
/* We got here because the password was wrong, so go
|
||||
read a new one and re-open the connection. */
|
||||
m_pop3ConData->next_state = POP3_READ_PASSWORD;
|
||||
m_pop3ConData->command_succeeded = PR_TRUE;
|
||||
status = 0;
|
||||
break;
|
||||
}
|
||||
else
|
||||
/* Else we got a "real" error, so finish up. */
|
||||
m_pop3ConData->next_state = POP3_FREE;
|
||||
|
||||
if (mailnewsurl)
|
||||
mailnewsurl->SetUrlState(PR_FALSE, NS_ERROR_FAILURE);
|
||||
/* Else we got a "real" error, so finish up. */
|
||||
m_pop3ConData->next_state = POP3_FREE;
|
||||
|
||||
if (mailnewsurl)
|
||||
mailnewsurl->SetUrlState(PR_FALSE, NS_ERROR_FAILURE);
|
||||
m_pop3ConData->pause_for_read = PR_FALSE;
|
||||
break;
|
||||
|
||||
|
@ -86,14 +86,8 @@ nsPop3Sink::~nsPop3Sink()
|
||||
nsresult
|
||||
nsPop3Sink::SetUserAuthenticated(PRBool authed)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if (authed)
|
||||
printf("User is authenticated. \n");
|
||||
else
|
||||
printf("User is NOT authenticated. \n");
|
||||
#endif
|
||||
m_authed = authed;
|
||||
return NS_OK;
|
||||
m_authed = authed;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -109,37 +103,30 @@ nsPop3Sink::GetUserAuthenticated(PRBool* authed)
|
||||
nsresult
|
||||
nsPop3Sink::SetSenderAuthedFlag(void* closure, PRBool authed)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if (authed)
|
||||
printf("Sender is authenticated. \n");
|
||||
else
|
||||
printf("Sender is NOT authenticated. \n");
|
||||
#endif
|
||||
m_authed = authed;
|
||||
return NS_OK;
|
||||
|
||||
m_authed = authed;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPop3Sink::SetMailAccountURL(const char* urlString)
|
||||
{
|
||||
if (urlString)
|
||||
{
|
||||
PR_FREEIF(m_accountUrl);
|
||||
m_accountUrl = PL_strdup(urlString);
|
||||
}
|
||||
if (urlString)
|
||||
{
|
||||
PR_FREEIF(m_accountUrl);
|
||||
m_accountUrl = PL_strdup(urlString);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPop3Sink::GetMailAccountURL(char* *urlString)
|
||||
{
|
||||
NS_ASSERTION(urlString, "null getter in getMailAccountURL");
|
||||
if (!urlString) return NS_ERROR_NULL_POINTER;
|
||||
NS_ASSERTION(urlString, "null getter in getMailAccountURL");
|
||||
if (!urlString) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*urlString = nsCRT::strdup(m_accountUrl);
|
||||
return NS_OK;
|
||||
*urlString = nsCRT::strdup(m_accountUrl);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -515,33 +502,13 @@ nsPop3Sink::BiffGetNewMail()
|
||||
nsresult
|
||||
nsPop3Sink::SetBiffStateAndUpdateFE(PRUint32 aBiffState, PRInt32 numNewMessages)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("Set biff state: %d\n", aBiffState);
|
||||
#endif
|
||||
|
||||
m_biffState = aBiffState;
|
||||
m_biffState = aBiffState;
|
||||
if(m_folder)
|
||||
{
|
||||
m_folder->SetBiffState(aBiffState);
|
||||
m_folder->SetNumNewMessages(numNewMessages);
|
||||
m_folder->SetBiffState(aBiffState);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
switch (aBiffState)
|
||||
{
|
||||
case nsIMsgFolder::nsMsgBiffState_Unknown:
|
||||
default:
|
||||
printf("Excuse me, Sir. I have no idea.\n");
|
||||
break;
|
||||
case nsIMsgFolder::nsMsgBiffState_NewMail:
|
||||
printf("Y'all got mail!\n");
|
||||
break;
|
||||
case nsIMsgFolder::nsMsgBiffState_NoMail:
|
||||
printf("You have no mail.\n");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
Loading…
Reference in New Issue
Block a user