From 29ffc91c35fd770eb965bb2572f729e3b15b7c6e Mon Sep 17 00:00:00 2001 From: joe Date: Thu, 21 Apr 2011 15:17:09 +0200 Subject: fbgui class doxigen comments (to test...) --- src/fbgui.cpp | 56 +++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file 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... } } -- cgit v1.2.3-55-g7522 From c95ab785a56ab739576b1fee9c4bc989dad09775 Mon Sep 17 00:00:00 2001 From: joe Date: Thu, 21 Apr 2011 17:22:52 +0200 Subject: mainboard serial formatting if empty --- src/fbgui.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/fbgui.cpp b/src/fbgui.cpp index fd6f5fa..760a490 100644 --- a/src/fbgui.cpp +++ b/src/fbgui.cpp @@ -245,7 +245,12 @@ QByteArray fbgui::generatePOSTData() { SysInfo si; QByteArray data(si.getInfo("mac").toUtf8()); // append mainboard serial to the mac address for more unique hardwarehash - data.append(si.getInfo("mbserial").toUtf8()); + QByteArray mbserial(si.getInfo("mbserial").toUtf8()); + if (!mbserial.isEmpty()) + data.append(mbserial); + else { + qxtLog->debug() << "[gui] Mainboard serial was empty. Not appending..."; + } qxtLog->debug() << "[post] Hashing: " << data; // generate MD5 hash of data QByteArray hash = QCryptographicHash::hash(data, QCryptographicHash::Md5); -- cgit v1.2.3-55-g7522 From 7cb508eb877ae0a696427073b1105ee8d9c19876 Mon Sep 17 00:00:00 2001 From: joe Date: Thu, 21 Apr 2011 23:35:02 +0200 Subject: uniformed ident 3-spaced.... --- src/downloadmanager.cpp | 338 ++++++++++++++--------------- src/downloadmanager.h | 78 +++---- src/fbgui.cpp | 513 ++++++++++++++++++++++---------------------- src/fbgui.h | 121 ++++++----- src/javascriptinterface.cpp | 120 +++++------ src/javascriptinterface.h | 70 +++--- src/loggerengine.cpp | 105 ++++----- src/loggerengine.h | 34 +-- src/main.cpp | 358 +++++++++++++++---------------- src/sysinfo.cpp | 332 ++++++++++++++-------------- src/sysinfo.h | 30 +-- src/sysinfolibsysfs.cpp | 220 +++++++++---------- src/sysinfolibsysfs.h | 17 +- 13 files changed, 1164 insertions(+), 1172 deletions(-) diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index c772776..1be8964 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -4,216 +4,212 @@ int DownloadManager::downloaded = 0; // ------------------------------------------------------------------------------------------------------- DownloadManager::DownloadManager() { - qxtLog->debug() << "Initializing download manager..."; - checkDownloadDirectory(); - _qnam = new QNetworkAccessManager(); - //_qnam->moveToThread(&dmThread); - dip = false; + qxtLog->debug() << "Initializing download manager..."; + checkDownloadDirectory(); + _qnam = new QNetworkAccessManager(); + //_qnam->moveToThread(&dmThread); + dip = false; } DownloadManager::~DownloadManager() { - delete _qnam; + delete _qnam; } // ------------------------------------------------------------------------------------------------------- void DownloadManager::checkDownloadDirectory() { - // check if downloadPath exists, if not create it. - downloadDir = QDir(downloadPath); - if (!downloadDir.exists()) { - qxtLog->debug() << "[dm] Download directory: " << downloadDir.path() - << " doesn't exist."; - // try to create the directory - if (QDir::current().mkdir(downloadPath)) - qxtLog->debug() << "[dm] Created download directory: " - << downloadDir.path(); - else { - qxtLog->debug() << "[dm] Failed to create directory: " - << downloadDir.path(); - // try to save to /tmp/fbgui - downloadDir.setPath(QDir::tempPath() + "/fbgui"); - if (!downloadDir.exists()) { - if (QDir::current().mkdir(QDir::tempPath() + "/fbgui")) - qxtLog->debug() << "[dm] Successfully created: " - << downloadDir.absolutePath(); - else { - // just in case - qxtLog->debug() << "[dm] Failed to create: " - << downloadDir.absolutePath(); - qxtLog->debug() << "[dm] Exiting..."; - exit( EXIT_FAILURE); - } - } else - qxtLog->debug() << "[dm] " << downloadDir.absolutePath() - << " already exists."; - } - } else - qxtLog->debug() << "[dm] Download directory: " - << downloadDir.absolutePath() << " already exists."; + // check if downloadPath exists, if not create it. + downloadDir = QDir(downloadPath); + if (!downloadDir.exists()) { + qxtLog->debug() << "[dm] Download directory: " << downloadDir.path() + << " doesn't exist."; + // try to create the directory + if (QDir::current().mkdir(downloadPath)) + qxtLog->debug() << "[dm] Created download directory: " + << downloadDir.path(); + else { + qxtLog->debug() << "[dm] Failed to create directory: " + << downloadDir.path(); + // try to save to /tmp/fbgui + downloadDir.setPath(QDir::tempPath() + "/fbgui"); + if (!downloadDir.exists()) { + if (QDir::current().mkdir(QDir::tempPath() + "/fbgui")) + qxtLog->debug() << "[dm] Successfully created: " + << downloadDir.absolutePath(); + else { + // just in case + qxtLog->debug() << "[dm] Failed to create: " + << downloadDir.absolutePath(); + qxtLog->debug() << "[dm] Exiting..."; + exit( EXIT_FAILURE); + } + } else + qxtLog->debug() << "[dm] " << downloadDir.absolutePath() + << " already exists."; + } + } else + qxtLog->debug() << "[dm] Download directory: " + << downloadDir.absolutePath() << " already exists."; - qxtLog->debug() << "[dm] Saving downloads to: " - << downloadDir.absolutePath(); - downloadPath = downloadDir.absolutePath(); + qxtLog->debug() << "[dm] Saving downloads to: " + << downloadDir.absolutePath(); + downloadPath = downloadDir.absolutePath(); } // ------------------------------------------------------------------------------------------------------- // Public access // ------------------------------------------------------------------------------------------------------- void DownloadManager::downloadFile(const QString& filename) { - QUrl fileUrl(baseURL.resolved(QUrl(filename))); - this->processDownloadRequest(fileUrl); + QUrl fileUrl(baseURL.resolved(QUrl(filename))); + this->processDownloadRequest(fileUrl); } // ------------------------------------------------------------------------------------------------------- void DownloadManager::downloadFile(const QUrl& fileUrl) { - this->processDownloadRequest(fileUrl); + this->processDownloadRequest(fileUrl); } // ------------------------------------------------------------------------------------------------------- // Private functions handling download requests and queueing // ------------------------------------------------------------------------------------------------------- void DownloadManager::processDownloadRequest(const QUrl& url) { - if (url.isEmpty()) { - qxtLog->debug() << "[dm] No URL specified for download."; - return; - } - qxtLog->debug() << "[dm] Enqueueing: " << url.toString(); - dlQ.enqueue(url); - if (dip) { - // download in progress, return. - qxtLog->debug() << "[dm] Download in progress! Queued:" - << url.toString() << "(" << dlQ.size() << " in queue)"; - return; - } - // no running downloads: start next in queue - startNextDownload(); + if (url.isEmpty()) { + qxtLog->debug() << "[dm] No URL specified for download."; + return; + } + qxtLog->debug() << "[dm] Enqueueing: " << url.toString(); + dlQ.enqueue(url); + if (dip) { + // download in progress, return. + qxtLog->debug() << "[dm] Download in progress! Queued:" << url.toString() + << "(" << dlQ.size() << " in queue)"; + return; + } + // no running downloads: start next in queue + startNextDownload(); } // ------------------------------------------------------------------------------------------------------- void DownloadManager::startNextDownload() { - QWSServer::instance()->setCursorVisible(false); - if (dlQ.isEmpty()) { - emit downloadQueueEmpty(); - qxtLog->debug() << "[dm] Download manager ready. (1)"; - return; - } - qxtLog->debug() << "[dm] Starting next download: " << dlQ.head().toString() - << " (" << dlQ.size() - 1 << " in queue.)"; + QWSServer::instance()->setCursorVisible(false); + if (dlQ.isEmpty()) { + emit downloadQueueEmpty(); + qxtLog->debug() << "[dm] Download manager ready. (1)"; + return; + } + qxtLog->debug() << "[dm] Starting next download: " << dlQ.head().toString() + << " (" << dlQ.size() - 1 << " in queue.)"; - // dequeue next URL to download. - QUrl url = dlQ.dequeue(); + // dequeue next URL to download. + QUrl url = dlQ.dequeue(); - // get filename from URL. - QString tmp = url.path(); - tmp.remove(0, tmp.lastIndexOf(QChar('/')) + 1); + // get filename from URL. + QString tmp = url.path(); + tmp.remove(0, tmp.lastIndexOf(QChar('/')) + 1); - // check if filename exists on target file system - if (downloadDir.exists(tmp)) { - qxtLog->debug() << "[dm] File already exists: " - << downloadDir.absoluteFilePath(tmp); - outfile.setFileName( - QString(downloadDir.absolutePath() + "/" + tmp + ".\%1").arg( - downloaded)); - } else - outfile.setFileName(downloadDir.absoluteFilePath(tmp)); - qxtLog->debug() << "[dm] Saving to: " << outfile.fileName(); + // check if filename exists on target file system + if (downloadDir.exists(tmp)) { + qxtLog->debug() << "[dm] File already exists: " + << downloadDir.absoluteFilePath(tmp); + outfile.setFileName(QString(downloadDir.absolutePath() + "/" + tmp + + ".\%1").arg(downloaded)); + } else + outfile.setFileName(downloadDir.absoluteFilePath(tmp)); + qxtLog->debug() << "[dm] Saving to: " << outfile.fileName(); - // try to open for writing - if (!outfile.open(QIODevice::WriteOnly)) { - qxtLog->debug() << "[dm] No write access to " << outfile.fileName() - << " . Skipping download..."; - return; - } + // try to open for writing + if (!outfile.open(QIODevice::WriteOnly)) { + qxtLog->debug() << "[dm] No write access to " << outfile.fileName() + << " . Skipping download..."; + return; + } - // send the request for the file - QNetworkRequest request(url); - currentDownload = _qnam->get(request); - lastProgress = 0; - currentProgress = 0; - dip = true; - _time.start(); - QObject::connect(currentDownload, SIGNAL(readyRead()), this, - SLOT(downloadReady())); - QObject::connect(currentDownload, SIGNAL(metaDataChanged()), this, - SLOT(processMetaInfo())); - QObject::connect(currentDownload, SIGNAL(downloadProgress(qint64, qint64)), - this, SLOT(downloadProgress(qint64, qint64))); - QObject::connect(currentDownload, SIGNAL(finished()), this, - SLOT(downloadFinished())); + // send the request for the file + QNetworkRequest request(url); + currentDownload = _qnam->get(request); + lastProgress = 0; + currentProgress = 0; + dip = true; + _time.start(); + QObject::connect(currentDownload, SIGNAL(readyRead()), this, SLOT( + downloadReady())); + QObject::connect(currentDownload, SIGNAL(metaDataChanged()), this, SLOT( + processMetaInfo())); + QObject::connect(currentDownload, SIGNAL(downloadProgress(qint64, qint64)), + this, SLOT(downloadProgress(qint64, qint64))); + QObject::connect(currentDownload, SIGNAL(finished()), this, SLOT( + downloadFinished())); } // ------------------------------------------------------------------------------------------------------- // Private slots to handle a download in progress // ------------------------------------------------------------------------------------------------------- void DownloadManager::processMetaInfo() { - // fetch filesize from header & filename from URL (for now) - const QByteArray cltag = "Content-Length"; - QByteArray clinfo = currentDownload->rawHeader(cltag); - QFileInfo fi(outfile); - qxtLog->debug() << "[dm] Download Info: " << fi.fileName() << " (Size: " - << clinfo.toDouble() << ")"; - emit downloadInfo(fi.fileName(), clinfo.toDouble()); + // fetch filesize from header & filename from URL (for now) + const QByteArray cltag = "Content-Length"; + QByteArray clinfo = currentDownload->rawHeader(cltag); + QFileInfo fi(outfile); + qxtLog->debug() << "[dm] Download Info: " << fi.fileName() << " (Size: " + << clinfo.toDouble() << ")"; + emit downloadInfo(fi.fileName(), clinfo.toDouble()); } // ------------------------------------------------------------------------------------------------------- void DownloadManager::downloadReady() { - // data ready, save it - outfile.write(currentDownload->readAll()); + // data ready, save it + outfile.write(currentDownload->readAll()); } // ------------------------------------------------------------------------------------------------------- void DownloadManager::downloadProgress(qint64 bytesIn, qint64 bytesTotal) { - if (bytesIn > bytesTotal || bytesTotal <= 0) { - qxtLog->debug() << "[dm] downloadProgress invalid values:" << "In:" - << bytesIn << " / Total: " << bytesTotal; - return; - } - // calculate current speed - double speed = bytesIn * 1000 / _time.elapsed(); - QString unit; - if (speed < 1024) { - unit = "bytes/sec"; - } else if (speed < 1024 * 1024) { - speed /= 1024; - unit = "KB/s"; - } else { - speed /= 1024 * 1024; - unit = "MB/s"; - } - // update progress only if difference higher than the updateInterval setting - currentProgress = ((bytesIn * 100) / bytesTotal); - if (currentProgress - lastProgress >= updateInterval) { - lastProgress = currentProgress; - emit - updateProgress(currentProgress, speed, unit); - qxtLog->debug() << "[dm] Download progress of " - << currentDownload->url().toString() << ": " << bytesIn << "/" - << bytesTotal << "(" << currentProgress << "\%)"; - } + if (bytesIn > bytesTotal || bytesTotal <= 0) { + qxtLog->debug() << "[dm] downloadProgress invalid values:" << "In:" + << bytesIn << " / Total: " << bytesTotal; + return; + } + // calculate current speed + double speed = bytesIn * 1000 / _time.elapsed(); + QString unit; + if (speed < 1024) { + unit = "bytes/sec"; + } else if (speed < 1024 * 1024) { + speed /= 1024; + unit = "KB/s"; + } else { + speed /= 1024 * 1024; + unit = "MB/s"; + } + // update progress only if difference higher than the updateInterval setting + currentProgress = ((bytesIn * 100) / bytesTotal); + if (currentProgress - lastProgress >= updateInterval) { + lastProgress = currentProgress; + emit updateProgress(currentProgress, speed, unit); + qxtLog->debug() << "[dm] Download progress of " + << currentDownload->url().toString() << ": " << bytesIn << "/" + << bytesTotal << "(" << currentProgress << "\%)"; + } } // ------------------------------------------------------------------------------------------------------- void DownloadManager::downloadFinished() { - // check for errors - if (currentDownload->error()) { - outfile.close(); - outfile.remove(); - int statusCode = currentDownload->attribute( - QNetworkRequest::HttpStatusCodeAttribute).toInt(); - qxtLog->debug() << "[dm] Download of " - << currentDownload->url().toString() - << " failed with HTTP error code: " << statusCode; - emit - notify(QString("Download failed! HTTP Status Code: %1").arg(statusCode)); - currentDownload->deleteLater(); - } else { - // end download - outfile.close(); - downloaded++; - qxtLog->debug() << "[dm] Download of " - << currentDownload->url().toString() - << " finished. (downloaded = " << downloaded << ")"; - emit - notify( - QString("Successfully downloaded %1").arg( - currentDownload->url().toString())); - currentDownload->deleteLater(); - } - dip = false; - // process next in queue, if any - if (dlQ.isEmpty()) { - emit downloadQueueEmpty(); - qxtLog->debug() << "[dm] Download manager ready. (2)"; - return; - } - startNextDownload(); + // check for errors + if (currentDownload->error()) { + outfile.close(); + outfile.remove(); + int statusCode = currentDownload->attribute( + QNetworkRequest::HttpStatusCodeAttribute).toInt(); + qxtLog->debug() << "[dm] Download of " + << currentDownload->url().toString() + << " failed with HTTP error code: " << statusCode; + emit notify(QString("Download failed! HTTP Status Code: %1").arg( + statusCode)); + currentDownload->deleteLater(); + } else { + // end download + outfile.close(); + downloaded++; + qxtLog->debug() << "[dm] Download of " + << currentDownload->url().toString() << " finished. (downloaded = " + << downloaded << ")"; + emit notify(QString("Successfully downloaded %1").arg( + currentDownload->url().toString())); + currentDownload->deleteLater(); + } + dip = false; + // process next in queue, if any + if (dlQ.isEmpty()) { + emit downloadQueueEmpty(); + qxtLog->debug() << "[dm] Download manager ready. (2)"; + return; + } + startNextDownload(); } diff --git a/src/downloadmanager.h b/src/downloadmanager.h index a7afe23..dfb4d03 100644 --- a/src/downloadmanager.h +++ b/src/downloadmanager.h @@ -33,53 +33,53 @@ class DownloadManager: public QObject { Q_OBJECT public: - DownloadManager(); - ~DownloadManager(); - QTime _time; + DownloadManager(); + ~DownloadManager(); + QTime _time; private: - // checks for valid download directory, ran once in constructor - void checkDownloadDirectory(); - // private control function for queueing mechanism. - void processDownloadRequest(const QUrl& url); + // checks for valid download directory, ran once in constructor + void checkDownloadDirectory(); + // private control function for queueing mechanism. + void processDownloadRequest(const QUrl& url); - // base objects for downloading - QNetworkAccessManager* _qnam; - QQueue dlQ; - QNetworkReply* currentDownload; - QFile outfile; - QDir downloadDir; - // download progress variables - int currentProgress, lastProgress; - // download in progress flag - bool dip; - // static counter - static int downloaded; + // base objects for downloading + QNetworkAccessManager* _qnam; + QQueue dlQ; + QNetworkReply* currentDownload; + QFile outfile; + QDir downloadDir; + // download progress variables + int currentProgress, lastProgress; + // download in progress flag + bool dip; + // static counter + static int downloaded; -signals: - // notify sends a message to the javascript interface to be evaluated there - void notify(const QString& msg); - // downloadInfo sends static information (name, size) to the interface. - void downloadInfo(const QString& filename, const double& filesize); - // updateProgress sends download progress information to the interface. - void updateProgress(const int& percent, const double& speed, - const QString& unit); - // signal emitted when download queue is empty. - void downloadQueueEmpty(); + signals: + // notify sends a message to the javascript interface to be evaluated there + void notify(const QString& msg); + // downloadInfo sends static information (name, size) to the interface. + void downloadInfo(const QString& filename, const double& filesize); + // updateProgress sends download progress information to the interface. + void updateProgress(const int& percent, const double& speed, + const QString& unit); + // signal emitted when download queue is empty. + void downloadQueueEmpty(); public slots: - // public slots to receive download requests. - void downloadFile(const QUrl& fileUrl); - // convenience function - void downloadFile(const QString& fileUrl); + // public slots to receive download requests. + void downloadFile(const QUrl& fileUrl); + // convenience function + void downloadFile(const QString& fileUrl); private slots: - // private slots to manage the downloading process - void startNextDownload(); - void processMetaInfo(); - void downloadReady(); - void downloadProgress(qint64 bytesIn, qint64 bytesTotal); - void downloadFinished(); + // private slots to manage the downloading process + void startNextDownload(); + void processMetaInfo(); + void downloadReady(); + void downloadProgress(qint64 bytesIn, qint64 bytesTotal); + void downloadFinished(); }; #endif // DOWNLOADMANAGER_H diff --git a/src/fbgui.cpp b/src/fbgui.cpp index 760a490..fdedf1f 100644 --- a/src/fbgui.cpp +++ b/src/fbgui.cpp @@ -33,63 +33,62 @@ int debugMode = -1; * @see DownloadManager */ fbgui::fbgui() { - // test for libsys function - //SysInfoLibsysfs* sil = new SysInfoLibsysfs(); - //sil->getInfoAboutNetworkInterface(); - //sil->getInfoMainboardSerial(); - //SysInfo si; - //qxtLog->debug() << si.getInfo("mbserial"); - //si.getInfo("usb"); + // test for libsys function + //SysInfoLibsysfs* sil = new SysInfoLibsysfs(); + //sil->getInfoAboutNetworkInterface(); + //sil->getInfoMainboardSerial(); + //SysInfo si; + //qxtLog->debug() << si.getInfo("mbserial"); + //si.getInfo("usb"); - setupLayout(); - createActions(); + setupLayout(); + createActions(); - // initialize javascript interface - 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())); + // initialize javascript interface + 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())); - // initialize download manager - DownloadManager* dm = new DownloadManager(); - QObject::connect(dm, SIGNAL(downloadInfo(const QString&, const double&)), - jsi, SLOT(downloadInfo(const QString&, const double&))); - QObject::connect(dm, SIGNAL(notify(const QString&)), jsi, - SLOT(notify(const QString&))); - QObject::connect(jsi, SIGNAL(requestFile(const QString&)), dm, - 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( - prepareKexec())); + // initialize download manager + DownloadManager* dm = new DownloadManager(); + QObject::connect(dm, SIGNAL(downloadInfo(const QString&, const double&)), + jsi, SLOT(downloadInfo(const QString&, const double&))); + QObject::connect(dm, SIGNAL(notify(const QString&)), jsi, + SLOT(notify(const QString&))); + QObject::connect(jsi, SIGNAL(requestFile(const QString&)), dm, + 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(prepareKexec())); - // move download manager to its own thread - //dm->moveToThread(&dmThread); - //dmThread.start(); + // move download manager to its own thread + //dm->moveToThread(&dmThread); + //dmThread.start(); - //_webView->page()->networkAccessManager()->setCookieJar(new QNetworkCookieJar); - // show page - _webView->load(QUrl("qrc:/html/preload.html")); - // start watching for fileToTriggerURL - watchForTrigger(); - //if (checkHost()) loadURL(); + // show "waiting for internet" page until triggered. + _webView->load(QUrl("qrc:/html/preload.html")); + //statusBar()->showMessage("Waiting for internet..."); + // start watching for fileToTriggerURL + watchForTrigger(); - // set properties - setWindowTitle("fbgui"); - setAttribute(Qt::WA_QuitOnClose, true); - setWindowFlags(Qt::FramelessWindowHint); - showFullScreen(); + // set properties + setWindowTitle("fbgui"); + setAttribute(Qt::WA_QuitOnClose, true); + setWindowFlags(Qt::FramelessWindowHint); + showFullScreen(); } fbgui::~fbgui() { - //dmThread.quit(); + //dmThread.quit(); } //------------------------------------------------------------------------------------------- // Layout / actions setup @@ -103,28 +102,28 @@ fbgui::~fbgui() { * out console */ void fbgui::setupLayout() { - // setup layout of the gui: debug split or browser - _webView = new QWebView(this); - if (debugMode == 1) { - // split main window in browser & debug console - createDebugConsole(); - _splitter = new QSplitter(Qt::Vertical, this); - _splitter->addWidget(_webView); - _splitter->addWidget(_debugConsole); - setCentralWidget(_splitter); - } else - setCentralWidget(_webView); + // setup layout of the gui: debug split or browser + _webView = new QWebView(this); + if (debugMode == 1) { + // split main window in browser & debug console + createDebugConsole(); + _splitter = new QSplitter(Qt::Vertical, this); + _splitter->addWidget(_webView); + _splitter->addWidget(_debugConsole); + setCentralWidget(_splitter); + } else + setCentralWidget(_webView); } //------------------------------------------------------------------------------------------- /** * This method enables a shortcut for closing the program. + * The shortcut itself is not configurable: CTRL + X */ void fbgui::createActions() { - // CTRL + X to kill the gui - _quit = new QAction(tr("&quit"), this); - _quit->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_X)); - this->addAction(_quit); - connect(_quit, SIGNAL(triggered()), this, SLOT(close())); + _quit = new QAction(tr("&quit"), this); + _quit->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_X)); + this->addAction(_quit); + connect(_quit, SIGNAL(triggered()), this, SLOT(close())); } //------------------------------------------------------------------------------------------- // File system watching @@ -139,29 +138,28 @@ void fbgui::createActions() { * */ void fbgui::watchForTrigger() { - // check if fileToTriggerURL already exists - QFile file(fileToTriggerURL); - if (file.exists()) { - qxtLog->debug() << "[watcher] " << fileToTriggerURL - << " exists already!"; - // try to load URL - loadURL(); - } else { - // create it - if (file.open(QIODevice::WriteOnly)) { - qxtLog->debug() << "[gui] Created: " << fileToTriggerURL; - file.close(); - } else { - qxtLog->debug() << "[gui] Creation of " << fileToTriggerURL - << " failed! Exiting..."; - exit( EXIT_FAILURE); - } - } - // watch the path where trigger file is expected - qxtLog->debug() << "[watcher] Watching " << fileToTriggerURL; - _watcher = new QFileSystemWatcher(QStringList(fileToTriggerURL), this); + // check if fileToTriggerURL already exists + QFile file(fileToTriggerURL); + if (file.exists()) { + qxtLog->debug() << "[watcher] " << fileToTriggerURL << " found."; + // try to load URL + loadURL(); + } else { + // create it + if (file.open(QIODevice::WriteOnly)) { + qxtLog->debug() << "[gui] Created: " << fileToTriggerURL; + file.close(); + } else { + qxtLog->debug() << "[gui] Creation of " << fileToTriggerURL + << " failed! Exiting..."; + exit( EXIT_FAILURE); + } + } + // 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())); + SLOT(prepareURLLoad())); } //------------------------------------------------------------------------------------------- @@ -176,13 +174,13 @@ QObject::connect(_watcher, SIGNAL(fileChanged(const QString&)), this, * @see fbgui::loadURL() */ void fbgui::prepareURLLoad() { - qxtLog->debug() << "[watcher] " << fileToTriggerURL << " changed!"; - // disconnect _watcher, his job is done - qxtLog->debug() << "[watcher] disconnected."; - _watcher->disconnect(this); - _watcher->deleteLater(); - // try to load URL - loadURL(); + qxtLog->debug() << "[watcher] " << fileToTriggerURL << " changed!"; + // disconnect _watcher, his job is done + qxtLog->debug() << "[watcher] disconnected."; + _watcher->disconnect(this); + _watcher->deleteLater(); + // try to load URL + loadURL(); } //------------------------------------------------------------------------------------------- // Preparations for URL load @@ -193,16 +191,15 @@ void fbgui::prepareURLLoad() { * This method checks if is connected to the internet. */ bool fbgui::checkHost() const { - QHostInfo hostInfo = QHostInfo::fromName(baseURL.host()); - if (hostInfo.error() != QHostInfo::NoError) { - qxtLog->debug() << "[gui] Lookup of " << baseURL.host() - << "failed. Exiting..."; - return false; - } else { - qxtLog->debug() << "[gui] Lookup of " << baseURL.host() - << " succeeded."; - return true; - } + QHostInfo hostInfo = QHostInfo::fromName(baseURL.host()); + if (hostInfo.error() != QHostInfo::NoError) { + qxtLog->debug() << "[gui] Lookup of " << baseURL.host() + << "failed. Exiting..."; + return false; + } else { + qxtLog->debug() << "[gui] Lookup of " << baseURL.host() << " succeeded."; + return true; + } } //------------------------------------------------------------------------------------------- /** @@ -216,15 +213,17 @@ bool fbgui::checkHost() const { * @see fbgui::generatePOSTData() */ void fbgui::loadURL() { - if (checkHost()) { - qxtLog->debug() << "[gui] Loading URL..."; - QByteArray postData = generatePOSTData(); - QNetworkRequest req(baseURL); - // show arrow cursor - QWSServer::instance()->setCursorVisible(true); - //qApp->setOverrideCursor(QCursor(Qt::ArrowCursor)); - _webView->load(req, QNetworkAccessManager::PostOperation, postData); - } + if (checkHost()) { + qxtLog->debug() << "[gui] Loading URL..."; + + // Generate POST identification data needed by PBS. + QByteArray postData = generatePOSTData(); + QNetworkRequest req(baseURL); + + // show cursor again since user is about to interact. + QWSServer::instance()->setCursorVisible(true); + _webView->load(req, QNetworkAccessManager::PostOperation, postData); + } } //------------------------------------------------------------------------------------------- /** @@ -240,85 +239,43 @@ void fbgui::loadURL() { * @see SysInfo::getMainboardSerial() */ QByteArray fbgui::generatePOSTData() { - qxtLog->debug() << "[gui] Generating POST data..."; - // use MAC address as base data - SysInfo si; - QByteArray data(si.getInfo("mac").toUtf8()); - // append mainboard serial to the mac address for more unique hardwarehash - QByteArray mbserial(si.getInfo("mbserial").toUtf8()); - if (!mbserial.isEmpty()) - data.append(mbserial); - else { - qxtLog->debug() << "[gui] Mainboard serial was empty. Not appending..."; - } - qxtLog->debug() << "[post] Hashing: " << data; - // generate MD5 hash of data - QByteArray hash = QCryptographicHash::hash(data, QCryptographicHash::Md5); - qxtLog->debug() << "[post] MD5 Hash: " << hash.toHex(); + qxtLog->debug() << "[gui] Generating POST data..."; + // use MAC address as base data + SysInfo si; + QByteArray data(si.getInfo("mac").toUtf8()); + // append mainboard serial to the mac address for more unique hardwarehash + QByteArray mbserial(si.getInfo("mbserial").toUtf8()); + if (!mbserial.isEmpty()) + data.append(mbserial); + else { + qxtLog->debug() << "[gui] Mainboard serial was empty. Not appending..."; + } + qxtLog->debug() << "[post] Hashing: " << data; + // generate MD5 hash of data + QByteArray hash = QCryptographicHash::hash(data, QCryptographicHash::Md5); + qxtLog->debug() << "[post] MD5 Hash: " << hash.toHex(); - // fetch serial number from usb - QByteArray serial; - QFile file(serialLocation); - if (!file.open(QIODevice::ReadOnly)) { - qxtLog->debug() << "[post] No such file: " << file.fileName(); - } - // everything ok, read data - serial = file.readAll(); - file.close(); - serial.chop(1); // chop EOF - qxtLog->debug() << "[post] Serial number is: " << serial; + // fetch serial number from usb + QByteArray serial; + QFile file(serialLocation); + if (!file.open(QIODevice::ReadOnly)) { + qxtLog->debug() << "[post] No such file: " << file.fileName(); + } + // everything ok, read data + serial = file.readAll(); + file.close(); + serial.chop(1); // chop EOF + qxtLog->debug() << "[post] Serial number is: " << serial; - // construct final byte array - QByteArray postData("mac="); - postData.append(si.getInfo("mac")); - postData.append("&hardwarehash=" + hash.toHex()); - postData.append("&serialnumber=" + serial); - qxtLog->debug() << "[post] POST data: " << postData; - return postData; -} -//------------------------------------------------------------------------------------------- -// 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); - _debugConsole->setWindowFlags(Qt::FramelessWindowHint); - // fanciness - QPalette pal; - pal.setColor(QPalette::Base, Qt::black); - _debugConsole->setPalette(pal); - _debugConsole->setTextColor(Qt::white); - // enable custom logger engine - qxtLog->addLoggerEngine("fb_logger", new LoggerEngine_fb(_debugConsole)); - //qxtLog->initLoggerEngine("fb_logger"); - qxtLog->setMinimumLevel("fb_logger", QxtLogger::DebugLevel); - // CTRL + D toggles debug window - _toggleDebugConsole = new QAction(tr("&toggleDebug"), this); - _toggleDebugConsole->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D)); - addAction(_toggleDebugConsole); - connect(_toggleDebugConsole, SIGNAL(triggered()), this, SLOT( - 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(); + // construct final byte array + QByteArray postData("mac="); + postData.append(si.getInfo("mac")); + postData.append("&hardwarehash=" + hash.toHex()); + postData.append("&serialnumber=" + serial); + qxtLog->debug() << "[post] POST data: " << postData; + return postData; } + //------------------------------------------------------------------------------------------- // System Calls Functions //------------------------------------------------------------------------------------------- @@ -338,14 +295,13 @@ void fbgui::toggleDebugConsole() { * @see JavascriptInterface::shutDown() */ void fbgui::performShutDown() { - QFile file("/proc/sysrq-trigger"); - if (file.open(QIODevice::WriteOnly)) { - file.write("o"); - file.close(); - } - else { - qxtLog->debug() << "[gui] Could not open /proc/sysrq-trigger"; - } + QFile file("/proc/sysrq-trigger"); + if (file.open(QIODevice::WriteOnly)) { + file.write("o"); + file.close(); + } else { + qxtLog->debug() << "[gui] Could not open /proc/sysrq-trigger"; + } } //------------------------------------------------------------------------------------------- /** @@ -362,14 +318,13 @@ void fbgui::performShutDown() { * @see JavascriptInterface::reboot() */ void fbgui::performReboot() { - QFile file("/proc/sysrq-trigger"); - if (file.open(QIODevice::WriteOnly)) { - file.write("b"); - file.close(); - } - else { - qxtLog->debug() << "[gui] Could not open /proc/sysrq-trigger"; - } + QFile file("/proc/sysrq-trigger"); + if (file.open(QIODevice::WriteOnly)) { + file.write("b"); + file.close(); + } else { + qxtLog->debug() << "[gui] Could not open /proc/sysrq-trigger"; + } } //------------------------------------------------------------------------------------------- // Preparing System Boot (Stage 3) @@ -383,55 +338,55 @@ void fbgui::performReboot() { */ void fbgui::prepareKexec() { - // 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. - QString kcl = file.readAll(); - file.close(); - qxtLog->debug() << "[gui] KCL from PBS: " << kcl; + // 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. + QString kcl = file.readAll(); + file.close(); + qxtLog->debug() << "[gui] KCL from PBS: " << kcl; - // 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; + // 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; + // 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() - + "\""; - qxtLog->debug() << "[gui] kexec cmdline: " << cmdline; - process->start(cmdline); - bool ret = process->waitForFinished(); - if (!ret) { - qxtLog->debug() << "[sysinfo] Failed to load kexec! Exiting..."; - exit( EXIT_FAILURE); - } else { - qxtLog->debug() << "[gui] Kexec load successfull."; - if (debugMode < 0) { - // 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."; - close(); - } - } + // 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() + + "\""; + qxtLog->debug() << "[gui] kexec cmdline: " << cmdline; + process->start(cmdline); + bool ret = process->waitForFinished(); + if (!ret) { + qxtLog->debug() << "[sysinfo] Failed to load kexec! Exiting..."; + exit( EXIT_FAILURE); + } else { + qxtLog->debug() << "[gui] Kexec load successfull."; + if (debugMode < 0) { + // 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."; + close(); + } + } } //------------------------------------------------------------------------------------------- /** @@ -442,11 +397,53 @@ void fbgui::prepareKexec() { * */ 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... - } + 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... + } +} +//------------------------------------------------------------------------------------------- +// 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); + _debugConsole->setWindowFlags(Qt::FramelessWindowHint); + // fanciness + QPalette pal; + pal.setColor(QPalette::Base, Qt::black); + _debugConsole->setPalette(pal); + _debugConsole->setTextColor(Qt::white); + // enable custom logger engine + qxtLog->addLoggerEngine("fb_logger", new LoggerEngine_fb(_debugConsole)); + //qxtLog->initLoggerEngine("fb_logger"); + qxtLog->setMinimumLevel("fb_logger", QxtLogger::DebugLevel); + // CTRL + D toggles debug window + _toggleDebugConsole = new QAction(tr("&toggleDebug"), this); + _toggleDebugConsole->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D)); + addAction(_toggleDebugConsole); + connect(_toggleDebugConsole, SIGNAL(triggered()), this, SLOT( + 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(); } diff --git a/src/fbgui.h b/src/fbgui.h index 891e17a..664eea4 100644 --- a/src/fbgui.h +++ b/src/fbgui.h @@ -44,75 +44,74 @@ extern QUrl baseURL; extern int debugMode; extern int updateInterval; - class fbgui: public QMainWindow { Q_OBJECT public: - fbgui(); - ~fbgui(); + fbgui(); + ~fbgui(); private: - //------------------- - // layout setup: - //------------------- - // Sets the layout depending on the debug mode: - // no debug or debugMode = 0 -> only browser shown. - // debugMode = 1 -> split main window in browser and debug console. - void setupLayout(); - // Create all actions for the GUI. (Currently only quit.) - void createActions(); - // Create a debug console widget as QTextEdit in order to print debug messages - // directly within the GUI. This was needed since ttys can't really be used - // for debugging purposes in the preboot environment. - void createDebugConsole(); - - //---------------------------------------- - // control the display of components: - //---------------------------------------- - // watches for the file triggering the loading of the URL. - // the file can be specified by the corresponding option. - void watchForTrigger(); - bool checkHost() const; - void loadURL(); - QByteArray generatePOSTData(); - - //---------------------------------- - // widgets constituing the gui: - //---------------------------------- - // QWebView for displaying internet content - QWebView* _webView; - // QSplitter to split the main window in two resizable frames. - QSplitter* _splitter; - // QTextEdit implementing a minimalistic debug console. - QTextEdit* _debugConsole; - - //------------------ - // action list: - //------------------ - // closes the main window provoking the application to quit. - QAction* _quit; - // triggers toggleDebugConsole() - QAction* _toggleDebugConsole; - - // watcher to detect changes in the observed directory. - QFileSystemWatcher* _watcher; + //------------------- + // layout setup: + //------------------- + // Sets the layout depending on the debug mode: + // no debug or debugMode = 0 -> only browser shown. + // debugMode = 1 -> split main window in browser and debug console. + void setupLayout(); + // Create all actions for the GUI. (Currently only quit.) + void createActions(); + // Create a debug console widget as QTextEdit in order to print debug messages + // directly within the GUI. This was needed since ttys can't really be used + // for debugging purposes in the preboot environment. + void createDebugConsole(); + + //---------------------------------------- + // control the display of components: + //---------------------------------------- + // watches for the file triggering the loading of the URL. + // the file can be specified by the corresponding option. + void watchForTrigger(); + bool checkHost() const; + void loadURL(); + QByteArray generatePOSTData(); + + //---------------------------------- + // widgets constituing the gui: + //---------------------------------- + // QWebView for displaying internet content + QWebView* _webView; + // QSplitter to split the main window in two resizable frames. + QSplitter* _splitter; + // QTextEdit implementing a minimalistic debug console. + QTextEdit* _debugConsole; + + //------------------ + // action list: + //------------------ + // closes the main window provoking the application to quit. + QAction* _quit; + // triggers toggleDebugConsole() + QAction* _toggleDebugConsole; + + // watcher to detect changes in the observed directory. + QFileSystemWatcher* _watcher; private slots: - // toggles debug console when action _toggleDebugConsole happens. - void toggleDebugConsole(); - - // 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(); - // prepareKexec - void prepareKexec(); - void runKexec(); + // toggles debug console when action _toggleDebugConsole happens. + void toggleDebugConsole(); + + // 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(); + // prepareKexec + void prepareKexec(); + void runKexec(); }; #endif // FBGUI_H diff --git a/src/javascriptinterface.cpp b/src/javascriptinterface.cpp index 66ec7a5..eba4027 100644 --- a/src/javascriptinterface.cpp +++ b/src/javascriptinterface.cpp @@ -12,8 +12,8 @@ * Is of type QWebFrame. */ JavascriptInterface::JavascriptInterface(QWebFrame *parent) { - qxtLog->debug() << "Initializing javascript interface..."; - _parent = parent; + qxtLog->debug() << "Initializing javascript interface..."; + _parent = parent; } //------------------------------------------------------------------------------------------------------- /** @@ -33,8 +33,8 @@ JavascriptInterface::~JavascriptInterface() { /* destructor dummy */ * @see JavascriptInterface::loadJQuery() */ void JavascriptInterface::attachToDOM() { - _parent->addToJavaScriptWindowObject(QString("fbgui"), this); - loadJQuery(); + _parent->addToJavaScriptWindowObject(QString("fbgui"), this); + loadJQuery(); } //------------------------------------------------------------------------------------------------------- /** @@ -49,30 +49,30 @@ void JavascriptInterface::attachToDOM() { * @see JavascriptInterface::attachToDOM() */ void JavascriptInterface::loadJQuery() { - QString js; - QString pathToJsDir(DEFAULT_QRC_HTML_DIR); - pathToJsDir.append("/js"); + QString js; + QString pathToJsDir(DEFAULT_QRC_HTML_DIR); + pathToJsDir.append("/js"); - QDir qrcJSDir(pathToJsDir); - QFileInfoList fiList = qrcJSDir.entryInfoList(); - QFileInfo fi; - foreach(fi, fiList) - { - if (fi.suffix() == "js") { - //qDebug()<< fi.fileName(); - //qxtLog->debug() << fi.fileName(); - if (fi.fileName() != "test.js") { - QFile file; - file.setFileName(pathToJsDir + "/" + fi.fileName()); - file.open(QIODevice::ReadOnly); - js = file.readAll(); - file.close(); + QDir qrcJSDir(pathToJsDir); + QFileInfoList fiList = qrcJSDir.entryInfoList(); + QFileInfo fi; +foreach(fi, fiList) +{ + if (fi.suffix() == "js") { + //qDebug()<< fi.fileName(); + //qxtLog->debug() << fi.fileName(); + if (fi.fileName() != "test.js") { + QFile file; + file.setFileName(pathToJsDir + "/" + fi.fileName()); + file.open(QIODevice::ReadOnly); + js = file.readAll(); + file.close(); - _parent->evaluateJavaScript(js); - //qxtLog->debug() << "evaluated " + fi.fileName(); - } - } - } + _parent->evaluateJavaScript(js); + //qxtLog->debug() << "evaluated " + fi.fileName(); + } + } +} } //------------------------------------------------------------------------------------------------------- // Javascript functions for webpage @@ -85,12 +85,12 @@ void JavascriptInterface::loadJQuery() { * Emits the JavascriptInterface::requestFile(const QString) signal. */ void JavascriptInterface::startDownload(const QString& filename) { - // ignore if empty filename - if (filename.isEmpty()) { - _parent->evaluateJavaScript("alert(\"No filename!\")"); - return; - } - emit requestFile(filename); + // ignore if empty filename + if (filename.isEmpty()) { + _parent->evaluateJavaScript("alert(\"No filename!\")"); + return; + } + emit requestFile(filename); } //------------------------------------------------------------------------------------------------------- /** @@ -102,8 +102,8 @@ void JavascriptInterface::startDownload(const QString& filename) { * @todo add some more informations */ void JavascriptInterface::setCallbackOnFinished(const QString& function) { - qxtLog->debug() << "[jsi] Callback set: " << function; - _callbackOnDownloadsFinished = QString(function); + qxtLog->debug() << "[jsi] Callback set: " << function; + _callbackOnDownloadsFinished = QString(function); } //------------------------------------------------------------------------------------------------------- /** @@ -127,8 +127,8 @@ void JavascriptInterface::setCallbackOnFinished(const QString& function) { * @see SysInfo::getInfo(const QString& infoName) */ const QString JavascriptInterface::getSysInfo(const QString& info) { - SysInfo si; - return si.getInfo(info); + SysInfo si; + return si.getInfo(info); } //------------------------------------------------------------------------------------------------------- /** @@ -139,7 +139,7 @@ const QString JavascriptInterface::getSysInfo(const QString& info) { * Emits JavascriptInterface::quitFbgui() signal */ void JavascriptInterface::quit() { - emit quitFbgui(); + emit quitFbgui(); } //------------------------------------------------------------------------------------------------------- @@ -153,7 +153,7 @@ void JavascriptInterface::quit() { * @see fbgui::performShutDown() */ void JavascriptInterface::shutDown() { - emit shutDownClient(); + emit shutDownClient(); } //------------------------------------------------------------------------------------------------------- /** @@ -166,7 +166,7 @@ void JavascriptInterface::shutDown() { * @see fbgui::performReboot() */ void JavascriptInterface::reboot() { - emit rebootClient(); + emit rebootClient(); } //------------------------------------------------------------------------------------------------------- // Download Manager information exchange @@ -179,10 +179,10 @@ void JavascriptInterface::reboot() { * @todo add some more informations */ void JavascriptInterface::downloadInfo(const QString& filename, - const double& filesize) { - QString code = QString("downloadInfo('\%1', \%2)").arg(filename).arg( - filesize); - _parent->evaluateJavaScript(code); + const double& filesize) { + QString code = QString("downloadInfo('\%1', \%2)").arg(filename).arg( + filesize); + _parent->evaluateJavaScript(code); } //------------------------------------------------------------------------------------------------------- /** @@ -194,12 +194,12 @@ void JavascriptInterface::downloadInfo(const QString& filename, * @todo add some more informations */ void JavascriptInterface::updateProgressBar(const int& percent, - const double& speed, const QString& unit) { - if (percent == 0) - return; - QString code = QString("updateProgress(\%1, \%2, '\%3')").arg(percent).arg( - speed).arg(unit); - _parent->evaluateJavaScript(code); + const double& speed, const QString& unit) { + if (percent == 0) + return; + QString code = QString("updateProgress(\%1, \%2, '\%3')").arg(percent).arg( + speed).arg(unit); + _parent->evaluateJavaScript(code); } //------------------------------------------------------------------------------------------------------- /** @@ -208,17 +208,17 @@ void JavascriptInterface::updateProgressBar(const int& percent, * @todo add some more informations. */ void JavascriptInterface::notify(const QString& msg) { - qxtLog->debug() << "[jsi] Notifying: " << msg; - QString code = QString("notify('\%1')").arg(msg); - _parent->evaluateJavaScript(code); + qxtLog->debug() << "[jsi] Notifying: " << msg; + QString code = QString("notify('\%1')").arg(msg); + _parent->evaluateJavaScript(code); } //------------------------------------------------------------------------------------------------------- /** * @todo add some more informations */ void JavascriptInterface::callbackOnFinished() { - QString code = QString("\%1").arg(_callbackOnDownloadsFinished); - _parent->evaluateJavaScript(code); + QString code = QString("\%1").arg(_callbackOnDownloadsFinished); + _parent->evaluateJavaScript(code); } //------------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------------- @@ -237,10 +237,10 @@ void JavascriptInterface::callbackOnFinished() { * @see void fbgui::loadURL() */ void JavascriptInterface::trigger() { - QFile file(fileToTriggerURL); - if (file.open(QIODevice::WriteOnly)) { - file.write("data\n"); - qxtLog->debug() << "[jsi] *trigger watcher*"; - } - file.close(); + QFile file(fileToTriggerURL); + if (file.open(QIODevice::WriteOnly)) { + file.write("data\n"); + qxtLog->debug() << "[jsi] *trigger watcher*"; + } + file.close(); } diff --git a/src/javascriptinterface.h b/src/javascriptinterface.h index 1f93e38..ce07d93 100644 --- a/src/javascriptinterface.h +++ b/src/javascriptinterface.h @@ -23,50 +23,50 @@ class JavascriptInterface: public QObject { Q_OBJECT public: - JavascriptInterface(QWebFrame* parent); - ~JavascriptInterface(); + JavascriptInterface(QWebFrame* parent); + ~JavascriptInterface(); private: - // pointer to parent - QWebFrame* _parent; - // function to be called withint javascript when downloads are done. - QString _callbackOnDownloadsFinished; - // loads jQuery code - void loadJQuery(); + // pointer to parent + QWebFrame* _parent; + // function to be called withint javascript when downloads are done. + QString _callbackOnDownloadsFinished; + // loads jQuery code + void loadJQuery(); -signals: - // request the file from download manager - 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(); + signals: + // request the file from download manager + 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 - void attachToDOM(); + // make sure the interface stays attached on webpage reload + void attachToDOM(); - // slots for calling from the webpage - void startDownload(const QString& filename); - void setCallbackOnFinished(const QString& function); - const QString getSysInfo(const QString& info); - void quit(); - void shutDown(); - void reboot(); + // slots for calling from the webpage + void startDownload(const QString& filename); + void setCallbackOnFinished(const QString& function); + const QString getSysInfo(const QString& info); + void quit(); + void shutDown(); + void reboot(); - // callback when downloads are done. - void callbackOnFinished(); + // callback when downloads are done. + void callbackOnFinished(); - // slots for information exchange with the download manager. - void updateProgressBar(const int& percent, const double& speed, - const QString& unit); - void downloadInfo(const QString& filename, const double& filesize); - void notify(const QString& msg); + // slots for information exchange with the download manager. + void updateProgressBar(const int& percent, const double& speed, + const QString& unit); + void downloadInfo(const QString& filename, const double& filesize); + void notify(const QString& msg); - // test stuff - void trigger(); + // test stuff + void trigger(); }; #endif // JAVASCRIPTINTERFACE_H_ diff --git a/src/loggerengine.cpp b/src/loggerengine.cpp index d37999d..51fba62 100644 --- a/src/loggerengine.cpp +++ b/src/loggerengine.cpp @@ -4,83 +4,88 @@ // base of a custom logger engine for the framebuffer //--------------------------------------------------------------------------------------------------- LoggerEngine_fb::LoggerEngine_fb(QTextEdit *parent) : - QxtLoggerEngine() { - _debugConsole = parent; - //_initialized = false; - //setLogLevelsEnabled(QxtLogger::DebugLevel); - //enableLogging(); + QxtLoggerEngine() { + _debugConsole = parent; + //_initialized = false; + //setLogLevelsEnabled(QxtLogger::DebugLevel); + //enableLogging(); } LoggerEngine_fb::~LoggerEngine_fb() { } void LoggerEngine_fb::initLoggerEngine() { - //_initialized = true; - return; + //_initialized = true; + return; } void LoggerEngine_fb::killLoggerEngine() { - return; + return; } void LoggerEngine_fb::setLogLevelEnabled(QxtLogger::LogLevels level, - bool enable) { - //QxtLoggerEngine::setLogLevelsEnabled(level, enable); - //if (!enable) QxtLoggerEngine::setLogLevelsEnabled(QxtLogger::DebugLevel); + bool enable) { + //QxtLoggerEngine::setLogLevelsEnabled(level, enable); + //if (!enable) QxtLoggerEngine::setLogLevelsEnabled(QxtLogger::DebugLevel); } bool LoggerEngine_fb::isInitialized() const { - //return _initialized; - return true; + //return _initialized; + return true; } -void LoggerEngine_fb::writeFormatted(QxtLogger::LogLevel level, - const QList & msgs) { +void LoggerEngine_fb::writeFormatted(QxtLogger::LogLevel level, const QList< + QVariant> & msgs) { - if (msgs.isEmpty()) - return; - QString header = '[' + QTime::currentTime().toString("hh:mm:ss.zzz") + "] "; - _debugConsole->insertPlainText(header); - // only write to console for debug level - if (level == QxtLogger::DebugLevel) { - Q_FOREACH(const QVariant& out, msgs) - { - if (!out.isNull()) - _debugConsole->insertPlainText(out.toString()); - } - _debugConsole->insertPlainText(QString("\n")); - // autoscroll - QTextCursor c = _debugConsole->textCursor(); - c.movePosition(QTextCursor::End); - _debugConsole->setTextCursor(c); - } + // ignore in case no messages was passed. + if (msgs.isEmpty()) + return; + + // write timestamp header in format: [hh:mm:ss.zzz] + // example: [23:58:99.999] + QString header = '[' + QTime::currentTime().toString("hh:mm:ss.zzz") + "] "; + _debugConsole->insertPlainText(header); + + // only write to console for debug level + if (level == QxtLogger::DebugLevel) { + Q_FOREACH(const QVariant& out, msgs) + { + if (!out.isNull()) + _debugConsole->insertPlainText(out.toString()); + } + _debugConsole->insertPlainText(QString("\n")); + // autoscroll + QTextCursor c = _debugConsole->textCursor(); + c.movePosition(QTextCursor::End); + _debugConsole->setTextCursor(c); + } } //--------------------------------------------------------------------------------------------------- // slighty modified QxtBasicSTDLoggerEngine //--------------------------------------------------------------------------------------------------- LoggerEngine_std::LoggerEngine_std() : - QxtBasicSTDLoggerEngine() { + QxtBasicSTDLoggerEngine() { } LoggerEngine_std::~LoggerEngine_std() { } -void LoggerEngine_std::writeToStdErr(const QString& str_level, - const QList &msgs) { +void LoggerEngine_std::writeToStdErr(const QString& str_level, const QList< + QVariant> &msgs) { - if (msgs.isEmpty()) - return; - QString header = '[' + QTime::currentTime().toString("hh:mm:ss.zzz") + "] "; - QTextStream* errstream = stdErrStream(); - Q_ASSERT(errstream); - *errstream << header; - Q_FOREACH(const QVariant& out, msgs) - { - if (!out.isNull()) - *errstream << out.toString(); - } - *errstream << endl; + if (msgs.isEmpty()) + return; + QString header = '[' + QTime::currentTime().toString("hh:mm:ss.zzz") + "] "; + QTextStream* errstream = stdErrStream(); + Q_ASSERT(errstream); + *errstream << header; + Q_FOREACH(const QVariant& out, msgs) + { + if (!out.isNull()) + *errstream << out.toString(); + } + *errstream << endl; } void LoggerEngine_std::writeToStdOut(const QString& level, - const QList & msgs) { - // reimplementing this is needed for compiling, - // we only need write to std::err, so this function is not needed + const QList & msgs) { + // reimplementing this is needed for compiling, + // we only need write to std::err, so this function is not needed } diff --git a/src/loggerengine.h b/src/loggerengine.h index 9c3ab96..95a8f93 100644 --- a/src/loggerengine.h +++ b/src/loggerengine.h @@ -25,20 +25,20 @@ //--------------------------------------------------------------------------------------------------- class LoggerEngine_fb: public QxtLoggerEngine { public: - LoggerEngine_fb(QTextEdit* parent); - ~LoggerEngine_fb(); + LoggerEngine_fb(QTextEdit* parent); + ~LoggerEngine_fb(); - // parent widget, target of messages - QTextEdit *_debugConsole; - bool _initialized; + // parent widget, target of messages + QTextEdit *_debugConsole; + bool _initialized; - // reimplemented virtual functions of QxtLoggerEngine - void initLoggerEngine(); - void killLoggerEngine(); - void writeFormatted(QxtLogger::LogLevel level, - const QList & messages); - void setLogLevelEnabled(QxtLogger::LogLevels level, bool enable = true); - bool isInitialized() const; + // reimplemented virtual functions of QxtLoggerEngine + void initLoggerEngine(); + void killLoggerEngine(); + void writeFormatted(QxtLogger::LogLevel level, + const QList & messages); + void setLogLevelEnabled(QxtLogger::LogLevels level, bool enable = true); + bool isInitialized() const; }; //--------------------------------------------------------------------------------------------------- @@ -46,12 +46,12 @@ public: //--------------------------------------------------------------------------------------------------- class LoggerEngine_std: public QxtBasicSTDLoggerEngine { public: - LoggerEngine_std(); - ~LoggerEngine_std(); + LoggerEngine_std(); + ~LoggerEngine_std(); - // reimplemented virtual functions of QxtBasicSTDLoggerEngineqqq - void writeToStdOut(const QString& level, const QList &msgs); - void writeToStdErr(const QString& str_level, const QList &msgs); + // reimplemented virtual functions of QxtBasicSTDLoggerEngineqqq + void writeToStdOut(const QString& level, const QList &msgs); + void writeToStdErr(const QString& str_level, const QList &msgs); }; #endif // LOGGERENGINE_H_ diff --git a/src/main.cpp b/src/main.cpp index baff7af..9b0a18a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8,187 +8,185 @@ #include "fbgui.h" void printHelp() { - QTextStream qout(stdout); - qout << QObject::tr("Usage: ./fbgui [OPTIONS]") << endl; - qout << QObject::tr("Options:") << endl; - qout << "-c , --config= " << QObject::tr( - "Path to configuration file.") << endl; - qout << "-u , --url= " << QObject::tr( - "Sets the URL to be loaded.") << endl; - qout << "-d , --download= " << QObject::tr( - "Specify the download directory.") << endl; - qout << "-t " << QObject::tr( - "Specify location of the file triggering the URL load.") << endl; - qout << "-s " << QObject::tr( - "Specify location of the file containing the serial number.") - << endl; - qout << "-D , --debug= " << QObject::tr( - "Activate debug mode. [0,1]") << endl; - qout << "-h, --help " << QObject::tr( - "Prints this help.") << endl; - qout.flush(); - exit( EXIT_SUCCESS); + QTextStream qout(stdout); + qout << QObject::tr("Usage: ./fbgui [OPTIONS]") << endl; + qout << QObject::tr("Options:") << endl; + qout << "-c , --config= " << QObject::tr( + "Path to configuration file.") << endl; + qout << "-u , --url= " << QObject::tr( + "Sets the URL to be loaded.") << endl; + qout << "-d , --download= " << QObject::tr( + "Specify the download directory.") << endl; + qout << "-t " << QObject::tr( + "Specify location of the file triggering the URL load.") << endl; + qout << "-s " << QObject::tr( + "Specify location of the file containing the serial number.") << endl; + qout << "-D , --debug= " << QObject::tr( + "Activate debug mode. [0,1]") << endl; + qout << "-h, --help " << QObject::tr( + "Prints this help.") << endl; + qout.flush(); + exit( EXIT_SUCCESS); } int main(int argc, char *argv[]) { - // Initialisation of the QApplication: - // In QT, every application is composed of two separate - // components: the GUI-Client and the GUI-Server. - // - // The third parameter sets the application as the - // GUI-Server (aswell as the GUI-Client). - - QApplication app(argc, argv, QApplication::GuiServer); - app.setOrganizationName("team_projekt_2011"); - app.setApplicationName("prebootGUI"); - binPath = QApplication::applicationDirPath(); - - QTranslator translator; - translator.load(":" + QLocale::system().name()); - app.installTranslator(&translator); - - // parse command line arguments using getopt - QMap clOpts; - int longIndex = 0; - static const char *optString = "c:u:d:s:t:D:h"; - static const struct option longOpts[] = { { "config", required_argument, - NULL, 'c' }, { "url", required_argument, NULL, 'u' }, { "download", - required_argument, NULL, 'd' }, { "serial", required_argument, - NULL, 's' }, { "trigger", required_argument, NULL, 't' }, { - "debug", required_argument, NULL, 'D' }, { "help", no_argument, - NULL, 'h' } }; - int opt = getopt_long(argc, argv, optString, longOpts, &longIndex); - while (opt != -1) { - switch (opt) { - case 'c': - clOpts.insert("configFile", optarg); - break; - case 'u': - clOpts.insert("url", optarg); - break; - case 'd': - clOpts.insert("downloadDir", optarg); - break; - case 's': - clOpts.insert("serialLocation", optarg); - break; - case 't': - clOpts.insert("trigger", optarg); - break; - case 'D': - clOpts.insert("debug", optarg); - break; - case 'h': - clOpts.insert("help", "help"); - break; - } - opt = getopt_long(argc, argv, optString, longOpts, &longIndex); - } - - if (clOpts.contains("help")) - printHelp(); - - if (clOpts.contains("debug")) { - debugMode = clOpts.value("debug").toInt(); - // start basic debug log - qxtLog->disableLoggerEngine("DEFAULT"); - qxtLog->addLoggerEngine("std_logger", new LoggerEngine_std); - qxtLog->initLoggerEngine("std_logger"); - qxtLog->setMinimumLevel("std_logger", QxtLogger::DebugLevel); - qxtLog->enableLogLevels(QxtLogger::DebugLevel); - qxtLog->debug() << "Initializing fbgui..."; - } else - debugMode = -1; - - // look for config file either in: - // - the path found in the configuration file - // - the user's home directory (as .fbgui.conf) - // - /etc/fbgui.conf - - QString configFilePath; - QFileInfo confInfo; - if (clOpts.contains("configFile")) - configFilePath = clOpts.value("configFile"); - else { - confInfo = QFileInfo(QDir::home(), ".fbgui.conf"); - if (confInfo.exists()) - configFilePath = confInfo.absoluteFilePath(); - else { - confInfo = QFileInfo(QString("/etc/fbgui.conf")); - if (confInfo.exists()) - configFilePath = QString("/etc/fbgui.conf"); - else - configFilePath = DEFAULT_CONFIG_PATH; - } - } - - // read the config file - QSettings confFileSettings(configFilePath, QSettings::IniFormat); - confFileSettings.setIniCodec("UTF-8"); - - // set base URL to be loaded - if (clOpts.contains("url")) - baseURL = QUrl(clOpts.value("url")); - else if (confFileSettings.contains("default/pbs_url")) - baseURL = confFileSettings.value("default/pbs_url").toUrl(); - else - baseURL = DEFAULT_URL; - - // set directory for downloads - if (clOpts.contains("downloadDir")) - downloadPath = clOpts.value("downloadDir"); - else if (confFileSettings.contains("default/download_directory")) - downloadPath - = confFileSettings.value("default/download_directory").toString(); - else - downloadPath = DEFAULT_DOWNLOAD_DIR; - - if (confFileSettings.contains("default/update_interval")) - updateInterval - = confFileSettings.value("default/update_interval").toInt(); - else - updateInterval = DEFAULT_UPDATE_INTERVAL; - - // set which file to watch to trigger loading of URL - if (clOpts.contains("trigger")) - fileToTriggerURL = clOpts.value("trigger"); - else if (confFileSettings.contains("default/file_trigger")) - fileToTriggerURL - = confFileSettings.value("default/file_trigger").toString(); - else - fileToTriggerURL = DEFAULT_FILE_TRIGGER; - - // set serial location - if (clOpts.contains("serialLocation")) - serialLocation = clOpts.value("serialLocation"); - else if (confFileSettings.contains("default/serial_location")) - serialLocation - = confFileSettings.value("default/serial_location").toString(); - else - serialLocation = QString("/serial"); // tests - - // save ip config location (file generated by uchpc) - if (confFileSettings.contains("default/ip_config")) - ipConfigFilePath = confFileSettings.value("default/ip_config").toString(); - //else - // ipConfigFilePath = QString("/tmp/ip_config"); - - // print config - qxtLog->debug() << "************* CONFIG INFO *************"; - qxtLog->debug() << "configFilePath: " << configFilePath.toUtf8(); - qxtLog->debug() << "ipConfigFilePath:" << ipConfigFilePath.toUtf8(); - qxtLog->debug() << "baseURL: " << baseURL.toString().toUtf8(); - qxtLog->debug() << "downloadDir : " << downloadPath.toUtf8(); - qxtLog->debug() << "trigger: " << fileToTriggerURL.toUtf8(); - qxtLog->debug() << "serialLocation: " << serialLocation.toUtf8(); - qxtLog->debug() << "*******************************************"; - - // set invisible cursor - QWSServer::instance()->setCursorVisible(false); - QWSServer::instance()->setDefaultKeyboard("TTY:/dev/tty0"); - QWSServer::instance()->setDefaultMouse("IntelliMouse:/dev/mice"); - // start fbgui - fbgui gui; - gui.show(); - return app.exec(); + // Initialisation of the QApplication: + // In QT, every application is composed of two separate + // components: the GUI-Client and the GUI-Server. + // + // The third parameter sets the application as the + // GUI-Server (aswell as the GUI-Client). + + QApplication app(argc, argv, QApplication::GuiServer); + app.setOrganizationName("team_projekt_2011"); + app.setApplicationName("prebootGUI"); + binPath = QApplication::applicationDirPath(); + + QTranslator translator; + translator.load(":" + QLocale::system().name()); + app.installTranslator(&translator); + + // parse command line arguments using getopt + QMap clOpts; + int longIndex = 0; + static const char *optString = "c:u:d:s:t:D:h"; + static const struct option longOpts[] = { { "config", required_argument, + NULL, 'c' }, { "url", required_argument, NULL, 'u' }, { "download", + required_argument, NULL, 'd' }, { "serial", required_argument, NULL, + 's' }, { "trigger", required_argument, NULL, 't' }, { "debug", + required_argument, NULL, 'D' }, { "help", no_argument, NULL, 'h' } }; + int opt = getopt_long(argc, argv, optString, longOpts, &longIndex); + while (opt != -1) { + switch (opt) { + case 'c': + clOpts.insert("configFile", optarg); + break; + case 'u': + clOpts.insert("url", optarg); + break; + case 'd': + clOpts.insert("downloadDir", optarg); + break; + case 's': + clOpts.insert("serialLocation", optarg); + break; + case 't': + clOpts.insert("trigger", optarg); + break; + case 'D': + clOpts.insert("debug", optarg); + break; + case 'h': + clOpts.insert("help", "help"); + break; + } + opt = getopt_long(argc, argv, optString, longOpts, &longIndex); + } + + if (clOpts.contains("help")) + printHelp(); + + if (clOpts.contains("debug")) { + debugMode = clOpts.value("debug").toInt(); + // start basic debug log + qxtLog->disableLoggerEngine("DEFAULT"); + qxtLog->addLoggerEngine("std_logger", new LoggerEngine_std); + qxtLog->initLoggerEngine("std_logger"); + qxtLog->setMinimumLevel("std_logger", QxtLogger::DebugLevel); + qxtLog->enableLogLevels(QxtLogger::DebugLevel); + qxtLog->debug() << "Initializing fbgui..."; + } else + debugMode = -1; + + // look for config file either in: + // - the path found in the configuration file + // - the user's home directory (as .fbgui.conf) + // - /etc/fbgui.conf + + QString configFilePath; + QFileInfo confInfo; + if (clOpts.contains("configFile")) + configFilePath = clOpts.value("configFile"); + else { + confInfo = QFileInfo(QDir::home(), ".fbgui.conf"); + if (confInfo.exists()) + configFilePath = confInfo.absoluteFilePath(); + else { + confInfo = QFileInfo(QString("/etc/fbgui.conf")); + if (confInfo.exists()) + configFilePath = QString("/etc/fbgui.conf"); + else + configFilePath = DEFAULT_CONFIG_PATH; + } + } + + // read the config file + QSettings confFileSettings(configFilePath, QSettings::IniFormat); + confFileSettings.setIniCodec("UTF-8"); + + // set base URL to be loaded + if (clOpts.contains("url")) + baseURL = QUrl(clOpts.value("url")); + else if (confFileSettings.contains("default/pbs_url")) + baseURL = confFileSettings.value("default/pbs_url").toUrl(); + else + baseURL = DEFAULT_URL; + + // set directory for downloads + if (clOpts.contains("downloadDir")) + downloadPath = clOpts.value("downloadDir"); + else if (confFileSettings.contains("default/download_directory")) + downloadPath + = confFileSettings.value("default/download_directory").toString(); + else + downloadPath = DEFAULT_DOWNLOAD_DIR; + + if (confFileSettings.contains("default/update_interval")) + updateInterval + = confFileSettings.value("default/update_interval").toInt(); + else + updateInterval = DEFAULT_UPDATE_INTERVAL; + + // set which file to watch to trigger loading of URL + if (clOpts.contains("trigger")) + fileToTriggerURL = clOpts.value("trigger"); + else if (confFileSettings.contains("default/file_trigger")) + fileToTriggerURL + = confFileSettings.value("default/file_trigger").toString(); + else + fileToTriggerURL = DEFAULT_FILE_TRIGGER; + + // set serial location + if (clOpts.contains("serialLocation")) + serialLocation = clOpts.value("serialLocation"); + else if (confFileSettings.contains("default/serial_location")) + serialLocation + = confFileSettings.value("default/serial_location").toString(); + else + serialLocation = QString("/serial"); // tests + + // save ip config location (file generated by uchpc) + if (confFileSettings.contains("default/ip_config")) + ipConfigFilePath = confFileSettings.value("default/ip_config").toString(); + //else + // ipConfigFilePath = QString("/tmp/ip_config"); + + // print config + qxtLog->debug() << "************* CONFIG INFO *************"; + qxtLog->debug() << "configFilePath: " << configFilePath.toUtf8(); + qxtLog->debug() << "ipConfigFilePath:" << ipConfigFilePath.toUtf8(); + qxtLog->debug() << "baseURL: " << baseURL.toString().toUtf8(); + qxtLog->debug() << "downloadDir : " << downloadPath.toUtf8(); + qxtLog->debug() << "trigger: " << fileToTriggerURL.toUtf8(); + qxtLog->debug() << "serialLocation: " << serialLocation.toUtf8(); + qxtLog->debug() << "*******************************************"; + + // set invisible cursor + QWSServer::instance()->setCursorVisible(false); + QWSServer::instance()->setDefaultKeyboard("TTY:/dev/tty0"); + QWSServer::instance()->setDefaultMouse("IntelliMouse:/dev/mice"); + // start fbgui + fbgui gui; + gui.show(); + return app.exec(); } diff --git a/src/sysinfo.cpp b/src/sysinfo.cpp index ef7dc04..2de7b92 100644 --- a/src/sysinfo.cpp +++ b/src/sysinfo.cpp @@ -34,22 +34,22 @@ SysInfo::~SysInfo() { * @see JavascriptInterface::getSysInfo(const QString& info) */ const QString SysInfo::getInfo(const QString& infoName) { - qxtLog->debug() << "[sysinfo] requested " << infoName; - if (infoName == QString("mac")) - return getMACAddress(); - else if (infoName == QString("ip")) - return getIPAddress(); - else if (infoName == QString("all")) - return getAllInfos(); - else if (infoName == QString("mbserial")) - return getMainboardSerial(); - else if (infoName == QString("usb")) - return getUsbVendorIdProductIdSerialNumber(); - else if (infoName == QString("json")) - return getNames(); - /* unknown code */ - qxtLog->debug() << "[sysinfo] unknown requested"; - return "info_error"; + qxtLog->debug() << "[sysinfo] requested " << infoName; + if (infoName == QString("mac")) + return getMACAddress(); + else if (infoName == QString("ip")) + return getIPAddress(); + else if (infoName == QString("all")) + return getAllInfos(); + else if (infoName == QString("mbserial")) + return getMainboardSerial(); + else if (infoName == QString("usb")) + return getUsbVendorIdProductIdSerialNumber(); + else if (infoName == QString("json")) + return getNames(); + /* unknown code */ + qxtLog->debug() << "[sysinfo] unknown requested"; + return "info_error"; } // ------------------------------------------------------------------------------------------------ /** @@ -68,16 +68,16 @@ const QString SysInfo::getInfo(const QString& infoName) { * @see SysInfo::getInfo(const QString& infoName) */ const QString SysInfo::getMACAddress() { - // Returns MAC address of eth0 for now - QNetworkInterface qni = QNetworkInterface::interfaceFromName( - QString("eth0")); - if (!qni.isValid()) { - qxtLog->debug() - << "[sysinfo] MAC Address: No interface matching \"eth0\" found."; - return "no_eth0"; - } - //eth0_index = qni.index(); - return qni.hardwareAddress(); + // Returns MAC address of eth0 for now + QNetworkInterface qni = + QNetworkInterface::interfaceFromName(QString("eth0")); + if (!qni.isValid()) { + qxtLog->debug() + << "[sysinfo] MAC Address: No interface matching \"eth0\" found."; + return "no_eth0"; + } + //eth0_index = qni.index(); + return qni.hardwareAddress(); } // ------------------------------------------------------------------------------------------------ /** @@ -94,22 +94,22 @@ const QString SysInfo::getMACAddress() { * @see SysInfo::getInfo(const QString& infoName) */ const QString SysInfo::getIPAddress() { - // Again for eth0 only at the moment. - // TODO: this doesn't quite work yet... - QNetworkInterface qni = QNetworkInterface::interfaceFromName( - QString("eth0")); - QList addrlist = qni.allAddresses(); - // This is does not return the right IP atm... - foreach(QHostAddress addr, addrlist) - { - if (addr.protocol() == QAbstractSocket::IPv4Protocol && addr - != QHostAddress::LocalHost) { - return addr.toString(); - } - } - // still here? - qxtLog->debug() << "[sysinfo] IP Address: ip_error"; - return "ip_error"; + // Again for eth0 only at the moment. + // TODO: this doesn't quite work yet... + QNetworkInterface qni = + QNetworkInterface::interfaceFromName(QString("eth0")); + QList addrlist = qni.allAddresses(); + // This is does not return the right IP atm... + foreach(QHostAddress addr, addrlist) + { + if (addr.protocol() == QAbstractSocket::IPv4Protocol && addr + != QHostAddress::LocalHost) { + return addr.toString(); + } + } + // still here? + qxtLog->debug() << "[sysinfo] IP Address: ip_error"; + return "ip_error"; } // ------------------------------------------------------------------------------------------------ /** @@ -117,22 +117,22 @@ const QString SysInfo::getIPAddress() { */ const QByteArray SysInfo::getNames() { - QVariantMap foo; - foo.insert("name", "foo"); - foo.insert("type", 123); + QVariantMap foo; + foo.insert("name", "foo"); + foo.insert("type", 123); - QVariantMap fooo; - fooo.insert("name", "boo"); - fooo.insert("type", 321); + QVariantMap fooo; + fooo.insert("name", "boo"); + fooo.insert("type", 321); - QVariantList jsonV; - jsonV << foo << fooo; + QVariantList jsonV; + jsonV << foo << fooo; - QJson::Serializer serializer; - QByteArray json = serializer.serialize(jsonV); + QJson::Serializer serializer; + QByteArray json = serializer.serialize(jsonV); - qxtLog->debug() << json; - return json; + qxtLog->debug() << json; + return json; } // ------------------------------------------------------------------------------------------------ @@ -140,17 +140,17 @@ const QByteArray SysInfo::getNames() { * just a test method for json. */ QString SysInfo::getAllInfos() { - QVariantMap infos; - infos.insert("mac", getMACAddress()); - infos.insert("ip", getIPAddress()); - infos.insert("whoami", getScriptOutput("whoami")); - //infos.insert("pwd", getScriptOutput("pwd")); + QVariantMap infos; + infos.insert("mac", getMACAddress()); + infos.insert("ip", getIPAddress()); + infos.insert("whoami", getScriptOutput("whoami")); + //infos.insert("pwd", getScriptOutput("pwd")); - //QJson::Serializer serializer; - QByteArray json = serializer.serialize(infos); + //QJson::Serializer serializer; + QByteArray json = serializer.serialize(infos); - qxtLog->debug() << json; - return json; + qxtLog->debug() << json; + return json; } // ------------------------------------------------------------------------------------------------ @@ -170,27 +170,27 @@ QString SysInfo::getAllInfos() { * @see SysInfo::getInfo(const QString& infoName) */ const QString SysInfo::getMainboardSerial() { - QString out = ""; - struct sysfs_class_device *class_device = sysfs_open_class_device("dmi", - "id"); - struct dlist *attrlist = sysfs_get_classdev_attributes(class_device); - struct sysfs_device *device = sysfs_get_classdev_device(class_device); + QString out = ""; + struct sysfs_class_device *class_device = sysfs_open_class_device("dmi", + "id"); + struct dlist *attrlist = sysfs_get_classdev_attributes(class_device); + struct sysfs_device *device = sysfs_get_classdev_device(class_device); - if (attrlist != NULL) { - struct sysfs_attribute *attr = NULL; - dlist_for_each_data(attrlist, attr, struct sysfs_attribute) { - QVariantMap a; - if(QString(attr->name) == QString("board_serial")) { - out = QString(attr->value); - } - } - qxtLog->debug() << "[sysinfo] Mainboard Serial: " + out; - return out; - } - qxtLog->debug() - << "[sysinfo] Mainboard Serial: attrlist is null! return: mainboard_serial_error"; - sysfs_close_class_device(class_device); - return "mainboard_serial_error"; + if (attrlist != NULL) { + struct sysfs_attribute *attr = NULL; + dlist_for_each_data(attrlist, attr, struct sysfs_attribute) { + QVariantMap a; + if(QString(attr->name) == QString("board_serial")) { + out = QString(attr->value); + } + } + qxtLog->debug() << "[sysinfo] Mainboard Serial: " + out; + return out; + } + qxtLog->debug() + << "[sysinfo] Mainboard Serial: attrlist is null! return: mainboard_serial_error"; + sysfs_close_class_device(class_device); + return "mainboard_serial_error"; } // ------------------------------------------------------------------------------------------------ /** @@ -215,76 +215,75 @@ const QString SysInfo::getMainboardSerial() { * @see SysInfo::getInfo(const QString& infoName) */ const QString SysInfo::getUsbVendorIdProductIdSerialNumber() { - QString tag = "[sysinfo] Usb Serial:"; - QString out = ""; - QVariantList list; + QString tag = "[sysinfo] Usb Serial:"; + QString out = ""; + QVariantList list; - libusb_device **devs; - libusb_context *ctx = NULL; //a libusb session - ssize_t cnt; //holding number of devices in list - int r = 1; - r = libusb_init(&ctx); - if (r < 0) { - qxtLog->debug() << tag + "failed to initialise libusb"; - return "error"; - } - cnt = libusb_get_device_list(ctx, &devs); //get the list of devices - if (cnt < 0) { - qxtLog->debug() << tag + "Get Device Error"; //there was an error - } - qxtLog->debug() << tag + cnt + " Devices in list."; //print total number of usb devices - ssize_t i; //for iterating through the list# - for (i = 0; i < cnt; i++) { - //printdev(devs[i]); //print specs of this device - QVariantMap infos; - libusb_device *dev = devs[i]; - libusb_device_descriptor desc; - int re = libusb_get_device_descriptor(dev, &desc); - if (re < 0) { - qxtLog->debug() << tag + "failed to get device descriptor"; - return "error"; - } - infos.insert("vendorId", desc.idVendor); - infos.insert("productId", desc.idProduct); - unsigned char string[256]; - libusb_device_handle *handle; - re = libusb_open(dev, &handle); - if (re != 0) { - qxtLog->debug() << tag - + "failed to get handler / fail to open device"; - return "error"; - } - re = libusb_get_string_descriptor_ascii(handle, desc.iSerialNumber, - string, sizeof(string)); - if (re < 0) { - qxtLog->debug() << tag + "failed to get SerialNumber"; - return "error"; - } - infos.insert("serialnumber", QString((const char *) string)); - re = libusb_get_string_descriptor_ascii(handle, desc.iProduct, string, - sizeof(string)); - if (re < 0) { - qxtLog->debug() << tag + "failed to get Product"; - return "error"; - } - infos.insert("product", QString((const char *) string)); - re = libusb_get_string_descriptor_ascii(handle, desc.iManufacturer, - string, sizeof(string)); - if (re < 0) { - qxtLog->debug() << tag + "failed to get Product"; - return "error"; - } - infos.insert("manuacturer", QString((const char *) string)); + libusb_device **devs; + libusb_context *ctx = NULL; //a libusb session + ssize_t cnt; //holding number of devices in list + int r = 1; + r = libusb_init(&ctx); + if (r < 0) { + qxtLog->debug() << tag + "failed to initialise libusb"; + return "error"; + } + cnt = libusb_get_device_list(ctx, &devs); //get the list of devices + if (cnt < 0) { + qxtLog->debug() << tag + "Get Device Error"; //there was an error + } + qxtLog->debug() << tag + cnt + " Devices in list."; //print total number of usb devices + ssize_t i; //for iterating through the list# + for (i = 0; i < cnt; i++) { + //printdev(devs[i]); //print specs of this device + QVariantMap infos; + libusb_device *dev = devs[i]; + libusb_device_descriptor desc; + int re = libusb_get_device_descriptor(dev, &desc); + if (re < 0) { + qxtLog->debug() << tag + "failed to get device descriptor"; + return "error"; + } + infos.insert("vendorId", desc.idVendor); + infos.insert("productId", desc.idProduct); + unsigned char string[256]; + libusb_device_handle *handle; + re = libusb_open(dev, &handle); + if (re != 0) { + qxtLog->debug() << tag + "failed to get handler / fail to open device"; + return "error"; + } + re = libusb_get_string_descriptor_ascii(handle, desc.iSerialNumber, + string, sizeof(string)); + if (re < 0) { + qxtLog->debug() << tag + "failed to get SerialNumber"; + return "error"; + } + infos.insert("serialnumber", QString((const char *) string)); + re = libusb_get_string_descriptor_ascii(handle, desc.iProduct, string, + sizeof(string)); + if (re < 0) { + qxtLog->debug() << tag + "failed to get Product"; + return "error"; + } + infos.insert("product", QString((const char *) string)); + re = libusb_get_string_descriptor_ascii(handle, desc.iManufacturer, + string, sizeof(string)); + if (re < 0) { + qxtLog->debug() << tag + "failed to get Product"; + return "error"; + } + infos.insert("manuacturer", QString((const char *) string)); - list << infos; - libusb_close(handle); - } - libusb_free_device_list(devs, 1); //free the list, unref the devices in it - libusb_exit(ctx); //close the session + list << infos; + libusb_close(handle); + } + libusb_free_device_list(devs, 1); //free the list, unref the devices in it + libusb_exit(ctx); //close the session - QByteArray json = serializer.serialize(list); - qxtLog->debug() << tag + "json object: " + json; - return json; + QByteArray json = serializer.serialize(list); + qxtLog->debug() << tag + "json object: " + json; + return json; } // ------------------------------------------------------------------------------------------------ @@ -302,26 +301,25 @@ const QString SysInfo::getUsbVendorIdProductIdSerialNumber() { * output of the script. */ QString SysInfo::getScriptOutput(QString cmd) { - QProcess *process = new QProcess(); - qxtLog->debug() << "[sysinfo] Script Output: try to open: " << cmd; - process->start(cmd, QIODevice::ReadOnly); + QProcess *process = new QProcess(); + 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"; + if (!process->waitForStarted()) + qxtLog->debug() << "[sysinfo] Script Output: process couldn't get opened"; - QString output; - process->waitForFinished(); + QString output; + process->waitForFinished(); - QTextStream *txt_stream = new QTextStream(process); + QTextStream *txt_stream = new QTextStream(process); - while (!txt_stream->atEnd()) { - qxtLog->debug() << "[sysinfo] Script Output: read output: "; - QString tmp_str = txt_stream->readLine(); - output += tmp_str; - qxtLog->debug() << "[sysinfo] Script Output: " << tmp_str; - } - qxtLog->debug() << "[sysinfo] Script Output: process finished: "; - return output; + while (!txt_stream->atEnd()) { + qxtLog->debug() << "[sysinfo] Script Output: read output: "; + QString tmp_str = txt_stream->readLine(); + output += tmp_str; + qxtLog->debug() << "[sysinfo] Script Output: " << tmp_str; + } + qxtLog->debug() << "[sysinfo] Script Output: process finished: "; + return output; } diff --git a/src/sysinfo.h b/src/sysinfo.h index 2c5d16d..f4fa3b2 100644 --- a/src/sysinfo.h +++ b/src/sysinfo.h @@ -33,23 +33,23 @@ extern "C" { class SysInfo { public: - SysInfo(); - ~SysInfo(); - // public access, valid infoName: "mac", "ip", ... - const QString getInfo(const QString& infoName); + SysInfo(); + ~SysInfo(); + // public access, valid infoName: "mac", "ip", ... + const QString getInfo(const QString& infoName); private: - // private system information readers - const QString getMACAddress(); - const QString getIPAddress(); - const QString getMainboardSerial(); - const QString getUsbVendorIdProductIdSerialNumber(); - QString getAllInfos(); - QString getScriptOutput(QString cmd); - - // JSon testing - QJson::Serializer serializer; - const QByteArray getNames(); + // private system information readers + const QString getMACAddress(); + const QString getIPAddress(); + const QString getMainboardSerial(); + const QString getUsbVendorIdProductIdSerialNumber(); + QString getAllInfos(); + QString getScriptOutput(QString cmd); + + // JSon testing + QJson::Serializer serializer; + const QByteArray getNames(); }; #endif // SYSTINFO_H diff --git a/src/sysinfolibsysfs.cpp b/src/sysinfolibsysfs.cpp index 9030155..5c89bde 100644 --- a/src/sysinfolibsysfs.cpp +++ b/src/sysinfolibsysfs.cpp @@ -14,135 +14,135 @@ // Initialisation //------------------------------------------------------------------------------------------------------- SysInfoLibsysfs::SysInfoLibsysfs() { - // TODO Auto-generated constructor stub + // TODO Auto-generated constructor stub } SysInfoLibsysfs::~SysInfoLibsysfs() { - // TODO Auto-generated destructor stub + // TODO Auto-generated destructor stub } void SysInfoLibsysfs::getInfoAboutNetworkInterface() { - struct sysfs_class_device *class_device = sysfs_open_class_device("net", - "eth0"); - struct dlist *attrlist = sysfs_get_classdev_attributes(class_device); - struct sysfs_device *device = sysfs_get_classdev_device(class_device); - //struct sysfs_driver *driver = sysfs_get_classdev_driver(class_device); - if (device == NULL) { - //qxtLog->debug() << "[libsysfs] device is NULL!"; - } else { - qDebug() << "--- print eth0 device path:"; - qDebug() << QString(device->path); - } - - sysfs_close_class_device(class_device); + struct sysfs_class_device *class_device = sysfs_open_class_device("net", + "eth0"); + struct dlist *attrlist = sysfs_get_classdev_attributes(class_device); + struct sysfs_device *device = sysfs_get_classdev_device(class_device); + //struct sysfs_driver *driver = sysfs_get_classdev_driver(class_device); + if (device == NULL) { + //qxtLog->debug() << "[libsysfs] device is NULL!"; + } else { + qDebug() << "--- print eth0 device path:"; + qDebug() << QString(device->path); + } + + sysfs_close_class_device(class_device); } void SysInfoLibsysfs::getInfoMbSerial() { - QJson::Serializer serializer; - QVariantList listOfDevices; - - struct sysfs_class_device *class_device = sysfs_open_class_device("dmi", - "id"); - struct dlist *attrlist = sysfs_get_classdev_attributes(class_device); - struct sysfs_device *device = sysfs_get_classdev_device(class_device); - - if (attrlist != NULL) { - struct sysfs_attribute *attr = NULL; - QVariantList list; - dlist_for_each_data(attrlist, attr, struct sysfs_attribute) { - QVariantMap a; - if(QString(attr->name) == QString("board_serial")) { - a.insert("name", QString(attr->name)); - a.insert("value", QString(attr->value)); - a.insert("len", QString(attr->len)); - a.insert("path", QString(attr->path)); - a.insert("method", QString(attr->method)); - list << a; - } - } - QByteArray json = serializer.serialize(list); - - qDebug() << json; - return; - } - qDebug() << "attrlist is null!"; - sysfs_close_class_device(class_device); + QJson::Serializer serializer; + QVariantList listOfDevices; + + struct sysfs_class_device *class_device = sysfs_open_class_device("dmi", + "id"); + struct dlist *attrlist = sysfs_get_classdev_attributes(class_device); + struct sysfs_device *device = sysfs_get_classdev_device(class_device); + + if (attrlist != NULL) { + struct sysfs_attribute *attr = NULL; + QVariantList list; + dlist_for_each_data(attrlist, attr, struct sysfs_attribute) { + QVariantMap a; + if(QString(attr->name) == QString("board_serial")) { + a.insert("name", QString(attr->name)); + a.insert("value", QString(attr->value)); + a.insert("len", QString(attr->len)); + a.insert("path", QString(attr->path)); + a.insert("method", QString(attr->method)); + list << a; + } + } + QByteArray json = serializer.serialize(list); + + qDebug() << json; + return; + } + qDebug() << "attrlist is null!"; + sysfs_close_class_device(class_device); } QString SysInfoLibsysfs::getInfoMainboardSerial() { - QString out = ""; - struct sysfs_class_device *class_device = sysfs_open_class_device("dmi", - "id"); - struct dlist *attrlist = sysfs_get_classdev_attributes(class_device); - struct sysfs_device *device = sysfs_get_classdev_device(class_device); - - if (attrlist != NULL) { - struct sysfs_attribute *attr = NULL; - dlist_for_each_data(attrlist, attr, struct sysfs_attribute) { - QVariantMap a; - if(QString(attr->name) == QString("board_serial")) { - out = QString(attr->value); - } - } - - qDebug() << out; - return out; - } - qDebug() << "attrlist is null!"; - sysfs_close_class_device(class_device); - return NULL; + QString out = ""; + struct sysfs_class_device *class_device = sysfs_open_class_device("dmi", + "id"); + struct dlist *attrlist = sysfs_get_classdev_attributes(class_device); + struct sysfs_device *device = sysfs_get_classdev_device(class_device); + + if (attrlist != NULL) { + struct sysfs_attribute *attr = NULL; + dlist_for_each_data(attrlist, attr, struct sysfs_attribute) { + QVariantMap a; + if(QString(attr->name) == QString("board_serial")) { + out = QString(attr->value); + } + } + + qDebug() << out; + return out; + } + qDebug() << "attrlist is null!"; + sysfs_close_class_device(class_device); + return NULL; } void SysInfoLibsysfs::getInfoAboutClassNet() { - QJson::Serializer serializer; - QVariantList listOfDevices; - - struct sysfs_class *sysfsclass = sysfs_open_class("net"); - struct dlist *devices = sysfs_get_class_devices(sysfsclass); - struct sysfs_device *dev = NULL; - dlist_for_each_data(devices,dev, struct sysfs_device) { - if(dev == NULL) { - qDebug() << "device is NULL!"; - //qxtLog->debug() << "[libsysfs] device is NULL!"; - } - else { - - qDebug() << "--- print device:"; - - QVariantMap infos; - infos.insert("name", QString(dev->name)); - infos.insert("bus", QString(dev->bus)); - infos.insert("bus_id", QString(dev->bus_id)); - infos.insert("driver_name", QString(dev->driver_name)); - infos.insert("path", QString(dev->path)); - infos.insert("subsystem", QString(dev->subsystem)); - struct dlist *attrlist = dev->attrlist; - if (attrlist != NULL) { - struct sysfs_attribute *attr = NULL; - QVariantList list; - dlist_for_each_data(attrlist, attr, struct sysfs_attribute) { - QVariantMap a; - a.insert("name", QString(attr->name)); - a.insert("value", QString(attr->value)); - a.insert("len", QString(attr->len)); - a.insert("path", QString(attr->path)); - a.insert("method", QString(attr->method)); - list << a; - } - QByteArray json = serializer.serialize(list); - - qDebug() << json; - infos.insert("attrlist", list); + QJson::Serializer serializer; + QVariantList listOfDevices; + + struct sysfs_class *sysfsclass = sysfs_open_class("net"); + struct dlist *devices = sysfs_get_class_devices(sysfsclass); + struct sysfs_device *dev = NULL; + dlist_for_each_data(devices,dev, struct sysfs_device) { + if(dev == NULL) { + qDebug() << "device is NULL!"; + //qxtLog->debug() << "[libsysfs] device is NULL!"; + } + else { + + qDebug() << "--- print device:"; + + QVariantMap infos; + infos.insert("name", QString(dev->name)); + infos.insert("bus", QString(dev->bus)); + infos.insert("bus_id", QString(dev->bus_id)); + infos.insert("driver_name", QString(dev->driver_name)); + infos.insert("path", QString(dev->path)); + infos.insert("subsystem", QString(dev->subsystem)); + struct dlist *attrlist = dev->attrlist; + if (attrlist != NULL) { + struct sysfs_attribute *attr = NULL; + QVariantList list; + dlist_for_each_data(attrlist, attr, struct sysfs_attribute) { + QVariantMap a; + a.insert("name", QString(attr->name)); + a.insert("value", QString(attr->value)); + a.insert("len", QString(attr->len)); + a.insert("path", QString(attr->path)); + a.insert("method", QString(attr->method)); + list << a; } - listOfDevices << infos; - } + QByteArray json = serializer.serialize(list); + + qDebug() << json; + infos.insert("attrlist", list); + } + listOfDevices << infos; + } - } + } - sysfs_close_class(sysfsclass); + sysfs_close_class(sysfsclass); - QByteArray json = serializer.serialize(listOfDevices); + QByteArray json = serializer.serialize(listOfDevices); - qDebug() << json; + qDebug() << json; } diff --git a/src/sysinfolibsysfs.h b/src/sysinfolibsysfs.h index f5de0aa..df746f3 100644 --- a/src/sysinfolibsysfs.h +++ b/src/sysinfolibsysfs.h @@ -39,16 +39,15 @@ extern "C" { #include "fbgui.h" #include -class SysInfoLibsysfs : public QObject -{ - Q_OBJECT +class SysInfoLibsysfs: public QObject { +Q_OBJECT public: - SysInfoLibsysfs(); - virtual ~SysInfoLibsysfs(); - void getInfoAboutNetworkInterface(); - void getInfoAboutClassNet(); - void getInfoMbSerial(); - QString getInfoMainboardSerial(); + SysInfoLibsysfs(); + virtual ~SysInfoLibsysfs(); + void getInfoAboutNetworkInterface(); + void getInfoAboutClassNet(); + void getInfoMbSerial(); + QString getInfoMainboardSerial(); }; -- cgit v1.2.3-55-g7522 From d64a82af25a484e887a7e1482ce810eff0671739 Mon Sep 17 00:00:00 2001 From: joe Date: Thu, 21 Apr 2011 23:43:53 +0200 Subject: few more comments in fbgui --- src/fbgui.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/fbgui.cpp b/src/fbgui.cpp index fdedf1f..bd0c508 100644 --- a/src/fbgui.cpp +++ b/src/fbgui.cpp @@ -327,7 +327,7 @@ void fbgui::performReboot() { } } //------------------------------------------------------------------------------------------- -// Preparing System Boot (Stage 3) +// Preparing Kernel Switch per kexec (initiating Stage 3) //------------------------------------------------------------------------------------------- /** * This method prepares kexec. @@ -335,6 +335,13 @@ void fbgui::performReboot() { * 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. * + * A process is then started to load the kernel, initramfs and kcl into kexec. + * The process tries to execute kexec -l with these parameters. + * + * If this succeeds, runKexec() is called + * + * @see fbgui::runKexec() + * */ void fbgui::prepareKexec() { @@ -392,8 +399,7 @@ 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 + * This method tries to execute: kexec -e * */ void fbgui::runKexec() { -- cgit v1.2.3-55-g7522 From 5e05006fdd62ee804379faa1e759b85f8892eb32 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Sun, 24 Apr 2011 02:21:09 +0200 Subject: loading system page --- src/html/loadsystem.css | 98 ++++++++++++++++++++++++++++++++++++++++++++++++ src/html/loadsystem.html | 43 +++++++++++++++++++++ 2 files changed, 141 insertions(+) create mode 100644 src/html/loadsystem.css create mode 100644 src/html/loadsystem.html diff --git a/src/html/loadsystem.css b/src/html/loadsystem.css new file mode 100644 index 0000000..d0e8a90 --- /dev/null +++ b/src/html/loadsystem.css @@ -0,0 +1,98 @@ +html,body{ + height:100%; +} +body{ + margin:0; + padding:0; + background-color:black; + background-size:100%; +} +#top{ + position:absolute; + top:38%; + left:41%; +} +h1, p{ + margin:0; + padding:0.3em 0; + color:white; +} +#container{ + min-height:100%; + margin-bottom:-50px; +} +* html #container{ + height:100%; +} +#footer-spacer{ + height:0px; +} +#footer{ + height:30px; + text-align:center; +} +/* position the bars and balls correctly (rotate them and translate them outward)*/ +.bar1 { + -moz-transform:rotate(0deg) translate(0, -40px); + -webkit-transform:rotate(0deg) translate(0, -40px);opacity:0.12; +} +.bar2 { + -moz-transform:rotate(45deg) translate(0, -40px); + -webkit-transform:rotate(45deg) translate(0, -40px);opacity:0.25; +} +.bar3 { + -moz-transform:rotate(90deg) translate(0, -40px); + -webkit-transform:rotate(90deg) translate(0, -40px);opacity:0.37; +} +.bar4 { + -moz-transform:rotate(135deg) translate(0, -40px); + -webkit-transform:rotate(135deg) translate(0, -40px);opacity:0.50; +} +.bar5 { + -moz-transform:rotate(180deg) translate(0, -40px); + -webkit-transform:rotate(180deg) translate(0, -40px);opacity:0.62; +} +.bar6 { + -moz-transform:rotate(225deg) translate(0, -40px); + -webkit-transform:rotate(225deg) translate(0, -40px);opacity:0.75; +} +.bar7 { + -moz-transform:rotate(270deg) translate(0, -40px); + -webkit-transform:rotate(270deg) translate(0, -40px);opacity:0.87; +} +.bar8 { + -moz-transform:rotate(315deg) translate(0, -40px); + -webkit-transform:rotate(315deg) translate(0, -40px);opacity:1; +} +#div4 { + position:absolute; + left:50%; + top:50%; + margin-left:-50px; + margin-top:-50px; + width:100px; + height:100px; + -moz-border-radius:100px; + -webkit-border-radius:100px; + -moz-transform:scale(0.5); + -webkit-transform:scale(0.5); + -webkit-animation-name: rotateThis; + -webkit-animation-duration:2s; + -webkit-animation-iteration-count:infinite; + -webkit-animation-timing-function:linear; +} +#div4 div { + width:20px; + height:20px; + background:#fff; + -moz-border-radius:40px; + -webkit-border-radius:40px; + position:absolute; + left:40px; + top:40px; +} +/* add a shadow to the first */ +#div4 div { + -moz-box-shadow:black 0 0 4px; + -webkit-box-shadow:black 0 0 4px; +} diff --git a/src/html/loadsystem.html b/src/html/loadsystem.html new file mode 100644 index 0000000..f01ba5b --- /dev/null +++ b/src/html/loadsystem.html @@ -0,0 +1,43 @@ + + + + + + +
+

Loading system, please wait...

+
+
+
+
+
+
+
+
+
+
+
+
+ +
+ + + -- cgit v1.2.3-55-g7522 From ce42f447314d241d725f77d4dd12b00f7ca5a7b6 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Sun, 24 Apr 2011 02:22:03 +0200 Subject: download manager threaded again, debug preload page --- src/downloadmanager.cpp | 2 +- src/fbgui.cpp | 38 +++++++++++++++++++++++++++----------- src/fbgui.h | 3 ++- src/fbgui.qrc | 2 ++ src/html/preload-debug.html | 8 ++++---- 5 files changed, 36 insertions(+), 17 deletions(-) diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 1be8964..7458b4c 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -7,7 +7,7 @@ DownloadManager::DownloadManager() { qxtLog->debug() << "Initializing download manager..."; checkDownloadDirectory(); _qnam = new QNetworkAccessManager(); - //_qnam->moveToThread(&dmThread); + _qnam->moveToThread(&dmThread); dip = false; } DownloadManager::~DownloadManager() { diff --git a/src/fbgui.cpp b/src/fbgui.cpp index bd0c508..63f6983 100644 --- a/src/fbgui.cpp +++ b/src/fbgui.cpp @@ -10,7 +10,7 @@ #include #include -//QThread dmThread; +QThread dmThread; QString ipConfigFilePath(""); QString binPath(""); QUrl baseURL(""); @@ -68,16 +68,20 @@ fbgui::fbgui() { SLOT(updateProgressBar(const int&, const double&, const QString&))); QObject::connect(dm, SIGNAL(downloadQueueEmpty()), jsi, SLOT( callbackOnFinished())); - QObject::connect(dm, SIGNAL(downloadQueueEmpty()), this, - SLOT(prepareKexec())); + QObject::connect(dm, SIGNAL(downloadQueueEmpty()), this, SLOT(loadSystem())); // move download manager to its own thread - //dm->moveToThread(&dmThread); - //dmThread.start(); + dm->moveToThread(&dmThread); + dmThread.start(); // show "waiting for internet" page until triggered. - _webView->load(QUrl("qrc:/html/preload.html")); + if (debugMode > -1) { + _webView->load(QUrl("qrc:/html/preload-debug.html")); + } else { + _webView->load(QUrl("qrc:/html/preload.html")); + } //statusBar()->showMessage("Waiting for internet..."); + // start watching for fileToTriggerURL watchForTrigger(); @@ -88,7 +92,7 @@ fbgui::fbgui() { showFullScreen(); } fbgui::~fbgui() { - //dmThread.quit(); + dmThread.quit(); } //------------------------------------------------------------------------------------------- // Layout / actions setup @@ -186,9 +190,10 @@ void fbgui::prepareURLLoad() { // Preparations for URL load //------------------------------------------------------------------------------------------- /** - * This method checks if is connected to the internet. + * This method checks the existance of the host. * - * This method checks if is connected to the internet. + * This method checks if the host exists / can be found. + * The host is from the URL given through the configuration. */ bool fbgui::checkHost() const { QHostInfo hostInfo = QHostInfo::fromName(baseURL.host()); @@ -203,7 +208,7 @@ bool fbgui::checkHost() const { } //------------------------------------------------------------------------------------------- /** - * This method loads the main screen. + * This method tries loads the URL. * * This method loads the main screen via an POST request. If also disconnects the watcher * of the file, (Watcher is set in the fbgui::watchForTrigger() method). @@ -224,6 +229,7 @@ void fbgui::loadURL() { QWSServer::instance()->setCursorVisible(true); _webView->load(req, QNetworkAccessManager::PostOperation, postData); } + // TODO: error page if no host. } //------------------------------------------------------------------------------------------- /** @@ -234,6 +240,8 @@ void fbgui::loadURL() { * The hardwarehash is a MD5 hash over the MAC address and the * mainboard serial number. * The specific serial number is set at the creation of the usb boot stick. + * This file has to be present on the directory specified in + * the configuration for this to work. * * @see SysInfo::getMACAddress() * @see SysInfo::getMainboardSerial() @@ -277,7 +285,7 @@ QByteArray fbgui::generatePOSTData() { } //------------------------------------------------------------------------------------------- -// System Calls Functions +// Shutdown / Reboot of the client //------------------------------------------------------------------------------------------- // TODO One function for reboot and shutdown, with parameter for the action. // for example: doSystemCall(_REBOOT_); @@ -453,3 +461,11 @@ void fbgui::createDebugConsole() { void fbgui::toggleDebugConsole() { (_debugConsole->isVisible()) ? _debugConsole->hide() : _debugConsole->show(); } +//------------------------------------------------------------------------------------------- +// +//------------------------------------------------------------------------------------------- +void fbgui::loadSystem() { + //show loading system page. + _webView->load(QUrl("qrc:/html/loadsystem.html")); + prepareKexec(); +} diff --git a/src/fbgui.h b/src/fbgui.h index 664eea4..48ddce4 100644 --- a/src/fbgui.h +++ b/src/fbgui.h @@ -109,7 +109,8 @@ private slots: void performShutDown(); // reboot the system void performReboot(); - // prepareKexec + // Kexec + void loadSystem(); void prepareKexec(); void runKexec(); }; diff --git a/src/fbgui.qrc b/src/fbgui.qrc index 10a8bd6..8f576cc 100644 --- a/src/fbgui.qrc +++ b/src/fbgui.qrc @@ -8,5 +8,7 @@ html/preload.html html/bg.png html/preload-debug.html + html/loadsystem.css + html/loadsystem.html diff --git a/src/html/preload-debug.html b/src/html/preload-debug.html index cc69aa1..0aad6c5 100644 --- a/src/html/preload-debug.html +++ b/src/html/preload-debug.html @@ -13,13 +13,13 @@ function quitgui(){

Preboot GUI

+

Waiting on internet... + -

Waiting on internet...i -

-- cgit v1.2.3-55-g7522 From 9bc86ea4a4179cf671a3aa23ed833f80bfa927dd Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Sun, 24 Apr 2011 16:37:14 +0200 Subject: dm thread ending properly now, few fixes --- src/fbgui.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/fbgui.cpp b/src/fbgui.cpp index 63f6983..e3c2d3a 100644 --- a/src/fbgui.cpp +++ b/src/fbgui.cpp @@ -61,13 +61,12 @@ fbgui::fbgui() { SLOT(notify(const QString&))); QObject::connect(jsi, SIGNAL(requestFile(const QString&)), dm, SLOT(downloadFile(const QString&))); - QObject::connect( - dm, + 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()), jsi, + SLOT(callbackOnFinished())); QObject::connect(dm, SIGNAL(downloadQueueEmpty()), this, SLOT(loadSystem())); // move download manager to its own thread @@ -92,7 +91,7 @@ fbgui::fbgui() { showFullScreen(); } fbgui::~fbgui() { - dmThread.quit(); + //dmThread.quit(); } //------------------------------------------------------------------------------------------- // Layout / actions setup @@ -162,8 +161,8 @@ 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())); } //------------------------------------------------------------------------------------------- @@ -353,6 +352,7 @@ void fbgui::performReboot() { */ void fbgui::prepareKexec() { + qxtLog->debug() << "[gui] Preparing kexec ..."; // try to read KCL file that was downloaded. QFile file(downloadPath + "/kcl"); if (!file.open(QIODevice::ReadOnly)) { @@ -465,6 +465,10 @@ void fbgui::toggleDebugConsole() { // //------------------------------------------------------------------------------------------- void fbgui::loadSystem() { + // stop the thread for the download manager + qxtLog->debug() << "[gui] Stopping download manager's thread..."; + dmThread.quit(); + //show loading system page. _webView->load(QUrl("qrc:/html/loadsystem.html")); prepareKexec(); -- cgit v1.2.3-55-g7522 From 51a1b87480973792fcadb35767d7b61f32d12df9 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Sun, 24 Apr 2011 16:59:50 +0200 Subject: auto-close removed, handled by fbgui nowmake --- src/loggerengine.cpp | 51 +++++++++++++++++++++++++++++++++++++++------------ src/loggerengine.h | 13 ++++++++++++- src/main.cpp | 9 ++++++++- 3 files changed, 59 insertions(+), 14 deletions(-) diff --git a/src/loggerengine.cpp b/src/loggerengine.cpp index 51fba62..3a44159 100644 --- a/src/loggerengine.cpp +++ b/src/loggerengine.cpp @@ -32,8 +32,8 @@ bool LoggerEngine_fb::isInitialized() const { return true; } -void LoggerEngine_fb::writeFormatted(QxtLogger::LogLevel level, const QList< - QVariant> & msgs) { +void LoggerEngine_fb::writeFormatted(QxtLogger::LogLevel level, + const QList & msgs) { // ignore in case no messages was passed. if (msgs.isEmpty()) @@ -47,10 +47,10 @@ void LoggerEngine_fb::writeFormatted(QxtLogger::LogLevel level, const QList< // only write to console for debug level if (level == QxtLogger::DebugLevel) { Q_FOREACH(const QVariant& out, msgs) - { - if (!out.isNull()) - _debugConsole->insertPlainText(out.toString()); - } + { + if (!out.isNull()) + _debugConsole->insertPlainText(out.toString()); + } _debugConsole->insertPlainText(QString("\n")); // autoscroll QTextCursor c = _debugConsole->textCursor(); @@ -68,8 +68,8 @@ LoggerEngine_std::LoggerEngine_std() : LoggerEngine_std::~LoggerEngine_std() { } -void LoggerEngine_std::writeToStdErr(const QString& str_level, const QList< - QVariant> &msgs) { +void LoggerEngine_std::writeToStdErr(const QString& str_level, + const QList &msgs) { if (msgs.isEmpty()) return; @@ -78,10 +78,10 @@ void LoggerEngine_std::writeToStdErr(const QString& str_level, const QList< Q_ASSERT(errstream); *errstream << header; Q_FOREACH(const QVariant& out, msgs) - { - if (!out.isNull()) - *errstream << out.toString(); - } + { + if (!out.isNull()) + *errstream << out.toString(); + } *errstream << endl; } void LoggerEngine_std::writeToStdOut(const QString& level, @@ -89,3 +89,30 @@ void LoggerEngine_std::writeToStdOut(const QString& level, // reimplementing this is needed for compiling, // we only need write to std::err, so this function is not needed } +//--------------------------------------------------------------------------------------------------- +// slighty modified QxtBasicFileLoggerEngine +//--------------------------------------------------------------------------------------------------- +LoggerEngine_file::LoggerEngine_file() : + QxtBasicFileLoggerEngine() { +} + +LoggerEngine_file::~LoggerEngine_file() { +} + +LoggerEngine_file::initLoggerEngine() {} + +void LoggerEngine_file::writeToFile(const QString& str_level, + const QList &msgs) { + + if (msgs.isEmpty()) + return; + QIODevice* file = device(); + QString header = '[' + QTime::currentTime().toString("hh:mm:ss.zzz") + "] "; + file->write(header.toUtf8()); + Q_FOREACH(const QVariant& out, msgs) + { + if (!out.isNull()) + file->write(out.toString().toUtf8()); + } + file->write("\n"); +} diff --git a/src/loggerengine.h b/src/loggerengine.h index 95a8f93..45f6827 100644 --- a/src/loggerengine.h +++ b/src/loggerengine.h @@ -49,9 +49,20 @@ public: LoggerEngine_std(); ~LoggerEngine_std(); - // reimplemented virtual functions of QxtBasicSTDLoggerEngineqqq + // reimplemented virtual functions of QxtBasicSTDLoggerEngine void writeToStdOut(const QString& level, const QList &msgs); void writeToStdErr(const QString& str_level, const QList &msgs); }; +//--------------------------------------------------------------------------------------------------- +// slighty modified QxtBasicFileLoggerEngine +//--------------------------------------------------------------------------------------------------- +class LoggerEngine_file: public QxtBasicFileLoggerEngine { +public: + LoggerEngine_file(); + ~LoggerEngine_file(); + + // reimplemented virtual functions of QxtBasicFileLoggerEngine + void writeToFile(const QString& level, const QList &msgs); +}; #endif // LOGGERENGINE_H_ diff --git a/src/main.cpp b/src/main.cpp index 9b0a18a..601a62e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -88,13 +88,20 @@ int main(int argc, char *argv[]) { if (clOpts.contains("debug")) { debugMode = clOpts.value("debug").toInt(); - // start basic debug log + // start basic debug output on terminal qxtLog->disableLoggerEngine("DEFAULT"); qxtLog->addLoggerEngine("std_logger", new LoggerEngine_std); qxtLog->initLoggerEngine("std_logger"); qxtLog->setMinimumLevel("std_logger", QxtLogger::DebugLevel); qxtLog->enableLogLevels(QxtLogger::DebugLevel); qxtLog->debug() << "Initializing fbgui..."; + // start debug logging to file. + qxtLog->addLoggerEngine("file_logger", new LoggerEngine_file); + + //qxtLog->initLoggerEngine("std_logger"); + //qxtLog->setMinimumLevel("std_logger", QxtLogger::DebugLevel); + //qxtLog->enableLogLevels(QxtLogger::DebugLevel); + } else debugMode = -1; -- cgit v1.2.3-55-g7522 From 518ab031c29f36095578c8819e0befa503d1ae1d Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Sun, 24 Apr 2011 17:28:07 +0200 Subject: new logger engine to output in file, configurable per cmdline / config file --- fbgui.conf | 1 + src/downloadmanager.cpp | 1 - src/fbgui.cpp | 1 + src/fbgui.h | 4 +++- src/loggerengine.cpp | 8 +++++--- src/loggerengine.h | 4 +++- src/main.cpp | 43 +++++++++++++++++++++++++++++-------------- 7 files changed, 42 insertions(+), 20 deletions(-) diff --git a/fbgui.conf b/fbgui.conf index ac2cecb..8c79c8f 100644 --- a/fbgui.conf +++ b/fbgui.conf @@ -5,3 +5,4 @@ update_interval=5 file_trigger=/tmp/fbgui_trigger serial_location=/serial ip_config=/tmp/ip_config +log_file=/tmp/fbgui.log diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 7458b4c..adbedd1 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -1,5 +1,4 @@ #include "downloadmanager.h" -#include "fbgui.h" int DownloadManager::downloaded = 0; // ------------------------------------------------------------------------------------------------------- diff --git a/src/fbgui.cpp b/src/fbgui.cpp index e3c2d3a..3494b83 100644 --- a/src/fbgui.cpp +++ b/src/fbgui.cpp @@ -11,6 +11,7 @@ #include QThread dmThread; +QString logFilePath(""); QString ipConfigFilePath(""); QString binPath(""); QUrl baseURL(""); diff --git a/src/fbgui.h b/src/fbgui.h index 48ddce4..98ab4c4 100644 --- a/src/fbgui.h +++ b/src/fbgui.h @@ -26,13 +26,15 @@ // Internal default settings #define DEFAULT_URL "http://www.google.com" -#define DEFAULT_DOWNLOAD_DIR "/tmp/fbgui/downloads" +#define DEFAULT_DOWNLOAD_DIR "/tmp/fbgui" #define DEFAULT_CONFIG_PATH "/etc/fbgui.conf" +#define DEFAULT_LOG_FILE_PATH "/tmp/fbgui.log" #define DEFAULT_UPDATE_INTERVAL 1; #define DEFAULT_QRC_HTML_DIR ":/html" #define DEFAULT_FILE_TRIGGER "/tmp/fbgui/trigger" // Global settings variables +extern QString logFilePath; extern QString ipConfigFilePath; extern QThread dmThread; extern QString serialLocation; diff --git a/src/loggerengine.cpp b/src/loggerengine.cpp index 3a44159..fd44633 100644 --- a/src/loggerengine.cpp +++ b/src/loggerengine.cpp @@ -92,14 +92,16 @@ void LoggerEngine_std::writeToStdOut(const QString& level, //--------------------------------------------------------------------------------------------------- // slighty modified QxtBasicFileLoggerEngine //--------------------------------------------------------------------------------------------------- -LoggerEngine_file::LoggerEngine_file() : - QxtBasicFileLoggerEngine() { +LoggerEngine_file::LoggerEngine_file(const QString& logFileName) : + QxtBasicFileLoggerEngine(logFileName) { + //setLogFileName(logFileName); } LoggerEngine_file::~LoggerEngine_file() { } -LoggerEngine_file::initLoggerEngine() {} +void LoggerEngine_file::initLoggerEngine() { +} void LoggerEngine_file::writeToFile(const QString& str_level, const QList &msgs) { diff --git a/src/loggerengine.h b/src/loggerengine.h index 45f6827..94cf59e 100644 --- a/src/loggerengine.h +++ b/src/loggerengine.h @@ -20,6 +20,7 @@ #include #include #include + //--------------------------------------------------------------------------------------------------- // base of a custom logger engine for the framebuffer //--------------------------------------------------------------------------------------------------- @@ -58,8 +59,9 @@ public: //--------------------------------------------------------------------------------------------------- class LoggerEngine_file: public QxtBasicFileLoggerEngine { public: - LoggerEngine_file(); + LoggerEngine_file(const QString& logFileName); ~LoggerEngine_file(); + void initLoggerEngine(); // reimplemented virtual functions of QxtBasicFileLoggerEngine void writeToFile(const QString& level, const QList &msgs); diff --git a/src/main.cpp b/src/main.cpp index 601a62e..24e0430 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -54,13 +54,17 @@ int main(int argc, char *argv[]) { NULL, 'c' }, { "url", required_argument, NULL, 'u' }, { "download", required_argument, NULL, 'd' }, { "serial", required_argument, NULL, 's' }, { "trigger", required_argument, NULL, 't' }, { "debug", - required_argument, NULL, 'D' }, { "help", no_argument, NULL, 'h' } }; + required_argument, NULL, 'D' }, { "help", no_argument, NULL, 'h' }, { + "logfile", required_argument, NULL, 'l' } }; int opt = getopt_long(argc, argv, optString, longOpts, &longIndex); while (opt != -1) { switch (opt) { case 'c': clOpts.insert("configFile", optarg); break; + case 'l': + clOpts.insert("logFile", optarg); + break; case 'u': clOpts.insert("url", optarg); break; @@ -90,18 +94,10 @@ int main(int argc, char *argv[]) { debugMode = clOpts.value("debug").toInt(); // start basic debug output on terminal qxtLog->disableLoggerEngine("DEFAULT"); + qxtLog->enableLogLevels(QxtLogger::DebugLevel); qxtLog->addLoggerEngine("std_logger", new LoggerEngine_std); qxtLog->initLoggerEngine("std_logger"); qxtLog->setMinimumLevel("std_logger", QxtLogger::DebugLevel); - qxtLog->enableLogLevels(QxtLogger::DebugLevel); - qxtLog->debug() << "Initializing fbgui..."; - // start debug logging to file. - qxtLog->addLoggerEngine("file_logger", new LoggerEngine_file); - - //qxtLog->initLoggerEngine("std_logger"); - //qxtLog->setMinimumLevel("std_logger", QxtLogger::DebugLevel); - //qxtLog->enableLogLevels(QxtLogger::DebugLevel); - } else debugMode = -1; @@ -175,12 +171,27 @@ int main(int argc, char *argv[]) { // save ip config location (file generated by uchpc) if (confFileSettings.contains("default/ip_config")) ipConfigFilePath = confFileSettings.value("default/ip_config").toString(); - //else - // ipConfigFilePath = QString("/tmp/ip_config"); + + // save path to log file + if (clOpts.contains("logFile")) + logFilePath = clOpts.value("logFile"); + else if (confFileSettings.contains("default/log_file")) + logFilePath = confFileSettings.value("default/log_file").toString(); + else + logFilePath = DEFAULT_LOG_FILE_PATH; + + // activate file logger if debug mode activated. + if (debugMode > -1) { + // start debug logging to file. + qxtLog->addLoggerEngine("file_logger", + new LoggerEngine_file(logFilePath)); + qxtLog->setMinimumLevel("file_logger", QxtLogger::DebugLevel); + } // print config qxtLog->debug() << "************* CONFIG INFO *************"; qxtLog->debug() << "configFilePath: " << configFilePath.toUtf8(); + qxtLog->debug() << "logFilePath: " << logFilePath.toUtf8(); qxtLog->debug() << "ipConfigFilePath:" << ipConfigFilePath.toUtf8(); qxtLog->debug() << "baseURL: " << baseURL.toString().toUtf8(); qxtLog->debug() << "downloadDir : " << downloadPath.toUtf8(); @@ -190,9 +201,13 @@ int main(int argc, char *argv[]) { // set invisible cursor QWSServer::instance()->setCursorVisible(false); - QWSServer::instance()->setDefaultKeyboard("TTY:/dev/tty0"); - QWSServer::instance()->setDefaultMouse("IntelliMouse:/dev/mice"); + + // set default keyboard / mouse drivers. TODO: fix this, doesn't work... + //QWSServer::instance()->setDefaultKeyboard("TTY:/dev/tty0"); + //QWSServer::instance()->setDefaultMouse("IntelliMouse:/dev/mice"); + // start fbgui + qxtLog->debug() << "Initializing fbgui..."; fbgui gui; gui.show(); return app.exec(); -- cgit v1.2.3-55-g7522 From a7fb2734a2e1e29a63fa60beae00b3a2496c8e5b Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Sun, 24 Apr 2011 17:42:03 +0200 Subject: log file config fix --- src/fbgui.h | 2 +- src/main.cpp | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/fbgui.h b/src/fbgui.h index 98ab4c4..5c3247d 100644 --- a/src/fbgui.h +++ b/src/fbgui.h @@ -28,7 +28,7 @@ #define DEFAULT_URL "http://www.google.com" #define DEFAULT_DOWNLOAD_DIR "/tmp/fbgui" #define DEFAULT_CONFIG_PATH "/etc/fbgui.conf" -#define DEFAULT_LOG_FILE_PATH "/tmp/fbgui.log" +#define DEFAULT_LOG_FILE_PATH "/tmp/fbgui.log2" #define DEFAULT_UPDATE_INTERVAL 1; #define DEFAULT_QRC_HTML_DIR ":/html" #define DEFAULT_FILE_TRIGGER "/tmp/fbgui/trigger" diff --git a/src/main.cpp b/src/main.cpp index 24e0430..d51bc02 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -49,13 +49,13 @@ int main(int argc, char *argv[]) { // parse command line arguments using getopt QMap clOpts; int longIndex = 0; - static const char *optString = "c:u:d:s:t:D:h"; + static const char *optString = "c:u:d:s:t:D:hl:"; static const struct option longOpts[] = { { "config", required_argument, NULL, 'c' }, { "url", required_argument, NULL, 'u' }, { "download", required_argument, NULL, 'd' }, { "serial", required_argument, NULL, 's' }, { "trigger", required_argument, NULL, 't' }, { "debug", required_argument, NULL, 'D' }, { "help", no_argument, NULL, 'h' }, { - "logfile", required_argument, NULL, 'l' } }; + "log", required_argument, NULL, 'l' } }; int opt = getopt_long(argc, argv, optString, longOpts, &longIndex); while (opt != -1) { switch (opt) { @@ -144,6 +144,7 @@ int main(int argc, char *argv[]) { else downloadPath = DEFAULT_DOWNLOAD_DIR; + // set update interval for download progress functions of download manager. if (confFileSettings.contains("default/update_interval")) updateInterval = confFileSettings.value("default/update_interval").toInt(); @@ -173,8 +174,8 @@ int main(int argc, char *argv[]) { ipConfigFilePath = confFileSettings.value("default/ip_config").toString(); // save path to log file - if (clOpts.contains("logFile")) - logFilePath = clOpts.value("logFile"); + if (clOpts.contains("logFile")){ + logFilePath = clOpts.value("logFile");qxtLog->debug() << "LOG FILE: " << clOpts.value("logFile");} else if (confFileSettings.contains("default/log_file")) logFilePath = confFileSettings.value("default/log_file").toString(); else -- cgit v1.2.3-55-g7522 From 489d9d0b8fa4dacd715c3a3fccaabd12efe8ce50 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Sun, 24 Apr 2011 17:44:55 +0200 Subject: AUTHORS added, please complete info --- AUTHORS | 5 +++++ fbgui.conf | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 AUTHORS diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..f70178f --- /dev/null +++ b/AUTHORS @@ -0,0 +1,5 @@ +Authors: + +Jonathan Bauer +Niklas Goby <...> +Sebastian Wagner <...> diff --git a/fbgui.conf b/fbgui.conf index 8c79c8f..af0b39f 100644 --- a/fbgui.conf +++ b/fbgui.conf @@ -1,5 +1,5 @@ [default] -pbs_url=http://132.230.4.27 +pbs_url=http://pbs2.mp.openslx.org/fbgui download_directory=/tmp update_interval=5 file_trigger=/tmp/fbgui_trigger -- cgit v1.2.3-55-g7522 From e4fd0bbd9d9b08ba9381d253b4987e719890cd69 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Sun, 24 Apr 2011 17:46:42 +0200 Subject: AUTHORS more info --- AUTHORS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AUTHORS b/AUTHORS index f70178f..fb44522 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,3 +1,6 @@ +Master-Teamproject at Lehrstuhl fuer Kommunikationssysteme for Uni Freiburg, 2010-2011. +Sub-Project: Framebuffer-GUI "fbgui" + Authors: Jonathan Bauer -- cgit v1.2.3-55-g7522 From e1e2bc138cafa1e5f26b377b36d31812f59c5e35 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Sun, 24 Apr 2011 18:10:03 +0200 Subject: old test --- build.sh | 2 +- src/downloadmanager.cpp | 18 +++++++++++------- src/fbgui.h | 2 +- src/javascriptinterface.cpp | 30 +++++++++++++++--------------- src/main.cpp | 24 ++++++++++++------------ 5 files changed, 40 insertions(+), 36 deletions(-) diff --git a/build.sh b/build.sh index 8ea3fc5..2eabc4f 100755 --- a/build.sh +++ b/build.sh @@ -1,7 +1,7 @@ #!/bin/bash QT_VERSION=QtEmbedded-4.7.2 -rm fbgui.tgz +[ -f fbgui.tgz ] && rm fbgui.tgz mkdir -p pkg diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index adbedd1..22c1c09 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -103,8 +103,9 @@ void DownloadManager::startNextDownload() { if (downloadDir.exists(tmp)) { qxtLog->debug() << "[dm] File already exists: " << downloadDir.absoluteFilePath(tmp); - outfile.setFileName(QString(downloadDir.absolutePath() + "/" + tmp - + ".\%1").arg(downloaded)); + outfile.setFileName( + QString(downloadDir.absolutePath() + "/" + tmp + ".\%1").arg( + downloaded)); } else outfile.setFileName(downloadDir.absoluteFilePath(tmp)); qxtLog->debug() << "[dm] Saving to: " << outfile.fileName(); @@ -172,7 +173,8 @@ void DownloadManager::downloadProgress(qint64 bytesIn, qint64 bytesTotal) { currentProgress = ((bytesIn * 100) / bytesTotal); if (currentProgress - lastProgress >= updateInterval) { lastProgress = currentProgress; - emit updateProgress(currentProgress, speed, unit); + emit + updateProgress(currentProgress, speed, unit); qxtLog->debug() << "[dm] Download progress of " << currentDownload->url().toString() << ": " << bytesIn << "/" << bytesTotal << "(" << currentProgress << "\%)"; @@ -189,8 +191,8 @@ void DownloadManager::downloadFinished() { qxtLog->debug() << "[dm] Download of " << currentDownload->url().toString() << " failed with HTTP error code: " << statusCode; - emit notify(QString("Download failed! HTTP Status Code: %1").arg( - statusCode)); + emit + notify(QString("Download failed! HTTP Status Code: %1").arg(statusCode)); currentDownload->deleteLater(); } else { // end download @@ -199,8 +201,10 @@ void DownloadManager::downloadFinished() { qxtLog->debug() << "[dm] Download of " << currentDownload->url().toString() << " finished. (downloaded = " << downloaded << ")"; - emit notify(QString("Successfully downloaded %1").arg( - currentDownload->url().toString())); + emit + notify( + QString("Successfully downloaded %1").arg( + currentDownload->url().toString())); currentDownload->deleteLater(); } dip = false; diff --git a/src/fbgui.h b/src/fbgui.h index 5c3247d..98ab4c4 100644 --- a/src/fbgui.h +++ b/src/fbgui.h @@ -28,7 +28,7 @@ #define DEFAULT_URL "http://www.google.com" #define DEFAULT_DOWNLOAD_DIR "/tmp/fbgui" #define DEFAULT_CONFIG_PATH "/etc/fbgui.conf" -#define DEFAULT_LOG_FILE_PATH "/tmp/fbgui.log2" +#define DEFAULT_LOG_FILE_PATH "/tmp/fbgui.log" #define DEFAULT_UPDATE_INTERVAL 1; #define DEFAULT_QRC_HTML_DIR ":/html" #define DEFAULT_FILE_TRIGGER "/tmp/fbgui/trigger" diff --git a/src/javascriptinterface.cpp b/src/javascriptinterface.cpp index eba4027..18949ae 100644 --- a/src/javascriptinterface.cpp +++ b/src/javascriptinterface.cpp @@ -56,23 +56,23 @@ void JavascriptInterface::loadJQuery() { QDir qrcJSDir(pathToJsDir); QFileInfoList fiList = qrcJSDir.entryInfoList(); QFileInfo fi; -foreach(fi, fiList) -{ - if (fi.suffix() == "js") { - //qDebug()<< fi.fileName(); - //qxtLog->debug() << fi.fileName(); - if (fi.fileName() != "test.js") { - QFile file; - file.setFileName(pathToJsDir + "/" + fi.fileName()); - file.open(QIODevice::ReadOnly); - js = file.readAll(); - file.close(); + foreach(fi, fiList) + { + if (fi.suffix() == "js") { + //qDebug()<< fi.fileName(); + //qxtLog->debug() << fi.fileName(); + if (fi.fileName() != "test.js") { + QFile file; + file.setFileName(pathToJsDir + "/" + fi.fileName()); + file.open(QIODevice::ReadOnly); + js = file.readAll(); + file.close(); - _parent->evaluateJavaScript(js); - //qxtLog->debug() << "evaluated " + fi.fileName(); + _parent->evaluateJavaScript(js); + //qxtLog->debug() << "evaluated " + fi.fileName(); + } + } } - } -} } //------------------------------------------------------------------------------------------------------- // Javascript functions for webpage diff --git a/src/main.cpp b/src/main.cpp index d51bc02..c913b40 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -174,9 +174,10 @@ int main(int argc, char *argv[]) { ipConfigFilePath = confFileSettings.value("default/ip_config").toString(); // save path to log file - if (clOpts.contains("logFile")){ - logFilePath = clOpts.value("logFile");qxtLog->debug() << "LOG FILE: " << clOpts.value("logFile");} - else if (confFileSettings.contains("default/log_file")) + if (clOpts.contains("logFile")) { + logFilePath = clOpts.value("logFile"); + qxtLog->debug() << "LOG FILE: " << clOpts.value("logFile"); + } else if (confFileSettings.contains("default/log_file")) logFilePath = confFileSettings.value("default/log_file").toString(); else logFilePath = DEFAULT_LOG_FILE_PATH; @@ -184,20 +185,19 @@ int main(int argc, char *argv[]) { // activate file logger if debug mode activated. if (debugMode > -1) { // start debug logging to file. - qxtLog->addLoggerEngine("file_logger", - new LoggerEngine_file(logFilePath)); + qxtLog->addLoggerEngine("file_logger", new LoggerEngine_file(logFilePath)); qxtLog->setMinimumLevel("file_logger", QxtLogger::DebugLevel); } // print config qxtLog->debug() << "************* CONFIG INFO *************"; - qxtLog->debug() << "configFilePath: " << configFilePath.toUtf8(); - qxtLog->debug() << "logFilePath: " << logFilePath.toUtf8(); - qxtLog->debug() << "ipConfigFilePath:" << ipConfigFilePath.toUtf8(); - qxtLog->debug() << "baseURL: " << baseURL.toString().toUtf8(); - qxtLog->debug() << "downloadDir : " << downloadPath.toUtf8(); - qxtLog->debug() << "trigger: " << fileToTriggerURL.toUtf8(); - qxtLog->debug() << "serialLocation: " << serialLocation.toUtf8(); + qxtLog->debug() << "configFilePath: " << configFilePath.toUtf8(); + qxtLog->debug() << "logFilePath: " << logFilePath.toUtf8(); + qxtLog->debug() << "ipConfigFilePath: " << ipConfigFilePath.toUtf8(); + qxtLog->debug() << "baseURL: " << baseURL.toString().toUtf8(); + qxtLog->debug() << "downloadDir : " << downloadPath.toUtf8(); + qxtLog->debug() << "trigger: " << fileToTriggerURL.toUtf8(); + qxtLog->debug() << "serialLocation: " << serialLocation.toUtf8(); qxtLog->debug() << "*******************************************"; // set invisible cursor -- cgit v1.2.3-55-g7522 From 80599bbbe80d8672a14132d8773a7796d56688e9 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Sun, 24 Apr 2011 18:20:14 +0200 Subject: more old tests... --- src/main.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c913b40..a319ae4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -174,10 +174,9 @@ int main(int argc, char *argv[]) { ipConfigFilePath = confFileSettings.value("default/ip_config").toString(); // save path to log file - if (clOpts.contains("logFile")) { + if (clOpts.contains("logFile")) logFilePath = clOpts.value("logFile"); - qxtLog->debug() << "LOG FILE: " << clOpts.value("logFile"); - } else if (confFileSettings.contains("default/log_file")) + else if (confFileSettings.contains("default/log_file")) logFilePath = confFileSettings.value("default/log_file").toString(); else logFilePath = DEFAULT_LOG_FILE_PATH; -- cgit v1.2.3-55-g7522 From 03ac351f38316d8f923f3797aa7dd0deade7ed5d Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Sun, 24 Apr 2011 21:36:26 +0200 Subject: url status handling, 5sec delay before closing gui when exiting with failure (not actually returning 1 atm), lots of formatting... --- src/downloadmanager.cpp | 160 ++++++++++++++++++++------------------------ src/downloadmanager.h | 57 ++++++++-------- src/fbgui.cpp | 82 ++++++++++++----------- src/fbgui.h | 34 +++++----- src/fbgui.qrc | 4 +- src/html/background.png | Bin 0 -> 316905 bytes src/html/bg.png | Bin 316905 -> 0 bytes src/html/preload-debug.html | 2 +- src/html/preload.css | 97 +++++++++++++++++++++++++++ src/html/preload.html | 2 +- src/html/style.css | 97 --------------------------- src/javascriptinterface.cpp | 20 +++--- src/javascriptinterface.h | 36 +++++----- src/loggerengine.cpp | 16 ++--- src/loggerengine.h | 31 +++++---- src/main.cpp | 39 +++++------ src/sysinfo.cpp | 30 +++------ src/sysinfo.h | 28 ++++---- src/sysinfolibsysfs.cpp | 15 ++--- src/sysinfolibsysfs.h | 36 +++++----- 20 files changed, 377 insertions(+), 409 deletions(-) create mode 100644 src/html/background.png delete mode 100644 src/html/bg.png create mode 100644 src/html/preload.css delete mode 100644 src/html/style.css diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index 22c1c09..8f7d8bb 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -1,55 +1,48 @@ #include "downloadmanager.h" -int DownloadManager::downloaded = 0; +int DownloadManager::_downloaded = 0; // ------------------------------------------------------------------------------------------------------- DownloadManager::DownloadManager() { qxtLog->debug() << "Initializing download manager..."; - checkDownloadDirectory(); + check_downloadDirectory(); _qnam = new QNetworkAccessManager(); _qnam->moveToThread(&dmThread); - dip = false; + _dip = false; } DownloadManager::~DownloadManager() { delete _qnam; } // ------------------------------------------------------------------------------------------------------- -void DownloadManager::checkDownloadDirectory() { +void DownloadManager::check_downloadDirectory() { // check if downloadPath exists, if not create it. - downloadDir = QDir(downloadPath); - if (!downloadDir.exists()) { - qxtLog->debug() << "[dm] Download directory: " << downloadDir.path() - << " doesn't exist."; + _downloadDir = QDir(downloadPath); + if (!_downloadDir.exists()) { + qxtLog->debug() << "[dm] Download directory: " << _downloadDir.path() << " doesn't exist."; // try to create the directory if (QDir::current().mkdir(downloadPath)) - qxtLog->debug() << "[dm] Created download directory: " - << downloadDir.path(); + qxtLog->debug() << "[dm] Created download directory: " << _downloadDir.path(); else { - qxtLog->debug() << "[dm] Failed to create directory: " - << downloadDir.path(); + qxtLog->debug() << "[dm] Failed to create directory: " << _downloadDir.path(); // try to save to /tmp/fbgui - downloadDir.setPath(QDir::tempPath() + "/fbgui"); - if (!downloadDir.exists()) { + _downloadDir.setPath(QDir::tempPath() + "/fbgui"); + if (!_downloadDir.exists()) { if (QDir::current().mkdir(QDir::tempPath() + "/fbgui")) - qxtLog->debug() << "[dm] Successfully created: " - << downloadDir.absolutePath(); + qxtLog->debug() << "[dm] Successfully created: " << _downloadDir.absolutePath(); else { // just in case - qxtLog->debug() << "[dm] Failed to create: " - << downloadDir.absolutePath(); + qxtLog->debug() << "[dm] Failed to create: " << _downloadDir.absolutePath(); qxtLog->debug() << "[dm] Exiting..."; exit( EXIT_FAILURE); } } else - qxtLog->debug() << "[dm] " << downloadDir.absolutePath() - << " already exists."; + qxtLog->debug() << "[dm] " << _downloadDir.absolutePath() << " already exists."; } } else - qxtLog->debug() << "[dm] Download directory: " - << downloadDir.absolutePath() << " already exists."; + qxtLog->debug() << "[dm] Download directory: " << _downloadDir.absolutePath() + << " already exists."; - qxtLog->debug() << "[dm] Saving downloads to: " - << downloadDir.absolutePath(); - downloadPath = downloadDir.absolutePath(); + qxtLog->debug() << "[dm] Saving downloads to: " << _downloadDir.absolutePath(); + downloadPath = _downloadDir.absolutePath(); } // ------------------------------------------------------------------------------------------------------- // Public access @@ -71,11 +64,11 @@ void DownloadManager::processDownloadRequest(const QUrl& url) { return; } qxtLog->debug() << "[dm] Enqueueing: " << url.toString(); - dlQ.enqueue(url); - if (dip) { + _downloadQueue.enqueue(url); + if (_dip) { // download in progress, return. - qxtLog->debug() << "[dm] Download in progress! Queued:" << url.toString() - << "(" << dlQ.size() << " in queue)"; + qxtLog->debug() << "[dm] Download in progress! Queued:" << url.toString() << "(" + << _downloadQueue.size() << " in queue)"; return; } // no running downloads: start next in queue @@ -84,53 +77,51 @@ void DownloadManager::processDownloadRequest(const QUrl& url) { // ------------------------------------------------------------------------------------------------------- void DownloadManager::startNextDownload() { QWSServer::instance()->setCursorVisible(false); - if (dlQ.isEmpty()) { + if (_downloadQueue.isEmpty()) { emit downloadQueueEmpty(); qxtLog->debug() << "[dm] Download manager ready. (1)"; return; } - qxtLog->debug() << "[dm] Starting next download: " << dlQ.head().toString() - << " (" << dlQ.size() - 1 << " in queue.)"; + qxtLog->debug() << "[dm] Starting next download: " << _downloadQueue.head().toString() << " (" + << _downloadQueue.size() - 1 << " in queue.)"; // dequeue next URL to download. - QUrl url = dlQ.dequeue(); + QUrl url = _downloadQueue.dequeue(); // get filename from URL. QString tmp = url.path(); tmp.remove(0, tmp.lastIndexOf(QChar('/')) + 1); // check if filename exists on target file system - if (downloadDir.exists(tmp)) { - qxtLog->debug() << "[dm] File already exists: " - << downloadDir.absoluteFilePath(tmp); - outfile.setFileName( - QString(downloadDir.absolutePath() + "/" + tmp + ".\%1").arg( - downloaded)); + if (_downloadDir.exists(tmp)) { + qxtLog->debug() << "[dm] File already exists: " << _downloadDir.absoluteFilePath(tmp); + _outfile.setFileName( + QString(_downloadDir.absolutePath() + "/" + tmp + ".\%1").arg(_downloaded)); } else - outfile.setFileName(downloadDir.absoluteFilePath(tmp)); - qxtLog->debug() << "[dm] Saving to: " << outfile.fileName(); + _outfile.setFileName(_downloadDir.absoluteFilePath(tmp)); + qxtLog->debug() << "[dm] Saving to: " << _outfile.fileName(); // try to open for writing - if (!outfile.open(QIODevice::WriteOnly)) { - qxtLog->debug() << "[dm] No write access to " << outfile.fileName() + if (!_outfile.open(QIODevice::WriteOnly)) { + qxtLog->debug() << "[dm] No write access to " << _outfile.fileName() << " . Skipping download..."; return; } // send the request for the file QNetworkRequest request(url); - currentDownload = _qnam->get(request); - lastProgress = 0; - currentProgress = 0; - dip = true; - _time.start(); - QObject::connect(currentDownload, SIGNAL(readyRead()), this, SLOT( + _currentDownload = _qnam->get(request); + _lastProgress = 0; + _currentProgress = 0; + _dip = true; + time.start(); + QObject::connect(_currentDownload, SIGNAL(readyRead()), this, SLOT( downloadReady())); - QObject::connect(currentDownload, SIGNAL(metaDataChanged()), this, SLOT( + QObject::connect(_currentDownload, SIGNAL(metaDataChanged()), this, SLOT( processMetaInfo())); - QObject::connect(currentDownload, SIGNAL(downloadProgress(qint64, qint64)), - this, SLOT(downloadProgress(qint64, qint64))); - QObject::connect(currentDownload, SIGNAL(finished()), this, SLOT( + QObject::connect(_currentDownload, SIGNAL(downloadProgress(qint64, qint64)), this, + SLOT(downloadProgress(qint64, qint64))); + QObject::connect(_currentDownload, SIGNAL(finished()), this, SLOT( downloadFinished())); } // ------------------------------------------------------------------------------------------------------- @@ -139,26 +130,26 @@ void DownloadManager::startNextDownload() { void DownloadManager::processMetaInfo() { // fetch filesize from header & filename from URL (for now) const QByteArray cltag = "Content-Length"; - QByteArray clinfo = currentDownload->rawHeader(cltag); - QFileInfo fi(outfile); - qxtLog->debug() << "[dm] Download Info: " << fi.fileName() << " (Size: " - << clinfo.toDouble() << ")"; + QByteArray clinfo = _currentDownload->rawHeader(cltag); + QFileInfo fi(_outfile); + qxtLog->debug() << "[dm] Download Info: " << fi.fileName() << " (Size: " << clinfo.toDouble() + << ")"; emit downloadInfo(fi.fileName(), clinfo.toDouble()); } // ------------------------------------------------------------------------------------------------------- void DownloadManager::downloadReady() { // data ready, save it - outfile.write(currentDownload->readAll()); + _outfile.write(_currentDownload->readAll()); } // ------------------------------------------------------------------------------------------------------- void DownloadManager::downloadProgress(qint64 bytesIn, qint64 bytesTotal) { if (bytesIn > bytesTotal || bytesTotal <= 0) { - qxtLog->debug() << "[dm] downloadProgress invalid values:" << "In:" - << bytesIn << " / Total: " << bytesTotal; + qxtLog->debug() << "[dm] downloadProgress invalid values:" << "In:" << bytesIn + << " / Total: " << bytesTotal; return; } // calculate current speed - double speed = bytesIn * 1000 / _time.elapsed(); + double speed = bytesIn * 1000 / time.elapsed(); QString unit; if (speed < 1024) { unit = "bytes/sec"; @@ -170,46 +161,41 @@ void DownloadManager::downloadProgress(qint64 bytesIn, qint64 bytesTotal) { unit = "MB/s"; } // update progress only if difference higher than the updateInterval setting - currentProgress = ((bytesIn * 100) / bytesTotal); - if (currentProgress - lastProgress >= updateInterval) { - lastProgress = currentProgress; + _currentProgress = ((bytesIn * 100) / bytesTotal); + if (_currentProgress - _lastProgress >= updateInterval) { + _lastProgress = _currentProgress; emit - updateProgress(currentProgress, speed, unit); - qxtLog->debug() << "[dm] Download progress of " - << currentDownload->url().toString() << ": " << bytesIn << "/" - << bytesTotal << "(" << currentProgress << "\%)"; + updateProgress(_currentProgress, speed, unit); + qxtLog->debug() << "[dm] Download progress of " << _currentDownload->url().toString() << ": " + << bytesIn << "/" << bytesTotal << "(" << _currentProgress << "\%)"; } } // ------------------------------------------------------------------------------------------------------- void DownloadManager::downloadFinished() { // check for errors - if (currentDownload->error()) { - outfile.close(); - outfile.remove(); - int statusCode = currentDownload->attribute( - QNetworkRequest::HttpStatusCodeAttribute).toInt(); - qxtLog->debug() << "[dm] Download of " - << currentDownload->url().toString() + if (_currentDownload->error()) { + _outfile.close(); + _outfile.remove(); + int statusCode = + _currentDownload->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); + qxtLog->debug() << "[dm] Download of " << _currentDownload->url().toString() << " failed with HTTP error code: " << statusCode; emit notify(QString("Download failed! HTTP Status Code: %1").arg(statusCode)); - currentDownload->deleteLater(); + _currentDownload->deleteLater(); } else { // end download - outfile.close(); - downloaded++; - qxtLog->debug() << "[dm] Download of " - << currentDownload->url().toString() << " finished. (downloaded = " - << downloaded << ")"; + _outfile.close(); + _downloaded++; + qxtLog->debug() << "[dm] Download of " << _currentDownload->url().toString() + << " finished. (_downloaded = " << _downloaded << ")"; emit - notify( - QString("Successfully downloaded %1").arg( - currentDownload->url().toString())); - currentDownload->deleteLater(); + notify(QString("Successfully _downloaded %1").arg(_currentDownload->url().toString())); + _currentDownload->deleteLater(); } - dip = false; + _dip = false; // process next in queue, if any - if (dlQ.isEmpty()) { + if (_downloadQueue.isEmpty()) { emit downloadQueueEmpty(); qxtLog->debug() << "[dm] Download manager ready. (2)"; return; diff --git a/src/downloadmanager.h b/src/downloadmanager.h index dfb4d03..58bcd53 100644 --- a/src/downloadmanager.h +++ b/src/downloadmanager.h @@ -1,21 +1,21 @@ /* - # Copyright (c) 2010,2011 - RZ Uni Freiburg - # Copyright (c) 2010,2011 - OpenSLX Project - # - # This program/file is free software distributed under the GPL version 2. - # See http://openslx.org/COPYING - # - # If you have any feedback please consult http://openslx.org/feedback and - # send your feedback to feedback@openslx.org - # - # General information about OpenSLX can be found under http://openslx.org - # - # - # Class managing download requests: - # - provides queueing functionality - # - static info: filename, filesize - # - dynamic info: download progress, current speed - # + * Copyright (c) 2010,2011 - RZ Uni Freiburg + * Copyright (c) 2010,2011 - OpenSLX Project + * + * This program/file is free software distributed under the GPL version 2. + * See http://openslx.org/COPYING + * + * If you have any feedback please consult http://openslx.org/feedback and + * send your feedback to feedback@openslx.org + * + * General information about OpenSLX can be found under http://openslx.org + * + * + * Class managing download requests: + * - provides queueing functionality + * - static info: filename, filesize + * - dynamic info: download progress, current speed + * */ #ifndef DOWNLOADMANAGER_H @@ -35,35 +35,34 @@ Q_OBJECT public: DownloadManager(); ~DownloadManager(); - QTime _time; + QTime time; private: // checks for valid download directory, ran once in constructor - void checkDownloadDirectory(); + void check_downloadDirectory(); // private control function for queueing mechanism. void processDownloadRequest(const QUrl& url); // base objects for downloading QNetworkAccessManager* _qnam; - QQueue dlQ; - QNetworkReply* currentDownload; - QFile outfile; - QDir downloadDir; + QQueue _downloadQueue; + QNetworkReply* _currentDownload; + QFile _outfile; + QDir _downloadDir; // download progress variables - int currentProgress, lastProgress; + int _currentProgress, _lastProgress; // download in progress flag - bool dip; + bool _dip; // static counter - static int downloaded; + static int _downloaded; - signals: +signals: // notify sends a message to the javascript interface to be evaluated there void notify(const QString& msg); // downloadInfo sends static information (name, size) to the interface. void downloadInfo(const QString& filename, const double& filesize); // updateProgress sends download progress information to the interface. - void updateProgress(const int& percent, const double& speed, - const QString& unit); + void updateProgress(const int& percent, const double& speed, const QString& unit); // signal emitted when download queue is empty. void downloadQueueEmpty(); diff --git a/src/fbgui.cpp b/src/fbgui.cpp index 3494b83..9a0ee1d 100644 --- a/src/fbgui.cpp +++ b/src/fbgui.cpp @@ -34,10 +34,8 @@ int debugMode = -1; * @see DownloadManager */ fbgui::fbgui() { + // test for libsys function - //SysInfoLibsysfs* sil = new SysInfoLibsysfs(); - //sil->getInfoAboutNetworkInterface(); - //sil->getInfoMainboardSerial(); //SysInfo si; //qxtLog->debug() << si.getInfo("mbserial"); //si.getInfo("usb"); @@ -46,28 +44,22 @@ 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())); // initialize download manager DownloadManager* dm = new DownloadManager(); - QObject::connect(dm, SIGNAL(downloadInfo(const QString&, const double&)), - jsi, SLOT(downloadInfo(const QString&, const double&))); - QObject::connect(dm, SIGNAL(notify(const QString&)), jsi, - SLOT(notify(const QString&))); + QObject::connect(dm, SIGNAL(downloadInfo(const QString&, const double&)), jsi, + SLOT(downloadInfo(const QString&, const double&))); + QObject::connect(dm, SIGNAL(notify(const QString&)), jsi, SLOT(notify(const QString&))); QObject::connect(jsi, SIGNAL(requestFile(const QString&)), dm, SLOT(downloadFile(const QString&))); - QObject::connect(dm, - SIGNAL(updateProgress(const int&, const double&, const QString&)), - jsi, + 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()), jsi, SLOT(callbackOnFinished())); QObject::connect(dm, SIGNAL(downloadQueueEmpty()), this, SLOT(loadSystem())); // move download manager to its own thread @@ -80,7 +72,6 @@ fbgui::fbgui() { } else { _webView->load(QUrl("qrc:/html/preload.html")); } - //statusBar()->showMessage("Waiting for internet..."); // start watching for fileToTriggerURL watchForTrigger(); @@ -92,7 +83,7 @@ fbgui::fbgui() { showFullScreen(); } fbgui::~fbgui() { - //dmThread.quit(); + dmThread.quit(); } //------------------------------------------------------------------------------------------- // Layout / actions setup @@ -154,16 +145,15 @@ void fbgui::watchForTrigger() { qxtLog->debug() << "[gui] Created: " << fileToTriggerURL; file.close(); } else { - qxtLog->debug() << "[gui] Creation of " << fileToTriggerURL - << " failed! Exiting..."; - exit( EXIT_FAILURE); + qxtLog->debug() << "[gui] Creation of " << fileToTriggerURL << " failed!"; + qxtLog->debug() << "[gui] Exiting in 5 seconds..."; + QTimer::singleShot(5000, this, SLOT(close())); } } // 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())); } //------------------------------------------------------------------------------------------- @@ -198,8 +188,8 @@ void fbgui::prepareURLLoad() { bool fbgui::checkHost() const { QHostInfo hostInfo = QHostInfo::fromName(baseURL.host()); if (hostInfo.error() != QHostInfo::NoError) { - qxtLog->debug() << "[gui] Lookup of " << baseURL.host() - << "failed. Exiting..."; + qxtLog->debug() << "[gui] Lookup of " << baseURL.host() << "failed."; + qxtLog->debug() << "[gui] Host can not be reached."; return false; } else { qxtLog->debug() << "[gui] Lookup of " << baseURL.host() << " succeeded."; @@ -219,7 +209,7 @@ bool fbgui::checkHost() const { */ void fbgui::loadURL() { if (checkHost()) { - qxtLog->debug() << "[gui] Loading URL..."; + qxtLog->debug() << "[gui] Loading URL: " << baseURL.toString() << " ..."; // Generate POST identification data needed by PBS. QByteArray postData = generatePOSTData(); @@ -227,10 +217,22 @@ void fbgui::loadURL() { // show cursor again since user is about to interact. QWSServer::instance()->setCursorVisible(true); + QObject::connect(_webView, SIGNAL(loadFinished(bool)), this, SLOT(loadURLDone(bool))); _webView->load(req, QNetworkAccessManager::PostOperation, postData); } // TODO: error page if no host. } +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] Exiting in 5 seconds..."; + QTimer::singleShot(5000, this, SLOT(close())); + } + else { + qxtLog->debug() << "[gui] Loaded URL: " << _webView->url().toString(); + } +} //------------------------------------------------------------------------------------------- /** * This method generates the POST data body. @@ -382,24 +384,22 @@ 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(); if (!ret) { - qxtLog->debug() << "[sysinfo] Failed to load kexec! Exiting..."; - exit( EXIT_FAILURE); + qxtLog->debug() << "[gui] Failed to execute: " << cmdline; + qxtLog->debug() << "[gui] Exiting in 5 seconds..."; + QTimer::singleShot(5000, this, SLOT(close())); } else { - qxtLog->debug() << "[gui] Kexec load successfull."; + qxtLog->debug() << "[gui] Kexec load was successfull."; if (debugMode < 0) { // 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(); } } @@ -416,7 +416,8 @@ void fbgui::runKexec() { process->startDetached("kexec -e"); if (!process->waitForStarted()) { qxtLog->debug() << "[gui] Failed to execute: kexec -e"; - exit( EXIT_FAILURE); + qxtLog->debug() << "[gui] Exiting in 5 seconds..."; + QTimer::singleShot(5000, this, SLOT(close())); //TODO: Handle failure properly... } } @@ -466,11 +467,12 @@ void fbgui::toggleDebugConsole() { // //------------------------------------------------------------------------------------------- void fbgui::loadSystem() { - // stop the thread for the download manager - qxtLog->debug() << "[gui] Stopping download manager's thread..."; - dmThread.quit(); - //show loading system page. _webView->load(QUrl("qrc:/html/loadsystem.html")); prepareKexec(); } +//------------------------------------------------------------------------------------------- +void fbgui::quitFailure() { +} +void fbgui::quitSuccess() { +} diff --git a/src/fbgui.h b/src/fbgui.h index 98ab4c4..80cbb25 100644 --- a/src/fbgui.h +++ b/src/fbgui.h @@ -1,19 +1,19 @@ /* - # Copyright (c) 2010,2011 - RZ Uni Freiburg - # Copyright (c) 2010,2011 - OpenSLX Project - # - # This program/file is free software distributed under the GPL version 2. - # See http://openslx.org/COPYING - # - # If you have any feedback please consult http://openslx.org/feedback and - # send your feedback to feedback@openslx.org - # - # General information about OpenSLX can be found under http://openslx.org - # - # - # Main class of the fbgui: - # - Manages display of components and their communications - # + * Copyright (c) 2010,2011 - RZ Uni Freiburg + * Copyright (c) 2010,2011 - OpenSLX Project + * + * This program/file is free software distributed under the GPL version 2. + * See http://openslx.org/COPYING + * + * If you have any feedback please consult http://openslx.org/feedback and + * send your feedback to feedback@openslx.org + * + * General information about OpenSLX can be found under http://openslx.org + * + * + * Main class of the fbgui: + * - Manages display of components and their communications + * */ #ifndef FBGUI_H @@ -106,6 +106,7 @@ private slots: // triggered by fileChanged Signal of _watcher // deletes _watcher, since we don't need it anymore and tries to load URL. void prepareURLLoad(); + void loadURLDone(bool success); // shut off the system void performShutDown(); @@ -115,6 +116,9 @@ private slots: void loadSystem(); void prepareKexec(); void runKexec(); + void quitSuccess(); + void quitFailure(); + }; #endif // FBGUI_H diff --git a/src/fbgui.qrc b/src/fbgui.qrc index 8f576cc..e378bed 100644 --- a/src/fbgui.qrc +++ b/src/fbgui.qrc @@ -4,9 +4,9 @@ html/js/jquery-1.5.1.min.js html/js/jquery-ui-1.8.11.min.js html/js/test.js - html/style.css + html/background.png + html/preload.css html/preload.html - html/bg.png html/preload-debug.html html/loadsystem.css html/loadsystem.html diff --git a/src/html/background.png b/src/html/background.png new file mode 100644 index 0000000..84dd7b3 Binary files /dev/null and b/src/html/background.png differ diff --git a/src/html/bg.png b/src/html/bg.png deleted file mode 100644 index 84dd7b3..0000000 Binary files a/src/html/bg.png and /dev/null differ diff --git a/src/html/preload-debug.html b/src/html/preload-debug.html index 0aad6c5..8c0f481 100644 --- a/src/html/preload-debug.html +++ b/src/html/preload-debug.html @@ -1,6 +1,6 @@ - + -
-

Loading system, please wait...

+ +
+

Loading system, please wait...

@@ -33,11 +31,5 @@ window.setTimeout(rotate, 100);
-
- -
- diff --git a/src/html/old.png b/src/html/old.png new file mode 100644 index 0000000..84dd7b3 Binary files /dev/null and b/src/html/old.png differ diff --git a/src/html/preload-debug.html b/src/html/preload-debug.html index 8c0f481..29d7391 100644 --- a/src/html/preload-debug.html +++ b/src/html/preload-debug.html @@ -12,6 +12,8 @@ function quitgui(){
+
+

Preboot GUI

Waiting on internet...