banshee r3636 - in trunk/banshee: . src/Extensions/Banshee.Daap/Banshee.Daap src/Extensions/Banshee.Daap/Daap
- From: ahixon svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r3636 - in trunk/banshee: . src/Extensions/Banshee.Daap/Banshee.Daap src/Extensions/Banshee.Daap/Daap
- Date: Tue, 1 Apr 2008 11:24:57 +0100 (BST)
Author: ahixon
Date: Tue Apr 1 11:24:57 2008
New Revision: 3636
URL: http://svn.gnome.org/viewvc/banshee?rev=3636&view=rev
Log:
2008-04-01 Alexander Hixon <hixon alexander mediati org>
* src/Extensions/Banshee.Daap/Daap/ServiceLocator.cs: Use Generics instead
of Hashtable. Use IPv4 addresses where available, but still provide
fallbacks to whatever we first got if we didn't get any other alternatives.
* src/Extensions/Banshee.Daap/Banshee.Daap/DaapService.cs: Update from
changes in ServiceLocator, since we get OnServiceAdded multiple times now.
* src/Extensions/Banshee.Daap/Banshee.Daap/DaapSource.cs: Spit out a
warning dialog if we fail to connect. Hookup the TrackAdded callback, and
stubbed out TrackRemoved. Implement IImportSource (doesn't do much yet).
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapService.cs
trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapSource.cs
trunk/banshee/src/Extensions/Banshee.Daap/Daap/ServiceLocator.cs
Modified: trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapService.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapService.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapService.cs Tue Apr 1 11:24:57 2008
@@ -85,13 +85,23 @@
private void OnServiceFound (object o, ServiceArgs args)
{
DaapSource source = new DaapSource (args.Service);
- source_map.Add (String.Format ("{0}:{1}", args.Service.Address, args.Service.Port), source);
+ string key = String.Format ("{0}:{1}", args.Service.Name, args.Service.Port);
+
+ if (source_map.ContainsKey (key)) {
+ // Received new connection info for service
+ container.RemoveChildSource (source_map [key]);
+ source_map [key] = source;
+ } else {
+ // New service information
+ source_map.Add (key, source);
+ }
+
container.AddChildSource (source);
}
private void OnServiceRemoved (object o, ServiceArgs args)
{
- string key = String.Format ("{0}:{1}", args.Service.Address, args.Service.Port);
+ string key = String.Format ("{0}:{1}", args.Service.Name, args.Service.Port);
DaapSource source = source_map [key];
source.Disconnect (true);
Modified: trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapSource.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapSource.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapSource.cs Tue Apr 1 11:24:57 2008
@@ -33,12 +33,13 @@
using Banshee.Base;
using Banshee.Collection;
using Banshee.Collection.Database;
+using Banshee.Library;
using Banshee.Sources;
using Banshee.ServiceStack;
namespace Banshee.Daap
{
- public class DaapSource : PrimarySource, IDurationAggregator, IDisposable, IUnmapableSource
+ public class DaapSource : PrimarySource, IDurationAggregator, IDisposable, IUnmapableSource, IImportSource
{
private Service service;
private DAAP.Client client;
@@ -92,7 +93,13 @@
box.PackStart(error_view, true, true, 0);
error_view.Show();
});*/
- Console.WriteLine ("Error while connecting to remote: {0}", e);
+
+ string details = String.Format ("Couldn't connect to service {0} on {1}:{2} - {3}",
+ service.Name,
+ service.Address,
+ service.Port, e.ToString ().Replace ("<", "<").Replace (">", ">"));
+ Hyena.Log.Warning ("Failed to connect", details, true);
+ DestroyStatusMessage ();
}
is_activating = false;
@@ -131,8 +138,7 @@
if (database != null) {
database.TrackAdded -= OnDatabaseTrackAdded;
- // TODO
- //database.TrackRemoved -= OnDatabaseTrackRemoved;
+ database.TrackRemoved -= OnDatabaseTrackRemoved;
database = null;
}
@@ -209,9 +215,9 @@
if (database == null && client.Databases.Count > 0) {
database = client.Databases[0];
database.TrackAdded += OnDatabaseTrackAdded;
- //database.TrackRemoved += OnDatabaseTrackRemoved;
- //database_proxy.Database = database;
- //DaapCore.ProxyServer.RegisterDatabase (database);
+ database.TrackRemoved += OnDatabaseTrackRemoved;
+
+ // TODO
//AddPlaylistSources ();
foreach (Track track in database.Tracks) {
@@ -233,7 +239,13 @@
public void OnDatabaseTrackAdded (object o, TrackArgs args)
{
- Console.WriteLine ("Added: {0}", args.Track);
+ DaapTrackInfo track = new DaapTrackInfo (args.Track, this);
+ track.Save ();
+ }
+
+ public void OnDatabaseTrackRemoved (object o, TrackArgs args)
+ {
+ // FIXME
}
public override bool CanRemoveTracks {
@@ -285,5 +297,23 @@
public bool ConfirmBeforeUnmap {
get { return false; }
}
+
+ public void Import ()
+ {
+ Console.WriteLine ("Import called.");
+ foreach (TrackInfo track in TrackModel.SelectedItems) {
+ Console.WriteLine ("Selected: {0}", track);
+ }
+
+ Console.WriteLine ("Selection count: {0}", TrackModel.Selection.Count);
+ }
+
+ public bool CanImport {
+ get { return false; }
+ }
+
+ public string [] IconNames {
+ get { return null; }
+ }
}
}
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 Tue Apr 1 11:24:57 2008
@@ -21,7 +21,7 @@
using System.Net;
using System.Net.Sockets;
using System.Text;
-using System.Collections;
+using System.Collections.Generic;
using Mono.Zeroconf;
@@ -81,7 +81,7 @@
public class ServiceLocator {
private ServiceBrowser browser;
- private Hashtable services = new Hashtable ();
+ private Dictionary <string, Service> services = new Dictionary <string, Service> ();
private bool showLocals = false;
public event ServiceHandler Found;
@@ -92,8 +92,12 @@
set { showLocals = value; }
}
- public IEnumerable Services {
- get { return services; }
+ public Service [] Services {
+ get {
+ Service [] ret = new Service [services.Count];
+ services.Values.CopyTo (ret, 0);
+ return ret;
+ }
}
public void Start () {
@@ -115,16 +119,15 @@
private void OnServiceAdded (object o, ServiceBrowseEventArgs args) {
args.Service.Resolved += OnServiceResolved;
+ Console.WriteLine ("Got {0}, trying to resolve...", args.Service.Name);
args.Service.Resolve ();
}
private void OnServiceResolved (object o, ServiceResolvedEventArgs args) {
string name = args.Service.Name;
- if (services[name] != null) {
- return; // we already have it somehow
- }
-
+ Console.WriteLine ("Managed to resolve {0}.", args.Service.Name);
+
bool pwRequired = false;
// iTunes tacks this on to indicate a passsword protected share. Ugh.
@@ -144,28 +147,36 @@
}
IPAddress address = args.Service.HostEntry.AddressList[0];
- if (address.AddressFamily == AddressFamily.InterNetworkV6) {
+
+ if (services.ContainsKey (name) && address.AddressFamily == AddressFamily.InterNetworkV6) {
// XXX: Workaround a Mono bug where we can't resolve IPv6 addresses properly
- //address = Dns.GetHostEntry (args.Service.HostEntry.HostName).AddressList[0];
+ // Only skip this service if it resolves to a IPv6 address, and we already have info
+ // for this service already.
return;
}
DAAP.Service svc = new DAAP.Service (address, (ushort)service.Port,
name, pwRequired);
- services[svc.Name] = svc;
+ if (services.ContainsKey (name)) {
+ services[name] = svc;
+ } else {
+ services.Add (name, svc);
+ }
if (Found != null)
Found (this, new ServiceArgs (svc));
}
private void OnServiceRemoved (object o, ServiceBrowseEventArgs args) {
- Service svc = (Service) services[args.Service.Name];
- if (svc != null) {
- services.Remove (svc.Name);
+ if (services.ContainsKey (args.Service.Name)) {
+ Service svc = (Service) services[args.Service.Name];
+ if (svc != null) {
+ services.Remove (svc.Name);
- if (Removed != null)
- Removed (this, new ServiceArgs (svc));
+ if (Removed != null)
+ Removed (this, new ServiceArgs (svc));
+ }
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]