Ñò
�Þ	Nc           @   sÒ  d  „  Z  d „  Z d „  Z d „  Z d Z d Z d Z d Z d Z d	 Z	 d
 Z
 d Z d Z d Z d Z d Z d Z d „  Z d Z d „  Z d Z d „  Z d Z d „  Z d Z d Z d „  Z d Z d „  Z d Z d „  Z d Z d  „  Z  d! Z! d" Z" d# „  Z# d$ Z$ d% „  Z% d& Z& d' „  Z' d( Z( d) „  Z) d* Z* d+ Z+ d, „  Z, d- Z- d. d/ „ Z. d0 Z/ d1 d2 „ Z0 d3 „  Z1 d4 Z2 d5 Z3 d6 „  Z4 d7 Z5 d8 „  Z6 d9 Z7 d: „  Z8 d; Z9 d< „  Z: d= Z; d> „  Z< d? Z= d@ „  Z> dA S(B   c         C   s"   |  i  d d ƒ } | i  d d ƒ S(   Nu   &u   &#x26;u   <u   &#x3C;(   t   replace(   t   textt   t(    (    s   scripts/common/xmpp/Stanzas.pyt   xmlText   s    c         C   s   |  d i  | ƒ S(   Nt   attr(   t   get(   t   stanzat   name(    (    s   scripts/common/xmpp/Stanzas.pyt   getAttr	   s    c         C   s/   x( |  d D] } | d | j o | Sq Wd  S(   Nt   childrenR   (   t   None(   R   R   t   c(    (    s   scripts/common/xmpp/Stanzas.pyt   getChild   s
     	c         C   sì   d  } | d j p | d j o+ d |  j o |  i d d ƒ d } qá n— | d j o+ d |  j o |  i d d ƒ d } qá n_ | d j o* |  i d d ƒ d i d d ƒ d } n( | d j o |  i d d ƒ d } n | p d S(   Nt   resourcet   muc_usert   /i   iÿÿÿÿt   usert   @i    t   servert   domaint   hostt   baret    (   R   R   s   host(   R
   t   split(   t   jidR   R   (    (    s   scripts/common/xmpp/Stanzas.pyt   jidAttr   s    *uu   
<stream:stream
  xmlns='jabber:client'
  xmlns:stream='http://etherx.jabber.org/streams'
  to='%s'
  version='1.0'>
u   
</stream:stream>
uG   
<iq type='get' id='reg1'>
  <query xmlns='jabber:iq:register'/>
</iq>
u‰   
<iq type='set' id='reg2'>
  <query xmlns='jabber:iq:register'>
    <username>%s</username>
    <password>%s</password>
  </query>
</iq>
uR   
<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl'
         mechanism='DIGEST-MD5'/>
uD   
<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
%s
</response>
us   username="%s",realm="%s",nonce="%s",cnonce="%s",nc=00000001,qop=auth,digest-uri="xmpp/%s",response=%s,charset=utf-8u6   
<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>
uL   
<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">%s</auth>
uw   
<iq type='set' id='bind_2'>
	<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>
		<resource>%s</resource>
	</bind>
</iq>
u[   
<iq type='set' id='sess_1'>
	<session xmlns='urn:ietf:params:xml:ns:xmpp-session'/>
</iq>
uG   
<message from='%s' to='%s' xml:lang='en'>
	<body>%s</body>
</message>
uL   
<iq from='%s' type='get' id='%s'>
	<query xmlns='jabber:iq:roster'/>
</iq>
c         C   s   t  | |  f S(   N(   t   QUERY_ROSTER(   t   stanzaIDt   fromJID(    (    s   scripts/common/xmpp/Stanzas.pyt   queryRosterz   s    u¥   
<iq from='%s' type='set' id='%s'>
  <query xmlns='jabber:iq:roster'>
    <item jid='%s' name='%s'/>
  </query>
</iq>
<presence from='%s' to='%s' type='subscribe'/>
c         C   s   t  | |  | | | | f S(   N(   t
   ROSTER_ADD(   R   t	   senderJIDt   recipientJID(    (    s   scripts/common/xmpp/Stanzas.pyt	   rosterAddˆ   s    	u/   
<iq from='%s' to='%s' type='result' id='%s'/>
c         C   s   t  | | |  f S(   N(   t   ROSTER_SET_REPLY(   R   R   R    (    (    s   scripts/common/xmpp/Stanzas.pyt   rosterSetReply’   s    ux   
<iq type='set' id='%s'>
  <query xmlns='jabber:iq:roster'>
    <item jid='%s' subscription='remove'/>
  </query>
</iq>
c         C   s   t  |  | f S(   N(   t
   ROSTER_DEL(   R   t   jidToRemove(    (    s   scripts/common/xmpp/Stanzas.pyt	   rosterDelŸ   s    u?   
<presence from='%s' to='%s' xml:lang='en' type='subscribed'/>
uX   
<iq from='%s' to='%s' type='get' id='reg1'>
	<query xmlns='jabber:iq:register'/>
</iq>
c         C   s   t  |  | f S(   N(   t   QUERY_GATEWAY(   R   t   transportDomain(    (    s   scripts/common/xmpp/Stanzas.pyt   gatewayQuery¯   s    u“   
<iq from='%s' to='%s' type='set' id='%s'>
	<query xmlns='jabber:iq:register'>
		<username>%s</username>
		<password>%s</password>
	</query>
</iq>
c         C   s   t  | | |  | | f S(   N(   t   REGISTER_GATEWAY(   R   R   t   gatewayt   usernamet   password(    (    s   scripts/common/xmpp/Stanzas.pyt   gatewayRegister¼   s    uo   
<iq type='set' from='%s' to='%s' id='%s'>
  <query xmlns='jabber:iq:register'>
    <remove/>
  </query>
</iq>
c         C   s   t  | | |  f S(   N(   t   DEREGISTER_GATEWAY(   R   R   t   toTransportJID(    (    s   scripts/common/xmpp/Stanzas.pyt   gatewayDeregisterÉ   s    u.   <presence from='%s' to='%s' type='subscribe'/>c         C   s   t  |  | f S(   N(   t   PRESENCE_SUBSCRIBE(   R   t   toJID(    (    s   scripts/common/xmpp/Stanzas.pyt   presenceSubscribeÎ   s    u5   
<iq  id='%s' from='%s' to='%s' type='%s'>
	%s
</iq>
u7   <query xmlns='http://jabber.org/protocol/disco#items'/>c         C   s   t  |  | | d t f S(   NR   (   t   IQ_BODYt   DISCO_ITEMS_ELEMENT(   t   idR   t   to(    (    s   scripts/common/xmpp/Stanzas.pyt   queryDiscoItemsÛ   s    u6   <query xmlns='http://jabber.org/protocol/disco#info'/>c         C   s   t  |  | | d t f S(   NR   (   R5   t   DISCO_INFO_ELEMENT(   R7   R   R8   (    (    s   scripts/common/xmpp/Stanzas.pyt   queryDiscoInfoà   s    u1   <x xmlns='http://jabber.org/protocol/muc#owner'/>c         C   s   t  |  | | d t f S(   NR   (   R5   t   MUC_CONFIGURATION_ELEMENT(   R7   t   from_jidt   to_jid(    (    s   scripts/common/xmpp/Stanzas.pyt   mucConfigutationå   s    ui   
<query xmlns='http://jabber.org/protocol/muc#owner'>
	<x xmlns='jabber:x:data' type='cancel'/>
</query>
c         C   s   t  |  | | d t f S(   Nt   set(   R5   t   MUC_CANCEL_CREATION_ELEMENT(   R7   R=   R>   (    (    s   scripts/common/xmpp/Stanzas.pyt   mucCancelCreationî   s    uC   
<query xmlns='http://jabber.org/protocol/muc#admin'>
	%s
</query>
u$   
	<item affiliation='%s' jid='%s'/>
c      	   C   sL   d } x( | D]  \ } } | t  | | f 7} q Wt |  | | d t | f S(   Nu    R@   (   t   MUC_AFFILATION_ITEMR5   t   MUC_CHANGE_AFFILATION_ELEMENT(   R7   R=   R>   t   affiliationst   itemsR   t   affiliation(    (    s   scripts/common/xmpp/Stanzas.pyt   mucChangeAffiliationû   s
     ul   
<query xmlns='http://jabber.org/protocol/muc#owner'>
	<destroy>
		<reason>%s</reason>
	</destroy>
</query>
R   c         C   s   t  |  | | d t | f S(   NR@   (   R5   t   MUC_DESTROY_ROOM_ELEMENT(   R7   R=   R>   t   reason(    (    s   scripts/common/xmpp/Stanzas.pyt   mucDestroyRoom  s    uY   
<query xmlns='http://jabber.org/protocol/muc#admin'>
	<item affiliation='%s'/>
</query>
u   memberc         C   s   t  |  | | d t | f S(   NR   (   R5   t   MUC_QUERY_MEMBERS_ELEMENT(   R7   R=   R>   t   members(    (    s   scripts/common/xmpp/Stanzas.pyt   mucQueryMembers  s    c           C   s   d S(   Nu   <presence/>(    (    (    (    s   scripts/common/xmpp/Stanzas.pyt   presence  s    u.   
<presence from='%s' to='%s'>
	%s
</presence>
u+   <x xmlns='http://jabber.org/protocol/muc'/>c         C   s   t  |  | t f S(   N(   t   PRESENCE_BODYt   MUC_EXTENSION_ELEMENT(   R=   R>   (    (    s   scripts/common/xmpp/Stanzas.pyt   mucPresence&  s    u6   
<presence id='%s' from='%s' to='%s'>
	%s
</presence>
c         C   s   t  |  | | t f S(   N(   t   PRESENCE_BODY_IDRQ   (   R7   R=   R>   (    (    s   scripts/common/xmpp/Stanzas.pyt   mucPresenceId/  s    u)   
<presence from='%s' to='%s' type='%s'/>
c         C   s   t  |  | | f S(   N(   t   PRESENCE_BODY_TYPE(   R=   R>   t   type(    (    s   scripts/common/xmpp/Stanzas.pyt   mucPresenceType5  s    u.   
<field var='%s'>
	<value>%s</value>
</field>
c         C   s   t  |  | f S(   N(   t   FORM_FIELD_VALUE(   R   t   value(    (    s   scripts/common/xmpp/Stanzas.pyt	   formFieldB  s    uÓ   
<query xmlns='http://jabber.org/protocol/muc#owner'>
	<x xmlns='jabber:x:data' type='submit'>
		<field var='FORM_TYPE'>
		<value>http://jabber.org/protocol/muc#roomconfig</value>
		</field>
		%s
	</x>
</query>
c         C   s   t  |  | | d t | f S(   NR@   (   R5   t   FORM_SUBMIT_ELEMENT(   R7   R=   R>   t   fields(    (    s   scripts/common/xmpp/Stanzas.pyt
   submitFormP  s    uC   
<message from='%s' to='%s' type='%s'>
	<body>%s</body>
</message>
c         C   s   t  |  | d | f S(   Nt	   groupchat(   t   MESSAGE_BODY(   R=   R>   t   msg(    (    s   scripts/common/xmpp/Stanzas.pyt
   mucMessage[  s    N(?   R   R   R   R   t   STREAM_STARTt
   STREAM_ENDt   REGISTRATION_IQt   REGISTRATIONt   AUTHENTICATION_MD5_STARTt   AUTHENTICATION_MD5_RESPONSEt   AUTHENTICATION_MD5_BODYt   AUTHENTICATION_MD5_ENDt   AUTHENTICATION_PLAINt   BIND_RESOURCEt   SESSIONt   MESSAGER   R   R   R!   R"   R#   R$   R&   t   SUBSCRIBE_ALLOWR'   R)   R*   R.   R/   R1   R2   R4   R5   R6   R9   R:   R;   R<   R?   RA   RB   RD   RC   RH   RI   RK   RL   RN   RO   RP   RQ   RR   RS   RT   RU   RW   RX   RZ   R[   R]   R_   Ra   (    (    (    s   scripts/common/xmpp/Stanzas.pyt   <module>   s|   				
																						