summaryrefslogtreecommitdiffstats
path: root/workspace/LogReceiver/logreceiver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'workspace/LogReceiver/logreceiver.cpp')
-rw-r--r--workspace/LogReceiver/logreceiver.cpp49
1 files changed, 41 insertions, 8 deletions
diff --git a/workspace/LogReceiver/logreceiver.cpp b/workspace/LogReceiver/logreceiver.cpp
index 127d69e..9f73862 100644
--- a/workspace/LogReceiver/logreceiver.cpp
+++ b/workspace/LogReceiver/logreceiver.cpp
@@ -39,14 +39,23 @@ void LogReceiver::initAndRun(QString serverPath, QString pathToExe,
close();
*/
// emit signal to the gui that a critial error occoured
- qDebug() << "--- \t [LogReceiver::initAndRun] Unable to start server:"
+ QString errorInfo("Unable to start server: ");
+ qDebug() << "--- \t [LogReceiver::initAndRun] " + errorInfo
<< server->errorString();
+ emit abortBoot(errorInfo + server->errorString());
return;
}
connect(server, SIGNAL(newConnection()), this, SLOT(handleNewConnection()));
pathToDhcpcdExe = pathToExe;
+ // check if the path to the customdhcpcd file is correct
+ QFileInfo fInfo(pathToDhcpcdExe);
+ if (!fInfo.exists()) {
+ qDebug() << "couldn't find customdhcpcd exe. Please check the path to this file.";
+ emit abortBoot("couldn't find customdhcpcd exe. Please check the path to this file.");
+ return;
+ }
if (args != NULL && !args->isEmpty()) {
qDebug() << "--- \t [LogReceiver::initAndRun] added additional args";
@@ -250,23 +259,46 @@ void LogReceiver::checkInternetConnectionViaTCP(QString ifName) {
void LogReceiver::handleNewConnection() {
qDebug() << "New Connection arrived";
- QLocalSocket * client = server ->nextPendingConnection();
+ /*QLocalSocket **/ client = server ->nextPendingConnection();
clients.insert(client, client);
- connect(client, SIGNAL(disconnected()), client, SLOT(deleteLater()));
+ connect(client, SIGNAL(disconnected()), this, SLOT(handleClientDisconnect()));
connect(client, SIGNAL(readyRead()), this, SLOT(handleNewInput()));
}
+void LogReceiver::handleClientDisconnect() {
+ QLocalSocket* socket = qobject_cast<QLocalSocket *> (QObject::sender());
+
+ QLocalSocket * client = clients.value(socket);
+
+ qDebug() << "disconnect client";
+ handleNewInput(client);
+ client->deleteLater();
+}
+
+void LogReceiver::handleNewInput(QLocalSocket * client) {
+ QString data(client->readAll());
+
+ data = data.trimmed();
+ qDebug() << data;
+ QStringList lines = data.split("\n");
+
+ for (int i = 0; i < lines.length(); i++) {
+ handleNewInputLine(lines.at(i));
+ }
+}
+
void LogReceiver::handleNewInput() {
- QObject* sender = const_cast<QObject*> (QObject::sender());
- QLocalSocket* socket = static_cast<QLocalSocket*> (sender);
+ //QObject* sender = const_cast<QObject*> (QObject::sender());
+ //QLocalSocket* socket = static_cast<QLocalSocket*> (sender);
+ QLocalSocket* socket = qobject_cast<QLocalSocket * >(QObject::sender());
QLocalSocket * client = clients.value(socket);
QString data(client->readAll());
data = data.trimmed();
-
+ qDebug() << data;
QStringList lines = data.split("\n");
for (int i=0; i < lines.length(); i++) {
@@ -283,7 +315,7 @@ void LogReceiver::handleNewInputLine(QString data) {
QString msg = logMsg.section(";", 3, 3);
int st = s_state.trimmed().toInt();
int sst = s_subState.trimmed().toInt();
- qDebug() << logMsg;
+ //qDebug() << logMsg;
switch (st) {
case LOG_INFO:
switch (sst) {
@@ -320,7 +352,7 @@ void LogReceiver::handleNewInputLine(QString data) {
emit changeProgressBarValue(interface, 80);
break;
case DHCPCD_EXIT:
- emit changeProgressBarValue(interface, 100);
+ //emit changeProgressBarValue(interface, 100);
break;
case DHCPCD_LOG:
@@ -353,6 +385,7 @@ void LogReceiver::handleProcessFinished(int exitCode,
else {
qDebug() << "process normal exit";
qDebug() << "check internet connction";
+ emit changeProgressBarValue(ifName, 100);
emit updateStatusLabel(ifName, "check connectivity");
//checkInternetConnection(ifName);
checkInternetConnectionViaTCP(ifName);