Exemplo n.º 1
0
 public void OpenChatWindow(JID jid, bool isMucUser, bool focus, ChatHandlerEvent callback)
 {
     QApplication.Invoke(delegate {
         IChatHandler handler = null;
         string windowJid     = isMucUser ? jid.ToString() : jid.Bare;
         lock (m_ChatWindows) {
             if (!m_ChatWindows.ContainsKey(windowJid))
             {
                 handler        = new ChatHandler(m_Account, isMucUser, windowJid);
                 var window     = new ChatWindow(handler);
                 window.Closed += HandleChatWindowClosed;
                 m_ChatWindows.Add(windowJid, window);
                 Gui.TabbedChatsWindow.AddChatWindow(window, focus);
             }
             else
             {
                 var window = m_ChatWindows[windowJid];
                 if (focus)
                 {
                     Gui.TabbedChatsWindow.FocusChatWindow(window);
                 }
                 handler = (ChatHandler)window.Handler;
             }
         }
         if (callback != null)
         {
             callback(handler);
         }
     });
 }
Exemplo n.º 2
0
        public InviteToMucDialog(IChatHandler handler, QWidget parentWindow)
            : base(parentWindow)
        {
            SetupUi();

            buttonBox.StandardButtons = (uint)QDialogButtonBox.StandardButton.Ok | (uint)QDialogButtonBox.StandardButton.Cancel | (uint)QDialogButtonBox.StandardButton.Close;
            buttonBox.Button(QDialogButtonBox.StandardButton.Close).Hide();
            buttonBox.Button(QDialogButtonBox.StandardButton.Ok).Text = "&Invite";

            m_Handler = handler;

            if (handler is ChatHandler) {
                foreach (var room in m_Handler.Account.ConferenceManager.Rooms) {
                    mucsListWidget.AddItem(room.JID.ToString());
                }
                stackedWidget.CurrentIndex = 0;
            } else {
                foreach (var jid in m_Handler.Account.Roster) {
                    if (m_Handler.Account.PresenceManager.IsAvailable(jid)) {
                        friendsListWidget.AddItem(jid.ToString());
                    }
                }
                stackedWidget.CurrentIndex = 1;
                urlLineEdit.Text = String.Format("http://chat.synapse.im/room/{0}/", Uri.EscapeUriString(((MucHandler)m_Handler).Room.JID.ToString()));
            }

            Gui.CenterWidgetOnScreen(this);

            on_mucsListWidget_itemSelectionChanged();
        }
Exemplo n.º 3
0
        public InviteToMucDialog(IChatHandler handler, QWidget parentWindow) : base(parentWindow)
        {
            SetupUi();

            buttonBox.StandardButtons = (uint)QDialogButtonBox.StandardButton.Ok | (uint)QDialogButtonBox.StandardButton.Cancel | (uint)QDialogButtonBox.StandardButton.Close;
            buttonBox.Button(QDialogButtonBox.StandardButton.Close).Hide();
            buttonBox.Button(QDialogButtonBox.StandardButton.Ok).Text = "&Invite";

            m_Handler = handler;

            if (handler is ChatHandler)
            {
                foreach (var room in m_Handler.Account.ConferenceManager.Rooms)
                {
                    mucsListWidget.AddItem(room.JID.ToString());
                }
                stackedWidget.CurrentIndex = 0;
            }
            else
            {
                foreach (var jid in m_Handler.Account.Roster)
                {
                    if (m_Handler.Account.PresenceManager.IsAvailable(jid))
                    {
                        friendsListWidget.AddItem(jid.ToString());
                    }
                }
                stackedWidget.CurrentIndex = 1;
                urlLineEdit.Text           = String.Format("http://chat.synapse.im/room/{0}/", Uri.EscapeUriString(((MucHandler)m_Handler).Room.JID.ToString()));
            }

            Gui.CenterWidgetOnScreen(this);

            on_mucsListWidget_itemSelectionChanged();
        }
 public ChatController
 (
     IChatHandler chatHandler,
     IHubContext <ChatHub> chatHubContext
 )
 {
     this._chatHandler    = chatHandler;
     this._chatHubContext = chatHubContext;
 }
 public BlakullaController(
     IGame game,
     ITwitchAuth auth,
     IChatHandler chatHandler)
 {
     this.auth        = auth;
     this.game        = game;
     this.chatHandler = chatHandler;
 }
Exemplo n.º 6
0
        public void SendMessage(IChatHandler handler, string language, string text)
        {
            var bodyElement = handler.Account.Client.Document.CreateElement("body");

            bodyElement.SetAttribute("xmlns:code", CODE_NS);
            bodyElement.SetAttribute("language", CODE_NS, language);
            bodyElement.InnerText = text;

            handler.Send(bodyElement);
        }
Exemplo n.º 7
0
 void SendMessages(IChatHandler chat, List <ChatMessage> newMessagesFromAnotherChat)
 {
     if (newMessagesFromAnotherChat == null)
     {
         return;
     }
     foreach (ChatMessage item in newMessagesFromAnotherChat)
     {
         chat.SendMessage(item);
     }
 }
Exemplo n.º 8
0
        protected override void CloseEvent(QCloseEvent evnt)
        {
            if (Closed != null)
            {
                Closed(this,EventArgs.Empty);
            }

            m_Handler.NewContent -= HandleNewContent;
            m_Handler.Dispose();
            m_Handler = null;

            evnt.Accept();
        }
Exemplo n.º 9
0
        public TwoChatsHandler(ChatSpammerSettings spammerSettings, IChatHandler chat1, IChatHandler chat2)
        {
            Settings         = spammerSettings;
            UniqueIdentifier = RandomTextGenerator.Generate(4);
            string dateStr = string.Format("{0:dd.MM.yy_HH.mm.ss}", DateTime.Now);

            UsedFolder = ResourcesAndConsts.Instance().FolderForСorrespondenceAndLogs + "/" + dateStr + "__" + UniqueIdentifier;
            Directory.CreateDirectory(UsedFolder);
            Chat1 = chat1;
            Chat2 = chat2;
            if (spammerSettings.BotScenario != null)
            {
                BotScenario = spammerSettings.BotScenario.Clone() as IBotScenario;
            }
        }
Exemplo n.º 10
0
        List <ChatMessage> GetNewMessages(IChatHandler chat, ref int msgCountWas)
        {
            chat.UpdateMessagesList();
            int msgCount = chat.GetMessagesCount();
            List <ChatMessage> newMsg = new List <ChatMessage>();

            while (msgCountWas < msgCount)
            {
                ChatMessage cm = chat.GetMessageAt(msgCountWas);
                newMsg.Add(cm);
                msgCountWas++;
            }

            return(newMsg);
        }
Exemplo n.º 11
0
 public StagePlayUseCase(IChatHandler chatHandler,
                         IStageEntity stageEntity,
                         IPlayerEntity playerEntity,
                         IMainStateEntity mainStateEntity,
                         IMainStateRpcRequester mainStateRpcRequester,
                         ITimerEntity timerEntity,
                         ITimeRenderer timeRenderer,
                         IStageResultRpcRequester stageResultRpcRequester)
 {
     ChatHandler             = chatHandler;
     StageEntity             = stageEntity;
     PlayerEntity            = playerEntity;
     MainStateEntity         = mainStateEntity;
     MainStateRpcRequester   = mainStateRpcRequester;
     TimerEntity             = timerEntity;
     TimeRenderer            = timeRenderer;
     StageResultRpcRequester = stageResultRpcRequester;
 }
        public Game(
            ILogger logger,
            IPlayerHandler playerHandler,
            IChatHandler chatHandler,
            IActionQueue actionQueue,
            IPropertyRepository propertyRepository)
        {
            this.logger             = logger;
            this.playerHandler      = playerHandler;
            this.chatHandler        = chatHandler;
            this.actionQueue        = actionQueue;
            this.propertyRepository = propertyRepository;

            this.messageLookup = propertyRepository.Load <ConcurrentDictionary <Guid, TaskCompletionSource <GameActionReply> > >(nameof(messageLookup))
                                 ?? new ConcurrentDictionary <Guid, TaskCompletionSource <GameActionReply> >();

            this.context = propertyRepository.Load <GameContext>(nameof(context)) ?? GameContext.CreateEmpty();
        }
Exemplo n.º 13
0
 /// <summary>
 /// Конструктор с инициализацией полей
 /// </summary>
 public Main(IResolutionRoot kernel)
 {
     ServerKernel.Kernel      = kernel;
     _worldInitializer        = kernel.Get <IWorldInitializer>();
     _databaseSynchronizer    = kernel.Get <IDatabaseSynchronizer>();
     _finishDownloadManager   = kernel.Get <IPlayerFinishDownloadManager>();
     _playerConnectManager    = kernel.Get <IPlayerConnectManager>();
     _playerDisconnectManager = kernel.Get <IPlayerDisconnectManager>();
     _playerRespawn           = kernel.Get <IPlayerRespawnManager>();
     _playerDamagedManager    = kernel.Get <IPlayerDamagedManager>();
     _playerDeathManager      = kernel.Get <IPlayerDeathManager>();
     _vehicleEnterManager     = kernel.Get <IVehicleEnterManager>();
     _chatHandler             = kernel.Get <IChatHandler>();
     _playerManager           = kernel.Get <IPlayerManager>();
     _vehicleManager          = kernel.Get <IVehicleManager>();
     _vehicleInfoManager      = kernel.Get <IVehicleInfoManager>();
     _giftsManager            = kernel.Get <IGiftsManager>();
 }
Exemplo n.º 14
0
        public async Task Invoke(HttpContext context, IChatHandler _chatHandler)
        {
            if (!context.WebSockets.IsWebSocketRequest)
            {
                await _next.Invoke(context);

                return;
            }

            var socket = await context.WebSockets.AcceptWebSocketAsync();

            await _websocketHandler.OnConnected(socket);

            await Receive(socket, async (result, message) =>
            {
                await _chatHandler.ReceiveAsync(socket, message);
                return;
            });
        }
Exemplo n.º 15
0
        public void OnChatsDisposed(IChatHandler chatHandler1, IChatHandler chatHandler2, TwoChatsHandlerStatus twoChatsHandlerStatus)
        {
            ProxyStatus proxyStatus = (twoChatsHandlerStatus == TwoChatsHandlerStatus.FatalError) ? ProxyStatus.Dead : ProxyStatus.Free;

            if (chatHandler1 != null)
            {
                var ch1 = chatHandler1 as ChatHandler_WrapperForChatvdvoemBasicWorker;
                CacheHandle(ch1.CacheFolder, twoChatsHandlerStatus == TwoChatsHandlerStatus.FatalError);
                if (ch1.ProxyStr != null)
                {
                    _ProxyDispatcher.SetProxyStatus(ch1.ProxyStr, proxyStatus);
                }
            }
            if (chatHandler2 != null)
            {
                var ch2 = chatHandler2 as ChatHandler_WrapperForChatvdvoemBasicWorker;
                CacheHandle(ch2.CacheFolder, twoChatsHandlerStatus == TwoChatsHandlerStatus.FatalError);
                if (ch2.ProxyStr != null)
                {
                    _ProxyDispatcher.SetProxyStatus(ch2.ProxyStr, proxyStatus);
                }
            }
        }
 public void OnChatsDisposed(IChatHandler chatHandler1, IChatHandler chatHandler2, TwoChatsHandlerStatus twoChatsHandlerStatus)
 {
     Factory1.OnChatsDisposed(chatHandler1, null, twoChatsHandlerStatus);
     Factory2.OnChatsDisposed(chatHandler2, null, twoChatsHandlerStatus);
 }
Exemplo n.º 17
0
        public void SendMessage(IChatHandler handler, string language, string text)
        {
            var bodyElement = handler.Account.Client.Document.CreateElement("body");
            bodyElement.SetAttribute("xmlns:code", CODE_NS);
            bodyElement.SetAttribute("language", CODE_NS, language);
            bodyElement.InnerText = text;

            handler.Send(bodyElement);
        }
Exemplo n.º 18
0
        internal ChatWindow(IChatHandler handler)
        {
            if (handler == null)
            {
                throw new ArgumentNullException("handler");
            }
            m_Handler = handler;

            var settingsService = ServiceManager.Get <SettingsService>();

            SetupUi();

            if (handler is MucHandler)
            {
                m_ParticipantsMenu = new QMenu(this);
                QObject.Connect(m_ParticipantsMenu, Qt.SIGNAL("aboutToShow()"), HandleMenuAboutToShow);
                QObject.Connect(m_ParticipantsMenu, Qt.SIGNAL("aboutToHide()"), HandleMenuAboutToHide);

                var mucHandler = (MucHandler)handler;
                participantsGrid.Model             = mucHandler.GridModel;
                participantsGrid.ContextMenuPolicy = Qt.ContextMenuPolicy.CustomContextMenu;
                participantsGrid.ItemActivated    += HandleItemActivated;

                participantsGrid.ListMode = settingsService.Get <bool>("MucListMode");
                if (settingsService.Has("MucIconSize"))
                {
                    participantsGrid.IconSize = settingsService.Get <int>("MucIconSize");
                }

                var group = new QActionGroup(this);

                var gridModeAction = new QAction("View as Grid", this);
                QObject.Connect(gridModeAction, Qt.SIGNAL("triggered()"), HandleGridModeActionTriggered);
                gridModeAction.SetActionGroup(group);
                gridModeAction.Checkable = true;
                gridModeAction.Checked   = true;
                m_ParticipantsMenu.AddAction(gridModeAction);

                var listModeAction = new QAction("View as List", this);
                QObject.Connect(listModeAction, Qt.SIGNAL("triggered()"), HandleListModeActionTriggered);
                listModeAction.SetActionGroup(group);
                listModeAction.Checkable = true;
                listModeAction.Checked   = participantsGrid.ListMode;
                m_ParticipantsMenu.AddAction(listModeAction);

                var separatorAction = new QAction(participantsGrid);
                separatorAction.SetSeparator(true);
                m_ParticipantsMenu.AddAction(separatorAction);

                var sliderAction = new AvatarGridZoomAction <jabber.connection.RoomParticipant>(participantsGrid);
                sliderAction.ValueChanged += delegate(int value) {
                    participantsGrid.IconSize = value;
                    settingsService.Set("MucIconSize", value);
                };
                m_ParticipantsMenu.AddAction(sliderAction);

                m_ParticipantItemMenu = new QMenu(this);
                QObject.Connect(m_ParticipantItemMenu, Qt.SIGNAL("aboutToShow()"), HandleMenuAboutToShow);
                QObject.Connect(m_ParticipantItemMenu, Qt.SIGNAL("aboutToHide()"), HandleMenuAboutToHide);

                var mucViewProfileAction = new QAction("View Profile", this);
                QObject.Connect(mucViewProfileAction, Qt.SIGNAL("triggered()"), HandleMucViewProfileActionTriggered);
                m_ParticipantItemMenu.AddAction(mucViewProfileAction);

                var mucPrivateMessageAction = new QAction("IM", this);
                QObject.Connect(mucPrivateMessageAction, Qt.SIGNAL("triggered()"), HandleMucPrivateMessageTriggered);
                m_ParticipantItemMenu.AddAction(mucPrivateMessageAction);

                var mucSendFileAction = new QAction("Send File...", this);
                QObject.Connect(mucSendFileAction, Qt.SIGNAL("triggered()"), HandleMucSendFileActionTriggered);
                m_ParticipantItemMenu.AddAction(mucSendFileAction);

                var mucViewHistoryAction = new QAction("View History", this);
                QObject.Connect(mucViewHistoryAction, Qt.SIGNAL("triggered()"), HandleMucViewHistoryActionTriggered);
                m_ParticipantItemMenu.AddAction(mucViewHistoryAction);

                m_ModeratorActionsMenu = new QMenu("Moderator Actions", this);

                var roomRoleActionGroup = new QActionGroup(this);
                QObject.Connect(roomRoleActionGroup, Qt.SIGNAL("triggered(QAction*)"), this, Qt.SLOT("HandleRoomRoleActionGroupTriggered(QAction*)"));

                m_ModeratorAction = new QAction("Moderator",this);
                roomRoleActionGroup.AddAction(m_ModeratorAction);
                m_ModeratorAction.Checkable = true;
                m_ModeratorActionsMenu.AddAction(m_ModeratorAction);

                m_ParticipantAction = new QAction("Participant",this);
                roomRoleActionGroup.AddAction(m_ParticipantAction);
                m_ParticipantAction.Checkable = true;
                m_ModeratorActionsMenu.AddAction(m_ParticipantAction);

                m_VisitorAction = new QAction("Visitor",this);
                roomRoleActionGroup.AddAction(m_VisitorAction);
                m_VisitorAction.Checkable = true;
                m_ModeratorActionsMenu.AddAction(m_VisitorAction);

                m_ModeratorActionsMenu.AddSeparator();

                var mucKickAction = new QAction("Kick...",this);
                QObject.Connect(mucKickAction,Qt.SIGNAL("triggered()"),HandleMucKickActionTriggered);
                m_ModeratorActionsMenu.AddAction(mucKickAction);

                var mucBanAction = new QAction("Ban...",this);
                QObject.Connect(mucBanAction,Qt.SIGNAL("triggered()"),HandleMucBanActionTriggered);
                m_ModeratorActionsMenu.AddAction(mucBanAction);

                m_ModeratorActionsMenu.AddSeparator();

                m_ChangeAffiliationAction = new QAction("Change Affiliation...",this);
                QObject.Connect(m_ChangeAffiliationAction,Qt.SIGNAL("triggered()"),HandleChangeAffiliationTriggered);
                m_ModeratorActionsMenu.AddAction(m_ChangeAffiliationAction);

                m_ParticipantItemMenu.AddSeparator();
                m_ParticipantItemMenu.AddMenu(m_ModeratorActionsMenu);

                m_ParticipantItemMenu.AddSeparator();

                m_AddAsFriendAction = new QAction("Add as Friend",this);
                m_ParticipantItemMenu.AddAction(m_AddAsFriendAction);

                this.WindowTitle = mucHandler.Room.JID.User;                 // FIXME: Show only "user" in tab, show full room jid in title?
                this.WindowIcon  = Gui.LoadIcon("internet-group-chat");
            }
            else
            {
                var chatHandler = (ChatHandler)handler;
                rightContainer.Hide();

                if (((ChatHandler)handler).IsMucMessage)
                {
                    this.WindowTitle = chatHandler.Jid.Resource;
                }
                else
                {
                    this.WindowTitle = chatHandler.Account.GetDisplayName(chatHandler.Jid);
                }
                this.WindowIcon = new QIcon((QPixmap)Synapse.Xmpp.AvatarManager.GetAvatar(chatHandler.Jid));
            }

            m_ConversationWidget.ChatHandler = handler;

            handler.ReadyChanged += HandleReadyChanged;

            splitter.SetStretchFactor(1,0);
            splitter_2.SetStretchFactor(1,0);

            if (settingsService.Has("MucSplitterState"))
            {
                byte[] state = settingsService.Get <byte[]>("MucSplitterState");
                splitter_2.RestoreState(QByteArrayConverter.FromArray(state));
            }

            KeyPressEater eater = new KeyPressEater(this);

            eater.KeyEvent += HandleKeyEvent;
            textEdit.InstallEventFilter(eater);

            QToolBar toolbar = new QToolBar(this);

            toolbar.IconSize = new QSize(16,16);

            var formatMenuButton = new QToolButton(this);

            var formatMenu = new QMenu(this);

            QObject.Connect <QAction>(formatMenu,Qt.SIGNAL("triggered(QAction*)"),HandleFormatMenuActionTriggered);
            formatMenuButton.ToolButtonStyle = ToolButtonStyle.ToolButtonTextBesideIcon;
            formatMenuButton.Text            = "Format";
            formatMenuButton.icon            = Gui.LoadIcon("preferences-desktop-font",16);
            formatMenuButton.PopupMode       = QToolButton.ToolButtonPopupMode.InstantPopup;
            formatMenuButton.SetMenu(formatMenu);
            toolbar.AddWidget(formatMenuButton);

            m_BoldAction           = new QAction(Gui.LoadIcon("format-text-bold",16),"Bold",this);
            m_BoldAction.Shortcut  = "Ctrl+B";
            m_BoldAction.Checkable = true;
            formatMenu.AddAction(m_BoldAction);

            m_ItalicAction           = new QAction(Gui.LoadIcon("format-text-italic",16),"Italic",this);
            m_ItalicAction.Shortcut  = "Ctrl+I";
            m_ItalicAction.Checkable = true;
            formatMenu.AddAction(m_ItalicAction);

            m_UnderlineAction           = new QAction(Gui.LoadIcon("format-text-underline",16),"Underline",this);
            m_UnderlineAction.Shortcut  = "Ctrl+U";
            m_UnderlineAction.Checkable = true;
            formatMenu.AddAction(m_UnderlineAction);

            m_StrikethroughAction           = new QAction(Gui.LoadIcon("format-text-strikethrough",16),"Strikethrough",this);
            m_StrikethroughAction.Shortcut  = "Ctrl+S";
            m_StrikethroughAction.Checkable = true;
            formatMenu.AddAction(m_StrikethroughAction);

            formatMenu.AddSeparator();

            m_ClearFormattingAction = new QAction(Gui.LoadIcon("edit-clear",16),"Clear Formatting",this);
            formatMenu.AddAction(m_ClearFormattingAction);

            var insertMenu       = new QMenu(this);
            var insertMenuButton = new QToolButton(this);

            insertMenuButton.ToolButtonStyle = ToolButtonStyle.ToolButtonTextBesideIcon;
            insertMenuButton.Text            = "Insert";
            insertMenuButton.icon            = Gui.LoadIcon("image-x-generic",16);
            insertMenuButton.PopupMode       = QToolButton.ToolButtonPopupMode.InstantPopup;
            insertMenuButton.SetMenu(insertMenu);
            toolbar.AddWidget(insertMenuButton);

            m_InsertPhotoAction = new QAction(Gui.LoadIcon("insert-image",16),"Photo...",this);
            QObject.Connect(m_InsertPhotoAction,Qt.SIGNAL("triggered()"),HandleInsertImageActionTriggered);
            insertMenu.AddAction(m_InsertPhotoAction);

            m_InsertLinkAction = new QAction(Gui.LoadIcon("insert-link",16),"Link...",this);
            QObject.Connect(m_InsertLinkAction,Qt.SIGNAL("triggered()"),HandleInsertLinkActionTriggered);
            insertMenu.AddAction(m_InsertLinkAction);

            foreach (IActionCodon node in AddinManager.GetExtensionNodes("/Synapse/QtClient/ChatWindow/InsertActions"))
            {
                insertMenu.AddAction((QAction)node.CreateInstance(this));
            }

            toolbar.AddSeparator();

            var activitiesMenu       = new QMenu(this);
            var activitiesMenuButton = new QToolButton(this);

            activitiesMenuButton.ToolButtonStyle = ToolButtonStyle.ToolButtonTextBesideIcon;
            activitiesMenuButton.Text            = "Activities";
            activitiesMenuButton.icon            = Gui.LoadIcon("applications-games",16);   // FIXME: Not a good icon.
            activitiesMenuButton.PopupMode       = QToolButton.ToolButtonPopupMode.InstantPopup;
            activitiesMenuButton.SetMenu(activitiesMenu);
            toolbar.AddWidget(activitiesMenuButton);

            m_InviteToMucAction = new QAction(Gui.LoadIcon("internet-group-chat",16),"Invite to Conference...",this);
            QObject.Connect(m_InviteToMucAction,Qt.SIGNAL("triggered()"),HandleInviteToMucActionTriggered);
            activitiesMenu.AddAction(m_InviteToMucAction);
            activitiesMenu.AddSeparator();

            activitiesMenu.AddAction(Gui.LoadIcon("applications-graphics",16),"Launch Whiteboard...");
            activitiesMenu.AddAction(Gui.LoadIcon("user-desktop",16),"Share Desktop...");

            var spacerWidget = new QWidget(toolbar);

            spacerWidget.SetSizePolicy(QSizePolicy.Policy.Expanding,QSizePolicy.Policy.Fixed);
            toolbar.AddWidget(spacerWidget);

            var toContainer = new QWidget(toolbar);
            var layout      = new QHBoxLayout(toContainer);

            layout.SetContentsMargins(0,0,4,0);

            m_ToComboBox = new QComboBox(toContainer);

            layout.AddWidget(new QLabel("To:",toContainer));
            layout.AddWidget(m_ToComboBox);

            QAction toWidgetAction = (QWidgetAction)toolbar.AddWidget(toContainer);

            m_ToComboBox.AddItem("Automatic","auto");
            m_ToComboBox.InsertSeparator(1);

            ((QVBoxLayout)bottomContainer.Layout()).InsertWidget(0,toolbar);

            if (handler is ChatHandler)
            {
                var chatHandler = (ChatHandler)handler;
                handler.Account.Client.OnPresence += delegate(object sender,Presence pres) {
                    if (pres.From.Bare != chatHandler.Jid.Bare || pres.Priority == "-1")
                    {
                        return;
                    }
                    QApplication.Invoke(delegate {
                        if (!String.IsNullOrEmpty(pres.From.Resource))
                        {
                            if (pres.Type == PresenceType.available)
                            {
                                string text = String.Format("{0} ({1})",Helper.GetResourceDisplay(pres),Helper.GetPresenceDisplay(pres));
                                int i       = m_ToComboBox.FindData(pres.From.Resource);
                                if (i == -1)
                                {
                                    m_ToComboBox.AddItem(text,pres.From.Resource);
                                }
                                else
                                {
                                    m_ToComboBox.SetItemText(i,text);
                                }
                            }
                            else if (pres.Type == PresenceType.unavailable)
                            {
                                int i = m_ToComboBox.FindData(pres.From.Resource);
                                if (i > -1)
                                {
                                    m_ToComboBox.RemoveItem(i);
                                    m_ToComboBox.CurrentIndex = 0;
                                }
                            }
                        }

                        if (chatHandler.IsMucMessage)
                        {
                            toWidgetAction.Visible = false;
                        }
                        else
                        {
                            string title = null;
                            if (handler.Account.PresenceManager[pres.From.BareJID] == null)
                            {
                                title = String.Format("{0} (Offline)",chatHandler.Account.GetDisplayName(chatHandler.Jid));
                            }
                            else
                            {
                                title = chatHandler.Account.GetDisplayName(chatHandler.Jid);
                            }
                            Gui.TabbedChatsWindow.SetTabTitle(this,title);
                        }
                    });
                };

                foreach (var presence in chatHandler.Account.PresenceManager.GetAll(chatHandler.Jid))
                {
                    if (presence.Priority != "-1" && !String.IsNullOrEmpty(presence.From.Resource))
                    {
                        string text = String.Format("{0} ({1})",Helper.GetResourceDisplay(presence),Helper.GetPresenceDisplay(presence));
                        m_ToComboBox.AddItem(text,presence.From.Resource);
                    }
                }

                // FIXME: Make this a menu with "View Profile" and "View History".
                var viewProfileAction = new QAction(Gui.LoadIcon("info",16),"View Profile",this);
                QObject.Connect(viewProfileAction,Qt.SIGNAL("triggered()"),HandleViewProfileActionTriggered);
                toolbar.AddAction(viewProfileAction);
            }
            else
            {
                toWidgetAction.Visible = false;
            }

            QObject.Connect <bool>(m_ConversationWidget.Page(),Qt.SIGNAL("loadFinished(bool)"),delegate(bool ok) {
                if (!ok)
                {
                    throw new Exception("Failed to load chat html.");
                }
                handler.NewContent += HandleNewContent;
                m_Handler.FireQueued();
            });

            var settings = ServiceManager.Get <SettingsService>();

            m_ConversationWidget.ShowHeader    = settings.Get <bool>("MessageShowHeader");
            m_ConversationWidget.ShowUserIcons = settings.Get <bool>("MessageShowAvatars");
            m_ConversationWidget.LoadTheme(settings.Get <string>("MessageTheme"),settings.Get <string>("MessageThemeVariant"));
        }
Exemplo n.º 19
0
        void HandleNewContent(IChatHandler handler,AbstractChatContent content)
        {
            if (content is ChatContentTyping)
            {
                var typingContent = (ChatContentTyping)content;
                if (m_Handler is ChatHandler)
                {
                    var chatHandler = (ChatHandler)m_Handler;
                    if (!chatHandler.IsMucMessage)
                    {
                        string title = null;
                        if (typingContent.TypingState != TypingState.None && typingContent.TypingState != TypingState.Active)
                        {
                            title = String.Format("{0} ({1})",chatHandler.Account.GetDisplayName(chatHandler.Jid),typingContent.TypingState.ToString());
                        }
                        else
                        {
                            title = chatHandler.Account.GetDisplayName(chatHandler.Jid);
                        }
                        QApplication.Invoke(delegate {
                            Gui.TabbedChatsWindow.SetTabTitle(this,title);
                        });
                    }
                }
            }
            else
            {
                bool isSimilar = (!(content is ChatContentStatus)) && m_PreviousContent != null && content.IsSimilarToContent(m_PreviousContent);
                //bool replaceLast = m_PreviousContent is ChatContentStatus &&
                //	               content is ChatContentStatus &&
                //	               ((ChatContentStatus)m_PreviousContent).CoalescingKey == ((ChatContentStatus)content).CoalescingKey;
                bool replaceLast = m_PreviousContent is ChatContentTyping;

                m_PreviousContent = content;
                QApplication.Invoke(delegate {
                    m_ConversationWidget.AppendContent(content,isSimilar,false,replaceLast);

                    if (content is ChatContentMessage && !IsActive)
                    {
                        UrgencyHint = true;

                        if (m_Notification == null)
                        {
                            try {
                                string plainText = HtmlSanitizer.ToPlainText(((ChatContentMessage)content).MessageHtml);
                                // Only show notifications for MUC messages that contain your name.
                                if (m_Handler is ChatHandler || (m_Handler is MucHandler && plainText.Contains(((MucHandler)m_Handler).Room.Nickname)))
                                {
                                    if (m_Handler is MucHandler)
                                    {
                                        Gdk.Pixbuf pixbuf = Gdk.Pixbuf.LoadFromResource("internet-group-chat__32.png");
                                        string roomName   = ((MucHandler)m_Handler).Room.JID.Bare;
                                        m_Notification    = new Notification(String.Format("Message from {0} in {1}",content.SourceDisplayName,roomName),plainText,pixbuf);
                                    }
                                    else
                                    {
                                        // FIXME: Too much logic outside of AvatarManager.
                                        Gdk.Pixbuf pixbuf = null;
                                        string fileName   = AvatarManager.GetAvatarFileName(content.Source.BareJID);
                                        if (System.IO.File.Exists(fileName))
                                        {
                                            pixbuf = new Gdk.Pixbuf(fileName);
                                        }
                                        else
                                        {
                                            pixbuf = Gdk.Pixbuf.LoadFromResource("default-avatar.png");
                                        }
                                        m_Notification = new Notification(String.Format("Message from {0}",content.SourceDisplayName),plainText,pixbuf);
                                    }
                                    m_Notification.Show();
                                    m_Notification.Closed += delegate {
                                        m_Notification = null;
                                    };
                                }
                            } catch (Exception ex) {
                                Console.WriteLine("FAILED TO DISPLAY NOTIFICATION: " + ex);
                                m_Notification = null;
                            }
                        }
                    }

                    if (m_Handler is ChatHandler)
                    {
                        if (content is ChatContentMessage && (content.Source.Bare == ((ChatHandler)m_Handler).Jid.Bare))
                        {
                            // Select this resource so our replies go to it.
                            int i = m_ToComboBox.FindData(((ChatContentMessage)content).Source.Resource);
                            m_ToComboBox.CurrentIndex = (i > -1) ? i : 0;
                        }
                    }
                });
            }
        }
Exemplo n.º 20
0
 public ChatHub(IChatHandler chatHandler)
 {
     this.chatHandler = chatHandler;
 }
 public void OnChatsDisposed(IChatHandler chatHandler1, IChatHandler chatHandler2, TwoChatsHandlerStatus twoChatsHandlerStatus)
 {
 }
Exemplo n.º 22
0
        protected override void CloseEvent(QCloseEvent evnt)
        {
            if (Closed != null)
                Closed(this, EventArgs.Empty);

            m_Handler.NewContent -= HandleNewContent;
            m_Handler.Dispose();
            m_Handler = null;

            evnt.Accept();
        }
Exemplo n.º 23
0
        void HandleNewContent(IChatHandler handler, AbstractChatContent content)
        {
            if (content is ChatContentTyping) {
                var typingContent = (ChatContentTyping)content;
                if (m_Handler is ChatHandler) {
                    var chatHandler = (ChatHandler)m_Handler;
                    if (!chatHandler.IsMucMessage) {
                        string title = null;
                        if (typingContent.TypingState != TypingState.None && typingContent.TypingState != TypingState.Active) {
                            title = String.Format("{0} ({1})", chatHandler.Account.GetDisplayName(chatHandler.Jid), typingContent.TypingState.ToString());
                        } else {
                            title = chatHandler.Account.GetDisplayName(chatHandler.Jid);
                        }
                        QApplication.Invoke(delegate {
                            Gui.TabbedChatsWindow.SetTabTitle(this, title);
                        });
                    }
                }
            } else {
                bool isSimilar   = (!(content is ChatContentStatus)) && m_PreviousContent != null && content.IsSimilarToContent(m_PreviousContent);
                //bool replaceLast = m_PreviousContent is ChatContentStatus &&
                //	               content is ChatContentStatus &&
                //	               ((ChatContentStatus)m_PreviousContent).CoalescingKey == ((ChatContentStatus)content).CoalescingKey;
                bool replaceLast = m_PreviousContent is ChatContentTyping;

                m_PreviousContent = content;
                QApplication.Invoke(delegate {
                    m_ConversationWidget.AppendContent(content, isSimilar, false, replaceLast);

                    if (content is ChatContentMessage && !IsActive) {
                        UrgencyHint = true;

                        if (m_Notification == null) {
                            try {
                                string plainText = HtmlSanitizer.ToPlainText(((ChatContentMessage)content).MessageHtml);
                                // Only show notifications for MUC messages that contain your name.
                                if (m_Handler is ChatHandler || (m_Handler is MucHandler && plainText.Contains(((MucHandler)m_Handler).Room.Nickname))) {
                                    if (m_Handler is MucHandler) {
                                        Gdk.Pixbuf pixbuf = Gdk.Pixbuf.LoadFromResource("internet-group-chat__32.png");
                                        string roomName = ((MucHandler)m_Handler).Room.JID.Bare;
                                        m_Notification = new Notification(String.Format("Message from {0} in {1}", content.SourceDisplayName, roomName), plainText, pixbuf);

                                    } else {
                                        // FIXME: Too much logic outside of AvatarManager.
                                        Gdk.Pixbuf pixbuf = null;
                                        string fileName = AvatarManager.GetAvatarFileName(content.Source.BareJID);
                                        if (System.IO.File.Exists(fileName)) {
                                            pixbuf = new Gdk.Pixbuf(fileName);
                                        } else {
                                            pixbuf = Gdk.Pixbuf.LoadFromResource("default-avatar.png");
                                        }
                                        m_Notification = new Notification(String.Format("Message from {0}", content.SourceDisplayName), plainText, pixbuf);
                                    }
                                    m_Notification.Show();
                                    m_Notification.Closed += delegate {
                                        m_Notification = null;
                                    };
                                }
                            } catch (Exception ex) {
                                Console.WriteLine("FAILED TO DISPLAY NOTIFICATION: " + ex);
                                m_Notification = null;
                            }
                        }
                    }

                    if (m_Handler is ChatHandler) {
                        if (content is ChatContentMessage && (content.Source.Bare == ((ChatHandler)m_Handler).Jid.Bare)) {
                            // Select this resource so our replies go to it.
                            int i = m_ToComboBox.FindData(((ChatContentMessage)content).Source.Resource);
                            m_ToComboBox.CurrentIndex = (i > -1) ? i : 0;
                        }
                    }
                });
            }
        }
Exemplo n.º 24
0
        internal ChatWindow(IChatHandler handler)
        {
            if (handler == null)
                throw new ArgumentNullException("handler");
            m_Handler = handler;

            SetupUi();

            if (handler is MucHandler) {
                m_ParticipantsMenu = new QMenu(this);
                QObject.Connect(m_ParticipantsMenu, Qt.SIGNAL("aboutToShow()"), HandleMenuAboutToShow);
                QObject.Connect(m_ParticipantsMenu, Qt.SIGNAL("aboutToHide()"), HandleMenuAboutToHide);

                var mucHandler = (MucHandler)handler;
                participantsGrid.Model = mucHandler.GridModel;
                participantsGrid.ContextMenuPolicy = Qt.ContextMenuPolicy.CustomContextMenu;
                participantsGrid.ItemActivated += HandleItemActivated;

                var group = new QActionGroup(this);

                var gridModeAction = new QAction("View as Grid", this);
                QObject.Connect(gridModeAction, Qt.SIGNAL("triggered()"), HandleGridModeActionTriggered);
                gridModeAction.SetActionGroup(group);
                gridModeAction.Checkable = true;
                gridModeAction.Checked = true;
                m_ParticipantsMenu.AddAction(gridModeAction);

                var listModeAction = new QAction("View as List", this);
                QObject.Connect(listModeAction, Qt.SIGNAL("triggered()"), HandleListModeActionTriggered);
                listModeAction.SetActionGroup(group);
                listModeAction.Checkable = true;
                m_ParticipantsMenu.AddAction(listModeAction);

                var separatorAction = new QAction(participantsGrid);
                separatorAction.SetSeparator(true);
                m_ParticipantsMenu.AddAction(separatorAction);

                var sliderAction = new AvatarGridZoomAction<jabber.connection.RoomParticipant>(participantsGrid);
                m_ParticipantsMenu.AddAction(sliderAction);

                m_ParticipantItemMenu = new QMenu(this);
                QObject.Connect(m_ParticipantItemMenu, Qt.SIGNAL("aboutToShow()"), HandleMenuAboutToShow);
                QObject.Connect(m_ParticipantItemMenu, Qt.SIGNAL("aboutToHide()"), HandleMenuAboutToHide);

                var mucViewProfileAction = new QAction("View Profile", this);
                QObject.Connect(mucViewProfileAction, Qt.SIGNAL("triggered()"), HandleMucViewProfileActionTriggered);
                m_ParticipantItemMenu.AddAction(mucViewProfileAction);

                var mucPrivateMessageAction = new QAction("IM", this);
                QObject.Connect(mucPrivateMessageAction, Qt.SIGNAL("triggered()"), HandleMucPrivateMessageTriggered);
                m_ParticipantItemMenu.AddAction(mucPrivateMessageAction);

                var mucSendFileAction = new QAction("Send File...", this);
                QObject.Connect(mucSendFileAction, Qt.SIGNAL("triggered()"), HandleMucSendFileActionTriggered);
                m_ParticipantItemMenu.AddAction(mucSendFileAction);

                var mucViewHistoryAction = new QAction("View History", this);
                QObject.Connect(mucViewHistoryAction, Qt.SIGNAL("triggered()"), HandleMucViewHistoryActionTriggered);
                m_ParticipantItemMenu.AddAction(mucViewHistoryAction);

                m_ModeratorActionsMenu = new QMenu("Moderator Actions", this);

                var roomRoleActionGroup = new QActionGroup(this);
                QObject.Connect(roomRoleActionGroup, Qt.SIGNAL("triggered(QAction*)"), this, Qt.SLOT("HandleRoomRoleActionGroupTriggered(QAction*)"));

                m_ModeratorAction = new QAction("Moderator", this);
                roomRoleActionGroup.AddAction(m_ModeratorAction);
                m_ModeratorAction.Checkable = true;
                m_ModeratorActionsMenu.AddAction(m_ModeratorAction);

                m_ParticipantAction = new QAction("Participant", this);
                roomRoleActionGroup.AddAction(m_ParticipantAction);
                m_ParticipantAction.Checkable = true;
                m_ModeratorActionsMenu.AddAction(m_ParticipantAction);

                m_VisitorAction = new QAction("Visitor", this);
                roomRoleActionGroup.AddAction(m_VisitorAction);
                m_VisitorAction.Checkable = true;
                m_ModeratorActionsMenu.AddAction(m_VisitorAction);

                m_ModeratorActionsMenu.AddSeparator();

                var mucKickAction = new QAction("Kick...", this);
                QObject.Connect(mucKickAction, Qt.SIGNAL("triggered()"), HandleMucKickActionTriggered);
                m_ModeratorActionsMenu.AddAction(mucKickAction);

                var mucBanAction = new QAction("Ban...", this);
                QObject.Connect(mucBanAction, Qt.SIGNAL("triggered()"), HandleMucBanActionTriggered);
                m_ModeratorActionsMenu.AddAction(mucBanAction);

                m_ModeratorActionsMenu.AddSeparator();

                m_ChangeAffiliationAction = new QAction("Change Affiliation...", this);
                QObject.Connect(m_ChangeAffiliationAction, Qt.SIGNAL("triggered()"), HandleChangeAffiliationTriggered);
                m_ModeratorActionsMenu.AddAction(m_ChangeAffiliationAction);

                m_ParticipantItemMenu.AddSeparator();
                m_ParticipantItemMenu.AddMenu(m_ModeratorActionsMenu);

                m_ParticipantItemMenu.AddSeparator();

                m_AddAsFriendAction = new QAction("Add as Friend", this);
                m_ParticipantItemMenu.AddAction(m_AddAsFriendAction);

                this.WindowTitle = mucHandler.Room.JID.User; // FIXME: Show only "user" in tab, show full room jid in title?
                this.WindowIcon = Gui.LoadIcon("internet-group-chat");
            } else {
                var chatHandler = (ChatHandler)handler;
                rightContainer.Hide();

                if (((ChatHandler)handler).IsMucMessage) {
                    this.WindowTitle = chatHandler.Jid.Resource;
                } else {
                    this.WindowTitle = chatHandler.Account.GetDisplayName(chatHandler.Jid);
                }
                this.WindowIcon = new QIcon((QPixmap)Synapse.Xmpp.AvatarManager.GetAvatar(chatHandler.Jid));
            }

            m_ConversationWidget.ChatHandler = handler;

            handler.ReadyChanged += HandleReadyChanged;

            splitter.SetStretchFactor(1, 0);
            splitter_2.SetStretchFactor(1, 0);

            KeyPressEater eater = new KeyPressEater(this);
            eater.KeyEvent += HandleKeyEvent;
            textEdit.InstallEventFilter(eater);

            QToolBar toolbar = new QToolBar(this);
            toolbar.IconSize = new QSize(16, 16);

            var formatMenuButton = new QToolButton(this);

            var formatMenu = new QMenu(this);
            QObject.Connect<QAction>(formatMenu, Qt.SIGNAL("triggered(QAction*)"), HandleFormatMenuActionTriggered);
            formatMenuButton.ToolButtonStyle = ToolButtonStyle.ToolButtonTextBesideIcon;
            formatMenuButton.Text = "Format";
            formatMenuButton.icon = Gui.LoadIcon("fonts", 16);
            formatMenuButton.PopupMode = QToolButton.ToolButtonPopupMode.InstantPopup;
            formatMenuButton.SetMenu(formatMenu);
            toolbar.AddWidget(formatMenuButton);

            m_BoldAction = new QAction(Gui.LoadIcon("format-text-bold", 16), "Bold", this);
            m_BoldAction.Shortcut = "Ctrl+B";
            m_BoldAction.Checkable = true;
            formatMenu.AddAction(m_BoldAction);

            m_ItalicAction = new QAction(Gui.LoadIcon("format-text-italic", 16), "Italic", this);
            m_ItalicAction.Shortcut = "Ctrl+I";
            m_ItalicAction.Checkable = true;
            formatMenu.AddAction(m_ItalicAction);

            m_UnderlineAction = new QAction(Gui.LoadIcon("format-text-underline", 16), "Underline", this);
            m_UnderlineAction.Shortcut = "Ctrl+U";
            m_UnderlineAction.Checkable = true;
            formatMenu.AddAction(m_UnderlineAction);

            m_StrikethroughAction = new QAction(Gui.LoadIcon("format-text-strikethrough", 16), "Strikethrough", this);
            m_StrikethroughAction.Shortcut = "Ctrl+S";
            m_StrikethroughAction.Checkable = true;
            formatMenu.AddAction(m_StrikethroughAction);

            formatMenu.AddSeparator();

            m_ClearFormattingAction = new QAction(Gui.LoadIcon("edit-clear", 16), "Clear Formatting", this);
            formatMenu.AddAction(m_ClearFormattingAction);

            var insertMenu = new QMenu(this);
            var insertMenuButton = new QToolButton(this);
            insertMenuButton.ToolButtonStyle = ToolButtonStyle.ToolButtonTextBesideIcon;
            insertMenuButton.Text = "Insert";
            insertMenuButton.icon = Gui.LoadIcon("image", 16);
            insertMenuButton.PopupMode = QToolButton.ToolButtonPopupMode.InstantPopup;
            insertMenuButton.SetMenu(insertMenu);
            toolbar.AddWidget(insertMenuButton);

            m_InsertPhotoAction = new QAction(Gui.LoadIcon("insert-image", 16), "Photo...", this);
            QObject.Connect(m_InsertPhotoAction, Qt.SIGNAL("triggered()"), HandleInsertImageActionTriggered);
            insertMenu.AddAction(m_InsertPhotoAction);

            m_InsertLinkAction = new QAction(Gui.LoadIcon("insert-link", 16), "Link...", this);
            QObject.Connect(m_InsertLinkAction, Qt.SIGNAL("triggered()"), HandleInsertLinkActionTriggered);
            insertMenu.AddAction(m_InsertLinkAction);

            foreach (IActionCodon node in AddinManager.GetExtensionNodes("/Synapse/QtClient/ChatWindow/InsertActions")) {
                insertMenu.AddAction((QAction)node.CreateInstance(this));
            }

            toolbar.AddSeparator();

            var activitiesMenu = new QMenu(this);
            var activitiesMenuButton = new QToolButton(this);
            activitiesMenuButton.ToolButtonStyle = ToolButtonStyle.ToolButtonTextBesideIcon;
            activitiesMenuButton.Text = "Activities";
            activitiesMenuButton.icon = Gui.LoadIcon("applications-games", 16); // FIXME: Not a good icon.
            activitiesMenuButton.PopupMode = QToolButton.ToolButtonPopupMode.InstantPopup;
            activitiesMenuButton.SetMenu(activitiesMenu);
            toolbar.AddWidget(activitiesMenuButton);

            m_InviteToMucAction = new QAction(Gui.LoadIcon("internet-group-chat", 16), "Invite to Conference...", this);
            QObject.Connect(m_InviteToMucAction, Qt.SIGNAL("triggered()"), HandleInviteToMucActionTriggered);
            activitiesMenu.AddAction(m_InviteToMucAction);
            activitiesMenu.AddSeparator();

            activitiesMenu.AddAction(Gui.LoadIcon("applications-graphics", 16), "Launch Whiteboard...");
            activitiesMenu.AddAction(Gui.LoadIcon("desktop", 16), "Share Desktop...");

            var spacerWidget = new QWidget(toolbar);
            spacerWidget.SetSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed);
            toolbar.AddWidget(spacerWidget);

            var toContainer = new QWidget(toolbar);
            var layout = new QHBoxLayout(toContainer);
            layout.SetContentsMargins(0, 0, 4, 0);

            m_ToComboBox = new QComboBox(toContainer);

            layout.AddWidget(new QLabel("To:", toContainer));
            layout.AddWidget(m_ToComboBox);

            QAction toWidgetAction = (QWidgetAction)toolbar.AddWidget(toContainer);

            m_ToComboBox.AddItem("Automatic", "auto");
            m_ToComboBox.InsertSeparator(1);

            ((QVBoxLayout)bottomContainer.Layout()).InsertWidget(0, toolbar);

            if (handler is ChatHandler) {
                var chatHandler = (ChatHandler)handler;
                handler.Account.Client.OnPresence += delegate(object sender, Presence pres) {
                    if (pres.From.Bare != chatHandler.Jid.Bare || pres.Priority == "-1") {
                        return;
                    }
                    QApplication.Invoke(delegate {
                        if (!String.IsNullOrEmpty(pres.From.Resource)) {
                            if (pres.Type == PresenceType.available) {
                                string text = String.Format("{0} ({1})", Helper.GetResourceDisplay(pres), Helper.GetPresenceDisplay(pres));
                                int i = m_ToComboBox.FindData(pres.From.Resource);
                                if (i == -1) {
                                    m_ToComboBox.AddItem(text, pres.From.Resource);
                                } else {
                                    m_ToComboBox.SetItemText(i, text);
                                }
                            } else if (pres.Type == PresenceType.unavailable) {
                                int i = m_ToComboBox.FindData(pres.From.Resource);
                                if (i > -1) {
                                    m_ToComboBox.RemoveItem(i);
                                    m_ToComboBox.CurrentIndex = 0;
                                }
                            }
                        }

                        if (chatHandler.IsMucMessage) {
                            toWidgetAction.Visible = false;
                        } else {
                            string title = null;
                            if (handler.Account.PresenceManager[pres.From.BareJID] == null) {
                                title = String.Format("{0} (Offline)", chatHandler.Account.GetDisplayName(chatHandler.Jid));
                            } else {
                                title = chatHandler.Account.GetDisplayName(chatHandler.Jid);
                            }
                            Gui.TabbedChatsWindow.SetTabTitle(this, title);
                        }
                    });
                };

                foreach (var presence in chatHandler.Account.PresenceManager.GetAll(chatHandler.Jid)) {
                    if (presence.Priority != "-1" && !String.IsNullOrEmpty(presence.From.Resource)) {
                        string text = String.Format("{0} ({1})", Helper.GetResourceDisplay(presence), Helper.GetPresenceDisplay(presence));
                        m_ToComboBox.AddItem(text, presence.From.Resource);
                    }
                }

                // FIXME: Make this a menu with "View Profile" and "View History".
                var viewProfileAction = new QAction(Gui.LoadIcon("info", 16), "View Profile", this);
                QObject.Connect(viewProfileAction, Qt.SIGNAL("triggered()"), HandleViewProfileActionTriggered);
                toolbar.AddAction(viewProfileAction);
            } else {
                toWidgetAction.Visible = false;
            }

            QObject.Connect<bool>(m_ConversationWidget.Page(), Qt.SIGNAL("loadFinished(bool)"), delegate (bool ok) {
                if (!ok) {
                    throw new Exception("Failed to load chat html.");
                }
                handler.NewContent += HandleNewContent;
                m_Handler.FireQueued();
            });

            var settings = ServiceManager.Get<SettingsService>();
            m_ConversationWidget.ShowHeader = settings.Get<bool>("MessageShowHeader");
            m_ConversationWidget.ShowUserIcons = settings.Get<bool>("MessageShowAvatars");
            m_ConversationWidget.LoadTheme(settings.Get<string>("MessageTheme"), settings.Get<string>("MessageThemeVariant"));
        }
Exemplo n.º 25
0
 public ChatController(ILogger <ChatController> logger,
                       IChatHandler chatHandler)
 {
     this.logger      = logger;
     this.chatHandler = chatHandler;
 }
Exemplo n.º 26
0
 public MessageController(NotificationsMessageHandler notificationsMessageHandler, IChatHandler chatHandler)
 {
     _notificationsMessageHandler = notificationsMessageHandler;
     _chatHandler = chatHandler;
 }
 public SessionStorageHelper(IChatHandler chatHandler)
 {
     _chatHandler = chatHandler;
 }
Exemplo n.º 28
0
 public UserController(NotificationsMessageHandler notificationsMessageHandler, IUserHandler userHandler, IChatHandler chatHandler)
 {
     _userHandler = userHandler;
     _chatHandler = chatHandler;
     _notificationsMessageHandler = notificationsMessageHandler;
 }
Exemplo n.º 29
0
 public void AddHandler(IChatHandler handler)
 {
     _handler.Add(handler);
 }
Exemplo n.º 30
0
 void Start()
 {
     CharacterListController   = new CharacterListController(this);
     CharacterCreateController = new CharacterCreateController(this);
     ChatController            = new ChatHandler(this);
 }
Exemplo n.º 31
0
 public ChatController(IChatHandler chatHandler)
 {
     _chatHandler = chatHandler;
     _user        = new User();
 }
Exemplo n.º 32
0
 public ChatController(IChatHandler chatHandler)
 {
     _chatHandler = chatHandler;
 }