banshee r3781 - in trunk/banshee: . build src/Core/Banshee.Services/Banshee.Playlist src/Core/Banshee.Services/Banshee.Sources 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 r3781 - in trunk/banshee: . build src/Core/Banshee.Services/Banshee.Playlist src/Core/Banshee.Services/Banshee.Sources src/Extensions/Banshee.Daap src/Extensions/Banshee.Daap/Banshee.Daap src/Extensions/Banshee.Daap/Daap
- Date: Wed, 16 Apr 2008 12:19:12 +0100 (BST)
Author: ahixon
Date: Wed Apr 16 12:19:11 2008
New Revision: 3781
URL: http://svn.gnome.org/viewvc/banshee?rev=3781&view=rev
Log:
2008-04-16 Alexander Hixon <hixon alexander mediati org>
This commit basically changes the DAAP namespace to Daap, removes the
server bits from daap-sharp, and puts in support for using avahi-sharp
instead of Mono.Zeroconf when compiling the extension (note that the
build stuff hasn't quite been hooked up yet). There's also a few
changes to using generics in daap-sharp, and DaapPlaylistSource uses
the database, rather than keeping stuff in memory.
* src/Extensions/Banshee.Daap/Daap/ContentFetcher.cs:
* src/Extensions/Banshee.Daap/Daap/Client.cs:
* src/Extensions/Banshee.Daap/Daap/User.cs:
* src/Extensions/Banshee.Daap/Daap/ServerInfo.cs:
* src/Extensions/Banshee.Daap/Daap/BrokenMD5.cs:
* src/Extensions/Banshee.Daap/Daap/ContentParser.cs:
* src/Extensions/Banshee.Daap/Daap/LoginException.cs:
* src/Extensions/Banshee.Daap/Daap/AuthenticationException.cs:
* src/Extensions/Banshee.Daap/Daap/Playlist.cs:
* src/Extensions/Banshee.Daap/Daap/Utility.cs:
* src/Extensions/Banshee.Daap/Daap/Track.cs:
* src/Extensions/Banshee.Daap/Daap/ContentWriter.cs
* src/Extensions/Banshee.Daap/Daap/Hasher.cs:
* src/Extensions/Banshee.Daap/Banshee.Daap/DaapLoginDialog.cs:
* src/Extensions/Banshee.Daap/Banshee.Daap/DaapService.cs:
* src/Extensions/Banshee.Daap/Banshee.Daap/DaapTrackInfo.cs:
Simple namespace change from DAAP to Daap.
* src/Extensions/Banshee.Daap/Daap/ContentCodeBag.cs:
* src/Extensions/Banshee.Daap/Daap/Database.cs: Use Generics instead of
regular Collection classes. Also update the namespaces from DAAP to Daap.
* src/Extensions/Banshee.Daap/Daap/ServiceLocator.cs: Provide support for
avahi-sharp as well as Mono.Zeroconf. Also use Hyena logging instead of
spewing via Console.WriteLine.
* src/Extensions/Banshee.Daap/Daap/sync-tree.sh: Remove this since it's
practically useless now.
* src/Extensions/Banshee.Daap/Daap/Server.cs: Remove this since we're
not serving up DAAP shares from Banshee directly anymore.
* src/Extensions/Banshee.Daap/Banshee.Daap/DaapSource.cs:
* src/Extensions/Banshee.Daap/Banshee.Daap/DaapPlaylistSource.cs: Track
the database IDs rather than the entire track information, and use the
new namespace.
* src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs:
* src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs: Add
virtual AddTrack method that should be overriden by implementing classes
before use.
* src/Core/Banshee.Services/Banshee.Playlist/PlaylistSource.cs: New
AddTrack methods for adding existing tracks from the database to a
playlist without reassigning the ParentSource property.
* build/build.environment.mk: Nasty hack to include the avahi-sharp
bindings at compile time. This should really be optional, but my auto*
foo is poor. Good thing we don't enable DAAP by default. :)
Removed:
trunk/banshee/src/Extensions/Banshee.Daap/Daap/Server.cs
trunk/banshee/src/Extensions/Banshee.Daap/Daap/sync-tree.sh
Modified:
trunk/banshee/ChangeLog
trunk/banshee/build/build.environment.mk
trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistSource.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs
trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap.mdp
trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapContainerSource.cs
trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapLoginDialog.cs
trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapPlaylistSource.cs
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/Banshee.Daap/DaapTrackInfo.cs
trunk/banshee/src/Extensions/Banshee.Daap/Daap/AuthenticationException.cs
trunk/banshee/src/Extensions/Banshee.Daap/Daap/BrokenMD5.cs
trunk/banshee/src/Extensions/Banshee.Daap/Daap/Client.cs
trunk/banshee/src/Extensions/Banshee.Daap/Daap/ContentCodeBag.cs
trunk/banshee/src/Extensions/Banshee.Daap/Daap/ContentFetcher.cs
trunk/banshee/src/Extensions/Banshee.Daap/Daap/ContentParser.cs
trunk/banshee/src/Extensions/Banshee.Daap/Daap/ContentWriter.cs
trunk/banshee/src/Extensions/Banshee.Daap/Daap/Database.cs
trunk/banshee/src/Extensions/Banshee.Daap/Daap/Hasher.cs
trunk/banshee/src/Extensions/Banshee.Daap/Daap/LoginException.cs
trunk/banshee/src/Extensions/Banshee.Daap/Daap/Playlist.cs
trunk/banshee/src/Extensions/Banshee.Daap/Daap/ServerInfo.cs
trunk/banshee/src/Extensions/Banshee.Daap/Daap/ServiceLocator.cs
trunk/banshee/src/Extensions/Banshee.Daap/Daap/Track.cs
trunk/banshee/src/Extensions/Banshee.Daap/Daap/User.cs
trunk/banshee/src/Extensions/Banshee.Daap/Daap/Utility.cs
trunk/banshee/src/Extensions/Banshee.Daap/Makefile.am
Modified: trunk/banshee/build/build.environment.mk
==============================================================================
--- trunk/banshee/build/build.environment.mk (original)
+++ trunk/banshee/build/build.environment.mk Wed Apr 16 12:19:11 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)
+REF_EXTENSION_DAAP = $(LINK_BANSHEE_THICKCLIENT_DEPS) $(LINK_ICSHARP_ZIP_LIB) $(LINK_MONO_ZEROCONF) -pkg:avahi-sharp
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/Core/Banshee.Services/Banshee.Playlist/PlaylistSource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistSource.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Playlist/PlaylistSource.cs Wed Apr 16 12:19:11 2008
@@ -51,6 +51,7 @@
public class PlaylistSource : AbstractPlaylistSource, IUnmapableSource
{
private static HyenaSqliteCommand add_track_range_command;
+ private static HyenaSqliteCommand add_track_command;
private static HyenaSqliteCommand remove_track_range_command;
private static string add_track_range_from_joined_model_sql;
@@ -78,6 +79,11 @@
LIMIT ?, ?"
);
+ add_track_command = new HyenaSqliteCommand (@"
+ INSERT INTO CorePlaylistEntries
+ VALUES (null, ?, ?, 0)"
+ );
+
add_track_range_from_joined_model_sql = @"
INSERT INTO CorePlaylistEntries
SELECT null, ?, TrackID, 0
@@ -108,7 +114,6 @@
Properties.SetString ("Icon.Name", "source-playlist");
Properties.SetString ("RemoveTracksActionLabel", Catalog.GetString ("Remove From Playlist"));
Properties.SetString ("UnmapSourceActionLabel", Catalog.GetString ("Delete Playlist"));
- DbId = dbid;
}
#endregion
@@ -209,12 +214,18 @@
#endregion
- /*public override void AddTrack (DatabaseTrackInfo track)
+ protected void AddTrack (int track)
{
- add_track_command.ApplyValues (DbId, track.DbId);
+ add_track_command.ApplyValues (DbId, track);
ServiceManager.DbConnection.Execute (add_track_command);
- Reload ();
- }*/
+ this.OnTracksAdded ();
+ //Reload ();
+ }
+
+ protected override void AddTrack (DatabaseTrackInfo track)
+ {
+ AddTrack (track.TrackId);
+ }
public override bool AddSelectedTracks (Source source)
{
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs Wed Apr 16 12:19:11 2008
@@ -175,7 +175,7 @@
public virtual bool HasDependencies {
get { return false; }
}
-
+
public void RemoveTrack (int index)
{
if (index != -1) {
@@ -378,6 +378,11 @@
{
throw new NotImplementedException();
}
+
+ protected virtual void AddTrack (DatabaseTrackInfo track)
+ {
+ throw new NotImplementedException();
+ }
protected virtual void RateTrackRange (DatabaseTrackListModel model, RangeCollection.Range range, int rating)
{
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs Wed Apr 16 12:19:11 2008
@@ -411,11 +411,6 @@
}
}
- protected virtual void AddTrack (DatabaseTrackInfo track)
- {
- throw new Exception ("PrimarySource DeleteTrack method not implemented");
- }
-
protected override void PruneArtistsAlbums ()
{
ServiceManager.DbConnection.Execute (prune_artists_albums_command);
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 Wed Apr 16 12:19:11 2008
@@ -23,7 +23,6 @@
<File name="Daap/Hasher.cs" subtype="Code" buildaction="Compile" />
<File name="Daap/LoginException.cs" subtype="Code" buildaction="Compile" />
<File name="Daap/Playlist.cs" subtype="Code" buildaction="Compile" />
- <File name="Daap/Server.cs" subtype="Code" buildaction="Compile" />
<File name="Daap/ServerInfo.cs" subtype="Code" buildaction="Compile" />
<File name="Daap/ServiceLocator.cs" subtype="Code" buildaction="Compile" />
<File name="Daap/Track.cs" subtype="Code" buildaction="Compile" />
@@ -50,4 +49,4 @@
<AsmRefVar />
<ProjectRefVar />
</MonoDevelop.Autotools.MakefileInfo>
-</Project>
\ No newline at end of file
+</Project>
Modified: trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapContainerSource.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapContainerSource.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapContainerSource.cs Wed Apr 16 12:19:11 2008
@@ -40,7 +40,7 @@
{
public DaapContainerSource () : base (Catalog.GetString ("Shared Music"), Catalog.GetString ("Shared Music"), 300)
{
- Properties.SetString ("Icon.Name", "applications-internet");
+ Properties.SetStringList ("Icon.Name", "applications-internet", "network-server");
}
public override bool? AutoExpand {
Modified: trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapLoginDialog.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapLoginDialog.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapLoginDialog.cs Wed Apr 16 12:19:11 2008
@@ -28,7 +28,7 @@
using System;
using Mono.Unix;
-using DAAP;
+using Daap;
using Gtk;
using Banshee.Base;
Modified: trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapPlaylistSource.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapPlaylistSource.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapPlaylistSource.cs Wed Apr 16 12:19:11 2008
@@ -29,84 +29,42 @@
using System;
using Mono.Unix;
+using Hyena;
+
using Banshee.Collection;
using Banshee.Collection.Database;
using Banshee.Playlist;
using Banshee.Sources;
-using DAAP;
+using DAAP = Daap;
namespace Banshee.Daap
{
- public class DaapPlaylistSource : Source, ITrackModelSource
+ public class DaapPlaylistSource : PlaylistSource
{
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)
+ public DaapPlaylistSource (DAAP.Playlist playlist, int id, DaapSource parent) : base (playlist.Name, parent.DbId)
{
this.parent = parent;
+ this.Save ();
- track_model = new MemoryTrackListModel ();
- Properties.SetString ("Icon.Name", "source-playlist");
-
- foreach (Track track in playlist.Tracks) {
- if (parent.TrackMap.ContainsKey (track.Id)) {
- track_model.Add (parent.TrackMap [track.Id]);
+ foreach (DAAP.Track track in playlist.Tracks) {
+ if (track != null && parent.TrackMap.ContainsKey (track.Id)) {
+ Console.WriteLine ("Adding track {0} to {1}", parent.TrackMap [track.Id], DbId);
+ AddTrack (parent.TrackMap [track.Id]);
+ } else {
+ Log.Warning ("Can't find track: was either null or not in map.", false);
}
}
+
+ this.Reload ();
}
- public ArtistListModel ArtistModel {
- get { return null; }
- }
-
- public AlbumListModel AlbumModel {
- get { return null; }
- }
-
- public TrackListModel TrackModel {
- get { return track_model; }
- }
-
- public bool CanAddTracks {
- get { return false; }
- }
-
- 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 {
+ public override bool ShowBrowser {
get { return false; }
}
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 Wed Apr 16 12:19:11 2008
@@ -29,7 +29,7 @@
using System;
using System.Collections.Generic;
using Mono.Unix;
-using DAAP;
+using Daap;
using Banshee.Base;
using Banshee.Collection;
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 Wed Apr 16 12:19:11 2008
@@ -29,7 +29,8 @@
using System;
using System.Collections.Generic;
using Mono.Unix;
-using DAAP;
+
+using Hyena;
using Banshee.Base;
using Banshee.Collection;
@@ -38,11 +39,13 @@
using Banshee.Sources;
using Banshee.ServiceStack;
+using DAAP = Daap;
+
namespace Banshee.Daap
{
public class DaapSource : PrimarySource, IDurationAggregator, IUnmapableSource, IImportSource
{
- private Service service;
+ private DAAP.Service service;
private DAAP.Client client;
private DAAP.Database database;
@@ -50,24 +53,26 @@
get { return database; }
}
- private Dictionary <int, DaapTrackInfo> daap_track_map;
- public Dictionary <int, DaapTrackInfo> TrackMap {
+ private Dictionary <int, int> daap_track_map;
+ public Dictionary <int, int> TrackMap {
get { return daap_track_map; }
}
private bool is_activating;
+ private int playlistid;
- public DaapSource (Service service) : base (Catalog.GetString ("Music Share"), service.Name,
+ public DaapSource (DAAP.Service service) : base (Catalog.GetString ("Music Share"), service.Name,
(service.Address.ToString () + service.Port).Replace (":", "").Replace (".", ""), 300)
{
this.service = service;
- daap_track_map = new Dictionary <int, DaapTrackInfo> ();
+ daap_track_map = new Dictionary <int, int> ();
Properties.SetString ("UnmapSourceActionLabel", Catalog.GetString ("Disconnect"));
Properties.SetString ("UnmapSourceActionIconName", "gtk-disconnect");
UpdateIcon ();
AfterInitialized ();
+ playlistid = this.DbId;
}
private void UpdateIcon ()
@@ -93,11 +98,11 @@
Console.WriteLine ("Connecting to {0}:{1}", service.Address, service.Port);
ThreadAssist.Spawn (delegate {
- try {
+ try {
client = new DAAP.Client (service);
client.Updated += OnClientUpdated;
- if (client.AuthenticationMethod == AuthenticationMethod.None) {
+ if (client.AuthenticationMethod == DAAP.AuthenticationMethod.None) {
client.Login ();
} else {
ThreadAssist.ProxyToMain (PromptLogin);
@@ -117,7 +122,7 @@
service.Address,
service.Port, e.ToString ().Replace ("&", "&")
.Replace ("<", "<").Replace (">", ">"));
- Hyena.Log.Warning ("Failed to connect", details, true);
+ Log.Warning ("Failed to connect", details, true);
HideStatus ();
}
@@ -177,7 +182,7 @@
SetStatus (String.Format (Catalog.GetString ("Logging in to {0}"), Name), false);
DaapLoginDialog dialog = new DaapLoginDialog (client.Name,
- client.AuthenticationMethod == AuthenticationMethod.UserAndPassword);
+ client.AuthenticationMethod == DAAP.AuthenticationMethod.UserAndPassword);
if (dialog.Run () == (int) Gtk.ResponseType.Ok) {
AuthenticatedLogin (dialog.Username, dialog.Password);
} else {
@@ -192,7 +197,7 @@
ThreadAssist.Spawn (delegate {
try {
client.Login (username, password);
- } catch (AuthenticationException) {
+ } catch (DAAP.AuthenticationException) {
ThreadAssist.ProxyToMain (PromptLogin);
}
});
@@ -205,11 +210,12 @@
database.TrackAdded += OnDatabaseTrackAdded;
database.TrackRemoved += OnDatabaseTrackRemoved;
- foreach (Track track in database.Tracks) {
+ foreach (DAAP.Track track in database.Tracks) {
DaapTrackInfo daaptrack = new DaapTrackInfo (track, this);
daaptrack.Save ();
+ Log.Debug ("Track ID", daaptrack.TrackId.ToString ());
- daap_track_map.Add (track.Id, daaptrack);
+ daap_track_map.Add (track.Id, daaptrack.TrackId);
}
AddPlaylistSources ();
@@ -230,27 +236,29 @@
private void AddPlaylistSources ()
{
foreach (DAAP.Playlist pl in database.Playlists) {
- Console.WriteLine ("Has playlist: {0}", pl.Name);
- DaapPlaylistSource source = new DaapPlaylistSource (pl, this);
+ DaapPlaylistSource source = new DaapPlaylistSource (pl, playlistid, this);
AddChildSource (source);
+ playlistid ++;
}
}
- public void OnDatabaseTrackAdded (object o, TrackArgs args)
+ public void OnDatabaseTrackAdded (object o, DAAP.TrackArgs args)
{
DaapTrackInfo track = new DaapTrackInfo (args.Track, this);
track.Save ();
if (!daap_track_map.ContainsKey (args.Track.Id)) {
- daap_track_map.Add (args.Track.Id, track);
+ daap_track_map.Add (args.Track.Id, track.TrackId);
}
}
- public void OnDatabaseTrackRemoved (object o, TrackArgs args)
+ public void OnDatabaseTrackRemoved (object o, DAAP.TrackArgs args)
{
if (daap_track_map.ContainsKey (args.Track.Id)) {
- DaapTrackInfo track = daap_track_map [args.Track.Id];
- RemoveTrack (track);
+ //DaapTrackInfo track = daap_track_map [args.Track.Id];
+ //RemoveTrack (track);
+ //RemoveTrack (
+ // TODO
}
}
@@ -289,12 +297,12 @@
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);
+ Log.Debug ("Starting import...");
+ DateTime start = DateTime.Now;
+ ServiceManager.SourceManager.MusicLibrary.AddAllTracks (this);
+ DateTime finish = DateTime.Now;
+ TimeSpan time = finish - start;
+ Log.DebugFormat ("Import completed. Took {0} seconds.", time.TotalSeconds);
}
public bool CanImport {
Modified: trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapTrackInfo.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapTrackInfo.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Daap/Banshee.Daap/DaapTrackInfo.cs Wed Apr 16 12:19:11 2008
@@ -32,7 +32,7 @@
using Banshee.Base;
using Banshee.Collection;
using Banshee.Collection.Database;
-using DAAP;
+using Daap;
namespace Banshee.Daap
{
Modified: trunk/banshee/src/Extensions/Banshee.Daap/Daap/AuthenticationException.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Daap/Daap/AuthenticationException.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Daap/Daap/AuthenticationException.cs Wed Apr 16 12:19:11 2008
@@ -1,7 +1,7 @@
using System;
-namespace DAAP {
+namespace Daap {
public class AuthenticationException : ApplicationException {
Modified: trunk/banshee/src/Extensions/Banshee.Daap/Daap/BrokenMD5.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Daap/Daap/BrokenMD5.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Daap/Daap/BrokenMD5.cs Wed Apr 16 12:19:11 2008
@@ -51,7 +51,7 @@
using System.Runtime.InteropServices;
using System.Security.Cryptography;
-namespace DAAP {
+namespace Daap {
internal class BrokenMD5 : MD5 {
private const int BLOCK_SIZE_BYTES = 64;
Modified: trunk/banshee/src/Extensions/Banshee.Daap/Daap/Client.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Daap/Daap/Client.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Daap/Daap/Client.cs Wed Apr 16 12:19:11 2008
@@ -28,7 +28,7 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
-namespace DAAP {
+namespace Daap {
public class Client : IDisposable {
private const int UpdateSleepInterval = 2 * 60 * 1000; // 2 minutes
Modified: trunk/banshee/src/Extensions/Banshee.Daap/Daap/ContentCodeBag.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Daap/Daap/ContentCodeBag.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Daap/Daap/ContentCodeBag.cs Wed Apr 16 12:19:11 2008
@@ -20,11 +20,11 @@
using System;
using System.Reflection;
using System.IO;
-using System.Collections;
+using System.Collections.Generic;
using System.Text;
using System.Net;
-namespace DAAP {
+namespace Daap {
internal enum ContentType : short {
Char = 1,
@@ -51,7 +51,7 @@
private const int ChunkLength = 8192;
private static ContentCodeBag defaultBag;
- private Hashtable codes = new Hashtable ();
+ private Dictionary <int, ContentCode> codes = new Dictionary <int, ContentCode> ();
public static ContentCodeBag Default {
get {
@@ -115,12 +115,12 @@
}
internal ContentNode ToNode () {
- ArrayList nodes = new ArrayList ();
+ List <ContentNode> nodes = new List <ContentNode> ();
foreach (int number in codes.Keys) {
ContentCode code = (ContentCode) codes[number];
- ArrayList contents = new ArrayList ();
+ List <ContentNode> contents = new List <ContentNode> ();
contents.Add (new ContentNode ("dmap.contentcodesnumber", code.Number));
contents.Add (new ContentNode ("dmap.contentcodesname", code.Name));
contents.Add (new ContentNode ("dmap.contentcodestype", code.Type));
Modified: trunk/banshee/src/Extensions/Banshee.Daap/Daap/ContentFetcher.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Daap/Daap/ContentFetcher.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Daap/Daap/ContentFetcher.cs Wed Apr 16 12:19:11 2008
@@ -18,7 +18,6 @@
*/
using System;
-using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Web;
@@ -27,7 +26,7 @@
using System.Runtime.InteropServices;
using ICSharpCode.SharpZipLib.GZip;
-namespace DAAP {
+namespace Daap {
internal class ContentFetcher : IDisposable {
private IPAddress address;
Modified: trunk/banshee/src/Extensions/Banshee.Daap/Daap/ContentParser.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Daap/Daap/ContentParser.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Daap/Daap/ContentParser.cs Wed Apr 16 12:19:11 2008
@@ -22,7 +22,7 @@
using System.Net;
using System.Collections;
-namespace DAAP {
+namespace Daap {
public class ContentException : ApplicationException {
@@ -118,10 +118,11 @@
}
int length = IPAddress.NetworkToHostOrder (BitConverter.ToInt32 (buffer, offset + 4));
-
+
if (code.Equals (ContentCode.Zero)) {
- throw new ContentException (String.Format ("Failed to find content code for '{0}'. Data length is {1}",
- ContentCodeBag.GetStringFormat (num), length));
+ string s = System.Text.ASCIIEncoding.ASCII.GetString (buffer);
+ throw new ContentException (String.Format ("Failed to find content code for '{0}'. Data length is {1}; content is {2}",
+ ContentCodeBag.GetStringFormat (num), length, s));
}
node.Name = code.Name;
Modified: trunk/banshee/src/Extensions/Banshee.Daap/Daap/ContentWriter.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Daap/Daap/ContentWriter.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Daap/Daap/ContentWriter.cs Wed Apr 16 12:19:11 2008
@@ -21,7 +21,7 @@
using System.Net;
using System.IO;
-namespace DAAP {
+namespace Daap {
internal class ContentWriter {
Modified: trunk/banshee/src/Extensions/Banshee.Daap/Daap/Database.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Daap/Daap/Database.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Daap/Daap/Database.cs Wed Apr 16 12:19:11 2008
@@ -20,12 +20,11 @@
using System;
using System.Net;
using System.IO;
-using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Threading;
-namespace DAAP {
+namespace Daap {
public delegate void TrackHandler (object o, TrackArgs args);
@@ -182,22 +181,22 @@
internal ContentNode ToTracksNode (string[] fields, int[] deletedIds) {
- ArrayList trackNodes = new ArrayList ();
+ List <ContentNode> trackNodes = new List <ContentNode> ();
foreach (Track track in tracks) {
trackNodes.Add (track.ToNode (fields));
}
- ArrayList deletedNodes = null;
+ List <ContentNode> deletedNodes = null;
if (deletedIds.Length > 0) {
- deletedNodes = new ArrayList ();
+ deletedNodes = new List <ContentNode> ();
foreach (int id in deletedIds) {
deletedNodes.Add (new ContentNode ("dmap.itemid", id));
}
}
- ArrayList children = new ArrayList ();
+ List <ContentNode> children = new List <ContentNode> ();
children.Add (new ContentNode ("dmap.status", 200));
children.Add (new ContentNode ("dmap.updatetype", deletedNodes == null ? (byte) 0 : (byte) 1));
children.Add (new ContentNode ("dmap.specifiedtotalcount", tracks.Count));
@@ -212,7 +211,7 @@
}
internal ContentNode ToPlaylistsNode () {
- ArrayList nodes = new ArrayList ();
+ List <ContentNode> nodes = new List <ContentNode> ();
nodes.Add (basePlaylist.ToNode (true));
@@ -276,7 +275,7 @@
return;
// handle playlist additions/changes
- ArrayList plids = new ArrayList ();
+ List <int> plids = new List <int> ();
foreach (ContentNode playlistNode in (ContentNode[]) playlistsNode.GetChild ("dmap.listing").Value) {
Playlist pl = Playlist.FromNode (playlistNode);
Modified: trunk/banshee/src/Extensions/Banshee.Daap/Daap/Hasher.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Daap/Daap/Hasher.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Daap/Daap/Hasher.cs Wed Apr 16 12:19:11 2008
@@ -43,7 +43,7 @@
using System;
using System.Text;
-namespace DAAP {
+namespace Daap {
internal class Hasher
{
Modified: trunk/banshee/src/Extensions/Banshee.Daap/Daap/LoginException.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Daap/Daap/LoginException.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Daap/Daap/LoginException.cs Wed Apr 16 12:19:11 2008
@@ -1,7 +1,7 @@
using System;
-namespace DAAP {
+namespace Daap {
public class LoginException : ApplicationException {
Modified: trunk/banshee/src/Extensions/Banshee.Daap/Daap/Playlist.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Daap/Daap/Playlist.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Daap/Daap/Playlist.cs Wed Apr 16 12:19:11 2008
@@ -22,7 +22,7 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
-namespace DAAP {
+namespace Daap {
public delegate void PlaylistTrackHandler (object o, int index, Track track);
Modified: trunk/banshee/src/Extensions/Banshee.Daap/Daap/ServerInfo.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Daap/Daap/ServerInfo.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Daap/Daap/ServerInfo.cs Wed Apr 16 12:19:11 2008
@@ -21,7 +21,7 @@
using System.Text;
using System.Net;
-namespace DAAP {
+namespace Daap {
public enum AuthenticationMethod : byte {
None,
@@ -81,7 +81,7 @@
new ContentNode ("dmap.itemname", name),
new ContentNode ("dmap.loginrequired", (byte) 1),
new ContentNode ("dmap.authenticationmethod", (byte) authMethod),
- new ContentNode ("dmap.timeoutinterval", (int) Server.DefaultTimeout.TotalSeconds),
+ /*new ContentNode ("dmap.timeoutinterval", (int) Server.DefaultTimeout.TotalSeconds),*/
new ContentNode ("dmap.supportsautologout", (byte) 1),
new ContentNode ("dmap.supportsupdate", (byte) 1),
new ContentNode ("dmap.supportspersistentids", (byte) 1),
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 12:19:11 2008
@@ -17,15 +17,23 @@
* 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;
using System.Text;
using System.Collections.Generic;
+using Hyena;
+
+#if USE_AVAHI_SHARP
+using Avahi;
+#else
using Mono.Zeroconf;
+#endif
-namespace DAAP {
+namespace Daap {
public delegate void ServiceHandler (object o, ServiceArgs args);
@@ -77,7 +85,146 @@
}
}
-
+#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;
@@ -100,6 +247,11 @@
}
}
+ public ServiceLocator ()
+ {
+ Log.Debug ("ServiceLocator backend", "using Mono.Zeroconf.");
+ }
+
public void Start () {
if (browser != null) {
Stop ();
@@ -119,14 +271,14 @@
private void OnServiceAdded (object o, ServiceBrowseEventArgs args) {
args.Service.Resolved += OnServiceResolved;
- Console.WriteLine ("Got {0}, trying to resolve...", args.Service.Name);
+ Log.DebugFormat ("Got {0}, trying to resolve...", args.Service.Name);
args.Service.Resolve ();
}
private void OnServiceResolved (object o, ServiceResolvedEventArgs args) {
string name = args.Service.Name;
- Console.WriteLine ("Managed to resolve {0}.", args.Service.Name);
+ Log.DebugFormat ("Managed to resolve {0}.", args.Service.Name);
bool pwRequired = false;
@@ -148,10 +300,13 @@
IPAddress address = args.Service.HostEntry.AddressList[0];
+ 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;
} else if (!services.ContainsKey (name) && address.AddressFamily == AddressFamily.InterNetworkV6) {
// This is the first address we've resolved, however, it's an IPv6 address.
@@ -165,7 +320,9 @@
}
}
- DAAP.Service svc = new DAAP.Service (address, (ushort)service.Port,
+ Log.DebugFormat ("Using address {0}", address);
+
+ Daap.Service svc = new Daap.Service (address, (ushort)service.Port,
name, pwRequired);
if (services.ContainsKey (name)) {
@@ -190,4 +347,5 @@
}
}
}
+#endif
}
Modified: trunk/banshee/src/Extensions/Banshee.Daap/Daap/Track.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Daap/Daap/Track.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Daap/Daap/Track.cs Wed Apr 16 12:19:11 2008
@@ -20,7 +20,7 @@
using System;
using System.Collections;
-namespace DAAP {
+namespace Daap {
public class Track : ICloneable {
Modified: trunk/banshee/src/Extensions/Banshee.Daap/Daap/User.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Daap/Daap/User.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Daap/Daap/User.cs Wed Apr 16 12:19:11 2008
@@ -1,7 +1,7 @@
using System;
using System.Net;
-namespace DAAP {
+namespace Daap {
public delegate void UserHandler (object o, UserArgs args);
Modified: trunk/banshee/src/Extensions/Banshee.Daap/Daap/Utility.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Daap/Daap/Utility.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Daap/Daap/Utility.cs Wed Apr 16 12:19:11 2008
@@ -1,7 +1,7 @@
using System;
-namespace DAAP {
+namespace Daap {
internal class Utility {
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 Wed Apr 16 12:19:11 2008
@@ -21,7 +21,6 @@
Daap/Hasher.cs \
Daap/LoginException.cs \
Daap/Playlist.cs \
- Daap/Server.cs \
Daap/ServerInfo.cs \
Daap/ServiceLocator.cs \
Daap/Track.cs \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]