Skip to content

Commit

Permalink
Merge pull request #103 from dannagle/development
Browse files Browse the repository at this point in the history
Merge with Development
  • Loading branch information
dannagle authored Jan 9, 2018
2 parents b851951 + f433d26 commit 9bc5376
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define GLOBALS_H

//BEGIN SW VERSION
#define SW_VERSION "v5.6.1"
#define SW_VERSION "v5.6.2"
//END SW VERSION


Expand Down Expand Up @@ -57,7 +57,20 @@
#define PSLOGO ":pslogo.png"
#define UPDOWNICON ":icons/moveupdown.png"

//used when binding
#define IPV4_OR_IPV6 (ipMode > 4) ? (QHostAddress::AnyIPv6) : (QHostAddress::AnyIPv4)


//Qt 5.10 changed the way sockets bind
//It seems dual ipv4/ipv6 mode works better.

//I'm not convinced it works perfect when in server mode.

#include <QtGlobal>
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
#define IPV4_OR_IPV6 (QHostAddress::Any)
#else
//used when binding
#define IPV4_OR_IPV6 (ipMode > 4) ? (QHostAddress::AnyIPv6) : (QHostAddress::AnyIPv4)
#endif


#endif // GLOBALS_H
19 changes: 19 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,11 +444,17 @@ int main(int argc, char *argv[])
if(tcp || ssl) {
QSslSocket sock;

#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
sock.bind(QHostAddress::Any, bind);
#else
if(ipv6) {
sock.bind(QHostAddress::AnyIPv6, bind);
} else {
sock.bind(QHostAddress::AnyIPv4, bind);
}
#endif



if(tcp) {
sock.connectToHost(addy, port);
Expand Down Expand Up @@ -554,6 +560,16 @@ int main(int argc, char *argv[])

} else {
QUdpSocket sock;
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)

if(!sock.bind(QHostAddress::Any, bind)) {
OUTIF() << "Error: Could not bind to " << bind;

OUTPUT();
return -1;
}
#else

if(ipv6) {
if(!sock.bind(QHostAddress::AnyIPv6, bind)) {
OUTIF() << "Error: Could not bind to " << bind;
Expand All @@ -571,6 +587,9 @@ int main(int argc, char *argv[])
}

}

#endif

OUTIF() << "UDP (" <<sock.localPort() <<")://" << address << ":" << port << " " << dataString;

bytesWriten = sock.writeDatagram(sendData, addy, port);
Expand Down
3 changes: 3 additions & 0 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,10 @@ MainWindow::MainWindow(QWidget *parent) :
IPmodeButton = new QPushButton("IPv4 Mode");
IPmodeButton->setFlat(true);
IPmodeButton->setCursor(Qt::PointingHandCursor);

#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
statusBar()->insertPermanentWidget(5, IPmodeButton);
#endif

setIPMode();

Expand Down
6 changes: 6 additions & 0 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ Settings::Settings(QWidget *parent) :
ui->asciiResponseEdit->setText(Packet::hexToASCII(ascii));


#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
ui->ipv4Radio->hide();
ui->ipv6Radio->hide();
#endif


int ipMode = settings.value("ipMode", 4).toInt();
if (ipMode > 4) {
ui->ipv6Radio->setChecked(true);
Expand Down

0 comments on commit 9bc5376

Please sign in to comment.