# Path: pyxmpp/all.py



import sys
import logging
import pyxmpp.jabberd.all
from pyxmpp.all import JID,Iq,Presence,Message,StreamError,FeatureNotImplementedProtocolError

    def set_register(self,iq):
        """Handler for jabber:iq:register 'set' queries.

        This does not do anything usefull (registration data is ignored),
        but shows how to parse request and use Presence stanzas for
        subscription handling."""
        to=iq.get_to()
        if to and to!=self.jid:
            raise FeatureNotImplementedProtocolError, "Tried to register at non-null node"
        remove=iq.xpath_eval("r:query/r:remove",{"r":"jabber:iq:register"})
        if remove:
            m=Message(from_jid=iq.get_to(),to_jid=iq.get_from(),stanza_type="chat",
                    body=u"Unregistered")
            self.stream.send(m)
            p=Presence(from_jid=iq.get_to(),to_jid=iq.get_from(),stanza_type="unsubscribe")
            self.stream.send(p)
            p=Presence(from_jid=iq.get_to(),to_jid=iq.get_from(),stanza_type="unsubscribed")
            self.stream.send(p)
            return True
        username=iq.xpath_eval("r:query/r:username",{"r":"jabber:iq:register"})
        if username:
            username=username[0].getContent()
        else:
            username=u""
        password=iq.xpath_eval("r:query/r:password",{"r":"jabber:iq:register"})
        if password:
            password=password[0].getContent()
        else:
            password=u""

# Path: pyxmpp/all.py



# Path: examples/echocomponent.py
import sys
import logging
import pyxmpp.jabberd.all
from pyxmpp.all import JID,Iq,Presence,Message,StreamError,FeatureNotImplementedProtocolError


    def set_register(self,iq):
        """Handler for jabber:iq:register 'set' queries.

        This does not do anything usefull (registration data is ignored),
        but shows how to parse request and use Presence stanzas for
        subscription handling."""
        to=iq.get_to()
        if to and to!=self.jid:
            raise FeatureNotImplementedProtocolError, "Tried to register at non-null node"
        remove=iq.xpath_eval("r:query/r:remove",{"r":"jabber:iq:register"})
        if remove:
            m=Message(from_jid=iq.get_to(),to_jid=iq.get_from(),stanza_type="chat",
                    body=u"Unregistered")
            self.stream.send(m)
            p=Presence(from_jid=iq.get_to(),to_jid=iq.get_from(),stanza_type="unsubscribe")
            self.stream.send(p)
            p=Presence(from_jid=iq.get_to(),to_jid=iq.get_from(),stanza_type="unsubscribed")
            self.stream.send(p)
            return True
        username=iq.xpath_eval("r:query/r:username",{"r":"jabber:iq:register"})
        if username:
            username=username[0].getContent()
        else:
            username=u""
        password=iq.xpath_eval("r:query/r:password",{"r":"jabber:iq:register"})
        if password:
            password=password[0].getContent()
        else:
            password=u""

        m=Message(from_jid=iq.get_to(),to_jid=iq.get_from(),stanza_type="chat",