mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 11:20:22 +02: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:
@@ -375,6 +375,7 @@ NetworkProxyFactory::setNoProxyHosts( const QStringList& hosts )
|
|||||||
{
|
{
|
||||||
QString munge = host.simplified();
|
QString munge = host.simplified();
|
||||||
newList << munge;
|
newList << munge;
|
||||||
|
//TODO: wildcard support
|
||||||
}
|
}
|
||||||
qDebug() << Q_FUNC_INFO << " No-proxy hosts: " << newList;
|
qDebug() << Q_FUNC_INFO << " No-proxy hosts: " << newList;
|
||||||
m_noProxyHosts = newList;
|
m_noProxyHosts = newList;
|
||||||
|
@@ -57,7 +57,10 @@ namespace TomahawkUtils
|
|||||||
class DLLEXPORT NetworkProxyFactory : public QNetworkProxyFactory
|
class DLLEXPORT NetworkProxyFactory : public QNetworkProxyFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NetworkProxyFactory() {}
|
NetworkProxyFactory()
|
||||||
|
: m_proxy( QNetworkProxy::NoProxy )
|
||||||
|
{}
|
||||||
|
|
||||||
virtual ~NetworkProxyFactory() {}
|
virtual ~NetworkProxyFactory() {}
|
||||||
|
|
||||||
virtual QList< QNetworkProxy > queryProxy( const QNetworkProxyQuery & query = QNetworkProxyQuery() );
|
virtual QList< QNetworkProxy > queryProxy( const QNetworkProxyQuery & query = QNetworkProxyQuery() );
|
||||||
|
@@ -155,22 +155,22 @@ JabberPlugin::refreshProxy()
|
|||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
if(!m_client->connection())
|
if( !m_client->connection() )
|
||||||
{
|
return;
|
||||||
m_client->setConnection(new Jreen::TcpConnection(m_currentServer, m_currentPort));
|
|
||||||
}
|
|
||||||
|
|
||||||
QNetworkProxy proxyToUse = TomahawkUtils::proxyFactory()->queryProxy( QNetworkProxyQuery( m_currentServer, m_currentPort ) ).first();
|
QNetworkProxy proxyToUse = TomahawkUtils::proxyFactory()->queryProxy( QNetworkProxyQuery( m_currentServer, m_currentPort ) ).first();
|
||||||
m_usedProxy = proxyToUse;
|
m_usedProxy = proxyToUse;
|
||||||
|
|
||||||
if( proxyToUse.type() != QNetworkProxy::NoProxy && ( m_currentServer.isEmpty() || !(m_currentPort > 0) ) )
|
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
|
// patches are welcome in Jreen that implement jdns through proxy
|
||||||
emit error( SipPlugin::ConnectionError,
|
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" ) );
|
tr( "You need to set hostname and port of your jabber server, if you want to use it through a proxy" ) );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qDebug() << Q_FUNC_INFO << " proxy type is NoProxy ? " << (proxyToUse.type() == QNetworkProxy::NoProxy ? "true" : "false" );
|
||||||
qobject_cast<Jreen::DirectConnection*>( m_client->connection() )->setProxy( proxyToUse );
|
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?!
|
return true; //FIXME: should i return false here?!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
refreshProxy();
|
||||||
|
|
||||||
qDebug() << "Connecting to the XMPP server..." << m_client->jid().full();
|
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
|
//FIXME: we're badly workarounding some missing reconnection api here, to be fixed soon
|
||||||
QTimer::singleShot( 1000, m_client, SLOT( connectToServer() ) );
|
QTimer::singleShot( 1000, m_client, SLOT( connectToServer() ) );
|
||||||
|
|
||||||
@@ -507,15 +507,13 @@ JabberPlugin::checkSettings()
|
|||||||
|
|
||||||
QNetworkProxy proxyToUse = TomahawkUtils::proxyFactory()->queryProxy( QNetworkProxyQuery( m_currentServer, m_currentPort ) ).first();
|
QNetworkProxy proxyToUse = TomahawkUtils::proxyFactory()->queryProxy( QNetworkProxyQuery( m_currentServer, m_currentPort ) ).first();
|
||||||
if ( proxyToUse.hostName() != m_usedProxy.hostName() ||
|
if ( proxyToUse.hostName() != m_usedProxy.hostName() ||
|
||||||
proxyToUse.port() != m_usedProxy.port() ||
|
proxyToUse.port() != m_usedProxy.port() ||
|
||||||
proxyToUse.user() != m_usedProxy.user() ||
|
proxyToUse.user() != m_usedProxy.user() ||
|
||||||
proxyToUse.password() != m_usedProxy.password() ||
|
proxyToUse.password() != m_usedProxy.password() ||
|
||||||
proxyToUse.type() != m_usedProxy.type() ||
|
proxyToUse.type() != m_usedProxy.type() ||
|
||||||
proxyToUse.capabilities() != m_usedProxy.capabilities() )
|
proxyToUse.capabilities() != m_usedProxy.capabilities()
|
||||||
{
|
)
|
||||||
m_usedProxy = proxyToUse;
|
|
||||||
reconnect = true;
|
reconnect = true;
|
||||||
}
|
|
||||||
|
|
||||||
m_currentUsername = accountName();
|
m_currentUsername = accountName();
|
||||||
m_currentPassword = readPassword();
|
m_currentPassword = readPassword();
|
||||||
@@ -534,6 +532,8 @@ JabberPlugin::checkSettings()
|
|||||||
|
|
||||||
setupClientHelper();
|
setupClientHelper();
|
||||||
|
|
||||||
|
refreshProxy();
|
||||||
|
|
||||||
qDebug() << Q_FUNC_INFO << "Updated settings";
|
qDebug() << Q_FUNC_INFO << "Updated settings";
|
||||||
connectPlugin( false );
|
connectPlugin( false );
|
||||||
}
|
}
|
||||||
|
@@ -193,7 +193,9 @@ TomahawkApp::init()
|
|||||||
QNetworkProxy proxy( static_cast<QNetworkProxy::ProxyType>( s->proxyType() ), s->proxyHost(), s->proxyPort(), s->proxyUsername(), s->proxyPassword() );
|
QNetworkProxy proxy( static_cast<QNetworkProxy::ProxyType>( s->proxyType() ), s->proxyHost(), s->proxyPort(), s->proxyUsername(), s->proxyPassword() );
|
||||||
proxyFactory->setProxy( proxy );
|
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 );
|
TomahawkUtils::NetworkProxyFactory::setApplicationProxyFactory( proxyFactory );
|
||||||
|
|
||||||
#ifdef LIBLASTFM_FOUND
|
#ifdef LIBLASTFM_FOUND
|
||||||
@@ -535,7 +537,7 @@ TomahawkApp::setupSIP()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
qDebug() << "Connecting SIP classes";
|
qDebug() << "Connecting SIP classes";
|
||||||
SipHandler::instance()->refreshProxy();
|
//SipHandler::instance()->refreshProxy();
|
||||||
SipHandler::instance()->loadFromConfig( true );
|
SipHandler::instance()->loadFromConfig( true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user