Two patches for Xesam adaptor

"Anders Rune Jensen" <[email protected]>
Newsgroups gmane.comp.gnome.dashboard.devel
Message-ID <[email protected]>
Hello

Two patches for the xesam adaptor:

title: Fixes title, as title is apparently dc:title in beagle and not title
snippet: implements snippet support

-- 
Anders Rune Jensen
http://people.iola.dk/anders/

_______________________________________________
Dashboard-hackers mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/dashboard-hackers
title.diff (text/x-patch, 532 B)
--- /home/arj/source/beagle-xesam/src/Ontologies.cs	2007-12-18 15:30:05.000000000 +0100
+++ src/Ontologies.cs	2008-01-09 16:53:00.000000000 +0100
@@ -48,8 +48,8 @@
 			{
 				fields_mapping = new Dictionary<string, string> ();
 
-				fields_mapping.Add ("dc:title", "title");
-				fields_mapping.Add ("xesam:title", "title");
+				fields_mapping.Add ("dc:title", "dc:title");
+				fields_mapping.Add ("xesam:title", "dc:title");
 
 				fields_mapping.Add ("dc:author", "author");
 				fields_mapping.Add ("xesam:author", "author");
snippet-1.diff (text/x-patch, 424 B)
--- /home/arj/source/beagle-xesam/src/Ontologies.cs	2007-12-18 15:30:05.000000000 +0100
+++ src/Ontologies.cs	2008-01-09 16:53:00.000000000 +0100
@@ -73,6 +73,8 @@
 
 				fields_mapping.Add ("xesam:fileExtension", "beagle:FilenameExtension");
 				fields_mapping.Add ("fileExtension", "beagle:FilenameExtension");
+
+				fields_mapping.Add ("snippet", "snippet");
 			}
 
 			private static void InitializeSourcesMapping ()
snippet-2.diff (text/x-patch, 1.6 KB)
--- /home/arj/source/beagle-xesam/src/Search.cs	2007-12-21 12:10:34.000000000 +0100
+++ src/Search.cs	2008-01-09 17:08:57.000000000 +0100
@@ -53,7 +53,7 @@
 				get { return bHit; }
 			}
 
-			public Hit (uint id, Beagle.Hit hit, string[] fields)
+		        public Hit (uint id, Beagle.Hit hit, string[] fields, Query query)
 			{
 				this.id = id;
 				bHit = hit;
@@ -77,7 +77,13 @@
 					case "date":
 						hitValue [i++] = hit.Timestamp.ToString ("s");
 						break;
-						
+
+					case "snippet":
+					        SnippetRequest sreq = new SnippetRequest (query, hit);
+						SnippetResponse sresp = (SnippetResponse) sreq.Send ();
+						hitValue [i++] = sresp.Snippet != null ? sresp.Snippet : String.Empty;
+						break;
+					    
 					default:
 						//FIXME: This *will* break since we don't know what the expected
 						//type here is
@@ -211,7 +217,7 @@
 				mutex.WaitOne ();
 
 				foreach (uint id in ids) {
-					Hit hit = new Hit (id, hits [id].BeagleHit, fields);
+				        Hit hit = new Hit (id, hits [id].BeagleHit, fields, query);
 					ret.Add (hit.Value);
 				}
 
@@ -227,8 +233,8 @@
 				// cache the hits and keep them nice and safe
 				Console.Error.WriteLine ("{0}: Got some hits: {1}", id, response.Hits.Count);
 				foreach (Beagle.Hit bHit in response.Hits) {
-				    //					Console.Error.WriteLine ("+Hit: {0}", bHit.Uri);
-					newHits.Add (hitCount++, new Xesam.Hit (hitCount, bHit, parentSession.HitFields));
+					Console.Error.WriteLine ("+Hit: {0}", bHit.Uri);
+					newHits.Add (hitCount++, new Xesam.Hit (hitCount, bHit, parentSession.HitFields, query));
 				}
 
 				if (newHits.Count > 0 && HitsAddedHandler != null) {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.