Ejemplo n.º 1
0
    def to_element(e):
        iq = Entity.to_element(e)
        attrs = {u'node': e.node_name}
        E(u'query', namespace=XMPP_DISCO_INFO_NS, parent=iq,
          attributes=attrs)

        return iq
Ejemplo n.º 2
0
 def to_unsubscription_element(e):
     iq = Entity.to_element(e)
     pubsub = E(u'pubsub', namespace=XMPP_PUBSUB_NS, parent=iq)
     sub_jid = e.sub_jid
     attrs = {u'node': e.node_name, u'jid': e.sub_jid}
     E(u'unsubscribe', attributes=attrs, namespace=XMPP_PUBSUB_NS, parent=pubsub)
     return iq
Ejemplo n.º 3
0
    def to_element(e):
        iq = Entity.to_element(e)
        p = E(u'profile', namespace=XMPP_USER_PROFILE_NS, parent=iq)

        if e.x:
            Data.to_element(e.x, parent=p)

        return iq
Ejemplo n.º 4
0
    def to_retract_element(e):
        iq = Entity.to_element(e)
        pubsub = E(u'pubsub', namespace=XMPP_PUBSUB_NS, parent=iq)
        attrs = {u'node': e.node_name}
        publish = E(u'retract', attributes=attrs, namespace=XMPP_PUBSUB_NS, parent=pubsub)
        attrs = {u'id': e.item.id}
        item = E(u'item', attributes=attrs, namespace=XMPP_PUBSUB_NS, parent=publish)

        return iq
Ejemplo n.º 5
0
    def to_element(e):
        iq = Entity.to_element(e)
        query = E(u'query', namespace=XMPP_PUBSUB_NS, parent=iq)
        attr = None
        if e.node_name:
            attr = {u'node': e.node_name}
        E('subscriptions', namespace=XMPP_PUBSUB_NS, attributes=attr, parent=query)

        return iq
Ejemplo n.º 6
0
    def to_request_item(e):
        iq = Entity.to_element(e)
        pubsub = E(u'pubsub', namespace=XMPP_PUBSUB_NS, parent=iq)
        attrs = {u'node': e.node_name}
        items = E(u'items', attributes=attrs, namespace=XMPP_PUBSUB_NS, parent=pubsub)
        if e.item:
            attrs = {u'id': e.item.id}
            E(u'item', attributes=attrs, namespace=XMPP_PUBSUB_NS, parent=items)

        return iq
Ejemplo n.º 7
0
 def to_creation_element(e):
     iq = Entity.to_element(e)
     pubsub = E(u'pubsub', namespace=XMPP_PUBSUB_NS, parent=iq)
     attrs = {u'node': e.node_name}
     E(u'create', attributes=attrs, namespace=XMPP_PUBSUB_NS, parent=pubsub)
     if not e.configure:
         E(u'configure', namespace=XMPP_PUBSUB_NS, parent=pubsub)
     else:
         Configure.to_element(e.configure, parent=pubsub)
     return iq
Ejemplo n.º 8
0
    def to_publication_element(e):
        iq = Entity.to_element(e)
        pubsub = E(u'pubsub', namespace=XMPP_PUBSUB_NS, parent=iq)
        attrs = {u'node': e.node_name}
        publish = E(u'publish', attributes=attrs, namespace=XMPP_PUBSUB_NS, parent=pubsub)
        attrs = {u'id': e.item.id}
        item = E(u'item', attributes=attrs, namespace=XMPP_PUBSUB_NS, parent=publish)

        if e.item.payload and isinstance(e.item.payload, E):
            e.item.payload.xml_parent = item
            item.xml_children.append(e.item.payload)
        elif e.item.payload and isinstance(e.item.payload, unicode):
            item.xml_text = e.item.payload
            
        return iq
Ejemplo n.º 9
0
    def to_element(e):
        iq = Entity.to_element(e)
        query = E(u'query', namespace=XMPP_IBR_NS, parent=iq)
        
        if e.remove:
            E(u'remove', namespace=XMPP_IBR_NS, parent=query)
        
        if e.registered:
            E(u'registered', namespace=XMPP_IBR_NS, parent=query)

        for info in e.infos:
           E(info, namespace=XMPP_IBR_NS, parent=query,
             content=e.infos[info]) 

        if e.x:
            Data.to_element(e.x, parent=query)

        return iq
Ejemplo n.º 10
0
 def to_element(e):
     iq = Entity.to_element(e)
     if e.type != 'result':
         query = E(u'query', namespace=XMPP_ROSTER_NS, parent=iq)
         for item_id in e.items:
             item = e.items[item_id]
             attr = {u'jid': unicode(item.jid)}
             if item.subscription:
                 attr[u'subscription'] = item.subscription
             if item.name:
                 attr[u'name'] = item.name
             if item.language:
                 attr[u'language'] = item.language
             i = E(u'item', namespace=XMPP_ROSTER_NS,
                   attributes=attr, parent=query)
             for group in item.groups:
                 E(u'group', namespace=XMPP_ROSTER_NS,
                   content=group, parent=i)
     return iq
Ejemplo n.º 11
0
 def to_purge_element(e):
     iq = Entity.to_element(e)
     pubsub = E(u'pubsub', namespace=XMPP_PUBSUB_OWNER_NS, parent=iq)
     attrs = {u'node': e.node_name}
     E(u'purge', attributes=attrs, namespace=XMPP_PUBSUB_OWNER_NS, parent=pubsub)
     return iq
Ejemplo n.º 12
0
    def to_element(e):
        iq = Entity.to_element(e)
        query = E(u'query', namespace=XMPP_PUBSUB_NS, parent=iq)
        E('affiliations', namespace=XMPP_PUBSUB_NS, parent=query)

        return iq