Skip to content
Snippets Groups Projects
Commit 702b4709 authored by borsitsb's avatar borsitsb
Browse files

added Linux compatibility

parent 48737857
Branches
No related tags found
No related merge requests found
......@@ -8,11 +8,12 @@
#ifndef DIAGNOSTIC_HPP
#define DIAGNOSTIC_HPP
static QString gateway_ip;
class Diagnostic {
typedef QString (Diagnostic::*diagFn_t)();
typedef QString (*diagFn_t)();
public:
QString gateway_ip;
static const int funcsLen = 3;
diagFn_t funcs[funcsLen];
......@@ -22,7 +23,7 @@ public:
funcs[2] = getInterfaceInfo;
}
QString getRoutingInfo(){
static QString getRoutingInfo(){
FILE *cmdHandle;
QString ipAddr("- - - Default Gateway - - - \n");
#if defined( Q_OS_WIN )
......@@ -55,7 +56,7 @@ public:
return ipAddr.append("\n");
}
QString getInterfaceInfo(){
static QString getInterfaceInfo(){
QList<QNetworkInterface> ifList = QNetworkInterface::allInterfaces();
QStringList out;
QString tab(" ");
......@@ -86,7 +87,7 @@ public:
return QString(out.join(' '));
}
QString getPingGateway(){
static QString getPingGateway(){
QString ping_stat("- - - Pinging Default Gateway - - -\n");
if (gateway_ip.isEmpty() == false){
......@@ -94,6 +95,9 @@ public:
cmdHandle = popen(
#if defined( Q_OS_WIN )
QString("ping -n 4 -w 1 %1").arg(gateway_ip).toStdString().c_str(), "r"
#elif defined ( Q_OS_LINUX )
QString("ping -c 4 -W 1 %1").arg(gateway_ip).toStdString().c_str(), "r"
#else
#error "We do not support ping for this OS."
#endif
......
......@@ -195,7 +195,7 @@ void NetCheckerWindow::nextPage(){
global_w->setCurrentIndex(1);
double step = 100.0/Diagnostic::funcsLen;
for (int i = 0; i < Diagnostic::funcsLen; i++){
log_w->append((d.*d.Diagnostic::funcs[i])());
log_w->append((d.funcs[i])());
progressbar_w->setValue(static_cast<int>(ceil(step*(i+1))));
/*QMessageBox msg;
msg.setText(QString("[%1]").arg(d.gateway_ip));
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment