summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/fbgui.cpp47
-rw-r--r--src/fbgui.h6
-rw-r--r--src/javascriptinterface.cpp27
-rw-r--r--src/javascriptinterface.h6
4 files changed, 86 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";
+}
diff --git a/src/fbgui.h b/src/fbgui.h
index a703d6e..25911fd 100644
--- a/src/fbgui.h
+++ b/src/fbgui.h
@@ -103,6 +103,12 @@ private slots:
// triggered by fileChanged Signal of _watcher
// deletes _watcher, since we don't need it anymore and tries to load URL.
void prepareURLLoad();
+
+ // shut off the system
+ void performShutDown();
+
+ // reboot the system
+ void performReboot();
};
#endif // FBGUI_H
diff --git a/src/javascriptinterface.cpp b/src/javascriptinterface.cpp
index ea25855..66ec7a5 100644
--- a/src/javascriptinterface.cpp
+++ b/src/javascriptinterface.cpp
@@ -141,6 +141,33 @@ const QString JavascriptInterface::getSysInfo(const QString& info) {
void JavascriptInterface::quit() {
emit quitFbgui();
}
+
+//-------------------------------------------------------------------------------------------------------
+/**
+ * This method performs a shutdown of the client.
+ *
+ * This method performs a shutdown of the client.
+ * Emits the JavascriptInterface::shutDownClient() signal.It is
+ * connected with the fbgui::performShutDown() method.
+ *
+ * @see fbgui::performShutDown()
+ */
+void JavascriptInterface::shutDown() {
+ emit shutDownClient();
+}
+//-------------------------------------------------------------------------------------------------------
+/**
+ * This method performs a reboot of the client.
+ *
+ * This method performs a reboot of the client.
+ * Emits the JavascriptInterface::rebootClient() signal. It is
+ * connected with the fbgui::performReboot() method.
+ *
+ * @see fbgui::performReboot()
+ */
+void JavascriptInterface::reboot() {
+ emit rebootClient();
+}
//-------------------------------------------------------------------------------------------------------
// Download Manager information exchange
//-------------------------------------------------------------------------------------------------------
diff --git a/src/javascriptinterface.h b/src/javascriptinterface.h
index 9d7bd37..1f93e38 100644
--- a/src/javascriptinterface.h
+++ b/src/javascriptinterface.h
@@ -39,6 +39,10 @@ signals:
void requestFile(const QString& filename);
// quit the application
void quitFbgui();
+ // shut off the system. connected to fbgui::performShutDown()
+ void shutDownClient();
+ // reboot the system. connected to fbgui::performReboot()
+ void rebootClient();
public slots:
// make sure the interface stays attached on webpage reload
@@ -49,6 +53,8 @@ public slots:
void setCallbackOnFinished(const QString& function);
const QString getSysInfo(const QString& info);
void quit();
+ void shutDown();
+ void reboot();
// callback when downloads are done.
void callbackOnFinished();