diff --git a/xpinstall/wizard/unix/src2/installer.ini b/xpinstall/wizard/unix/src2/installer.ini index d58eb446d2c..33f04b4fac5 100644 --- a/xpinstall/wizard/unix/src2/installer.ini +++ b/xpinstall/wizard/unix/src2/installer.ini @@ -82,4 +82,7 @@ UNKNOWN=Unknown -623=Destination directory doesn't exist -624=Can't make destination directory. Please try another directory. -625=A previous installation exists. +-626=Insufficient permission +-627=Insufficient disk space +-628=Multiple CRC Failure diff --git a/xpinstall/wizard/unix/src2/nsInstallDlg.cpp b/xpinstall/wizard/unix/src2/nsInstallDlg.cpp index 16c1f29f6ce..8baf218f9e6 100644 --- a/xpinstall/wizard/unix/src2/nsInstallDlg.cpp +++ b/xpinstall/wizard/unix/src2/nsInstallDlg.cpp @@ -131,61 +131,64 @@ nsInstallDlg::Next(GtkWidget *aWidget, gpointer aData) else bDownload = TRUE; - gtk_progress_set_activity_mode(GTK_PROGRESS(sMajorProgBar), FALSE); - gtk_progress_bar_update(GTK_PROGRESS_BAR(sMajorProgBar), (gfloat) 0); - gtk_label_set_text(GTK_LABEL(sMajorLabel), ""); + if (gCtx->opt->mMode != nsXIOptions::MODE_SILENT) { + gtk_progress_set_activity_mode(GTK_PROGRESS(sMajorProgBar), FALSE); + gtk_progress_bar_update(GTK_PROGRESS_BAR(sMajorProgBar), (gfloat) 0); + gtk_label_set_text(GTK_LABEL(sMajorLabel), ""); - if (bDownload) - { - InitDLProgress( TRUE ); + if (bDownload) + { + InitDLProgress( TRUE ); - pauseLabel = gtk_label_new(gCtx->Res("PAUSE")); - resumeLabel = gtk_label_new(gCtx->Res("RESUME")); - gtk_container_remove(GTK_CONTAINER(gCtx->back), gCtx->backLabel); - gtk_container_remove(GTK_CONTAINER(gCtx->next), gCtx->installLabel); - gtk_container_add(GTK_CONTAINER(gCtx->back), pauseLabel); - gtk_container_add(GTK_CONTAINER(gCtx->next), resumeLabel); - gtk_widget_show(pauseLabel); - gtk_widget_show(resumeLabel); + pauseLabel = gtk_label_new(gCtx->Res("PAUSE")); + resumeLabel = gtk_label_new(gCtx->Res("RESUME")); + gtk_container_remove(GTK_CONTAINER(gCtx->back), gCtx->backLabel); + gtk_container_remove(GTK_CONTAINER(gCtx->next), gCtx->installLabel); + gtk_container_add(GTK_CONTAINER(gCtx->back), pauseLabel); + gtk_container_add(GTK_CONTAINER(gCtx->next), resumeLabel); + gtk_widget_show(pauseLabel); + gtk_widget_show(resumeLabel); - gtk_signal_disconnect(GTK_OBJECT(gCtx->back), gCtx->backID); - gtk_signal_disconnect(GTK_OBJECT(gCtx->next), gCtx->nextID); - gtk_signal_disconnect(GTK_OBJECT(gCtx->cancel), gCtx->cancelID); + gtk_signal_disconnect(GTK_OBJECT(gCtx->back), gCtx->backID); + gtk_signal_disconnect(GTK_OBJECT(gCtx->next), gCtx->nextID); + gtk_signal_disconnect(GTK_OBJECT(gCtx->cancel), gCtx->cancelID); - // disable resume button - gtk_widget_set_sensitive(gCtx->next, FALSE); + // disable resume button + gtk_widget_set_sensitive(gCtx->next, FALSE); + XI_GTK_UPDATE_UI(); + + // hook up buttons with callbacks + gCtx->backID = gtk_signal_connect(GTK_OBJECT(gCtx->back), "clicked", + GTK_SIGNAL_FUNC(DLPause), NULL); + gCtx->nextID = gtk_signal_connect(GTK_OBJECT(gCtx->next), "clicked", + GTK_SIGNAL_FUNC(DLResume), NULL); + gCtx->cancelID = gtk_signal_connect(GTK_OBJECT(gCtx->cancel), "clicked", + GTK_SIGNAL_FUNC(DLCancel), NULL); + } + else + { + gtk_widget_show(sMajorLabel); + gtk_widget_show(sMajorProgBar); + + gtk_widget_hide(gCtx->back); + gtk_widget_hide(gCtx->next); + gtk_widget_hide(gCtx->cancel); + } + + gtk_widget_hide(sMsg0Label); + if (bDownload && sDLTable) + gtk_widget_hide(sDLTable); XI_GTK_UPDATE_UI(); - // hook up buttons with callbacks - gCtx->backID = gtk_signal_connect(GTK_OBJECT(gCtx->back), "clicked", - GTK_SIGNAL_FUNC(DLPause), NULL); - gCtx->nextID = gtk_signal_connect(GTK_OBJECT(gCtx->next), "clicked", - GTK_SIGNAL_FUNC(DLResume), NULL); - gCtx->cancelID = gtk_signal_connect(GTK_OBJECT(gCtx->cancel), "clicked", - GTK_SIGNAL_FUNC(DLCancel), NULL); - } - else - { - gtk_widget_show(sMajorLabel); - gtk_widget_show(sMajorProgBar); - - gtk_widget_hide(gCtx->back); - gtk_widget_hide(gCtx->next); - gtk_widget_hide(gCtx->cancel); + bInstallClicked = TRUE; } - gtk_widget_hide(sMsg0Label); - if (bDownload && sDLTable) - gtk_widget_hide(sDLTable); - XI_GTK_UPDATE_UI(); - - bInstallClicked = TRUE; PerformInstall(); if (bDLCancel) // set only when download was cancelled { // mode auto has no call to gtk_main() - if (gCtx->opt->mMode != nsXIOptions::MODE_AUTO) + if (gCtx->opt->mMode == nsXIOptions::MODE_DEFAULT) gtk_main_quit(); } @@ -559,7 +562,8 @@ nsInstallDlg::PerformInstall() err = engine->Download(bCus, comps); if (err == E_DL_DROP_CXN) { - DLPause(NULL, NULL); + if (gCtx->opt->mMode != nsXIOptions::MODE_SILENT) + DLPause(NULL, NULL); ShowCxnDroppedDlg(); return err; } @@ -581,8 +585,11 @@ nsInstallDlg::PerformInstall() } // prepare install UI - InitInstallProgress(); - HideNavButtons(); + if (gCtx->opt->mMode != nsXIOptions::MODE_SILENT) + { + InitInstallProgress(); + HideNavButtons(); + } // 2> extract engine XI_ERR_BAIL(engine->Extract(xpiengine)); @@ -596,7 +603,10 @@ nsInstallDlg::PerformInstall() engine->DeleteXPIs(bCus, comps); } - ShowCompleteDlg(); + if (gCtx->opt->mMode != nsXIOptions::MODE_SILENT) + { + ShowCompleteDlg(); + } // run all specified applications after installation if (sRunAppList) @@ -615,6 +625,8 @@ BAIL: void nsInstallDlg::XPIProgressCB(const char *aMsg, int aVal, int aMax) { + if (gCtx->opt->mMode == nsXIOptions::MODE_SILENT) + return; // DUMP("XPIProgressCB"); if (!aMsg) @@ -681,7 +693,7 @@ nsInstallDlg::MajorProgressCB(char *aName, int aNum, int aTotal, int aActivity) char msg[256]; if (!aName) - return; + return; #ifdef DEBUG printf("%s %d: Name = %s\tNum = %d\tTotal = %d\tAct = %d\n", @@ -745,7 +757,7 @@ nsInstallDlg::SetDownloadComp(nsComponent *aComp, int aURLIndex, char localPath[MAXPATHLEN]; if (!aComp) - return; + return; if (!bHaveXPIDir) { @@ -1153,6 +1165,11 @@ nsInstallDlg::ShowCRCDlg() { GtkWidget *label, *okButton, *packer; + if (gCtx->opt->mMode == nsXIOptions::MODE_SILENT) { + ErrorHandler(E_CRC_FAILED); + return; + } + if ( crcDlg == (GtkWidget *) NULL ) { // throw up dialog informing user to press resume // or to cancel out @@ -1187,6 +1204,11 @@ nsInstallDlg::ShowCRCFailedDlg() // throw up dialog informing user to press resume // or to cancel out + if (gCtx->opt->mMode == nsXIOptions::MODE_SILENT) { + ErrorHandler(E_CRC_FAILED); + return OK; + } + crcFailedDlg = gtk_dialog_new(); label = gtk_label_new(gCtx->Res("CRC_FAILED")); okButton = gtk_button_new_with_label(gCtx->Res("OK_LABEL")); @@ -1220,6 +1242,11 @@ nsInstallDlg::ShowCxnDroppedDlg() // throw up dialog informing user to press resume // or to cancel out + if (gCtx->opt->mMode == nsXIOptions::MODE_SILENT) { + ErrorHandler(E_NO_DOWNLOAD); + return OK; + } + cxnDroppedDlg = gtk_dialog_new(); label = gtk_label_new(gCtx->Res("CXN_DROPPED")); okButton = gtk_button_new_with_label(gCtx->Res("OK_LABEL")); diff --git a/xpinstall/wizard/unix/src2/nsXIEngine.cpp b/xpinstall/wizard/unix/src2/nsXIEngine.cpp index 781cfedfe77..c54bea5d760 100644 --- a/xpinstall/wizard/unix/src2/nsXIEngine.cpp +++ b/xpinstall/wizard/unix/src2/nsXIEngine.cpp @@ -156,8 +156,9 @@ nsXIEngine::Download(int aCustom, nsComponentList *aComps) currURL = currComp->GetURL(i); if (!currURL) break; - nsInstallDlg::SetDownloadComp(currComp, i, - currCompNum, numToDL); + if (gCtx->opt->mMode != nsXIOptions::MODE_SILENT) + nsInstallDlg::SetDownloadComp(currComp, i, + currCompNum, numToDL); // restore resume position resPos = currComp->GetResumePos(); @@ -202,8 +203,11 @@ nsXIEngine::Download(int aCustom, nsComponentList *aComps) { sprintf(localPath, "%s/%s", XPI_DIR, currComp->GetArchive()); - err = conn->Get(nsInstallDlg::DownloadCB, localPath, - resPos); + if (gCtx->opt->mMode == nsXIOptions::MODE_SILENT) + err = conn->Get(NULL, localPath, resPos); + else + err = conn->Get(nsInstallDlg::DownloadCB, localPath, + resPos); conn->Close(); } @@ -237,8 +241,11 @@ nsXIEngine::Download(int aCustom, nsComponentList *aComps) { sprintf(localPath, "%s/%s", XPI_DIR, currComp->GetArchive()); - err = conn->Get(nsInstallDlg::DownloadCB, localPath, - resPos); + if (gCtx->opt->mMode == nsXIOptions::MODE_SILENT) + err = conn->Get(NULL, localPath, resPos); + else + err = conn->Get(nsInstallDlg::DownloadCB, localPath, + resPos); conn->Close(); } @@ -291,8 +298,12 @@ nsXIEngine::Download(int aCustom, nsComponentList *aComps) { sprintf(localPath, "%s/%s", XPI_DIR, currComp->GetArchive()); - err = conn->Get(srvPath, localPath, nsFTPConn::BINARY, - resPos, 1, nsInstallDlg::DownloadCB); + if (gCtx->opt->mMode == nsXIOptions::MODE_SILENT) + err = conn->Get(srvPath, localPath, nsFTPConn::BINARY, + resPos, 1, NULL); + else + err = conn->Get(srvPath, localPath, nsFTPConn::BINARY, + resPos, 1, nsInstallDlg::DownloadCB); passCount++; } @@ -339,7 +350,8 @@ nsXIEngine::Download(int aCustom, nsComponentList *aComps) } } - nsInstallDlg::ClearRateLabel(); // clean after ourselves + if (gCtx->opt->mMode != nsXIOptions::MODE_SILENT) + nsInstallDlg::ClearRateLabel(); // clean after ourselves if (err == OK) { @@ -368,7 +380,8 @@ nsXIEngine::Download(int aCustom, nsComponentList *aComps) currCompNum = 1; } currCompSave = currComp; - gCtx->idlg->ReInitUI(); + if (gCtx->opt->mMode != nsXIOptions::MODE_SILENT) + gCtx->idlg->ReInitUI(); gCtx->idlg->ShowCRCDlg(); numToDL = TotalToDownload(aCustom, aComps); } @@ -515,8 +528,9 @@ nsXIEngine::Install(int aCustom, nsComponentList *aComps, char *aDestination) #endif if (!currComp->IsDownloadOnly()) { - nsInstallDlg::MajorProgressCB(currComp->GetDescShort(), - compNum, mTotalComps, nsInstallDlg::ACT_INSTALL); + if (gCtx->opt->mMode != nsXIOptions::MODE_SILENT) + nsInstallDlg::MajorProgressCB(currComp->GetDescShort(), + compNum, mTotalComps, nsInstallDlg::ACT_INSTALL); err = InstallXPI(currComp, &stub); if (err != OK) if (err == E_INSTALL) @@ -1032,7 +1046,8 @@ nsXIEngine::CRCCheckDownloadedArchives(char *dlPath, short dlPathlen, buf[ dlPathlen ] = '\0'; strcat( buf, "/" ); strcat( buf, currComp->GetArchive() ); - nsInstallDlg::MajorProgressCB(buf, i, count, nsInstallDlg::ACT_INSTALL); + if (gCtx->opt->mMode != nsXIOptions::MODE_SILENT) + nsInstallDlg::MajorProgressCB(buf, i, count, nsInstallDlg::ACT_INSTALL); if (((aCustom == TRUE && currComp->IsSelected()) || (aCustom == FALSE)) && IsArchiveFile(buf) == PR_TRUE && VerifyArchive( buf ) != ZIP_OK) { diff --git a/xpinstall/wizard/unix/src2/nsXInstaller.cpp b/xpinstall/wizard/unix/src2/nsXInstaller.cpp index 880cae9bab2..a7707cab301 100644 --- a/xpinstall/wizard/unix/src2/nsXInstaller.cpp +++ b/xpinstall/wizard/unix/src2/nsXInstaller.cpp @@ -150,46 +150,42 @@ nsXInstaller::RunWizard(int argc, char **argv) XI_VERIFY(gCtx); // create the dialog window - gtk_set_locale(); - gtk_init(&argc, &argv); - gdk_rgb_init(); + if (gCtx->opt->mMode != nsXIOptions::MODE_SILENT) { + gtk_set_locale(); + gtk_init(&argc, &argv); + gdk_rgb_init(); - gCtx->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - XI_VERIFY(gCtx->window); + gCtx->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + XI_VERIFY(gCtx->window); - gtk_window_set_position(GTK_WINDOW(gCtx->window), GTK_WIN_POS_CENTER); - gtk_signal_connect(GTK_OBJECT(gCtx->window), "delete_event", - GTK_SIGNAL_FUNC(Kill), NULL); + gtk_window_set_position(GTK_WINDOW(gCtx->window), GTK_WIN_POS_CENTER); + gtk_signal_connect(GTK_OBJECT(gCtx->window), "delete_event", + GTK_SIGNAL_FUNC(Kill), NULL); - gtk_widget_set_usize(gCtx->window, XI_WIN_WIDTH, XI_WIN_HEIGHT); - gtk_container_set_border_width(GTK_CONTAINER(gCtx->window), 5); - gtk_window_set_title(GTK_WINDOW(gCtx->window), gCtx->opt->mTitle); - gtk_widget_show(gCtx->window); + gtk_widget_set_usize(gCtx->window, XI_WIN_WIDTH, XI_WIN_HEIGHT); + gtk_container_set_border_width(GTK_CONTAINER(gCtx->window), 5); + gtk_window_set_title(GTK_WINDOW(gCtx->window), gCtx->opt->mTitle); + gtk_widget_show(gCtx->window); - // create and display the logo and cancel button - logovbox = DrawLogo(); - if (logovbox) - DrawCancelButton(logovbox); + // create and display the logo and cancel button + logovbox = DrawLogo(); + if (logovbox) + DrawCancelButton(logovbox); - // create and display the nav buttons - XI_ERR_BAIL(DrawNavButtons()); + // create and display the nav buttons + XI_ERR_BAIL(DrawNavButtons()); - // create the notebook whose pages are dlgs - gCtx->notebook = gtk_notebook_new(); - XI_VERIFY(gCtx->notebook); - gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gCtx->notebook), FALSE); - gtk_notebook_set_show_border(GTK_NOTEBOOK(gCtx->notebook), FALSE); - gtk_notebook_set_scrollable(GTK_NOTEBOOK(gCtx->notebook), FALSE); - gtk_widget_show(gCtx->notebook); - gtk_container_add(GTK_CONTAINER(gCtx->canvas), gCtx->notebook); - - if (gCtx->opt->mMode == nsXIOptions::MODE_AUTO) - { - // show install dlg - gCtx->idlg->Show(nsXInstallerDlg::FORWARD_MOVE); - gCtx->idlg->Next((GtkWidget *)NULL, (gpointer) gCtx->idlg); + // create the notebook whose pages are dlgs + gCtx->notebook = gtk_notebook_new(); + XI_VERIFY(gCtx->notebook); + gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gCtx->notebook), FALSE); + gtk_notebook_set_show_border(GTK_NOTEBOOK(gCtx->notebook), FALSE); + gtk_notebook_set_scrollable(GTK_NOTEBOOK(gCtx->notebook), FALSE); + gtk_widget_show(gCtx->notebook); + gtk_container_add(GTK_CONTAINER(gCtx->canvas), gCtx->notebook); } - else + + if (gCtx->opt->mMode == nsXIOptions::MODE_DEFAULT) { // show welcome dlg gCtx->wdlg->Show(nsXInstallerDlg::FORWARD_MOVE); @@ -198,6 +194,13 @@ nsXInstaller::RunWizard(int argc, char **argv) gtk_main(); } + else + { + // show install dlg + if (gCtx->opt->mMode == nsXIOptions::MODE_AUTO) + gCtx->idlg->Show(nsXInstallerDlg::FORWARD_MOVE); + gCtx->idlg->Next((GtkWidget *)NULL, (gpointer) gCtx->idlg); + } return OK; @@ -407,6 +410,11 @@ ErrorHandler(int aErr, const char* aErrMsg) else sprintf(msg, gCtx->Res("FATAL_ERROR"), aErr, gCtx->Res(errStr)); + if (gCtx->opt->mMode == nsXIOptions::MODE_SILENT) + { + fprintf (stderr, "%s\n", msg); + return aErr; + } sErrDlg = gtk_dialog_new(); gtk_window_set_title(GTK_WINDOW(sErrDlg), gCtx->Res("ERROR_TITLE")); okButton = gtk_button_new_with_label(gCtx->Res("OK_LABEL")); diff --git a/xpinstall/wizard/unix/src2/nsZipExtractor.cpp b/xpinstall/wizard/unix/src2/nsZipExtractor.cpp index 363d48511a8..689e36be5da 100644 --- a/xpinstall/wizard/unix/src2/nsZipExtractor.cpp +++ b/xpinstall/wizard/unix/src2/nsZipExtractor.cpp @@ -110,8 +110,9 @@ nsZipExtractor::Extract(nsComponent *aXPIEngine, int aTotal) /* update UI */ - nsInstallDlg::MajorProgressCB(leaf, i, - aTotal, nsInstallDlg::ACT_EXTRACT); + if (gCtx->opt->mMode != nsXIOptions::MODE_SILENT) + nsInstallDlg::MajorProgressCB(leaf, i, + aTotal, nsInstallDlg::ACT_EXTRACT); sprintf(epath, "%s/%s", mDest, zpath); err = DirCreateRecursive(epath);