summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiklas2011-11-04 11:56:28 +0100
committerNiklas2011-11-04 11:56:28 +0100
commit5d215d54cbb33f3ef5fb4f5da9a860b0a105ae9b (patch)
tree8965df059ab3acff163d0b7c907f35754472ee23
parentchanged the tryout, also some big changes in program flow. there is now userc... (diff)
downloadfbgui-5d215d54cbb33f3ef5fb4f5da9a860b0a105ae9b.tar.gz
fbgui-5d215d54cbb33f3ef5fb4f5da9a860b0a105ae9b.tar.xz
fbgui-5d215d54cbb33f3ef5fb4f5da9a860b0a105ae9b.zip
last changes
-rw-r--r--customdhcpcd/src/logger.c6
-rw-r--r--customdhcpcd/src/logwriter.c3
-rw-r--r--src/html/networkdiscovery.html3
-rw-r--r--src/html/networkdiscovery_debug.html3
-rw-r--r--src/main.cpp8
-rw-r--r--src/ndgui.cpp19
-rw-r--r--src/ndgui.h1
-rw-r--r--src/networkdiscovery.cpp44
-rw-r--r--src/networkdiscovery.h3
9 files changed, 71 insertions, 19 deletions
diff --git a/customdhcpcd/src/logger.c b/customdhcpcd/src/logger.c
index c6498ed..2c8431d 100644
--- a/customdhcpcd/src/logger.c
+++ b/customdhcpcd/src/logger.c
@@ -82,12 +82,15 @@ void logger(int level, const char *fmt, ...) {
//va_list p2;
// FILE *f = stderr;
FILE *f;
+ FILE *f2;
char* path = "/tmp/cdhcpcd.log";
+ char* msgpath = "/tmp/cdhcpcd-msg.log";
int size = 512;
char *msg = (char *) malloc (size);
f = fopen(path,"a");
+ f2 = fopen(msgpath,"a");
va_start (p, fmt);
//va_copy (p2, p);
@@ -96,6 +99,9 @@ void logger(int level, const char *fmt, ...) {
strcat(msg,"\n");
logToQt(level, DHCPCD_LOG, msg);
+ fprintf(f2, "%s, %s", leveltolog(level), logprefix);
+ fprintf(f2, "%s", msg);
+ fputc('\n', f2);
fprintf(f, "%s, %s", leveltolog(level), logprefix);
vfprintf(f, fmt, p);
diff --git a/customdhcpcd/src/logwriter.c b/customdhcpcd/src/logwriter.c
index 67cf839..6230d4c 100644
--- a/customdhcpcd/src/logwriter.c
+++ b/customdhcpcd/src/logwriter.c
@@ -24,7 +24,6 @@ int sockfd, ns;
int retval = -1;
char socketName[QTSOCKETADDRESSLENGTH];
char interfaceName[IF_NAMESIZE];
-char mesg[1024];
void setSocketName(const char * sn) {
snprintf(socketName, sizeof(socketName), "%s", sn);
@@ -83,7 +82,7 @@ void sendToQt(log_msg * msg) {
ret = snprintf(outbuf, DHCP_MESSAGE_SIZE, tpl, msg->device, msg->status,
msg->substatus, msg->msg);
if (ret < 1) {
- logger(LOG_INFO, "[fbgui] ERROR filling message buffer");
+ log ger(LOG_INFO, "[fbgui] ERROR filling message buffer");
//syslog(LOG_INFO, "[fbgui] ERROR filling message buffer");
return;
}
diff --git a/src/html/networkdiscovery.html b/src/html/networkdiscovery.html
index 991ec0f..a1e62ac 100644
--- a/src/html/networkdiscovery.html
+++ b/src/html/networkdiscovery.html
@@ -12,7 +12,7 @@
// prepare the form when the DOM is ready
$(document).ready(function() {
// Setup the ajax indicator
- $("#nd_status").append('<div id="ajaxBusy"><p><img src="qrc:/html/images/loading.gif"></p></div>');
+ $("#nd_loading_sign").append('<div id="ajaxBusy"><p><img src="qrc:/html/images/loading.gif"></p></div>');
});
</script>
@@ -38,6 +38,7 @@ We are now looking for usable interfaces and will go on as soon as we found one.
<section>
<!-- Main content area -->
<p id="nd_status"></p>
+ <div id="nd_loading_sign"></div>
<!-- anchor for the show log dialog -->
<div id="nd_show_log_dialog" title="Log File">
<pre id="nd_show_log_msg"></pre>
diff --git a/src/html/networkdiscovery_debug.html b/src/html/networkdiscovery_debug.html
index be0c35f..06c1fe7 100644
--- a/src/html/networkdiscovery_debug.html
+++ b/src/html/networkdiscovery_debug.html
@@ -12,7 +12,7 @@
// prepare the form when the DOM is ready
$(document).ready(function() {
// Setup the ajax indicator
- $("#nd_status").append('<div id="ajaxBusy"><p><img src="qrc:/html/images/loading.gif"></p></div>');
+ $("#nd_loading_sign").append('<div id="ajaxBusy"><p><img src="qrc:/html/images/loading.gif"></p></div>');
});
</script>
@@ -37,6 +37,7 @@ We are now looking for usable interfaces and will go on as soon as we found one.
<section>
<!-- Main content area -->
<p id="nd_status"></p>
+ <div id="nd_loading_sign"></div>
<!-- anchor for the show log dialog -->
<div id="nd_show_log_dialog" title="Log File">
<pre id="nd_show_log_msg"></pre>
diff --git a/src/main.cpp b/src/main.cpp
index 837cf6e..a187d01 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -195,24 +195,32 @@ int main(int argc, char *argv[]) {
//
if (clOpts.contains("server"))
gServerIp = clOpts.value("server");
+ else if (confFileSettings.contains("default/server"))
+ gServerIp = confFileSettings.value("default/server").toString();
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 if (confFileSettings.contains("default/autoup"))
+ gAutoUp = confFileSettings.value("default/autoup").toBool();
else
gAutoUp = false;
//
if (clOpts.contains("socketserverpath"))
gSocketServerPath = clOpts.value("socketserverpath");
+ else if (confFileSettings.contains("default/socketserverpath"))
+ gSocketServerPath = confFileSettings.value("default/socketserverpath").toString();
else
gSocketServerPath = DEFAULT_QTSOCKETADDRESS;
//
if (clOpts.contains("pathtoexe"))
gPathToDhcpExe = clOpts.value("pathtoexe");
+ else if (confFileSettings.contains("default/pathtoexe"))
+ gPathToDhcpExe = confFileSettings.value("default/pathtoexe").toString();
else
gPathToDhcpExe = DEFAULT_PATHTODHCPCDEXE;
diff --git a/src/ndgui.cpp b/src/ndgui.cpp
index d99dfd8..6988477 100644
--- a/src/ndgui.cpp
+++ b/src/ndgui.cpp
@@ -88,6 +88,7 @@ void ndgui::init () {
connect(_networkDiscovery, SIGNAL(updateStatus(QString)), this, SLOT(updateStatus(const QString&)));
connect(_networkDiscovery, SIGNAL(allProcessesFinished()), this, SLOT(handleAllProcessesFinished()));
connect(_networkDiscovery, SIGNAL(continueBoot(QString)), this, SLOT(continueBoot(QString)));
+ connect(_networkDiscovery, SIGNAL(continueBootWithoutCheck(QString )), this, SLOT(continueBootWithoutCheck(QString)));
connect(_webView->page()->mainFrame(), SIGNAL(
@@ -289,7 +290,7 @@ void ndgui::handleAllProcessesFinished() {
}
}
} else {
- abortBoot("No usable interfaces found!");
+ abortBoot("No usable interfaces found!" + _networkDiscovery->GetErrorStr());
}
}
@@ -344,6 +345,15 @@ void ndgui::continueBoot(QString ifName) {
}
}
+
+
+
+/**/
+void ndgui::continueBootWithoutCheck(QString ifName) {
+ qxtLog->debug() << _tag << " continue with interface: " << ifName;
+ emit initFbgui();
+ this->close();
+}
//void ndgui::continueBoot(QString ifName) {
// if (!_userChoice) {
// foreach(QString i, _ifNameList)
@@ -399,8 +409,11 @@ QString ndgui::readLogFile() {
/**/
void ndgui::tryAgain() {
qxtLog->debug()<< _tag << " try again ";
- delete _debugConsole;
- delete _toggleDebugConsole;
+ if(debugMode > -1) {
+ delete _splitter;
+ delete _debugConsole;
+ delete _toggleDebugConsole;
+ }
delete _allowUserChoice;
delete _webView;
delete _networkDiscovery;
diff --git a/src/ndgui.h b/src/ndgui.h
index b6c23a6..d5f86f8 100644
--- a/src/ndgui.h
+++ b/src/ndgui.h
@@ -35,6 +35,7 @@ public slots:
void restartSystem();
void shutDownSystem();
void continueBoot(QString ifName);
+ void continueBootWithoutCheck(QString ifName);
void tryAgain();
diff --git a/src/networkdiscovery.cpp b/src/networkdiscovery.cpp
index 9361887..b0b7131 100644
--- a/src/networkdiscovery.cpp
+++ b/src/networkdiscovery.cpp
@@ -64,6 +64,7 @@ void NetworkDiscovery::initAndRun(QString serverIp, bool userChoice, bool autoUp
_numberOfProcesses = 0;
_ifUpCountdown = 10;
+ _errorStr = "";
_networkManager = new NetworkManager();
_clientProcessToIfNameMap.clear();
_clients.clear();
@@ -148,7 +149,8 @@ void NetworkDiscovery::mainWork()
*/
void NetworkDiscovery::getListOfNetworkInterfacesWithAutoUp() {
QList<QNetworkInterface> nIList = QNetworkInterface::allInterfaces();
-
+ _ifUpList.clear();
+ _ifDownList.clear();
if (nIList.size() > 0) {
foreach(QNetworkInterface nI, nIList)
{
@@ -180,7 +182,7 @@ void NetworkDiscovery::getListOfNetworkInterfacesWithAutoUp() {
}
else if (!(nI.flags() & QNetworkInterface::IsUp)) {
_networkManager->bringInterfaceUP(nI.humanReadableName());
- qxtLog->debug() << _tag << " bring up: " << nI.humanReadableName() ;
+ qxtLog->debug() << _tag << " interface is down, try to bring up: " << nI.humanReadableName() ;
_ifDownList.append(nI.humanReadableName());
}
else if (!(nI.flags() & QNetworkInterface::IsRunning)) {
@@ -200,7 +202,8 @@ void NetworkDiscovery::getListOfNetworkInterfacesWithAutoUp() {
*/
void NetworkDiscovery::getListOfNetworkInterfaces() {
QList<QNetworkInterface> nIList = QNetworkInterface::allInterfaces();
-
+ _ifUpList.clear();
+ _ifDownList.clear();
if (nIList.size() > 0) {
foreach(QNetworkInterface nI, nIList)
{
@@ -285,7 +288,10 @@ void NetworkDiscovery::slotReadyForRun() {
} else {
qxtLog->debug() << _tag << " list is empty. Have not found usable interface. ";
emit
- abortBoot("Have not found usable interface");
+ foreach(QString i, _ifDownList) {
+ qxtLog->debug() << _tag << " " << i << " is not in running state. (check cable)";
+ }
+ abortBoot("All interfaces are not usable. (e.g. please check if all network cables are plugged in. Read the log for more informations.)");
return;
}
}
@@ -487,10 +493,15 @@ bool NetworkDiscovery::checkConnectivityViaTcp() {
*/
bool NetworkDiscovery::checkConnectivityViaTcp(QString server) {
// check connectivity via tcp connection
+ qxtLog->debug() << _tag << " check connectivity to server: " << server;
+ // do host lookup
+ //QHostInfo hostInfo = QHostInfo::fromName(server);
QTcpSocket *tcpSocket = new QTcpSocket(this);
+ //qxtLog->debug() << _tag << " hostInfo first address: " << hostInfo.addresses().first().toString(); //hostInfo.addresses().first()
tcpSocket->connectToHost(server, 80);
if (!tcpSocket->waitForConnected(500)) {
qxtLog->debug() << _tag << tcpSocket->errorString();
+ _errorStr += tcpSocket->errorString();
return false;
} else {
return true;
@@ -608,7 +619,7 @@ void NetworkDiscovery::handleNewInputLine(QLocalSocket * client, QString data) {
emit changeProgressBarValue(interface, 60);
break;
case DHCP_RELEASE:
-
+ qxtLog->debug() << _tag << " " << interface << " release";
break;
case DHCP_INFORM:
break;
@@ -679,10 +690,10 @@ int NetworkDiscovery::ip4_setManualConfiguration(QVariantMap result) {
result["broadcast"].toString(), result["gateway"].toString(), 0,
AF_INET, "/etc/", dns);
- qxtLog->debug() << _tag << "set man conf. and check connectivity";
+ qxtLog->debug() << _tag << " set man conf. and check connectivity";
if (!checkConnectivityViaTcp(_serverIp)) {
- qxtLog->debug() << _tag << "no connectivity. reset conf.";
+ qxtLog->debug() << _tag << " no connectivity. reset conf.";
interfaceconfiguration * ifc = _ifcMap.value(
result["ifname"].toString(), NULL);
if (ifc != NULL) {
@@ -695,8 +706,10 @@ int NetworkDiscovery::ip4_setManualConfiguration(QVariantMap result) {
}
return 0;
- } emit
- continueBoot(result["ifname"].toString());
+ }
+ qxtLog->debug() << _tag << " emit signal continueBootWithoutCheck(" << result["ifname"].toString() << ")";
+ emit
+ continueBootWithoutCheck(result["ifname"].toString());
return 0;
}
@@ -762,7 +775,7 @@ void NetworkDiscovery::killDHCPCD() {
p->start("killall cdhcpcd");
p->waitForFinished();
if (p->exitCode() > 0)
- qxtLog->debug() << _tag << "[tryAgain]" << p->errorString();
+ qxtLog->debug() << _tag << " [tryAgain] " << p->errorString();
delete p;
}
@@ -819,7 +832,7 @@ QVariantMap NetworkDiscovery::getInterfaceConfig(QString ifName) {
* connects the client readyRead signal with the handleNewInput slot.
*/
void NetworkDiscovery::handleNewConnection() {
- qxtLog->debug() << _tag << "New Connection arrived";
+ qxtLog->debug() << _tag << " New Connection arrived";
/*QLocalSocket **/
_client = _server->nextPendingConnection();
@@ -839,7 +852,7 @@ void NetworkDiscovery::handleClientDisconnect() {
QLocalSocket * client = _clients.value(socket);
- qxtLog->debug() << _tag << "disconnect client";
+ qxtLog->debug() << _tag << " disconnect client";
handleNewInput(client);
client->deleteLater();
}
@@ -876,6 +889,13 @@ bool NetworkDiscovery::checkBlackList(QString i) {
+/**/
+QString NetworkDiscovery::GetErrorStr() {
+ return _errorStr;
+}
+
+
+
//////////////////////////////////////////////////////////////////////////////////////
/**
diff --git a/src/networkdiscovery.h b/src/networkdiscovery.h
index 3256ced..d1792a8 100644
--- a/src/networkdiscovery.h
+++ b/src/networkdiscovery.h
@@ -47,6 +47,7 @@ public:
bool checkConnectivity(QString ifName);
bool checkConnectivityViaTcp();
QVariantMap getInterfaceConfig(QString ifName);
+ QString GetErrorStr();
private slots:
void handleNewConnection();
@@ -70,6 +71,7 @@ signals:
void updateStatus(QString status);
void allProcessesFinished();
void continueBoot(QString ifName);
+ void continueBootWithoutCheck(QString ifName);
void setManualConfInterfaces(QString jsonArr);
void readyForRun();
@@ -96,6 +98,7 @@ private:
int _ifUpCountdown;
QTimer*_timer;
QList<Q_PID> _pidsList;
+ QString _errorStr;
QMap<QString,interfaceconfiguration*> _ifcMap;
void mainWork();