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



Author: apart
Date: Sun Aug 17 19:23:10 2008
New Revision: 4276
URL: http://svn.gnome.org/viewvc/f-spot?rev=4276&view=rev

Log:
Fixing event handlers


Modified:
   trunk/dpap-sharp/ChangeLog
   trunk/dpap-sharp/DPAPBrowser/DPAPBrowser.cs
   trunk/dpap-sharp/lib/Client.cs
   trunk/dpap-sharp/lib/Discovery.cs

Modified: trunk/dpap-sharp/DPAPBrowser/DPAPBrowser.cs
==============================================================================
--- trunk/dpap-sharp/DPAPBrowser/DPAPBrowser.cs	(original)
+++ trunk/dpap-sharp/DPAPBrowser/DPAPBrowser.cs	Sun Aug 17 19:23:10 2008
@@ -96,12 +96,12 @@
 				if (!alb.Name.Equals (name)) 
 					continue;
 				
-				Directory.CreateDirectory ("/tmp/" + client.Databases [0].Name + "/" + alb.Name);
+				Directory.CreateDirectory (System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal) + "/.cache/DPAP/" + client.Name + "/" + alb.Name);
 				foreach (DPAP.Photo ph in alb.Photos)
 					if (ph != null)
-						d.DownloadPhoto (ph,"/tmp/" + client.Databases [0].Name + "/" + alb.Name + "/" + ph.FileName);
+						d.DownloadPhoto (ph, System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal) + "/.cache/DPAP/" + client.Name + "/" + alb.Name + "/" + ph.FileName);
 					
-				FSpot.Core.FindInstance ().View ("file:///tmp/" + client.Databases [0].Name + "/" + alb.Name);
+				FSpot.Core.FindInstance ().View ( System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal) + "/.cache/DPAP/" + client.Name + "/" + alb.Name);
 				break;
 			}
 			
@@ -149,7 +149,18 @@
 		{
 			Service service = args.Service;
 			Console.WriteLine ("Service removed " + service.Name);
-			// list.Remove ()
+			TreeIter root = TreeIter.Zero;
+			TreeIter iter = TreeIter.Zero;
+
+			bool valid = tree.Model.GetIterFirst (out root);
+
+			while (valid) {
+				if(((String)tree.Model.GetValue(root,0)).Equals(service.Name))
+					(tree.Model as TreeStore).Remove(ref root);
+				valid = tree.Model.IterNext (ref root);
+			}
+			if (Directory.Exists (System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal) + "/.cache/DPAP/" + service.Name))
+				Directory.Delete (System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal) + "/.cache/DPAP/" + service.Name, true);
 			
 		}
 	}
@@ -160,8 +171,7 @@
 		private static DPAPPageWidget widget;
 		public DPAPBrowser () : base (new DPAPPageWidget (), "Shared items", "gtk-new") 
 		{
-			Console.WriteLine ("Starting DPAP client...");
-		
+			Console.WriteLine ("Starting DPAP client...");		
 			widget = (DPAPPageWidget)SidebarWidget;
 		}
 		

Modified: trunk/dpap-sharp/lib/Client.cs
==============================================================================
--- trunk/dpap-sharp/lib/Client.cs	(original)
+++ trunk/dpap-sharp/lib/Client.cs	Sun Aug 17 19:23:10 2008
@@ -51,7 +51,8 @@
         private ContentFetcher fetcher;
         private int revision;
         private bool update_running;
-
+		private string service_name;
+		
         public event EventHandler Updated;
 
         internal int Revision {
@@ -59,7 +60,7 @@
         }
 
         public string Name {
-            get { return server_info.Name; }
+            get { return service_name; }
         }
 
         public IPAddress Address {
@@ -86,16 +87,16 @@
             get { return fetcher; }
         }
 
-        public Client (Service service) : this (service.Address, service.Port) {
+        public Client (Service service) : this (service.Address, service.Port, service.Name) {
         }
 
-        public Client (string host, UInt16 port) : this (Dns.GetHostEntry (host).AddressList [0], port) {
+        public Client (string host, UInt16 port) : this (Dns.GetHostEntry (host).AddressList [0], port, "") {
         }
 
-        public Client (IPAddress address, UInt16 port) {
+        public Client (IPAddress address, UInt16 port, String name) {
             this.address = address;
             this.port = port;
-			
+			this.service_name = name;
             fetcher = new ContentFetcher (address, port);
 			Login (null,null);
 			

Modified: trunk/dpap-sharp/lib/Discovery.cs
==============================================================================
--- trunk/dpap-sharp/lib/Discovery.cs	(original)
+++ trunk/dpap-sharp/lib/Discovery.cs	Sun Aug 17 19:23:10 2008
@@ -107,7 +107,9 @@
 		
 		public void Start () {
 			browser = new ServiceBrowser ();
+
 			browser.ServiceAdded += OnServiceAdded;
+			browser.ServiceRemoved += OnServiceRemoved;
 			
 			browser.Browse ("_dpap._tcp","local");
 		}
@@ -162,6 +164,14 @@
 			
 			if (Found != null)
                 Found (this, new ServiceArgs (svc));
-		}		    
+		}
+		
+		private void OnServiceRemoved (object o, ServiceBrowseEventArgs args){
+			
+			IResolvableService s = args.Service;
+			
+			Removed (this, new ServiceArgs (new DPAP.Service (null, 0, s.Name, false, null)));
+			
+		}
 	}
 }
\ No newline at end of file



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