fixing bug #11210. Updated the install progress dialog to have a better

look and feel.  r=sgehani.  affects only the windows platform.
This commit is contained in:
ssu%netscape.com 2000-02-01 23:00:49 +00:00
parent d35e634fb8
commit 620e812679
3 changed files with 157 additions and 48 deletions

View File

@ -28,17 +28,26 @@
#include "xpistub.h" #include "xpistub.h"
#include "xpi.h" #include "xpi.h"
#define BDIR_RIGHT 1
#define BDIR_LEFT 2
static XpiInit pfnXpiInit; static XpiInit pfnXpiInit;
static XpiInstall pfnXpiInstall; static XpiInstall pfnXpiInstall;
static XpiExit pfnXpiExit; static XpiExit pfnXpiExit;
static long lFileCounter; static long lFileCounter;
static long lBarberCounter;
static BOOL bBarberBar;
static DWORD dwBarberDirection;
static DWORD dwCurrentArchive; static DWORD dwCurrentArchive;
static DWORD dwTotalArchives; static DWORD dwTotalArchives;
char szStrProcessingFile[MAX_BUF];
char szStrCopyingFile[MAX_BUF];
char szStrInstalling[MAX_BUF];
static void UpdateGaugeFileProgressBar(unsigned value); static void UpdateGaugeFileProgressBar(unsigned value);
static void UpdateGaugeArchiveProgressBar(unsigned value); static void UpdateGaugeArchiveProgressBar(unsigned value);
static void UpdateFileStatus(const char *szFullFilename); static void UpdateGaugeFileBarber(void);
struct ExtractFilesDlgInfo struct ExtractFilesDlgInfo
{ {
@ -149,6 +158,12 @@ HRESULT SmartUpdateJars()
return(1); return(1);
if(NS_LoadString(hSetupRscInst, IDS_DLG_EXTRACTING_TITLE, szDlgExtractingTitle, MAX_BUF) != WIZ_OK) if(NS_LoadString(hSetupRscInst, IDS_DLG_EXTRACTING_TITLE, szDlgExtractingTitle, MAX_BUF) != WIZ_OK)
return(1); return(1);
if(NS_LoadString(hSetupRscInst, IDS_STR_PROCESSINGFILE, szStrProcessingFile, MAX_BUF) != WIZ_OK)
exit(1);
if(NS_LoadString(hSetupRscInst, IDS_STR_INSTALLING, szStrInstalling, MAX_BUF) != WIZ_OK)
exit(1);
if(NS_LoadString(hSetupRscInst, IDS_STR_COPYINGFILE, szStrCopyingFile, MAX_BUF) != WIZ_OK)
exit(1);
ShowMessage(szMsgSmartUpdateStart, TRUE); ShowMessage(szMsgSmartUpdateStart, TRUE);
if(InitializeXPIStub() == WIZ_OK) if(InitializeXPIStub() == WIZ_OK)
@ -158,17 +173,21 @@ HRESULT SmartUpdateJars()
ShowMessage(szMsgSmartUpdateStart, FALSE); ShowMessage(szMsgSmartUpdateStart, FALSE);
InitProgressDlg(); InitProgressDlg();
GetTotalArchivesToInstall(); GetTotalArchivesToInstall();
SetWindowText(dlgInfo.hWndDlg, szDlgExtractingTitle);
dwIndex0 = 0; dwIndex0 = 0;
dwCurrentArchive = 0; dwCurrentArchive = 0;
dwTotalArchives *= 2; dwTotalArchives = (dwTotalArchives * 2) + 1;
siCObject = SiCNodeGetObject(dwIndex0, TRUE); bBarberBar = FALSE;
siCObject = SiCNodeGetObject(dwIndex0, TRUE);
while(siCObject) while(siCObject)
{ {
/* launch smartupdate engine for earch jar to be installed */ /* launch smartupdate engine for earch jar to be installed */
if((siCObject->dwAttributes & SIC_SELECTED) && !(siCObject->dwAttributes & SIC_LAUNCHAPP)) if((siCObject->dwAttributes & SIC_SELECTED) && !(siCObject->dwAttributes & SIC_LAUNCHAPP))
{ {
lFileCounter = 0; lFileCounter = 0;
lBarberCounter = 0;
dwBarberDirection = BDIR_RIGHT;
dlgInfo.nFileBars = 0; dlgInfo.nFileBars = 0;
UpdateGaugeFileProgressBar(0); UpdateGaugeFileProgressBar(0);
@ -199,8 +218,15 @@ HRESULT SmartUpdateJars()
} }
} }
wsprintf(szBuf, szDlgExtractingTitle, siCObject->szDescriptionShort); if(dwCurrentArchive == 0)
SetWindowText(dlgInfo.hWndDlg, szBuf); {
++dwCurrentArchive;
UpdateGaugeArchiveProgressBar((unsigned)(((double)(dwCurrentArchive)/(double)dwTotalArchives)*(double)100));
}
wsprintf(szBuf, szStrInstalling, siCObject->szDescriptionShort);
SetDlgItemText(dlgInfo.hWndDlg, IDC_STATUS0, szBuf);
hrResult = pfnXpiInstall(szArchive, "", 0xFFFF); hrResult = pfnXpiInstall(szArchive, "", 0xFFFF);
if(hrResult == 999) if(hrResult == 999)
bReboot = TRUE; bReboot = TRUE;
@ -240,23 +266,36 @@ HRESULT SmartUpdateJars()
void cbXPIStart(const char *URL, const char *UIName) void cbXPIStart(const char *URL, const char *UIName)
{ {
// MessageBox(NULL, UIName, "XpiStub is running", MB_ICONEXCLAMATION);
} }
void cbXPIProgress(const char* msg, PRInt32 val, PRInt32 max) void cbXPIProgress(const char* msg, PRInt32 val, PRInt32 max)
{ {
char szFilename[MAX_BUF];
char szStrProcessingFileBuf[MAX_BUF];
char szStrCopyingFileBuf[MAX_BUF];
ParsePath((char *)msg, szFilename, sizeof(szFilename), PP_FILENAME_ONLY);
if(max == 0) if(max == 0)
{ {
UpdateFileStatus(msg); wsprintf(szStrProcessingFileBuf, szStrProcessingFile, szFilename);
SetDlgItemText(dlgInfo.hWndDlg, IDC_STATUS3, szStrProcessingFileBuf);
bBarberBar = TRUE;
UpdateGaugeFileBarber();
} }
else else
{ {
UpdateGaugeFileProgressBar((unsigned)(((double)(val+1)/(double)max)*(double)100)); if(bBarberBar == TRUE)
if((dwCurrentArchive % 2) == 0)
{ {
dlgInfo.nFileBars = 0;
++dwCurrentArchive; ++dwCurrentArchive;
UpdateGaugeArchiveProgressBar((unsigned)(((double)(dwCurrentArchive)/(double)dwTotalArchives)*(double)100)); UpdateGaugeArchiveProgressBar((unsigned)(((double)(dwCurrentArchive)/(double)dwTotalArchives)*(double)100));
bBarberBar = FALSE;
} }
wsprintf(szStrCopyingFileBuf, szStrCopyingFile, szFilename);
SetDlgItemText(dlgInfo.hWndDlg, IDC_STATUS3, szStrCopyingFileBuf);
UpdateGaugeFileProgressBar((unsigned)(((double)(val+1)/(double)max)*(double)100));
} }
ProcessWindowsMessages(); ProcessWindowsMessages();
@ -290,42 +329,57 @@ CenterWindow(HWND hWndDlg)
LRESULT CALLBACK LRESULT CALLBACK
ProgressDlgProc(HWND hWndDlg, UINT msg, WPARAM wParam, LPARAM lParam) ProgressDlgProc(HWND hWndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
char szStrFileNumber[MAX_BUF];
char szStrFilename[MAX_BUF];
switch (msg) switch (msg)
{ {
case WM_INITDIALOG: case WM_INITDIALOG:
if(NS_LoadString(hSetupRscInst, IDS_STR_FILE_NUMBER, szStrFileNumber, MAX_BUF) != WIZ_OK)
exit(1);
if(NS_LoadString(hSetupRscInst, IDS_STR_FILENAME, szStrFilename, MAX_BUF) != WIZ_OK)
exit(1);
// Center the dialog over the desktop
CenterWindow(hWndDlg); CenterWindow(hWndDlg);
SetDlgItemText(hWndDlg, IDC_STATUS0, szStrFileNumber);
SetDlgItemText(hWndDlg, IDC_STATUS3, szStrFilename);
return FALSE; return FALSE;
case WM_COMMAND: case WM_COMMAND:
// DestroyWindow(hWndDlg);
return TRUE; return TRUE;
} }
return FALSE; // didn't handle the message return FALSE; // didn't handle the message
} }
// This routine will update the File Gauge progress bar to the specified percentage
// (value between 0 and 100)
static void static void
UpdateFileStatus(const char *szFullFilename) UpdateGaugeFileBarber()
{ {
char szFileCounter[MAX_BUF]; int nBars;
char szFilename[MAX_BUF]; HWND hWndGauge = GetDlgItem(dlgInfo.hWndDlg, IDC_GAUGE_FILE);
RECT rect;
ParsePath((char *)szFullFilename, szFilename, sizeof(szFilename), PP_FILENAME_ONLY); if(dwBarberDirection == BDIR_RIGHT)
++lFileCounter; {
ltoa(lFileCounter, szFileCounter, 10); if(lBarberCounter < 151)
SetDlgItemText(dlgInfo.hWndDlg, IDC_STATUS1, szFileCounter); ++lBarberCounter;
SetDlgItemText(dlgInfo.hWndDlg, IDC_STATUS2, szFilename); else
dwBarberDirection = BDIR_LEFT;
}
else if(dwBarberDirection == BDIR_LEFT)
{
if(lBarberCounter > 0)
--lBarberCounter;
else
dwBarberDirection = BDIR_RIGHT;
}
// Figure out how many bars should be displayed
nBars = (dlgInfo.nMaxFileBars * lBarberCounter / 100);
// Update the gauge state before painting
dlgInfo.nFileBars = nBars;
// Only invalidate the part that needs updating
GetClientRect(hWndGauge, &rect);
InvalidateRect(hWndGauge, &rect, FALSE);
// Update the whole extracting dialog. We do this because we don't
// have a message loop to process WM_PAINT messages in case the
// extracting dialog was exposed
UpdateWindow(dlgInfo.hWndDlg);
} }
// This routine will update the File Gauge progress bar to the specified percentage // This routine will update the File Gauge progress bar to the specified percentage
@ -460,6 +514,54 @@ DrawProgressBar(HWND hWnd, int nBars)
EndPaint(hWnd, &ps); EndPaint(hWnd, &ps);
} }
// Draws the blue progress bar
static void
DrawBarberBar(HWND hWnd, int nBars)
{
int i;
PAINTSTRUCT ps;
HDC hDC;
RECT rect;
HBRUSH hBrush;
HBRUSH hBrushClear;
hDC = BeginPaint(hWnd, &ps);
GetClientRect(hWnd, &rect);
if(nBars <= 0)
{
/* clear the bars */
hBrushClear = CreateSolidBrush(GetSysColor(COLOR_MENU));
FillRect(hDC, &rect, hBrushClear);
}
else
{
// Draw the bars
hBrushClear = CreateSolidBrush(GetSysColor(COLOR_MENU));
hBrush = CreateSolidBrush(RGB(0, 0, 128));
rect.left = rect.top = BAR_MARGIN;
rect.bottom -= BAR_MARGIN;
rect.right = rect.left + BAR_WIDTH;
for(i = 0; i < (nBars + 1); i++)
{
RECT dest;
if(IntersectRect(&dest, &ps.rcPaint, &rect))
{
if((i >= (nBars - 15)) && (i < nBars))
FillRect(hDC, &rect, hBrush);
else
FillRect(hDC, &rect, hBrushClear);
}
OffsetRect(&rect, BAR_WIDTH + BAR_SPACING, 0);
}
}
DeleteObject(hBrush);
EndPaint(hWnd, &ps);
}
// Adjusts the width of the gauge based on the maximum number of bars // Adjusts the width of the gauge based on the maximum number of bars
static void static void
SizeToFitGauge(HWND hWnd, int nMaxBars) SizeToFitGauge(HWND hWnd, int nMaxBars)
@ -507,7 +609,11 @@ GaugeFileWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
return(FALSE); return(FALSE);
case WM_PAINT: case WM_PAINT:
DrawProgressBar(hWnd, dlgInfo.nFileBars); if(bBarberBar == TRUE)
DrawBarberBar(hWnd, dlgInfo.nFileBars);
else
DrawProgressBar(hWnd, dlgInfo.nFileBars);
return(FALSE); return(FALSE);
} }

View File

@ -28,6 +28,9 @@
#define IDS_ERROR_XPI_INSTALL 23 #define IDS_ERROR_XPI_INSTALL 23
#define IDS_ERROR_SETUP_REQUIREMENT 24 #define IDS_ERROR_SETUP_REQUIREMENT 24
#define IDS_DLG_EXTRACTING_TITLE 25 #define IDS_DLG_EXTRACTING_TITLE 25
#define IDS_STR_PROCESSINGFILE 26
#define IDS_STR_INSTALLING 27
#define IDS_STR_COPYINGFILE 28
#define IDI_ICON1 105 #define IDI_ICON1 105
#define IDI_SETUP 105 #define IDI_SETUP 105
#define IDB_BITMAP_WELCOME 108 #define IDB_BITMAP_WELCOME 108

View File

@ -52,7 +52,7 @@ END
// Dialog // Dialog
// //
DLG_WELCOME DIALOG 51, 56, 315, 205 DLG_WELCOME DIALOG DISCARDABLE 51, 56, 315, 205
STYLE WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU STYLE WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
FONT 8, "MS Sans Serif" FONT 8, "MS Sans Serif"
BEGIN BEGIN
@ -67,7 +67,7 @@ BEGIN
WS_EX_STATICEDGE WS_EX_STATICEDGE
END END
DLG_SETUP_TYPE DIALOG 51, 56, 315, 205 DLG_SETUP_TYPE DIALOG DISCARDABLE 51, 56, 315, 205
STYLE WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU STYLE WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
FONT 8, "MS Sans Serif" FONT 8, "MS Sans Serif"
BEGIN BEGIN
@ -95,7 +95,7 @@ BEGIN
LTEXT "Static",IDC_EDIT_DESTINATION,107,160,144,9 LTEXT "Static",IDC_EDIT_DESTINATION,107,160,144,9
END END
DLG_SELECT_COMPONENTS DIALOG 51, 56, 315, 205 DLG_SELECT_COMPONENTS DIALOG DISCARDABLE 51, 56, 315, 205
STYLE WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU STYLE WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
FONT 8, "MS Sans Serif" FONT 8, "MS Sans Serif"
BEGIN BEGIN
@ -123,7 +123,7 @@ BEGIN
LTEXT "Download Size",IDC_STATIC,201,32,103,8,0,WS_EX_RIGHT LTEXT "Download Size",IDC_STATIC,201,32,103,8,0,WS_EX_RIGHT
END END
DLG_WINDOWS_INTEGRATION DIALOG 51, 56, 315, 205 DLG_WINDOWS_INTEGRATION DIALOG DISCARDABLE 51, 56, 315, 205
STYLE WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU STYLE WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
FONT 8, "MS Sans Serif" FONT 8, "MS Sans Serif"
BEGIN BEGIN
@ -146,7 +146,7 @@ BEGIN
WS_EX_STATICEDGE WS_EX_STATICEDGE
END END
DLG_PROGRAM_FOLDER DIALOG 51, 56, 315, 205 DLG_PROGRAM_FOLDER DIALOG DISCARDABLE 51, 56, 315, 205
STYLE WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU STYLE WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
FONT 8, "MS Sans Serif" FONT 8, "MS Sans Serif"
BEGIN BEGIN
@ -166,7 +166,7 @@ BEGIN
WS_EX_STATICEDGE WS_EX_STATICEDGE
END END
DLG_LICENSE DIALOG 51, 56, 315, 205 DLG_LICENSE DIALOG DISCARDABLE 51, 56, 315, 205
STYLE WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU STYLE WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
FONT 8, "MS Sans Serif" FONT 8, "MS Sans Serif"
BEGIN BEGIN
@ -183,7 +183,7 @@ BEGIN
WS_EX_STATICEDGE WS_EX_STATICEDGE
END END
DLG_START_INSTALL DIALOG 51, 56, 315, 205 DLG_START_INSTALL DIALOG DISCARDABLE 51, 56, 315, 205
STYLE WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU STYLE WS_MINIMIZEBOX | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
FONT 8, "MS Sans Serif" FONT 8, "MS Sans Serif"
BEGIN BEGIN
@ -201,7 +201,7 @@ BEGIN
WS_EX_STATICEDGE WS_EX_STATICEDGE
END END
DLG_BROWSE_DIR DIALOG 147, 23, 190, 143 DLG_BROWSE_DIR DIALOG DISCARDABLE 147, 23, 190, 143
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Select a directory" CAPTION "Select a directory"
FONT 8, "MS Shell Dlg" FONT 8, "MS Shell Dlg"
@ -242,16 +242,13 @@ BEGIN
END END
DLG_EXTRACTING DIALOG DISCARDABLE 0, 0, 193, 73 DLG_EXTRACTING DIALOG DISCARDABLE 0, 0, 193, 73
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "Extracting..."
FONT 8, "MS Sans Serif" FONT 8, "MS Sans Serif"
BEGIN BEGIN
LTEXT "",IDC_STATUS1,48,10,25,8 CONTROL "",IDC_GAUGE_FILE,"GaugeFile",0x0,9,52,175,11
CONTROL "",IDC_GAUGE_FILE,"GaugeFile",0x0,9,37,175,11 LTEXT "",IDC_STATUS0,9,9,175,8
LTEXT "",IDC_STATUS2,45,22,139,8 LTEXT "",IDC_STATUS3,9,40,175,8
LTEXT "",IDC_STATUS0,9,10,35,8 CONTROL "",IDC_GAUGE_ARCHIVE,"GaugeArchive",0x0,9,21,175,11
LTEXT "",IDC_STATUS3,9,22,31,8
CONTROL "",IDC_GAUGE_ARCHIVE,"GaugeArchive",0x0,9,55,175,11
END END
@ -283,7 +280,7 @@ GUIDELINES DESIGNINFO DISCARDABLE
BEGIN BEGIN
DLG_EXTRACTING, DIALOG DLG_EXTRACTING, DIALOG
BEGIN BEGIN
BOTTOMMARGIN, 61 BOTTOMMARGIN, 72
END END
END END
#endif // APSTUDIO_INVOKED #endif // APSTUDIO_INVOKED
@ -332,7 +329,10 @@ BEGIN
IDS_ERROR_XPI_INSTALL "Error ocurred during installation" IDS_ERROR_XPI_INSTALL "Error ocurred during installation"
IDS_ERROR_SETUP_REQUIREMENT IDS_ERROR_SETUP_REQUIREMENT
"Windows95 or greater Operating System is required! Exiting setup..." "Windows95 or greater Operating System is required! Exiting setup..."
IDS_DLG_EXTRACTING_TITLE "Installing %s" IDS_DLG_EXTRACTING_TITLE "Install Progress"
IDS_STR_PROCESSINGFILE "Preparing file: %s"
IDS_STR_INSTALLING "Currently installing %s"
IDS_STR_COPYINGFILE "Copying file: %s"
END END
#endif // English (U.S.) resources #endif // English (U.S.) resources