Exemplo n.º 1
0
    def send_whiteboard_node(self, items, rids):
        # takes int rid and dict items and sends it as a node
        # sends new item
        jid = self.session.peerjid
        sid = self.session.sid
        message = Message(to=jid)
        sxe = message.addChild(name='sxe',
                               attrs={'session': sid},
                               namespace=NS_SXE)

        for x in rids:
            if items[x]['type'] == 'element':
                parent = x
                attrs = {
                    'rid': x,
                    'name': items[x]['data'][0].getName(),
                    'type': items[x]['type']
                }
                sxe.addChild(name='new', attrs=attrs)
            if items[x]['type'] == 'attr':
                attr_name = items[x]['data']
                chdata = items[parent]['data'][0].getAttr(attr_name)
                attrs = {
                    'rid': x,
                    'name': attr_name,
                    'type': items[x]['type'],
                    'chdata': chdata,
                    'parent': parent
                }
                sxe.addChild(name='new', attrs=attrs)
        self.session.connection.connection.send(message)
Exemplo n.º 2
0
    def send_whiteboard_node(self, items, rids):
        # takes int rid and dict items and sends it as a node
        # sends new item
        jid = self.session.peerjid
        sid = self.session.sid
        message = Message(to=jid)
        sxe = message.addChild(name='sxe', attrs={'session': sid},
            namespace=NS_SXE)

        for x in rids:
            if items[x]['type'] == 'element':
                parent = x
                attrs = {'rid': x,
                     'name': items[x]['data'][0].getName(),
                     'type': items[x]['type']}
                sxe.addChild(name='new', attrs=attrs)
            if items[x]['type'] == 'attr':
                attr_name = items[x]['data']
                chdata = items[parent]['data'][0].getAttr(attr_name)
                attrs = {'rid': x,
                     'name': attr_name,
                     'type': items[x]['type'],
                     'chdata': chdata,
                     'parent': parent}
                sxe.addChild(name='new', attrs=attrs)
        self.session.connection.connection.send(message)
Exemplo n.º 3
0
    def delete_whiteboard_node(self, rids):
        message = Message(to=self.session.peerjid)
        sxe = message.addChild(name='sxe', attrs={'session': self.session.sid},
            namespace=NS_SXE)

        for x in rids:
            sxe.addChild(name='remove', attrs = {'target': x})
        self.session.connection.connection.send(message)
Exemplo n.º 4
0
    def delete_whiteboard_node(self, rids):
        message = Message(to=self.session.peerjid)
        sxe = message.addChild(name='sxe', attrs={'session': self.session.sid},
                               namespace=NS_SXE)

        for x in rids:
            sxe.addChild(name='remove', attrs={'target': x})
        self.session.connection.connection.send(message)
Exemplo n.º 5
0
def parse_chatstate(stanza: nbxmpp.Message) -> Optional[str]:
    if stanza.getTag('delay', namespace=nbxmpp.NS_DELAY2) is not None:
        return None

    children = stanza.getChildren()
    for child in children:
        if child.getNamespace() == nbxmpp.NS_CHATSTATES:
            return child.getName()
    return None