Ejemplo n.º 1
0
    def __on_auth_succeeded(self, xmlstream):
        # Nothing happens until we actually send a presence
        presence = domish.Element(('jabber:client', 'presence'))
        presence.addElement('status').addContent('Online')

        xmlstream.send(presence)

        # add a callback for the messages
        xmlstream.addObserver('/message', self.__on_message)
        
        self._xmlstream = xmlstream

        self._reset()
        
        notifications = NotificationSet(self)        
        self.global_resource._update_property(("online-desktop:/p/o/global", "online"),
                                              UPDATE_REPLACE, CARDINALITY_1, True,
                                              notifications)

        self.global_resource._update_property(("online-desktop:/p/o/global", "webBaseUrl"),
                                              UPDATE_REPLACE, CARDINALITY_1,  self.web_base_url,
                                              notifications)

        self_resource_id = self.web_base_url + "/o/user/" + self.username
        self_resource = self._ensure_resource(self_resource_id,
                                              "http://mugshot.org/p/o/user")
        
        self.global_resource._update_property(("online-desktop:/p/o/global", "self"),
                                              UPDATE_REPLACE, CARDINALITY_01, self_resource,
                                              notifications)

        notifications.send()
        
        self._on_ready()
Ejemplo n.º 2
0
    def authenticated(self, xmlstream):
        self.deferred.callback(self)

        presence = domish.Element(('jabber:client', 'presence'))
        #presence.addElement('status').addContent('Online')
        xmlstream.send(presence)

        xmlstream.addObserver('/message', self.receivedMessage)
Ejemplo n.º 3
0
    def authenticated(self, xmlstream):
        self.deferred.callback(self)
        
        presence = domish.Element(('jabber:client','presence'))
        #presence.addElement('status').addContent('Online')
        xmlstream.send(presence)

        xmlstream.addObserver('/message',  self.receivedMessage)
def gotPresence(el):
    if not "type" in el.attributes:
        return
    t = el.attributes["type"]
    if t == "subscribe":
        # Grant every subscription request
        xmlstream.send(
            domish.Element(
                (None, "presence"), attribs={"from": _me.full(), "to": el.attributes["from"], "type": "subscribed"}
            )
        )
def authd(xmlstream):
    # Autentificacion
    global thexmlstream
    thexmlstream = xmlstream
    print "we've authd!"
    print repr(xmlstream)

    # se envia la presencia a los demas clientes
    presence = domish.Element(('jabber:client', 'presence'))
    presence.addElement('status').addContent('Online')
    xmlstream.send(presence)

    initOnline(xmlstream)
Ejemplo n.º 6
0
def authd(xmlstream):
    # Autentificacion
    global thexmlstream
    thexmlstream = xmlstream
    print "we've authd!"
    print repr(xmlstream)

    # se envia la presencia a los demas clientes
    presence = domish.Element(('jabber:client', 'presence'))
    presence.addElement('status').addContent('Online')
    xmlstream.send(presence)

    initOnline(xmlstream)
def gotPresence(el):
    if (not 'type' in el.attributes):
        return
    t = el.attributes['type']
    if t == 'subscribe':
        # Grant every subscription request
        xmlstream.send(
            domish.Element(
                (None, 'presence'),
                attribs={
                    'from': _me.full(),
                    'to': el.attributes['from'],
                    'type': 'subscribed'
                }))
def authd(xmlstream):
    global _xmlstream
    logger.debug("authenticated")
    _xmlstream = xmlstream
    xmlstream.rawDataInFn = logger.debug
    xmlstream.rawDataOutFn = logger.debug

    presence = domish.Element((None, 'presence'))
    presence.addElement('status').addContent('Online')
    xmlstream.send(presence)

    # add a callback for the messages -- need to handle subscribe
    xmlstream.addObserver('/presence', gotPresence)
    xmlstream.addObserver('/iq', gotIq)
    """
  <iq type="set" to="pubsub.pubjab.be-n.com" id="create3">
    <pubsub xmlns="http://jabber.org/protocol/pubsub">
      <create node="/home/pubjab.be-n.com/ben"/>
      <configure/>
    </pubsub>
  </iq>
  """
    if (_pubsub):
        (u, host) = _user.split("@")
        # if we are using pubsub, register a chanel.
        iq = domish.Element((None, 'iq'),
                            attribs={
                                'from': _me.userhost(),
                                'to': "pubsub." + host,
                                'type': 'set'
                            })
        pubsub = domish.Element(
            ('http://jabber.org/protocol/pubsub', 'pubsub'))
        pubsub.addChild(
            domish.Element((None, "create"),
                           attribs={'node': "/home/%s/%s" % (host, u)}))
        pubsub.addElement("configure")
        iq.addChild(pubsub)
        logger.debug(iq.toXml())
        xmlstream.send(iq)
        iq = domish.Element((None, 'iq'),
                            attribs={
                                'from': _me.userhost(),
                                'to': "pubsub." + host,
                                'type': 'set'
                            })
        pubsub = domish.Element(
            ('http://jabber.org/protocol/pubsub', 'pubsub'))
        pubsub.addChild(
            domish.Element((None, "create"),
                           attribs={'node': "/home/%s/%s/btscan" % (host, u)}))
        pubsub.addElement("configure")
        iq.addChild(pubsub)
        logger.info("Publishing updates to: /home/%s/%s/btscan over XMPP" %
                    (host, u))
        logger.debug(iq.toXml())
        xmlstream.send(iq)
def authd(xmlstream):
    global _xmlstream
    logger.debug("authenticated")
    _xmlstream = xmlstream
    xmlstream.rawDataInFn = logger.debug
    xmlstream.rawDataOutFn = logger.debug

    presence = domish.Element((None, "presence"))
    presence.addElement("status").addContent("Online")
    xmlstream.send(presence)

    # add a callback for the messages -- need to handle subscribe
    xmlstream.addObserver("/presence", gotPresence)
    xmlstream.addObserver("/iq", gotIq)
    """
  <iq type="set" to="pubsub.pubjab.be-n.com" id="create3">
    <pubsub xmlns="http://jabber.org/protocol/pubsub">
      <create node="/home/pubjab.be-n.com/ben"/>
      <configure/>
    </pubsub>
  </iq>
  """
    if _pubsub:
        (u, host) = _user.split("@")
        # if we are using pubsub, register a chanel.
        iq = domish.Element((None, "iq"), attribs={"from": _me.userhost(), "to": "pubsub." + host, "type": "set"})
        pubsub = domish.Element(("http://jabber.org/protocol/pubsub", "pubsub"))
        pubsub.addChild(domish.Element((None, "create"), attribs={"node": "/home/%s/%s" % (host, u)}))
        pubsub.addElement("configure")
        iq.addChild(pubsub)
        logger.debug(iq.toXml())
        xmlstream.send(iq)
        iq = domish.Element((None, "iq"), attribs={"from": _me.userhost(), "to": "pubsub." + host, "type": "set"})
        pubsub = domish.Element(("http://jabber.org/protocol/pubsub", "pubsub"))
        pubsub.addChild(domish.Element((None, "create"), attribs={"node": "/home/%s/%s/btscan" % (host, u)}))
        pubsub.addElement("configure")
        iq.addChild(pubsub)
        logger.info("Publishing updates to: /home/%s/%s/btscan over XMPP" % (host, u))
        logger.debug(iq.toXml())
        xmlstream.send(iq)
Ejemplo n.º 10
0
def ping(xmlstream):
	xmlstream.send('  \t  ')
	reactor.callLater(40, ping, xmlstream)
Ejemplo n.º 11
0
def basic_disconnect(f, xmlstream):
    sh = "</stream:stream>"
    xmlstream.send(sh)
    f.stopTrying()
    xmlstream = None
Ejemplo n.º 12
0
def basic_disconnect(f, xmlstream):
    sh = "</stream:stream>"
    xmlstream.send(sh)
    f.stopTrying()
    xmlstream = None