From 76f9e4bf6eccce658f98c2563226c84552647b15 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Mon, 25 Apr 2011 15:30:30 +0200 Subject: loading system page improved display logic --- src/fbgui.cpp | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) (limited to 'src/fbgui.cpp') diff --git a/src/fbgui.cpp b/src/fbgui.cpp index 9a0ee1d..b55fb9c 100644 --- a/src/fbgui.cpp +++ b/src/fbgui.cpp @@ -44,9 +44,11 @@ fbgui::fbgui() { createActions(); // initialize javascript interface - JavascriptInterface* jsi = new JavascriptInterface(_webView->page()->mainFrame()); + 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(jsi, SIGNAL(shutDownClient()), this, + SLOT(performShutDown())); QObject::connect(_webView->page()->mainFrame(), SIGNAL( javaScriptWindowObjectCleared()), jsi, SLOT(attachToDOM())); @@ -59,8 +61,9 @@ fbgui::fbgui() { SLOT(downloadFile(const QString&))); QObject::connect(dm, SIGNAL(updateProgress(const int&, const double&, const QString&)), jsi, SLOT(updateProgressBar(const int&, const double&, const QString&))); - QObject::connect(dm, SIGNAL(downloadQueueEmpty()), jsi, SLOT(callbackOnFinished())); - QObject::connect(dm, SIGNAL(downloadQueueEmpty()), this, SLOT(loadSystem())); + QObject::connect(dm, SIGNAL(downloadQueueEmpty()), jsi, SLOT( + callbackOnFinished())); + QObject::connect(dm, SIGNAL(downloadQueueEmpty()), this, SLOT(showLoadSystem())); // move download manager to its own thread dm->moveToThread(&dmThread); @@ -145,7 +148,8 @@ void fbgui::watchForTrigger() { qxtLog->debug() << "[gui] Created: " << fileToTriggerURL; file.close(); } else { - qxtLog->debug() << "[gui] Creation of " << fileToTriggerURL << " failed!"; + qxtLog->debug() << "[gui] Creation of " << fileToTriggerURL + << " failed!"; qxtLog->debug() << "[gui] Exiting in 5 seconds..."; QTimer::singleShot(5000, this, SLOT(close())); } @@ -153,7 +157,7 @@ void fbgui::watchForTrigger() { // watch the path to trigger file qxtLog->debug() << "[watcher] Watching " << fileToTriggerURL; _watcher = new QFileSystemWatcher(QStringList(fileToTriggerURL), this); - QObject::connect(_watcher, SIGNAL(fileChanged(const QString&)), this, SLOT(prepareURLLoad())); +QObject::connect(_watcher, SIGNAL(fileChanged(const QString&)), this, SLOT(prepareURLLoad())); } //------------------------------------------------------------------------------------------- @@ -225,12 +229,19 @@ void fbgui::loadURL() { void fbgui::loadURLDone(bool success) { // done contains the success of the loading: false / true if (!success) { - qxtLog->debug() << "[gui] Loading failed. URL: " << _webView->url().toString(); + qxtLog->debug() << "[gui] Loading failed. URL: " + << _webView->url().toString(); qxtLog->debug() << "[gui] Exiting in 5 seconds..."; QTimer::singleShot(5000, this, SLOT(close())); - } - else { + } else { qxtLog->debug() << "[gui] Loaded URL: " << _webView->url().toString(); + // if loadsystem, start prepareKexec() + if (_webView->url() == QUrl("qrc:/html/loadystem.html")) { + qxtLog->debug() << "aosidhailshlashgajglkahgäolh"; + qxtLog->debug() << "aosidhailshlashgajglkahgäolh"; + qxtLog->debug() << "aosidhailshlashgajglkahgäolh"; + prepareKexec(); + } } } //------------------------------------------------------------------------------------------- @@ -384,7 +395,8 @@ void fbgui::prepareKexec() { // 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() + "\""; + + downloadPath.toUtf8() + "/initramfs --append=\"" + kcl.toUtf8() + + "\""; qxtLog->debug() << "[gui] kexec cmdline: " << cmdline; process->start(cmdline); bool ret = process->waitForFinished(); @@ -398,8 +410,10 @@ void fbgui::prepareKexec() { // if process successfully finished, try to run kexec -e runKexec(); } else { - qxtLog->debug() << "[gui] Skipping execution of kexec - open debug shell."; - qxtLog->debug() << "[gui] To start the system execute \"kexec -e\" in your shell."; + qxtLog->debug() + << "[gui] Skipping execution of kexec - open debug shell."; + qxtLog->debug() + << "[gui] To start the system execute \"kexec -e\" in your shell."; close(); } } @@ -466,10 +480,11 @@ void fbgui::toggleDebugConsole() { //------------------------------------------------------------------------------------------- // //------------------------------------------------------------------------------------------- -void fbgui::loadSystem() { +void fbgui::showLoadSystem() { //show loading system page. + _webView->disconnect(this); + QObject::connect(_webView, SIGNAL(loadFinished(bool)), this, SLOT(prepareKexec())); _webView->load(QUrl("qrc:/html/loadsystem.html")); - prepareKexec(); } //------------------------------------------------------------------------------------------- void fbgui::quitFailure() { -- cgit v1.2.3-55-g7522