banshee r3677 - in trunk/banshee: . src/Extensions/Banshee.Daap src/Extensions/Banshee.Daap/Banshee.Daap src/Extensions/Banshee.Daap/Daap
- From: ahixon svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r3677 - in trunk/banshee: . src/Extensions/Banshee.Daap src/Extensions/Banshee.Daap/Banshee.Daap src/Extensions/Banshee.Daap/Daap
- Date: Sat, 5 Apr 2008 01:19:02 +0100 (BST)
Author: ahixon
Date: Sat Apr 5 01:19:01 2008
New Revision: 3677
URL: http://svn.gnome.org/viewvc/banshee?rev=3677&view=rev
Log:
2008-04-05 Alexander Hixon <hixon alexander mediati org>
* src/Extensions/Banshee.Daap/Daap/ServiceLocator.cs: Try to resolve all
possible addresses for the first resolved hostname if it gives us an IPv6
address.
* src/Extensions/Banshee.Daap/Banshee.Daap/DaapPlaylistSource.cs: Child
playlist source for DAAP sources. Uses DaapTrackInfo from parent source to
populate trackmodel.
* src/Extensions/Banshee.Daap/Banshee.Daap/DaapSource.cs: Create playlist
sources if the DAAP share provides any. Also hookup different icons for
protected/unprotected shares. Now also handles the remote removing tracks
from the share and updating our local view to reflect changes.
Added:
trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapPlaylistSource.cs
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap.mdp
trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapSource.cs
trunk/banshee/src/Extensions/Banshee.Daap/Daap/ServiceLocator.cs
trunk/banshee/src/Extensions/Banshee.Daap/Makefile.am
Modified: trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap.mdp
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap.mdp (original)
+++ trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap.mdp Sat Apr 5 01:19:01 2008
@@ -1,4 +1,4 @@
-<Project name="Banshee.Daap" fileversion="2.0" UseParentDirectoryAsNamespace="True" language="C#" clr-version="Net_2_0" ctype="DotNetProject">
+<Project name="Banshee.Daap" fileversion="2.0" language="C#" clr-version="Net_2_0" UseParentDirectoryAsNamespace="True" ctype="DotNetProject">
<Configurations active="Debug">
<Configuration name="Debug" ctype="DotNetProjectConfiguration">
<Output directory="../../../bin" assemblyKeyFile="." assembly="Banshee.Daap" />
@@ -32,6 +32,7 @@
<File name="Daap/content-codes" subtype="Code" buildaction="EmbedAsResource" />
<File name="Resources/Banshee.Daap.addin.xml" subtype="Code" buildaction="EmbedAsResource" />
<File name="Banshee.Daap/DaapLoginDialog.cs" subtype="Code" buildaction="Compile" />
+ <File name="Banshee.Daap/DaapPlaylistSource.cs" subtype="Code" buildaction="Compile" />
</Contents>
<References>
<ProjectReference type="Project" localcopy="True" refto="Banshee.Core" />
Added: trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapPlaylistSource.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapPlaylistSource.cs Sat Apr 5 01:19:01 2008
@@ -0,0 +1,111 @@
+//
+// DaapPlaylistSource.cs
+//
+// Author:
+// Alexander Hixon <hixon alexander mediati org>
+//
+// Copyright (C) 2008 Alexander Hixon
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using Mono.Unix;
+
+using Banshee.Collection;
+using Banshee.Collection.Database;
+using Banshee.Playlist;
+using Banshee.Sources;
+
+using DAAP;
+
+namespace Banshee.Daap
+{
+ public class DaapPlaylistSource : Source, ITrackModelSource, IDaapSource
+ {
+ private DaapSource parent;
+ public DAAP.Database Database {
+ get { return parent.Database; }
+ }
+
+ private MemoryTrackListModel track_model;
+
+ public DaapPlaylistSource (DAAP.Playlist playlist, DaapSource parent) : base (Catalog.GetString ("Playlist"), playlist.Name, parent.DbId)
+ {
+ this.parent = parent;
+
+ track_model = new MemoryTrackListModel ();
+ Properties.SetString ("Icon.Name", "source-playlist");
+
+ foreach (Track track in playlist.Tracks) {
+ track_model.Add (parent.TrackMap [track.Id]);
+ }
+ }
+
+ public ArtistListModel ArtistModel {
+ get { return null; }
+ }
+
+ public AlbumListModel AlbumModel {
+ get { return null; }
+ }
+
+ public TrackListModel TrackModel {
+ get { return track_model; }
+ }
+
+ public bool CanRemoveTracks {
+ get { return false; }
+ }
+
+ public bool CanDeleteTracks {
+ get { return false; }
+ }
+
+ public void DeleteSelectedTracks ()
+ {
+ }
+
+ public void RemoveSelectedTracks ()
+ {
+ }
+
+ public void Reload ()
+ {
+ track_model.Reload ();
+ }
+
+ public bool HasDependencies {
+ get { return false; }
+ }
+
+ public bool ConfirmRemoveTracks {
+ get { return false; }
+ }
+
+ public bool ShowBrowser {
+ get { return false; }
+ }
+
+ protected override string TypeUniqueId {
+ get { return "daap-playlist"; }
+ }
+ }
+}
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 Sat Apr 5 01:19:01 2008
@@ -27,6 +27,7 @@
//
using System;
+using System.Collections.Generic;
using Mono.Unix;
using DAAP;
@@ -49,18 +50,35 @@
get { return database; }
}
+ private Dictionary <int, DaapTrackInfo> daap_track_map;
+ public Dictionary <int, DaapTrackInfo> TrackMap {
+ get { return daap_track_map; }
+ }
+
private bool is_activating;
private SourceMessage status_message;
- public DaapSource (Service service) : base (Catalog.GetString ("Music Share"), service.Name, (service.Address.ToString () + service.Port).Replace (":", "").Replace (".", ""), 300)
+ public DaapSource (Service service) : base (Catalog.GetString ("Music Share"), service.Name,
+ (service.Address.ToString () + service.Port).Replace (":", "").Replace (".", ""), 300)
{
this.service = service;
- Properties.SetString ("Icon.Name", "computer");
+ daap_track_map = new Dictionary <int, DaapTrackInfo> ();
Properties.SetString ("UnmapSourceActionLabel", Catalog.GetString ("Disconnect"));
+ UpdateIcon ();
+
AfterInitialized ();
}
+ private void UpdateIcon ()
+ {
+ if (service != null && !service.IsProtected) {
+ Properties.SetStringList ("Icon.Name", "computer", "network-server");
+ } else {
+ Properties.SetStringList ("Icon.Name", "system-lock-screen", "computer", "network-server");
+ }
+ }
+
public override void Activate ()
{
if (client != null || is_activating) {
@@ -97,7 +115,8 @@
string details = String.Format ("Couldn't connect to service {0} on {1}:{2} - {3}",
service.Name,
service.Address,
- service.Port, e.ToString ().Replace ("<", "<").Replace (">", ">"));
+ service.Port, e.ToString ().Replace ("&", "&")
+ .Replace ("<", "<").Replace (">", ">"));
Hyena.Log.Warning ("Failed to connect", details, true);
DestroyStatusMessage ();
}
@@ -126,6 +145,8 @@
RemoveTrackRange ((TrackListDatabaseModel)TrackModel, new Hyena.Collections.RangeCollection.Range (0, Count));
}
+ daap_track_map.Clear ();
+
if (client != null) {
if (logout) {
client.Logout ();
@@ -217,14 +238,15 @@
database.TrackAdded += OnDatabaseTrackAdded;
database.TrackRemoved += OnDatabaseTrackRemoved;
- // TODO
- //AddPlaylistSources ();
-
foreach (Track track in database.Tracks) {
DaapTrackInfo daaptrack = new DaapTrackInfo (track, this);
daaptrack.Save ();
+
+ daap_track_map.Add (track.Id, daaptrack);
}
+ AddPlaylistSources ();
+
Reload ();
ThreadAssist.ProxyToMain(delegate {
@@ -234,18 +256,37 @@
Name = client.Name;
+ UpdateIcon ();
OnUpdated ();
}
+ private void AddPlaylistSources ()
+ {
+ foreach (DAAP.Playlist pl in database.Playlists) {
+ Console.WriteLine ("Has playlist: {0}", pl.Name);
+ DaapPlaylistSource source = new DaapPlaylistSource (pl, this);
+ AddChildSource (source);
+ }
+ }
+
public void OnDatabaseTrackAdded (object o, TrackArgs args)
{
DaapTrackInfo track = new DaapTrackInfo (args.Track, this);
track.Save ();
+
+ daap_track_map.Add (args.Track.Id, track);
+
+ Reload ();
}
public void OnDatabaseTrackRemoved (object o, TrackArgs args)
{
- // FIXME
+ if (daap_track_map.ContainsKey (args.Track.Id)) {
+ DaapTrackInfo track = daap_track_map [args.Track.Id];
+ RemoveTrack (track);
+ }
+
+ Reload ();
}
public override bool CanRemoveTracks {
@@ -309,7 +350,7 @@
}
public bool CanImport {
- get { return false; }
+ get { return true; }
}
public string [] IconNames {
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 Sat Apr 5 01:19:01 2008
@@ -148,11 +148,21 @@
IPAddress address = args.Service.HostEntry.AddressList[0];
+ // XXX: Workaround a Mono bug where we can't resolve IPv6 addresses properly
if (services.ContainsKey (name) && address.AddressFamily == AddressFamily.InterNetworkV6) {
- // XXX: Workaround a Mono bug where we can't resolve IPv6 addresses properly
// Only skip this service if it resolves to a IPv6 address, and we already have info
// for this service already.
return;
+ } else if (!services.ContainsKey (name) && address.AddressFamily == AddressFamily.InterNetworkV6) {
+ // This is the first address we've resolved, however, it's an IPv6 address.
+ // Try and resolve the hostname in hope that it'll end up as an IPv4 address - it doesn't
+ // really matter if it still ends up with an IPv6 address, we're not risking anything.
+
+ foreach (IPAddress addr in Dns.GetHostEntry (args.Service.HostEntry.HostName).AddressList) {
+ if (addr.AddressFamily == AddressFamily.InterNetwork) {
+ address = addr;
+ }
+ }
}
DAAP.Service svc = new DAAP.Service (address, (ushort)service.Port,
Modified: trunk/banshee/src/Extensions/Banshee.Daap/Makefile.am
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Daap/Makefile.am (original)
+++ trunk/banshee/src/Extensions/Banshee.Daap/Makefile.am Sat Apr 5 01:19:01 2008
@@ -6,6 +6,7 @@
SOURCES = \
Banshee.Daap/DaapContainerSource.cs \
Banshee.Daap/DaapLoginDialog.cs \
+ Banshee.Daap/DaapPlaylistSource.cs \
Banshee.Daap/DaapService.cs \
Banshee.Daap/DaapSource.cs \
Banshee.Daap/DaapTrackInfo.cs \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]