How to use the nbxmpp.Node 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 / test / gtk / dataform.py View on Github external
def __init__(self):
        Gtk.Window.__init__(self, title="Data Form Test")
        self.set_default_size(600, 600)
        options = {
            'left-width': 100,
            'form-width': 435,
        }
        self._widget = DataFormWidget(
            extend_form(node=nbxmpp.Node(node=FORM)), options)
        self.add(self._widget)
        self.show()
github gajim / gajim / gajim / common / jingle_rtp.py View on Github external
def iter_codecs(self):
        codecs = self.p2psession.props.codecs_without_config
        for codec in codecs:
            attrs = {
                'name': codec.encoding_name,
                'id': codec.id,
            }
            if codec.channels > 0:
                attrs['channels'] = codec.channels
            if codec.clock_rate:
                attrs['clockrate'] = codec.clock_rate
            if codec.optional_params:
                payload = [nbxmpp.Node('parameter',
                                       {'name': p.name, 'value': p.value})
                           for p in codec.optional_params]
            else:
                payload = []
            yield nbxmpp.Node('payload-type', attrs, payload)
github gajim / gajim / gajim / common / modules / atom.py View on Github external
uri = property(
        get_uri, None, None,
        '''Conveys an IRI associated with the person.
        Might be None when not set.''')

    def get_email(self):
        return self.getTagData('email')

    email = property(
        get_email, None, None,
        '''Conveys an e-mail address associated with the person.
        Might be None when not set.''')


class Entry(nbxmpp.Node):
    def __init__(self, node=None):
        nbxmpp.Node.__init__(self, 'entry', node=node)

    def __repr__(self):
        return '' % self.getAttr('id')


class OldEntry(nbxmpp.Node):
    """
    Parser for feeds from pubsub.com. They use old Atom 0.3 format with their
    extensions
    """

    def __init__(self, node=None):
        ''' Create new Atom 0.3 entry object. '''
        nbxmpp.Node.__init__(self, 'entry', node=node)
github gajim / gajim / gajim / common / modules / register.py View on Github external
def _get_register_form(stanza):
        parse_bob_data(stanza.getQuery())
        form = stanza.getQuery().getTag('x', namespace=Namespace.DATA)
        is_form = form is not None
        if not is_form:
            form = {}
            oob = stanza.getQuery().getTag('x', namespace=Namespace.X_OOB)
            if oob is not None:
                form['redirect-url'] = oob.getTagData('url')
            for field in stanza.getQueryPayload():
                if not isinstance(field, nbxmpp.Node):
                    continue
                if field.getName() == 'x':
                    continue
                form[field.getName()] = field.getData()

        return form, is_form
github gajim / gajim / gajim / common / modules / privacylists.py View on Github external
def set_default_list(self, name=None):
        self._log.info('Set default list: %s', name)
        attr = {}
        if name:
            attr['name'] = name
        node = nbxmpp.Node('default', attr)
        iq = nbxmpp.Iq('set', Namespace.PRIVACY, payload=[node])
        self._con.connection.SendAndCallForResponse(
            iq, self._default_result_handler, {})
github gajim / gajim / gajim / common / modules / privacylists.py View on Github external
def get_privacy_list(self, name):
        self._log.info('Request list: %s', name)
        list_ = nbxmpp.Node('list', {'name': name})
        iq = nbxmpp.Iq('get', Namespace.PRIVACY, payload=[list_])
        self._con.connection.SendAndCallForResponse(
            iq, self._privacy_list_received)
github gajim / gajim / gajim / common / jingle_session.py View on Github external
else:
            # it's an iq-result (ack) stanza
            action = 'iq-result'
        callables = self.callbacks[action]
        try:
            for call in callables:
                call(stanza=stanza, jingle=jingle, error=error, action=action)
        except nbxmpp.NodeProcessed:
            pass
        except TieBreak:
            self.__send_error(stanza, 'conflict', 'tiebreak')
        except OutOfOrder:
            # FIXME
            self.__send_error(stanza, 'unexpected-request', 'out-of-order')
        except FailedApplication:
            reason = nbxmpp.Node('reason')
            reason.addChild('failed-application')
            self._session_terminate(reason)
github gajim / gajim / gajim / common / jingle_rtp.py View on Github external
Farstream.StreamDirection.BOTH)

            elif name == 'farstream-local-candidates-prepared':
                self.candidates_ready = True
                if self.is_ready():
                    self.session.on_session_state_changed(self)
            elif name == 'farstream-new-local-candidate':
                candidate = self.p2pstream.parse_new_local_candidate(message)[1]
                self.transport.candidates.append(candidate)
                if self.sent:
                    # FIXME: Is this case even possible?
                    self.send_candidate(candidate)
            elif name == 'farstream-component-state-changed':
                state = message.get_structure().get_value('state')
                if state == Farstream.StreamState.FAILED:
                    reason = nbxmpp.Node('reason')
                    reason.setTag('failed-transport')
                    self.session.remove_content(self.creator, self.name, reason)
            elif name == 'farstream-error':
                log.error('Farstream error #%d!\nMessage: %s',
                          message.get_structure().get_value('error-no'),
                          message.get_structure().get_value('error-msg'))
        elif message.type == Gst.MessageType.ERROR:
            # TODO: Fix it to fallback to videotestsrc anytime an error occur,
            # or raise an error, Jingle way
            # or maybe one-sided stream?
            gerror_msg = message.get_structure().get_value('gerror')
            debug_msg = message.get_structure().get_value('debug')
            log.error(gerror_msg)
            log.error(debug_msg)
            if not self.stream_failed_once:
                app.nec.push_incoming_event(
github gajim / gajim / gajim / common / jingle_rtp.py View on Github external
for codec in codecs:
            attrs = {
                'name': codec.encoding_name,
                'id': codec.id,
            }
            if codec.channels > 0:
                attrs['channels'] = codec.channels
            if codec.clock_rate:
                attrs['clockrate'] = codec.clock_rate
            if codec.optional_params:
                payload = [nbxmpp.Node('parameter',
                                       {'name': p.name, 'value': p.value})
                           for p in codec.optional_params]
            else:
                payload = []
            yield nbxmpp.Node('payload-type', attrs, payload)