protected virtual void OnMessageTextViewMessageHighlighted(object sender, MessageTextViewMessageHighlightedEventArgs e)
{
if (IsSynced) {
bool isActiveChat = IsActive;
if (Frontend.UseLowBandwidthMode && !isActiveChat) {
HasHighlight = true;
return;
}
var method = Trace.GetMethodBase();
// update last seen highlight
// OPT-TODO: we should use a TaskStack here OR at least a
// timeout approach that will only sync once per 30 seconds!
_LastSeenHighlightQueue.Queue(delegate {
Trace.Call(method, null, null);
// unhandled exception here would kill the syncer thread
try {
if (isActiveChat) {
// REMOTING CALL 1
_ChatModel.LastSeenHighlight = e.Message.TimeStamp;
} else {
// REMOTING CALL 1
if (_ChatModel.LastSeenHighlight < e.Message.TimeStamp) {
Gtk.Application.Invoke(delegate {
// we have to make sure we only highlight
// the chat if it still isn't the active
// one as isActiveChat state is probably
// obsolete by now
if (IsActive) {
return;
}
HasHighlight = true;
});
}
}
} catch (Exception ex) {
#if LOG4NET
_Logger.Error("OnMessageTextViewMessageHighlighted(): Exception: ", ex);
#endif
}
});
} else {
if (e.Message.TimeStamp > SyncedLastSeenHighlight) {
HasHighlight = true;
}
}
if (e.Message.TimeStamp > SyncedLastSeenHighlight) {
// unseen highlight
// HACK: out of scope?
// only beep if the main windows has no focus (the user is
// elsewhere) and the chat is was already synced, as during sync we
// would get insane from all beeping caused by the old highlights
if (!Frontend.MainWindow.HasToplevelFocus &&
IsSynced &&
Frontend.UserConfig["Sound/BeepOnHighlight"] != null &&
(bool) Frontend.UserConfig["Sound/BeepOnHighlight"]) {
#if LOG4NET
_Logger.Debug("OnMessageTextViewMessageHighlighted(): BEEP!");
#endif
try {
if (Display != null) {
Display.Beep();
}
} catch (Exception ex) {
#if LOG4NET
_Logger.Error("OnMessageTextViewMessageHighlighted(): Exception", ex);
#endif
}
}
if (MessageHighlighted != null) {
MessageHighlighted(this, new ChatViewMessageHighlightedEventArgs(e.Message));
}
}
}