| 1602 | | mtype = msg.getType() |
| 1603 | | thread_id = msg.getThread() |
| 1604 | | |
| 1605 | | if not mtype: |
| 1606 | | mtype = 'normal' |
| 1607 | | |
| 1608 | | game_invite = msg.getTag('invite', namespace='http://jabber.org/protocol/games') |
| 1609 | | if game_invite: |
| 1610 | | game = game_invite.getTag('game') |
| 1611 | | |
| 1612 | | if game.getAttr('var') == \ |
| 1613 | | 'http://jabber.org/protocol/games/tictactoe': |
| 1614 | | klass = tictactoe.TicTacToeSession |
| 1615 | | |
| 1616 | | # this assumes that the invitation came with a thread_id we haven't |
| 1617 | | # seen |
| 1618 | | session = self.make_new_session(frm, thread_id, klass=klass) |
| 1619 | | |
| 1620 | | session.invited(msg) |
| 1621 | | |
| 1622 | | return |
| 1623 | | elif mtype != 'groupchat': |
| 1624 | | session = self.get_or_create_session(frm, thread_id) |
| 1625 | | |
| 1626 | | if thread_id and not session.received_thread_id: |
| 1627 | | session.received_thread_id = True |
| 1638 | | |
| 1639 | | # check if the message is a XEP-0020 feature negotiation request |
| 1640 | | if msg.getTag('feature', namespace=common.xmpp.NS_FEATURE): |
| 1641 | | if gajim.HAVE_PYCRYPTO: |
| 1642 | | self._FeatureNegCB(con, msg, session) |
| 1643 | | return |
| 1644 | | if msg.getTag('init', namespace=common.xmpp.NS_ESESSION_INIT): |
| 1645 | | self._InitE2ECB(con, msg, session) |
| 1646 | | |
| 1647 | | encrypted = False |
| 1648 | | tim = msg.getTimestamp() |
| 1649 | | tim = helpers.datetime_tuple(tim) |
| 1650 | | tim = localtime(timegm(tim)) |
| 1651 | | |
| 1652 | | if msg.getTag('c', namespace=common.xmpp.NS_STANZA_CRYPTO): |
| 1653 | | encrypted = True |
| 1654 | | |
| 1655 | | try: |
| 1656 | | msg = session.decrypt_stanza(msg) |
| 1657 | | except: |
| 1658 | | self.dispatch('FAILED_DECRYPT', (frm, tim, session)) |
| 1659 | | |
| 1660 | | msgtxt = msg.getBody() |
| 1661 | | subject = msg.getSubject() # if not there, it's None |
| 1662 | | |
| 1663 | | frm = helpers.get_full_jid_from_iq(msg) |
| 1664 | | jid = helpers.get_jid_from_iq(msg) |
| 1665 | | |
| 1666 | | addressTag = msg.getTag('addresses', namespace = common.xmpp.NS_ADDRESS) |
| 1667 | | |
| 1668 | | # Be sure it comes from one of our resource, else ignore address element |
| 1669 | | if addressTag and jid == gajim.get_jid_from_account(self.name): |
| 1670 | | address = addressTag.getTag('address', attrs={'type': 'ofrom'}) |
| 1671 | | if address: |
| 1672 | | frm = address.getAttr('jid') |
| 1673 | | jid = gajim.get_jid_without_resource(frm) |
| | 1635 | |
| | 1636 | mtype = msg.getType() |
| | 1637 | thread_id = msg.getThread() |
| | 1638 | |
| | 1639 | if not mtype: |
| | 1640 | mtype = 'normal' |
| | 1641 | |
| | 1642 | game_invite = msg.getTag('invite', namespace='http://jabber.org/protocol/games') |
| | 1643 | if game_invite: |
| | 1644 | game = game_invite.getTag('game') |
| | 1645 | |
| | 1646 | if game.getAttr('var') == \ |
| | 1647 | 'http://jabber.org/protocol/games/tictactoe': |
| | 1648 | klass = tictactoe.TicTacToeSession |
| | 1649 | |
| | 1650 | # this assumes that the invitation came with a thread_id we haven't |
| | 1651 | # seen |
| | 1652 | session = self.make_new_session(frm, thread_id, klass=klass) |
| | 1653 | |
| | 1654 | session.invited(msg) |
| | 1655 | |
| | 1656 | return |
| | 1657 | elif mtype != 'groupchat': |
| | 1658 | session = self.get_or_create_session(frm, thread_id) |
| | 1659 | |
| | 1660 | if thread_id and not session.received_thread_id: |
| | 1661 | session.received_thread_id = True |
| | 1662 | |
| | 1663 | # check if the message is a XEP-0020 feature negotiation request |
| | 1664 | if msg.getTag('feature', namespace=common.xmpp.NS_FEATURE): |
| | 1665 | if gajim.HAVE_PYCRYPTO: |
| | 1666 | self._FeatureNegCB(con, msg, session) |
| | 1667 | return |
| | 1668 | if msg.getTag('init', namespace=common.xmpp.NS_ESESSION_INIT): |
| | 1669 | self._InitE2ECB(con, msg, session) |
| | 1670 | |
| | 1671 | encrypted = False |
| | 1672 | tim = msg.getTimestamp() |
| | 1673 | tim = helpers.datetime_tuple(tim) |
| | 1674 | tim = localtime(timegm(tim)) |
| | 1675 | |
| | 1676 | if msg.getTag('c', namespace=common.xmpp.NS_STANZA_CRYPTO): |
| | 1677 | encrypted = True |
| | 1678 | |
| | 1679 | try: |
| | 1680 | msg = session.decrypt_stanza(msg) |
| | 1681 | except: |
| | 1682 | self.dispatch('FAILED_DECRYPT', (frm, tim, session)) |
| | 1683 | |
| | 1684 | msgtxt = msg.getBody() |
| | 1685 | subject = msg.getSubject() # if not there, it's None |
| | 1686 | |
| | 1687 | jid = helpers.get_jid_from_iq(msg) |
| | 1688 | |
| | 1689 | addressTag = msg.getTag('addresses', namespace = common.xmpp.NS_ADDRESS) |
| | 1690 | |
| | 1691 | # Be sure it comes from one of our resource, else ignore address element |
| | 1692 | if addressTag and jid == gajim.get_jid_from_account(self.name): |
| | 1693 | address = addressTag.getTag('address', attrs={'type': 'ofrom'}) |
| | 1694 | if address: |
| | 1695 | frm = address.getAttr('jid') |
| | 1696 | jid = gajim.get_jid_without_resource(frm) |