public Tile (Hit hit, Query query) : base () { base.AboveChild = true; base.AppPaintable = true; base.CanFocus = true; this.hit = hit; this.query = query; this.timestamp = hit.Timestamp; this.score = hit.Score; Gtk.Drag.SourceSet (this, Gdk.ModifierType.Button1Mask, targets, Gdk.DragAction.Copy | Gdk.DragAction.Move); int pad = (int)StyleGetProperty ("focus-line-width") + (int)StyleGetProperty ("focus-padding") + 1; hbox = new Gtk.HBox (false, 5); hbox.BorderWidth = (uint)(pad + Style.Xthickness); hbox.Show (); icon = new Gtk.Image (); icon.Show (); hbox.PackStart (icon, false, false, 0); Add (hbox); }
private void AddField (Hit hit, String key, String name, StringBuilder builder) { if (hit [key] != null) { builder.Append ("<tr><td>" + name + ":</td>"); builder.Append ("<td>" + hit [key] + "</td></tr>"); } }
public static LibraryTrackInfo HitToTrack(Hit hit) { uint track_number = 0; uint track_count = 0; int year = 0; try { track_number = UInt32.Parse(hit.GetFirstProperty("fixme:tracknumber")); } catch { } try { track_count = UInt32.Parse(hit.GetFirstProperty("fixme:trackcount")); } catch { } try { year = Int32.Parse(hit.GetFirstProperty("fixme:year")); } catch { } try { LibraryTrackInfo track = new LibraryTrackInfo( new SafeUri(hit.Uri), hit.GetFirstProperty("fixme:artist"), hit.GetFirstProperty("fixme:album"), hit.GetFirstProperty("fixme:title"), hit.GetFirstProperty("fixme:genre"), track_number, track_count, year, TimeSpan.Zero, null, RemoteLookupStatus.NoAttempt); return track; } catch { return null; } }
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; } } }
static string RemapUriToPath(Hashtable all_hits_by_uri, Hit hit) { string exact_name; if (hit.GetFirstProperty(Property.IsChildPropKey) == "true") { exact_name = hit.GetFirstProperty("parent:" + Property.ExactFilenamePropKey); } else { exact_name = hit.GetFirstProperty(Property.ExactFilenamePropKey); } string parent_uri_str = hit.GetFirstProperty(Property.ParentDirUriPropKey); if (parent_uri_str == null) { return(exact_name); } else { return(Path.Combine(RemapUriToPath(all_hits_by_uri, (Hit)all_hits_by_uri [parent_uri_str]), exact_name)); } }
private string HTMLRenderSingleHit (Hit hit) { if (hit ["Icon"] == null && hit ["Text"] == null) return ""; string html; html = String.Format ( "<table border=0 cellpadding=0 cellspacing=0>" + "<tr>"); if (hit ["Icon"] != null) html += String.Format ( " <td valign=center>" + + " <a href=\"{0}\"><img src=\"{1}\" border=0></a>" + " </td>", hit ["Action"], hit ["Icon"]); html += String.Format ("<td> </td>" + " <td valign=top>" + " <a href=\"{0}\" style=\"text-decoration: none;\">{1}" + " </td>" + "</tr>" + "</table>", hit ["Action"], hit ["Text"]); return html; }
public SnippetRequest (Query query, Hit hit) : base (false) { this.QueryTerms = new string [query.StemmedText.Count]; int i = 0; foreach (string term in query.StemmedText) { this.QueryTerms [i] = term; ++i; } this.Hit = hit; }
virtual protected string BuildHtml (Hit hit) { StringBuilder htmlBuilder = new StringBuilder (""); StreamReader sr = DataBarn.GetText (templateName); string line; while ((line = sr.ReadLine ()) != null) TransformLineOfHtml (line, htmlBuilder); return htmlBuilder.ToString (); }
private void SingleHitToHtml (Hit hit, bool color_band, StringBuilder builder) { builder.Append ("<table"); if (color_band) builder.Append (" bgcolor=\"#eeeeee\""); builder.Append (" width=\"100%\">"); builder.Append ("<tr><td colspan=2>" + hit ["Name"] + "</td></tr>"); AddField (hit, "Email1", "Email", builder); AddField (hit, "Email2", "Email", builder); AddField (hit, "Email3", "Email", builder); AddField (hit, "HomePhone", "Phone", builder); AddField (hit, "HomePhone2", "Phone2", builder); AddField (hit, "MobilePhone", "Mobile", builder); builder.Append ("</table>"); }
//////////////////////////////////// private Tile HitToTile (Hit hit) { Tile t = null; // FIXME: We don't want to allow heterogenous containers. switch (hit.Type) { case "Contact": t = new Tile ("contact.html", hit); break; case "File": t = new Tile ("file-generic.html", hit); break; case "IMLog": t = new Tile ("im-log.html", hit); break; case "MailMessage": string icon = "mail.png"; if (hit ["_IsAnswered"] != null) icon = "mail-replied.png"; else if (hit ["_IsSeen"] != null) icon = "mail-read.png"; hit ["mail:Icon"] = icon; if (hit ["_IsSent"] != null) t = new Tile ("email-sent.html", hit); else t = new Tile ("email.html", hit); break; case "WebHistory": t = new Tile ("web-history.html", hit); break; case "WebLink": if (hit.Source == "Google") t = new Tile ("google.html", hit); break; } return t; }
static string RemapUriToPath (Hashtable all_hits_by_uri, Hit hit) { string exact_name; if (hit.GetFirstProperty (Property.IsChildPropKey) == "true") exact_name = hit.GetFirstProperty ("parent:" + Property.ExactFilenamePropKey); else exact_name = hit.GetFirstProperty (Property.ExactFilenamePropKey); string parent_uri_str = hit.GetFirstProperty (Property.ParentDirUriPropKey); if (parent_uri_str == null) return exact_name; else return Path.Combine (RemapUriToPath (all_hits_by_uri, (Hit) all_hits_by_uri [parent_uri_str]), exact_name); }
public void Add (Hit hit) { HitFlavor flavor = HitToHitFlavor.Get (hit); if (flavor == null) return; object[] args = new object [1]; args[0] = hit; Tile tile = (Tile) Activator.CreateInstance (flavor.TileType, args); tile.Hit = hit; tile.Uri = hit.Uri; tile.Query = this.Query; if (hit_collection.Add (hit, tile)) Changed (); //Console.WriteLine ("+ {0}", hit.Uri); }
int IComparer.Compare(Object x, Object y) { Hit MatchX = (Hit)x; Hit MatchY = (Hit)y; float ScoreX; float ScoreY; // These try..catch blocks are here in case we receive // a match without a Score property. (Assume Score = 0) try { ScoreX = Single.Parse(Convert.ToString(MatchX ["Score"])); } catch { ScoreX = 0; } try { ScoreY = Single.Parse(Convert.ToString(MatchY ["Score"])); } catch { ScoreY = 0; } if (MatchX == null && MatchY == null) { return(0); } else if (MatchX == null && MatchY != null) { return((this.m_direction == SortDirection.Ascending) ? -1 : 1); } else if (MatchX != null && MatchY == null) { return((this.m_direction == SortDirection.Ascending) ? 1 : -1); } else { return((this.m_direction == SortDirection.Ascending) ? ScoreX.CompareTo(ScoreY) : ScoreY.CompareTo(ScoreX)); } // end if } // end IComparer.Compare
// Return true if we need a refresh after this add. private bool AddInRightPlace(Hit hit) { if (hits.Count == 0) { hits.Add(hit); if (first == 0) { return(true); } } else { int i = hits.BinarySearch(hit); hits.Insert(i < 0 ? ~i : i, hit); if (hits.Count >= first && i < first + displayedCount) { return(true); } } return(false); }
public void Add (Hit hit) { bool needRefresh = false; lock (this) { if (ProcessHit (hit)) needRefresh = AddInRightPlace (hit); } // ScheduleRefresh needs to acquire a lock, // so we wait until hits is unlocked before // calling it. if (needRefresh) ScheduleRefresh (100); }
private void HTMLRenderSingleWebLink (Hit hit, bool color_band, XmlWriter xw) { string icon = CompositeEmblemIcon (Favicons.GetIconPath (hit.Uri)); string Title = (string)hit ["Title"]; string Score = Convert.ToString (hit.Score); if (Score == null || Score == "") Score = "n/a"; xw.WriteStartElement ("tr"); xw.WriteStartElement ("td"); xw.WriteAttributeString ("valign", "center"); xw.WriteStartElement ("a"); xw.WriteAttributeString ("href", hit.Uri); xw.WriteStartElement ("img"); xw.WriteAttributeString ("src", icon); xw.WriteAttributeString ("border", "0"); xw.WriteEndElement (); // img xw.WriteEndElement (); // a href xw.WriteEndElement (); // td xw.WriteStartElement ("td"); xw.WriteRaw (" "); xw.WriteEndElement (); // td xw.WriteStartElement ("td"); xw.WriteAttributeString ("valign", "top"); xw.WriteRaw (Title); xw.WriteStartElement ("font"); xw.WriteAttributeString ("size", "-2"); xw.WriteAttributeString ("color", "#666666"); xw.WriteString (" (score=" + Score + ")"); xw.WriteEndElement (); // font xw.WriteStartElement ("br"); xw.WriteEndElement (); // br xw.WriteStartElement ("font"); xw.WriteAttributeString ("size", "-1"); xw.WriteAttributeString ("color", "#666666"); xw.WriteStartElement ("a"); xw.WriteAttributeString ("href", hit.Uri); xw.WriteAttributeString ("style", "text-decoration: none;"); xw.WriteString (hit.Uri); xw.WriteEndElement (); // a xw.WriteEndElement (); // font xw.WriteEndElement (); // td xw.WriteEndElement (); // tr }
public Tile(string templateName, Hit hit) { this.templateName = templateName; this.hit = hit; }
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; } } }
static int DumpOneIndex_Metadata(string index_name, ArrayList uris, bool show_properties) { LuceneQueryingDriver driver; driver = new LuceneQueryingDriver(index_name, -1, true); Hashtable all_hits_by_uri = null; ArrayList all_hits = null; if (uris.Count == 0 || index_name == "FileSystemIndex") { all_hits_by_uri = driver.GetAllHitsByUri(); all_hits = new ArrayList(all_hits_by_uri.Values); } // A hard-wired hack if (index_name == "FileSystemIndex") { foreach (Hit hit in all_hits) { string internal_uri; if (hit [Property.IsChildPropKey] == "true") { string path = RemapUriToPath(all_hits_by_uri, hit); internal_uri = UriFu.UriToEscapedString(hit.ParentUri); hit.ParentUri = UriFu.PathToFileUri(path); hit.Uri = UriFu.AddFragment(UriFu.PathToFileUri(path), hit.Uri.Fragment, true); } else { internal_uri = UriFu.UriToEscapedString(hit.Uri); hit.Uri = UriFu.PathToFileUri(RemapUriToPath(all_hits_by_uri, hit)); hit.AddProperty(Property.NewUnsearched("beagle:InternalUri", internal_uri)); } } } ArrayList matching_hits; if (uris.Count == 0) { matching_hits = all_hits; } else { matching_hits = new ArrayList(driver.GetHitsForUris(RemapUris(driver, uris))); if (index_name == "FileSystemIndex") { for (int i = 0; i < matching_hits.Count; i++) { Hit hit = (Hit)matching_hits [i]; Hit mapped_hit = (Hit)all_hits_by_uri [hit.Uri]; matching_hits [i] = mapped_hit; } } } matching_hits.Sort(new HitByUriComparer()); foreach (Hit hit in matching_hits) { if (!show_properties) { Console.WriteLine("{0}: {1}", index_name, hit.Uri); continue; } Console.WriteLine(" Index: {0}", index_name); Console.WriteLine(" Uri: {0}", hit.Uri); if (hit.ParentUri != null) { Console.WriteLine("Parent: {0}", hit.ParentUri); } Console.WriteLine(" MimeT: {0}", hit.MimeType); Console.WriteLine(" Type: {0}", hit.Type); Console.WriteLine("Source: {0}", hit.Source); ArrayList props; props = new ArrayList(hit.Properties); props.Sort(); foreach (Property prop in props) { char [] legend = new char [4]; legend [0] = prop.IsMutable ? 'm' : ' '; legend [1] = prop.IsSearched ? 's' : ' '; legend [2] = prop.IsPersistent ? 'p' : ' '; legend [3] = prop.Type == PropertyType.Text ? 't' : ' '; Console.WriteLine(" Prop: [{0}] {1} = '{2}'", new String(legend), prop.Key, prop.Value); } Console.WriteLine(); } return(matching_hits.Count); }
//Returns: null, if Hit does not match any filter // Uri, after Translation public string TranslateHit (Hit hit) { if ((hit == null) || (matchers.Count == 0)) return null; string uri = hit.UriAsString; string newuri = null; foreach (SimpleMatcher matcher in matchers) { if (uri.IndexOf (matcher.Match) == -1) continue; newuri = uri.Replace (matcher.Match, matcher.Rewrite); //Console.WriteLine("TranslateHit: " + newuri); return newuri; } return null; //Hit does not match any specified filter }
protected void OpenFromMime (Hit hit) { string command = null; string uri = null, path = null; string mimetype = hit.MimeType; // FIXME: This is evil. Nautilus should be handling // inode/directory, not just x-directory/normal if (mimetype == "inode/directory") mimetype = "x-directory/normal"; // FIXME: I'm not sure that opening the parent // URI (if present) is the right thing to do in // all cases, but it does work for all our // current cases. if (hit.ParentUri != null) uri = hit.EscapedParentUri; else uri = hit.EscapedUri; #if ENABLE_DESKTOP_LAUNCH RunDefaultHandler ("desktop-launch", uri); #elif ENABLE_XDG_OPEN RunDefaultHandler ("xdg-open", uri); #else MimeApplication app; app = Mime.GetDefaultApplication (mimetype); if (app == null) { Console.WriteLine ("Can't open MimeType '{0}'", mimetype); return; } bool expect_uris = app.SupportsUris (); path = hit.Path; GLib.List list = new GLib.List ((IntPtr) 0); list.Append (expect_uris ? uri : path); Gnome.Vfs.Result result = app.Launch (list); if (result != Gnome.Vfs.Result.Ok) Console.WriteLine ("Error in opening {0}: {1}", uri, result); #endif }
public void Initialize(Hit hit) { // Set all the properties based on info from the provided Match this.subject = Convert.ToString(hit ["Subject"]); this.sender = Convert.ToString(hit ["From"]); this.recipient = Convert.ToString(hit ["To"]); this.sentdate = DateTime.Parse(Convert.ToString(hit ["SentDate"])); this.uid = Convert.ToString(hit ["UID"]); // this.sendername = this.sender.Substring (0, (this.sender.LastIndexOf ("<") - 1)); // Parse the message flags int flags = int.Parse(Convert.ToString(hit ["Flags"])); if ((flags & (int)CamelFlags.ANSWERED) == (int)CamelFlags.ANSWERED) { this.hasreply = true; } if ((flags & (int)CamelFlags.DELETED) == (int)CamelFlags.DELETED) { this.isdeleted = true; } if ((flags & (int)CamelFlags.DRAFT) == (int)CamelFlags.DRAFT) { this.isdraft = true; } if ((flags & (int)CamelFlags.FLAGGED) == (int)CamelFlags.FLAGGED) { this.isflagged = true; } if ((flags & (int)CamelFlags.SEEN) == (int)CamelFlags.SEEN) { this.isnew = false; } else { this.isnew = true; } if ((flags & (int)CamelFlags.ATTACHMENTS) == (int)CamelFlags.ATTACHMENTS) { this.hasattachment = true; } if ((flags & (int)CamelFlags.ANSWERED_ALL) == (int)CamelFlags.ATTACHMENTS) { this.hasreply = true; } // Generate the icon if (this.hasreply) { this.icon = "internal:mail-replied.png"; } else if (this.isnew) { this.icon = "internal:mail-new.png"; } else { this.icon = "internal:mail-read.png"; } }
private void HTMLRenderSingleMailMessage(Hit hit, bool color_band, XmlWriter xw) { // Make the date look pretty string maildate = Convert.ToString(hit ["SentDate"]); string ParsedDate = ParseMailDate(maildate); Message msg = new Message(); msg.Initialize(hit); // Console.WriteLine ("To: {0}\nFrom: {1}\nSubject: {2}\nDate: {3}", // msg.Recipient, msg.Sender, msg.Subject, msg.SentDate); xw.WriteStartElement("tr"); if (color_band) { xw.WriteAttributeString("bgcolor", "#eeeeee"); } xw.WriteStartElement("a"); xw.WriteAttributeString("href", "exec:evolution-1.5 " + hit.Uri); // FIXME: Probably unsafe xw.WriteAttributeString("style", "text-decoration: none; color: black;"); // new / read / replied-to icon xw.WriteStartElement("td"); xw.WriteAttributeString("width", "1%"); xw.WriteAttributeString("valign", "top"); xw.WriteStartElement("img"); xw.WriteAttributeString("border", "0"); xw.WriteAttributeString("src", msg.Icon); xw.WriteEndElement(); // img xw.WriteEndElement(); // td // sender (mail from) xw.WriteStartElement("td"); // xw.WriteAttributeString ("nowrap", "true"); xw.WriteAttributeString("width", "98%"); xw.WriteRaw(MarkupStatus(msg.GetSenderName(), msg)); xw.WriteEndElement(); // td // date xw.WriteStartElement("td"); xw.WriteAttributeString("colspan", "2"); xw.WriteAttributeString("align", "right"); xw.WriteAttributeString("nowrap", "1"); xw.WriteAttributeString("valign", "top"); xw.WriteAttributeString("width", "1%"); xw.WriteRaw(MarkupStatus(ParsedDate, msg)); xw.WriteEndElement(); // td xw.WriteEndElement(); // a href xw.WriteEndElement(); // tr xw.WriteStartElement("tr"); if (color_band) { xw.WriteAttributeString("bgcolor", "#eeeeee"); } xw.WriteStartElement("a"); xw.WriteAttributeString("href", "exec:evolution-1.5 " + hit.Uri); // FIXME: Probably unsafe xw.WriteAttributeString("style", "text-decoration: none; color: black"); // attachment icon xw.WriteStartElement("td"); xw.WriteAttributeString("width", "1%"); xw.WriteAttributeString("valign", "top"); xw.WriteAttributeString("align", "right"); if (msg.HasAttachment) { xw.WriteStartElement("img"); xw.WriteAttributeString("border", "0"); xw.WriteAttributeString("src", "internal:attachment.png"); xw.WriteEndElement(); // img } xw.WriteEndElement(); // td // subject xw.WriteStartElement("td"); xw.WriteAttributeString("colspan", "2"); xw.WriteAttributeString("width", "98%"); xw.WriteAttributeString("valign", "top"); xw.WriteStartElement("font"); xw.WriteAttributeString("color", "#666666"); xw.WriteRaw(MarkupStatus(msg.Subject, msg)); xw.WriteEndElement(); // font xw.WriteEndElement(); // td xw.WriteEndElement(); // a href xw.WriteEndElement(); // tr }
public ISnippetReader GetSnippet (string[] query_terms, Hit hit, bool full_text, int ctx_length, int snp_length) { string source = hit ["beagle:Source"]; hit ["beagle:Source"] = hit ["beagle:OrigSource"]; string network_node = hit ["beagle:NetworkNode"]; SnippetReader snippet_reader = null; // FIXME: Creating a snippet request, registering transports, all of this // doing everytime for hundreds of hits may become quite expensive. // In that case, pre generate one snippetrequest and use it over and over. // Form a correct snippet request SnippetRequest sreq = new SnippetRequest (); sreq.Hit = hit; sreq.QueryTerms = query_terms; sreq.FullText = full_text; sreq.ContextLength = ctx_length; sreq.SnippetLength = snp_length; // fake a blocking snippet retrieval sreq.RegisterAsyncResponseHandler (typeof (SnippetResponse), delegate (ResponseMessage response) { if (response is ErrorResponse) { Log.Error ("Error retrieval snippet for {0} from network node {1}", hit.Uri, network_node); return; } snippet_reader = new SnippetReader ((SnippetResponse) response); }); List<string[]> network_services = Conf.Networking.GetListOptionValues (Conf.Names.NetworkServices); foreach (string[] service in network_services) { if (network_node != service [0]) continue; sreq.Transports.Clear (); sreq.RegisterTransport (new HttpTransport (service [1])); // fake a blocking snippet retrieval try { sreq.SendAsyncBlocking (); } catch (Exception e) { Log.Debug (e, "Error while requesting snippet from {0} for {1}", service [1], hit.Uri); } break; } hit ["beagle:Source"] = source; // reset source return snippet_reader; }
public bool IsMatch (Hit hit) { return (uri == null || StringFu.GlobMatch (uri, hit.EscapedUri)) && (type == null || StringFu.GlobMatch (type, hit.Type)) && (mimetype == null || StringFu.GlobMatch (mimetype, hit.MimeType)); }
private void HTMLRenderSingleFile (Hit hit, bool color_band, XmlWriter xw) { if (! hit.IsFile) return; string Text = hit.FileName; string Icon = BU.GnomeIconLookup.LookupMimeIcon (hit.MimeType, (Gtk.IconSize) 48); string Score = Convert.ToString (hit.Score); if (Score == null || Score == "") Score = "n/a"; // DEBUG //Console.WriteLine ("File name: {0}", file.FullName); //Console.WriteLine ("Creation time: {0}", file.CreationTime); //Console.WriteLine ("Last Access time: {0}", file.LastAccessTime); //Console.WriteLine ("Last Write Time: {0}", file.LastWriteTime); //Console.WriteLine ("Size: {0}", file.Length); FileInfo info = hit.FileInfo; string LastModifiedDate = info.LastWriteTime.ToLongDateString (); string LastAccessedDate = info.LastAccessTime.ToLongDateString (); xw.WriteStartElement ("tr"); if (color_band) // highlight every other row xw.WriteAttributeString ("bgcolor", "#eeeeee"); //originally #f6f2f6 xw.WriteStartElement ("td"); xw.WriteAttributeString ("valign", "top"); xw.WriteAttributeString ("align", "left"); // Show the file's icon (and make it a link) xw.WriteStartElement ("a"); // link String href = hit.Uri; if (hit.MimeType != null) href += " " + hit.MimeType; xw.WriteAttributeString ("href", href); xw.WriteStartElement ("img"); // icon xw.WriteAttributeString ("src", Icon); xw.WriteAttributeString ("border", "0"); xw.WriteEndElement (); // img xw.WriteEndElement (); // a xw.WriteEndElement (); // td xw.WriteStartElement ("td"); xw.WriteAttributeString ("valign", "top"); xw.WriteAttributeString ("align", "left"); xw.WriteAttributeString ("width", "100%"); xw.WriteStartElement ("font"); // Make the font smaller to fit window width // Print the filename (w/ hyperlink) xw.WriteStartElement ("a"); xw.WriteAttributeString ("href", href); xw.WriteStartElement ("font"); xw.WriteAttributeString ("size", "+1"); xw.WriteString (Text); xw.WriteEndElement (); // font xw.WriteEndElement (); // a href xw.WriteStartElement ("font"); xw.WriteAttributeString ("color", "#666666"); xw.WriteString (" (" + Score + ")"); xw.WriteEndElement (); // font xw.WriteStartElement ("br"); xw.WriteEndElement (); // br // Print 'Last modified: date' xw.WriteStartElement ("font"); xw.WriteAttributeString ("color", "#666666"); xw.WriteString ("Last modified " + LastModifiedDate); xw.WriteEndElement (); // font xw.WriteStartElement ("br"); xw.WriteEndElement (); // br // FIXME: // Last accessed isn't very useful, since it will just // tell us the last time the file crawler ran, right? // We really want to know the last time the *user* accessed // the file. // Print 'Last accessed: date' xw.WriteStartElement ("font"); xw.WriteAttributeString ("color", "#666666"); xw.WriteString ("Last accessed " + LastAccessedDate); xw.WriteEndElement (); // font xw.WriteEndElement (); // font xw.WriteEndElement (); // td xw.WriteEndElement (); // tr }
public ISnippetReader GetSnippet (string[] query_terms, Hit hit, bool full_text, int ctx_length, int snp_length) { return null; }
//Returns: false, if Hit does not match any filter // true, if Hit URI is part of any specified filter public bool FilterHit (Hit hit) { if ((hit == null) || (matchers.Count == 0)) return false; string uri = hit.UriAsString; foreach (SimpleMatcher matcher in matchers) { if (uri.IndexOf (matcher.Match) == -1) continue; return hit.IsFile; //return true; } return false; }
private void HTMLRenderSingleMailMessage (Hit hit, bool color_band, XmlWriter xw) { // Make the date look pretty string maildate = Convert.ToString (hit ["SentDate"]); string ParsedDate = ParseMailDate (maildate); Message msg = new Message (); msg.Initialize (hit); // Console.WriteLine ("To: {0}\nFrom: {1}\nSubject: {2}\nDate: {3}", // msg.Recipient, msg.Sender, msg.Subject, msg.SentDate); xw.WriteStartElement ("tr"); if (color_band) xw.WriteAttributeString ("bgcolor", "#eeeeee"); xw.WriteStartElement ("a"); xw.WriteAttributeString ("href", "exec:evolution-1.5 " + hit.Uri); // FIXME: Probably unsafe xw.WriteAttributeString ("style", "text-decoration: none; color: black;"); // new / read / replied-to icon xw.WriteStartElement ("td"); xw.WriteAttributeString ("width", "1%"); xw.WriteAttributeString ("valign", "top"); xw.WriteStartElement ("img"); xw.WriteAttributeString ("border", "0"); xw.WriteAttributeString ("src", msg.Icon); xw.WriteEndElement (); // img xw.WriteEndElement (); // td // sender (mail from) xw.WriteStartElement ("td"); // xw.WriteAttributeString ("nowrap", "true"); xw.WriteAttributeString ("width", "98%"); xw.WriteRaw (MarkupStatus (msg.GetSenderName (), msg)); xw.WriteEndElement (); // td // date xw.WriteStartElement ("td"); xw.WriteAttributeString ("colspan", "2"); xw.WriteAttributeString ("align", "right"); xw.WriteAttributeString ("nowrap", "1"); xw.WriteAttributeString ("valign", "top"); xw.WriteAttributeString ("width", "1%"); xw.WriteRaw (MarkupStatus (ParsedDate, msg)); xw.WriteEndElement (); // td xw.WriteEndElement (); // a href xw.WriteEndElement (); // tr xw.WriteStartElement ("tr"); if (color_band) xw.WriteAttributeString ("bgcolor", "#eeeeee"); xw.WriteStartElement ("a"); xw.WriteAttributeString ("href", "exec:evolution-1.5 " + hit.Uri); // FIXME: Probably unsafe xw.WriteAttributeString ("style", "text-decoration: none; color: black"); // attachment icon xw.WriteStartElement ("td"); xw.WriteAttributeString ("width", "1%"); xw.WriteAttributeString ("valign", "top"); xw.WriteAttributeString ("align", "right"); if (msg.HasAttachment) { xw.WriteStartElement ("img"); xw.WriteAttributeString ("border", "0"); xw.WriteAttributeString ("src", "internal:attachment.png"); xw.WriteEndElement (); // img } xw.WriteEndElement (); // td // subject xw.WriteStartElement ("td"); xw.WriteAttributeString ("colspan", "2"); xw.WriteAttributeString ("width", "98%"); xw.WriteAttributeString ("valign", "top"); xw.WriteStartElement ("font"); xw.WriteAttributeString ("color", "#666666"); xw.WriteRaw (MarkupStatus (msg.Subject, msg)); xw.WriteEndElement (); // font xw.WriteEndElement (); // td xw.WriteEndElement (); // a href xw.WriteEndElement (); // tr }
public ISnippetReader GetSnippet (string[] query_terms, Hit hit, bool full_text, int ctx_length, int snp_length) { if (hit == null) return null; // Sanity-check: make sure this Hit actually came out of this Queryable if (QueryDriver.GetQueryable (hit.Source) != this) { string msg = String.Format ("Queryable mismatch in GetSnippet: {0} vs {1}", hit.Source, this); throw new Exception (msg); } try { return iqueryable.GetSnippet (query_terms, hit, full_text, ctx_length, snp_length); } catch (Exception ex) { Logger.Log.Warn (ex, "Caught exception calling DoQuery on '{0}'", Name); } return null; }
public Tile (string templateName, Hit hit) { this.templateName = templateName; this.hit = hit; }
// Return true if we need a refresh after this add. private bool AddInRightPlace (Hit hit) { if (hits.Count == 0) { hits.Add (hit); if (first == 0) return true; } else { int i = hits.BinarySearch (hit); hits.Insert (i < 0 ? ~i : i, hit); if (hits.Count >= first && i < first + displayedCount) return true; } return false; }
protected override bool ProcessHit (Hit hit) { Tile tile = HitToTile (hit); if (tile == null) return false; tiles [hit] = tile; return true; }
private int GetHitInteger(Hit hit, string key) { try { return Int32.Parse (hit.GetFirstProperty (key)); } catch { return 0; } }
protected virtual bool ProcessHit(Hit hit) { return(true); }
private void HTMLRenderSingleWebLink(Hit hit, bool color_band, XmlWriter xw) { string icon = CompositeEmblemIcon(Favicons.GetIconPath(hit.Uri)); string Title = (string)hit ["Title"]; string Score = Convert.ToString(hit.Score); if (Score == null || Score == "") { Score = "n/a"; } xw.WriteStartElement("tr"); xw.WriteStartElement("td"); xw.WriteAttributeString("valign", "center"); xw.WriteStartElement("a"); xw.WriteAttributeString("href", hit.Uri); xw.WriteStartElement("img"); xw.WriteAttributeString("src", icon); xw.WriteAttributeString("border", "0"); xw.WriteEndElement(); // img xw.WriteEndElement(); // a href xw.WriteEndElement(); // td xw.WriteStartElement("td"); xw.WriteRaw(" "); xw.WriteEndElement(); // td xw.WriteStartElement("td"); xw.WriteAttributeString("valign", "top"); xw.WriteRaw(Title); xw.WriteStartElement("font"); xw.WriteAttributeString("size", "-2"); xw.WriteAttributeString("color", "#666666"); xw.WriteString(" (score=" + Score + ")"); xw.WriteEndElement(); // font xw.WriteStartElement("br"); xw.WriteEndElement(); // br xw.WriteStartElement("font"); xw.WriteAttributeString("size", "-1"); xw.WriteAttributeString("color", "#666666"); xw.WriteStartElement("a"); xw.WriteAttributeString("href", hit.Uri); xw.WriteAttributeString("style", "text-decoration: none;"); xw.WriteString(hit.Uri); xw.WriteEndElement(); // a xw.WriteEndElement(); // font xw.WriteEndElement(); // td xw.WriteEndElement(); // tr }
protected virtual bool ProcessHit (Hit hit) { return true; }
private void HTMLRenderSingleFile(Hit hit, bool color_band, XmlWriter xw) { if (!hit.IsFile) { return; } string Text = hit.FileName; string Icon = BU.GnomeIconLookup.LookupMimeIcon(hit.MimeType, (Gtk.IconSize) 48); string Score = Convert.ToString(hit.Score); if (Score == null || Score == "") { Score = "n/a"; } // DEBUG //Console.WriteLine ("File name: {0}", file.FullName); //Console.WriteLine ("Creation time: {0}", file.CreationTime); //Console.WriteLine ("Last Access time: {0}", file.LastAccessTime); //Console.WriteLine ("Last Write Time: {0}", file.LastWriteTime); //Console.WriteLine ("Size: {0}", file.Length); FileInfo info = hit.FileInfo; string LastModifiedDate = info.LastWriteTime.ToLongDateString(); string LastAccessedDate = info.LastAccessTime.ToLongDateString(); xw.WriteStartElement("tr"); if (color_band) // highlight every other row { xw.WriteAttributeString("bgcolor", "#eeeeee"); //originally #f6f2f6 } xw.WriteStartElement("td"); xw.WriteAttributeString("valign", "top"); xw.WriteAttributeString("align", "left"); // Show the file's icon (and make it a link) xw.WriteStartElement("a"); // link String href = hit.Uri; if (hit.MimeType != null) { href += " " + hit.MimeType; } xw.WriteAttributeString("href", href); xw.WriteStartElement("img"); // icon xw.WriteAttributeString("src", Icon); xw.WriteAttributeString("border", "0"); xw.WriteEndElement(); // img xw.WriteEndElement(); // a xw.WriteEndElement(); // td xw.WriteStartElement("td"); xw.WriteAttributeString("valign", "top"); xw.WriteAttributeString("align", "left"); xw.WriteAttributeString("width", "100%"); xw.WriteStartElement("font"); // Make the font smaller to fit window width // Print the filename (w/ hyperlink) xw.WriteStartElement("a"); xw.WriteAttributeString("href", href); xw.WriteStartElement("font"); xw.WriteAttributeString("size", "+1"); xw.WriteString(Text); xw.WriteEndElement(); // font xw.WriteEndElement(); // a href xw.WriteStartElement("font"); xw.WriteAttributeString("color", "#666666"); xw.WriteString(" (" + Score + ")"); xw.WriteEndElement(); // font xw.WriteStartElement("br"); xw.WriteEndElement(); // br // Print 'Last modified: date' xw.WriteStartElement("font"); xw.WriteAttributeString("color", "#666666"); xw.WriteString("Last modified " + LastModifiedDate); xw.WriteEndElement(); // font xw.WriteStartElement("br"); xw.WriteEndElement(); // br // FIXME: // Last accessed isn't very useful, since it will just // tell us the last time the file crawler ran, right? // We really want to know the last time the *user* accessed // the file. // Print 'Last accessed: date' xw.WriteStartElement("font"); xw.WriteAttributeString("color", "#666666"); xw.WriteString("Last accessed " + LastAccessedDate); xw.WriteEndElement(); // font xw.WriteEndElement(); // font xw.WriteEndElement(); // td xw.WriteEndElement(); // tr }
public object[][] GetHitData (uint[] ids, string[] fields) { List<object[]> ret = new List<object[]>(); mutex.WaitOne (); foreach (uint id in ids) { Hit hit = new Hit (id, hits [id].BeagleHit, fields, query); ret.Add (hit.Value); } Console.Error.WriteLine ("GetHits(): returning {0} hits", ret.Count); mutex.ReleaseMutex (); return ret.ToArray (); }
public void Initialize (Hit hit) { // Set all the properties based on info from the provided Match this.subject = Convert.ToString (hit ["Subject"]); this.sender = Convert.ToString (hit ["From"]); this.recipient = Convert.ToString (hit ["To"]); this.sentdate = DateTime.Parse (Convert.ToString (hit ["SentDate"])); this.uid = Convert.ToString (hit ["UID"]); // this.sendername = this.sender.Substring (0, (this.sender.LastIndexOf ("<") - 1)); // Parse the message flags int flags = int.Parse (Convert.ToString (hit ["Flags"])); if ((flags & (int) CamelFlags.ANSWERED) == (int) CamelFlags.ANSWERED) this.hasreply = true; if ((flags & (int) CamelFlags.DELETED) == (int) CamelFlags.DELETED) this.isdeleted = true; if ((flags & (int) CamelFlags.DRAFT) == (int) CamelFlags.DRAFT) this.isdraft = true; if ((flags & (int) CamelFlags.FLAGGED) == (int) CamelFlags.FLAGGED) this.isflagged = true; if ((flags & (int) CamelFlags.SEEN) == (int) CamelFlags.SEEN) { this.isnew = false; } else { this.isnew = true; } if ((flags & (int) CamelFlags.ATTACHMENTS) == (int) CamelFlags.ATTACHMENTS) this.hasattachment = true; if ((flags & (int) CamelFlags.ANSWERED_ALL) == (int) CamelFlags.ATTACHMENTS) this.hasreply = true; // Generate the icon if (this.hasreply) { this.icon = "internal:mail-replied.png"; } else if (this.isnew) { this.icon = "internal:mail-new.png"; } else { this.icon = "internal:mail-read.png"; } }
public string GetSnippet (string[] query_terms, Hit hit) { string s = ""; if (hit is NetworkHit) s = ((NetworkHit)hit).snippet; return s; }