Bug #379070 --> nsIMsgStatusFeedback cleanup. Convert many of the string arguments to A(C)String. General code cleanup.

Patch by Joerg Bornemann <jobor@gmx.de>

sr=mscott
This commit is contained in:
scott%scott-macgregor.org 2007-06-05 22:59:39 +00:00
Родитель 54bc12a59f
Коммит 222c9bf7af
15 изменённых файлов: 70 добавлений и 70 удалений

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

@ -37,13 +37,13 @@
#include "nsISupports.idl"
[scriptable, uuid(FD1321EC-C84E-4939-B26B-8CFC676C8333)]
[scriptable, uuid(AACBFA34-8D29-4A08-9283-A8E5B3AB067F)]
interface nsIMsgStatusFeedback : nsISupports {
void showStatusString(in wstring status);
void showStatusString(in AString aStatus);
void startMeteors();
void stopMeteors();
void showProgress(in long percent);
void setStatusString(in wstring status); // will be displayed until next user action
void showProgress(in long aPercent);
void setStatusString(in AString aStatus); // will be displayed until next user action
/* aStatusFeedback: a wrapped JS status feedback object */
void setWrappedStatusFeedback(in nsIMsgStatusFeedback aStatusFeedback);

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

@ -266,7 +266,7 @@ nsresult nsFolderCompactState::ShowStatusMsg(const nsString& aMsg)
{
m_window->GetStatusFeedback(getter_AddRefs(statusFeedback));
if (statusFeedback && !aMsg.IsEmpty())
return statusFeedback->SetStatusString (aMsg.get());
return statusFeedback->SetStatusString(aMsg);
}
return NS_OK;
}

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

@ -401,7 +401,7 @@ NS_IMETHODIMP nsMsgOfflineManager::OnProgress(PRUint32 aCurrentMessage, PRUint32
NS_IMETHODIMP nsMsgOfflineManager::OnStatus(const PRUnichar *aMsg)
{
if (m_statusFeedback && aMsg)
return m_statusFeedback->ShowStatusString (aMsg);
return m_statusFeedback->ShowStatusString(nsDependentString(aMsg));
else
return NS_OK;
}

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

@ -590,7 +590,7 @@ nsMsgPrintEngine::SetStatusMessage(const nsString& aMsgString)
if ( (!mFeedback) || (aMsgString.IsEmpty()) )
return NS_OK;
mFeedback->ShowStatusString(aMsgString.get());
mFeedback->ShowStatusString(aMsgString);
return NS_OK;
}

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

@ -298,14 +298,14 @@ nsresult nsMsgProgress::ReleaseListeners()
return rv;
}
NS_IMETHODIMP nsMsgProgress::ShowStatusString(const PRUnichar *status)
NS_IMETHODIMP nsMsgProgress::ShowStatusString(const nsAString& aStatus)
{
return OnStatusChange(nsnull, nsnull, NS_OK, status);
return OnStatusChange(nsnull, nsnull, NS_OK, PromiseFlatString(aStatus).get());
}
NS_IMETHODIMP nsMsgProgress::SetStatusString(const PRUnichar *status)
NS_IMETHODIMP nsMsgProgress::SetStatusString(const nsAString& aStatus)
{
return OnStatusChange(nsnull, nsnull, NS_OK, status);
return OnStatusChange(nsnull, nsnull, NS_OK, PromiseFlatString(aStatus).get());
}
/* void startMeteors (); */
@ -367,5 +367,5 @@ NS_IMETHODIMP nsMsgProgress::OnStatus(nsIRequest *request, nsISupports* ctxt,
nsString str;
rv = sbs->FormatStatusMessage(aStatus, aStatusArg, getter_Copies(str));
NS_ENSURE_SUCCESS(rv, rv);
return ShowStatusString(str.get());
return ShowStatusString(str);
}

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

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -60,17 +60,17 @@
nsMsgStatusFeedback::nsMsgStatusFeedback() :
m_lastPercent(0)
{
LL_I2L(m_lastProgressTime, 0);
LL_I2L(m_lastProgressTime, 0);
nsresult rv;
nsCOMPtr<nsIStringBundleService> bundleService =
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
nsresult rv;
nsCOMPtr<nsIStringBundleService> bundleService =
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv))
bundleService->CreateBundle("chrome://messenger/locale/messenger.properties",
getter_AddRefs(mBundle));
if (NS_SUCCEEDED(rv))
bundleService->CreateBundle("chrome://messenger/locale/messenger.properties",
getter_AddRefs(mBundle));
m_msgLoadedAtom = do_GetAtom("msgLoaded");
m_msgLoadedAtom = do_GetAtom("msgLoaded");
}
nsMsgStatusFeedback::~nsMsgStatusFeedback()
@ -82,11 +82,11 @@ NS_IMPL_THREADSAFE_ADDREF(nsMsgStatusFeedback)
NS_IMPL_THREADSAFE_RELEASE(nsMsgStatusFeedback)
NS_INTERFACE_MAP_BEGIN(nsMsgStatusFeedback)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIMsgStatusFeedback)
NS_INTERFACE_MAP_ENTRY(nsIMsgStatusFeedback)
NS_INTERFACE_MAP_ENTRY(nsIProgressEventSink)
NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIMsgStatusFeedback)
NS_INTERFACE_MAP_ENTRY(nsIMsgStatusFeedback)
NS_INTERFACE_MAP_ENTRY(nsIProgressEventSink)
NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_END
//////////////////////////////////////////////////////////////////////////////////
@ -133,7 +133,7 @@ nsMsgStatusFeedback::OnStateChange(nsIWebProgress* aWebProgress,
rv = mBundle->GetStringFromName(NS_LITERAL_STRING("documentLoading").get(),
getter_Copies(loadingDocument));
if (NS_SUCCEEDED(rv))
ShowStatusString(loadingDocument.get());
ShowStatusString(loadingDocument);
}
else if (aProgressStateFlags & STATE_STOP)
{
@ -192,7 +192,7 @@ nsMsgStatusFeedback::OnStateChange(nsIWebProgress* aWebProgress,
rv = mBundle->GetStringFromName(NS_LITERAL_STRING("documentDone").get(),
getter_Copies(documentDone));
if (NS_SUCCEEDED(rv))
ShowStatusString(documentDone.get());
ShowStatusString(documentDone);
}
}
return NS_OK;
@ -225,54 +225,54 @@ nsMsgStatusFeedback::OnSecurityChange(nsIWebProgress *aWebProgress,
NS_IMETHODIMP
nsMsgStatusFeedback::ShowStatusString(const PRUnichar *status)
nsMsgStatusFeedback::ShowStatusString(const nsAString& aStatus)
{
nsCOMPtr<nsIMsgStatusFeedback> jsStatusFeedback(do_QueryReferent(mJSStatusFeedbackWeak));
if (jsStatusFeedback)
jsStatusFeedback->ShowStatusString(status);
return NS_OK;
}
NS_IMETHODIMP
nsMsgStatusFeedback::SetStatusString(const PRUnichar *status)
{
nsCOMPtr<nsIMsgStatusFeedback> jsStatusFeedback(do_QueryReferent(mJSStatusFeedbackWeak));
nsCOMPtr <nsIXULBrowserWindow> xulBrowserWindow = do_QueryInterface(jsStatusFeedback);
if (xulBrowserWindow)
xulBrowserWindow->SetJSDefaultStatus(nsDependentString(status));
jsStatusFeedback->ShowStatusString(aStatus);
return NS_OK;
}
NS_IMETHODIMP
nsMsgStatusFeedback::ShowProgress(PRInt32 percentage)
nsMsgStatusFeedback::SetStatusString(const nsAString& aStatus)
{
nsCOMPtr<nsIMsgStatusFeedback> jsStatusFeedback(do_QueryReferent(mJSStatusFeedbackWeak));
nsCOMPtr <nsIXULBrowserWindow> xulBrowserWindow = do_QueryInterface(jsStatusFeedback);
if (xulBrowserWindow)
xulBrowserWindow->SetJSDefaultStatus(aStatus);
return NS_OK;
}
NS_IMETHODIMP
nsMsgStatusFeedback::ShowProgress(PRInt32 aPercentage)
{
// if the percentage hasn't changed...OR if we are going from 0 to 100% in one step
// then don't bother....just fall out....
if (percentage == m_lastPercent || (m_lastPercent == 0 && percentage >= 100))
return NS_OK;
if (aPercentage == m_lastPercent || (m_lastPercent == 0 && aPercentage >= 100))
return NS_OK;
m_lastPercent = percentage;
m_lastPercent = aPercentage;
PRInt64 nowMS;
LL_I2L(nowMS, 0);
if (percentage < 100) // always need to do 100%
{
int64 minIntervalBetweenProgress;
PRInt64 nowMS;
LL_I2L(nowMS, 0);
if (aPercentage < 100) // always need to do 100%
{
int64 minIntervalBetweenProgress;
LL_I2L(minIntervalBetweenProgress, 250);
int64 diffSinceLastProgress;
LL_I2L(nowMS, PR_IntervalToMilliseconds(PR_IntervalNow()));
LL_SUB(diffSinceLastProgress, nowMS, m_lastProgressTime); // r = a - b
LL_SUB(diffSinceLastProgress, diffSinceLastProgress, minIntervalBetweenProgress); // r = a - b
if (!LL_GE_ZERO(diffSinceLastProgress))
return NS_OK;
}
LL_I2L(minIntervalBetweenProgress, 250);
int64 diffSinceLastProgress;
LL_I2L(nowMS, PR_IntervalToMilliseconds(PR_IntervalNow()));
LL_SUB(diffSinceLastProgress, nowMS, m_lastProgressTime); // r = a - b
LL_SUB(diffSinceLastProgress, diffSinceLastProgress, minIntervalBetweenProgress); // r = a - b
if (!LL_GE_ZERO(diffSinceLastProgress))
return NS_OK;
}
m_lastProgressTime = nowMS;
m_lastProgressTime = nowMS;
nsCOMPtr<nsIMsgStatusFeedback> jsStatusFeedback(do_QueryReferent(mJSStatusFeedbackWeak));
if (jsStatusFeedback)
jsStatusFeedback->ShowProgress(percentage);
return NS_OK;
jsStatusFeedback->ShowProgress(aPercentage);
return NS_OK;
}
NS_IMETHODIMP
@ -318,5 +318,5 @@ NS_IMETHODIMP nsMsgStatusFeedback::OnStatus(nsIRequest *request, nsISupports* ct
nsString str;
rv = sbs->FormatStatusMessage(aStatus, aStatusArg, getter_Copies(str));
NS_ENSURE_SUCCESS(rv, rv);
return ShowStatusString(str.get());
return ShowStatusString(str);
}

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

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*

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

@ -452,7 +452,7 @@ void nsSmtpProtocol::UpdateStatus(PRInt32 aStatusID)
void nsSmtpProtocol::UpdateStatusWithString(const PRUnichar * aStatusString)
{
if (m_statusFeedback && aStatusString)
m_statusFeedback->ShowStatusString(aStatusString);
m_statusFeedback->ShowStatusString(nsDependentString(aStatusString));
}
/////////////////////////////////////////////////////////////////////////////////////////////

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

@ -6898,7 +6898,7 @@ nsImapMailFolder::CopyStreamMessage(nsIMsgDBHdr* message,
m_copyState->m_msgWindow->GetStatusFeedback(getter_AddRefs(statusFeedback));
if (statusFeedback)
{
statusFeedback->ShowStatusString(progressText.get());
statusFeedback->ShowStatusString(progressText);
PRInt32 percent;
percent = (100 * m_copyState->m_curIndex) / (PRInt32) m_copyState->m_totalCount;
statusFeedback->ShowProgress(percent);

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

@ -3260,7 +3260,7 @@ nsresult nsMsgLocalMailFolder::DisplayMoveCopyStatusMsg()
return NS_OK;
mCopyState->m_lastProgressTime = nowMS;
mCopyState->m_statusFeedback->ShowStatusString(finalString.get());
mCopyState->m_statusFeedback->ShowStatusString(finalString);
mCopyState->m_statusFeedback->ShowProgress(mCopyState->m_curCopyIndex * 100 / mCopyState->m_totalMsgCount);
}
}

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

@ -275,7 +275,7 @@ void nsMsgMailboxParser::UpdateStatusText (PRUint32 stringID)
}
else
bundle->GetStringFromID(stringID, getter_Copies(finalString));
m_statusFeedback->ShowStatusString(finalString.get());
m_statusFeedback->ShowStatusString(finalString);
}
}

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

@ -3057,7 +3057,7 @@ nsPop3Protocol::SendRetr()
getter_Copies(finalString));
NS_ASSERTION(NS_SUCCEEDED(rv), "couldn't format string");
if (m_statusFeedback)
m_statusFeedback->ShowStatusString(finalString.get());
m_statusFeedback->ShowStatusString(finalString);
}
status = SendData(m_url, cmd);

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

@ -1096,7 +1096,7 @@ nsNNTPNewsgroupList::SetProgressStatus(const PRUnichar *message)
mailnewsUrl->GetStatusFeedback(getter_AddRefs(feedback));
if (feedback) {
feedback->ShowStatusString(message);
feedback->ShowStatusString(nsDependentString(message));
}
}
}

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

@ -3149,7 +3149,7 @@ PRInt32 nsNNTPProtocol::ReadNewsList(nsIInputStream * inputStream, PRUint32 leng
formatStrings, 3,
getter_Copies(statusString));
rv = msgStatusFeedback->ShowStatusString(statusString.get());
rv = msgStatusFeedback->ShowStatusString(statusString);
if (NS_FAILED(rv)) {
PR_Free(lineToFree);
return rv;

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

@ -245,7 +245,7 @@ nsresult nsNewsDownloader::ShowProgress(const PRUnichar *progressString, PRInt32
}
if (m_statusFeedback)
{
m_statusFeedback->ShowStatusString(progressString);
m_statusFeedback->ShowStatusString(nsDependentString(progressString));
if (percent != m_lastPercent)
{
m_statusFeedback->ShowProgress(percent);