rendered paste bodyIndex: libs/libmyth/mythcontext.cpp
===================================================================
--- libs/libmyth/mythcontext.cpp (revision 14863)
+++ libs/libmyth/mythcontext.cpp (working copy)
@@ -1108,8 +1108,16 @@
bool blockingClient)
{
MythSocket *serverSock = NULL;
+ MythBusyDialog *busy = NULL;
int cnt = 1;
+
+ bool enableGUI=false;
+ if(GetMainWindow())
+ enableGUI=true;
+ else
+ enableGUI=false;
+VERBOSE(VB_GENERAL, enableGUI);
int sleepTime = GetNumSetting("WOLbackendReconnectWaitTime", 0);
int maxConnTry = GetNumSetting("WOLbackendConnectRetry", 1);
@@ -1147,7 +1155,8 @@
manageLock = true;
d->serverSockLock.unlock();
}
- MythPopupBox::showOkPopup(d->mainWindow,
+ if (GetMainWindow())
+ MythPopupBox::showOkPopup(d->mainWindow,
"connection failure",
tr("Could not connect to the "
"master backend server -- is "
@@ -1163,19 +1172,60 @@
}
else
{
+ QString wol_cmd;
+ QString waitString=QObject::tr("Waiting for Server...");
+
+ if (GetMainWindow())
+ {
+ busy = new MythBusyDialog(waitString);
+ busy->start(1);
+ }
+
VERBOSE(VB_GENERAL, "Trying to wake up the MasterBackend "
"now.");
- QString wol_cmd = GetSetting("WOLbackendCommand",
- "echo \'would run the "
- "WakeServerCommand now, if "
- "set!\'");
- system(wol_cmd.ascii());
+
+ /* If this is run from the master backend, use local command
+ * to start backend (eg. /etc/init.d/mythtv-backend start).
+ * Otherwise use WakeOnLan command to start backend remotely.
+ */
+ if (gContext->IsMasterHost())
+ wol_cmd = GetSetting("MythbackendStartCommand",
+ "sudo /etc/init.d/mythtv-backend start");
+ else
+ wol_cmd = GetSetting("WOLbackendCommand",
+ "echo \'would run the WakeServerCommand now, "
+ "if set!\'");
- VERBOSE(VB_GENERAL, QString("Waiting for %1 seconds until I "
- "try to reconnect again.")
+ // Don't restart the backend if setup is running
+ if ( ! isRunning("mythtv-setup") )
+ {
+ //busy->setLabel(waitString);
+ system(wol_cmd.ascii());
+ cout << wol_cmd.ascii();
+ }
+ //else
+ // busy->setLabel(QObject::tr("Setup is Running. Not restarting backend until setup is finished!"));
+
+ VERBOSE(VB_GENERAL, QString("Waiting for %1 seconds before I send wake command again.")
.arg(sleepTime));
- sleep(sleepTime);
+
+ int sleepCount = 0;
+ serverSock = new MythSocket();
+ while (!serverSock->connect(hostname, port))
+ {
+ sleep(1);
+ sleepCount++;
+ if (sleepCount > sleepTime)
+ break;
+ }
+ serverSock->DownRef();
+ serverSock = NULL;
++cnt;
+ if (GetMainWindow())
+ {
+ busy->Close();
+ busy->deleteLater();
+ }
}
d->attemptingToConnect = false;
}
Index: programs/mythtv-setup/main.cpp
===================================================================
--- programs/mythtv-setup/main.cpp (revision 14863)
+++ programs/mythtv-setup/main.cpp (working copy)
@@ -296,6 +296,9 @@
gContext->UpdateImageCache();
MythThemeBase *themeBase = new MythThemeBase();
(void) themeBase;
+ DialogBox *dia = NULL;
+ QString stCmd;
+ int val = 0;
LanguageSettings::prompt();
LanguageSettings::load("mythfrontend");
@@ -304,27 +307,35 @@
QObject::tr("WARNING") + ": " +
QObject::tr("MythTV has detected that the backend is running.")+"\n\n"+
QObject::tr("Changing existing card inputs, deleting anything, "
- "or scanning for channels may not work.");
+ "or scanning for channels may not work.")+"\n\n"+
+ QObject::tr("It is strongly advised that you stop the backend whilst running setup!");
- bool backendIsRunning = gContext->BackendIsRunning();
+ bool restartBackend=false;
- if (backendIsRunning)
+ // Offer to stop the backend if sensible
+ if (gContext->BackendIsRunning() && gContext->IsMasterHost())
{
- int val = MythPopupBox::show2ButtonPopup(
- gContext->GetMainWindow(), QObject::tr("WARNING"),
- warn,
- QObject::tr("Continue"),
- QObject::tr("Exit"), 1);
- if (1 == val)
- return 0;
-
- backendIsRunning = true;
+ dia = new DialogBox(mainWindow, warn);
+ dia->AddButton(QObject::tr("Stop backend and continue"));
+ dia->AddButton(QObject::tr("Continue anyway"));
+ dia->AddButton(QObject::tr("Exit"));
+ val = dia->exec();
+ dia->deleteLater();
+
+ if (val == 1) // Stop Backend
+ {
+ stCmd = gContext->GetSetting("MythbackendStopCommand", "sudo /etc/init.d/mythtv-backend stop");
+ if (!stCmd.isEmpty())
+ myth_system(stCmd);
+ restartBackend=true;
+ }
+ else // Exit
+ return 1;
}
REG_KEY("qt", "DELETE", "Delete", "D");
REG_KEY("qt", "EDIT", "Edit", "E");
- DialogBox *dia = NULL;
bool haveProblems = false;
do
{
@@ -350,7 +361,7 @@
if (dia->exec() == 2)
haveProblems = false;
- delete dia;
+ dia->deleteLater();
}
delete problems;
@@ -359,19 +370,34 @@
}
while (haveProblems);
+ // Start backend
+ if (restartBackend)
+ {
+ stCmd = gContext->GetSetting("MythbackendStartCommand", "sudo /etc/init.d/mythtv-backend start");
+ if (!stCmd.isEmpty())
+ myth_system(stCmd);
+ }
+
if (gContext->IsMasterHost())
{
dia = new DialogBox(mainWindow,
- QObject::tr("If this is the master backend server, "
- "please run 'mythfilldatabase' "
- "to populate the database "
- "with channel information."));
- dia->AddButton(QObject::tr("OK"));
- dia->exec();
- delete dia;
+ QObject::tr("Run 'mythfilldatabase' to populate the database "
+ "with channel information?")+"\n\n"+
+ QObject::tr("(Not required if you are using off-air information only, "
+ "such as on DVB)."));
+ dia->AddButton(QObject::tr("No, just exit"));
+ dia->AddButton(QObject::tr("Yes, run mythfilldatabase"));
+ val = dia->exec();
+ dia->deleteLater();
+ if (val == 1)
+ {
+ stCmd = gContext->GetSetting("MythFillDatabasePath", "mythfilldatabase");
+ if (!stCmd.isEmpty())
+ myth_system(stCmd);
+ }
}
- if (backendIsRunning)
+ if (gContext->BackendIsRunning())
RemoteSendMessage("CLEAR_SETTINGS_CACHE");
return 0;
Index: programs/mythtv-setup/backendsettings.cpp
===================================================================
--- programs/mythtv-setup/backendsettings.cpp (revision 14863)
+++ programs/mythtv-setup/backendsettings.cpp (working copy)
@@ -327,10 +327,10 @@
static GlobalLineEdit *WOLbackendCommand()
{
GlobalLineEdit *gc = new GlobalLineEdit("WOLbackendCommand");
- gc->setLabel(QObject::tr("Wake Command"));
+ gc->setLabel(QObject::tr("WOL Wake Command"));
gc->setValue("");
gc->setHelpText(QObject::tr("The command used to wake up your master "
- "backend server\n(eg. sudo /etc/init.d/mythtv-backend restart)."));
+ "backend server from another machine.\n (Leave blank to disable)."));
return gc;
};
@@ -340,10 +340,30 @@
gc->setLabel(QObject::tr("Wake command"));
gc->setValue("");
gc->setHelpText(QObject::tr("The command used to wakeup your slave "
- "backends. Leave empty to disable."));
+ "backends.\n (Leave blank to disable)."));
return gc;
};
+static GlobalLineEdit *MythbackendStopCommand()
+{
+ GlobalLineEdit *gc = new GlobalLineEdit("MythbackendStopCommand");
+ gc->setLabel(QObject::tr("Backend Stop Command"));
+ gc->setValue("sudo /etc/init.d/mythtv-backend stop");
+ gc->setHelpText(QObject::tr("The command used to stop the backend when running on "
+ "the master backend server\n(eg. sudo /etc/init.d/mythtv-backend stop)."));
+ return gc;
+};
+
+static GlobalLineEdit *MythbackendStartCommand()
+{
+ GlobalLineEdit *gc = new GlobalLineEdit("MythbackendStartCommand");
+ gc->setLabel(QObject::tr("Backend Start Command"));
+ gc->setValue("sudo /etc/init.d/mythtv-backend start");
+ gc->setHelpText(QObject::tr("The command used to start the backend when running on "
+ "the master backend server\n(eg. sudo /etc/init.d/mythtv-backend start)."));
+ return gc;
+};
+
static GlobalSpinBox *idleTimeoutSecs()
{
GlobalSpinBox *gc = new GlobalSpinBox("idleTimeoutSecs", 0, 1200, 5);
@@ -766,6 +708,8 @@
backend->addChild(WOLbackendReconnectWaitTime());
backend->addChild(WOLbackendConnectRetry());
backend->addChild(WOLbackendCommand());
+ backend->addChild(MythbackendStopCommand());
+ backend->addChild(MythbackendStartCommand());
group4->addChild(backend);
VerticalConfigurationGroup* slaveBackend = new VerticalConfigurationGroup();