Exemple #1
0
		        public Hit (uint id, Beagle.Hit hit, string[] fields, Query query)
			{
				this.id = id;
				bHit = hit;
				hitValue = new object[fields.Length];
				int i = 0;

				uri = hit.Uri;

				foreach (string field in fields) {
					// We add String.Empty to attributes because they may be null and we cannot
					// return null objects over DBus
					string[] bfields = Ontologies.XesamToBeagleField (field);

					switch (bfields [0]) {
					case "uri":
						hitValue [i++] = hit.Uri.ToString ();
						break;

					case "mimetype":
						hitValue [i++] = hit.MimeType + String.Empty;
						break;

					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, and we're always using strings
						
						List<string> values = new List<string> ();

						foreach (string bfield in bfields) {
							string[] prop = hit.GetProperties (bfield);

							if (prop != null)
								values.AddRange (prop);
						}

						if (values.Count == 0)
							// No values found
							hitValue [i++] = String.Empty;
						else if (values.Count == 1)
							// Only one value -- return as string
							hitValue [i++] = values [0];
						else
							// Multiple values -- returns as string[]
							hitValue [i++] = values.ToArray ();

						break;
					}
				}
			}
		public override Tile BuildTile (Beagle.Hit hit, Beagle.Query query)
		{
			if (ditem == IntPtr.Zero)
				return null;

			if (hit ["fixme:NoDisplay"] == "true")
				return null;

			string notshow = gnome_desktop_item_get_string (ditem, "NotShowIn");
			if (notshow != null && notshow.IndexOf ("GNOME") != -1)
				return null;

			string onlyshow = gnome_desktop_item_get_string (ditem, "OnlyShowIn");
			if (onlyshow != null && onlyshow.IndexOf ("GNOME") == -1)
				return null;


			if (!checked_gconf)
				CheckLockdown();

			if (disable_command_line) {
				string[] categories = hit.GetProperties ("fixme:Categories");

				if (categories != null && Array.IndexOf (categories, "TerminalEmulator") != -1)
					return null;
			}

			return new Application (hit, query, ditem);
		}