2 using System
.Diagnostics
;
6 namespace Search
.Tiles
{
8 public class MailAttachmentActivator
: TileActivator
{
10 public MailAttachmentActivator () : base ()
12 AddSupportedFlavor (new HitFlavor (null, "MailMessage", null));
15 public override Tile
BuildTile (Beagle
.Hit hit
, Beagle
.Query query
)
17 return new MailAttachment (hit
, query
);
20 public override bool Validate (Beagle
.Hit hit
)
22 if (! base.Validate (hit
))
25 string str
= hit
.GetFirstProperty ("parent:fixme:hasAttachments");
26 if (hit
.ParentUri
== null || str
== null || str
== "false")
29 str
= hit
.GetFirstProperty ("fixme:attachment_title");
30 if (str
== null || str
== "")
39 public class MailAttachment
: TileTemplate
{
41 public MailAttachment (Beagle
.Hit hit
, Beagle
.Query query
) : base (hit
, query
)
43 Group
= TileGroup
.Documents
;
44 Title
= Hit
["fixme:attachment_title"];
45 Description
= Catalog
.GetString ("Mail attachment");
48 // FIXME: This needs better handling in the daemon, attachments
50 private static bool IsAttachment (Beagle
.Hit hit
)
52 // check if there is parent and parent has attachments
53 string str
= hit
["parent:fixme:hasAttachments"];
54 return (hit
.ParentUri
!= null && str
!= null && (str
== "true"));
57 private static string GetHitProperty (Beagle
.Hit hit
, string name
)
59 // FIXME: We should handle this case better, but
60 // for now, if we match an attachment, we just want
61 // to display the properties for the parent message.
62 if (!IsAttachment (hit
))
65 return hit
["parent:" + name
];
68 public override void Open ()
72 if (Hit
.ParentUri
!= null)
73 p
= MailMessage
.GetClientProcess (GetHitProperty (Hit
, "fixme:client"), Hit
.EscapedParentUri
);
75 p
= MailMessage
.GetClientProcess (GetHitProperty (Hit
, "fixme:client"), Hit
.EscapedUri
);
83 } catch (SafeProcessException e
) {
84 Console
.WriteLine ("Unable to run {0}: {1}", p
.Arguments
[0], e
.Message
);