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



Author: apart
Date: Wed Jul  2 23:15:05 2008
New Revision: 4139
URL: http://svn.gnome.org/viewvc/f-spot?rev=4139&view=rev

Log:
Fetching albums & image info


Modified:
   trunk/dpap-sharp/launcher/Main.cs
   trunk/dpap-sharp/lib/Client.cs
   trunk/dpap-sharp/lib/ContentCodeBag.cs
   trunk/dpap-sharp/lib/ContentFetcher.cs
   trunk/dpap-sharp/lib/Database.cs
   trunk/dpap-sharp/lib/Playlist.cs
   trunk/dpap-sharp/lib/dpap-sharp.mdp

Modified: trunk/dpap-sharp/launcher/Main.cs
==============================================================================
--- trunk/dpap-sharp/launcher/Main.cs	(original)
+++ trunk/dpap-sharp/launcher/Main.cs	Wed Jul  2 23:15:05 2008
@@ -39,7 +39,21 @@
 
 			System.Console.WriteLine("Connecting to {0} at {1}:{2}", service.Name, service.Address, service.Port);
 		    client = new Client( service );
-			Console.ReadLine();
+			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 (Track tr in d.Tracks) 
+					if(tr != null)
+						Console.WriteLine("\t\tFile: " + tr.Title);
+				
+			}
+			client.Logout();
+			Console.WriteLine("Press <enter> to exit...");
+			//Console.ReadLine();
 	//		});
         /*            //client.Updated += OnClientUpdated;
                     if(client.AuthenticationMethod == AuthenticationMethod.None) {

Modified: trunk/dpap-sharp/lib/Client.cs
==============================================================================
--- trunk/dpap-sharp/lib/Client.cs	(original)
+++ trunk/dpap-sharp/lib/Client.cs	Wed Jul  2 23:15:05 2008
@@ -117,7 +117,8 @@
 
             try {
                 bag = ContentCodeBag.ParseCodes (fetcher.Fetch ("/content-codes"));
-				
+			//	ContentNode n = bag.ToNode();
+			//	n.Dump();
                 ContentNode node = ContentParser.Parse (bag, fetcher.Fetch ("/login"));
                 ParseSessionId (node);
 				//byte[] db_reply = fetcher.Fetch ("/databases");

Modified: trunk/dpap-sharp/lib/ContentCodeBag.cs
==============================================================================
--- trunk/dpap-sharp/lib/ContentCodeBag.cs	(original)
+++ trunk/dpap-sharp/lib/ContentCodeBag.cs	Wed Jul  2 23:15:05 2008
@@ -110,7 +110,7 @@
             code.Number = GetIntFormat (num);
             code.Name = name;
             code.Type = type;
-			Console.Write(name + ' ');
+			//Console.Write(name + ' ');
 			
             codes[code.Number] = code;
 	//		Console.WriteLine("Leaving ContentCodeBag AddCode(string,string,ContentType)");

Modified: trunk/dpap-sharp/lib/ContentFetcher.cs
==============================================================================
--- trunk/dpap-sharp/lib/ContentFetcher.cs	(original)
+++ trunk/dpap-sharp/lib/ContentFetcher.cs	Wed Jul  2 23:15:05 2008
@@ -151,13 +151,13 @@
 
             string hash = Hasher.GenerateHash (3, builder.Uri.PathAndQuery, 2, requestId);
 
-            request.UserAgent = "iPhoto/4.01 (Macintosh; PPC)";
+            request.UserAgent = "iPhoto/5.0.2 (Macintosh; PPC)";
             request.Headers.Set ("Client-DMAP-Version", "1.0");
-			request.Headers.Set ("Client-DPAP-Version", "1.0");
+			request.Headers.Set ("Client-DPAP-Version", "1.1");
             /*request.Headers.Set ("Client-DPAP-Validation", hash);
             request.Headers.Set ("Client-DPAP-Access-Index", "2");
 			*/
-			Console.Write(path + query);
+			Console.Write(path + "?"+query);
 			Console.Write(request.Headers);
 			
             if (requestId >= 0)
@@ -171,7 +171,8 @@
                     requests.Add (request);
                 }
                 HttpWebResponse response = (HttpWebResponse) request.GetResponse ();
-				Console.Write(response.StatusCode);
+				//if(!response.StatusCode.Equals("OK"))
+				//	Console.Write(response.StatusCode);
                 return response;
             } finally {
                 lock (requests) {

Modified: trunk/dpap-sharp/lib/Database.cs
==============================================================================
--- trunk/dpap-sharp/lib/Database.cs	(original)
+++ trunk/dpap-sharp/lib/Database.cs	Wed Jul  2 23:15:05 2008
@@ -341,38 +341,47 @@
         }
 
         private void RefreshTracks (string revquery) {
-            byte[] tracksData = client.Fetcher.Fetch (String.Format ("/databases/{0}/items", id),
-                                                     TrackQuery + "&" + revquery);
-            ContentNode tracksNode = ContentParser.Parse (client.Bag, tracksData);
-
-            if (IsUpdateResponse (tracksNode))
-                return;
-
-            // handle track additions/changes
-            foreach (ContentNode trackNode in (ContentNode[]) tracksNode.GetChild ("dmap.listing").Value) {
-                Track track = Track.FromNode (trackNode);
-                Track existing = LookupTrackById (track.Id);
-
-                if (existing == null)
-                    AddTrack (track);
-                else
-                    existing.Update (track);
-            }
-
-            if ((byte) tracksNode.GetChild ("dmap.updatetype").Value == 1) {
-
-                // handle track deletions
-                ContentNode deleteList = tracksNode.GetChild ("dmap.deletedidlisting");
-
-                if (deleteList != null) {
-                    foreach (ContentNode deleted in (ContentNode[]) deleteList.Value) {
-                        Track track = LookupTrackById ((int) deleted.Value);
-
-                        if (track != null)
-                            RemoveTrack (track);
-                    }
-                }
-            }
+			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);
+
+	            if (IsUpdateResponse (tracksNode))
+	                return;
+
+	            // handle track additions/changes
+	            foreach (ContentNode trackNode in (ContentNode[]) tracksNode.GetChild ("dmap.listing").Value) {
+					//trackNode.Dump();
+	                Track track = Track.FromNode (trackNode);
+					
+	                Track existing = LookupTrackById (track.Id);
+					
+	                if (existing == null){
+						Console.WriteLine("adding " + track.Title);
+	                    AddTrack (track);
+					}
+	                else
+					{
+						Console.WriteLine("updating " + existing.Title);
+	                    existing.Update (track);
+					}
+	            }
+
+	            if ((byte) tracksNode.GetChild ("dmap.updatetype").Value == 1) {
+
+	                // handle track deletions
+	                ContentNode deleteList = tracksNode.GetChild ("dmap.deletedidlisting");
+
+	                if (deleteList != null) {
+	                    foreach (ContentNode deleted in (ContentNode[]) deleteList.Value) {
+	                        Track track = LookupTrackById ((int) deleted.Value);
+
+	                        if (track != null)
+	                            RemoveTrack (track);
+	                    }
+	                }
+				}
+			}
         }
 
         internal void Refresh (int newrev) {
@@ -383,9 +392,9 @@
 
             if (client.Revision != 0)
                 revquery = String.Format ("revision-number={0}&delta={1}", newrev, newrev - client.Revision);
-
-            RefreshTracks ("");
+            
             RefreshPlaylists ("");
+			RefreshTracks ("");
         }
 
         private HttpWebResponse FetchTrack (Track track, long offset) {

Modified: trunk/dpap-sharp/lib/Playlist.cs
==============================================================================
--- trunk/dpap-sharp/lib/Playlist.cs	(original)
+++ trunk/dpap-sharp/lib/Playlist.cs	Wed Jul  2 23:15:05 2008
@@ -70,7 +70,7 @@
         internal Playlist () {
             id = nextid++;
         }
-
+		
         public Playlist (string name) : this () {
             this.name = name;
         }
@@ -208,6 +208,10 @@
         internal int LookupIndexByContainerId (int id) {
             return containerIds.IndexOf (id);
         }
+
+		public int getId() {
+			return Id;
+		}
     }
 
 }

Modified: trunk/dpap-sharp/lib/dpap-sharp.mdp
==============================================================================
--- trunk/dpap-sharp/lib/dpap-sharp.mdp	(original)
+++ trunk/dpap-sharp/lib/dpap-sharp.mdp	Wed Jul  2 23:15:05 2008
@@ -14,7 +14,6 @@
     </Configuration>
   </Configurations>
   <Contents>
-    <File name="MyClass.cs" subtype="Code" buildaction="Compile" />
     <File name="AssemblyInfo.cs" subtype="Code" buildaction="Compile" />
     <File name="gtk-gui/gui.stetic" subtype="Code" buildaction="EmbedAsResource" />
     <File name="gtk-gui/generated.cs" subtype="Code" buildaction="Compile" />



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