banshee r3788 - in trunk/banshee: . build src/Extensions/Banshee.Daap/Daap
- From: ahixon svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r3788 - in trunk/banshee: . build src/Extensions/Banshee.Daap/Daap
- Date: Wed, 16 Apr 2008 23:33:51 +0100 (BST)
Author: ahixon
Date: Wed Apr 16 23:33:51 2008
New Revision: 3788
URL: http://svn.gnome.org/viewvc/banshee?rev=3788&view=rev
Log:
2008-04-16 Alexander Hixon <hixon alexander mediati org>
* build/build.environment.mk
* src/Extensions/Banshee.Daap/Daap/ServiceLocator.cs: We don't like
bandaids.
Modified:
trunk/banshee/ChangeLog
trunk/banshee/build/build.environment.mk
trunk/banshee/src/Extensions/Banshee.Daap/Daap/ServiceLocator.cs
Modified: trunk/banshee/build/build.environment.mk
==============================================================================
--- trunk/banshee/build/build.environment.mk (original)
+++ trunk/banshee/build/build.environment.mk Wed Apr 16 23:33:51 2008
@@ -139,7 +139,7 @@
# Extensions
REF_EXTENSION_AUDIOCD = $(LINK_BANSHEE_THICKCLIENT_DEPS) $(LINK_MUSICBRAINZ_DEPS)
REF_EXTENSION_BOOKMARKS = $(LINK_BANSHEE_THICKCLIENT_DEPS)
-REF_EXTENSION_DAAP = $(LINK_BANSHEE_THICKCLIENT_DEPS) $(LINK_ICSHARP_ZIP_LIB) $(LINK_MONO_ZEROCONF) -pkg:avahi-sharp
+REF_EXTENSION_DAAP = $(LINK_BANSHEE_THICKCLIENT_DEPS) $(LINK_ICSHARP_ZIP_LIB) $(LINK_MONO_ZEROCONF)
REF_EXTENSION_MULTIMEDIAKEYS = $(LINK_BANSHEE_SERVICES_DEPS)
REF_EXTENSION_NOTIFICATIONAREA = $(LINK_BANSHEE_THICKCLIENT_DEPS)
REF_EXTENSION_PLAYQUEUE = $(LINK_BANSHEE_THICKCLIENT_DEPS)
Modified: trunk/banshee/src/Extensions/Banshee.Daap/Daap/ServiceLocator.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Daap/Daap/ServiceLocator.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Daap/Daap/ServiceLocator.cs Wed Apr 16 23:33:51 2008
@@ -17,8 +17,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#define USE_AVAHI_SHARP
-
using System;
using System.Net;
using System.Net.Sockets;
@@ -26,12 +24,7 @@
using System.Collections.Generic;
using Hyena;
-
-#if USE_AVAHI_SHARP
-using Avahi;
-#else
using Mono.Zeroconf;
-#endif
namespace Daap {
@@ -85,146 +78,6 @@
}
}
-#if USE_AVAHI_SHARP
- public class ServiceLocator
- {
- private Avahi.Client client;
- private ServiceBrowser browser;
- private Dictionary <string, Service> services = new Dictionary <string, Service> ();
- private List <ServiceResolver> resolvers = new List <ServiceResolver> ();
- private bool showLocals = false;
-
- public event ServiceHandler Found;
- public event ServiceHandler Removed;
-
- public bool ShowLocalServices {
- get { return showLocals; }
- set { showLocals = value; }
- }
-
- public Service [] Services {
- get {
- Service [] ret = new Service [services.Count];
- services.Values.CopyTo (ret, 0);
- return ret;
- }
- }
-
- public ServiceLocator ()
- {
- Log.Debug ("ServiceLocator backend", "using Avahi.");
- }
-
- public void Start ()
- {
- if (client == null) {
- client = new Avahi.Client ();
- browser = new ServiceBrowser (client, "_daap._tcp");
- browser.ServiceAdded += OnServiceAdded;
- browser.ServiceRemoved += OnServiceRemoved;
- }
- }
-
- public void Stop ()
- {
- if (client != null) {
- services.Clear ();
- browser.Dispose ();
- client.Dispose ();
- client = null;
- browser = null;
- }
- }
-
- private void OnServiceAdded (object o, ServiceInfoArgs args)
- {
- if ((args.Service.Flags & LookupResultFlags.Local) > 0 && !showLocals)
- return;
-
- Log.DebugFormat ("Got {0}, trying to resolve...", args.Service.Name);
-
- ServiceResolver resolver = new ServiceResolver (client, args.Service);
- resolvers.Add (resolver);
- resolver.Found += OnServiceResolved;
- resolver.Timeout += OnServiceTimeout;
- }
-
- private void OnServiceResolved (object o, ServiceInfoArgs args)
- {
- ServiceResolver resolver = o as ServiceResolver;
- resolvers.Remove (resolver);
- resolver.Dispose ();
-
- string name = args.Service.Name;
-
- Log.DebugFormat ("Managed to resolve {0}.", name);
-
- bool pwRequired = false;
-
- // iTunes tacks this on to indicate a passsword protected share. Ugh.
- if (name.EndsWith ("_PW")) {
- name = name.Substring (0, name.Length - 3);
- pwRequired = true;
- }
-
- foreach (byte[] txt in args.Service.Text) {
- string txtstr = Encoding.UTF8.GetString (txt);
-
- string[] splitstr = txtstr.Split('=');
-
- if (splitstr.Length < 2)
- continue;
-
- if (splitstr[0].ToLower () == "password")
- pwRequired = splitstr[1].ToLower () == "true";
- else if (splitstr[0].ToLower () == "machine name")
- name = splitstr[1];
- }
-
- IPAddress address = args.Service.Address;
-
- Log.DebugFormat ("OnServiceResolved provided {0}", address);
-
- // XXX: Workaround a Mono bug where we can't resolve IPv6 addresses properly
- if (services.ContainsKey (name) && address.AddressFamily == AddressFamily.InterNetworkV6) {
- // Only skip this service if it resolves to a IPv6 address, and we *already have info
- // for this service already*.
- Log.Debug ("Skipping service", "already have IPv4 address.");
- return;
- }
-
- Service svc = new Service (address, args.Service.Port,
- name, pwRequired);
-
- if (services.ContainsKey (name)) {
- services[name] = svc;
- } else {
- services.Add (name, svc);
- }
-
- if (Found != null)
- Found (this, new ServiceArgs (svc));
- }
-
- private void OnServiceTimeout (object o, EventArgs args)
- {
- Log.Warning ("Failed to resolve", false);
- }
-
- private void OnServiceRemoved (object o, ServiceInfoArgs args)
- {
- if (services.ContainsKey (args.Service.Name)) {
- Service svc = (Service) services[args.Service.Name];
- services.Remove (svc.Name);
-
- if (Removed != null)
- Removed (this, new ServiceArgs (svc));
- }
- }
- }
-
-#else
-
public class ServiceLocator {
private ServiceBrowser browser;
@@ -347,5 +200,4 @@
}
}
}
-#endif
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]