nemo r35 - trunk/broker



Author: arj
Date: Mon Jan  7 10:48:23 2008
New Revision: 35
URL: http://svn.gnome.org/viewvc/nemo?rev=35&view=rev

Log:
Fix search for text using Xesam



Modified:
   trunk/broker/Xesam.cs

Modified: trunk/broker/Xesam.cs
==============================================================================
--- trunk/broker/Xesam.cs	(original)
+++ trunk/broker/Xesam.cs	Mon Jan  7 10:48:23 2008
@@ -223,14 +223,14 @@
 			ThreadPool.QueueUserWorkItem(delegate {
 	            ++cur_search_id;
 
-	            int search_id = cur_search_id;
+	            int unique_search_id = cur_search_id;
 
 	            if (!fast)
 	                Thread.Sleep(1000);
 
 				System.Console.WriteLine("searching for text 2");
 
-	            if (cur_search_id == search_id)
+	            if (cur_search_id == unique_search_id)
 	            {
 					System.Console.WriteLine("new session?");
             		session_id = bus_search.NewSession();
@@ -242,14 +242,33 @@
 
 					bool got_results = false;
 	
-					hits_added_callbacks.Add(session_id, new Callback(10, delegate(ref int count, UInt32 amount) {
+					string xml_string = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+"<request xmlns=\"http://freedesktop.org/standards/xesam/1.0/query\";>" +
+"  <query>" +
+"    <and> " +
+"    <inSet> " +
+"      <field name=\"mime\"/> " +
+Helpers.reduce_to_string(Helpers.map_strings(string_start(), supported_mimetypes, string_end()))  +
+"    </inSet> " +
+"    <fullText> " +
+"      <string>" + search_string + "</string> " +
+"    </fullText> " +
+"    </and> " +
+"  </query> " +
+"</request> ";
+
+					System.Console.WriteLine(xml_string);
+
+					string search_id = bus_search.NewSearch(session_id, xml_string);
+
+					hits_added_callbacks.Add(search_id, new Callback(10, delegate(ref int count, UInt32 amount) {
 						System.Console.WriteLine("hits added: {0} - {1}", amount, session_id);
 
-						object[][] result = bus_search.GetHits(session_id, amount);
+						object[][] result = bus_search.GetHits(search_id, amount);
 						
 						System.Console.WriteLine("ze hits!");
 
-						if (cur_search_id == search_id) {
+						if (cur_search_id == unique_search_id) {
 
 							System.Console.WriteLine("hits ok");
 
@@ -286,43 +305,20 @@
 								callback(real_results);
 								
 								// We don't want more results
-								hits_added_callbacks.Remove(session_id);
+								hits_added_callbacks.Remove(search_id);
 							}));
 						}
 					}));
 
-					System.Console.WriteLine("yes");
-
-					hits_done_callbacks.Add(session_id, delegate  { 
+					hits_done_callbacks.Add(search_id, delegate  { 
 						System.Console.WriteLine("closing session {0}", session_id);
 						bus_search.CloseSession(session_id);
-						hits_added_callbacks.Remove(session_id);
+						hits_added_callbacks.Remove(search_id);
 
 						if (!got_results) // no results
 							callback(new List<Tuple<string[], File>>());
 					});
 
-					System.Console.WriteLine("yes!");
-
-					string xml_string = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
-"<request xmlns=\"http://freedesktop.org/standards/xesam/1.0/query\";>" +
-"  <query>" +
-"    <and> " +
-"    <inSet> " +
-"      <field name=\"mime\"/> " +
-Helpers.reduce_to_string(Helpers.map_strings(string_start(), supported_mimetypes, string_end()))  +
-"    </inSet> " +
-"    <fullText> " +
-"      <string>" + search_string + "</string> " +
-"    </fullText> " +
-"    </and> " +
-"  </query> " +
-"</request> ";
-
-					System.Console.WriteLine(xml_string);
-
-					bus_search.NewSearch(session_id, xml_string);
-
 					bus_search.StartSearch(session_id);
 	            }
 	        });



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