How to use the nbxmpp.NodeProcessed function in nbxmpp

To help you get started, we’ve selected a few nbxmpp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gajim / gajim / gajim / common / modules / bytestream.py View on Github external
def _on_result(self, _con, iq_obj, _properties):
        # if we want to respect xep-0065 we have to check for proxy
        # activation result in any result iq
        real_id = iq_obj.getAttr('id')
        if real_id is None:
            log.warning('Invalid IQ without id attribute:\n%s', iq_obj)
            raise nbxmpp.NodeProcessed
        if real_id is None or not real_id.startswith('au_'):
            return
        frm = self._ft_get_from(iq_obj)
        id_ = real_id[3:]
        file_props = FilesProp.getFilePropByTransportSid(self._account, id_)
        if file_props.streamhost_used:
            for host in file_props.proxyhosts:
                if host['initiator'] == frm and 'idx' in host:
                    app.socks5queue.activate_proxy(host['idx'])
                    raise nbxmpp.NodeProcessed
github gajim / gajim / gajim / common / modules / ping.py View on Github external
def _answer_request(self,
                        _con: ConnectionT,
                        stanza: nbxmpp.Iq,
                        _properties: Any) -> None:
        iq = stanza.buildReply('result')
        ping = iq.getTag('ping')
        if ping is not None:
            iq.delChild(ping)
        self._con.connection.send(iq)
        self._log.info('Send pong to %s', stanza.getFrom())
        raise nbxmpp.NodeProcessed
github gajim / gajim / gajim / common / modules / presence.py View on Github external
def _subscribed_received(self, _con, _stanza, properties):
        jid = properties.jid.getBare()
        self._log.info('Received Subscribed: %s', properties.jid)
        if jid in self.automatically_added:
            self.automatically_added.remove(jid)
            raise nbxmpp.NodeProcessed

        app.nec.push_incoming_event(NetworkEvent(
            'subscribed-presence-received',
            account=self._account,
            jid=properties.jid))
        raise nbxmpp.NodeProcessed
github gajim / gajim / gajim / common / modules / entity_time.py View on Github external
iq = stanza.buildReply('result')
            time_ = iq.setTag('time', namespace=Namespace.TIME_REVISED)
            formated_time = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime())
            time_.setTagData('utc', formated_time)
            isdst = time.localtime().tm_isdst
            zone = -(time.timezone, time.altzone)[isdst] / 60.0
            tzo = (zone / 60, abs(zone % 60))
            time_.setTagData('tzo', '%+03d:%02d' % (tzo))
            self._log.info('Answer: %s %s', formated_time, '%+03d:%02d' % (tzo))
        else:
            iq = stanza.buildReply('error')
            err = nbxmpp.ErrorNode(nbxmpp.ERR_SERVICE_UNAVAILABLE)
            iq.addChild(node=err)
            self._log.info('Send service-unavailable')
        self._con.connection.send(iq)
        raise nbxmpp.NodeProcessed
github gajim / gajim / gajim / common / modules / adhoc_commands.py View on Github external
newcmd = self._commands[node]
            if not newcmd.is_visible_for(self.is_same_jid(jid)):
                self._log.warning('Command not visible for jid: %s', jid)
                raise nbxmpp.NodeProcessed

            # generate new sessionid
            sessionid = generate_id()

            # create new instance and run it
            obj = newcmd(conn=self, jid=jid, sessionid=sessionid)
            rc = obj.execute(stanza)
            if rc:
                self._sessions[(jid, sessionid, node)] = obj
            self._log.info('Comand %s executed: %s', node, jid)
            raise nbxmpp.NodeProcessed

        # the command is already running, check for it
        magictuple = (jid, sessionid, node)
        if magictuple not in self._sessions:
            # we don't have this session... ha!
            self._log.warning('Invalid session %s', magictuple)
            raise nbxmpp.NodeProcessed

        action = cmd.getAttr('action')
        obj = self._sessions[magictuple]

        try:
            if action == 'cancel':
                rc = obj.cancel(stanza)
            elif action == 'prev':
                rc = obj.prev(stanza)
github gajim / gajim / gajim / common / modules / iq.py View on Github external
self._con.get_module('Bytestream').disconnect_transfer(
                    file_props)
                raise nbxmpp.NodeProcessed

        if properties.error.condition == 'item-not-found':
            sid = self._get_sid(properties.id)
            file_props = FilesProp.getFileProp(self._account, sid)
            if file_props:
                app.nec.push_incoming_event(
                    NetworkEvent('file-send-error',
                                 account=self._account,
                                 jid=str(properties.jid),
                                 file_props=file_props))
                self._con.get_module('Bytestream').disconnect_transfer(
                    file_props)
                raise nbxmpp.NodeProcessed

        app.nec.push_incoming_event(
            NetworkEvent('iq-error-received',
                         account=self._account,
                         properties=properties))
        raise nbxmpp.NodeProcessed
github gajim / gajim / gajim / common / modules / muc.py View on Github external
def _on_voice_request(self, _con, _stanza, properties):
        if not properties.is_voice_request:
            return

        jid = str(properties.jid)
        contact = app.contacts.get_groupchat_contact(self._account, jid)
        if contact is None:
            return

        app.nec.push_incoming_event(
            NetworkEvent('muc-voice-request',
                         account=self._account,
                         room_jid=str(properties.muc_jid),
                         voice_request=properties.voice_request))
        raise nbxmpp.NodeProcessed
github gajim / gajim / gajim / common / modules / mam.py View on Github external
if properties.from_.bareMatch(self._con.get_own_jid()):
                kind = KindConstant.CHAT_MSG_SENT
            else:
                kind = KindConstant.CHAT_MSG_RECV

        stanza_id, message_id = self._get_unique_id(properties)

        # Search for duplicates
        if app.logger.find_stanza_id(self._account,
                                     str(properties.mam.archive),
                                     stanza_id,
                                     message_id,
                                     groupchat=is_groupchat):
            self._log.info('Found duplicate with stanza-id: %s, '
                           'message-id: %s', stanza_id, message_id)
            raise nbxmpp.NodeProcessed

        additional_data = AdditionalDataDict()
        if properties.has_user_delay:
            # Record it as a user timestamp
            additional_data.set_value(
                'gajim', 'user_timestamp', properties.user_timestamp)

        parse_oob(properties, additional_data)

        msgtxt = properties.body

        if properties.is_encrypted:
            additional_data['encrypted'] = properties.encrypted.additional_data
        else:
            if properties.eme is not None:
                msgtxt = get_eme_message(properties.eme)
github gajim / gajim / gajim / common / modules / jingle.py View on Github external
sesn.on_stanza(stanza)
            return
        # do we need to create a new jingle object
        if sid not in self._sessions:
            #TODO: tie-breaking and other things...
            newjingle = JingleSession(self._con, weinitiate=False, jid=jid,
                                      iq_id=id_, sid=sid)
            self._sessions[sid] = newjingle
        # we already have such session in dispatcher...
        self._sessions[sid].collect_iq_id(id_)
        self._sessions[sid].on_stanza(stanza)
        # Delete invalid/unneeded sessions
        if sid in self._sessions and \
        self._sessions[sid].state == JingleStates.ENDED:
            self.delete_jingle_session(sid)
        raise nbxmpp.NodeProcessed
github gajim / gajim / gajim / common / modules / bits_of_binary.py View on Github external
def _answer_bob_request(self, _con, stanza, _properties):
        self._log.info('Request from %s for BoB data', stanza.getFrom())
        iq = stanza.buildReply('error')
        err = nbxmpp.ErrorNode(nbxmpp.ERR_ITEM_NOT_FOUND)
        iq.addChild(node=err)
        self._log.info('Sending item-not-found')
        self._con.connection.send(iq)
        raise nbxmpp.NodeProcessed