diff options
author | Britney Fransen <brfransen@gmail.com> | 2013-12-09 23:00:51 (GMT) |
---|---|---|
committer | Britney Fransen <brfransen@gmail.com> | 2013-12-09 23:00:51 (GMT) |
commit | 23b63734b90bb8c37d88673383002cbd210cdc99 (patch) | |
tree | 8179ce273843f1527fc515c1fd59df75d0d9c77d /abs/core/mythinstall/MythVantage-app/mythbeselect/main.cpp | |
parent | 9c7a9f742bbe8a69bdf50335e8218a45c3f28721 (diff) | |
download | linhes_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/mythbeselect/main.cpp')
-rwxr-xr-x | abs/core/mythinstall/MythVantage-app/mythbeselect/main.cpp | 195 |
1 files changed, 195 insertions, 0 deletions
diff --git a/abs/core/mythinstall/MythVantage-app/mythbeselect/main.cpp b/abs/core/mythinstall/MythVantage-app/mythbeselect/main.cpp new file mode 100755 index 0000000..7c5f9f2 --- /dev/null +++ b/abs/core/mythinstall/MythVantage-app/mythbeselect/main.cpp @@ -0,0 +1,195 @@ +#include <qapplication.h> +#include <cstdlib> +//#include "libmyth/mythdialogs.h" +#include "libmyth/mythcontext.h" +#include "libmyth/settings.h" +#include "libmyth/langsettings.h" +#include "libmyth/mythdbcon.h" +#include <libmyth/exitcodes.h> +#include "libmythtv/tv.h" + +#include "mythdialogbox.h" + +#include <iostream> +#include <fstream> +#include <stdio.h> + +#include "libmyth/dialogbox.h" +#include <qlist.h> +#include <qvaluevector.h> +#include "installdialog.h" +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) +{ + QString becommand; + QApplication a(argc, argv); + bool bShow=false; + gContext = NULL; + gContext = new MythContext(MYTH_BINARY_VERSION); + if (!gContext->Init()) + { + VERBOSE(VB_IMPORTANT, "mythwelcome: Could not initialize myth context. " + "Exiting."); + return FRONTEND_EXIT_NO_MYTHCONTEXT; + } + + if (!MSqlQuery::testDBConnection()) + { + VERBOSE(VB_IMPORTANT, "mythwelcome: Could not open the database. " + "Exiting."); + return -1; + } + + if ( a.argc() == 1 ) + { + VERBOSE(VB_IMPORTANT, "Not enough argurments"); + exit(1); + } + // Check command line arguments + for (int argpos = 1; argpos < a.argc(); ++argpos) + { + // ++argpos; + + if (!strcmp(a.argv()[argpos],"-restart")) + { + becommand="restart"; + } + else if (!strcmp(a.argv()[argpos],"-start")) + { + becommand="start"; + } + else if (!strcmp(a.argv()[argpos],"-stop")) + { + becommand="stop"; + } + else if (!strcmp(a.argv()[argpos],"-forceshow")) + { + bShow=true; + } + else + { + cerr << "Invalid argument: " << a.argv()[argpos] << endl << + "Valid options are: " << endl << + "-restart " << endl << + "-start " << endl << + "-stop " << endl << + "-forceshow" << endl; + + return FRONTEND_EXIT_INVALID_CMDLINE; + } + + + } + + gContext->LoadQtConfig(); + + + + QStringList msg; + QString tempip; + QString justifyip; + QString temphname; + QString justifyname; + QString tempbetype; + QString justifybetype; + + int listmaxpos = 0 ; + typedef QValueVector<QString> BEvector; + BEvector BElist (20); + + if (!MSqlQuery::testDBConnection()) + { + VERBOSE(VB_IMPORTANT, "mythwelcome: Could not open the database. " + "Exiting."); + } + + //select the master backend + MSqlQuery query(MSqlQuery::InitCon()); + query.prepare( "SELECT DISTINCT data,hostname from settings where value='MasterServerIP';"); + if (query.exec() && query.isActive() && query.size() > 0) + { + while (query.next()) + { + + tempip = query.value(0).toString(); + justifyip=tempip.rightJustify(15,' ',false); + temphname = query.value(1).toString(); + justifyname= temphname.rightJustify( 20, ' ',false ); + + if ( temphname == "" ) + tempbetype="MBE: "; + else + tempbetype="SBE: "; + + tempbetype.append(justifyname); + tempbetype.append(" "); + tempbetype.append(justifyip); + + justifybetype= tempbetype.leftJustify(50,' ' ,true); + BElist[listmaxpos] = tempbetype; + msg << (justifybetype); + listmaxpos++; + } + } + + + //slave backends + query.prepare( "SELECT DISTINCT data,hostname from settings where value='BackendServerIP' and not data=:ip ;"); + query.bindValue( ":ip", tempip ); + if (query.exec() && query.isActive() && query.size() > 0) + { + while (query.next()) + { + + tempip = query.value(0).toString(); + justifyip=tempip.rightJustify(15,' ',false); + temphname = query.value(1).toString(); + justifyname= temphname.rightJustify( 20, ' ',false ); + + if ( temphname == "" ) + tempbetype="MBE: "; + else + tempbetype="SBE: "; + + tempbetype.append(justifyname); + tempbetype.append(" "); + tempbetype.append(justifyip); + + justifybetype= tempbetype.leftJustify(50,' ' ,true); + BElist[listmaxpos] = tempbetype; + msg << (justifybetype); + listmaxpos++; + } + } + + + +if ( query.size () >1) + bShow=true; + + +cout << listmaxpos << endl; +if ( bShow ) +{ + LanguageSettings::load("mythfrontend"); + + MythMainWindow *mainWindow = GetMythMainWindow(); + mainWindow->Init(); + gContext->SetMainWindow(mainWindow); + initKeys(); + runstuff(msg,BElist,becommand); + +delete gContext; +} +else +{ + dorestart( becommand, BElist[0] ); +} +return 0; +} + |