[Banshee-List] Autoconfigure proxy for MusicBrainz


I have made a small patch that automatically sets the proxy server for
libmusicbrainz using Mono's proxy settings. These can be set in
.config files, and since October are by default loaded from the
conventional http_proxy environment variable.

I wan't sure exactly where to add in this support, but the easiest way
of making sure it gets  everywhere was to put it into the
MusicBrainz.Client constructor. If it were to happen at any other
time, for example after setting the server, there might be some nasty
surprises for people who want to set the proxy manually. For this
scenario I added a public method to make it easy to re-lookup the
proxy based on server address.

Note that GlobalProxySelection has been deprecated in .NET 2, but
replacements doesn't exist in .NET 1.1. A proxy server address can be
found in gconf, but I didn't think a gconf dependecy would be good for

I guess this should really go into the musicbrainz-sharp repository,
so that other projects can get it when they sync.

Could someone test this patch on a machine that doesn't need a proxy,
to make sure it doesn't break anything? It works fine with the proxy
on mine :-)

Index: src/MusicBrainz/Client.cs
RCS file: /cvs/gnome/banshee/src/MusicBrainz/Client.cs,v
retrieving revision 1.4
diff -r1.4 Client.cs
>         private string currentServer = "http://www.musicbrainz.org";;
>             AutoSetProxy ();
>         }
>         public bool AutoSetProxy ()
>         {
>         	Uri proxyAddress = System.Net.GlobalProxySelection.Select.GetProxy (new System.Uri (currentServer));
>         	Console.WriteLine ("Setting MusicBrainz proxy to " + proxyAddress.Host +":" + proxyAddress.Port.ToString ());
>         	return this.SetProxy (proxyAddress.Host, (short) proxyAddress.Port);
<             return mb_SetServer(handle, ToUtf8(serverAddr), serverPort) != 0;
>             if (mb_SetServer(handle, ToUtf8(serverAddr), serverPort) != 0)
>             {
>                 currentServer = serverAddr + serverPort.ToString ();
>                 return true;
>             }
>             else return false;

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]