summaryrefslogtreecommitdiffstats
path: root/src/fbgui.cpp
diff options
context:
space:
mode:
authorjoe2011-04-21 15:17:09 +0200
committerjoe2011-04-21 15:17:09 +0200
commit29ffc91c35fd770eb965bb2572f729e3b15b7c6e (patch)
treebfee740498c28500638f8ed04fc59d41f0ecfc67 /src/fbgui.cpp
parentfixed kernel command line reading & fixed performShutDown / performReboot (diff)
downloadfbgui-29ffc91c35fd770eb965bb2572f729e3b15b7c6e.tar.gz
fbgui-29ffc91c35fd770eb965bb2572f729e3b15b7c6e.tar.xz
fbgui-29ffc91c35fd770eb965bb2572f729e3b15b7c6e.zip
fbgui class doxigen comments (to test...)
Diffstat (limited to 'src/fbgui.cpp')
-rw-r--r--src/fbgui.cpp56
1 files changed, 47 insertions, 9 deletions
diff --git a/src/fbgui.cpp b/src/fbgui.cpp
index 8d2135a..fd6f5fa 100644
--- a/src/fbgui.cpp
+++ b/src/fbgui.cpp
@@ -274,6 +274,14 @@ QByteArray fbgui::generatePOSTData() {
//-------------------------------------------------------------------------------------------
// Debug console setup / control
//-------------------------------------------------------------------------------------------
+/**
+ * This method creates a debug console as a widget.
+ *
+ * It is basicly a QTextEdit widget as provided by QT's Framework.
+ * An action to toggle this widget is implemented (CTRL + D).
+ *
+ * @see fbgui::toggleDebugConsole()
+ */
void fbgui::createDebugConsole() {
// create the debug console widget
_debugConsole = new QTextEdit(this);
@@ -295,19 +303,31 @@ void fbgui::createDebugConsole() {
toggleDebugConsole()));
}
//-------------------------------------------------------------------------------------------
+/**
+ * This method toggles the debug console.
+ *
+ * Toggle the visibility of the debug console if the action _toggleDebugConsole is triggered.
+ *
+ * @see fbgui::createDebugConsole()
+ */
void fbgui::toggleDebugConsole() {
(_debugConsole->isVisible()) ? _debugConsole->hide()
: _debugConsole->show();
}
//-------------------------------------------------------------------------------------------
+// System Calls Functions
+//-------------------------------------------------------------------------------------------
+// TODO One function for reboot and shutdown, with parameter for the action.
+// for example: doSystemCall(_REBOOT_);
/**
* This method performs the shutdown of the client.
*
* This method performs the shutdown of the client. It is triggered by the
* JavascriptInterface::shutDownClient() signal which will be emited in the
* JavascriptInterface::shutDown() method.
- * This method uses an QProcess object to execute the standard linux
- * shutdown command.
+ * This method writes the character 'o' in /proc/sysrq-trigger
+ * which will shutdown the computer immediatly.
+ * (See linux magic keys)
*
* @see JavascriptInterface::shutDownClient()
* @see JavascriptInterface::shutDown()
@@ -329,8 +349,9 @@ void fbgui::performShutDown() {
* This method performs the reboot of the client. It is triggered by the
* JavascriptInterface::rebootClient() signal which will be emited in the
* JavascriptInterface::reboot() method.
- * This method uses an QProcess object to execute the standard linux
- * shutdown command.
+ * This method writes the character 'b' in /proc/sysrq-trigger
+ * which will shutdown the computer immediatly.
+ * (See linux magic keys)
*
* @see JavascriptInterface::rebootClient()
* @see JavascriptInterface::reboot()
@@ -346,36 +367,43 @@ void fbgui::performReboot() {
}
}
//-------------------------------------------------------------------------------------------
+// Preparing System Boot (Stage 3)
+//-------------------------------------------------------------------------------------------
/**
- * This method performs kexec.
+ * This method prepares kexec.
+ *
+ * The kernel command line file that should have been downloaded from the Preboot-Server
+ * and the ip config file (created by udhcpc) are merged into the final completed KCL.
*
*/
void fbgui::prepareKexec() {
- // TODO read kcl file
+ // try to read KCL file that was downloaded.
QFile file(downloadPath + "/kcl");
if (!file.open(QIODevice::ReadOnly)) {
qxtLog->debug() << "[gui] No such file: " << file.fileName();
}
- // everything ok, read data
+ // everything ok, read data.
QString kcl = file.readAll();
file.close();
qxtLog->debug() << "[gui] KCL from PBS: " << kcl;
- // TODO read IP config file
+ // try to read ipconfig file generated by udhcpc.
file.setFileName("/tmp/ip_config_fbgui");
if (!file.open(QIODevice::ReadOnly)) {
qxtLog->debug() << "[gui] No such file: " << file.fileName();
}
+ // everything ok, read data.
QString ipConfig = file.readAll();
file.close();
qxtLog->debug() << "[gui] IP config: " << ipConfig;
+ // append ipConfig
kcl.append(" ip=");
kcl.append(ipConfig);
-
qxtLog->debug() << "[gui] Complete KCL: " << kcl;
+ // load the kernel + initramfs + append of kcl into kexec.
QProcess *process = new QProcess(this);
QString cmdline = "kexec -l " + downloadPath.toUtf8() + "/kernel --initrd="
+ downloadPath.toUtf8() + "/initramfs --append=\"" + kcl.toUtf8()
@@ -389,6 +417,7 @@ void fbgui::prepareKexec() {
} else {
qxtLog->debug() << "[gui] Kexec load successfull.";
if (debugMode < 0) {
+ // if process successfully finished, try to run kexec -e
runKexec();
} else {
qxtLog->debug()
@@ -399,11 +428,20 @@ void fbgui::prepareKexec() {
}
}
}
+//-------------------------------------------------------------------------------------------
+/**
+ * This method tries to execute: kexec -e
+ *
+ * kernel, initramfs and kcl has been previously loaded in kexec.
+ * This method then tries to execute kexec -e
+ *
+ */
void fbgui::runKexec() {
QProcess *process = new QProcess(this);
process->startDetached("kexec -e");
if (!process->waitForStarted()) {
qxtLog->debug() << "[gui] Failed to execute: kexec -e";
exit( EXIT_FAILURE);
+ //TODO: Handle failure properly...
}
}