1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-21 00:09:47 +01:00

Fix jabber(/other?) networking. The only part of this commit related to the fix is the line replacing m_client->setConnection with return. I don't know why that line causes what seems to be a total block in the network but it does, and removing it doesn't seem to hurt anything.

Oddly, if refreshProxy doesn't check for m_client->connection() to be null, it segfaults. But, if that function is never run (and that function is the only place setting the connection directly), it works just fine (if no proxy is needed). So maybe it's leftover code but I really don't konw.
This commit is contained in:
Jeff Mitchell 2011-05-25 23:35:21 -04:00
parent f27d3b9fe9
commit e3e90744bf
4 changed files with 24 additions and 18 deletions

View File

@ -375,6 +375,7 @@ NetworkProxyFactory::setNoProxyHosts( const QStringList& hosts )
{
QString munge = host.simplified();
newList << munge;
//TODO: wildcard support
}
qDebug() << Q_FUNC_INFO << " No-proxy hosts: " << newList;
m_noProxyHosts = newList;

View File

@ -57,7 +57,10 @@ namespace TomahawkUtils
class DLLEXPORT NetworkProxyFactory : public QNetworkProxyFactory
{
public:
NetworkProxyFactory() {}
NetworkProxyFactory()
: m_proxy( QNetworkProxy::NoProxy )
{}
virtual ~NetworkProxyFactory() {}
virtual QList< QNetworkProxy > queryProxy( const QNetworkProxyQuery & query = QNetworkProxyQuery() );

View File

@ -155,22 +155,22 @@ JabberPlugin::refreshProxy()
{
qDebug() << Q_FUNC_INFO;
if(!m_client->connection())
{
m_client->setConnection(new Jreen::TcpConnection(m_currentServer, m_currentPort));
}
if( !m_client->connection() )
return;
QNetworkProxy proxyToUse = TomahawkUtils::proxyFactory()->queryProxy( QNetworkProxyQuery( m_currentServer, m_currentPort ) ).first();
m_usedProxy = proxyToUse;
if( proxyToUse.type() != QNetworkProxy::NoProxy && ( m_currentServer.isEmpty() || !(m_currentPort > 0) ) )
{
qDebug() << Q_FUNC_INFO << " proxy type is not noproxy but no server/port set";
// patches are welcome in Jreen that implement jdns through proxy
emit error( SipPlugin::ConnectionError,
tr( "You need to set hostname and port of your jabber server, if you want to use it through a proxy" ) );
return;
}
qDebug() << Q_FUNC_INFO << " proxy type is NoProxy ? " << (proxyToUse.type() == QNetworkProxy::NoProxy ? "true" : "false" );
qobject_cast<Jreen::DirectConnection*>( m_client->connection() )->setProxy( proxyToUse );
}
@ -223,10 +223,10 @@ JabberPlugin::connectPlugin( bool startup )
return true; //FIXME: should i return false here?!
}
refreshProxy();
qDebug() << "Connecting to the XMPP server..." << m_client->jid().full();
refreshProxy();
//FIXME: we're badly workarounding some missing reconnection api here, to be fixed soon
QTimer::singleShot( 1000, m_client, SLOT( connectToServer() ) );
@ -507,15 +507,13 @@ JabberPlugin::checkSettings()
QNetworkProxy proxyToUse = TomahawkUtils::proxyFactory()->queryProxy( QNetworkProxyQuery( m_currentServer, m_currentPort ) ).first();
if ( proxyToUse.hostName() != m_usedProxy.hostName() ||
proxyToUse.port() != m_usedProxy.port() ||
proxyToUse.user() != m_usedProxy.user() ||
proxyToUse.password() != m_usedProxy.password() ||
proxyToUse.type() != m_usedProxy.type() ||
proxyToUse.capabilities() != m_usedProxy.capabilities() )
{
m_usedProxy = proxyToUse;
proxyToUse.port() != m_usedProxy.port() ||
proxyToUse.user() != m_usedProxy.user() ||
proxyToUse.password() != m_usedProxy.password() ||
proxyToUse.type() != m_usedProxy.type() ||
proxyToUse.capabilities() != m_usedProxy.capabilities()
)
reconnect = true;
}
m_currentUsername = accountName();
m_currentPassword = readPassword();
@ -534,6 +532,8 @@ JabberPlugin::checkSettings()
setupClientHelper();
refreshProxy();
qDebug() << Q_FUNC_INFO << "Updated settings";
connectPlugin( false );
}

View File

@ -193,7 +193,9 @@ TomahawkApp::init()
QNetworkProxy proxy( static_cast<QNetworkProxy::ProxyType>( s->proxyType() ), s->proxyHost(), s->proxyPort(), s->proxyUsername(), s->proxyPassword() );
proxyFactory->setProxy( proxy );
}
proxyFactory->setNoProxyHosts( s->proxyNoProxyHosts().split( ',', QString::SkipEmptyParts ) );
if ( !s->proxyNoProxyHosts().isEmpty() )
proxyFactory->setNoProxyHosts( s->proxyNoProxyHosts().split( ',', QString::SkipEmptyParts ) );
TomahawkUtils::NetworkProxyFactory::setApplicationProxyFactory( proxyFactory );
#ifdef LIBLASTFM_FOUND
@ -535,7 +537,7 @@ TomahawkApp::setupSIP()
#endif
qDebug() << "Connecting SIP classes";
SipHandler::instance()->refreshProxy();
//SipHandler::instance()->refreshProxy();
SipHandler::instance()->loadFromConfig( true );
}
}