rewrite progress to go through the progress event sink which we get from the

mock channel instead of from the status feedback object attached to the url.

Change progress Info struct to pass in current and max progress separately
instead of as a percentage.
This commit is contained in:
mscott%netscape.com 2000-05-03 21:21:07 +00:00
Родитель cb7f1cb7b0
Коммит b5fd327021
4 изменённых файлов: 36 добавлений и 32 удалений

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

@ -202,7 +202,8 @@ typedef struct _StreamInfo {
typedef struct _ProgressInfo {
PRUnichar *message;
int percent;
PRInt32 currentProgress;
PRInt32 maxProgress;
} ProgressInfo;
typedef struct _StatusMessageInfo {

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

@ -50,7 +50,6 @@
#include "nsICopyMsgStreamListener.h"
#include "nsImapStringBundle.h"
#include "nsIMsgFolderCacheElement.h"
#include "nsIMsgStatusFeedback.h"
#include "nsTextFormatter.h"
#include "nsIPref.h"
@ -66,6 +65,8 @@
#include "nsXPIDLString.h"
#include "nsIImapFlagAndUidState.h"
#include "nsIMessenger.h"
#include "nsIImapMockChannel.h"
#include "nsIProgressEventSink.h"
static NS_DEFINE_CID(kNetSupportDialogCID, NS_NETSUPPORTDIALOG_CID);
static NS_DEFINE_CID(kMsgFilterServiceCID, NS_MSGFILTERSERVICE_CID);
@ -3524,62 +3525,61 @@ nsImapMailFolder::ProgressStatus(nsIImapProtocol* aProtocol,
aProtocol->GetRunningImapURL(getter_AddRefs(imapUrl));
if (imapUrl)
{
nsCOMPtr <nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(imapUrl);
if (mailnewsUrl)
nsCOMPtr<nsIImapMockChannel> mockChannel;
imapUrl->GetMockChannel(getter_AddRefs(mockChannel));
if (mockChannel)
{
nsCOMPtr <nsIMsgStatusFeedback> feedback;
mailnewsUrl->GetStatusFeedback(getter_AddRefs(feedback));
if (extraInfo)
nsCOMPtr<nsIProgressEventSink> progressSink;
mockChannel->GetProgressEventSink(getter_AddRefs(progressSink));
if (progressSink)
{
PRUnichar *printfString = nsTextFormatter::smprintf(progressMsg, extraInfo);
if (printfString)
if (extraInfo)
{
progressMsg = nsCRT::strdup(printfString);
nsTextFormatter::smprintf_free(printfString);
PRUnichar *printfString = nsTextFormatter::smprintf(progressMsg, extraInfo);
if (printfString)
{
progressMsg = nsCRT::strdup(printfString);
nsTextFormatter::smprintf_free(printfString);
}
}
progressSink->OnStatus(mockChannel, nsnull, progressMsg);
}
if (feedback)
feedback->ShowStatusString(progressMsg);
}
}
}
PR_FREEIF(progressMsg);
return NS_OK;
return NS_OK;
}
NS_IMETHODIMP
nsImapMailFolder::PercentProgress(nsIImapProtocol* aProtocol,
ProgressInfo* aInfo)
{
#ifdef DEBUG_bienvenu1
nsCString message(aInfo->message);
printf("progress: %d %s\n", aInfo->percent, message.GetBuffer());
#endif
if (aProtocol)
{
nsCOMPtr <nsIImapUrl> imapUrl;
aProtocol->GetRunningImapURL(getter_AddRefs(imapUrl));
if (imapUrl)
{
nsCOMPtr <nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(imapUrl);
if (mailnewsUrl)
nsCOMPtr<nsIImapMockChannel> mockChannel;
imapUrl->GetMockChannel(getter_AddRefs(mockChannel));
if (mockChannel)
{
nsCOMPtr <nsIMsgStatusFeedback> feedback;
mailnewsUrl->GetStatusFeedback(getter_AddRefs(feedback));
if (feedback)
nsCOMPtr<nsIProgressEventSink> progressSink;
mockChannel->GetProgressEventSink(getter_AddRefs(progressSink));
if (progressSink)
{
feedback->ShowProgress(aInfo->percent);
progressSink->OnProgress(mockChannel, nsnull, aInfo->currentProgress, aInfo->maxProgress);
if (aInfo->message)
feedback->ShowStatusString(aInfo->message);
progressSink->OnStatus(mockChannel, nsnull, aInfo->message);
}
}
}
}
return NS_OK;
return NS_OK;
}
NS_IMETHODIMP

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

@ -1176,12 +1176,15 @@ PercentProgressProxyEvent::PercentProgressProxyEvent(
if (aInfo)
{
m_progressInfo.message = (aInfo->message) ? nsCRT::strdup(aInfo->message) : nsnull;
m_progressInfo.percent = aInfo->percent;
m_progressInfo.currentProgress = aInfo->currentProgress;
m_progressInfo.maxProgress = aInfo->maxProgress;
}
else
{
m_progressInfo.message = nsnull;
m_progressInfo.percent = 0;
m_progressInfo.maxProgress = -1;
m_progressInfo.currentProgress = 0;
}
}

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

@ -2369,7 +2369,7 @@ PRBool nsImapServerResponseParser::msg_fetch_literal(PRBool chunk, PRInt32 origi
{
fServerConnection.ProgressEventFunctionUsingId(IMAP_DOWNLOADING_MESSAGE);
if (fTotalDownloadSize > 0)
fServerConnection.PercentProgressUpdateEvent(0,(100*(charsReadSoFar + origin))/fTotalDownloadSize);
fServerConnection.PercentProgressUpdateEvent(0,charsReadSoFar + origin, fTotalDownloadSize);
}
if (charsReadSoFar > numberOfCharsInThisChunk)
{ // this is rare. If this msg ends in the middle of a line then only display the actual message.