summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Neves2012-01-25 18:22:31 +0100
committerMichael Neves2012-01-25 18:22:31 +0100
commit6b1eebad28870e6eef578782bac394f83c279c24 (patch)
treec2f14f3f4f5449a24bb93871310ea07f70aecf9b
parenttestApp custom (diff)
parentdebug console fixed, now basicly tail on logfile (diff)
downloadfbgui-6b1eebad28870e6eef578782bac394f83c279c24.tar.gz
fbgui-6b1eebad28870e6eef578782bac394f83c279c24.tar.xz
fbgui-6b1eebad28870e6eef578782bac394f83c279c24.zip
Merge branch 'master' of git.openslx.org:openslx-ng/fbgui
Conflicts: testApp.sh
-rw-r--r--.gitignore1
-rw-r--r--fbgui.conf1
-rw-r--r--fbgui.logging.conf5
-rw-r--r--src/fbgui/fbgui.cpp53
-rw-r--r--src/fbgui/fbgui.h5
-rw-r--r--src/fbgui/main.cpp2
-rwxr-xr-xtestApp.sh23
7 files changed, 72 insertions, 18 deletions
diff --git a/.gitignore b/.gitignore
index 12331fb..ee34bb7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,3 +17,4 @@ Debug
/doxygen/html/*
/doxygen/latex/*
/doxygen/man/*
+testApp.sh
diff --git a/fbgui.conf b/fbgui.conf
index 7618847..29aabdd 100644
--- a/fbgui.conf
+++ b/fbgui.conf
@@ -8,5 +8,4 @@ ip_config=/tmp/ip_config
log_file=/tmp/fbgui.log
server=209.85.148.105
autoup=true
-pathtoexe=~/fbgui/build/src/customdhcpcd/cdhcpcd
serverSocket=/var/tmp/qt_c_socket_custom
diff --git a/fbgui.logging.conf b/fbgui.logging.conf
index b305de2..ba768ad 100644
--- a/fbgui.logging.conf
+++ b/fbgui.logging.conf
@@ -1,3 +1,7 @@
+
+log4j.rootLogger=DEBUG, FA, SLA
+
+
log4j.appender.SLA=SyslogAppender
log4j.appender.SLA.layout=PatternLayout
log4j.appender.SLA.layout.ConversionPattern=-4r -5p c{2} M.L x - m
@@ -10,5 +14,4 @@ log4j.appender.FA.layout=TTCCLayout
log4j.appender.FA.layout.ContextPrinting=disabled
log4j.appender.FA.layout.DateFormat=ISO8601
-log4j.rootLogger=DEBUG, SLA, FA
diff --git a/src/fbgui/fbgui.cpp b/src/fbgui/fbgui.cpp
index 683538b..759c747 100644
--- a/src/fbgui/fbgui.cpp
+++ b/src/fbgui/fbgui.cpp
@@ -54,6 +54,8 @@ void fbgui::init() {
// start fbgui
LOG4CXX_DEBUG(coreLogger, "Initializing fbgui...");
+ _watcher = new QFileSystemWatcher(this);
+
setupLayout();
createActions();
@@ -173,8 +175,9 @@ void fbgui::watchForTrigger() {
}
// watch the path to trigger file
LOG4CXX_DEBUG(coreLogger, "[watcher] Watching " << fileToTriggerURL);
- _watcher = new QFileSystemWatcher(QStringList(fileToTriggerURL), this);
-QObject::connect(_watcher, SIGNAL(fileChanged(const QString&)), this, SLOT(prepareURLLoad()));
+ _watcher->addPath(fileToTriggerURL);
+ //_watcher = new QFileSystemWatcher(QStringList(fileToTriggerURL, logFilePath), this);
+QObject::connect(_watcher, SIGNAL(fileChanged(const QString&)), this, SLOT(prepareURLLoad(const QString&)));
}
//-------------------------------------------------------------------------------------------
@@ -188,14 +191,16 @@ QObject::connect(_watcher, SIGNAL(fileChanged(const QString&)), this, SLOT(prepa
* @see fbgui::checkHost()
* @see fbgui::loadURL()
*/
-void fbgui::prepareURLLoad() {
- LOG4CXX_DEBUG(coreLogger, "[watcher] " << fileToTriggerURL << " changed!");
- // disconnect _watcher, his job is done
- LOG4CXX_DEBUG(coreLogger, "[watcher] disconnected.");
- _watcher->disconnect(this);
- _watcher->deleteLater();
- // try to load URL
- loadURL();
+void fbgui::prepareURLLoad(const QString& fileName) {
+ if (fileName == fileToTriggerURL) {
+ LOG4CXX_DEBUG(coreLogger, "[watcher] " << fileToTriggerURL << " changed!");
+ // disconnect _watcher, his job is done
+ LOG4CXX_DEBUG(coreLogger, "[watcher] disconnected.");
+ _watcher->disconnect(this);
+ _watcher->deleteLater();
+ // try to load URL
+ loadURL();
+ }
}
//-------------------------------------------------------------------------------------------
// Preparations for URL load
@@ -471,16 +476,36 @@ void fbgui::createDebugConsole() {
pal.setColor(QPalette::Base, Qt::black);
_debugConsole->setPalette(pal);
_debugConsole->setTextColor(Qt::white);
- // enable custom coreLogger engine
-// qxtLog->addLoggerEngine("fb_coreLogger", new LoggerEngine_fb(_debugConsole));
- //qxtLog->initLoggerEngine("fb_coreLogger");
-// qxtLog->setMinimumLevel("fb_coreLogger", 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()));
+
+ // read from log file
+ _logFile = new QFile(logFilePath);
+ _logFileIn = new QTextStream(_logFile);
+
+ if (!_logFile->open(QFile::ReadOnly | QFile::Text)) {
+ //do error
+ }
+ _debugConsole->setPlainText(_logFileIn->readAll());
+ _debugConsole->moveCursor(QTextCursor::End);
+ LOG4CXX_DEBUG(coreLogger, "Log file opened.");
+ // watch log file
+ _watcher->addPath(logFilePath);
+ QObject::connect(_watcher, SIGNAL(fileChanged(const QString&)), this, SLOT(refreshDebugConsole(const QString&)));
+
+}
+//-------------------------------------------------------------------------------------------
+void fbgui::refreshDebugConsole(const QString& fileName) {
+ if (fileName == logFilePath) {
+ while (!_logFileIn->atEnd()) {
+ _debugConsole->append(_logFileIn->readLine());
+ }
+ _debugConsole->moveCursor(QTextCursor::End);
+ }
}
//-------------------------------------------------------------------------------------------
/**
diff --git a/src/fbgui/fbgui.h b/src/fbgui/fbgui.h
index c6d5a01..4891194 100644
--- a/src/fbgui/fbgui.h
+++ b/src/fbgui/fbgui.h
@@ -101,14 +101,17 @@ private:
// watcher to detect changes in the observed directory.
QFileSystemWatcher* _watcher;
+ QFile* _logFile;
+ QTextStream* _logFileIn;
private slots:
// toggles debug console when action _toggleDebugConsole happens.
void toggleDebugConsole();
+ void refreshDebugConsole(const QString&);
// This function is triggered by fileChanged Signal of _watcher.
// It deletes _watcher, since we don't need it anymore and tries to load URL.
- void prepareURLLoad();
+ void prepareURLLoad(const QString&);
void loadURLDone(bool success);
// shut off the system
diff --git a/src/fbgui/main.cpp b/src/fbgui/main.cpp
index e7f9fae..6284054 100644
--- a/src/fbgui/main.cpp
+++ b/src/fbgui/main.cpp
@@ -80,7 +80,7 @@ int main(int argc, char *argv[]) {
// parse command line arguments using getopt
QMap<QString, QString> clOpts;
int longIndex = 0;
- static const char *optString = "c:u:d:s:t:D:hl:n";
+ static const char *optString = "c:u:d:s:t:D:hl:nS:p:e:";
static const struct option longOpts[] = { { "config", required_argument,
NULL, 'c' }, { "url", required_argument, NULL, 'u' }, { "download",
required_argument, NULL, 'd' }, { "serial", required_argument, NULL,
diff --git a/testApp.sh b/testApp.sh
index 7e044b8..132208c 100755
--- a/testApp.sh
+++ b/testApp.sh
@@ -11,10 +11,29 @@
# -s <path>, --serial=<path> sets path to serial number file
#
# Note: all path are expected to be absolute.
+<<<<<<< HEAD
QT_VERSION=Qt-4.8.0
+=======
+#
+# Adapt these to your own system.
+QT_VERSION=Qt-4.7.2
+PATH_TO_FBGUI_BUILD=/home/joe/workspace/fbgui
+
+# check if network discovery is activated and if running as root
+for ARG in $*
+do
+if [ "x$ARG" = "x-n" ]; then
+ if [ $(whoami) != "root" ]; then
+ echo "Network Discovery activated, you need to be root."
+ exit 1;
+ fi
+fi
+done
+>>>>>>> 2abf1cec73371fb4a97a078a47f521d23fbf0775
# clean /tmp/fbgui
[ -d /tmp/fbgui ] && rm -rf /tmp/fbgui
+[ -f /tmp/fbgui.log ] && rm /tmp/fbgui.log
[ -f /tmp/fbgui_trigger ] && rm /tmp/fbgui_trigger
# path to script (including script name)
@@ -31,6 +50,10 @@ display_id=$(grep -n $(whoami) /etc/passwd| head -n 1|awk -F : '{print $1}')
# quick sleep to wait for qvfb loading
sleep 0.2
# Start fbgui connecting to QVFb with display_id from above.
+<<<<<<< HEAD
$working_path/../workspace/fbgui/src/fbgui/fbgui -display QVFb:$display_id $@
+=======
+$PATH_TO_FBGUI_BUILD/src/fbgui/fbgui -display QVFb:$display_id $@ -e $PATH_TO_FBGUI_BUILD/src/customdhcpcd/cdhcpcd
+>>>>>>> 2abf1cec73371fb4a97a078a47f521d23fbf0775
# kill qvfb since fbgui stopped
killall qvfb