ShowException() public static method

public static ShowException ( Exception ex ) : void
ex System.Exception
return void
Esempio n. 1
0
        public virtual void Close()
        {
            Trace.Call();

            var protocolManager = ProtocolManager;

            if (protocolManager == null)
            {
#if LOG4NET
                _Logger.WarnFormat(
                    "{0}.Close(): ProtocolManager is null, bailing out!", this
                    );
#endif
                return;
            }

            ThreadPool.QueueUserWorkItem(delegate {
                try {
                    protocolManager.CloseChat(
                        Frontend.FrontendManager,
                        ChatModel
                        );
                } catch (Exception ex) {
                    Frontend.ShowException(ex);
                }
            });
        }
Esempio n. 2
0
        private void _OnCaretModeButtonClicked(object obj, EventArgs args)
        {
            Trace.Call(obj, args);

            try {
                _CaretMode = !_CaretMode;

                for (int i = 0; i < _Notebook.NPages; i++)
                {
                    ChatView chatView = _Notebook.GetChat(i);
                    chatView.OutputMessageTextView.CursorVisible = _CaretMode;
                }

                if (_CaretMode)
                {
                    _Notebook.CurrentChatView.OutputMessageTextView.HasFocus = true;
                }
                else
                {
                    _Entry.HasFocus = true;
                }
            } catch (Exception ex) {
                Frontend.ShowException(this, ex);
            }
        }
Esempio n. 3
0
        private void OnStatusIconActivated(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

            if (f_StatusIcon == null)
            {
                return;
            }

            try {
                if (f_StatusIcon.Blinking)
                {
                    f_MainWindow.Present();
                    return;
                }
                // not everyone uses a window list applet thus we have to
                // restore from minimized state here, see:
                // http://projects.qnetp.net/issues/show/159
                if (f_MainWindow.IsMinimized)
                {
                    f_MainWindow.Present();
                    return;
                }
                f_MainWindow.Visible = !f_MainWindow.Visible;
            } catch (Exception ex) {
                Frontend.ShowException(ex);
            }
        }
Esempio n. 4
0
        public virtual void UpdateLastSeenMessage()
        {
            _OutputMessageTextView.UpdateMarkerline();

            if (Frontend.EngineProtocolVersion == null ||
                Frontend.EngineProtocolVersion < new Version(0, 13))
            {
                return;
            }

            var lastSeenMessage = _OutputMessageTextView.LastMessage;

            if (lastSeenMessage == null)
            {
                return;
            }

            ThreadPool.QueueUserWorkItem(delegate {
                try {
                    // REMOTING CALL
                    _ChatModel.LastSeenMessage = lastSeenMessage.TimeStamp;
                } catch (Exception ex) {
                    Frontend.ShowException(ex);
                }
            });
        }
Esempio n. 5
0
        void OnUserListMenuRemoveActivated(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

            IList <PersonModel> persons = GetSelectedPersons();

            if (persons == null)
            {
                return;
            }

            foreach (PersonModel person in persons)
            {
                var per = person;

                ThreadPool.QueueUserWorkItem(delegate {
                    try {
                        XmppProtocolManager.CommandContact(
                            new CommandModel(
                                Frontend.FrontendManager,
                                ChatModel,
                                "remove " + per.ID
                                )
                            );
                    } catch (Exception ex) {
                        Frontend.ShowException(ex);
                    }
                });
            }
        }
Esempio n. 6
0
        protected virtual void OnMessageTextViewPopulatePopup(object sender, Gtk.PopulatePopupArgs e)
        {
            Trace.Call(sender, e);

            if (OutputMessageTextView.IsAtUrlTag)
            {
                return;
            }
            if (Frontend.MainWindow.ShowMenuBar)
            {
                return;
            }

            Gtk.Menu popup = e.Menu;
            popup.Prepend(new Gtk.SeparatorMenuItem());

            var item = new Gtk.CheckMenuItem(_("Show _Menubar"));

            item.Active     = Frontend.MainWindow.ShowMenuBar;
            item.Activated += delegate {
                try {
                    Frontend.MainWindow.ShowMenuBar = true;
                } catch (Exception ex) {
                    Frontend.ShowException(ex);
                }
            };
            popup.Prepend(item);
            popup.ShowAll();
        }
Esempio n. 7
0
        protected virtual void OnPersonsRowActivated(object sender, Gtk.RowActivatedArgs e)
        {
            Trace.Call(sender, e);

            IList <PersonModel> persons = GetSelectedPersons();

            if (persons == null)
            {
                return;
            }

            // this is a generic implemention that should be able to open/create
            // a private chat in most cases, as it depends what OpenChat()
            // of the specific protocol actually expects/needs
            foreach (PersonModel person in persons)
            {
                PersonChatModel personChat = new PersonChatModel(
                    person,
                    person.ID,
                    person.IdentityName,
                    null
                    );

                ThreadPool.QueueUserWorkItem(delegate {
                    try {
                        ChatModel.ProtocolManager.OpenChat(
                            Frontend.FrontendManager,
                            personChat
                            );
                    } catch (Exception ex) {
                        Frontend.ShowException(ex);
                    }
                });
            }
        }
Esempio n. 8
0
        protected virtual void OnRemoveButtonClicked(object sender, System.EventArgs e)
        {
            Trace.Call(sender, e);

            try {
                Gtk.TreeIter iter;
                if (!f_TreeView.Selection.GetSelected(out iter))
                {
                    return;
                }

                Gtk.MessageDialog md = new Gtk.MessageDialog(
                    f_Parent,
                    Gtk.DialogFlags.Modal,
                    Gtk.MessageType.Warning,
                    Gtk.ButtonsType.YesNo,
                    _("Are you sure you want to delete the selected filter?")
                    );
                int result = md.Run();
                md.Destroy();
                if (result != (int)Gtk.ResponseType.Yes)
                {
                    return;
                }

                f_ListStore.Remove(ref iter);

                OnChanged(EventArgs.Empty);
            } catch (Exception ex) {
                Frontend.ShowException(ex);
            }
        }
Esempio n. 9
0
        public static void Main(string[] args)
        {
            bool debug = false;

            foreach (string arg in args)
            {
                switch (arg)
                {
                case "-d":
                case "--debug":
                    debug = true;
                    break;

                case "-h":
                case "--help":
                    ShowHelp();
                    Environment.Exit(0);
                    break;

                    /*
                     * // don't block other parameters as we pass them to
                     * // GTK+ / GNOME too
                     * default:
                     *  Console.WriteLine("Invalid option: " + arg);
                     *  Environment.Exit(1);
                     *  break;
                     */
                }
            }

#if LOG4NET
            // initialize log level
            log4net.Repository.ILoggerRepository repo = log4net.LogManager.GetRepository();
            if (debug)
            {
                repo.Threshold = log4net.Core.Level.Debug;
            }
            else
            {
                repo.Threshold = log4net.Core.Level.Info;
            }
#endif

            try {
                Frontend.Init(args);
            } catch (Exception e) {
#if LOG4NET
                _Logger.Fatal(e);
#endif
                // when Gtk# receives an exception it is not usable/relyable anymore!
                // except the exception was thrown in Frontend.Init() itself
                if (Frontend.IsGtkInitialized && !Frontend.InGtkApplicationRun)
                {
                    Frontend.ShowException(e);
                }

                // rethrow the exception for console output
                throw;
            }
        }
Esempio n. 10
0
        protected virtual void OnTreeViewSelectionChanged(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

            try {
                ServerModel server = GetCurrentServer();
                if (server == null)
                {
                    return;
                }

                f_Widget.Load(server);
                // we are not editing server entries here instead we use
                // whatever values are entered
                f_Widget.ProtocolComboBox.Sensitive = true;
                // this field doesn't make sense here
                f_Widget.NetworkComboBoxEntry.Sensitive = false;
                // only enable the hostname field if there it's not empty, as
                // some protocols don't allow custom hosts, e.g. twitter
                if (!String.IsNullOrEmpty(f_Widget.HostnameEntry.Text))
                {
                    f_Widget.HostnameEntry.Sensitive = true;
                }
            } catch (ApplicationException ex) {
                Frontend.ShowError(this, _("Unable to load server: "), ex);
            } catch (Exception ex) {
                Frontend.ShowException(ex);
            }
        }
Esempio n. 11
0
        private void _OnUserListMenuQueryActivated(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

            IList <PersonModel> persons = GetSelectedPersons();

            if (persons == null)
            {
                return;
            }

            foreach (PersonModel person in persons)
            {
                ThreadPool.QueueUserWorkItem(delegate {
                    try {
                        _IrcProtocolManager.CommandMessageQuery(
                            new CommandModel(
                                Frontend.FrontendManager,
                                ChatModel,
                                person.ID
                                )
                            );
                    } catch (Exception ex) {
                        Frontend.ShowException(ex);
                    }
                });
            }
        }
Esempio n. 12
0
        private void _OnUserListMenuDevoiceActivated(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

            IList <PersonModel> persons = GetSelectedPersons();

            if (persons == null)
            {
                return;
            }

            // do smart mode changes
            List <string> nicks = new List <string>();

            foreach (PersonModel person in persons)
            {
                nicks.Add(person.ID);
            }
            ThreadPool.QueueUserWorkItem(delegate {
                try {
                    _IrcProtocolManager.CommandDevoice(
                        new CommandModel(
                            Frontend.FrontendManager,
                            ChatModel,
                            String.Join(" ", nicks.ToArray())
                            )
                        );
                } catch (Exception ex) {
                    Frontend.ShowException(ex);
                }
            });
        }
Esempio n. 13
0
        protected override void OnShown()
        {
            Trace.Call();

            if (!IsPopulated)
            {
                IsPopulated = true;
                foreach (var chatView in ChatViewManager.Chats)
                {
                    if (!(chatView is XmppGroupChatView))
                    {
                        // only invite to group chats
                        continue;
                    }
                    if (chatView == ChatViewManager.ActiveChat)
                    {
                        // don't need to add current chat to invite list
                        continue;
                    }
                    if (chatView.ProtocolManager != ProtocolManager)
                    {
                        // only add chats from current server
                        continue;
                    }
                    var groupChatView = (XmppGroupChatView)chatView;
                    if (groupChatView.IsContactList)
                    {
                        // ignore our abused groupchatview
                        continue;
                    }

                    var item = new Gtk.ImageMenuItem(chatView.Name);
                    item.Image = new Gtk.Image(GroupChatView.IconPixbuf);
                    var chatid = chatView.ID;
                    item.Activated += delegate {
                        var inviteFromChatModel = ChatViewManager.ActiveChat.ChatModel;
                        ThreadPool.QueueUserWorkItem(delegate {
                            try {
                                for (int i = 0; i < Invitees.Count; i++)
                                {
                                    ProtocolManager.CommandInvite(
                                        new CommandModel(
                                            Frontend.FrontendManager,
                                            inviteFromChatModel,
                                            chatid + " " + Invitees[i].ID
                                            )
                                        );
                                }
                            } catch (Exception ex) {
                                Frontend.ShowException(ex);
                            }
                        });
                    };
                    item.Show();
                    Append(item);
                }
            }

            base.OnShown();
        }
Esempio n. 14
0
        protected virtual void OnServerAddButtonClicked(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

            ServerDialog dialog = null;

            try {
                ServerListController controller = new ServerListController(Frontend.UserConfig);
                dialog = new ServerDialog(this, null,
                                          Frontend.Session.GetSupportedProtocols(),
                                          controller.GetNetworks());
                int         res    = dialog.Run();
                ServerModel server = dialog.GetServer();
                if (res != (int)Gtk.ResponseType.Ok)
                {
                    return;
                }

                controller.AddServer(server);
                controller.Save();
            } catch (InvalidOperationException ex) {
                Frontend.ShowError(this, _("Unable to add server: "), ex);
            } catch (Exception ex) {
                Frontend.ShowException(this, ex);
            } finally {
                if (dialog != null)
                {
                    dialog.Destroy();
                }
            }
        }
Esempio n. 15
0
        void OnPersonRenameEdited(object o, Gtk.EditedArgs e)
        {
            Trace.Call(o, e);

            Gtk.TreeIter iter;
            if (!PersonTreeView.Model.GetIterFromString(out iter, e.Path))
            {
                return;
            }
            PersonModel person = (PersonModel)PersonTreeView.Model.GetValue(iter, 0);

            ThreadPool.QueueUserWorkItem(delegate {
                try {
                    XmppProtocolManager.CommandContact(
                        new CommandModel(
                            Frontend.FrontendManager,
                            ChatModel,
                            "rename " + person.ID + " " + e.NewText
                            )
                        );
                } catch (Exception ex) {
                    Frontend.ShowException(ex);
                }
            });
        }
Esempio n. 16
0
        public void RemovePersonFromGroupChat(GroupChatModel groupChat, PersonModel person)
        {
            TraceRemotingCall(groupChat, person);

            MethodBase mb = Trace.GetMethodBase();

            Gtk.Application.Invoke(delegate {
                TraceRemotingCall(mb, groupChat, person);

                try {
                    GroupChatView groupChatView = (GroupChatView)_ChatViewManager.GetChat(groupChat);
                    if (groupChatView == null)
                    {
#if LOG4NET
                        _Logger.Fatal(
                            String.Format(
                                "RemovePersonFromGroupChat(): " +
                                "_ChatViewManager.GetChat(groupChat) " +
                                "groupChat.Name: {0} returned null!",
                                groupChat.Name
                                )
                            );
#endif
                        return;
                    }
                    groupChatView.RemovePerson(person);
                } catch (Exception ex) {
                    Frontend.ShowException(ex);
                }
            });
        }
Esempio n. 17
0
        protected void OnConnectActionActivated(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

            try {
                var dialog = new QuickConnectDialog(Parent);
                dialog.Load();
                int res    = dialog.Run();
                var server = dialog.Server;
                dialog.Destroy();
                if (res != (int)Gtk.ResponseType.Ok)
                {
                    return;
                }
                if (server == null)
                {
#if LOG4NET
                    f_Logger.Error("OnServerConnectButtonClicked(): server is null!");
                    return;
#endif
                }

                // do connect as background task as it might take a while
                ThreadPool.QueueUserWorkItem(delegate {
                    try {
                        Frontend.Session.Connect(server, Frontend.FrontendManager);
                    } catch (Exception ex) {
                        Frontend.ShowException(Parent, ex);
                    }
                });
            } catch (Exception ex) {
                Frontend.ShowException(Parent, ex);
            }
        }
Esempio n. 18
0
        public void UpdateTopicInGroupChat(GroupChatModel groupChat, MessageModel topic)
        {
            TraceRemotingCall(groupChat, topic);

            MethodBase mb = Trace.GetMethodBase();

            Gtk.Application.Invoke(delegate {
                TraceRemotingCall(mb, groupChat, topic);

                try {
                    GroupChatView groupChatView = (GroupChatView)Frontend.MainWindow.Notebook.GetChat(groupChat);
                    if (groupChatView == null)
                    {
#if LOG4NET
                        _Logger.Fatal(
                            String.Format(
                                "UpdateTopicInGroupChat(): " +
                                "_ChatViewManager.GetChat(groupChat) " +
                                "groupChat.Name: {0} returned null!",
                                groupChat.Name
                                )
                            );
#endif
                        return;
                    }
                    groupChatView.Topic = topic;
                } catch (Exception ex) {
                    Frontend.ShowException(ex);
                }
            });
        }
Esempio n. 19
0
        void OnUserListMenuUnbanActivated(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

            var persons = GetSelectedPersons();

            if (persons == null)
            {
                return;
            }

            var nicks = new List <string>();

            foreach (var person in persons)
            {
                nicks.Add(person.ID);
            }
            ThreadPool.QueueUserWorkItem(delegate {
                try {
                    IrcProtocolManager.CommandUnban(
                        new CommandModel(
                            Frontend.FrontendManager,
                            ChatModel,
                            String.Join(" ", nicks.ToArray())
                            )
                        );
                } catch (Exception ex) {
                    Frontend.ShowException(ex);
                }
            });
        }
Esempio n. 20
0
        void OnUserListMenuWhoisActivated(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

            var persons = GetSelectedPersons();

            if (persons == null)
            {
                return;
            }

            foreach (var person in persons)
            {
                var per = person;
                ThreadPool.QueueUserWorkItem(delegate {
                    try {
                        IrcProtocolManager.CommandWhoIs(
                            new CommandModel(
                                Frontend.FrontendManager,
                                ChatModel,
                                per.ID
                                )
                            );
                    } catch (Exception ex) {
                        Frontend.ShowException(ex);
                    }
                });
            }
        }
Esempio n. 21
0
        protected void OnAddServerActionActivated(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

            ServerDialog dialog = null;

            try {
                var controller = new ServerListController(Frontend.UserConfig);
                dialog = new ServerDialog(Parent, null,
                                          Frontend.Session.GetSupportedProtocols(),
                                          controller.GetNetworks());
                int         res    = dialog.Run();
                ServerModel server = dialog.GetServer();
                if (res != (int)Gtk.ResponseType.Ok)
                {
                    return;
                }

                controller.AddServer(server);
                controller.Save();

                // reload server list in join bar
                JoinWidget.InitNetworks(controller.GetNetworks());
            } catch (InvalidOperationException ex) {
                Frontend.ShowError(Parent, _("Unable to add server: "), ex);
            } catch (Exception ex) {
                Frontend.ShowException(Parent, ex);
            } finally {
                if (dialog != null)
                {
                    dialog.Destroy();
                }
            }
        }
Esempio n. 22
0
        protected virtual void OnFindPreviousChatMenuItemActivated(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

            try {
            } catch (Exception ex) {
                Frontend.ShowException(this, ex);
            }
        }
Esempio n. 23
0
 protected virtual void OnChatFindGroupChatButtonClicked(object sender, EventArgs e)
 {
     Trace.Call(sender, e);
     try {
         OpenFindGroupChatWindow();
     } catch (Exception ex) {
         Frontend.ShowException(this, ex);
     }
 }
Esempio n. 24
0
        protected virtual void OnTreeViewSelectionChanged(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

            try {
                f_OKButton.Sensitive = GetCurrentGroupChat() != null;
            } catch (Exception ex) {
                Frontend.ShowException(ex);
            }
        }
Esempio n. 25
0
        protected virtual void OnNameEntryActivated(object sender, System.EventArgs e)
        {
            Trace.Call(sender, e);

            try {
                f_FindButton.Click();
            } catch (Exception ex) {
                Frontend.ShowException(ex);
            }
        }
Esempio n. 26
0
        protected void OnWebsiteActionActivated(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

            try {
                Frontend.OpenLink(new Uri("https://smuxi.im/"));
            } catch (Exception ex) {
                Frontend.ShowException(Parent, ex);
            }
        }
Esempio n. 27
0
        protected virtual void OnSwitchPageQueueExceptionEvent(object sender, TaskQueueExceptionEventArgs e)
        {
            Trace.Call(sender, e);

#if LOG4NET
            f_Logger.Error("Exception in TaskQueue: ", e.Exception);
            f_Logger.Error("Inner-Exception: ", e.Exception.InnerException);
#endif
            Frontend.ShowException(e.Exception);
        }
Esempio n. 28
0
        protected virtual void OnLastSeenHighlightQueueExceptionEvent(object sender, TaskQueueExceptionEventArgs e)
        {
            Trace.Call(sender, e);

#if LOG4NET
            _Logger.Error("Exception in TaskQueue: ", e.Exception);
            _Logger.Error("Inner-Exception: ", e.Exception.InnerException);
#endif
            Frontend.ShowException(e.Exception);
        }
Esempio n. 29
0
        public void AddChat(ChatModel chat)
        {
            TraceRemotingCall(chat);

            try {
                _ChatViewManager.AddChat(chat);
            } catch (Exception ex) {
                Frontend.ShowException(ex);
            }
        }
Esempio n. 30
0
        protected virtual void OnTabMenuCloseActivated(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

            try {
                Close();
            } catch (Exception ex) {
                Frontend.ShowException(ex);
            }
        }