Summary: | JuK ignores KDE proxy exception setting for MusicBrainz | ||
---|---|---|---|
Product: | [Applications] juk | Reporter: | N.Cat <trisk-bug> |
Component: | general | Assignee: | Scott Wheeler <wheeler> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | 2.2.1 | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
N.Cat
2005-06-16 08:11:48 UTC
This is kind of a hard one because the URL is handled completely internally to MusicBrainz. We basically pass some things we would like to look up and it has a place to specify the proxy, but its proxy handling is pretty simplistic... So, basically we could either hard code it (a little ugly) or try to convince Robert to export the URL. We might go with the former for the next release and see if we can convince him of the latter for something later. SVN commit 467659 by mpyne: Backport fix for bug 107517 (JuK ignores MusicBrainz proxy exceptions) to KDE 3.4. Should be in KDE 3.4.3. I've also fixed it for 3.5 but forgot to CC the bug. Thanks to Thiago for advice on the implementation. BUG:107517 M +49 -2 ktrm.cpp --- branches/KDE/3.4/kdemultimedia/juk/ktrm.cpp #467658:467659 @@ -24,11 +24,13 @@ #if HAVE_MUSICBRAINZ #include <kapplication.h> +#include <kresolver.h> #include <kprotocolmanager.h> #include <kurl.h> #include <kdebug.h> #include <qmutex.h> +#include <qregexp.h> #include <qevent.h> #include <qobject.h> #include <qfile.h> @@ -121,9 +123,52 @@ tp_SetUseUTF8(m_pimp, true); tp_SetNotifyCallback(m_pimp, TRMNotifyCallback, 0); + // Re-read proxy config. + KProtocolManager::reparseConfiguration(); + if(KProtocolManager::useProxy()) { - KURL proxy = KProtocolManager::proxyFor("http"); - tp_SetProxy(m_pimp, proxy.host().latin1(), short(proxy.port())); + // split code copied from kcm_kio. + QString noProxiesFor = KProtocolManager::noProxyFor(); + QStringList noProxies = QStringList::split(QRegExp("[',''\t'' ']"), noProxiesFor); + bool useProxy = true; + + // Host that libtunepimp will contact. + QString tunepimpHost = "www.musicbrainz.org"; + QString tunepimpHostWithPort = "www.musicbrainz.org:80"; + + // Check what hosts are allowed to proceed without being proxied, + // or is using reversed proxy, what hosts must be proxied. + for(QStringList::ConstIterator it = noProxies.constBegin(); it != noProxies.constEnd(); ++it) { + QString normalizedHost = KNetwork::KResolver::normalizeDomain(*it); + + if(normalizedHost == tunepimpHost || + tunepimpHost.endsWith("." + normalizedHost)) + { + useProxy = false; + break; + } + + // KDE's proxy mechanism also supports exempting a specific + // host/port combo, check that also. + if(normalizedHost == tunepimpHostWithPort || + tunepimpHostWithPort.endsWith("." + normalizedHost)) + { + useProxy = false; + break; + } + } + + // KDE supports a reverse proxy mechanism. Uh, yay. + if(KProtocolManager::useReverseProxy()) + useProxy = !useProxy; + + if(useProxy) { + KURL proxy = KProtocolManager::proxyFor("http"); + QString proxyHost = proxy.host(); + + kdDebug(65432) << "Using proxy server " << proxyHost << " for www.musicbrainz.org.\n"; + tp_SetProxy(m_pimp, proxyHost.latin1(), short(proxy.port())); + } } } @@ -505,3 +550,5 @@ } #endif + +// vim: set et ts=8 sw=4: |