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