pass progress not as a percent but with a current and max byte count

Use progress event sink instead of nsIMsgStatusFeedback.
This commit is contained in:
mscott%netscape.com 2000-05-03 21:21:35 +00:00
Родитель 0d55754a41
Коммит a70db6d245
2 изменённых файлов: 15 добавлений и 68 удалений

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

@ -3526,15 +3526,7 @@ PRInt32 nsNNTPProtocol::DisplayNewsRC()
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(m_runningURL); nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(m_runningURL);
if (mailnewsurl) if (mailnewsurl)
status = SendData(mailnewsurl, outputBuffer); status = SendData(mailnewsurl, outputBuffer);
SetProgressBarPercent(m_newsRCListCount, m_newsRCListIndex);
percent = (m_newsRCListCount) ?
(PRInt32) (100.0 * ( (double)m_newsRCListIndex / (double)m_newsRCListCount )) :
0;
#ifdef UNREADY_CODE
FE_SetProgressBarPercent (ce->window_id, percent);
#else
SetProgressBarPercent(percent);
#endif
/* only update every 20 groups for speed */ /* only update every 20 groups for speed */
if ((m_newsRCListCount <= NEWS_GROUP_DISPLAY_FREQ) || (m_newsRCListIndex % NEWS_GROUP_DISPLAY_FREQ) == 0 || if ((m_newsRCListCount <= NEWS_GROUP_DISPLAY_FREQ) || (m_newsRCListIndex % NEWS_GROUP_DISPLAY_FREQ) == 0 ||
@ -3546,18 +3538,11 @@ PRInt32 nsNNTPProtocol::DisplayNewsRC()
PR_snprintf (thisGroup, sizeof(thisGroup), "%ld", (long) m_newsRCListIndex); PR_snprintf (thisGroup, sizeof(thisGroup), "%ld", (long) m_newsRCListIndex);
PR_snprintf (totalGroups, sizeof(totalGroups), "%ld", (long) m_newsRCListCount); PR_snprintf (totalGroups, sizeof(totalGroups), "%ld", (long) m_newsRCListCount);
#ifdef UNREADY_CODE
statusText = PR_smprintf (XP_GetString(XP_THERMO_PERCENT_FORM), thisGroup, totalGroups);
#else
statusText = PR_smprintf ("%s / %s", thisGroup, totalGroups); statusText = PR_smprintf ("%s / %s", thisGroup, totalGroups);
#endif
if (statusText) if (statusText)
{ {
#ifdef UNREADY_CODE
FE_Progress (ce->window_id, statusText);
#else
SetProgressStatus(statusText); SetProgressStatus(statusText);
#endif
PR_Free(statusText); PR_Free(statusText);
} }
} }
@ -3572,11 +3557,7 @@ PRInt32 nsNNTPProtocol::DisplayNewsRC()
{ {
if (m_newsRCListCount) if (m_newsRCListCount)
{ {
#ifdef UNREADY_CODE SetProgressBarPercent(0, -1);
FE_SetProgressBarPercent (ce->window_id, -1);
#else
SetProgressBarPercent(-1);
#endif
m_newsRCListCount = 0; m_newsRCListCount = 0;
} }
else if (m_responseCode == MK_NNTP_RESPONSE_LIST_OK) else if (m_responseCode == MK_NNTP_RESPONSE_LIST_OK)
@ -4974,56 +4955,22 @@ nsresult nsNNTPProtocol::CloseSocket()
return nsMsgProtocol::CloseSocket(); return nsMsgProtocol::CloseSocket();
} }
void nsNNTPProtocol::SetProgressBarPercent(int percent) void nsNNTPProtocol::SetProgressBarPercent(PRUint32 aProgress, PRUint32 aProgressMax)
{ {
PR_LOG(NNTP,PR_LOG_ALWAYS,("nsNNTPProtocol::SetProgressBarPercent(%d)",percent)); if (mProgressEventSink)
PRUnichar *progressMsg = nsnull; mProgressEventSink->OnProgress(this, m_channelContext, aProgress, aProgressMax);
// PRUnichar *progressMsg = NNTPGetStringByID(aMsgId);
if (!m_runningURL) return;
nsCOMPtr <nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(m_runningURL);
if (mailnewsUrl) {
nsCOMPtr <nsIMsgStatusFeedback> feedback;
mailnewsUrl->GetStatusFeedback(getter_AddRefs(feedback));
char *printfString = PR_smprintf("%d%%", percent);
if (printfString) {
nsString formattedString; formattedString.AssignWithConversion(printfString);
progressMsg = nsCRT::strdup(formattedString.GetUnicode());
}
if (feedback) {
feedback->ShowProgress(percent);
feedback->ShowStatusString(progressMsg);
}
}
PR_FREEIF(progressMsg);
} }
void void
nsNNTPProtocol::SetProgressStatus(char *message) nsNNTPProtocol::SetProgressStatus(char *message)
{ {
PR_LOG(NNTP,PR_LOG_ALWAYS,("nsNNTPProtocol::SetProgressStatus(%s)",message)); PR_LOG(NNTP,PR_LOG_ALWAYS,("nsNNTPProtocol::SetProgressStatus(%s)",message));
PRUnichar *progressMsg = nsnull; if (mProgressEventSink)
// PRUnichar *progressMsg = NNTPGetStringByID(aMsgId); {
nsAutoString formattedString;
if (!m_runningURL) return; formattedString.AssignWithConversion(message);
mProgressEventSink->OnStatus(this, m_channelContext, formattedString.GetUnicode());
nsCOMPtr <nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(m_runningURL); }
if (mailnewsUrl) {
nsCOMPtr <nsIMsgStatusFeedback> feedback;
mailnewsUrl->GetStatusFeedback(getter_AddRefs(feedback));
char *printfString = PR_smprintf("%s", message);
if (printfString) {
nsString formattedString; formattedString.AssignWithConversion(printfString);
progressMsg = nsCRT::strdup(formattedString.GetUnicode());
}
if (feedback) {
feedback->ShowStatusString(progressMsg);
}
}
PR_FREEIF(progressMsg);
} }
NS_IMETHODIMP nsNNTPProtocol::GetContentType(char * *aContentType) NS_IMETHODIMP nsNNTPProtocol::GetContentType(char * *aContentType)

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

@ -385,9 +385,9 @@ private:
nsresult ParseURL(nsIURI * aURL, PRBool * bValP, char ** aGroup, char ** aMessageID, char ** aCommandSpecificData); nsresult ParseURL(nsIURI * aURL, PRBool * bValP, char ** aGroup, char ** aMessageID, char ** aCommandSpecificData);
void SetProgressBarPercent(int percent); void SetProgressBarPercent(PRUint32 aProgress, PRUint32 aProgressMax);
void SetProgressStatus(char * message); void SetProgressStatus(char * message);
nsresult InitializeNewsFolderFromUri(const char *uri); nsresult InitializeNewsFolderFromUri(const char *uri);
}; };
NS_BEGIN_EXTERN_C NS_BEGIN_EXTERN_C