def sendMessageToTab(self, command, sourceNick, payload):
        # If a typing command, update the typing status in the tab, otherwise
        # show the message in the tab
        tab, tabIndex = self.getTabByNick(sourceNick)
        if command == constants.COMMAND_TYPING:
            # Show the typing status in the status bar if the tab is the selected tab
            if tabIndex == self.chatTabs.currentIndex():
                payload = int(payload)
                if payload == constants.TYPING_START:
                    self.statusBar.showMessage("%s is typing" % sourceNick)
                elif payload == constants.TYPING_STOP_WITHOUT_TEXT:
                    self.statusBar.showMessage('')
                elif payload == constants.TYPING_STOP_WITH_TEXT:
                    self.statusBar.showMessage("%s has entered text" % sourceNick)
        elif command == constants.COMMAND_SMP_0:
            print('got request for smp in tab %d' % (tabIndex))
        else:
            tab.appendMessage(payload, constants.RECEIVER)

            # Update the unread message count if the message is not intended for the currently selected tab
            if tabIndex != self.chatTabs.currentIndex():
                tab.unreadCount += 1
                self.chatTabs.setTabText(tabIndex, "%s (%d)" % (tab.nick, tab.unreadCount))
            else:
                # Clear the typing status if the current tab
                self.statusBar.showMessage('')

            # Show a system notifcation of the new message if not the current window or tab or the
            # scrollbar of the tab isn't at the bottom
            chatLogScrollbar = tab.widgetStack.widget(2).chatLog.verticalScrollBar()
            if not self.isActiveWindow() or tabIndex != self.chatTabs.currentIndex() or \
               chatLogScrollbar.value() != chatLogScrollbar.maximum():
                qtUtils.showDesktopNotification(self.systemTrayIcon, sourceNick, payload)
    def newClientSlot(self, nick):
        nick = str(nick)

        # Show a system notifcation of the new client if not the current window
        if not self.isActiveWindow():
            qtUtils.showDesktopNotification(self.systemTrayIcon, "Chat request from %s" % nick, '')

        # Show the accept dialog
        accept = QAcceptDialog.getAnswer(self, nick)

        if not accept:
            self.connectionManager.newClientRejected(nick)
            return

        # If nick already has a tab, reuse it
        if self.isNickInTabs(nick):
            self.getTabByNick(nick)[0].enable()
        else:
            self.addNewTab(nick)

        self.connectionManager.newClientAccepted(nick)