Fix for bug 30903 a=leger r=dveditz

This commit is contained in:
dbragg%netscape.com 2000-03-10 01:23:06 +00:00
parent d8df80eb99
commit 2e39119016
6 changed files with 54 additions and 16 deletions

View File

@ -35,7 +35,7 @@ interface nsIXPIProgressDlg : nsISupports
void SetTitle( in wstring aTitle );
void SetHeading( in wstring aHeading );
void SetActionText( in wstring aText );
void SetProgress( in long aValue, in long aMax );
void SetProgress( in long aValue, in long aMax , in char mode);
void StartInstallPhase();
boolean GetCancelStatus();

View File

@ -84,7 +84,7 @@
<box align="vertical">
<spring style="height:6px"/>
<progressmeter id="dialog.progress" mode="undetermined" style="width:200px;height:10px">
<progressmeter id="dialog.progress" mode="normal" value="0" style="width:200px;height:10px">
</progressmeter>
</box>

View File

@ -122,7 +122,7 @@ nsInstallProgressDialog::FinalizeProgress(const PRUnichar *message, PRInt32 item
nsresult rv = SetActionText( message );
if (NS_SUCCEEDED(rv))
rv = SetProgress( itemNum, totNum );
rv = SetProgress( itemNum, totNum, 'n' );
return rv;
}
@ -208,7 +208,7 @@ nsInstallProgressDialog::SetHeading(const PRUnichar * aHeading)
NS_IMETHODIMP
nsInstallProgressDialog::SetActionText(const PRUnichar * aActionText)
{
const PRInt32 maxChars = 40;
const PRInt32 maxChars = 50;
nsString theMessage(aActionText);
PRInt32 len = theMessage.Length();
@ -224,17 +224,38 @@ nsInstallProgressDialog::SetActionText(const PRUnichar * aActionText)
}
NS_IMETHODIMP
nsInstallProgressDialog::SetProgress(PRInt32 aValue, PRInt32 aMax)
nsInstallProgressDialog::SetProgress(PRInt32 aValue, PRInt32 aMax, char mode)
{
char buf[16];
static char modeFlag = 'n';
nsresult rv;
static PRInt32 previousMax;
//First check to see if the max value changed so we don't
//have to send a max value across the proxy every time.
if ( aMax != previousMax)
{
previousMax = aMax;
PR_snprintf( buf, sizeof buf, "%lu", aMax );
nsresult rv = setDlgAttribute( "dialog.progress", "max", buf );
rv = setDlgAttribute( "dialog.progress", "max", buf );
}
//I use this modeFlag business so I don't have to send
//progressmeter mode information across the proxy every time.
if ( mode != modeFlag )
{
modeFlag = mode;
if ( modeFlag == 'n' )
rv = setDlgAttribute( "dialog.progress", "mode", "normal");
else
rv = setDlgAttribute( "dialog.progress", "mode", "undetermined");
}
if ( NS_SUCCEEDED(rv))
{
if (aMax != 0)
PR_snprintf( buf, sizeof buf, "%lu", ((aMax-aValue)/aMax) );
PR_snprintf( buf, sizeof buf, "%lu", 100 * aValue/aMax );
else
PR_snprintf( buf, sizeof buf, "%lu", 0 );

View File

@ -157,8 +157,8 @@ nsSoftwareUpdate::~nsSoftwareUpdate()
//------------------------------------------------------------------------
// nsISupports implementation
//------------------------------------------------------------------------
NS_IMPL_ADDREF( nsSoftwareUpdate );
NS_IMPL_RELEASE( nsSoftwareUpdate );
NS_IMPL_THREADSAFE_ADDREF( nsSoftwareUpdate );
NS_IMPL_THREADSAFE_RELEASE( nsSoftwareUpdate );
NS_IMETHODIMP

View File

@ -66,7 +66,8 @@ static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
#define XPINSTALL_BUNDLE_URL "chrome://xpinstall/locale/xpinstall.properties"
nsXPInstallManager::nsXPInstallManager()
: mTriggers(0), mItem(0), mNextItem(0), mNumJars(0), mFinalizing(PR_FALSE), mCancelled(PR_FALSE)
: mTriggers(0), mItem(0), mNextItem(0), mNumJars(0),
mFinalizing(PR_FALSE), mCancelled(PR_FALSE), mContentLength(0)
{
NS_INIT_ISUPPORTS();
@ -98,8 +99,8 @@ nsXPInstallManager::~nsXPInstallManager()
}
NS_IMPL_ADDREF( nsXPInstallManager );
NS_IMPL_RELEASE( nsXPInstallManager );
NS_IMPL_THREADSAFE_ADDREF( nsXPInstallManager );
NS_IMPL_THREADSAFE_RELEASE( nsXPInstallManager );
NS_IMETHODIMP
nsXPInstallManager::QueryInterface(REFNSIID aIID,void** aInstancePtr)
@ -279,6 +280,7 @@ NS_IMETHODIMP nsXPInstallManager::DownloadNext()
{
nsresult rv;
mContentLength = 0;
if (mCancelled)
{
Shutdown();
@ -600,7 +602,17 @@ NS_IMETHODIMP
nsXPInstallManager::OnProgress(nsIChannel *channel, nsISupports *ctxt, PRUint32 aProgress, PRUint32 aProgressMax)
{
if (!mCancelled)
return mProxy->SetProgress(aProgress, aProgressMax);
{
nsresult rv = NS_OK;
char mode = 'n'; // downloads use a "normal" progress bar
if (mContentLength < 1) {
NS_ASSERTION(channel, "should have a channel");
rv = channel->GetContentLength(&mContentLength);
if (NS_FAILED(rv)) return rv;
}
return mProxy->SetProgress(aProgress, mContentLength, mode);
}
return NS_OK;
}
@ -629,6 +641,10 @@ nsXPInstallManager::BeforeJavascriptEvaluation(const PRUnichar *URL)
nsresult rv = NS_OK;
mFinalizing = PR_FALSE;
mProxy->SetProgress( 0, 0, 'u' ); // turn on the barber pole
PRUnichar tmp[] = { '\0' };
mProxy->SetActionText(tmp);
return rv;
}
@ -675,7 +691,7 @@ nsXPInstallManager::FinalizeProgress(const PRUnichar *message, PRInt32 itemNum,
}
}
}
return mProxy->SetProgress( itemNum, totNum );
return mProxy->SetProgress( itemNum, totNum, 'n' );
}
NS_IMETHODIMP

View File

@ -94,6 +94,7 @@ class nsXPInstallManager : public nsIXPINotifier,
PRInt32 mNumJars;
PRBool mFinalizing;
PRBool mCancelled;
PRInt32 mContentLength;
nsCOMPtr<nsIXPIProgressDlg> mDlg;
nsCOMPtr<nsIXPIProgressDlg> mProxy;