f-spot r4249 - in trunk/dpap-sharp: . DPAPBrowser DPAPService lib



Author: apart
Date: Tue Aug 12 19:37:53 2008
New Revision: 4249
URL: http://svn.gnome.org/viewvc/f-spot?rev=4249&view=rev

Log:
Fixed disconnecting after displaying hi-res photo


Modified:
   trunk/dpap-sharp/ChangeLog
   trunk/dpap-sharp/DPAPBrowser/DPAPBrowser.cs
   trunk/dpap-sharp/DPAPService/DPAPService.cs
   trunk/dpap-sharp/lib/Database.cs
   trunk/dpap-sharp/lib/Discovery.cs
   trunk/dpap-sharp/lib/Server.cs

Modified: trunk/dpap-sharp/DPAPBrowser/DPAPBrowser.cs
==============================================================================
--- trunk/dpap-sharp/DPAPBrowser/DPAPBrowser.cs	(original)
+++ trunk/dpap-sharp/DPAPBrowser/DPAPBrowser.cs	Tue Aug 12 19:37:53 2008
@@ -43,27 +43,23 @@
 			Console.WriteLine ("DPAP Page widget ctor!");
 			tree = new TreeView ();
 			Add (tree);
-			TreeViewColumn artistColumn = new Gtk.TreeViewColumn ();
-			//artistColumn.Title = "Artist";
+			TreeViewColumn albumColumn = new Gtk.TreeViewColumn ();
+			//albumColumn.Title = "album";
  
-			Gtk.CellRendererText artistNameCell = new Gtk.CellRendererText ();
-			artistNameCell.Visible = true;
-			artistColumn.PackStart (artistNameCell,false);
-			tree.AppendColumn (artistColumn);
-			//tree.AppendColumn ("Icon", new Gtk.CellRendererPixbuf (), "pixbuf", 0);  
+			Gtk.CellRendererText albumNameCell = new Gtk.CellRendererText ();
+			albumNameCell.Visible = true;
+			albumColumn.PackStart (albumNameCell,false);
+			tree.AppendColumn (albumColumn);
 
-			
 			list = new TreeStore (typeof (string));
 			tree.Model = list;
 			
-			artistColumn.AddAttribute (artistNameCell, "text", 0);
-			//list.AppendValues ("test");
+			albumColumn.AddAttribute (albumNameCell, "text", 0);
 		
 			tree.Selection.Changed += OnSelectionChanged;
-		//	tree.ShowNow ();
-		//	ShowAll ();
 			sd = new DPAP.ServiceDiscovery ();
-			sd.Found += OnServiceFound;		
+			sd.Found += OnServiceFound;
+			sd.Removed += OnServiceRemoved;
 			sd.Start ();	
 		}
 		
@@ -119,7 +115,6 @@
 	
 			client = new Client (service);
 			TreeIter iter;
-			//list.GetIterFromString (out iter, svcName);
 			list.GetIterFirst (out iter);
 			foreach (Database d in client.Databases){
 				
@@ -150,6 +145,13 @@
 			
 		}
 		
+		private void OnServiceRemoved (object o, ServiceArgs args)
+		{
+			Service service = args.Service;
+			Console.WriteLine ("Service removed " + service.Name);
+			// list.Remove ()
+			
+		}
 	}
 	
 	public class DPAPBrowser : SidebarPage

Modified: trunk/dpap-sharp/DPAPService/DPAPService.cs
==============================================================================
--- trunk/dpap-sharp/DPAPService/DPAPService.cs	(original)
+++ trunk/dpap-sharp/DPAPService/DPAPService.cs	Tue Aug 12 19:37:53 2008
@@ -40,9 +40,6 @@
 		{
 			Console.WriteLine ("Starting DPAP!");
 			uint timer = Log.InformationTimerStart ("Starting DPAP");
-		//	sd = new ServiceDiscovery ();
-		//	sd.Found += OnServiceFound;			
-		//	sd.Start ();
 			StartServer ();
 			
 
@@ -52,6 +49,7 @@
 				Log.Warning ("unable to hook the BeagleNotifier. are you running --view mode?");
 			}*/
 		//	Log.DebugTimerPrint (timer, "BeagleService startup took {0}");
+			
 			return true;
 		}
 		private void StartServer ()
@@ -64,7 +62,7 @@
 			server.AuthenticationMethod = AuthenticationMethod.None;
 			int collision_count = 0;
 			server.Collision += delegate {
-				server.Name = "f-spot photos" + " [" + ++collision_count + "]";
+				server.Name = "f-spot photos" + "[" + ++collision_count + "]";
 			};
             
 			
@@ -78,13 +76,10 @@
 			FSpot.Photo [] photos = Core.Database.Photos.Query (tags);
 			int i=0;
 			
-			foreach (FSpot.Photo photo in photos)
-			{
+			foreach (FSpot.Photo photo in photos) {
 				string thumbnail_path = ThumbnailGenerator.ThumbnailPath (photo.DefaultVersionUri);
 				FileInfo f = new FileInfo (thumbnail_path);
-				
 				DPAP.Photo p = new DPAP.Photo ();			
-				
 				p.FileName = photo.Name;
 				p.Thumbnail = thumbnail_path;
 				p.ThumbSize = (int)f.Length;
@@ -104,7 +99,6 @@
 
 			database.AddAlbum (a);
 			Console.WriteLine ("Album count is now " + database.Albums.Count);
-//			Console.WriteLine ("Photo name is " + database.Photos [0].FileName);
 			server.AddDatabase (database);
 			
 			//server.GetServerInfoNode ();			
@@ -149,12 +143,13 @@
 		    client = new Client (service);
 	
 			
-			foreach (Database d in client.Databases){
+			/*foreach (Database d in client.Databases){
 
 				Console.WriteLine ("Database " + d.Name);
 				
 				foreach (Album alb in d.Albums)
 					Console.WriteLine ("\tAlbum: "+alb.Name + ", id=" + alb.getId () + " number of items:" + alb.Photos.Count);
+				
 				Console.WriteLine (d.Photos [0].FileName);
 				foreach (DPAP.Photo ph in d.Photos)
 				{
@@ -165,7 +160,7 @@
 					}
 				}
 				
-			}
+			}*/
 			//client.Logout ();
 		//	Console.WriteLine ("Press <enter> to exit...");
 		}		

Modified: trunk/dpap-sharp/lib/Database.cs
==============================================================================
--- trunk/dpap-sharp/lib/Database.cs	(original)
+++ trunk/dpap-sharp/lib/Database.cs	Tue Aug 12 19:37:53 2008
@@ -491,10 +491,9 @@
 			int off = System.Int32.Parse (filedata_node.Value.ToString ());
 			byte [] photo_buf;
 			MemoryStream data = new MemoryStream ();
-			//while (count < photos_data.Length - fileDataNode.Value)
 			writer.Write (photos_data, (int)off, (int)photos_data.Length-off);
 			data.Position = 0;
-//			Gdk.Pixbuf pb = new Gdk.Pixbuf (data);
+			//	Gdk.Pixbuf pb = new Gdk.Pixbuf (data);
 			data.Close ();
 			Console.Write ("Written " + count + " out of " + (photos_data.Length-off));
         }

Modified: trunk/dpap-sharp/lib/Discovery.cs
==============================================================================
--- trunk/dpap-sharp/lib/Discovery.cs	(original)
+++ trunk/dpap-sharp/lib/Discovery.cs	Tue Aug 12 19:37:53 2008
@@ -108,6 +108,7 @@
 		public void Start () {
 			browser = new ServiceBrowser ();
 			browser.ServiceAdded += OnServiceAdded;
+			
 			browser.Browse ("_dpap._tcp","local");
 		}
 		

Modified: trunk/dpap-sharp/lib/Server.cs
==============================================================================
--- trunk/dpap-sharp/lib/Server.cs	(original)
+++ trunk/dpap-sharp/lib/Server.cs	Tue Aug 12 19:37:53 2008
@@ -727,6 +727,7 @@
                 ws.WriteResponse (client, GetLoginNode (session));
                 OnUserLogin (user);
             } else if (path == "/logout") {
+				Console.WriteLine("logout!");
                 User user = sessions [session];
                 
                 lock (sessions) {
@@ -786,13 +787,13 @@
 				ArrayList photoNodes = new ArrayList ();
 				Photo photo = db.LookupPhotoById (1);
 				
-				foreach (string photoId in photoIds)
-				{
+				foreach (string photoId in photoIds) {
 					match = dbPhotoRegex.Match (photoId);
-				photoid = Int32.Parse (match.Groups [1].Value);
-					Console.WriteLine ("Requested photo id=" + photoid);
+					photoid = Int32.Parse (match.Groups [1].Value);
 					photo = db.LookupPhotoById (photoid);
 					photoNodes.Add (photo.ToFileData (query ["meta"].Contains ("dpap.thumb")));
+					// DEBUG
+					//Console.WriteLine ("Requested photo id=" + photoid);
 				}
         
 				ArrayList children = new ArrayList ();
@@ -803,7 +804,6 @@
 				children.Add (new ContentNode ("dmap.listing", photoNodes));
 				ContentNode dbsongs = new ContentNode ("dpap.databasesongs", children);
                 
-				Console.WriteLine ("Photo tostring: " + photo.ToString ());
                 if (photo == null) {
                     ws.WriteResponse (client, HttpStatusCode.BadRequest, "invalid photo id");
                     return true;
@@ -818,11 +818,13 @@
                     } catch {}
                     
                     if (photo.FileName != null) {
-						Console.WriteLine ("photo.Filename != null" + query ["meta"].Split (',') [0]);
+						// DEBUG
+						//Console.WriteLine ("photo.Filename != null" + query ["meta"].Split (',') [0]);
 						//ContentNode node = photo.ToFileData ();
 						//node.Dump ();
+						
 						ws.WriteResponse (client, dbsongs);
-        //                ws.WriteResponseFile (client, photo.FileName, range);
+
                     } else if (db.Client != null) {
 						Console.WriteLine ("db.Client != null");
                         long photoLength = 0;
@@ -838,7 +840,8 @@
                         ws.WriteResponse (client, HttpStatusCode.InternalServerError, "no file");
                     }
                 } finally {
-                    client.Close ();
+					// commented out because it breaks the connection after sending a hires photo
+					// client.Close()
                 }
             } else if (dbContainersRegex.IsMatch (path)) {
                 int dbid = Int32.Parse (dbContainersRegex.Match (path).Groups [1].Value);



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