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()
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 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 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 componentConnected(self, xmlstream): self.xmlstream = xmlstream # TODO - this needs to be done another way self.jid = xmlstream.authenticator.otherHost xmlstream.addObserver(VERSION, self.onVersion, 1) xmlstream.addObserver(DISCO_INFO, self.onDiscoInfo, 1) xmlstream.addObserver(DISCO_ITEMS, self.onDiscoItems, 1) xmlstream.addObserver(IQ_GET, self.iqFallback, -1) xmlstream.addObserver(IQ_SET, self.iqFallback, -1)
def componentConnected(self, xmlstream): """ This method is called when the componentConnected event gets called. That event gets called when we have connected and authenticated with the XMPP server. """ self.jabberId = xmlstream.authenticator.otherHost self.xmlstream = xmlstream # set the xmlstream so we can reuse it xmlstream.addObserver(MESSAGE, self.onMessage, 1)
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 initOnline(xmlstream): # creamos los observadores hacia las respuestas xml message y una general (podemos incluir presence, iq...) global factory print 'Initializing...' xmlstream.addObserver('/message', gotMessage) xmlstream.addObserver('/*', gotSomething)