Example #1
0
        protected virtual void OnChatOpenChatButtonClicked(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

            try {
                OpenChatDialog dialog = new OpenChatDialog(this);
                int res = dialog.Run();

                var chatView = Notebook.CurrentChatView;
                if (chatView == null) {
                    return;
                }

                var manager = chatView.ChatModel.ProtocolManager;
                if (manager == null) {
                    return;
                }
                ChatModel chat;
                switch (dialog.ChatType) {
                    case ChatType.Group:
                        chat = new GroupChatModel(
                            dialog.ChatName,
                            dialog.ChatName,
                            manager
                        );
                        break;
                    case ChatType.Person:
                        chat = new PersonChatModel(
                            null,
                            dialog.ChatName,
                            dialog.ChatName,
                            manager
                        );
                        break;
                    default:
                        throw new ApplicationException(
                            String.Format(
                                _("Unknown ChatType: {0}"),
                                dialog.ChatType
                            )
                        );
                }

                dialog.Destroy();
                if (res != (int) Gtk.ResponseType.Ok) {
                    return;
                }

                manager.OpenChat(Frontend.FrontendManager, chat);
            } catch (Exception ex) {
                Frontend.ShowException(this, ex);
            }
        }
Example #2
0
        protected virtual void OnChatOpenChatButtonClicked(object sender, EventArgs e)
        {
            Trace.Call(sender, e);

            try {
                OpenChatDialog dialog = new OpenChatDialog(this);
                int            res    = dialog.Run();

                var chatView = Notebook.CurrentChatView;
                if (chatView == null)
                {
                    return;
                }

                // FIXME: REMOTING CALL
                var manager = chatView.ChatModel.ProtocolManager;
                if (manager == null)
                {
                    return;
                }
                ChatModel chat;
                switch (dialog.ChatType)
                {
                case ChatType.Group:
                    chat = new GroupChatModel(
                        dialog.ChatName,
                        dialog.ChatName,
                        null
                        );
                    break;

                case ChatType.Person:
                    chat = new PersonChatModel(
                        null,
                        dialog.ChatName,
                        dialog.ChatName,
                        null
                        );
                    break;

                default:
                    throw new ApplicationException(
                              String.Format(
                                  _("Unknown ChatType: {0}"),
                                  dialog.ChatType
                                  )
                              );
                }

                dialog.Destroy();
                if (res != (int)Gtk.ResponseType.Ok)
                {
                    return;
                }

                ThreadPool.QueueUserWorkItem(delegate {
                    try {
                        manager.OpenChat(Frontend.FrontendManager, chat);
                    } catch (Exception ex) {
                        Frontend.ShowException(this, ex);
                    }
                });
            } catch (Exception ex) {
                Frontend.ShowException(this, ex);
            }
        }