From d3981804f31fb842d37607c7db58f9b977ba366e Mon Sep 17 00:00:00 2001 From: Niklas Date: Fri, 21 Oct 2011 14:30:36 +0200 Subject: added some config possibilities --- CMakeLists.txt | 2 +- common/fbgui.h | 6 +++--- src/main.cpp | 45 ++++++++++++++++++++++++++++++++++++++++++++- src/ndgui.cpp | 8 ++++++++ src/ndgui.h | 6 ++++++ src/networkdiscovery.cpp | 2 +- src/networkdiscovery.h | 3 +-- 7 files changed, 64 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 89139eb..6383b26 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ set(QT_USE_QTNETWORK TRUE) set(QT_USE_QTWEBKIT TRUE) file(GLOB FBGUI_SOURCES src/*.cpp) -file(GLOB FBGUI_MOC_HEADERS src/*.h) +file(GLOB FBGUI_MOC_HEADERS src/*.h common/*.h) file(GLOB FBGUI_UIS src/*.ui) file(GLOB FBGUI_RCS src/*.qrc) diff --git a/common/fbgui.h b/common/fbgui.h index 75f9b7b..acbda66 100644 --- a/common/fbgui.h +++ b/common/fbgui.h @@ -1,5 +1,5 @@ -#ifndef FBGUI_H -#define FBGUI_H +#ifndef COMMON_FBGUI_H +#define COMMON_FBGUI_H #define DEFAULT_INTERFACE_CONF_LOCATION "/var/tmp/conf_" #define DEFAULT_QTSOCKETADDRESS "/var/tmp/qt_c_socket_default" @@ -12,4 +12,4 @@ #define DHCPCD_WRITE 12 #define DHCPCD_LOG 13 -#endif // FBGUI_H +#endif // COMMON_FBGUI_H diff --git a/src/main.cpp b/src/main.cpp index e408a33..2df76a6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -53,7 +53,12 @@ int main(int argc, char *argv[]) { required_argument, NULL, 'u' }, { "download", required_argument, NULL, 'd' }, { "serial", required_argument, NULL, 's' }, { "trigger", required_argument, NULL, 't' }, { "debug", required_argument, NULL, 'D' }, { "help", no_argument, NULL, 'h' }, { "log", - required_argument, NULL, 'l' } }; + required_argument, NULL, 'l' }, + { "server", required_argument, NULL, 'S' }, + { "autoup", no_argument, NULL, 'a' }, + { "socketserverpath", required_argument, NULL, 'p' }, + { "pathtoexe", required_argument, NULL, 'e' } + }; int opt = getopt_long(argc, argv, optString, longOpts, &longIndex); while (opt != -1) { switch (opt) { @@ -81,6 +86,18 @@ int main(int argc, char *argv[]) { case 'h': clOpts.insert("help", "help"); break; + case 'S': + clOpts.insert("server", optarg); + break; + case 'a': + clOpts.insert("autoup", "autoup"); + break; + case 'p': + clOpts.insert("socketserverpath", optarg); + break; + case 'e': + clOpts.insert("pathtoexe", optarg); + break; } opt = getopt_long(argc, argv, optString, longOpts, &longIndex); } @@ -175,6 +192,32 @@ int main(int argc, char *argv[]) { else logFilePath = DEFAULT_LOG_FILE_PATH; + // + if (clOpts.contains("server")) + gServerIp = clOpts.value("server"); + else + gServerIp = "209.85.148.105"; //that is a google server. change this to a proper default address + + // + if (clOpts.contains("autoup")) + gAutoUp = true; + else + gAutoUp = false; + + // + if (clOpts.contains("socketserverpath")) + gSocketServerPath = clOpts.value("socketserverpath"); + else + gSocketServerPath = DEFAULT_QTSOCKETADDRESS; + + // + if (clOpts.contains("pathtoexe")) + gPathToDhcpExe = clOpts.value("pathtoexe"); + else + gPathToDhcpExe = DEFAULT_PATHTODHCPCDEXE; + + + // write always a log file // // activate file logger if debug mode activated. // if (debugMode > -1) { diff --git a/src/ndgui.cpp b/src/ndgui.cpp index c0a390f..6e358b8 100644 --- a/src/ndgui.cpp +++ b/src/ndgui.cpp @@ -1,5 +1,13 @@ #include "ndgui.h" +QString gServerIp(""); +bool gAutoUp = true; +QString gSocketServerPath(""); +QString gPathToDhcpExe(""); + + + +/*constructor*/ ndgui::ndgui(QMainWindow *parent) : QMainWindow(parent) { diff --git a/src/ndgui.h b/src/ndgui.h index 96dac7a..f95e42d 100644 --- a/src/ndgui.h +++ b/src/ndgui.h @@ -8,6 +8,12 @@ #include "loggerengine.h" #include "networkdiscovery.h" + +extern QString gServerIp; +extern bool gAutoUp; +extern QString gSocketServerPath; +extern QString gPathToDhcpExe; + class ndgui: public QMainWindow { Q_OBJECT diff --git a/src/networkdiscovery.cpp b/src/networkdiscovery.cpp index 938c504..df1ae3c 100644 --- a/src/networkdiscovery.cpp +++ b/src/networkdiscovery.cpp @@ -3,7 +3,7 @@ #include "networkdiscovery.h" -#include "../common/fbgui.h" + /** diff --git a/src/networkdiscovery.h b/src/networkdiscovery.h index 1f7bd9d..3e34e7d 100644 --- a/src/networkdiscovery.h +++ b/src/networkdiscovery.h @@ -16,13 +16,12 @@ #include "interfaceconfiguration.h" #include "networkmanager.h" -#include "../common/fbgui.h" #include "dhcp.h" +#include "../common/fbgui.h" -#define DEFAULT_QTSOCKETADDRESS "/var/tmp/qt_c_socket_default" //#define DEFAULT_PATHTODHCPCDEXE "/home/niklas/fbgui/customdhcpcd/src/build/cdhcpcd" #define DEFAULT_PATHTODHCPCDEXE "/bin/cdhcpcd" -- cgit v1.2.3-55-g7522