summaryrefslogtreecommitdiffstats
path: root/abs/core/mythinstall/MythVantage-app/mythinstall/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'abs/core/mythinstall/MythVantage-app/mythinstall/main.cpp')
-rwxr-xr-xabs/core/mythinstall/MythVantage-app/mythinstall/main.cpp222
1 files changed, 92 insertions, 130 deletions
diff --git a/abs/core/mythinstall/MythVantage-app/mythinstall/main.cpp b/abs/core/mythinstall/MythVantage-app/mythinstall/main.cpp
index b6e66cd..51cce48 100755
--- a/abs/core/mythinstall/MythVantage-app/mythinstall/main.cpp
+++ b/abs/core/mythinstall/MythVantage-app/mythinstall/main.cpp
@@ -5,9 +5,7 @@
#include "password_manage.h"
#include "autocard.h"
#include "settemplate.h"
-
-
-
+#include "questionnotice.h"
// Qt
#include <QApplication>
@@ -15,15 +13,12 @@
#include <QDir>
#include <QTextStream>
-
#include <cstdlib>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
-#include <unistd.h>
-
-
-
+#include <chrono> // for milliseconds
+#include <thread> // for sleep_for
#include <stdio.h>
@@ -39,13 +34,12 @@
#include "commandlineparser.h"
#include "mythlogging.h"
#include "dialogbox.h"
-
+#include "signalhandling.h"
// libmythui
#include "mythmainwindow.h"
#include "mythuihelper.h"
-
//??
#include "myththemebase.h"
@@ -254,9 +248,8 @@ int main(int argc, char **argv)
bShowHelp = true;
if (cmdline.toBool("readme"))
- {
bShowReadme = true;
- }
+
if (cmdline.toBool("question"))
{
bShowquestion = true;
@@ -267,11 +260,11 @@ int main(int argc, char **argv)
bRunSetup = true;
if (cmdline.toBool("show_lang"))
- showLang = true;
+ showLang = true;
LCD::SetupLCD();
if (class LCD *lcd = LCD::Get())
- lcd->switchToTime();
+ lcd->switchToTime();
MythTranslation::load("mythfrontend");
@@ -300,14 +293,16 @@ int main(int argc, char **argv)
gCoreContext->ActivateSettingsCache(false);
gCoreContext->ClearSettingsCache();
bool runconfig = false;
- system("cp -f /etc/systemconfig /tmp/systemconfig.bak");
+ if (!system("cp -f /etc/systemconfig /tmp/systemconfig.bak"))
+ LOG(VB_GENERAL, LOG_ERR, "Could not backup /etc/systemconfig.");
QString olddb = gCoreContext->GetSetting("HostMysqlserver");
QString oldhostype = gCoreContext->GetSetting("HostSystemType");
//sync db with pacman
if (bShowplugins || bShowsoftware)
{
- system("pacman -Q > /tmp/pacman_installed");
+ if (!system("pacman -Q > /tmp/pacman_installed"))
+ LOG(VB_GENERAL, LOG_ERR, "Could not create /tmp/pacman_installed.");
QString progPacmanNamesArray[] = { "mythappletrailers",
"mytharchive",
"mythbrowser",
@@ -370,7 +365,7 @@ int main(int argc, char **argv)
QByteArray PacName = progPacmanNamesArray[i].toLocal8Bit();
const char *PacNameChar = PacName.data();
sprintf(cmd, "grep -q '%s ' /tmp/pacman_installed", PacNameChar);
-
+
//LOG(VB_GENERAL, LOG_INFO, QString(progPacmanNamesArray[i]));
//LOG(VB_GENERAL, LOG_INFO, QString(progDBNamesArray[i]));
QString currDBValue = gCoreContext->GetSetting(progDBNamesArray[i]);
@@ -389,7 +384,8 @@ int main(int argc, char **argv)
runconfig = true;
}
}
- system("rm -f /tmp/pacman_installed");
+ if (!system("rm -f /tmp/pacman_installed"))
+ LOG(VB_GENERAL, LOG_ERR, "Could not remove /tmp/pacman_installed.");
}
//DONE sync db with pacman
@@ -401,7 +397,8 @@ int main(int argc, char **argv)
//save my settings in case db switches
QString cmdtxt=MV_ROOT;
cmdtxt.append("bin/myth_settings_wrapper.sh -c save -t syssettings -d " + olddb);
- system(qPrintable(cmdtxt));
+ if (!system(qPrintable(cmdtxt)))
+ LOG(VB_GENERAL, LOG_ERR, "Could not save settings");
if ( status != 0 )
{
@@ -416,7 +413,8 @@ int main(int argc, char **argv)
QString cmdtxt;
cmdtxt=MV_ROOT;
cmdtxt.append("bin/myth_settings_wrapper.sh -c save -t syssettings -d " + olddb ) ;
- system(qPrintable(cmdtxt));
+ if (!system(qPrintable(cmdtxt)))
+ LOG(VB_GENERAL, LOG_ERR, "Could not save settings");
}
if ( runconfig )
@@ -437,7 +435,9 @@ int main(int argc, char **argv)
}
- system("rm -f /tmp/systemconfig.bak");
+ if (!system("rm -f /tmp/systemconfig.bak"))
+ LOG(VB_GENERAL, LOG_ERR, "Could not remove /tmp/systemconfig.bak.");
+
gCoreContext->ActivateSettingsCache(false);
gCoreContext->ClearSettingsCache();
if ( restart )
@@ -450,14 +450,16 @@ int main(int argc, char **argv)
problems->append("\n");
dia = new DialogBox(mainWindow, problems->append("\n" ));
dia->AddButton(QObject::tr("OK"));
- int returncode = 0;
- returncode = dia->exec();
+ //int returncode = 0;
+ //returncode = dia->exec();
+ dia->exec();
dia->deleteLater();
//cout << "restarting" << endl;
QString cmdtxt;
cmdtxt=MV_ROOT ;
cmdtxt.append("bin/systemconfig.sh reloadfe" );
- system(qPrintable(cmdtxt));
+ if (!system(qPrintable(cmdtxt)))
+ LOG(VB_GENERAL, LOG_ERR, "Could not reload frontend.");
}
gCoreContext->ActivateSettingsCache(false);
gCoreContext->ClearSettingsCache();
@@ -530,66 +532,42 @@ int main(int argc, char **argv)
else if (bShowHelp)
{
- DialogBox *dia = NULL;
- QString prompt;
- QString *problems = new QString("LinHES Help");
- problems->append("\n");
- problems->append("Visit http://linhes.org for additional help.");
- problems->append("\n");
- problems->append("\n");
- problems->append("------Keyboard Shortcuts---------------------------------");
- problems->append("\n");
- problems->append("Alt + h: This Screen");
- problems->append("\n");
-#ifdef __MVAPP__
- problems->append("F2: Open/Close Terminal");
- problems->append("\n");
- problems->append("Shift + Return: Open New Terminal (xterm)");
- problems->append("\n");
- problems->append("Alt + F2: Show 2nd desktop Alt + F1 To Go Back");
- problems->append("\n");
- problems->append("Alt + c: Capture Myth Screenshot");
- problems->append("\n");
-#else
- problems->append("Alt + x: Open New Terminal (xterm)");
- problems->append("\n");
- problems->append("Alt + m: Open mythfrontend");
- problems->append("\n");
- problems->append("m in mythfrontend: Display Power/About Menu");
- problems->append("\n");
-#endif
- problems->append("Alt + 1: Start Master mythbackend");
- problems->append("\n");
- problems->append("Alt + 2: Stop Master mythbackend");
- problems->append("\n");
- problems->append("Alt + 3: Restart Master mythbackend");
- problems->append("\n");
- problems->append("Alt + s: Open mythtv-setup");
- problems->append("\n");
- problems->append("Alt + u: Unhide/Hide Mouse Pointer");
- problems->append("\n");
- problems->append("Alt + w: Open Web Browser (Chrome if installed)");
- problems->append("\n");
- problems->append("Alt + f: Restart Window Manager");
- problems->append("\n");
+ QString line;
+ QString LH_HelpText;
+ QFile file("/usr/MythVantage/LH_HELP");
+ if ( file.open(QIODevice::ReadOnly | QIODevice::Text) )
+ {
+ QTextStream t( &file ); // use a text stream
+ while ( !t.atEnd() )
+ {
+ line = t.readLine();
+ LH_HelpText.append(line);
+ LH_HelpText.append("\n");
+ }
+ file.close();
+ }
+ else
+ LH_HelpText.append("Couldn't open /usr/MythVantage/LH_HELP");
+ MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack();
+ QuestionNoticeDialog *questionNotice = new QuestionNoticeDialog(mainStack,
+ "Notice");
+ if (questionNotice->Create("notice", "LinHES Help", LH_HelpText))
+ mainStack->AddScreen(questionNotice, true);
+ else
+ return -1;
+
+ do
+ {
+ qApp->processEvents();
+ std::this_thread::sleep_for(std::chrono::milliseconds(5));
+ } while (mainStack->TotalScreens() > 0);
- dia = new DialogBox(mainWindow, problems->append("\n" ));
- dia->AddButton(QObject::tr("OK"));
- int returncode = 0;
- returncode = dia->exec();
- dia->deleteLater();
- DestroyMythMainWindow();
- delete gContext;
- return returncode;
}
else if (bShowReadme)
{
- DialogBox *dia = NULL;
- QString prompt;
QString line;
- QString *problems = new QString("");
- problems->append("\n");
+ QString readmeText;
QFile file("/usr/MythVantage/README");
if ( file.open(QIODevice::ReadOnly | QIODevice::Text) )
{
@@ -597,88 +575,72 @@ int main(int argc, char **argv)
while ( !t.atEnd() )
{
line = t.readLine();
- problems->append(line);
- problems->append("\n");
+ readmeText.append(line);
+ readmeText.append("\n");
}
file.close();
}
else
- problems->append("Couldn't open file");
- dia = new DialogBox(mainWindow, problems->append("\n" ));
- dia->AddButton(QObject::tr("OK"));
- int returncode = 0;
- returncode = dia->exec();
- dia->deleteLater();
- DestroyMythMainWindow();
- delete gContext;
- return returncode;
- }
+ readmeText.append("Couldn't open /usr/MythVantage/README");
+ MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack();
+ QuestionNoticeDialog *questionNotice = new QuestionNoticeDialog(mainStack,
+ "Notice");
+ if (questionNotice->Create("notice", "Welcome to LinHES!", readmeText))
+ mainStack->AddScreen(questionNotice, true);
+ else
+ return -1;
+
+ do
+ {
+ qApp->processEvents();
+ std::this_thread::sleep_for(std::chrono::milliseconds(5));
+ } while (mainStack->TotalScreens() > 0);
+ }
else if (bShowquestion)
{
//LOG(VB_GENERAL, LOG_INFO, QString(question));
- DialogBox *dia = NULL;
- QString prompt;
- QString *problems = new QString("");
- problems->append("\n");
- problems->append("\n");
- problems->append(question);
- dia = new DialogBox(mainWindow, problems->append("\n" ));
- dia->AddButton(QObject::tr("Yes"));
- dia->AddButton(QObject::tr("No"));
- int returncode = 0;
+ extern int questionReturnCode; //as extern to be set in questionnotice.cpp
- returncode = dia->exec();
- dia->deleteLater();
- DestroyMythMainWindow();
- delete gContext;
+ MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack();
+ QuestionNoticeDialog *questionNotice = new QuestionNoticeDialog(mainStack,
+ "Question");
+ if (questionNotice->Create("question", "Question", question))
+ mainStack->AddScreen(questionNotice, true);
+ else
+ return -1;
- return returncode;
+ do
+ {
+ qApp->processEvents();
+ std::this_thread::sleep_for(std::chrono::milliseconds(5));
+ } while (mainStack->TotalScreens() > 0);
+ retval = questionReturnCode;
}
else
{
- if (LanguageSelection::prompt(showLang)){
+ if (LanguageSelection::prompt(showLang))
+ {
//taken from reloadTheme mythtv-setup
MythTranslation::reload();
GetMythMainWindow()->ReinitDone();
-
}
MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack();
WelcomeDialog *welcome = new WelcomeDialog(mainStack, "Welcome");
if (welcome->Create())
- {
mainStack->AddScreen(welcome, true);
- }
else
return -1;
do
{
-
qApp->processEvents();
- usleep(5000);
+ std::this_thread::sleep_for(std::chrono::milliseconds(5));
} while (mainStack->TotalScreens() > 0);
-
-
- // DestroyMythMainWindow();
- // delete gContext;
- // gContext = NULL;
- // delete qApp;
-
}
DestroyMythMainWindow();
-
- //gCoreContext->GetSetting("MasterServerIP");
- //gCoreContext->GetSetting("BackendServerIP");
-
-
-
delete gContext;
- gContext = NULL ;
- //delete qApp;
-
- return 0;
+ SignalHandler::Done();
+ return retval;
}
-
-