2 using System
.Diagnostics
;
3 using System
.Collections
;
7 namespace 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 Timestamp
= Utils
.ParseTimestamp (hit
.GetFirstProperty ("fixme:starttime"));
44 Date
.LabelProp
= Utils
.NiceShortDate (Timestamp
);
50 private Hashtable
IconsForSize (int size
)
52 Hashtable icons
= new Hashtable ();
54 icons
["aim"] = WidgetFu
.LoadThemeIcon ("im-aim", size
);
55 icons
["icq"] = WidgetFu
.LoadThemeIcon ("im-icq", size
);
56 icons
["jabber"] = WidgetFu
.LoadThemeIcon ("im-jabber", size
);
57 icons
["msn"] = WidgetFu
.LoadThemeIcon ("im-msn", size
);
58 icons
["novell"] = WidgetFu
.LoadThemeIcon ("im-nov", size
);
59 icons
["yahoo"] = WidgetFu
.LoadThemeIcon ("im-yahoo", size
);
64 protected override void LoadIcon (Gtk
.Image image
, int size
)
66 Hashtable icons
= (Hashtable
)all_icons
[size
];
68 all_icons
[size
] = icons
= IconsForSize (size
);
70 string protocol
= Hit
.GetFirstProperty ("fixme:protocol");
71 if (icons
[protocol
] != null)
72 image
.Pixbuf
= (Gdk
.Pixbuf
)icons
[protocol
];
74 image
.Pixbuf
= WidgetFu
.LoadThemeIcon ("im", size
);
77 private Gdk
.Pixbuf
LoadBuddyIcon ()
79 Gdk
.Pixbuf icon
= null;
81 if (Hit
["fixme:speakingto_icon"] != null && System
.IO
.File
.Exists (Hit
["fixme:speakingto_icon"]))
82 icon
= new Gdk
.Pixbuf (Hit
["fixme:speakingto_icon"]);
87 protected override DetailsPane
GetDetails ()
89 DetailsPane details
= new DetailsPane ();
91 details
.Icon
.Pixbuf
= LoadBuddyIcon ();
92 details
.AddLabelPair (Catalog
.GetString ("Name:"), FromLabel
.Text
);
93 details
.AddLabelPair (Catalog
.GetString ("Date Received:"), Utils
.NiceLongDate (Timestamp
));
95 string status
= GetBuddyStatus();
96 if (status
!= null && status
!= "")
97 details
.AddLabelPair (Catalog
.GetString ("Status:"), GetBuddyStatus());
99 details
.AddSnippet ();
101 GotSnippet
+= SetSubject
;
106 private string GetBuddyStatus ()
109 GalagoTools
.Status stat
= Beagle
.Util
.GalagoTools
.GetPresence (Hit
.GetFirstProperty ("fixme:protocol"), Hit
.GetFirstProperty ("fixme:speakingto"));
111 if (stat
== GalagoTools
.Status
.Idle
){
112 str
= String
.Format ("{0} for {1}" , Catalog
.GetString ("Idle"),
113 Beagle
.Util
.GalagoTools
.GetIdleTime (Hit
.GetFirstProperty ("fixme:protocol"),
114 Hit
.GetFirstProperty ("fixme:speakingto")));
118 case GalagoTools
.Status
.Away
:
119 str
= Catalog
.GetString ("Away");
121 case GalagoTools
.Status
.Offline
:
122 str
= Catalog
.GetString ("Offline");
124 case GalagoTools
.Status
.Available
:
125 str
= Catalog
.GetString ("Available");
127 case GalagoTools
.Status
.NoStatus
:
135 private void SetSubject (string snippet
)
137 Subject
.Markup
= snippet
;
140 public override void Open ()
142 SafeProcess p
= new SafeProcess ();
143 p
.Arguments
= new string [] { "beagle-imlogviewer",
144 "--client", Hit
["fixme:client"],
145 "--highlight-search", Query
.QuotedText
,
150 } catch (Exception e
) {
151 Console
.WriteLine ("Unable to run {0}: {1}", p
.Arguments
[0], e
.Message
);