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.cpp57
1 files changed, 52 insertions, 5 deletions
diff --git a/workspace/LogReceiver/logreceiver.cpp b/workspace/LogReceiver/logreceiver.cpp
index 29ea8d8..5c695e5 100644
--- a/workspace/LogReceiver/logreceiver.cpp
+++ b/workspace/LogReceiver/logreceiver.cpp
@@ -1,6 +1,8 @@
#include <QtGui>
+ #include <QMap>
#include <QtNetwork>
-#include <QMap>
+ #include <QProcess>
+
#include <stdio.h>
#include <string.h>
@@ -21,7 +23,7 @@ LogReceiver::LogReceiver(QWidget *parent) :
quitButton->setAutoDefault(false);
server = new QLocalServer(this);
- if (!server->listen("/var/tmp/qt_c_socket_test")) {
+ if (!server->listen("/var/tmp/qt_c_socket_default")) {
QMessageBox::critical(this, tr("LogReceiver"), tr(
"Unable to start the server: %1.") .arg(server->errorString()));
close();
@@ -70,9 +72,10 @@ void LogReceiver::handleNewInput() {
QByteArray data = client->readAll();
QString logMsg(data);
- QString s_state = logMsg.section(";", 0, 0);
- QString s_subState = logMsg.section(";", 1, 1);
- QString msg = logMsg.section(";", 2, 2);
+ QString interface = logMsg.section(";",0,0);
+ QString s_state = logMsg.section(";", 1, 1);
+ QString s_subState = logMsg.section(";", 2, 2);
+ QString msg = logMsg.section(";", 3, 3);
qDebug() << logMsg;
@@ -122,3 +125,47 @@ void LogReceiver::handleNewInput() {
statusLabel->setText(logMsg);
}
+QList<QNetworkInterface> LogReceiver::getListOfNetworkInterfaces() {
+ QList<QNetworkInterface> nIList = QNetworkInterface::allInterfaces();
+ QList<QNetworkInterface> result;
+ foreach(QNetworkInterface nI, nIList) {
+ if (((!(nI.flags() & QNetworkInterface::CanBroadcast)||
+ nI.flags() & QNetworkInterface::IsLoopBack) ||
+ nI.flags() & QNetworkInterface::IsPointToPoint))
+ {
+ continue;
+ }
+ qDebug() << nI.humanReadableName();
+ result.append(nI);
+ }
+ return result;
+}
+
+void LogReceiver::runDHCPCD(QList<QNetworkInterface> &interfaces) {
+ foreach(QNetworkInterface ni, interfaces) {
+ QProcess * p = new QProcess(this);
+ clientProcesses.insert(p->pid(),p);
+ p->start(pathToDhcpcdExe,dhcpcdArguments);
+ connect(p, SIGNAL(started()), this, SLOT(handleProcessStarted()));
+ connect(p, SIGNAL(finished(int, QProcess::ExitStatus)),
+ this, SLOT(handleProcessFinished(int, QProcess::ExitStatus)));
+ }
+}
+
+void LogReceiver::handleProcessFinished(int exitCode,
+ QProcess::ExitStatus exitStatus) {
+
+ QObject* sender = const_cast<QObject*> (QObject::sender());
+ QProcess* process = static_cast<QProcess*> (sender);
+
+ QProcess * client = clientProcesses.value(process->pid());
+}
+
+void LogReceiver::handleProcessStarted() {
+
+ QObject* sender = const_cast<QObject*> (QObject::sender());
+ QProcess* process = static_cast<QProcess*> (sender);
+
+ QProcess * client = clientProcesses.value(process->pid());
+}
+