2
using System.Diagnostics;
3
using System.Collections;
7
namespace Beagle.Search.Tiles {
9
public class IMLogActivator : TileActivator {
11
public IMLogActivator () : base ()
13
AddSupportedFlavor (new HitFlavor (null, "IMLog", null));
16
public override Tile BuildTile (Beagle.Hit hit, Beagle.Query query)
18
return new IMLog (hit, query);
22
public class IMLog : TileFlat {
24
private static Hashtable all_icons = new Hashtable ();
26
public IMLog (Beagle.Hit hit, Beagle.Query query) : base (hit, query)
28
Group = TileGroup.Conversations;
30
Subject.LabelProp = Catalog.GetString ("IM Conversation");
32
string alias = hit.GetFirstProperty ("fixme:speakingto_alias");
33
string name = hit.GetFirstProperty ("fixme:speakingto");
35
if (alias != null && alias != "")
36
From.LabelProp = "<b>" + alias + "</b>";
37
else if (name != null && name != "")
38
From.LabelProp = "<b>" + name + "</b>";
40
From.LabelProp = "(unknown)";
43
string starttime = hit.GetFirstProperty ("fixme:starttime");
45
if (!String.IsNullOrEmpty (starttime))
46
Timestamp = StringFu.StringToDateTime (starttime);
48
Date.LabelProp = Utils.NiceShortDate (Timestamp);
52
private Hashtable IconsForSize (int size)
54
Hashtable icons = new Hashtable ();
56
icons ["aim"] = WidgetFu.LoadThemeIcon ("im-aim", size);
57
icons ["icq"] = WidgetFu.LoadThemeIcon ("im-icq", size);
58
icons ["jabber"] = WidgetFu.LoadThemeIcon ("im-jabber", size);
59
icons ["msn"] = WidgetFu.LoadThemeIcon ("im-msn", size);
60
icons ["novell"] = WidgetFu.LoadThemeIcon ("im-nov", size);
61
icons ["yahoo"] = WidgetFu.LoadThemeIcon ("im-yahoo", size);
66
protected override void LoadIcon (Gtk.Image image, int size)
68
Hashtable icons = (Hashtable)all_icons[size];
70
all_icons[size] = icons = IconsForSize (size);
72
string protocol = Hit.GetFirstProperty ("fixme:protocol");
74
protocol = String.Empty;
76
if (icons [protocol] != null)
77
image.Pixbuf = (Gdk.Pixbuf)icons [protocol];
79
image.Pixbuf = WidgetFu.LoadThemeIcon ("im", size);
82
private Gdk.Pixbuf LoadBuddyIcon ()
84
Gdk.Pixbuf icon = null;
86
if (Hit ["fixme:speakingto_icon"] != null && System.IO.File.Exists (Hit ["fixme:speakingto_icon"]))
87
icon = new Gdk.Pixbuf (Hit ["fixme:speakingto_icon"]);
88
} catch (Exception e){
94
protected override DetailsPane GetDetails ()
96
DetailsPane details = new DetailsPane ();
98
details.Icon.Pixbuf = LoadBuddyIcon ();
99
details.AddLabelPair (Catalog.GetString ("Name:"), FromLabel.Text);
100
details.AddLabelPair (Catalog.GetString ("Date Received:"), Utils.NiceLongDate (Timestamp));
102
string status = GetBuddyStatus();
103
if (status != null && status != "")
104
details.AddLabelPair (Catalog.GetString ("Status:"), GetBuddyStatus());
106
details.AddSnippet ();
108
GotSnippet += SetSubject;
113
private string GetBuddyStatus ()
116
GalagoTools.Status stat = Beagle.Util.GalagoTools.GetPresence (Hit.GetFirstProperty ("fixme:protocol"), Hit.GetFirstProperty ("fixme:speakingto"));
118
if (stat == GalagoTools.Status.Idle){
119
str = String.Format ("{0} for {1}" , Catalog.GetString ("Idle"),
120
Beagle.Util.GalagoTools.GetIdleTime (Hit.GetFirstProperty ("fixme:protocol"),
121
Hit.GetFirstProperty ("fixme:speakingto")));
125
case GalagoTools.Status.Away :
126
str = Catalog.GetString ("Away");
128
case GalagoTools.Status.Offline :
129
str = Catalog.GetString ("Offline");
131
case GalagoTools.Status.Available:
132
str = Catalog.GetString ("Available");
134
case GalagoTools.Status.NoStatus:
142
private void SetSubject (string snippet)
144
Subject.Markup = snippet;
147
public override void Open ()
149
SafeProcess p = new SafeProcess ();
151
string log_path = Hit.Uri.LocalPath;
153
if (Hit.Source == "Konversation")
154
log_path = Hit.ParentUri.LocalPath;
156
p.Arguments = new string [] { "beagle-imlogviewer",
157
"--client", Hit ["fixme:client"],
158
"--highlight-search", Query.QuotedText,
163
} catch (Exception e) {
164
Console.WriteLine ("Unable to run {0}: {1}", p.Arguments [0], e.Message);