Bug 131377 - MusicBrainz lookup in Amarok is missing support for proxy exceptions
Summary: MusicBrainz lookup in Amarok is missing support for proxy exceptions
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: general (show other bugs)
Version: 1.4.1
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-07-26 04:44 UTC by N.Cat
Modified: 2006-07-30 00:03 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Patch for proxy exception support (1.99 KB, patch)
2006-07-26 04:45 UTC, N.Cat
Details

Note You need to log in before you can comment on or make changes to this bug.
Description N.Cat 2006-07-26 04:44:11 UTC
Version:           1.4.1 (using KDE KDE 3.5.4)
Installed from:    Compiled From Sources

MusicBrainz lookup in Amarok uses the HTTP proxy server defined in kcontrol. It will try to use the proxy server even if "Use proxy only for entries in this list" is enabled in kcontrol, which is not correct behaviour and causes it to fail here.

I've converted the fix (with a slight improvement) by Michael Pyne for the same bug in JuK (#107517). This allows Amarok to check the exception list and only use the proxy if it is actually enabled for the MusicBrainz site.

It's possible the proxy support is broken in tunepimp altogether, see #118288.
Comment 1 N.Cat 2006-07-26 04:45:39 UTC
Created attachment 17129 [details]
Patch for proxy exception support

This is the patch that correctly fixes the problem, also available at
http://trisk.acm.jhu.edu/ktrm-proxy-exception.diff
Comment 2 Martin Aumueller 2006-07-30 00:03:43 UTC
SVN commit 567716 by aumuell:

proxy exceptions for musicbrainz lookups
BUG: 131377


 M  +2 -0      ChangeLog  
 M  +35 -2     src/ktrm.cpp  


--- trunk/extragear/multimedia/amarok/ChangeLog #567715:567716
@@ -68,6 +68,8 @@
       since the last time it was enabled.
 
   BUGFIXES:
+    * Honour proxy exceptions for MusicBrainz lookups. Patch by N. Cat
+      <trisk-bug@quasarnet.org>. (BR 131377)
     * Correctly pass links containing parentheses to external browsers. Patch
       by Thomas Lindroth <tholi945@student.liu.se>. (BR 131307)
     * iPods would not show podcast descriptions. (BR 129824)
--- trunk/extragear/multimedia/amarok/src/ktrm.cpp #567715:567716
@@ -28,6 +28,7 @@
 #include <kapplication.h>
 #include <kprotocolmanager.h>
 #include <kurl.h>
+#include <kresolver.h>
 
 #include <qmutex.h>
 #include <qevent.h>
@@ -142,9 +143,41 @@
 #endif
         tp_SetNotifyCallback(m_pimp, TRMNotifyCallback, 0);
 
+        KProtocolManager::reparseConfiguration();
+
         if(KProtocolManager::useProxy()) {
-            KURL proxy = KProtocolManager::proxyFor("http");
-            tp_SetProxy(m_pimp, proxy.host().latin1(), short(proxy.port()));
+            QString noProxiesFor = KProtocolManager::noProxyFor();
+            QStringList noProxies = QStringList::split(QRegExp("[',''\t'' ']"), noProxiesFor);
+            bool useProxy = true;
+
+            char server[255];
+            short port;
+            tp_GetServer(m_pimp, server, 255, &port);
+            QString tunepimpHost = QString(server);
+            QString tunepimpHostWithPort = (tunepimpHost + ":%1").arg(port);
+
+            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;
+                }
+
+                if(normalizedHost == tunepimpHostWithPort ||
+                    tunepimpHostWithPort.endsWith("." + normalizedHost)) {
+                    useProxy = false;
+                    break;
+                }
+            }
+
+            if(KProtocolManager::useReverseProxy())
+                useProxy = !useProxy;
+
+            if(useProxy) {
+                KURL proxy = KProtocolManager::proxyFor("http");
+                tp_SetProxy(m_pimp, proxy.host().latin1(), short(proxy.port()));
+            }
         }
     }