FEATURE: qBittorrent can update dynamic DNS services (DynDNS, no-ip)

This commit is contained in:
Christophe Dumez
2011-04-15 13:02:39 +00:00
parent fd4f46485c
commit c85cb8799e
10 changed files with 559 additions and 8 deletions

View File

@@ -2281,11 +2281,103 @@ QGroupBox {
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="checkDynDNS">
<property name="title">
<string>Update my dynamic domain name</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QFormLayout" name="formLayout_5">
<item row="0" column="0">
<widget class="QLabel" name="label_19">
<property name="text">
<string>Service:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QComboBox" name="comboDNSService">
<item>
<property name="text">
<string>DynDNS</string>
</property>
</item>
<item>
<property name="text">
<string>No-IP</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QPushButton" name="registerDNSBtn">
<property name="text">
<string>Register</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_20">
<property name="text">
<string>Domain name:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="domainNameTxt">
<property name="text">
<string>changeme.dyndns.org</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_21">
<property name="text">
<string>Username:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="DNSUsernameTxt">
<property name="maxLength">
<number>50</number>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_22">
<property name="text">
<string>Password:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="DNSPasswordTxt">
<property name="maxLength">
<number>50</number>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_9">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
@@ -2315,8 +2407,8 @@ QGroupBox {
<rect>
<x>0</x>
<y>0</y>
<width>86</width>
<height>16</height>
<width>504</width>
<height>384</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_36"/>

View File

@@ -37,6 +37,7 @@
#include <QCloseEvent>
#include <QDesktopWidget>
#include <QTranslator>
#include <QDesktopServices>
#include <libtorrent/version.hpp>
#include <time.h>
@@ -50,6 +51,7 @@
#include "qinisettings.h"
#include "qbtsession.h"
#include "iconprovider.h"
#include "dnsupdater.h"
using namespace libtorrent;
@@ -203,6 +205,11 @@ options_imp::options_imp(QWidget *parent):
connect(textWebUiUsername, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton()));
connect(textWebUiPassword, SIGNAL(textChanged(QString)), this, SLOT(enableApplyButton()));
connect(checkBypassLocalAuth, SIGNAL(toggled(bool)), this, SLOT(enableApplyButton()));
connect(checkDynDNS, SIGNAL(toggled(bool)), SLOT(enableApplyButton()));
connect(comboDNSService, SIGNAL(currentIndexChanged(int)), SLOT(enableApplyButton()));
connect(domainNameTxt, SIGNAL(textChanged(QString)), SLOT(enableApplyButton()));
connect(DNSUsernameTxt, SIGNAL(textChanged(QString)), SLOT(enableApplyButton()));
connect(DNSPasswordTxt, SIGNAL(textChanged(QString)), SLOT(enableApplyButton()));
// Disable apply Button
applyButton->setEnabled(false);
// Tab selection mecanism
@@ -428,6 +435,12 @@ void options_imp::saveOptions(){
// FIXME: Check that the password is valid (not empty at least)
pref.setWebUiPassword(webUiPassword());
pref.setWebUiLocalAuthEnabled(!checkBypassLocalAuth->isChecked());
// DynDNS
pref.setDynDNSEnabled(checkDynDNS->isChecked());
pref.setDynDNSService(comboDNSService->currentIndex());
pref.setDynDomainName(domainNameTxt->text());
pref.setDynDNSUsername(DNSUsernameTxt->text());
pref.setDynDNSPassword(DNSPasswordTxt->text());
}
// End Web UI
// End preferences
@@ -666,6 +679,12 @@ void options_imp::loadOptions(){
textWebUiUsername->setText(pref.getWebUiUsername());
textWebUiPassword->setText(pref.getWebUiPassword());
checkBypassLocalAuth->setChecked(!pref.isWebUiLocalAuthEnabled());
// Dynamic DNS
checkDynDNS->setChecked(pref.isDynDNSEnabled());
comboDNSService->setCurrentIndex((int)pref.getDynDNSService());
domainNameTxt->setText(pref.getDynDomainName());
DNSUsernameTxt->setText(pref.getDynDNSUsername());
DNSPasswordTxt->setText(pref.getDynDNSPassword());
// End Web UI
// Random stuff
srand(time(0));
@@ -1090,6 +1109,10 @@ void options_imp::showConnectionTab()
tabSelection->setCurrentRow(2);
}
void options_imp::on_registerDNSBtn_clicked() {
QDesktopServices::openUrl(DNSUpdater::getRegistrationUrl(comboDNSService->currentIndex()));
}
void options_imp::on_IpFilterRefreshBtn_clicked() {
if(m_refreshingIpFilter) return;
m_refreshingIpFilter = true;

View File

@@ -80,6 +80,7 @@ private slots:
void on_randomButton_clicked();
void on_addScanFolderButton_clicked();
void on_removeScanFolderButton_clicked();
void on_registerDNSBtn_clicked();
void setLocale(const QString &locale);
private:

View File

@@ -61,6 +61,9 @@ enum ProxyType {HTTP=1, SOCKS5=2, HTTP_PW=3, SOCKS5_PW=4, SOCKS4=5};
namespace TrayIcon {
enum Style { NORMAL = 0, MONO_DARK, MONO_LIGHT };
}
namespace DNS {
enum Service { DYNDNS, NOIP };
}
class Preferences : public QIniSettings {
Q_DISABLE_COPY(Preferences);
@@ -746,6 +749,46 @@ public:
return pass_ha1;
}
bool isDynDNSEnabled() const {
return value("Preferences/DynDNS/Enabled", false).toBool();
}
void setDynDNSEnabled(bool enabled) {
setValue("Preferences/DynDNS/Enabled", enabled);
}
DNS::Service getDynDNSService() const {
return DNS::Service(value("Preferences/DynDNS/Service", DNS::DYNDNS).toInt());
}
void setDynDNSService(int service) {
setValue("Preferences/DynDNS/Service", service);
}
QString getDynDomainName() const {
return value("Preferences/DynDNS/DomainName", "changeme.dyndns.org").toString();
}
void setDynDomainName(const QString name) {
setValue("Preferences/DynDNS/DomainName", name);
}
QString getDynDNSUsername() const {
return value("Preferences/DynDNS/Username").toString();
}
void setDynDNSUsername(const QString username) {
setValue("Preferences/DynDNS/Username", username);
}
QString getDynDNSPassword() const {
return value("Preferences/DynDNS/Password").toString();
}
void setDynDNSPassword(const QString password) {
setValue("Preferences/DynDNS/Password", password);
}
// Advanced settings
void setUILockPassword(const QString &clear_password) {