summaryrefslogtreecommitdiffstats
path: root/LogReceiver/interfaceconfiguration.cpp
diff options
context:
space:
mode:
authorNiklas2011-09-02 17:06:02 +0200
committerNiklas2011-09-02 17:06:02 +0200
commit603f6e47b2be2b5e03e63f6bee9c6364c92a251e (patch)
tree1cc7c4583e54691b031fe9de3a5e68f7a4bbddf3 /LogReceiver/interfaceconfiguration.cpp
parentjust minor changes. deltions of unuseful comments (diff)
downloadfbgui-603f6e47b2be2b5e03e63f6bee9c6364c92a251e.tar.gz
fbgui-603f6e47b2be2b5e03e63f6bee9c6364c92a251e.tar.xz
fbgui-603f6e47b2be2b5e03e63f6bee9c6364c92a251e.zip
added a new container class which holds config informations about an interface. also solved the message loss problem by setting the read an writing messages to the same size
Diffstat (limited to 'LogReceiver/interfaceconfiguration.cpp')
-rw-r--r--LogReceiver/interfaceconfiguration.cpp133
1 files changed, 133 insertions, 0 deletions
diff --git a/LogReceiver/interfaceconfiguration.cpp b/LogReceiver/interfaceconfiguration.cpp
new file mode 100644
index 0000000..8ab7cbb
--- /dev/null
+++ b/LogReceiver/interfaceconfiguration.cpp
@@ -0,0 +1,133 @@
+/*
+ * interfaceconfiguration.cpp
+ *
+ * Created on: Sep 2, 2011
+ * Author: niklas
+ */
+#include "interfaceconfiguration.h"
+
+interfaceconfiguration::interfaceconfiguration() {
+
+}
+
+interfaceconfiguration::~interfaceconfiguration() {
+ // TODO Auto-generated destructor stub
+}
+
+/**
+ * This method reads the configuration values out of a file.
+ *
+ * This method reads the configuration values out of a file.
+ * The file has to be created before by the customdhcpcd QProcess.
+ * (Overwrites the old values if they are already present.)
+ *
+ * @param pathToConfig
+ * contains the path to the configuration file.
+ */
+bool interfaceconfiguration::readConfigOutOfFile(QString pathToConfig) {
+ QFile file(pathToConfig);
+ if (file.exists()) {
+ if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ qDebug() << "couldn't open file:" << pathToConfig;
+ return false;
+ }
+ while (!file.atEnd()) {
+ QString line(file.readLine());
+ QStringList splitedLine = line.split("=");
+ QString name = splitedLine.first().trimmed();
+ splitedLine.removeFirst();
+ QString values = splitedLine.first().trimmed();
+ values.remove(QChar('\''));
+ qDebug() << "read config file:" << name << values;
+ if (name.compare("IPADDR") == 0) {
+ this->ipAddress = values;
+ } else if (name.compare("NETMASK") == 0) {
+ this->netmask = values;
+ } else if (name.compare("NETWORK") == 0) {
+ this->network = values;
+ } else if (name.compare("BROADCAST") == 0) {
+ this->broadcast = values;
+ } else if (name.compare("ROUTES") == 0) {
+ this->routes = values;
+ } else if (name.compare("GATEWAYS") == 0) {
+ this->gateways = values;
+ this->gateway = this->gateways.split(" ").first().trimmed();
+ } else if (name.compare("HOSTNAME") == 0) {
+ this->hostname = values;
+ } else if (name.compare("DNSSEARCH") == 0) {
+ this->dnssearch = values;
+ } else if (name.compare("DNSSERVERS") == 0) {
+ this->dnsservers = values;
+ } else if (name.compare("DHCPSID") == 0) {
+ this->dhcpsid = values;
+ } else if (name.compare("INTERFACE") == 0) {
+ this->interface = values;
+ } else if (name.compare("CLIENTID") == 0) {
+ this->clientid = values;
+ } else if (name.compare("DHCPCHADDR") == 0) {
+ this->dhcpchaddr = values;
+ } else {
+ qDebug() << "read unknown name" << name << values;
+ }
+ }
+ } else {
+ qDebug() << "file doesn't exist:" << pathToConfig;
+ return false;
+ }
+ return true;
+}
+
+QString interfaceconfiguration::getBroadcast() {
+ return broadcast;
+}
+
+QString interfaceconfiguration::getClientid() {
+ return clientid;
+}
+
+QString interfaceconfiguration::getDhcpchaddr() {
+ return dhcpchaddr;
+}
+
+QString interfaceconfiguration::getDhcpsid() {
+ return dhcpsid;
+}
+QString interfaceconfiguration::getDnssearch() {
+ return dnssearch;
+}
+
+QString interfaceconfiguration::getDnsservers() {
+ return dnsservers;
+}
+
+QString interfaceconfiguration::getGateways() {
+ return gateways;
+}
+
+QString interfaceconfiguration::getGateway() {
+ return gateway;
+}
+
+QString interfaceconfiguration::getHostname() {
+ return hostname;
+}
+
+QString interfaceconfiguration::getInterface() {
+ return interface;
+}
+
+QString interfaceconfiguration::getIpAddress() {
+ return ipAddress;
+}
+
+QString interfaceconfiguration::getNetmask() {
+ return netmask;
+}
+
+QString interfaceconfiguration::getNetwork() {
+ return network;
+}
+
+QString interfaceconfiguration::getRoutes() {
+ return routes;
+}