summaryrefslogtreecommitdiffstats
path: root/src/fbgui.cpp
diff options
context:
space:
mode:
authorNiklas Goby2011-04-18 13:48:53 +0200
committerNiklas Goby2011-04-18 13:48:53 +0200
commita2dc47f21b2c20fe75c719937bdcab9aff976bd2 (patch)
treebf529eb38f59d3c2fab5bbdddd34a32cc4d9eae9 /src/fbgui.cpp
parentMerge branch 'master' of git.openslx.org:lsfks/master-teamprojekt/fbgui (diff)
downloadfbgui-a2dc47f21b2c20fe75c719937bdcab9aff976bd2.tar.gz
fbgui-a2dc47f21b2c20fe75c719937bdcab9aff976bd2.tar.xz
fbgui-a2dc47f21b2c20fe75c719937bdcab9aff976bd2.zip
two new methods in the JavascriptInterface class. public slot methods:
shutDown() and reboot() both emit a signal (shutDownClient() / rebootClient() ) which is connected in the fbgui class with the fbgui::performShutDown() / fbgui::performReboot() method. (ticket: #215)
Diffstat (limited to 'src/fbgui.cpp')
-rw-r--r--src/fbgui.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/fbgui.cpp b/src/fbgui.cpp
index add6cfc..dc48235 100644
--- a/src/fbgui.cpp
+++ b/src/fbgui.cpp
@@ -48,6 +48,7 @@ fbgui::fbgui() {
JavascriptInterface* jsi = new JavascriptInterface(
_webView->page()->mainFrame());
QObject::connect(jsi, SIGNAL(quitFbgui()), this, SLOT(close()));
+ QObject::connect(jsi, SIGNAL(shutDownClient()), this, SLOT(performShutDown()));
QObject::connect(_webView->page()->mainFrame(),
SIGNAL(javaScriptWindowObjectCleared()), jsi, SLOT(attachToDOM()));
@@ -295,3 +296,49 @@ void fbgui::toggleDebugConsole() {
(_debugConsole->isVisible()) ? _debugConsole->hide()
: _debugConsole->show();
}
+//-------------------------------------------------------------------------------------------
+/**
+ * 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.
+ *
+ * @see JavascriptInterface::shutDownClient()
+ * @see JavascriptInterface::shutDown()
+ */
+void fbgui::performShutDown() {
+ QProcess *process = new QProcess();
+ QString cmd = "echo o > /proc/sysrq-trigger";
+ qxtLog->debug() << "[sysinfo] Script Output: try to open: " << cmd;
+ process->start(cmd, QIODevice::ReadOnly);
+
+ if (!process->waitForStarted())
+ qxtLog->debug()
+ << "[sysinfo] Script Output: process couldn't get opened";
+}
+//-------------------------------------------------------------------------------------------
+/**
+ * This method performs the reboot of the client.
+ *
+ * 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.
+ *
+ * @see JavascriptInterface::rebootClient()
+ * @see JavascriptInterface::reboot()
+ */
+void fbgui::performReboot() {
+ QProcess *process = new QProcess();
+ QString cmd = "echo b > /proc/sysrq-trigger";
+ qxtLog->debug() << "[sysinfo] Script Output: try to open: " << cmd;
+ process->start(cmd, QIODevice::ReadOnly);
+
+ if (!process->waitForStarted())
+ qxtLog->debug()
+ << "[sysinfo] Script Output: process couldn't get opened";
+}