1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-21 13:21:52 +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:
Jeff Mitchell
2011-02-14 15:54:08 -05:00
parent 745e6793dd
commit 451c7d6943
6 changed files with 60 additions and 13 deletions

View File

@@ -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 // --lanhack means to advertise your LAN IP over jabber as if it were externallyVisible
qDebug() << "Address mode = " << (int)(TomahawkSettings::instance()->externalAddressMode()); 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() ) switch( TomahawkSettings::instance()->externalAddressMode() )
{ {
case TomahawkSettings::Lan: case TomahawkSettings::Lan:
@@ -101,14 +113,6 @@ Servent::startListening( QHostAddress ha, bool upnp, int port )
} }
break; 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: case TomahawkSettings::Upnp:
// TODO check if we have a public/internet IP on this machine directly // TODO check if we have a public/internet IP on this machine directly
qDebug() << "External address mode set to upnp...."; qDebug() << "External address mode set to upnp....";

View File

@@ -312,6 +312,16 @@ TomahawkSettings::setExternalAddressMode( ExternalAddressMode externalAddressMod
setValue( "network/external-address-mode", externalAddressMode ); 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 QString
TomahawkSettings::externalHostname() const TomahawkSettings::externalHostname() const
{ {

View File

@@ -55,10 +55,13 @@ public:
void setJabberPort( int port ); void setJabberPort( int port );
/// Network settings /// Network settings
enum ExternalAddressMode { Lan, DynDns, Upnp }; enum ExternalAddressMode { Lan, Upnp };
ExternalAddressMode externalAddressMode() const; ExternalAddressMode externalAddressMode() const;
void setExternalAddressMode(ExternalAddressMode externalAddressMode); void setExternalAddressMode(ExternalAddressMode externalAddressMode);
bool preferStaticHostPort() const;
void setPreferStaticHostPort( bool prefer );
bool httpEnabled() const; /// true by default bool httpEnabled() const; /// true by default
void setHttpEnabled( bool enable ); void setHttpEnabled( bool enable );

View File

@@ -42,7 +42,9 @@ SettingsDialog::SettingsDialog( QWidget *parent )
TomahawkSettings* s = TomahawkSettings::instance(); TomahawkSettings* s = TomahawkSettings::instance();
ui->checkBoxHttp->setChecked( s->httpEnabled() ); ui->checkBoxHttp->setChecked( s->httpEnabled() );
ui->checkBoxStaticPreferred->setChecked( s->preferStaticHostPort() );
ui->checkBoxUpnp->setChecked( s->externalAddressMode() == TomahawkSettings::Upnp ); ui->checkBoxUpnp->setChecked( s->externalAddressMode() == TomahawkSettings::Upnp );
ui->checkBoxUpnp->setEnabled( !s->preferStaticHostPort() );
// JABBER // JABBER
ui->checkBoxJabberAutoConnect->setChecked( s->jabberAutoConnect() ); ui->checkBoxJabberAutoConnect->setChecked( s->jabberAutoConnect() );
@@ -91,6 +93,7 @@ SettingsDialog::SettingsDialog( QWidget *parent )
connect( ui->buttonBrowse, SIGNAL( clicked() ), SLOT( showPathSelector() ) ); connect( ui->buttonBrowse, SIGNAL( clicked() ), SLOT( showPathSelector() ) );
connect( ui->proxyButton, SIGNAL( clicked() ), SLOT( showProxySettings() ) ); connect( ui->proxyButton, SIGNAL( clicked() ), SLOT( showProxySettings() ) );
connect( ui->checkBoxStaticPreferred, SIGNAL( toggled(bool) ), SLOT( toggleUpnp(bool) ) );
connect( this, SIGNAL( rejected() ), SLOT( onRejected() ) ); connect( this, SIGNAL( rejected() ), SLOT( onRejected() ) );
} }
@@ -116,7 +119,9 @@ SettingsDialog::~SettingsDialog()
} }
s->setHttpEnabled( ui->checkBoxHttp->checkState() == Qt::Checked ); 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->setJabberAutoConnect( ui->checkBoxJabberAutoConnect->checkState() == Qt::Checked );
s->setJabberUsername( ui->jabberUsername->text() ); 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 void
SettingsDialog::testLastFmLogin() SettingsDialog::testLastFmLogin()
{ {

View File

@@ -50,6 +50,8 @@ private slots:
void showPathSelector(); void showPathSelector();
void doScan(); void doScan();
void toggleUpnp( bool preferStaticEnabled );
void showProxySettings(); void showProxySettings();
void testLastFmLogin(); void testLastFmLogin();

View File

@@ -235,9 +235,12 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_13"> <layout class="QVBoxLayout" name="verticalLayout_13">
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_9"> <layout class="QVBoxLayout" name="staticSettingsLayout">
<item> <item>
<widget class="QLabel" name="label_6"> <layout class="QHBoxLayout" name="staticPreferredLayout"/>
</item>
<item>
<widget class="QLabel" name="staticHostNamePortLabel">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed"> <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@@ -253,7 +256,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_6"> <layout class="QHBoxLayout" name="staticHostNamePortLayout">
<item> <item>
<widget class="QLabel" name="staticHostNameLabel"> <widget class="QLabel" name="staticHostNameLabel">
<property name="sizePolicy"> <property name="sizePolicy">
@@ -295,6 +298,16 @@
</item> </item>
</layout> </layout>
</item> </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> </layout>
</item> </item>
<item> <item>