From 2e2e61962d093bdfc39c3a444420e67eb40475d8 Mon Sep 17 00:00:00 2001 From: "Tux3 / Mlkj / !Lev.uXFMLA" Date: Wed, 2 Jul 2014 00:47:06 +0200 Subject: [PATCH] Add option to disable IPv6 Fixes #50 --- core.cpp | 8 +++++++- settings.cpp | 12 ++++++++++++ settings.h | 5 +++++ widget/form/settingsform.cpp | 10 ++++++++++ widget/form/settingsform.h | 3 +++ 5 files changed, 37 insertions(+), 1 deletion(-) diff --git a/core.cpp b/core.cpp index 970d6fcfa..0fcd09fc6 100644 --- a/core.cpp +++ b/core.cpp @@ -63,7 +63,13 @@ Core::~Core() void Core::start() { - tox = tox_new(1); // IPv6 enabled, needed for LAN discovery, but can crash some weird routers + // IPv6 needed for LAN discovery, but can crash some weird routers. On by default, can be disabled in options. + bool enableIPv6 = Settings::getInstance().getEnableIPv6(); + if (enableIPv6) + qDebug() << "Core starting with IPv6 enabled"; + else + qWarning() << "Core starting with IPv6 disabled. LAN discovery may not work properly."; + tox = tox_new(enableIPv6); if (tox == nullptr) { qCritical() << "Tox core failed to start"; diff --git a/settings.cpp b/settings.cpp index e668f22ae..204119f6b 100644 --- a/settings.cpp +++ b/settings.cpp @@ -83,6 +83,7 @@ void Settings::load() s.beginGroup("General"); username = s.value("username", "My name").toString(); statusMessage = s.value("statusMessage", "My status").toString(); + enableIPv6 = s.value("enableIPv6", true).toBool(); s.endGroup(); s.beginGroup("Widgets"); @@ -142,6 +143,7 @@ void Settings::save() s.beginGroup("General"); s.setValue("username", username); s.setValue("statusMessage", statusMessage); + s.setValue("enableIPv6", enableIPv6); s.endGroup(); s.beginGroup("Widgets"); @@ -209,6 +211,16 @@ void Settings::setStatusMessage(const QString& newMessage) statusMessage = newMessage; } +bool Settings::getEnableIPv6() const +{ + return enableIPv6; +} + +void Settings::setEnableIPv6(bool newValue) +{ + enableIPv6 = newValue; +} + bool Settings::getEnableLogging() const { return enableLogging; diff --git a/settings.h b/settings.h index 82bc968bd..d113f8e11 100644 --- a/settings.h +++ b/settings.h @@ -49,6 +49,9 @@ public: QString getStatusMessage() const; void setStatusMessage(const QString& newMessage); + bool getEnableIPv6() const; + void setEnableIPv6(bool newValue); + bool getEnableLogging() const; void setEnableLogging(bool newValue); @@ -130,6 +133,8 @@ private: QString username; QString statusMessage; + bool enableIPv6; + bool enableLogging; bool encryptLogs; diff --git a/widget/form/settingsform.cpp b/widget/form/settingsform.cpp index e8a0150d5..4e000848a 100644 --- a/widget/form/settingsform.cpp +++ b/widget/form/settingsform.cpp @@ -1,5 +1,6 @@ #include "settingsform.h" #include "widget/widget.h" +#include "settings.h" #include SettingsForm::SettingsForm() @@ -19,6 +20,8 @@ SettingsForm::SettingsForm() id.setTextInteractionFlags(Qt::TextSelectableByMouse); videoTest.setText("Test video"); + enableIPv6.setText("Enable IPv6 (recommended)"); + enableIPv6.setChecked(Settings::getInstance().getEnableIPv6()); main->setLayout(&layout); layout.addWidget(&nameLabel); @@ -28,12 +31,14 @@ SettingsForm::SettingsForm() layout.addWidget(&idLabel); layout.addWidget(&id); layout.addWidget(&videoTest); + layout.addWidget(&enableIPv6); layout.addStretch(); head->setLayout(&headLayout); headLayout.addWidget(&headLabel); connect(&videoTest, SIGNAL(clicked()), this, SLOT(onTestVideoClicked())); + connect(&enableIPv6, SIGNAL(stateChanged(int)), this, SLOT(onEnableIPv6Updated())); } SettingsForm::~SettingsForm() @@ -59,3 +64,8 @@ void SettingsForm::onTestVideoClicked() { Widget::getInstance()->showTestCamview(); } + +void SettingsForm::onEnableIPv6Updated() +{ + Settings::getInstance().setEnableIPv6(enableIPv6.isChecked()); +} diff --git a/widget/form/settingsform.h b/widget/form/settingsform.h index e9b2ffb10..a6dc7c642 100644 --- a/widget/form/settingsform.h +++ b/widget/form/settingsform.h @@ -7,6 +7,7 @@ #include #include #include +#include #include "ui_widget.h" #include "widget/selfcamview.h" @@ -24,10 +25,12 @@ public slots: private slots: void onTestVideoClicked(); + void onEnableIPv6Updated(); private: QLabel headLabel, nameLabel, statusTextLabel, idLabel, id; QPushButton videoTest; + QCheckBox enableIPv6; QVBoxLayout layout, headLayout; QWidget *main, *head;