f-spot r4183 - in trunk/dpap-sharp: launcher lib



Author: apart
Date: Tue Jul 15 11:56:32 2008
New Revision: 4183
URL: http://svn.gnome.org/viewvc/f-spot?rev=4183&view=rev

Log:
Client & initial server work


Added:
   trunk/dpap-sharp/lib/Album.cs
   trunk/dpap-sharp/lib/Photo.cs
Modified:
   trunk/dpap-sharp/launcher/Main.cs
   trunk/dpap-sharp/lib/Client.cs
   trunk/dpap-sharp/lib/ContentCodeBag.cs
   trunk/dpap-sharp/lib/ContentParser.cs
   trunk/dpap-sharp/lib/Database.cs
   trunk/dpap-sharp/lib/Playlist.cs
   trunk/dpap-sharp/lib/Server.cs
   trunk/dpap-sharp/lib/ServerInfo.cs
   trunk/dpap-sharp/lib/Track.cs
   trunk/dpap-sharp/lib/content-codes

Modified: trunk/dpap-sharp/launcher/Main.cs
==============================================================================
--- trunk/dpap-sharp/launcher/Main.cs	(original)
+++ trunk/dpap-sharp/launcher/Main.cs	Tue Jul 15 11:56:32 2008
@@ -21,11 +21,35 @@
 		
 		public static void Main(string[] args)
 		{
+			Console.WriteLine("Starting DPAP server");
+			DPAP.Database database = new DPAP.Database("DPAP");
+			DPAP.Server server = new Server("DPAP");
+			server.AuthenticationMethod = AuthenticationMethod.None;
+			int collision_count = 0;
+			server.Collision += delegate {
+				server.Name = "DPAP" + " [" + ++collision_count + "]";
+			};
+            
+			server.AddDatabase(database);
+			//server.GetServerInfoNode();			
+			try {
+                server.Start();
+            } catch (System.Net.Sockets.SocketException) {
+                server.Port = 0;
+                server.Start();
+            }
+        
+             //DaapPlugin.ServerEnabledSchema.Set(true);
+            
+          //  if(!initial_db_committed) {
+                server.Commit();
+          //      initial_db_committed = true;
+          //  }
 			
 			ServiceDiscovery sd = new ServiceDiscovery();
 			sd.Found += OnServiceFound;			
 			sd.Start();
-
+			
 			
 //			sd.Services[0];
 			Console.ReadLine();
@@ -39,19 +63,20 @@
 
 			System.Console.WriteLine("Connecting to {0} at {1}:{2}", service.Name, service.Address, service.Port);
 		    client = new Client( service );
+	return;		
 			foreach (Database d in client.Databases){
 
 				Console.WriteLine("Database " + d.Name);
 				
-				foreach (Playlist pl in d.Playlists)
-					Console.WriteLine("\tAlbum: "+pl.Name + ", id=" + pl.getId() + " number of items:" + pl.Tracks.Count);
+				foreach (Album alb in d.Albums)
+					Console.WriteLine("\tAlbum: "+alb.Name + ", id=" + alb.getId() + " number of items:" + alb.Photos.Count);
 				
-				foreach (Track tr in d.Tracks)
+				foreach (Photo ph in d.Photos)
 				{
-					if(tr != null)
+					if(ph != null)
 					{
-						Console.WriteLine("\t\tFile: " + tr.FileName + " format = " + tr.Format + "size=" + tr.Width +"x" +tr.Height + " ID=" + tr.Id);
-						d.DownloadTrack(tr,"./"+tr.FileName);
+						Console.WriteLine("\t\tFile: " + ph.FileName + " format = " + ph.Format + "size=" + ph.Width +"x" +ph.Height + " ID=" + ph.Id);
+						d.DownloadPhoto(ph,"./"+ph.FileName);
 					}
 				}
 				

Added: trunk/dpap-sharp/lib/Album.cs
==============================================================================
--- (empty file)
+++ trunk/dpap-sharp/lib/Album.cs	Tue Jul 15 11:56:32 2008
@@ -0,0 +1,204 @@
+// Album.cs created with MonoDevelop
+// User: andrzej at 11:41Â2008-07-15
+//
+// To change standard headers go to Edit->Preferences->Coding->Standard Headers
+//
+
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+
+namespace DPAP
+{
+	public delegate void AlbumPhotoHandler (object o, int index, Photo track);
+	
+	public class Album
+	{
+		private static int nextid = 1;
+        
+        private int id;
+        private string name = String.Empty;
+        private List<Photo> photos = new List<Photo> ();
+        private List<int> containerIds = new List<int> ();
+		
+        public event AlbumPhotoHandler PhotoAdded;
+        public event AlbumPhotoHandler PhotoRemoved;
+        public event EventHandler NameChanged;
+
+        public Photo this[int index] {
+            get {
+                if (photos.Count > index)
+                    return photos[index];
+                else
+                    return null;
+            }
+            set { photos[index] = value; }
+        }
+        
+        public IList<Photo> Photos {
+            get { return new ReadOnlyCollection<Photo> (photos); }
+        }
+
+        internal int Id {
+            get { return id; }
+            set { id = value; }
+        }
+
+        public string Name {
+            get { return name; }
+            set {
+                name = value;
+                if (NameChanged != null)
+                    NameChanged (this, new EventArgs ());
+            }
+        }
+
+        internal Album () {
+            id = nextid++;
+        }
+		
+        public Album (string name) : this () {
+            this.name = name;
+        }
+
+        public void InsertPhoto (int index, Photo photo) {
+            InsertPhoto (index, photo, photos.Count + 1);
+        }
+
+        internal void InsertPhoto (int index, Photo photo, int id) {
+            photos.Insert (index, photo);
+            containerIds.Insert (index, id);
+
+            if (PhotoAdded != null)
+                PhotoAdded (this, index, photo);
+        }
+
+        public void Clear () {
+            photos.Clear ();
+        }
+
+        public void AddPhoto (Photo photo) {
+            AddPhoto (photo, photos.Count + 1);
+        }
+        
+        internal void AddPhoto (Photo photo, int id) {
+            photos.Add (photo);
+            containerIds.Add (id);
+
+            if (PhotoAdded != null)
+                PhotoAdded (this, photos.Count - 1, photo);
+        }
+
+        public void RemoveAt (int index) {
+            Photo photo = (Photo) photos[index];
+            photos.RemoveAt (index);
+            containerIds.RemoveAt (index);
+            
+            if (PhotoRemoved != null)
+                PhotoRemoved (this, index, photo);
+        }
+
+        public bool RemovePhoto (Photo photo) {
+            int index;
+            bool ret = false;
+            
+            while ((index = IndexOf (photo)) >= 0) {
+                ret = true;
+                RemoveAt (index);
+            }
+
+            return ret;
+        }
+
+        public int IndexOf (Photo photo) {
+            return photos.IndexOf (photo);
+        }
+
+        internal int GetContainerId (int index) {
+            return (int) containerIds[index];
+        }
+
+        internal ContentNode ToPhotosNode (int[] deletedIds) {
+            ArrayList photoNodes = new ArrayList ();
+
+            for (int i = 0; i < photos.Count; i++) {
+                Photo photo = photos[i] as Photo;
+                photoNodes.Add (photo.ToAlbumNode ((int) containerIds[i]));
+            }
+
+            ArrayList deletedNodes = null;
+            if (deletedIds.Length > 0) {
+                deletedNodes = new ArrayList ();
+
+                foreach (int id in deletedIds) {
+                    deletedNodes.Add (new ContentNode ("dmap.itemid", id));
+                }
+            }
+
+            ArrayList children = new ArrayList ();
+            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", photos.Count));
+            children.Add (new ContentNode ("dmap.returnedcount", photos.Count));
+            children.Add (new ContentNode ("dmap.listing", photoNodes));
+
+            if (deletedNodes != null)
+                children.Add (new ContentNode ("dmap.deletedidlisting", deletedNodes));
+            
+            
+            return new ContentNode ("dpap.playlistsongs", children);
+        }
+
+        internal ContentNode ToNode (bool baseAlbum) {
+
+            ArrayList nodes = new ArrayList ();
+
+            nodes.Add (new ContentNode ("dmap.itemid", id));
+            nodes.Add (new ContentNode ("dmap.persistentid", (long) id));
+            nodes.Add (new ContentNode ("dmap.itemname", name));
+            nodes.Add (new ContentNode ("dmap.itemcount", photos.Count));
+            if (baseAlbum)
+                nodes.Add (new ContentNode ("dpap.baseplaylist", (byte) 1));
+            
+            return new ContentNode ("dmap.listingitem", nodes);
+        }
+
+        internal static Album FromNode (ContentNode node) {
+            Album pl = new Album ();
+
+            foreach (ContentNode child in (ContentNode[]) node.Value) {
+                switch (child.Name) {
+                case  "dpap.baseplaylist":
+                    return null;
+                case "dmap.itemid":
+                    pl.Id = (int) child.Value;
+                    break;
+                case "dmap.itemname":
+                    pl.Name = (string) child.Value;
+                    break;
+                default:
+                    break;
+                }
+            }
+
+            return pl;
+        }
+
+        internal void Update (Album pl) {
+            if (pl.Name == name)
+                return;
+
+            Name = pl.Name;
+        }
+
+        internal int LookupIndexByContainerId (int id) {
+            return containerIds.IndexOf (id);
+        }
+
+		public int getId() {
+			return Id;
+		}
+    }
+
+}

Modified: trunk/dpap-sharp/lib/Client.cs
==============================================================================
--- trunk/dpap-sharp/lib/Client.cs	(original)
+++ trunk/dpap-sharp/lib/Client.cs	Tue Jul 15 11:56:32 2008
@@ -165,7 +165,7 @@
 
                 foreach (ContentNode item in (ContentNode[]) child.Value) {
                     Database db = new Database (this, item);
-					Console.WriteLine("Adding database {0} with id={1} and roll count={2}." , db.Name,db.Id,db.Playlists.Count); 
+					Console.WriteLine("Adding database {0} with id={1} and roll count={2}." , db.Name,db.Id,db.Albums.Count); 
                     databases.Add (db);
                 }
             }

Modified: trunk/dpap-sharp/lib/ContentCodeBag.cs
==============================================================================
--- trunk/dpap-sharp/lib/ContentCodeBag.cs	(original)
+++ trunk/dpap-sharp/lib/ContentCodeBag.cs	Tue Jul 15 11:56:32 2008
@@ -55,10 +55,12 @@
 
         public static ContentCodeBag Default {
             get {
+				Console.WriteLine("getting default content codebag");
                 if (defaultBag == null) {
 
                     // this is crappy
                     foreach (string name in Assembly.GetExecutingAssembly().GetManifestResourceNames()) {
+						Console.WriteLine("resource " +name);
                         using (BinaryReader reader = new BinaryReader(Assembly.GetExecutingAssembly().GetManifestResourceStream(name))) {
                             MemoryStream buf = new MemoryStream();
                             byte[] bytes = null;

Modified: trunk/dpap-sharp/lib/ContentParser.cs
==============================================================================
--- trunk/dpap-sharp/lib/ContentParser.cs	(original)
+++ trunk/dpap-sharp/lib/ContentParser.cs	Tue Jul 15 11:56:32 2008
@@ -120,8 +120,8 @@
                 // probably a buggy server.  fallback to our internal code bag
 				Console.WriteLine("fallback to internal code bag");
 				Console.WriteLine("Code number: "+num);
-				return null;
-                code = ContentCodeBag.Default.Lookup (num);
+				throw new Exception("Content code not found!");
+                //code = ContentCodeBag.Default.Lookup (num);
             }
 			
 			//System.Console.WriteLine("debug!4");

Modified: trunk/dpap-sharp/lib/Database.cs
==============================================================================
--- trunk/dpap-sharp/lib/Database.cs	(original)
+++ trunk/dpap-sharp/lib/Database.cs	Tue Jul 15 11:56:32 2008
@@ -27,30 +27,30 @@
 
 namespace DPAP {
 
-    public delegate void TrackHandler (object o, TrackArgs args);
+    public delegate void PhotoHandler (object o, PhotoArgs args);
 
-    public class TrackArgs : EventArgs {
-        private Track track;
+    public class PhotoArgs : EventArgs {
+        private Photo photo;
 
-        public Track Track {
-            get { return track; }
+        public Photo Photo {
+            get { return photo; }
         }
         
-        public TrackArgs (Track track) {
-            this.track = track;
+        public PhotoArgs (Photo photo) {
+            this.photo = photo;
         }
     }
         
-    public delegate void PlaylistHandler (object o, PlaylistArgs args);
+    public delegate void AlbumHandler (object o, AlbumArgs args);
 
-    public class PlaylistArgs : EventArgs {
-        private Playlist pl;
+    public class AlbumArgs : EventArgs {
+        private Album pl;
 
-        public Playlist Playlist {
+        public Album Album {
             get { return pl; }
         }
         
-        public PlaylistArgs (Playlist pl) {
+        public AlbumArgs (Album pl) {
             this.pl = pl;
         }
     }
@@ -59,7 +59,7 @@
 
         private const int ChunkLength = 8192;
 		
-        private const string TrackQuery = "meta=dpap.aspectratio,dmap.itemid,dmap.itemname,dpap.imagefilename," +
+        private const string PhotoQuery = "meta=dpap.aspectratio,dmap.itemid,dmap.itemname,dpap.imagefilename," +
 			"dpap.imagefilesize,dpap.creationdate,dpap.imagepixelwidth," +
 			"dpap.imagepixelheight,dpap.imageformat,dpap.imagerating," +
 			"dpap.imagecomments,dpap.imagelargefilesize&type=photo"; 
@@ -71,15 +71,15 @@
         private long persistentId;
         private string name;
 
-        private List<Track> tracks = new List<Track> ();
-        private List<Playlist> playlists = new List<Playlist> ();
-        private Playlist basePlaylist = new Playlist ();
-        private int nextTrackId = 1;
-
-        public event TrackHandler TrackAdded;
-        public event TrackHandler TrackRemoved;
-        public event PlaylistHandler PlaylistAdded;
-        public event PlaylistHandler PlaylistRemoved;
+        private List<Photo> photos = new List<Photo> ();
+        private List<Album> playlists = new List<Album> ();
+        private Album baseAlbum = new Album ();
+        private int nextPhotoId = 1;
+
+        public event PhotoHandler PhotoAdded;
+        public event PhotoHandler PhotoRemoved;
+        public event AlbumHandler AlbumAdded;
+        public event AlbumHandler AlbumRemoved;
 
         public int Id {
             get { return id; }
@@ -89,28 +89,28 @@
             get { return name; }
             set {
                 name = value;
-                basePlaylist.Name = value;
+                baseAlbum.Name = value;
             }
         }
         
-        public IList<Track> Tracks {
+        public IList<Photo> Photos {
             get {
-                return new ReadOnlyCollection<Track> (tracks);
+                return new ReadOnlyCollection<Photo> (photos);
             }
         }
         
-        public int TrackCount {
-            get { return tracks.Count; }
+        public int PhotoCount {
+            get { return photos.Count; }
         }
 
-        public Track TrackAt(int index)
+        public Photo PhotoAt(int index)
         {
-            return tracks[index] as Track;
+            return photos[index] as Photo;
         }
 
-        public IList<Playlist> Playlists {
+        public IList<Album> Albums {
             get {
-                return new ReadOnlyCollection<Playlist> (playlists);
+                return new ReadOnlyCollection<Album> (playlists);
             }
         }
 
@@ -151,20 +151,20 @@
             }
         }
 
-        public Track LookupTrackById (int id) {
-            foreach (Track track in tracks) {
-                if (track.Id == id)
-                    return track;
+        public Photo LookupPhotoById (int id) {
+            foreach (Photo photo in photos) {
+                if (photo.Id == id)
+                    return photo;
             }
 
             return null;
         }
 
-        public Playlist LookupPlaylistById (int id) {
-            if (id == basePlaylist.Id)
-                return basePlaylist;
+        public Album LookupAlbumById (int id) {
+            if (id == baseAlbum.Id)
+                return baseAlbum;
 
-            foreach (Playlist pl in playlists) {
+            foreach (Album pl in playlists) {
                 if (pl.Id == id)
                     return pl;
             }
@@ -172,11 +172,11 @@
             return null;
         }
 
-        internal ContentNode ToTracksNode (string[] fields, int[] deletedIds) {
+        internal ContentNode ToPhotosNode (string[] fields, int[] deletedIds) {
 
-            ArrayList trackNodes = new ArrayList ();
-            foreach (Track track in tracks) {
-                trackNodes.Add (track.ToNode (fields));
+            ArrayList photoNodes = new ArrayList ();
+            foreach (Photo photo in photos) {
+                photoNodes.Add (photo.ToNode (fields));
             }
 
             ArrayList deletedNodes = null;
@@ -192,9 +192,9 @@
             ArrayList children = new ArrayList ();
             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));
-            children.Add (new ContentNode ("dmap.returnedcount", tracks.Count));
-            children.Add (new ContentNode ("dmap.listing", trackNodes));
+            children.Add (new ContentNode ("dmap.specifiedtotalcount", photos.Count));
+            children.Add (new ContentNode ("dmap.returnedcount", photos.Count));
+            children.Add (new ContentNode ("dmap.listing", photoNodes));
 
             if (deletedNodes != null) {
                 children.Add (new ContentNode ("dmap.deletedidlisting", deletedNodes));
@@ -203,16 +203,16 @@
             return new ContentNode ("daap.databasesongs", children);
         }
 
-        internal ContentNode ToPlaylistsNode () {
+        internal ContentNode ToAlbumsNode () {
             ArrayList nodes = new ArrayList ();
 
-            nodes.Add (basePlaylist.ToNode (true));
+            nodes.Add (baseAlbum.ToNode (true));
             
-            foreach (Playlist pl in playlists) {
+            foreach (Album pl in playlists) {
                 nodes.Add (pl.ToNode (false));
             }
 
-            return new ContentNode ("daap.databaseplaylists",
+            return new ContentNode ("dpap.databaseplaylists",
                                     new ContentNode ("dmap.status", 200),
                                     new ContentNode ("dmap.updatetype", (byte) 0),
                                     new ContentNode ("dmap.specifiedtotalcount", nodes.Count),
@@ -225,7 +225,7 @@
                                     new ContentNode ("dmap.itemid", id),
                                     new ContentNode ("dmap.persistentid", (long) id),
                                     new ContentNode ("dmap.itemname", name),
-                                    new ContentNode ("dmap.itemcount", tracks.Count),
+                                    new ContentNode ("dmap.itemcount", photos.Count),
                                     new ContentNode ("dmap.containercount", playlists.Count + 1));
         }
 
@@ -233,19 +233,19 @@
             if (client != null)
                 throw new InvalidOperationException ("cannot clear client databases");
 
-            ClearPlaylists ();
-            ClearTracks ();
+            ClearAlbums ();
+            ClearPhotos ();
         }
 
-        private void ClearPlaylists () {
-            foreach (Playlist pl in new List<Playlist> (playlists)) {
-                RemovePlaylist (pl);
+        private void ClearAlbums () {
+            foreach (Album pl in new List<Album> (playlists)) {
+                RemoveAlbum (pl);
             }
         }
 
-        private void ClearTracks () {
-            foreach (Track track in new List<Track> (tracks)) {
-                RemoveTrack (track);
+        private void ClearPhotos () {
+            foreach (Photo photo in new List<Photo> (photos)) {
+                RemovePhoto (photo);
             }
         }
 
@@ -253,7 +253,7 @@
             return node.Name == "dmap.updateresponse";
         }
 
-        private void RefreshPlaylists (string revquery) {
+        private void RefreshAlbums (string revquery) {
             byte[] playlistsData;
 
             try {
@@ -271,14 +271,14 @@
             ArrayList plids = new ArrayList ();
             
             foreach (ContentNode playlistNode in (ContentNode[]) playlistsNode.GetChild ("dmap.listing").Value) {
-                Playlist pl = Playlist.FromNode (playlistNode);
+                Album pl = Album.FromNode (playlistNode);
 
                 if (pl != null) {
                     plids.Add (pl.Id);
-                    Playlist existing = LookupPlaylistById (pl.Id);
+                    Album existing = LookupAlbumById (pl.Id);
 
                     if (existing == null) {
-                        AddPlaylist (pl);
+                        AddAlbum (pl);
                     } else {
                         existing.Update (pl);
                     }
@@ -286,27 +286,27 @@
             }
 
             // delete playlists that no longer exist
-            foreach (Playlist pl in new List<Playlist> (playlists)) {
+            foreach (Album pl in new List<Album> (playlists)) {
                 if (!plids.Contains (pl.Id)) {
-                    RemovePlaylist (pl);
+                    RemoveAlbum (pl);
                 }
             }
 
             plids = null;
 
-            // add/remove tracks in the playlists
-            foreach (Playlist pl in playlists) {
-                byte[] playlistTracksData = client.Fetcher.Fetch (String.Format ("/databases/{0}/containers/{1}/items",
+            // add/remove photos in the playlists
+            foreach (Album pl in playlists) {
+                byte[] playlistPhotosData = client.Fetcher.Fetch (String.Format ("/databases/{0}/containers/{1}/items",
                                                                                 id, pl.Id), revquery);
-                ContentNode playlistTracksNode = ContentParser.Parse (client.Bag, playlistTracksData);
+                ContentNode playlistPhotosNode = ContentParser.Parse (client.Bag, playlistPhotosData);
 
-                if (IsUpdateResponse (playlistTracksNode))
+                if (IsUpdateResponse (playlistPhotosNode))
                     return;
 
-                if ((byte) playlistTracksNode.GetChild ("dmap.updatetype").Value == 1) {
+                if ((byte) playlistPhotosNode.GetChild ("dmap.updatetype").Value == 1) {
 
-                    // handle playlist track deletions
-                    ContentNode deleteList = playlistTracksNode.GetChild ("dmap.deletedidlisting");
+                    // handle playlist photo deletions
+                    ContentNode deleteList = playlistPhotosNode.GetChild ("dmap.deletedidlisting");
 
                     if (deleteList != null) {
                         foreach (ContentNode deleted in (ContentNode[]) deleteList.Value) {
@@ -320,19 +320,19 @@
                     }
                 }
 
-                // add new tracks, or reorder existing ones
+                // add new photos, or reorder existing ones
 
                 int plindex = 0;
-                foreach (ContentNode plTrackNode in (ContentNode[]) playlistTracksNode.GetChild ("dmap.listing").Value) {
-                    Track pltrack = null;
+                foreach (ContentNode plPhotoNode in (ContentNode[]) playlistPhotosNode.GetChild ("dmap.listing").Value) {
+                    Photo plphoto = null;
                     int containerId = 0;
-                    Track.FromPlaylistNode (this, plTrackNode, out pltrack, out containerId);
+                    Photo.FromAlbumNode (this, plPhotoNode, out plphoto, out containerId);
 
                     if (pl[plindex] != null && pl.GetContainerId (plindex) != containerId) {
                         pl.RemoveAt (plindex);
-                        pl.InsertTrack (plindex, pltrack, containerId);
+                        pl.InsertPhoto (plindex, plphoto, containerId);
                     } else if (pl[plindex] == null) {
-                        pl.InsertTrack (plindex, pltrack, containerId);
+                        pl.InsertPhoto (plindex, plphoto, containerId);
                     }
 
                     plindex++;
@@ -340,44 +340,44 @@
             }
         }
 
-        private void RefreshTracks (string revquery) {
-			foreach (Playlist pl in playlists){
-	            byte[] tracksData = client.Fetcher.Fetch (String.Format ("/databases/{0}/containers/{1}/items", id,pl.getId()),
-	                                                     TrackQuery);
-	            ContentNode tracksNode = ContentParser.Parse (client.Bag, tracksData);
+        private void RefreshPhotos (string revquery) {
+			foreach (Album pl in playlists){
+	            byte[] photosData = client.Fetcher.Fetch (String.Format ("/databases/{0}/containers/{1}/items", id,pl.getId()),
+	                                                     PhotoQuery);
+	            ContentNode photosNode = ContentParser.Parse (client.Bag, photosData);
 
-	            if (IsUpdateResponse (tracksNode))
+	            if (IsUpdateResponse (photosNode))
 	                return;
 
-	            // handle track additions/changes
-	            foreach (ContentNode trackNode in (ContentNode[]) tracksNode.GetChild ("dmap.listing").Value) {
-					//trackNode.Dump();
-	                Track track = Track.FromNode (trackNode);
+	            // handle photo additions/changes
+	            foreach (ContentNode photoNode in (ContentNode[]) photosNode.GetChild ("dmap.listing").Value) {
+					//photoNode.Dump();
+	                Photo photo = Photo.FromNode (photoNode);
 					
-	                Track existing = LookupTrackById (track.Id);
+	                Photo existing = LookupPhotoById (photo.Id);
 					
 	                if (existing == null){
-						Console.WriteLine("adding " + track.Title);
-	                    AddTrack (track);
+						Console.WriteLine("adding " + photo.Title);
+	                    AddPhoto (photo);
 					}
 	                else
 					{
 						Console.WriteLine("updating " + existing.Title);
-	                    existing.Update (track);
+	                    existing.Update (photo);
 					}
 	            }
 
-	            if ((byte) tracksNode.GetChild ("dmap.updatetype").Value == 1) {
+	            if ((byte) photosNode.GetChild ("dmap.updatetype").Value == 1) {
 
-	                // handle track deletions
-	                ContentNode deleteList = tracksNode.GetChild ("dmap.deletedidlisting");
+	                // handle photo deletions
+	                ContentNode deleteList = photosNode.GetChild ("dmap.deletedidlisting");
 
 	                if (deleteList != null) {
 	                    foreach (ContentNode deleted in (ContentNode[]) deleteList.Value) {
-	                        Track track = LookupTrackById ((int) deleted.Value);
+	                        Photo photo = LookupPhotoById ((int) deleted.Value);
 
-	                        if (track != null)
-	                            RemoveTrack (track);
+	                        if (photo != null)
+	                            RemovePhoto (photo);
 	                    }
 	                }
 				}
@@ -393,34 +393,34 @@
             if (client.Revision != 0)
                 revquery = String.Format ("revision-number={0}&delta={1}", newrev, newrev - client.Revision);
             
-            RefreshPlaylists ("");
-			RefreshTracks ("");
+            RefreshAlbums ("");
+			RefreshPhotos ("");
         }
 
-        private HttpWebResponse FetchTrack (Track track, long offset) {
+        private HttpWebResponse FetchPhoto (Photo photo, long offset) {
             return client.Fetcher.FetchResponse (String.Format ("/databases/{0}/items",id), offset, 
-			                                     String.Format("meta=dpap.filedata&query=('dmap.itemid:{0}')",track.Id),
+			                                     String.Format("meta=dpap.filedata&query=('dmap.itemid:{0}')",photo.Id),
 			                                     null, 1, true);
                                              
         }
 
-        public Stream StreamTrack (Track track, out long length) {
-            return StreamTrack (track, -1, out length);
+        public Stream StreamPhoto (Photo photo, out long length) {
+            return StreamPhoto (photo, -1, out length);
         }
         
-        public Stream StreamTrack (Track track, long offset, out long length) {
-            HttpWebResponse response = FetchTrack (track, offset);
+        public Stream StreamPhoto (Photo photo, long offset, out long length) {
+            HttpWebResponse response = FetchPhoto (photo, offset);
             length = response.ContentLength;
             return response.GetResponseStream ();
         }
 
-        public void DownloadTrack (Track track, string dest) {
+        public void DownloadPhoto (Photo photo, string dest) {
 
             BinaryWriter writer = new BinaryWriter (File.Open (dest, FileMode.Create));
 
             try {
                 long len;
-                using (BinaryReader reader = new BinaryReader (StreamTrack (track, out len))) {
+                using (BinaryReader reader = new BinaryReader (StreamPhoto (photo, out len))) {
                     int count = 0;
                     byte[] buf = new byte[ChunkLength];
                     
@@ -439,50 +439,50 @@
             }
         }
 
-        public void AddTrack (Track track) {
-            if (track.Id == 0)
-                track.SetId (nextTrackId++);
+        public void AddPhoto (Photo photo) {
+            if (photo.Id == 0)
+                photo.SetId (nextPhotoId++);
             
-            tracks.Add (track);
-            basePlaylist.AddTrack (track);
+            photos.Add (photo);
+            baseAlbum.AddPhoto (photo);
 
-            if (TrackAdded != null)
-                TrackAdded (this, new TrackArgs (track));
+            if (PhotoAdded != null)
+                PhotoAdded (this, new PhotoArgs (photo));
         }
 
-        public void RemoveTrack (Track track) {
-            tracks.Remove (track);
-            basePlaylist.RemoveTrack (track);
+        public void RemovePhoto (Photo photo) {
+            photos.Remove (photo);
+            baseAlbum.RemovePhoto (photo);
 
-            foreach (Playlist pl in playlists) {
-                pl.RemoveTrack (track);
+            foreach (Album pl in playlists) {
+                pl.RemovePhoto (photo);
             }
 
-            if (TrackRemoved != null)
-                TrackRemoved (this, new TrackArgs (track));
+            if (PhotoRemoved != null)
+                PhotoRemoved (this, new PhotoArgs (photo));
         }
 
-        public void AddPlaylist (Playlist pl) {
+        public void AddAlbum (Album pl) {
             playlists.Add (pl);
 
-            if (PlaylistAdded != null)
-                PlaylistAdded (this, new PlaylistArgs (pl));
+            if (AlbumAdded != null)
+                AlbumAdded (this, new AlbumArgs (pl));
         }
 
-        public void RemovePlaylist (Playlist pl) {
+        public void RemoveAlbum (Album pl) {
             playlists.Remove (pl);
 
-            if (PlaylistRemoved != null)
-                PlaylistRemoved (this, new PlaylistArgs (pl));
+            if (AlbumRemoved != null)
+                AlbumRemoved (this, new AlbumArgs (pl));
         }
 
-        private Playlist ClonePlaylist (Database db, Playlist pl) {
-            Playlist clonePl = new Playlist (pl.Name);
+        private Album CloneAlbum (Database db, Album pl) {
+            Album clonePl = new Album (pl.Name);
             clonePl.Id = pl.Id;
 
-            IList<Track> pltracks = pl.Tracks;
-            for (int i = 0; i < pltracks.Count; i++) {
-                clonePl.AddTrack (db.LookupTrackById (pltracks[i].Id), pl.GetContainerId (i));
+            IList<Photo> plphotos = pl.Photos;
+            for (int i = 0; i < plphotos.Count; i++) {
+                clonePl.AddPhoto (db.LookupPhotoById (plphotos[i].Id), pl.GetContainerId (i));
             }
 
             return clonePl;
@@ -493,20 +493,20 @@
             db.id = id;
             db.persistentId = persistentId;
 
-            List<Track> cloneTracks = new List<Track> ();
-            foreach (Track track in tracks) {
-                cloneTracks.Add ((Track) track.Clone ());
+            List<Photo> clonePhotos = new List<Photo> ();
+            foreach (Photo photo in photos) {
+                clonePhotos.Add ((Photo) photo.Clone ());
             }
 
-            db.tracks = cloneTracks;
+            db.photos = clonePhotos;
 
-            List<Playlist> clonePlaylists = new List<Playlist> ();
-            foreach (Playlist pl in playlists) {
-                clonePlaylists.Add (ClonePlaylist (db, pl));
+            List<Album> cloneAlbums = new List<Album> ();
+            foreach (Album pl in playlists) {
+                cloneAlbums.Add (CloneAlbum (db, pl));
             }
 
-            db.playlists = clonePlaylists;
-            db.basePlaylist = ClonePlaylist (db, basePlaylist);
+            db.playlists = cloneAlbums;
+            db.baseAlbum = CloneAlbum (db, baseAlbum);
             return db;
         }
     }

Added: trunk/dpap-sharp/lib/Photo.cs
==============================================================================
--- (empty file)
+++ trunk/dpap-sharp/lib/Photo.cs	Tue Jul 15 11:56:32 2008
@@ -0,0 +1,302 @@
+// Photo.cs created with MonoDevelop
+// User: andrzej at 11:42Â2008-07-15
+//
+// To change standard headers go to Edit->Preferences->Coding->Standard Headers
+//
+
+using System;
+using System.Collections;
+namespace DPAP
+{
+	
+	
+	public class Photo
+	{
+		private string author;
+        private string album;
+        private string title;
+        private int year;
+        private string format;
+        private TimeSpan duration;
+        private int id;
+        private int size;
+		private int width;
+		private int height;
+        private string genre;
+        private int photoNumber;
+        private int photoCount;
+        private string fileName;
+        private DateTime dateAdded = DateTime.Now;
+        private DateTime dateModified = DateTime.Now;
+        private short bitrate;
+
+        public event EventHandler Updated;
+        
+        public string Author {
+            get { return author; }
+            set {
+                author = value;
+                EmitUpdated ();
+            }
+        }
+        
+        public string Album {
+            get { return album; }
+            set {
+                album = value;
+                EmitUpdated ();
+            }
+        }
+        
+        public string Title {
+            get { return title; }
+            set {
+                title = value;
+                EmitUpdated ();
+            }
+        }
+        
+        public int Year {
+            get { return year; }
+            set {
+                year = value;
+                EmitUpdated ();
+            }
+        }
+        
+        public string Format {
+            get { return format; }
+            set {
+                format = value;
+                EmitUpdated ();
+            }
+        }
+        
+        public TimeSpan Duration {
+            get { return duration; }
+            set {
+                duration = value;
+                EmitUpdated ();
+            }
+        }
+        
+        public int Id {
+            get { return id; }
+        }
+        
+        public int Size {
+            get { return size; }
+            set {
+                size = value;
+                EmitUpdated ();
+            }
+        }
+                
+        public string FileName {
+            get { return fileName; }
+            set {
+                fileName = value;
+                EmitUpdated ();
+            }
+        }
+        
+		public int Width {
+			get { return width; }
+			set {
+				width = value;
+				EmitUpdated ();
+			}
+		}
+		
+		public int Height {
+			get { return height; }
+			set {
+				height = value;
+				EmitUpdated ();
+			}
+		}
+		
+        public DateTime DateAdded {
+            get { return dateAdded; }
+            set {
+                dateAdded = value;
+                EmitUpdated ();
+            }
+        }
+        
+        public DateTime DateModified {
+            get { return dateModified; }
+            set {
+                dateModified = value;
+                EmitUpdated ();
+            }
+        }
+
+        
+        public object Clone () {
+            Photo photo = new Photo ();
+            photo.author = author;
+            photo.album = album;
+            photo.title = title;
+            photo.year = year;
+            photo.format = format;
+            photo.duration = duration;
+            photo.id = id;
+            photo.size = size;
+            photo.fileName = fileName;
+            photo.dateAdded = dateAdded;
+            photo.dateModified = dateModified;
+       
+            return photo;
+        }
+
+        public override string ToString () {
+            return String.Format ("{0} - {1}.{2} ({3})", author, title, format, id);
+        }
+
+        internal void SetId (int id) {
+            this.id = id;
+        }
+
+        internal ContentNode ToNode (string[] fields) {
+
+            ArrayList nodes = new ArrayList ();
+            
+            foreach (string field in fields) {
+                object val = null;
+                
+                switch (field) {
+                case "dmap.itemid":
+                    val = id;
+                    break;
+                case "dmap.itemname":
+                    val = title;
+                    break;
+                case "dmap.itemkind":
+                    val = (byte) 2;
+                    break;
+                case "dmap.persistentid":
+                    val = (long) id;
+                    break;
+                case "dpap.photoalbum":
+                    val = album;
+                    break;
+                
+                case "dpap.author":
+                    val = author;
+                    break;
+                
+                case "dpap.imageformat":
+                    val = format;
+                    break;
+               
+                default:
+                    break;
+                }
+                
+                if (val != null) {
+                    // iTunes wants this to go first, sigh
+                    if (field == "dmap.itemkind")
+                        nodes.Insert (0, new ContentNode (field, val));
+                    else
+                        nodes.Add (new ContentNode (field, val));
+                }
+            }
+            
+            return new ContentNode ("dmap.listingitem", nodes);
+        }
+
+        internal static Photo FromNode (ContentNode node) {
+            Photo photo = new Photo ();
+            
+            foreach (ContentNode field in (ContentNode[]) node.Value) {
+                switch (field.Name) {
+                case "dmap.itemid":
+                    photo.id = (int) field.Value;
+                    break;
+                case "dmap.itemname":
+                    photo.title = (string) field.Value;
+                    break;
+                case "dpap.imageformat":
+                    photo.format = (string) field.Value;
+                    break;
+                case "dpap.imagefilename":
+					photo.fileName = (string) field.Value;
+					break;
+                case "dpap.imagefilesize":
+                    photo.size = (int) field.Value;
+                    break;
+                case "dpap.imagepixelwidth":
+					photo.width = (int) field.Value;
+					break;
+				case "dpap.imagepixelheight":
+					photo.height = (int) field.Value;
+					break;
+                default:
+                    break;
+                }
+            }
+
+            return photo;
+        }
+
+        internal ContentNode ToAlbumNode (int containerId) {
+            return new ContentNode ("dmap.listingitem",
+                                    new ContentNode ("dmap.itemkind", (byte) 2),
+                                    new ContentNode ("daap.songdatakind", (byte) 0),
+                                    new ContentNode ("dmap.itemid", Id),
+                                    new ContentNode ("dmap.containeritemid", containerId),
+                                    new ContentNode ("dmap.itemname", Title == null ? String.Empty : Title));
+        }
+
+        internal static void FromAlbumNode (Database db, ContentNode node, out Photo photo, out int containerId) {
+            photo = null;
+            containerId = 0;
+            
+            foreach (ContentNode field in (ContentNode[]) node.Value) {
+                switch (field.Name) {
+                case "dmap.itemid":
+                    photo = db.LookupPhotoById ((int) field.Value);
+                    break;
+                case "dmap.containeritemid":
+                    containerId = (int) field.Value;
+                    break;
+                default:
+                    break;
+                }
+            }
+        }
+
+        private bool Equals (Photo photo) {
+            return author == photo.Author &&
+                album == photo.Album &&
+                title == photo.Title &&
+                year == photo.Year &&
+                format == photo.Format &&
+                size == photo.Size &&
+                dateAdded == photo.DateAdded &&
+                dateModified == photo.DateModified;
+        }
+
+        internal void Update (Photo photo) {
+            if (Equals (photo))
+                return;
+
+            author = photo.Author;
+            album = photo.Album;
+            title = photo.Title;
+            year = photo.Year;
+            format = photo.Format;
+            size = photo.Size;
+            dateAdded = photo.DateAdded;
+            dateModified = photo.DateModified;
+
+            EmitUpdated ();
+        }
+
+        private void EmitUpdated () {
+            if (Updated != null)
+                Updated (this, new EventArgs ());
+        }
+    }
+}
\ No newline at end of file

Modified: trunk/dpap-sharp/lib/Playlist.cs
==============================================================================
--- trunk/dpap-sharp/lib/Playlist.cs	(original)
+++ trunk/dpap-sharp/lib/Playlist.cs	Tue Jul 15 11:56:32 2008
@@ -160,7 +160,7 @@
                 children.Add (new ContentNode ("dmap.deletedidlisting", deletedNodes));
             
             
-            return new ContentNode ("daap.playlistsongs", children);
+            return new ContentNode ("dpap.playlistsongs", children);
         }
 
         internal ContentNode ToNode (bool basePlaylist) {
@@ -172,7 +172,7 @@
             nodes.Add (new ContentNode ("dmap.itemname", name));
             nodes.Add (new ContentNode ("dmap.itemcount", tracks.Count));
             if (basePlaylist)
-                nodes.Add (new ContentNode ("daap.baseplaylist", (byte) 1));
+                nodes.Add (new ContentNode ("dpap.baseplaylist", (byte) 1));
             
             return new ContentNode ("dmap.listingitem", nodes);
         }
@@ -182,7 +182,7 @@
 
             foreach (ContentNode child in (ContentNode[]) node.Value) {
                 switch (child.Name) {
-                case  "daap.baseplaylist":
+                case  "dpap.baseplaylist":
                     return null;
                 case "dmap.itemid":
                     pl.Id = (int) child.Value;

Modified: trunk/dpap-sharp/lib/Server.cs
==============================================================================
--- trunk/dpap-sharp/lib/Server.cs	(original)
+++ trunk/dpap-sharp/lib/Server.cs	Tue Jul 15 11:56:32 2008
@@ -1,5 +1,5 @@
 /*
- * daap-sharp
+ * dpap-sharp
  * Copyright (C) 2005  James Willcox <snorp snorp net>
  * 
  * This library is free software; you can redistribute it and/or
@@ -125,7 +125,7 @@
             
             using (BinaryWriter writer = new BinaryWriter (new NetworkStream (client, false))) {
                 writer.Write (Encoding.UTF8.GetBytes (String.Format ("HTTP/1.1 {0} {1}\r\n", (int) code, code.ToString ())));
-                writer.Write (Encoding.UTF8.GetBytes ("DAAP-Server: daap-sharp\r\n"));
+                writer.Write (Encoding.UTF8.GetBytes ("DPAP-Server: dpap-sharp\r\n"));
                 writer.Write (Encoding.UTF8.GetBytes ("Content-Type: application/x-dmap-tagged\r\n"));
                 writer.Write (Encoding.UTF8.GetBytes (String.Format ("Content-Length: {0}\r\n", body.Length)));
                 writer.Write (Encoding.UTF8.GetBytes ("\r\n"));
@@ -267,8 +267,8 @@
                 } else {
                     try {
                         string path = splitRequest[1];
-                        if (!path.StartsWith ("daap://")) {
-                            path = String.Format ("daap://localhost{0}", path);
+                        if (!path.StartsWith ("dpap://")) {
+                            path = String.Format ("dpap://localhost{0}", path);
                         }
 
                         Uri uri = new Uri (path);
@@ -394,12 +394,12 @@
         }
     }
 
-    public class TrackRequestedArgs : EventArgs {
+    public class PhotoRequestedArgs : EventArgs {
 
         private string user;
         private IPAddress host;
         private Database db;
-        private Track track;
+        private Photo photo;
 
         public string UserName {
             get { return user; }
@@ -413,26 +413,26 @@
             get { return db; }
         }
 
-        public Track Track {
-            get { return track; }
+        public Photo Photo {
+            get { return photo; }
         }
         
-        public TrackRequestedArgs (string user, IPAddress host, Database db, Track track) {
+        public PhotoRequestedArgs (string user, IPAddress host, Database db, Photo photo) {
             this.user = user;
             this.host = host;
             this.db = db;
-            this.track = track;
+            this.photo = photo;
         }
     }
 
-    public delegate void TrackRequestedHandler (object o, TrackRequestedArgs args);
+    public delegate void PhotoRequestedHandler (object o, PhotoRequestedArgs args);
 
     public class Server {
 
         internal static readonly TimeSpan DefaultTimeout = TimeSpan.FromMinutes (30);
         
         private static Regex dbItemsRegex = new Regex ("/databases/([0-9]*?)/items$");
-        private static Regex dbTrackRegex = new Regex ("/databases/([0-9]*?)/items/([0-9]*).*");
+        private static Regex dbPhotoRegex = new Regex ("/databases/([0-9]*?)/items/([0-9]*).*");
         private static Regex dbContainersRegex = new Regex ("/databases/([0-9]*?)/containers$");
         private static Regex dbContainerItemsRegex = new Regex ("/databases/([0-9]*?)/containers/([0-9]*?)/items$");
         
@@ -440,7 +440,7 @@
         private ArrayList databases = new ArrayList ();
         private Dictionary<int, User> sessions = new Dictionary<int, User> ();
         private Random random = new Random ();
-        private UInt16 port = 3689;
+        private UInt16 port = 8770;
         private ServerInfo serverInfo = new ServerInfo ();
         private bool publish = true;
         private int maxUsers = 0;
@@ -453,7 +453,7 @@
         private RevisionManager revmgr = new RevisionManager ();
 
         public event EventHandler Collision;
-        public event TrackRequestedHandler TrackRequested;
+        public event PhotoRequestedHandler PhotoRequested;
         public event UserHandler UserLogin;
         public event UserHandler UserLogout;
 
@@ -586,7 +586,7 @@
                 
                 zc_service = new RegisterService ();
                 zc_service.Name = serverInfo.Name;
-                zc_service.RegType = "_daap._tcp";
+                zc_service.RegType = "_dpap._tcp";
                 zc_service.Port = (short)ws.BoundPort;
                 zc_service.TxtRecord = new TxtRecord ();
                 zc_service.TxtRecord.Add ("Password", auth);
@@ -597,6 +597,8 @@
                 }
                 
                 zc_service.TxtRecord.Add ("txtvers", "1");
+				zc_service.TxtRecord.Add ("Version", "65537");
+				zc_service.ReplyDomain = "local.";
                 zc_service.Response += OnRegisterServiceResponse;
                 zc_service.Register ();
             }
@@ -664,12 +666,12 @@
                 session = Int32.Parse (query["session-id"]);
             }
 
-            if (!sessions.ContainsKey (session) && path != "/server-info" && path != "/content-codes" &&
+/*            if (!sessions.ContainsKey (session) && path != "/server-info" && path != "/content-codes" &&
                 path != "/login") {
                 ws.WriteResponse (client, HttpStatusCode.Forbidden, "invalid session id");
                 return true;
             }
-
+*/
             if (session != 0) {
                 sessions[session].LastActionTime = DateTime.Now;
             }
@@ -683,7 +685,7 @@
             if (query["delta"] != null) {
                 delta = Int32.Parse (query["delta"]);
             }
-
+			Console.WriteLine("Before returning resources");
             if (path == "/server-info") {
                 ws.WriteResponse (client, GetServerInfoNode ());
             } else if (path == "/content-codes") {
@@ -734,20 +736,20 @@
                     Database olddb = revmgr.GetDatabase (clientRev - delta, dbid);
 
                     if (olddb != null) {
-                        foreach (Track track in olddb.Tracks) {
-                            if (curdb.LookupTrackById (track.Id) == null)
-                                deletedIds.Add (track.Id);
+                        foreach (Photo photo in olddb.Photos) {
+                            if (curdb.LookupPhotoById (photo.Id) == null)
+                                deletedIds.Add (photo.Id);
                         }
                     }
                 }
 
-                ContentNode node = curdb.ToTracksNode (query["meta"].Split (','),
+                ContentNode node = curdb.ToPhotosNode (query["meta"].Split (','),
                                                       (int[]) deletedIds.ToArray (typeof (int)));
                 ws.WriteResponse (client, node);
-            } else if (dbTrackRegex.IsMatch (path)) {
-                Match match = dbTrackRegex.Match (path);
+            } else if (dbPhotoRegex.IsMatch (path)) {
+                Match match = dbPhotoRegex.Match (path);
                 int dbid = Int32.Parse (match.Groups[1].Value);
-                int trackid = Int32.Parse (match.Groups[2].Value);
+                int photoid = Int32.Parse (match.Groups[2].Value);
 
                 Database db = revmgr.GetDatabase (clientRev, dbid);
                 if (db == null) {
@@ -755,28 +757,28 @@
                     return true;
                 }
 
-                Track track = db.LookupTrackById (trackid);
-                if (track == null) {
-                    ws.WriteResponse (client, HttpStatusCode.BadRequest, "invalid track id");
+                Photo photo = db.LookupPhotoById (photoid);
+                if (photo == null) {
+                    ws.WriteResponse (client, HttpStatusCode.BadRequest, "invalid photo id");
                     return true;
                 }
 
                 try {
                     try {
-                        if (TrackRequested != null)
-                            TrackRequested (this, new TrackRequestedArgs (username,
+                        if (PhotoRequested != null)
+                            PhotoRequested (this, new PhotoRequestedArgs (username,
                                                                         (client.RemoteEndPoint as IPEndPoint).Address,
-                                                                        db, track));
+                                                                        db, photo));
                     } catch {}
                     
-                    if (track.FileName != null) {
-                        ws.WriteResponseFile (client, track.FileName, range);
+                    if (photo.FileName != null) {
+                        ws.WriteResponseFile (client, photo.FileName, range);
                     } else if (db.Client != null) {
-                        long trackLength = 0;
-                        Stream trackStream = db.StreamTrack (track, out trackLength);
+                        long photoLength = 0;
+                        Stream photoStream = db.StreamPhoto (photo, out photoLength);
                         
                         try {
-                            ws.WriteResponseStream (client, trackStream, trackLength);
+                            ws.WriteResponseStream (client, photoStream, photoLength);
                         } catch (IOException) {
                         }
                     } else {
@@ -794,7 +796,7 @@
                     return true;
                 }
 
-                ws.WriteResponse (client, db.ToPlaylistsNode ());
+                ws.WriteResponse (client, db.ToAlbumsNode ());
             } else if (dbContainerItemsRegex.IsMatch (path)) {
                 Match match = dbContainerItemsRegex.Match (path);
                 int dbid = Int32.Parse (match.Groups[1].Value);
@@ -806,7 +808,7 @@
                     return true;
                 }
 
-                Playlist curpl = curdb.LookupPlaylistById (plid);
+                Album curpl = curdb.LookupAlbumById (plid);
                 if (curdb == null) {
                     ws.WriteResponse (client, HttpStatusCode.BadRequest, "invalid playlist id");
                     return true;
@@ -817,11 +819,11 @@
                     Database olddb = revmgr.GetDatabase (clientRev - delta, dbid);
 
                     if (olddb != null) {
-                        Playlist oldpl = olddb.LookupPlaylistById (plid);
+                        Album oldpl = olddb.LookupAlbumById (plid);
 
                         if (oldpl != null) {
-                            IList<Track> oldplTracks = oldpl.Tracks;
-                            for (int i = 0; i < oldplTracks.Count; i++) {
+                            IList<Photo> oldplPhotos = oldpl.Photos;
+                            for (int i = 0; i < oldplPhotos.Count; i++) {
                                 int id = oldpl.GetContainerId (i);
                                 if (curpl.LookupIndexByContainerId (id) < 0) {
                                     deletedIds.Add (id);
@@ -831,7 +833,7 @@
                     }
                 }
                     
-                ws.WriteResponse (client, curpl.ToTracksNode ((int[]) deletedIds.ToArray (typeof (int))));
+                ws.WriteResponse (client, curpl.ToPhotosNode ((int[]) deletedIds.ToArray (typeof (int))));
             } else if (path == "/update") {
                 int retrev;
                 
@@ -863,7 +865,8 @@
         }
 
         private ContentNode GetServerInfoNode () {
-            return serverInfo.ToNode (databases.Count);
+			
+            return serverInfo.ToNode(databases.Count);
         }
 
         private ContentNode GetDatabasesNode () {
@@ -876,7 +879,7 @@
                 }
             }
 
-            ContentNode node = new ContentNode ("daap.serverdatabases",
+            ContentNode node = new ContentNode ("dpap.serverdatabases",
                                                 new ContentNode ("dmap.status", 200),
                                                 new ContentNode ("dmap.updatetype", (byte) 0),
                                                 new ContentNode ("dmap.specifiedtotalcount", databases.Count),

Modified: trunk/dpap-sharp/lib/ServerInfo.cs
==============================================================================
--- trunk/dpap-sharp/lib/ServerInfo.cs	(original)
+++ trunk/dpap-sharp/lib/ServerInfo.cs	Tue Jul 15 11:56:32 2008
@@ -77,7 +77,7 @@
             return new ContentNode ("dmap.serverinforesponse",
                                     new ContentNode ("dmap.status", 200),
                                     new ContentNode ("dmap.protocolversion", new Version (2, 0, 2)),
-                                    new ContentNode ("daap.protocolversion", new Version (3, 0, 2)),
+                                    //new ContentNode ("dpap.protocolversion", new Version (3, 0, 2)),
                                     new ContentNode ("dmap.itemname", name),
                                     new ContentNode ("dmap.loginrequired", (byte) 1),
                                     new ContentNode ("dmap.authenticationmethod", (byte) authMethod),

Modified: trunk/dpap-sharp/lib/Track.cs
==============================================================================
--- trunk/dpap-sharp/lib/Track.cs	(original)
+++ trunk/dpap-sharp/lib/Track.cs	Tue Jul 15 11:56:32 2008
@@ -375,7 +375,7 @@
             foreach (ContentNode field in (ContentNode[]) node.Value) {
                 switch (field.Name) {
                 case "dmap.itemid":
-                    track = db.LookupTrackById ((int) field.Value);
+                  //  track = db.LookupTrackById ((int) field.Value);
                     break;
                 case "dmap.containeritemid":
                     containerId = (int) field.Value;

Modified: trunk/dpap-sharp/lib/content-codes
==============================================================================
Binary files. No diff available.



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