def openConversation(self, msnp, mail, weStarted, switchboard=None):
        '''opens a new conversation and a new window or tab'''

        # create new switchboard if needed
        if switchboard is None:
            switchboard = msnp.newSwitchboard()
            switchboard.invite(mail)

        conversation = Conversation.Conversation(self.controller, switchboard)

        # add a tab if we use tabs and if there is a window open already
        useTabs = not self.config.user['windows']
        if useTabs and len(self.conversations) > 0:
            # open a new tab
            window = self.conversations[0][0]
            window.openTab(conversation)
            if weStarted:
                window.present()
        else:
            # open a new window
            window = ConversationWindow.ConversationWindow(
                self.controller, conversation)
            window.show()
            if self.config.user['hideNewWindow'] and not weStarted:
                window.iconify()

        conversation.setWindow(window)
        window.set_icon(conversation.getWindowIcon())
        self.conversations.append((window, conversation))
        self.emit('new-conversation-ui', conversation, window)

        return window, conversation
Exemplo n.º 2
0
 def parse_data_to_case_class(input):
     conversations = []
     with open(input["data_path"] + ".json", encoding="utf8") as data:
         print("Successfully opened " + input["data_path"] + ".json...")
         for conversation in ijson.items(data,
                                         'conversations.conversation.item'):
             id = conversation["@id"]
             messages = []
             for message in conversation["message"]:
                 messages.append(
                     Message.Message(message["author"], message["time"],
                                     str(message["text"])))
             conversations.append(Conversation.Conversation(id, messages))
     return conversations
Exemplo n.º 3
0
    def _on_conversation_request(self, message):
        '''handle a conversation request, example
        RNG 1581441881 64.4.37.33:1863 CKI 252199185.167235214
        [email protected] tuza U messenger.msn.com'''
        session_id = message.tid
        (chost, auth_type, auth_id, user, username, unk, server, unk2) = \
        message.params

        (host, port) = chost.split(':')

        cid = time.time()
        con = Conversation.Conversation(self.session, cid, host, int(port),
                                        user, session_id, self.p2p, auth_id)
        self.conversations[cid] = con
        con.answer()
        con.start()
Exemplo n.º 4
0
    def _on_conversation_transfer(self, message):
        '''handle a message that inform us that we must start a new switchboard
        with a server'''
        # XFR 10
        # SB 207.46.27.178:1863 CKI 212949295.5321588.019445 U
        # messenger.msn.com 1

        if len(message.params) == 6:
            (sb_, chost, cki, session_id, unk, server) = message.params
        else:
            (sb_, chost, cki, session_id, unk, server, one) = message.params

        (host, port) = chost.split(':')
        account, cid = self.pending_conversations[int(message.tid)]
        messages = self.pending_messages[cid]

        del self.pending_conversations[int(message.tid)]
        del self.pending_messages[cid]

        if cid in self.pending_cids:
            self.pending_cids.remove(cid)

        if cid not in self.conversations:
            con = Conversation.Conversation(self.session, cid, host, int(port),
                                            account, session_id, self.p2p,
                                            self.proxy)
            self.conversations[cid] = con
            con.send_presentation()
            con.invite(account)
            con.start()
        else:
            con = self.conversations[cid]
            con.reconnect(host, int(port), session_id)

        # send all the pending messages
        for message in messages:
            con.send_message(message)