コード例 #1
0
        void OnChatViewMessageHighlighted(object sender,
                                          MessageTextViewMessageHighlightedEventArgs e,
                                          ChatView chatView)
        {
#if MSG_DEBUG
            Trace.Call(sender, e, chatView);
#endif

            if (!IsEnabled ||
                e.Message.TimeStamp <= chatView.SyncedLastSeenHighlight ||
                (MainWindow.HasToplevelFocus &&
                 (ChatViewManager.CurrentChatView == chatView ||
                  MainWindow.ChatTreeView.IsVisible(chatView))))
            {
                // no need to show a notification for:
                // - disabled chats
                // - seen highlights
                // - main window has focus and the chat is active or the chat
                //   row is visible
                return;
            }

            try {
                ShowNotification(chatView, e.Message);
            } catch (Exception ex) {
#if LOG4NET
                Logger.Error("OnChatViewMessageHighlighted(): " +
                             "ShowNotification() threw exception", ex);
#endif
            }
        }
コード例 #2
0
ファイル: MainWindow.cs プロジェクト: licnep/smuxi
        protected void OnChatViewMessageHighlighted(object sender, MessageTextViewMessageHighlightedEventArgs e)
        {
            Trace.Call(sender, e);

            if (!HasToplevelFocus)
            {
                UrgencyHint = true;
            }
        }
コード例 #3
0
        private void OnChatViewMessageHighlighted(object sender, MessageTextViewMessageHighlightedEventArgs e)
        {
            Trace.Call(sender, e);

            if (f_StatusIcon == null)
            {
                return;
            }

            if (!f_MainWindow.HasToplevelFocus)
            {
                f_StatusIcon.Blinking = true;
            }
        }
コード例 #4
0
ファイル: IndicateManager.cs プロジェクト: shubhtr/smuxi
        void OnChatViewMessageHighlighted(object sender,
                                          MessageTextViewMessageHighlightedEventArgs e,
                                          ChatView chatView)
        {
            if (!IsEnabled ||
                e.Message.TimeStamp <= chatView.SyncedLastSeenHighlight ||
                MainWindow.HasToplevelFocus)
            {
                return;
            }

#if INDICATE_SHARP
            ShowIndicator(chatView, e.Message);
#elif MESSAGING_MENU_SHARP
            ShowSource(chatView, e.Message);
#endif
        }
コード例 #5
0
        void OnChatViewMessageHighlighted(object sender,
                                          MessageTextViewMessageHighlightedEventArgs e,
                                          ChatView chatView)
        {
            Trace.Call(sender, e, chatView);

            if (!IsEnabled ||
                e.Message.TimeStamp <= chatView.SyncedLastSeenHighlight ||
                MainWindow.HasToplevelFocus)
            {
                return;
            }

            try {
                ShowNotification(chatView, e.Message);
            } catch (Exception ex) {
#if LOG4NET
                Logger.Error("OnChatViewMessageHighlighted(): " +
                             "ShowNotification() threw exception", ex);
#endif
            }
        }
コード例 #6
0
ファイル: ChatView.cs プロジェクト: Jaykul/smuxi
        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));
                }
            }
        }
コード例 #7
0
ファイル: ChatView.cs プロジェクト: licnep/smuxi
        protected virtual void OnMessageTextViewMessageHighlighted(object sender, MessageTextViewMessageHighlightedEventArgs e)
        {
            // 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 (_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;
                }
            }
        }
コード例 #8
0
ファイル: NotifyManager.cs プロジェクト: grendello/smuxi
        void OnChatViewMessageHighlighted(object sender,
                                          MessageTextViewMessageHighlightedEventArgs e,
                                          ChatView chatView)
        {
            #if MSG_DEBUG
            Trace.Call(sender, e, chatView);
            #endif

            if (!IsEnabled ||
                e.Message.TimeStamp <= chatView.SyncedLastSeenHighlight ||
                (MainWindow.HasToplevelFocus &&
                 chatView.LabelWidget.IsDrawable)) {
                // no need to show a notification for:
                // - disabled chats
                // - seen highlights
                // - main window has focus and the chat tab is visible
                return;
            }

            try {
                ShowNotification(chatView, e.Message);
            } catch (Exception ex) {
            #if LOG4NET
                Logger.Error("OnChatViewMessageHighlighted(): " +
                             "ShowNotification() threw exception", ex);
            #endif
            }
        }
コード例 #9
0
ファイル: MainWindow.cs プロジェクト: txdv/smuxi
        protected void OnChatViewMessageHighlighted(object sender, MessageTextViewMessageHighlightedEventArgs e)
        {
            Trace.Call(sender, e);

            if (!HasToplevelFocus) {
                UrgencyHint = true;
            }
        }
コード例 #10
0
ファイル: IndicateManager.cs プロジェクト: tuukka/smuxi
        void OnChatViewMessageHighlighted(object sender,
                                          MessageTextViewMessageHighlightedEventArgs e,
                                          ChatView chatView)
        {
            Trace.Call(sender, e, chatView);

            if (MainWindow.HasToplevelFocus || !IsEnabled) {
                return;
            }

            Indicator indicator;
            if (Indicators.TryGetValue(chatView, out indicator)) {
                // update time of existing indicator
                indicator.SetProperty(
                    "time",
                    e.Message.TimeStamp.ToLocalTime().ToString("s")
                );
                return;
            }

            indicator = new Indicator();
            indicator.SetProperty("subtype", "im");
            if (chatView is PersonChatView) {
                indicator.SetProperty("icon", PersonChatIconBase64);
                indicator.SetProperty("sender", chatView.Name);
            }
            if (chatView is GroupChatView) {
                indicator.SetProperty("icon", GroupChatIconBase64);
                var nick = GetNick(e.Message);
                if (nick == null) {
                    indicator.SetProperty("sender", chatView.Name);
                } else {
                    indicator.SetProperty("sender",
                        String.Format(
                            "{0} ({1})",
                            chatView.Name, nick
                        )
                    );
                }
            }
            indicator.SetProperty(
                "time",
                e.Message.TimeStamp.ToLocalTime().ToString("s")
            );
            indicator.SetPropertyBool("draw-attention", true);
            indicator.UserDisplay += delegate {
                try {
                    MainWindow.PresentWithTime(
                        (uint) (DateTime.UtcNow - UnixEpoch).TotalSeconds
                    );
                    MainWindow.Notebook.CurrentChatView = chatView;
                    DisposeIndicator(chatView);
                } catch (Exception ex) {
            #if LOG4NET
                    Logger.Error("OnChatViewMessageHighlighted() " +
                                 "indicator.UserDisplay threw exception", ex);
            #endif
                }
            };
            try {
                indicator.Show();
            } catch (Exception ex) {
            #if LOG4NET
                    Logger.Error("OnChatViewMessageHighlighted() " +
                                 "indicator.Show() thew exception", ex);
            #endif
            }

            Indicators.Add(chatView, indicator);
        }
コード例 #11
0
ファイル: IndicateManager.cs プロジェクト: licnep/smuxi
        void OnChatViewMessageHighlighted(object sender,
                                          MessageTextViewMessageHighlightedEventArgs e,
                                          ChatView chatView)
        {
            if (!IsEnabled ||
                e.Message.TimeStamp <= chatView.SyncedLastSeenHighlight ||
                MainWindow.HasToplevelFocus)
            {
                return;
            }

            Indicator indicator;

            if (Indicators.TryGetValue(chatView, out indicator))
            {
                // update time of existing indicator
                indicator.SetProperty(
                    "time",
                    e.Message.TimeStamp.ToLocalTime().ToString("s")
                    );
                return;
            }

            indicator = new Indicator();
            indicator.SetProperty("subtype", "im");
            if (chatView is PersonChatView)
            {
                indicator.SetProperty("icon", PersonChatIconBase64);
                indicator.SetProperty("sender", chatView.Name);
            }
            if (chatView is GroupChatView)
            {
                indicator.SetProperty("icon", GroupChatIconBase64);
                var nick = GetNick(e.Message);
                if (nick == null)
                {
                    indicator.SetProperty("sender", chatView.Name);
                }
                else
                {
                    indicator.SetProperty("sender",
                                          String.Format(
                                              "{0} ({1})",
                                              chatView.Name, nick
                                              )
                                          );
                }
            }
            indicator.SetProperty(
                "time",
                e.Message.TimeStamp.ToLocalTime().ToString("s")
                );
            indicator.SetPropertyBool("draw-attention", true);
            indicator.UserDisplay += delegate {
                try {
                    MainWindow.Present();
                    MainWindow.Notebook.CurrentChatView = chatView;
                    DisposeIndicator(chatView);
                } catch (Exception ex) {
#if LOG4NET
                    Logger.Error("OnChatViewMessageHighlighted() " +
                                 "indicator.UserDisplay threw exception", ex);
#endif
                }
            };
            try {
                indicator.Show();
            } catch (Exception ex) {
#if LOG4NET
                Logger.Error("OnChatViewMessageHighlighted() " +
                             "indicator.Show() thew exception", ex);
#endif
            }

            Indicators.Add(chatView, indicator);
        }
コード例 #12
0
ファイル: IndicateManager.cs プロジェクト: vith/smuxi
        void OnChatViewMessageHighlighted(object sender,
                                          MessageTextViewMessageHighlightedEventArgs e,
                                          ChatView chatView)
        {
            if (!IsEnabled ||
                e.Message.TimeStamp <= chatView.SyncedLastSeenHighlight ||
                MainWindow.HasToplevelFocus) {
                return;
            }

            #if INDICATE_SHARP
            ShowIndicator(chatView, e.Message);
            #elif MESSAGING_MENU_SHARP
            ShowSource(chatView, e.Message);
            #endif
        }
コード例 #13
0
ファイル: StatusIconManager.cs プロジェクト: tuukka/smuxi
        private void OnChatViewMessageHighlighted(object sender, MessageTextViewMessageHighlightedEventArgs e)
        {
            Trace.Call(sender, e);

            if (f_StatusIcon == null) {
                return;
            }

            if (!f_MainWindow.HasToplevelFocus) {
                f_StatusIcon.Blinking = true;
            }
        }
コード例 #14
0
ファイル: NotifyManager.cs プロジェクト: txdv/smuxi
        void OnChatViewMessageHighlighted(object sender,
                                          MessageTextViewMessageHighlightedEventArgs e,
                                          ChatView chatView)
        {
            Trace.Call(sender, e, chatView);

            if (MainWindow.HasToplevelFocus || !IsEnabled) {
                return;
            }

            Notification notification;
            if (!Capabilites.Contains("append") &&
                Notifications.TryGetValue(chatView, out notification)) {
                // no support for append, update the existing notification
                notification.Body = GLib.Markup.EscapeText(
                    e.Message.ToString()
                );
                return;
            }

            notification = new Notification() {
                Summary = chatView.Name,
                Category = "im.received"
            };
            if (Capabilites.Contains("body")) {
                // notify-osd doesn't like unknown tags when appending
                notification.Body = GLib.Markup.EscapeText(
                    e.Message.ToString()
                );
            }
            //notification.IconName = "notification-message-im";
            if (Capabilites.Contains("icon-static")) {
                if (chatView is PersonChatView) {
                    notification.Icon = PersonChatIconPixbuf;
                }
                if (chatView is GroupChatView) {
                    notification.Icon = GroupChatIconPixbuf;
                }
            }
            if (Capabilites.Contains("actions")) {
                notification.AddAction("show", _("Show"), delegate {
                    try {
                        MainWindow.PresentWithTime(
                            (uint) (DateTime.UtcNow - UnixEpoch).TotalSeconds
                        );
                        MainWindow.Notebook.CurrentChatView = chatView;
                        notification.Close();
                    } catch (Exception ex) {
            #if LOG4NET
                        Logger.Error("OnChatViewMessageHighlighted() " +
                                     "notification.Show threw exception", ex);
            #endif
                    }
                });
            }
            if (Capabilites.Contains("append")) {
                notification.AddHint("append", String.Empty);
            }
            if (Capabilites.Contains("sound")) {
                // DNS 0.9 only supports sound-file which is a file path
                // http://www.galago-project.org/specs/notification/0.9/x344.html
                // DNS 1.1 supports sound-name which is an id, see:
                // http://people.canonical.com/~agateau/notifications-1.1/spec/ar01s08.html
                // http://0pointer.de/public/sound-naming-spec.html
                // LAMESPEC: We can't tell which of those are actually
                // supported by this version as hint are totally optional :/
                // HACK: always pass both hints when possible
                notification.AddHint("sound-name", "message-new-instant");
                if (SoundFile != null) {
                    notification.AddHint("sound-file", SoundFile);
                }
            }
            notification.Closed += delegate {
                DisposeNotification(chatView);
            };

            try {
                notification.Show();
            } catch (Exception ex) {
            #if LOG4NET
                Logger.Error("OnChatViewMessageHighlighted(): " +
                             " notification.Show() threw exception", ex);
            #endif
            }

            if (!Notifications.ContainsKey(chatView)) {
                Notifications.Add(chatView, notification);
            }
        }
コード例 #15
0
ファイル: NotifyManager.cs プロジェクト: carlosmn/smuxi
        void OnChatViewMessageHighlighted(object sender,
                                          MessageTextViewMessageHighlightedEventArgs e,
                                          ChatView chatView)
        {
            Trace.Call(sender, e, chatView);

            if (!IsEnabled ||
                e.Message.TimeStamp <= chatView.SyncedLastSeenHighlight ||
                MainWindow.HasToplevelFocus) {
                return;
            }

            try {
                ShowNotification(chatView, e.Message);
            } catch (Exception ex) {
            #if LOG4NET
                Logger.Error("OnChatViewMessageHighlighted(): " +
                             "ShowNotification() threw exception", ex);
            #endif
            }
        }