Ejemplo n.º 1
0
 def __init__(self, from_jid, to_jid, node_name=None, type=u'get', stanza_id=None):
     Entity.__init__(self, from_jid, to_jid, type, stanza_id)
     self.x = None
     self.node_name = node_name
     self.identities = []
     self.features = []
     self.items = []
Ejemplo n.º 2
0
    def __init__(self, from_jid, to_jid, type=u'normal', stanza_id=None, lang=None):
        Entity.__init__(self, from_jid, to_jid, type, stanza_id)
        self.lang = lang

        self.bodies = []
        self.subjects = []
        self.event = None
        self.foreign = []
        self.thread = None
        self.timestamp = datetime.now()
Ejemplo n.º 3
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.º 4
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.º 5
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.º 6
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.º 7
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.º 8
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.º 9
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.º 10
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.º 11
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.º 12
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.º 13
0
 def __init__(self, kind=None, from_jid=None, to_jid=None,
              type=None, stanza_id=None, lang=None):
     Entity.__init__(self, from_jid, to_jid, type, stanza_id)
     self.kind = kind
     self.lang = lang
     self.children = []
Ejemplo n.º 14
0
 def __init__(self, from_jid, to_jid=None, type=u'none', stanza_id=None):
     Entity.__init__(self, from_jid, to_jid, type=type, stanza_id=stanza_id)
     self.status = None
     self.show = None
     self.priority = 0
     self.foreign = []
Ejemplo n.º 15
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.º 16
0
 def __init__(self, from_jid, to_jid=None, type=u'get', stanza_id=None):
     Entity.__init__(self, from_jid, to_jid, type=type, stanza_id=stanza_id)
     self.items = {}
Ejemplo n.º 17
0
 def __init__(self, from_jid, to_jid, node_name=None, type=u'get', stanza_id=None):
     Entity.__init__(self, from_jid, to_jid, type, stanza_id)
     self.subscriptions  = []
     self.node_name = node_name
Ejemplo n.º 18
0
 def __init__(self, from_jid, to_jid):
     Entity.__init__(self, from_jid, to_jid) 
     self.node_name = None
     self.items = []
     self.event = None
Ejemplo n.º 19
0
 def __init__(self, from_jid, to_jid, type=u'get', stanza_id=None):
     Entity.__init__(self, from_jid, to_jid, type, stanza_id)
     self.affiliations  = []
Ejemplo n.º 20
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
Ejemplo n.º 21
0
 def __init__(self, from_jid, to_jid, node_name=None, type=u'set', stanza_id=None, **kwargs):
     Entity.__init__(self, from_jid, to_jid, type, stanza_id) 
     self.node_name = node_name
     self.configure = None
     if kwargs:
         self.__dict__.update(kwargs)
Ejemplo n.º 22
0
 def __init__(self, from_jid=None, to_jid=None, type=u'get', stanza_id=None):
     Entity.__init__(self, from_jid, to_jid, type, stanza_id)
     self.x = None
     self.registered = False
     self.remove = False
     self.infos = {}
Ejemplo n.º 23
0
 def __init__(self, from_jid, to_jid, type=u"get", stanza_id=None, seconds=None, message=None):
     Entity.__init__(self, from_jid, to_jid)
     self.seconds = seconds
     self.message = message
     self.type = type
     self.stanza_id = stanza_id or generate_unique()
Ejemplo n.º 24
0
 def __init__(self, from_jid=None, to_jid=None, type=u'none', stanza_id=None):
     Entity.__init__(self, from_jid, to_jid, type=type, stanza_id=stanza_id)
     self.x = None