summaryrefslogtreecommitdiffstats
path: root/workspace/LogReceiver
diff options
context:
space:
mode:
Diffstat (limited to 'workspace/LogReceiver')
-rwxr-xr-xworkspace/LogReceiver/LogReceiverbin113415 -> 117864 bytes
-rw-r--r--workspace/LogReceiver/logreceiver.cpp49
-rw-r--r--workspace/LogReceiver/logreceiver.h6
3 files changed, 46 insertions, 9 deletions
diff --git a/workspace/LogReceiver/LogReceiver b/workspace/LogReceiver/LogReceiver
index 7fee3c5..a2450ce 100755
--- a/workspace/LogReceiver/LogReceiver
+++ b/workspace/LogReceiver/LogReceiver
Binary files differ
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);
diff --git a/workspace/LogReceiver/logreceiver.h b/workspace/LogReceiver/logreceiver.h
index 6611d15..6b32aa8 100644
--- a/workspace/LogReceiver/logreceiver.h
+++ b/workspace/LogReceiver/logreceiver.h
@@ -16,7 +16,7 @@ class LogReceiver: public QObject {
Q_OBJECT
#define DEFAULT_QTSOCKETADDRESS "/var/tmp/qt_c_socket_default"
-#define DEFAULT_PATHTODHCPCDEXE "/home/niklas/fbgui/workspace/customdhcpcd/src/dhcpcd"
+#define DEFAULT_PATHTODHCPCDEXE "/home/niklas/fbgui/workspace/customdhcpcd/src/customdhcpcd"
public:
LogReceiver();
@@ -32,6 +32,7 @@ private slots:
void handleNewInputLine(QString data);
void handleProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
void handleProcessStarted();
+ void handleClientDisconnect();
signals:
void addNewInterface(QString ifName);
@@ -47,6 +48,7 @@ private:
//QMap<int, QNetworkInterface > interfacesMap;
//QMap<QString, int> indexToIfaceNameMap;
QMap<QLocalSocket *, QLocalSocket *> clients;
+ QLocalSocket * client;
QMap<QProcess*, QString> clientProcessToIfNameMap;
QString pathToDhcpcdExe;
QStringList dhcpcdArguments;
@@ -54,6 +56,8 @@ private:
QNetworkAccessManager *accessManager;
int numberOfProcesses;
+ void handleNewInput(QLocalSocket * client);
+
void runDHCPCD(QList<QString> &interfaces);
void runDHCPCD(QString interface);
QList<QString>checkCarrierState(QList<QString> &interfaces);