mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-19 04:11:46 +02:00
Get rid of DynDns mode in favor of allowing a user to force to use static host/port in the settings dialog.
That now takes precedence, if enabled. If not enabled, and UPnP is enabled, it will attempt UPnP, falling back to static host/port if UPnP doesn't work, falling back to LAN if not. Users can still set LAN specifically in the config file, if they wish. Maybe should expose that at some point.
This commit is contained in:
@@ -88,6 +88,18 @@ Servent::startListening( QHostAddress ha, bool upnp, int port )
|
||||
|
||||
// --lanhack means to advertise your LAN IP over jabber as if it were externallyVisible
|
||||
qDebug() << "Address mode = " << (int)(TomahawkSettings::instance()->externalAddressMode());
|
||||
qDebug() << "Static host/port preferred ? = " << ( TomahawkSettings::instance()->preferStaticHostPort() ? "true" : "false" );
|
||||
|
||||
if( TomahawkSettings::instance()->preferStaticHostPort() )
|
||||
{
|
||||
qDebug() << "Forcing static preferred host and port";
|
||||
m_externalHostname = TomahawkSettings::instance()->externalHostname();
|
||||
m_externalPort = TomahawkSettings::instance()->externalPort();
|
||||
qDebug() << m_externalHostname << m_externalPort;
|
||||
emit ready();
|
||||
return true;
|
||||
}
|
||||
|
||||
switch( TomahawkSettings::instance()->externalAddressMode() )
|
||||
{
|
||||
case TomahawkSettings::Lan:
|
||||
@@ -101,14 +113,6 @@ Servent::startListening( QHostAddress ha, bool upnp, int port )
|
||||
}
|
||||
break;
|
||||
|
||||
case TomahawkSettings::DynDns:
|
||||
qDebug() << "External address mode set to dyndns...";
|
||||
m_externalHostname = TomahawkSettings::instance()->externalHostname();
|
||||
m_externalPort = TomahawkSettings::instance()->externalPort();
|
||||
qDebug() << m_externalHostname << m_externalPort;
|
||||
emit ready();
|
||||
break;
|
||||
|
||||
case TomahawkSettings::Upnp:
|
||||
// TODO check if we have a public/internet IP on this machine directly
|
||||
qDebug() << "External address mode set to upnp....";
|
||||
|
@@ -312,6 +312,16 @@ TomahawkSettings::setExternalAddressMode( ExternalAddressMode externalAddressMod
|
||||
setValue( "network/external-address-mode", externalAddressMode );
|
||||
}
|
||||
|
||||
bool TomahawkSettings::preferStaticHostPort() const
|
||||
{
|
||||
return value( "network/prefer-static-host-and-port" ).toBool();
|
||||
}
|
||||
|
||||
void TomahawkSettings::setPreferStaticHostPort( bool prefer )
|
||||
{
|
||||
setValue( "network/prefer-static-host-and-port", prefer );
|
||||
}
|
||||
|
||||
QString
|
||||
TomahawkSettings::externalHostname() const
|
||||
{
|
||||
|
@@ -55,9 +55,12 @@ public:
|
||||
void setJabberPort( int port );
|
||||
|
||||
/// Network settings
|
||||
enum ExternalAddressMode { Lan, DynDns, Upnp };
|
||||
enum ExternalAddressMode { Lan, Upnp };
|
||||
ExternalAddressMode externalAddressMode() const;
|
||||
void setExternalAddressMode(ExternalAddressMode externalAddressMode);
|
||||
|
||||
bool preferStaticHostPort() const;
|
||||
void setPreferStaticHostPort( bool prefer );
|
||||
|
||||
bool httpEnabled() const; /// true by default
|
||||
void setHttpEnabled( bool enable );
|
||||
|
@@ -42,7 +42,9 @@ SettingsDialog::SettingsDialog( QWidget *parent )
|
||||
TomahawkSettings* s = TomahawkSettings::instance();
|
||||
|
||||
ui->checkBoxHttp->setChecked( s->httpEnabled() );
|
||||
ui->checkBoxStaticPreferred->setChecked( s->preferStaticHostPort() );
|
||||
ui->checkBoxUpnp->setChecked( s->externalAddressMode() == TomahawkSettings::Upnp );
|
||||
ui->checkBoxUpnp->setEnabled( !s->preferStaticHostPort() );
|
||||
|
||||
// JABBER
|
||||
ui->checkBoxJabberAutoConnect->setChecked( s->jabberAutoConnect() );
|
||||
@@ -91,6 +93,7 @@ SettingsDialog::SettingsDialog( QWidget *parent )
|
||||
|
||||
connect( ui->buttonBrowse, SIGNAL( clicked() ), SLOT( showPathSelector() ) );
|
||||
connect( ui->proxyButton, SIGNAL( clicked() ), SLOT( showProxySettings() ) );
|
||||
connect( ui->checkBoxStaticPreferred, SIGNAL( toggled(bool) ), SLOT( toggleUpnp(bool) ) );
|
||||
connect( this, SIGNAL( rejected() ), SLOT( onRejected() ) );
|
||||
}
|
||||
|
||||
@@ -116,7 +119,9 @@ SettingsDialog::~SettingsDialog()
|
||||
}
|
||||
|
||||
s->setHttpEnabled( ui->checkBoxHttp->checkState() == Qt::Checked );
|
||||
s->setExternalAddressMode(ui->checkBoxUpnp->checkState() == Qt::Checked ? TomahawkSettings::Upnp : TomahawkSettings::Lan);
|
||||
|
||||
s->setPreferStaticHostPort( ui->checkBoxStaticPreferred->checkState() == Qt::Checked );
|
||||
s->setExternalAddressMode( ui->checkBoxUpnp->checkState() == Qt::Checked ? TomahawkSettings::Upnp : TomahawkSettings::Lan );
|
||||
|
||||
s->setJabberAutoConnect( ui->checkBoxJabberAutoConnect->checkState() == Qt::Checked );
|
||||
s->setJabberUsername( ui->jabberUsername->text() );
|
||||
@@ -222,6 +227,16 @@ SettingsDialog::showProxySettings()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SettingsDialog::toggleUpnp( bool preferStaticEnabled )
|
||||
{
|
||||
if ( preferStaticEnabled )
|
||||
ui->checkBoxUpnp->setEnabled( false );
|
||||
else
|
||||
ui->checkBoxUpnp->setEnabled( true );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
SettingsDialog::testLastFmLogin()
|
||||
{
|
||||
|
@@ -50,6 +50,8 @@ private slots:
|
||||
void showPathSelector();
|
||||
void doScan();
|
||||
|
||||
void toggleUpnp( bool preferStaticEnabled );
|
||||
|
||||
void showProxySettings();
|
||||
|
||||
void testLastFmLogin();
|
||||
|
@@ -235,9 +235,12 @@
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_13">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||
<layout class="QVBoxLayout" name="staticSettingsLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<layout class="QHBoxLayout" name="staticPreferredLayout"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="staticHostNamePortLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
@@ -253,7 +256,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<layout class="QHBoxLayout" name="staticHostNamePortLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="staticHostNameLabel">
|
||||
<property name="sizePolicy">
|
||||
@@ -295,6 +298,16 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxStaticPreferred">
|
||||
<property name="layoutDirection">
|
||||
<enum>Qt::RightToLeft</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Always use static host name/port? (Overrides UPnP discovery/port forwarding)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
Reference in New Issue
Block a user