diff options
Diffstat (limited to 'abs/core/mythinstall/MythVantage-app/mythinstall/installdialog.cpp')
-rwxr-xr-x | abs/core/mythinstall/MythVantage-app/mythinstall/installdialog.cpp | 346 |
1 files changed, 154 insertions, 192 deletions
diff --git a/abs/core/mythinstall/MythVantage-app/mythinstall/installdialog.cpp b/abs/core/mythinstall/MythVantage-app/mythinstall/installdialog.cpp index 6f4252f..980fa17 100755 --- a/abs/core/mythinstall/MythVantage-app/mythinstall/installdialog.cpp +++ b/abs/core/mythinstall/MythVantage-app/mythinstall/installdialog.cpp @@ -4,15 +4,16 @@ #include <fstream> #include "mythcontext.h" -//#include "tv.h" -//#include "uitypes.h" #include "installdialog.h" #include "installsettings.h" #include "installationtype.h" #include "mv_common.h" +#include "questionnotice.h" #include "mythprogressdialog.h" #include <stdlib.h> +#include <chrono> // for milliseconds +#include <thread> // for sleep_for #include "mythversion.h" #include "mythsystemlegacy.h" @@ -23,10 +24,9 @@ WelcomeDialog::WelcomeDialog(MythScreenStack *parent, const char *name) - :MythScreenType(parent, name), - m_status_text(NULL), m_recording_text(NULL), m_scheduled_text(NULL), - m_time_text(NULL), m_date_text(NULL), - m_menuPopup(NULL), m_mv_text(NULL) + :MythScreenType(parent, name), m_menuPopup(NULL), + m_status_text(NULL),m_recording_text(NULL), m_scheduled_text(NULL), + m_mv_text(NULL), m_time_text(NULL), m_date_text(NULL) { // system("rm -f /tmp/.install_state"); @@ -37,7 +37,6 @@ WelcomeDialog::WelcomeDialog(MythScreenStack *parent, const char *name) scheduled_text = ""; install_text = ""; version_text = ""; - I_AM_BUSY = false; WORKING_ON_INSTALL = false; current_hostname = ""; @@ -58,13 +57,9 @@ WelcomeDialog::WelcomeDialog(MythScreenStack *parent, const char *name) SLOT(updateTime())); m_timeTimer->start(1000); - reboot_box = NULL; m_menuPopup = NULL; - //QTimer::singleShot(6000, this, showPopup()); - // JM QTimer::singleShot(1000, this, SLOT(showPopup())); - } bool WelcomeDialog::Create(void) @@ -104,9 +99,15 @@ void WelcomeDialog::shutdownNow(int rc) // system("rm -f /tmp/.install_percent"); // system("rm -f /tmp/.install_error"); if (rc == 1) - system("/sbin/halt"); + { + if(!system("/sbin/halt")) + LOG(VB_GENERAL, LOG_ERR, "Error running halt"); + } else - system("/sbin/reboot"); + { + if(!system("/sbin/reboot")) + LOG(VB_GENERAL, LOG_ERR, "Error running reboot"); + } } void WelcomeDialog::runLIVECD(void) @@ -124,8 +125,6 @@ void WelcomeDialog::runLIVECD(void) { showPopup(); } - - } bool WelcomeDialog::keyPressEvent(QKeyEvent *event) @@ -159,7 +158,7 @@ bool WelcomeDialog::keyPressEvent(QKeyEvent *event) // QByteArray tmp = cmd.toAscii(); // QByteArray tmp = cmd; // system(tmp); - system(qPrintable(cmd)); + myth_system(qPrintable(cmd)); } } else @@ -174,7 +173,6 @@ bool WelcomeDialog::keyPressEvent(QKeyEvent *event) void WelcomeDialog::closeDialog() { Close(); - exit(0); } @@ -229,7 +227,9 @@ void WelcomeDialog::updateScreen(void) QString cmdtxt; cmdtxt=MV_ROOT ; cmdtxt.append("bin/install_proxy.sh " ); - system(qPrintable(cmdtxt)); + int sysRet = system(qPrintable(cmdtxt)); + if (sysRet < 0) + LOG(VB_GENERAL, LOG_ERR, "Error running install_proxy.sh in updateScreen"); recording_text="Press MENU for Options"; mythvantage_text=" "; error_text=" "; @@ -276,6 +276,7 @@ void WelcomeDialog::updateScreen(void) } else mythvantage_text=""; + m_recording_text->SetText(recording_text); m_scheduled_text->SetText(scheduled_text); m_mv_text->SetText(mythvantage_text); @@ -283,88 +284,40 @@ void WelcomeDialog::updateScreen(void) if ( install_drive != "" ) install_text = ""; - m_status_text->SetText(install_text ); + m_status_text->SetText(install_text); // m_updateScreenTimer->start(UPDATE_SCREEN_INTERVAL, true); m_updateScreenTimer->start(UPDATE_SCREEN_INTERVAL); if ( scheduled_text == "Done" ) { - Reboot_popup () ; + CloseBusyPopup(); + m_updateScreenTimer->stop(); + Reboot_popup(); } // shows the busy box when configuring the system if ( scheduled_text == "Configuring system") { m_recording_text->SetText(" "); - if ( ! I_AM_BUSY ) - busy_box(); + QString msgtext = "Configuring LinHES on host " ; + msgtext.append(current_hostname); + msgtext.append("..."); + OpenBusyPopup(msgtext); } }; -void WelcomeDialog::busy_box(void) -{ - QString msgtext = "Please wait, configuring LinHES on host " ; - msgtext.append(current_hostname); - msgtext.append("..."); - MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack"); - MythUIBusyDialog *busyPopup = new MythUIBusyDialog(msgtext, popupStack,"installbusy"); - if (busyPopup->Create()) - { - popupStack->AddScreen(busyPopup, false); - } - else - { - delete busyPopup; - busyPopup = NULL; - } - - - while ( scheduled_text == "Configuring system" ) - { - qApp->processEvents (); - usleep(900); - I_AM_BUSY = true; - } - - if (busyPopup) - { - busyPopup->Close(); - busyPopup = NULL; - } - I_AM_BUSY = false; -} - void WelcomeDialog::busy_find_oldsettings(void) { - - QString msgtext = "Importing Old Settings..." ; - MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack"); - MythUIBusyDialog *busyPopup = new MythUIBusyDialog(msgtext, popupStack, - "importsettingsbusy"); - if (busyPopup->Create()) - { - popupStack->AddScreen(busyPopup, false); - } - else - { - delete busyPopup; - busyPopup = NULL; - } + QString msgtext = "Importing Old Settings..." ; + OpenBusyPopup(msgtext); int return_code = 0; - while ( return_code == 0 ) + while ( return_code == 0 ) { qApp->processEvents (); - usleep(900); - I_AM_BUSY = true; + std::this_thread::sleep_for(std::chrono::microseconds(900)); return_code = myth_system("ps -ef|grep install_proxy.sh|grep -v grep > /dev/null"); } - if (busyPopup) - { - busyPopup->Close(); - busyPopup = NULL; - } - I_AM_BUSY = false; - + CloseBusyPopup(); } @@ -389,19 +342,6 @@ void WelcomeDialog::updateStatusMessage(void) void WelcomeDialog::showPopup(void) { - -// if (m_menuPopup) - // return; -// -// QString label = tr("MythVantage Menu"); -// MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); -// m_menuPopup = new MythDialogBox(label, mainStack, "menuPopup"); -// -// if (m_menuPopup->Create()) -// mainStack->AddScreen(m_menuPopup); -// -// m_menuPopup->SetReturnEvent(this, "action"); - MythScreenStack *popupStack = GetMythMainWindow()->GetMainStack(); m_menuPopup = new MythDialogBox("Menu", popupStack, "actionmenu"); @@ -418,7 +358,7 @@ void WelcomeDialog::showPopup(void) // This is a bad way to lock the buttons but it works for now. if ( scheduled_text.length() <= 2 ) { - m_menuPopup->AddButton(tr("Install or Upgrade "), + m_menuPopup->AddButton(tr("Install or Upgrade"), SLOT(Display_2ndpopup())); m_menuPopup->AddButton(tr("Run MythFrontend"), SLOT(runLIVECD())); @@ -513,7 +453,7 @@ QString WelcomeDialog::diskmodel(QString drive , QString tsize) return qline; } -QString WelcomeDialog::findinstallsouce(void) +QString WelcomeDialog::findinstallsource(void) { string line; QString currentitem; @@ -522,7 +462,7 @@ QString WelcomeDialog::findinstallsouce(void) { getline (mountfile,line); if ( line.empty() ) - line = "oops didn't find andthing"; + line = "oops didn't find anything"; currentitem= ( QString::fromStdString( line ) ); @@ -540,6 +480,7 @@ QString WelcomeDialog::findinstallsouce(void) return currentitem; }; } + return NULL; }; void WelcomeDialog::showPopup_2(void) @@ -564,7 +505,7 @@ void WelcomeDialog::showPopup_2(void) if ( NETBOOT == "YES" ) m_menuPopup->AddButton(("Diskless Frontend"), SLOT(install_net() ) ); - QString INSTALLSOURCE = findinstallsouce(); + QString INSTALLSOURCE = findinstallsource(); ifstream partitions("/proc/partitions"); if (partitions.is_open()) { @@ -631,38 +572,46 @@ void WelcomeDialog::GO_popup(QString go_text) void WelcomeDialog::Reboot_popup(void) -{ if (reboot_box) - return; +{ QString prompt1; QFile updbstatus("/tmp/.upgrade_db_failed"); if ( updbstatus.open(QIODevice::ReadOnly | QIODevice::Text) ) { - prompt1 = QObject::tr(" "); - prompt1.append("\n"); - prompt1.append("An error occured while attempting to restore the database!"); - prompt1.append("\n"); - prompt1.append("The old database could not be restored, so a new database was created"); + prompt1 = QObject::tr("An error occured while attempting to restore the database."); prompt1.append("\n"); + prompt1.append("The old database could not be restored, so a new database was created."); } else prompt1 = QObject::tr("Installation of LinHES is complete!"); - prompt1.append("\n"); - reboot_box = new DialogBox(GetMythMainWindow(), prompt1); - reboot_box->AddButton(QObject::tr("Reboot")); - reboot_box->AddButton(QObject::tr("Power Off")); + //as extern to be set in questionnotice.cpp + extern int questionReturnCode; + + MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); + QuestionNoticeDialog *questionNotice = + new QuestionNoticeDialog(mainStack, "Question"); + if (questionNotice->Create("question", "Installation Complete", prompt1, + "Reboot", "Shutdown")) mainStack->AddScreen(questionNotice, true); + else + return; - int returncode = 0; - DialogCode dcode = reboot_box->exec(); - reboot_box->deleteLater(); - if (kDialogCodeButton0 == dcode ) + do + { + qApp->processEvents(); + std::this_thread::sleep_for(std::chrono::milliseconds(5)); + } while (mainStack->TotalScreens() > 1); + + int returncode; + if (questionReturnCode == 16) + { + LOG(VB_GENERAL, LOG_INFO, "Reboot"); returncode = 0; - if (kDialogCodeButton1 == dcode ) + } + else + { + LOG(VB_GENERAL, LOG_INFO, "Shutdown"); returncode = 1; - if (kDialogCodeButton2 == dcode ) - returncode = 2; - - reboot_box = NULL; + } shutdownNow(returncode); } @@ -670,18 +619,11 @@ void WelcomeDialog::Reboot_popup(void) void WelcomeDialog::MAINPopup(void) { -// if (!popup) -// return; -// popup->hide(); -// popup->deleteLater(); - popup = NULL; showPopup(); - } void WelcomeDialog::Display_2ndpopup(void) { - //JM VERBOSE(VB_GENERAL, "Display_2ndpopup"); showPopup_2(); } @@ -867,7 +809,9 @@ void WelcomeDialog::install_generic(void) QString cmdtxt; cmdtxt=MV_ROOT ; cmdtxt.append("bin/install_proxy.sh find_update " + install_drive +" &"); - system(qPrintable(cmdtxt)); + int sysRet = system(qPrintable(cmdtxt)); + if (sysRet < 0) + LOG(VB_GENERAL, LOG_ERR, "Could not run install_proxy.sh find update"); busy_find_oldsettings(); bool flag = false; QString line; @@ -952,7 +896,7 @@ void WelcomeDialog::install_generic(void) void busy_network(void) { - QString msgtext = "Starting Network" ; + QString msgtext = "Starting Network..." ; MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack"); MythUIBusyDialog *busyPopup = new MythUIBusyDialog(msgtext, popupStack,"installbusy"); if (busyPopup->Create()) @@ -966,10 +910,10 @@ void busy_network(void) } int return_code = 0; - while ( return_code == 0 ) + while ( return_code == 0 ) { qApp->processEvents (); - usleep(900); + std::this_thread::sleep_for(std::chrono::microseconds(900)); return_code = myth_system("ps -ef|grep install_proxy.sh| grep setup_network |grep -v grep > /dev/null"); } @@ -978,9 +922,6 @@ void busy_network(void) busyPopup->Close(); busyPopup = NULL; } - - - } @@ -997,30 +938,64 @@ int WelcomeDialog::ask_validate_network(void) { MythProgressDialog *network_check = NULL; network_check = new MythProgressDialog(QObject::tr("Please wait while the network is checked..."), 7); + //busy_network(); + QString msgtext = "Starting Network..." ; + MythScreenStack *popupStack = GetMythMainWindow()->GetStack( + "popup stack"); + m_progressDialog = new MythUIProgressDialog(msgtext, popupStack, + "networkbusy"); + if (m_progressDialog->Create()) + { + popupStack->AddScreen(m_progressDialog, false); + } + else + { + delete m_progressDialog; + m_progressDialog = NULL; + } + + if (m_progressDialog) + m_progressDialog->SetTotal(6); + QString cmdtxt; - cmdtxt=MV_ROOT ; - cmdtxt.append("bin/install_proxy.sh network_check_it setup_network &"); - retval = system(qPrintable(cmdtxt)); - busy_network(); + cmdtxt=MV_ROOT; + cmdtxt.append("bin/install_proxy.sh network_check_it setup_network"); + retval = system(qPrintable(cmdtxt)); + + //int return_code = 0; + //while ( return_code == 0 ) + //{ + // qApp->processEvents (); + // std::this_thread::sleep_for(std::chrono::microseconds(900)); + // return_code = myth_system("ps -ef|grep install_proxy.sh| grep setup_network |grep -v grep > /dev/null"); + //} + + if (network_check) { network_check->setProgress(2); - cmdtxt=MV_ROOT ; + if ( retval == 0) + { + m_progressDialog->SetMessage("Checking Network for this Computer..."); + m_progressDialog->SetProgress(2); + cmdtxt=MV_ROOT; cmdtxt.append("bin/install_proxy.sh network_check_it check_self"); - retval = system(qPrintable(cmdtxt)); - if ( retval != 0 ) - { - network_check->Close(); - pop_text="Could not find myself on the network."; - } + retval = system(qPrintable(cmdtxt)); + if ( retval != 0 ) + { + network_check->Close(); + pop_text="Could not find myself on the network."; + } + } } - if ( retval == 0) { network_check->setProgress(3); - cmdtxt=MV_ROOT ; + m_progressDialog->SetMessage("Checking Network for the Gateway Server..."); + m_progressDialog->SetProgress(3); + cmdtxt=MV_ROOT; cmdtxt.append("bin/install_proxy.sh network_check_it check_gw"); - retval = system(qPrintable(cmdtxt)); + retval = system(qPrintable(cmdtxt)); if ( retval != 0 ) { network_check->Close(); @@ -1031,9 +1006,11 @@ int WelcomeDialog::ask_validate_network(void) if (retval == 0) { network_check->setProgress(4); - cmdtxt=MV_ROOT ; + m_progressDialog->SetMessage("Checking Network for the Nameserver..."); + m_progressDialog->SetProgress(4); + cmdtxt=MV_ROOT; cmdtxt.append("bin/install_proxy.sh network_check_it check_ns"); - retval = system(qPrintable(cmdtxt)); + retval = system(qPrintable(cmdtxt)); if ( retval != 0 ) { network_check->Close(); @@ -1044,9 +1021,11 @@ int WelcomeDialog::ask_validate_network(void) if (retval == 0) { network_check->setProgress(5); - cmdtxt=MV_ROOT ; + m_progressDialog->SetMessage("Checking the Nameserver..."); + m_progressDialog->SetProgress(5); + cmdtxt=MV_ROOT; cmdtxt.append("bin/install_proxy.sh network_check_it check_names"); - retval = system(qPrintable(cmdtxt)); + retval = system(qPrintable(cmdtxt)); if ( retval != 0 ) { network_check->Close(); @@ -1057,9 +1036,11 @@ int WelcomeDialog::ask_validate_network(void) if (retval == 0) { network_check->setProgress(6); - cmdtxt=MV_ROOT ; + m_progressDialog->SetMessage("Checking Network for this Hostname..."); + m_progressDialog->SetProgress(6); + cmdtxt=MV_ROOT; cmdtxt.append("bin/install_proxy.sh network_check_it host_names"); - retval = system(qPrintable(cmdtxt)); + retval = system(qPrintable(cmdtxt)); if ( retval != 0 ) { network_check->Close(); @@ -1067,6 +1048,11 @@ int WelcomeDialog::ask_validate_network(void) } } + if (m_progressDialog) + { + m_progressDialog->Close(); + m_progressDialog = NULL; + } network_check->setProgress(7); if (network_check) { @@ -1074,7 +1060,7 @@ int WelcomeDialog::ask_validate_network(void) network_check->deleteLater(); } - if (retval != 0 ) + if ( retval != 0 ) { DialogCode val = MythPopupBox::Show2ButtonPopup( GetMythMainWindow(), @@ -1082,7 +1068,7 @@ int WelcomeDialog::ask_validate_network(void) tr("Continue"), tr("Try Again"), kDialogCodeButton0); - if (kDialogCodeButton0 == val ) + if ( kDialogCodeButton0 == val ) retval = 0; } } @@ -1093,37 +1079,14 @@ int WelcomeDialog::ask_validate_network(void) void WelcomeDialog::install_it(void) { + int sysRet; QString installtype = gCoreContext->GetSetting("HOSTinstallationtype"); -// QString rootfs = gCoreContext->GetSetting("HOSTrootfstype"); -// QString datafs = gCoreContext->GetSetting("HOSTdatafstype"); -// QString rootsize = gCoreContext->GetSetting("HOSTOSsize"); -// rootsize=rootsize + "000"; -// QString usealldata = gCoreContext->GetSetting("HostUseALLdata"); -// QString datasize = gCoreContext->GetSetting("HOSTDATAsize"); -// QString uprootfs = gCoreContext->GetSetting("HOSTuprootfstype"); -// QString useswap = gCoreContext->GetSetting("HostUseSWAP"); -// QString swapsize = gCoreContext->GetSetting("HOSTSWAPsize"); if ( installtype != "Upgrade" ) current_hostname = gCoreContext->GetSetting("HostMyhostname"); QString clean_upgrade = getenv("CLEAN_UPGRADE"); if ( clean_upgrade == "YES" ) current_hostname = gCoreContext->GetSetting("HostMyhostname"); -//get the hostname here if upgrade then use previous declarion of hostname -// if ( usealldata == "1" ) -// { -// datasize="ALL"; -// } -// else -// { -// datasize=datasize + "000"; -// } -// if ( useswap == "0" ) -// { -// swapsize="NO"; -// }; - - if ( installtype == "Full/Auto" ) { QString currentitem; @@ -1140,28 +1103,22 @@ void WelcomeDialog::install_it(void) } } file.close(); -// bool ok; -// int mem = currentitem.toInt( &ok, 10 ); // dec == 0, ok == FALSE - - -// if ( mem >= 500000 ) -// { -// if ((gCoreContext->GetSetting("HostXres")) == "1280x720" ) -// gCoreContext->SaveSetting("Theme", "syth-lacquer-wide"); -// } - QString cmdtxt=MV_ROOT ; //cmdtxt.append("bin/install_proxy.sh full_install_it " + install_drive + " " + rootfs + " " + rootsize + " " + datafs + " " + datasize + " " + swapsize + "&"); cmdtxt.append("bin/install_proxy.sh full_install_it &"); - system(qPrintable(cmdtxt)); + sysRet = system(qPrintable(cmdtxt)); + if (sysRet < 0) + LOG(VB_GENERAL, LOG_ERR, "Error running install_proxy.sh full_install_it"); } else if ( installtype == "Upgrade" ) { QString cmdtxt=MV_ROOT ; //cmdtxt.append("bin/install_proxy.sh upgrade_it " + install_drive + " " + uprootfs + "&"); cmdtxt.append("bin/install_proxy.sh upgrade_it &"); - system(qPrintable(cmdtxt)); + sysRet = system(qPrintable(cmdtxt)); + if (sysRet < 0) + LOG(VB_GENERAL, LOG_ERR, "Error running install_proxy.sh upgrade_it"); } else if (installtype=="NET") { @@ -1178,16 +1135,21 @@ void WelcomeDialog::install_it(void) QString h; h=localhostname; cmdtxt.append("bin/restore_default_settings.sh -c save -t syssettings -d 127.0.0.1 -h " + h); - system(qPrintable(cmdtxt)); + sysRet = system(qPrintable(cmdtxt)); + if (sysRet < 0) + LOG(VB_GENERAL, LOG_ERR, "Error running restore_default_settings.sh"); + cmdtxt=MV_ROOT ; //cmdtxt.append("bin/install_proxy.sh NETBOOT " + install_drive + " &"); cmdtxt.append("bin/install_proxy.sh NETBOOT &"); - system(qPrintable(cmdtxt)); + sysRet = system(qPrintable(cmdtxt)); + if (sysRet < 0) + LOG(VB_GENERAL, LOG_ERR, "Error running install_proxy.sh NETBOOT"); } WORKING_ON_INSTALL = true; - usleep (500); + std::this_thread::sleep_for(std::chrono::microseconds(500)); updateScreen(); - usleep (500); + std::this_thread::sleep_for(std::chrono::microseconds(500)); updateScreen(); } |