summaryrefslogtreecommitdiffstats
path: root/workspace/LogReceiver
diff options
context:
space:
mode:
Diffstat (limited to 'workspace/LogReceiver')
-rwxr-xr-xworkspace/LogReceiver/LogReceiverbin35272 -> 35272 bytes
-rw-r--r--workspace/LogReceiver/logreceiver.cpp57
-rw-r--r--workspace/LogReceiver/logreceiver.h9
3 files changed, 60 insertions, 6 deletions
diff --git a/workspace/LogReceiver/LogReceiver b/workspace/LogReceiver/LogReceiver
index 4c9ccec..4fa7468 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 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());
+}
+
diff --git a/workspace/LogReceiver/logreceiver.h b/workspace/LogReceiver/logreceiver.h
index f73a56a..0c9df48 100644
--- a/workspace/LogReceiver/logreceiver.h
+++ b/workspace/LogReceiver/logreceiver.h
@@ -20,15 +20,22 @@ public:
private slots:
void handleNewConnection();
void handleNewInput();
+ void handleProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
+ void handleProcessStarted();
private:
Ui::LogReceiverClass ui;
QLabel *statusLabel;
QPushButton *quitButton;
QLocalServer *server;
- QStringList fortunes;
quint16 blockSize;
QMap<QLocalSocket *, QLocalSocket *> clients;
+ QMap<Q_PID, QProcess * > clientProcesses;
+ QString pathToDhcpcdExe;
+ QStringList dhcpcdArguments;
+
+ void runDHCPCD(QList<QNetworkInterface> &interfaces);
+ void getListOfNetworkInterfaces();
};
#endif // LOGRECEIVER_H