summaryrefslogtreecommitdiffstats
path: root/abs/core/mythinstall/MythVantage-app/mythinstall/main.cpp
diff options
context:
space:
mode:
authorBritney Fransen <brfransen@gmail.com>2013-12-09 23:00:51 (GMT)
committerBritney Fransen <brfransen@gmail.com>2013-12-09 23:00:51 (GMT)
commit23b63734b90bb8c37d88673383002cbd210cdc99 (patch)
tree8179ce273843f1527fc515c1fd59df75d0d9c77d /abs/core/mythinstall/MythVantage-app/mythinstall/main.cpp
parent9c7a9f742bbe8a69bdf50335e8218a45c3f28721 (diff)
downloadlinhes_pkgbuild-23b63734b90bb8c37d88673383002cbd210cdc99.zip
linhes_pkgbuild-23b63734b90bb8c37d88673383002cbd210cdc99.tar.gz
linhes_pkgbuild-23b63734b90bb8c37d88673383002cbd210cdc99.tar.bz2
mythinstall: pull in MythVantage src to LH tree.
more cleanup to many modules. access can now disable remotes and screensaver
Diffstat (limited to 'abs/core/mythinstall/MythVantage-app/mythinstall/main.cpp')
-rwxr-xr-xabs/core/mythinstall/MythVantage-app/mythinstall/main.cpp597
1 files changed, 597 insertions, 0 deletions
diff --git a/abs/core/mythinstall/MythVantage-app/mythinstall/main.cpp b/abs/core/mythinstall/MythVantage-app/mythinstall/main.cpp
new file mode 100755
index 0000000..fa16918
--- /dev/null
+++ b/abs/core/mythinstall/MythVantage-app/mythinstall/main.cpp
@@ -0,0 +1,597 @@
+//#include <qapplication.h>
+//Added by qt3to4:
+#include <Q3TextStream>
+
+
+#include "installdialog.h"
+#include "installsettings.h"
+#include "password_manage.h"
+#include "autocard.h"
+#include "settemplate.h"
+
+
+
+
+// Qt
+#include <QApplication>
+#include <QFileInfo>
+#include <QDir>
+
+
+
+#include <cstdlib>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+
+
+
+#include <stdio.h>
+
+//MythTV
+#include "langsettings.h"
+#include "mythcontext.h"
+#include "mythversion.h"
+#include "mythtranslation.h"
+#include "mythdbcon.h"
+#include "exitcodes.h"
+#include "compat.h"
+#include "lcddevice.h"
+#include "commandlineparser.h"
+#include "mythlogging.h"
+#include "dialogbox.h"
+
+
+// libmythui
+#include "mythmainwindow.h"
+#include "mythuihelper.h"
+
+
+//??
+#include "myththemebase.h"
+
+
+HostParms hostparm;
+DDCinfo ddcinfo;
+
+
+void initKeys(void)
+{
+ REG_KEY("Welcome", "STARTXTERM", "Open an Xterm window", "F12");
+ REG_KEY("Welcome", "SHOWSETTINGS", "Show Mythshutdown settings", "F11");
+}
+
+int main(int argc, char **argv)
+{
+ bool showLang = false;
+ bool bShowSettings = false;
+ bool bShowNetwork = false;
+ bool bShowHostype = false;
+ bool bShowMisc = false;
+ bool bShowshutdown = false;
+ bool bShowadvanced = false;
+ bool bShowsound = false;
+ bool bShowadvancedX = false;
+ bool bShowAccesscontrol = false;
+ bool bShowplugins = false;
+ bool bShowsoftware = false;
+ bool bShowTemplate = false;
+ bool bShowuser = false;
+ bool bShowwebuser = false;
+ bool bRunSetup = false;
+ bool bShowHelp = false;
+ bool bShowReadme = false;
+ bool bShowddns = false;
+ bool bShowinfrared = false;
+ bool bShowscreensaver = false;
+ bool bShowquestion = false;
+ bool bShowsupplemental = false;
+ bool bShowremotes_only = false;
+ bool bShowvnc = false;
+ bool bShowFileshare = false;
+
+ QStringList template_c_line ;
+ QString modulelist = "" ;
+ QString templateop="";
+ QString templatename="";
+ QString templatehostname="";
+ QString question;
+
+
+ int FRONTEND_EXIT_NO_MYTHCONTEXT = 1;
+ int FRONTEND_EXIT_INVALID_CMDLINE =1 ;
+ QApplication a(argc, argv);
+ QCoreApplication::setApplicationName("mythinstall");
+
+ // Check command line arguments
+ MythInstallCommandLineParser cmdline;
+ int retval;
+ if ((retval = cmdline.ConfigureLogging()) != GENERIC_EXIT_OK)
+ return retval;
+
+ if (!cmdline.Parse(argc, argv))
+ {
+ cmdline.PrintHelp();
+ return 4;
+ return GENERIC_EXIT_INVALID_CMDLINE;
+ }
+
+ if (cmdline.toBool("showhelp"))
+ {
+ cmdline.PrintHelp();
+ return GENERIC_EXIT_OK;
+ }
+
+ if (cmdline.toBool("showversion"))
+ {
+ cmdline.PrintVersion();
+ return GENERIC_EXIT_OK;
+ }
+//--------------------Start of real stuff---------------------
+ gContext = new MythContext(MYTH_BINARY_VERSION);
+
+ if (!gContext->Init())
+ {
+ LOG(VB_GENERAL, LOG_ERR,
+ "mythinstall: Could not initialize MythContext. Exiting.");
+ return GENERIC_EXIT_NO_MYTHCONTEXT;
+ }
+
+ if (!MSqlQuery::testDBConnection())
+ {
+ LOG(VB_GENERAL, LOG_ERR,
+ "mythinstall: Could not open the database. Exiting.");
+ return -1;
+ }
+
+ if (cmdline.toBool("screen"))
+ {
+ bShowSettings = true;
+ LOG(VB_GENERAL, LOG_INFO, QString("mythinstall: Screen stuff"));
+ QString tmpArg = (cmdline.toString("screen")) ;
+ QStringList pairs = QStringList::split(",", tmpArg);
+ for (unsigned int index = 0; index < pairs.size(); ++index)
+ {
+ if ( pairs[index] == "network" )
+ {
+ bShowNetwork = true;
+ modulelist.append("network,");
+ }
+ else if ( pairs[index] == "misc" )
+ {
+ bShowMisc = true;
+ modulelist.append("misc,");
+ }
+ else if ( pairs[index] == "sleep" )
+ {
+ bShowshutdown = true;
+ modulelist.append("sleep,");
+ }
+ else if ( pairs[index] == "hostype" )
+ {
+ bShowHostype = true;
+ modulelist.append("hostype,");
+ }
+ else if ( pairs[index] == "advanced" )
+ {
+ bShowadvanced = true;
+ modulelist.append("advanced,");
+ }
+ else if ( pairs[index] == "sound" )
+ {
+ bShowsound = true;
+ modulelist.append("audio,");
+ }
+ else if ( pairs[index] == "advancedX" )
+ {
+ bShowadvancedX = true;
+ modulelist.append("advancedX,");
+ }
+ else if ( pairs[index] == "accesscontrol" )
+ {
+ bShowAccesscontrol = true;
+ modulelist.append("accesscontrol,");
+ }
+ else if ( pairs[index] == "plugins" )
+ {
+ bShowplugins = true;
+ modulelist.append("plugins,");
+ }
+ else if ( pairs[index] == "software" )
+ {
+ bShowsoftware = true;
+ modulelist.append("software,");
+ }
+ else if ( pairs[index] == "user" )
+ {
+ bShowuser = true;
+ modulelist.append("user,");
+ }
+ else if ( pairs[index] == "webuser" )
+ {
+ bShowwebuser = true;
+ modulelist.append("webuser,");
+ }
+ else if ( pairs[index] == "ddns" )
+ {
+ bShowddns = true;
+ modulelist.append("ddns,");
+ }
+ else if ( pairs[index] == "ir" )
+ {
+ bShowinfrared = true;
+ modulelist.append("ir,");
+ }
+ else if ( pairs[index] == "screensaver" )
+ {
+ bShowscreensaver = true;
+ modulelist.append("screensaver,");
+ }
+ else if ( pairs[index] == "supplemental" )
+ {
+ bShowsupplemental = true;
+ modulelist.append("supplemental,");
+ }
+ else if ( pairs[index] == "remotes_only" )
+ {
+ bShowremotes_only = true;
+ modulelist.append("remotes_only,");
+ }
+ else if ( pairs[index] == "vnc" )
+ {
+ bShowvnc = true;
+ modulelist.append("vnc,");
+ }
+ else if ( pairs[index] == "fileshare" )
+ {
+ bShowFileshare = true;
+ modulelist.append("fileshare,");
+ }
+ } //for loop
+ }
+
+ if (cmdline.toBool("help"))
+ bShowHelp = true;
+
+ if (cmdline.toBool("readme"))
+ {
+ bShowReadme = true;
+ }
+ if (cmdline.toBool("question"))
+ {
+ bShowquestion = true;
+ question = (cmdline.toString("question")) ;
+ }
+
+ if (cmdline.toBool("run_mythsetup"))
+ bRunSetup = true;
+
+ if (cmdline.toBool("show_lang"))
+ showLang = true;
+
+ LCD::SetupLCD();
+ if (class LCD *lcd = LCD::Get())
+ lcd->switchToTime();
+
+
+ MythTranslation::load("mythfrontend");
+ GetMythUI()->LoadQtConfig();
+ MythMainWindow *mainWindow = GetMythMainWindow();
+ mainWindow->Init();
+
+// if parms were passed to -t then doen't init the screen.
+// if ( template_c_line.size() == 0 )
+// {
+// gCoreContext->SaveSetting("HOSTtemplatetype","Do Nothing" );
+// mainWindow->Init();
+// findme
+// gContext->SetMainWindow(mainWindow);
+//
+// MythThemeBase *themeBase = new MythThemeBase();
+// initKeys();
+// };
+
+ gCoreContext->ActivateSettingsCache(false);
+ gCoreContext->ClearSettingsCache();
+ gCoreContext->ActivateSettingsCache(false);
+
+ if (bShowSettings)
+ {
+ gCoreContext->ActivateSettingsCache(false);
+ gCoreContext->ClearSettingsCache();
+ bool runconfig = false;
+ system("cp -f /etc/systemconfig /tmp/systemconfig.bak");
+ QString olddb = gCoreContext->GetSetting("HostMysqlserver");
+ QString oldhostype = gCoreContext->GetSetting("HostSystemType");
+ runsettings(false,bShowNetwork,bShowHostype,bShowMisc,bShowshutdown,bShowadvanced,bShowsound,bShowadvancedX,bShowAccesscontrol,bShowplugins,bShowsoftware,bShowuser,bShowwebuser,bShowddns,bShowinfrared,bShowscreensaver,bShowsupplemental,bShowremotes_only,bShowvnc,bShowFileshare);
+ QString newdb = gCoreContext->GetSetting("HostMysqlserver");
+ QString newhostype = gCoreContext->GetSetting("HostSystemType");
+ int status = system("diff /tmp/systemconfig.bak /etc/systemconfig");
+ bool restart = false;
+ //save my settings in case db switches
+ QString cmdtxt;
+ cmdtxt=MV_ROOT ;
+ cmdtxt.append("bin/myth_settings_wrapper.sh -c save -t syssettings -d " + olddb);
+ system(cmdtxt);
+
+ if ( status != 0 )
+ {
+ runconfig = true;
+ }
+
+ if ( newdb != olddb )
+ {
+ runconfig = true;
+ restart = true;
+ //db changed save setting from olddb
+ QString cmdtxt;
+ cmdtxt=MV_ROOT ;
+ cmdtxt.append("bin/myth_settings_wrapper.sh -c save -t syssettings -d " + olddb ) ;
+ system(cmdtxt);
+ }
+
+ if ( runconfig )
+ {
+ //LOG(VB_GENERAL, LOG_ERR,
+ // "mythinstall: this is where i stalled");
+ if ( newhostype != oldhostype )
+ modulelist.append("hostypec,");
+ // trim off last ,
+ modulelist.truncate(modulelist.length()-1);
+ QString cmdtxt;
+ cmdtxt=MV_ROOT ;
+ cmdtxt.append("bin/myth_settings_wrapper.sh -c restore -t syssettings -d ");
+ QString dbcommand = cmdtxt;
+ dbcommand.append(newdb);
+ run_systemconfig(modulelist,restart,dbcommand);
+
+
+
+ }
+ system("rm -f /tmp/systemconfig.bak");
+ gCoreContext->ActivateSettingsCache(false);
+ gCoreContext->ClearSettingsCache();
+ if ( restart )
+ {
+ DialogBox *dia = NULL;
+ QString prompt;
+ QString *problems = new QString("The network address of the database has changed.");
+ problems->append("\n");
+ problems->append("The frontend will need to restart to connect to the new database.");
+ problems->append("\n");
+ dia = new DialogBox(mainWindow, problems->append("\n" ));
+ dia->AddButton(QObject::tr("OK"));
+ int returncode = 0;
+ returncode = dia->exec();
+ dia->deleteLater();
+ //cout << "restarting" << endl;
+ QString cmdtxt;
+ cmdtxt=MV_ROOT ;
+ cmdtxt.append("bin/systemconfig.sh reloadfe" );
+ system(cmdtxt);
+ }
+ gCoreContext->ActivateSettingsCache(false);
+ gCoreContext->ClearSettingsCache();
+ gCoreContext->SendMessage("CLEAR_SETTINGS_CACHE");
+
+
+
+ }//run settings
+
+ else if (bShowTemplate)
+ {
+// if ( template_c_line.size() == 2)
+// {
+// templateop=template_c_line[0];
+// templatename=template_c_line[1];
+// }
+// else if ( template_c_line.size() == 3)
+// {
+// templateop=template_c_line[0];
+// templatename=template_c_line[1];
+// templatehostname=template_c_line[2];
+// };
+// choosetemplate(templateop,templatename,templatehostname);
+ }
+
+ else if (bRunSetup)
+ {
+ DialogBox *dia = NULL;
+ QString prompt;
+ QString *problems = new QString("To configure the TV cards and program guide the setup program needs to be run.");
+ problems->append("\n");
+ problems->append("\n");
+
+ problems->append("For those in North America, guide data is provided by Schedules Direct.");
+ problems->append("\n");
+ problems->append("Visit http://www.schedulesdirect.org/ to signup for your account today");
+ problems->append("\n");
+ problems->append("\n");
+ problems->append("\n");
+
+ problems->append("If you choose to not run mythtv-setup now, the program can be run at any time by typing mythtv-setup or hitting ALT+s");
+ problems->append("\n");
+
+ problems->append("\n");
+ prompt = QObject::tr("Do you wish to run mythtv-setup ?");
+
+ dia = new DialogBox(mainWindow, problems->append("\n" + prompt));
+ dia->AddButton(QObject::tr("Yes"));
+ dia->AddButton(QObject::tr("Yes and try to autodetect cards"));
+ dia->AddButton(QObject::tr("No"));
+ int returncode = 0;
+ returncode = dia->exec();
+ DialogCode dcode = dia->exec();
+ dia->deleteLater();
+ if (kDialogCodeButton0 == dcode )
+ returncode = 0;
+ if (kDialogCodeButton1 == dcode )
+ returncode = 1;
+ if (kDialogCodeButton2 == dcode )
+ returncode = 2;
+/*
+ if (returncode == 1)
+ {
+ AutoCard listcards;
+ listcards.exec();
+ }*/
+
+ return returncode;
+ }
+
+ 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");
+
+
+ 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");
+ QFile file("/usr/MythVantage/README");
+ if ( file.open(QIODevice::ReadOnly | QIODevice::Text) )
+ {
+ Q3TextStream t( &file ); // use a text stream
+ while ( !t.eof() )
+ {
+ line = t.readLine();
+ problems->append(line);
+ problems->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;
+ }
+
+ 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;
+
+ returncode = dia->exec();
+ dia->deleteLater();
+ DestroyMythMainWindow();
+ delete gContext;
+
+ return returncode;
+ }
+ else
+ {
+ 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);
+ } 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;
+}
+
+