more work on hooking up progress and status

This commit is contained in:
bienvenu%netscape.com 1999-08-04 18:45:36 +00:00
parent fb9841c7e5
commit 5e0c8c42a6
11 changed files with 87 additions and 65 deletions

View File

@ -68,8 +68,7 @@ public:
const char* aString) = 0;
NS_IMETHOD FEAlertFromServer(nsIImapProtocol* aProtocol,
const char* aString) = 0;
NS_IMETHOD ProgressStatus(nsIImapProtocol* aProtocol,
const char* statusMsg) = 0;
NS_IMETHOD ProgressStatus(nsIImapProtocol* aProtocol, PRUint32 aMsgId) = 0;
NS_IMETHOD PercentProgress(nsIImapProtocol* aProtocol,
ProgressInfo* aInfo) = 0;
NS_IMETHOD PastPasswordCheck(nsIImapProtocol* aProtocol) = 0;

View File

@ -62,6 +62,7 @@ CPPSRCS = \
nsImapFlagAndUidState.cpp \
nsImapMoveCoalescer.cpp \
nsImapUndoTxn.cpp \
nsImapStringBundle.cpp \
$(NULL)
include $(topsrcdir)/config/config.mk

View File

@ -61,6 +61,7 @@ CPP_OBJS= .\$(OBJDIR)\nsImapUrl.obj \
.\$(OBJDIR)\nsImapMoveCoalescer.obj \
.\$(OBJDIR)\nsImapUtils.obj \
.\$(OBJDIR)\nsImapUndoTxn.obj \
.\$(OBJDIR)\nsImapStringBundle.obj \
$(NULL)

View File

@ -188,7 +188,7 @@ typedef struct _StreamInfo {
} StreamInfo;
typedef struct _ProgressInfo {
char *message;
PRUnichar *message;
int percent;
} ProgressInfo;

View File

@ -43,6 +43,9 @@
#include "nsIIMAPHostSessionList.h"
#include "nsIMsgCopyService.h"
#include "nsICopyMsgStreamListener.h"
#include "nsImapStringBundle.h"
#ifdef DOING_FILTERS
#include "nsIMsgFilter.h"
@ -2797,16 +2800,26 @@ nsImapMailFolder::FEAlertFromServer(nsIImapProtocol* aProtocol,
NS_IMETHODIMP
nsImapMailFolder::ProgressStatus(nsIImapProtocol* aProtocol,
const char* statusMsg)
PRUint32 aMsgId)
{
return NS_ERROR_FAILURE;
PRUnichar *progressMsg = IMAPGetStringByID(aMsgId);
#ifdef DEBUG_bienvenu
nsCString cString(progressMsg);
printf("status: %s\n", cString.GetBuffer());
#endif
return NS_OK;
}
NS_IMETHODIMP
nsImapMailFolder::PercentProgress(nsIImapProtocol* aProtocol,
ProgressInfo* aInfo)
{
return NS_ERROR_FAILURE;
#ifdef DEBUG_bienvenu
nsCString message(aInfo->message);
printf("progress: %d %s\n", aInfo->percent, message.GetBuffer());
#endif
return NS_OK;
}
NS_IMETHODIMP

View File

@ -285,7 +285,7 @@ public:
NS_IMETHOD FEAlertFromServer(nsIImapProtocol* aProtocol,
const char* aString);
NS_IMETHOD ProgressStatus(nsIImapProtocol* aProtocol,
const char* statusMsg);
PRUint32 aMsgId);
NS_IMETHOD PercentProgress(nsIImapProtocol* aProtocol,
ProgressInfo* aInfo);
NS_IMETHOD PastPasswordCheck(nsIImapProtocol* aProtocol);

View File

@ -42,6 +42,8 @@
#include "nsISocketTransportService.h"
#include "nsXPIDLString.h"
#include "nsImapStringBundle.h"
PRLogModuleInfo *IMAP;
// netlib required files
@ -1305,7 +1307,7 @@ void nsImapProtocol::ProcessSelectedStateURL()
else
{
// get new message counts, if any, from server
// ProgressEventFunction_UsingId (MK_IMAP_STATUS_SELECTING_MAILBOX);
ProgressEventFunctionUsingId (IMAP_STATUS_SELECTING_MAILBOX);
if (m_needNoop)
{
m_noopCount++;
@ -1386,7 +1388,7 @@ void nsImapProtocol::ProcessSelectedStateURL()
if (HandlingMultipleMessages(messageIdString))
{
// multiple messages, fetch them all
// m_progressStringId = XP_FOLDER_RECEIVING_MESSAGE_OF;
m_progressStringId = IMAP_FOLDER_RECEIVING_MESSAGE_OF;
m_progressIndex = 0;
m_progressCount = CountMessagesInIdString(messageIdString);
@ -1537,12 +1539,10 @@ void nsImapProtocol::ProcessSelectedStateURL()
nsString2 messageIdString("",eOneByte);
m_runningUrl->CreateListOfMessageIdsString(&messageIdString);
#ifdef DO_PROGRESS
if (HandlingMultipleMessages(messageIdString))
ProgressEventFunction_UsingId (XP_IMAP_DELETING_MESSAGES);
ProgressEventFunctionUsingId (IMAP_DELETING_MESSAGES);
else
ProgressEventFunction_UsingId(XP_IMAP_DELETING_MESSAGE);
#endif
ProgressEventFunctionUsingId(IMAP_DELETING_MESSAGE);
Store(messageIdString, "+FLAGS (\\Deleted)",
bMessageIdsAreUids);
@ -1678,20 +1678,19 @@ void nsImapProtocol::ProcessSelectedStateURL()
if (destinationMailbox)
{
#ifdef DOING_PROGRESS
if (imapAction == nsIImapUrl::nsImapOnlineMove) {
if (imapAction == nsIImapUrl::nsImapOnlineMove)
{
if (HandlingMultipleMessages(messageIdString))
ProgressEventFunction_UsingIdWithString (XP_IMAP_MOVING_MESSAGES_TO, destinationMailbox);
ProgressEventFunctionUsingIdWithString (IMAP_MOVING_MESSAGES_TO, destinationMailbox);
else
ProgressEventFunction_UsingIdWithString (XP_IMAP_MOVING_MESSAGE_TO, destinationMailbox);
ProgressEventFunctionUsingIdWithString (IMAP_MOVING_MESSAGE_TO, destinationMailbox);
}
else {
if (HandlingMultipleMessages(messageIdString))
ProgressEventFunction_UsingIdWithString (XP_IMAP_COPYING_MESSAGES_TO, destinationMailbox);
ProgressEventFunctionUsingIdWithString (IMAP_COPYING_MESSAGES_TO, destinationMailbox);
else
ProgressEventFunction_UsingIdWithString (XP_IMAP_COPYING_MESSAGE_TO, destinationMailbox);
ProgressEventFunctionUsingIdWithString (IMAP_COPYING_MESSAGE_TO, destinationMailbox);
}
#endif
Copy(messageIdString, destinationMailbox, bMessageIdsAreUids);
PR_FREEIF( destinationMailbox);
ImapOnlineCopyState copyState;
@ -1730,15 +1729,15 @@ void nsImapProtocol::ProcessSelectedStateURL()
m_runningUrl->CreateListOfMessageIdsString(&messageIdString);
if (messageIdString)
{
fProgressStringId = XP_FOLDER_RECEIVING_MESSAGE_OF;
fProgressIndex = 0;
fProgressCount = CountMessagesInIdString(messageIdString);
m_progressStringId = XP_FOLDER_RECEIVING_MESSAGE_OF;
m_progressIndex = 0;
m_progressCount = CountMessagesInIdString(messageIdString);
FetchMessage(messageIdString,
kEveryThingRFC822Peek,
bMessageIdsAreUids);
fProgressStringId = 0;
m_progressStringId = 0;
OnlineCopyCompleted(
GetServerStateParser().LastCommandSuccessful() ?
kSuccessfulCopy : kFailedCopy);
@ -1951,7 +1950,7 @@ char *nsImapProtocol::CreateEscapedMailboxName(const char *rawName)
void nsImapProtocol::SelectMailbox(const char *mailboxName)
{
// ProgressEventFunction_UsingId (MK_IMAP_STATUS_SELECTING_MAILBOX);
ProgressEventFunctionUsingId (IMAP_STATUS_SELECTING_MAILBOX);
IncrementCommandTagNumber();
m_closeNeededBeforeSelect = PR_FALSE; // initial value
@ -2728,26 +2727,24 @@ void nsImapProtocol::FolderHeaderDump(PRUint32 *msgUids, PRUint32 msgCount)
void nsImapProtocol::FolderMsgDump(PRUint32 *msgUids, PRUint32 msgCount, nsIMAPeFetchFields fields)
{
#if 0
// lets worry about this progress stuff later.
switch (fields) {
case TIMAP4BlockingConnection::kHeadersRFC822andUid:
fProgressStringId = XP_RECEIVING_MESSAGE_HEADERS_OF;
case kHeadersRFC822andUid:
m_progressStringId = IMAP_RECEIVING_MESSAGE_HEADERS_OF;
break;
case TIMAP4BlockingConnection::kFlags:
fProgressStringId = XP_RECEIVING_MESSAGE_FLAGS_OF;
case kFlags:
m_progressStringId = IMAP_RECEIVING_MESSAGE_FLAGS_OF;
break;
default:
fProgressStringId = XP_FOLDER_RECEIVING_MESSAGE_OF;
m_progressStringId = IMAP_FOLDER_RECEIVING_MESSAGE_OF;
break;
}
fProgressIndex = 0;
fProgressCount = msgCount;
#endif // 0
m_progressIndex = 0;
m_progressCount = msgCount;
FolderMsgDumpLoop(msgUids, msgCount, fields);
// fProgressStringId = 0;
m_progressStringId = 0;
}
void nsImapProtocol::WaitForPotentialListOfMsgsToFetch(PRUint32 **msgIdList, PRUint32 &msgCount)
@ -3673,18 +3670,32 @@ nsImapProtocol::ShowProgress()
{
ProgressInfo aProgressInfo;
aProgressInfo.message = "*** Fix me!! ***\r\n";
aProgressInfo.percent = 0;
if (m_progressStringId)
{
PRUnichar *progressString = NULL;
progressString = IMAPGetStringByID(m_progressStringId);
const char *mailboxName = GetServerStateParser().GetSelectedMailboxName();
// progressString = PR_sprintf_append(progressString, XP_GetString(m_progressStringId), (mailboxName) ? mailboxName : "", ++m_progressIndex, m_progressCount);
if (progressString)
PercentProgressUpdateEvent(progressString,(100*(++m_progressIndex))/m_progressCount );
PR_FREEIF(progressString);
aProgressInfo.message = progressString;
aProgressInfo.percent = (100*(m_progressIndex))/m_progressCount;
if (m_imapMiscellaneousSink)
m_imapMiscellaneousSink->PercentProgress(this, &aProgressInfo);
if (m_imapMiscellaneousSink)
m_imapMiscellaneousSink->PercentProgress(this, &aProgressInfo);
}
}
void
nsImapProtocol::ProgressEventFunctionUsingId(PRUint32 aMsgId)
{
PRUnichar *status = IMAPGetStringByID(aMsgId);
if (m_imapMiscellaneousSink)
m_imapMiscellaneousSink->ProgressStatus(this, "*** Fix me!! ***\r\n");
{
m_imapMiscellaneousSink->ProgressStatus(this, aMsgId);
// who's going to free this? Does ProgressStatus complete synchronously?
}
}
void
@ -3692,11 +3703,16 @@ nsImapProtocol::ProgressEventFunctionUsingIdWithString(PRUint32 aMsgId, const
char * aExtraInfo)
{
if (m_imapMiscellaneousSink)
m_imapMiscellaneousSink->ProgressStatus(this, "*** Fix me!! ***\r\n");
{
// PRUnichar *progressMsg = IMAPGetStringByID(aMsgId);
// ### FIXME - need to format this string, and pass it status. Or, invent a new interface
m_imapMiscellaneousSink->ProgressStatus(this, aMsgId);
}
}
void
nsImapProtocol::PercentProgressUpdateEvent(char *message, PRInt32 percent)
nsImapProtocol::PercentProgressUpdateEvent(PRUnichar *message, PRInt32 percent)
{
ProgressInfo aProgressInfo;
aProgressInfo.message = message;
@ -3935,7 +3951,7 @@ void nsImapProtocol::HandleCurrentUrlError()
void nsImapProtocol::Capability()
{
// ProgressEventFunction_UsingId (MK_IMAP_STATUS_CHECK_COMPAT);
ProgressEventFunctionUsingId (IMAP_STATUS_CHECK_COMPAT);
IncrementCommandTagNumber();
nsString2 command(GetServerCommandTag(), eOneByte);

View File

@ -198,7 +198,7 @@ public:
void ProgressEventFunctionUsingId(PRUint32 aMsgId);
void ProgressEventFunctionUsingIdWithString(PRUint32 aMsgId, const char *
aExtraInfo);
void PercentProgressUpdateEvent(char *message, PRInt32 percent);
void PercentProgressUpdateEvent(PRUnichar *message, PRInt32 percent);
// utility function calls made by the server
char * CreateUtf7ConvertedString(const char * aSourceString, PRBool

View File

@ -1599,18 +1599,15 @@ nsImapMiscellaneousSinkProxy::FEAlertFromServer(nsIImapProtocol* aProtocol,
NS_IMETHODIMP
nsImapMiscellaneousSinkProxy::ProgressStatus(nsIImapProtocol* aProtocol,
const char* statusMsg)
PRUint32 aMsgId)
{
nsresult res = NS_OK;
NS_PRECONDITION (statusMsg, "Oops... null statusMsg");
if(!statusMsg)
return NS_ERROR_NULL_POINTER;
NS_ASSERTION (m_protocol == aProtocol, "Ooh ooh, wrong protocol");
if (PR_GetCurrentThread() == m_thread)
{
ProgressStatusProxyEvent *ev =
new ProgressStatusProxyEvent(this, statusMsg);
new ProgressStatusProxyEvent(this, aMsgId);
if(nsnull == ev)
res = NS_ERROR_OUT_OF_MEMORY;
else
@ -1618,7 +1615,7 @@ nsImapMiscellaneousSinkProxy::ProgressStatus(nsIImapProtocol* aProtocol,
}
else
{
res = m_realImapMiscellaneousSink->ProgressStatus(aProtocol, statusMsg);
res = m_realImapMiscellaneousSink->ProgressStatus(aProtocol, aMsgId);
}
return res;
}
@ -3444,27 +3441,21 @@ FEAlertFromServerProxyEvent::HandleEvent()
}
ProgressStatusProxyEvent::ProgressStatusProxyEvent(
nsImapMiscellaneousSinkProxy* aProxy, const char* statusMsg) :
nsImapMiscellaneousSinkProxy* aProxy, PRUint32 aMsgId) :
nsImapMiscellaneousSinkProxyEvent(aProxy)
{
NS_ASSERTION (statusMsg, "Oops... a null statusMsg");
if (statusMsg)
m_statusMsg = PL_strdup(statusMsg);
else
m_statusMsg = nsnull;
m_statusMsgId = aMsgId;
}
ProgressStatusProxyEvent::~ProgressStatusProxyEvent()
{
if (m_statusMsg)
PL_strfree(m_statusMsg);
}
NS_IMETHODIMP
ProgressStatusProxyEvent::HandleEvent()
{
nsresult res = m_proxy->m_realImapMiscellaneousSink->ProgressStatus(
m_proxy->m_protocol, m_statusMsg);
m_proxy->m_protocol, m_statusMsgId);
if (m_notifyCompletion)
m_proxy->m_protocol->NotifyFEEventCompletion();
return res;
@ -3477,7 +3468,7 @@ PercentProgressProxyEvent::PercentProgressProxyEvent(
NS_ASSERTION (aInfo, "Oops... a null progress info");
if (aInfo)
{
m_progressInfo.message = PL_strdup(aInfo->message);
m_progressInfo.message = (aInfo->message) ? nsCRT::strdup(aInfo->message) : nsnull;
m_progressInfo.percent = aInfo->percent;
}
else
@ -3490,7 +3481,7 @@ PercentProgressProxyEvent::PercentProgressProxyEvent(
PercentProgressProxyEvent::~PercentProgressProxyEvent()
{
if (m_progressInfo.message)
PL_strfree(m_progressInfo.message);
PR_Free(m_progressInfo.message);
}
NS_IMETHODIMP

View File

@ -232,7 +232,7 @@ public:
NS_IMETHOD FEAlertFromServer(nsIImapProtocol* aProtocol,
const char* aString);
NS_IMETHOD ProgressStatus(nsIImapProtocol* aProtocol,
const char* statusMsg);
PRUint32 statusMsgId);
NS_IMETHOD PercentProgress(nsIImapProtocol* aProtocol,
ProgressInfo* aInfo);
NS_IMETHOD PastPasswordCheck(nsIImapProtocol* aProtocol);
@ -756,10 +756,10 @@ struct FEAlertFromServerProxyEvent : public nsImapMiscellaneousSinkProxyEvent
struct ProgressStatusProxyEvent : public nsImapMiscellaneousSinkProxyEvent
{
ProgressStatusProxyEvent(nsImapMiscellaneousSinkProxy* aProxy,
const char* statusMsg);
PRUint32 statusMsgId);
virtual ~ProgressStatusProxyEvent();
NS_IMETHOD HandleEvent();
char* m_statusMsg;
PRUint32 m_statusMsgId;
};
struct PercentProgressProxyEvent : public nsImapMiscellaneousSinkProxyEvent

View File

@ -64,7 +64,7 @@ NS_END_EXTERN_C
#define IMAP_NO_ONLINE_FOLDER 5034
#define IMAP_LOGIN_FAILED 5035
#define IMAP_RECEIVING_MESSAGE_HEADERS_OF 5036
#define XP_RECEIVING_MESSAGE_FLAGS_OF 5037
#define IMAP_RECEIVING_MESSAGE_FLAGS_OF 5037
#define IMAP_DELETING_MESSAGES 5038
#define IMAP_DELETING_MESSAGE 5039
#define IMAP_MOVING_MESSAGES_TO 5040
@ -72,6 +72,7 @@ NS_END_EXTERN_C
#define IMAP_COPYING_MESSAGES_TO 5042
#define IMAP_COPYING_MESSAGE_TO 5043
#define IMAP_SELECTING_MAILBOX 5044
#define IMAP_FOLDER_RECEIVING_MESSAGE_OF 5045
#endif /* _nsImapStringBundle_H__ */