HEX
Server: Apache
System: Linux hp3-stn-1011028.hostingp3.local 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: csh958633 (951153)
PHP: 8.3.30
Disabled: shell_exec,exec,system,popen,set_time_limit
Upload Files
File: //lib/python2.7/site-packages/jabber/jabber.pyo
�
��Sc@sdZddlZddlZddlZejZejZdZdZdZej	ej
f\Z	Z
dZejj
e�dZejj
e�dZejj
e�d	Zejj
e�d
Zejj
e�dZejj
e�dZd
ZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&d Z'd!Z(d"Z)d#Z*d$Z+e!d%Z,d&Z-e!d'Z.e.d(Z/e.d)Z0e!d*Z1dZ2dZ3d+Z4dZ5dZ6d+Z7dZ8dZ9d,�Z:e:e_:d-e;fd.��YZ<d/ej=fd0��YZ>d1e>fd2��YZ=d3ej?fd4��YZ@d5e@fd6��YZAd7e@fd8��YZBd9e@fd:��YZCd;fd<��YZDd=fd>��YZEd?e>fd@��YZFdAe@fdB��YZGdCe@fdD��YZHdEfdF��YZIdS(Gs�
__intro__

jabber.py is a Python module for the jabber instant messaging protocol.
jabber.py deals with the xml parsing and socket code, leaving the programmer
to concentrate on developing quality jabber based applications with Python.

The eventual aim is to produce a fully featured easy to use library for
creating both jabber clients and servers.

jabber.py requires at least python 2.0 and the XML expat parser module
( included in the standard Python distrubution ).

It is developed on Linux but should run happily on over Unix's and win32.

__Usage__

jabber.py basically subclasses the xmlstream classs and provides the
processing of jabber protocol elements into object instances as well
'helper' functions for parts of the protocol such as authentication
and roster management.

An example of usage for a simple client would be ( only psuedo code !)

<> Read documentation on jabber.org for the jabber protocol.

<> Birth a jabber.Client object with your jabber servers host

<> Define callback functions for the protocol elements you want to use
   and optionally a disconnection.

<> Authenticate with the server via auth method, or register via the
   reg methods to get an account.

<> Call requestRoster() and sendPresence()

<> loop over process(). Send Iqs,messages and presences by birthing
   them via there respective clients , manipulating them and using
   the Client's send() method.

<> Respond to incoming elements passed to your callback functions.

<> Find bugs :)


i����Niii,sjb-dispatchsjb-nodes
jb-node-iqsjb-node-messagesjb-node-pressencesjb-node-unknownsjabber:iq:agentsjabber:iq:agentssjabber:iq:auths
jabber:clientsjabber:x:delays
jabber:iq:oobsjabber:iq:registersjabber:iq:rostersjabber:x:rosters
jabber:serversjabber:iq:timesjabber:iq:versionsjabber:component:acceptsjabber:component:connectshttp://jabber.org/protocolsjabber:iq:passs
jabber:x:datas
jabber:iq:rpcsjabber:iq:browsesjabber:iq:lastsjabber:iq:privacysjabber:x:eventsjabber:x:expiresjabber:x:encryptedsjabber:x:signeds/mucs
vcard-temps/discos#infos#itemss	/commandsicCs�t|�td�kr!|}n`y|j�}Wntk
rPt|�}nXt|�td�kr�t|tjd�}n|S(spIf sending object is already a unicode str, just
       return it, otherwise convert it using xmlstream.ENCODINGutreplace(ttypet__str__tAttributeErrortstrtunicodet	xmlstreamtENCODING(twhattr((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytustr�s	
t
NodeProcessedcBseZRS((t__name__t
__module__(((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR�st
ConnectioncBs�eZdZgeejddd�Zded�Zded�Z	ddd�Z
d�Zd�Zd�Z
d	�Zd
�Zddeeed�Zd�Zed
�Zded�Zd�ZRS(s4Forms the base for both Client and Component Classesc		Cs�tjj||||d|d|d|d|d|�i|_|jdt�|jdt�|jdt�|jd	t�|j	d|j
d
t�i|_d|_
d|_d|_dS(
Ntdebugtlogt
connectionthostIPtproxytunknowntiqtmessagetpresencetsystemit(RtClientt__init__thandlerstregisterProtocoltProtocoltIqtMessagetPresencetregisterHandlert_expectedIqHandlertTruet	_expectedt_idtlastErrtlastErrCode(	tselfthosttportt	namespaceRRRRR((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR�s
				RcCsdGH|jd||d|�S(sBack compartibility methods`WARNING! setMessageHandler(...) method is obsolette, use registerHandler('message',...) instead.Rtchained(R"(R)tfuncRtchainOutput((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytsetMessageHandler�scCsdGH|jd||d|�S(sBack compartibility methodsbWARNING! setPresenceHandler(...) method is obsolette, use registerHandler('presence',...) instead.RR-(R"(R)R.RR/((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytsetPresenceHandler�scCsdGH|jd|||�S(sBack compartibility methodsVWARNING! setIqHandler(...) method is obsolette, use registerHandler('iq',...) instead.R(R"(R)R.Rtns((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytsetIqHandler�scCsk|jdt�d|j|jf}|jrC|d|j}n|d}|j|�|jt�dS(Nsstream: sending initial headeru[<?xml version='1.0' encoding='UTF-8' ?>                   <stream:stream to='%s' xmlns='%s's	 id='%s' s1 xmlns:stream='http://etherx.jabber.org/streams'>(tDEBUGtDBG_INITt_hostt
_namespacet_outgoingIDtsendtprocessttimeout(R)R((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytheader�s	
	

cCstjj|t|��dS(s4Sends a jabber protocol element (Node) to the serverN(RRtwriteR
(R)R((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR9�scCsS|jd�rO|jj|jd��rO||j|jd�<td��ndS(Ntids"No need for further Iq processing.(tgetAttrR%thas_keyR(R)tconntiq_obj((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR#�scCs�|j�}|jj|�s;|jd|t�d}n|jd|t�|j|td|�}|j�}|s�d}ny|j�}|s�d}nWn
d}nX|jd||ft	�||}|j|j|�s�d}n|j|j|�sd}n|j|j|�s4d}ng}x8d|||gD]$}|rM||j||7}qMqMWd}t
}	xs|D]k}
yK|	s�|
dr�|
d	r�|
d
|||�}q�|
d
||�nWq�tk
r�t}	q�Xq�WdS(s�Called internally when a 'protocol element' is received.
           Builds the relevant jabber.py object and dispatches it
           to a relevant function or callback.swhats a tag -> Rs
Got %s stanzatnodeRs$dispatch called for: name->%s ns->%stdefaultRtchainR.N(
tgetNameRR@R4tDBG_NODE_UNKNOWNtDBG_NODERtgetTypetgetQuerytDBG_DISPATCHR$RtFalse(R)tstanzatnamettypR2ttypnsREtkeytoutputtuserthandler((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytdispatch�sJ		


			


cCsi|t6gd6|j|<dS(s0Registers a protocol in protocol processing chain. You MUST register
           a protocol before you register any handler function for it.
           First parameter, that passed to this function is the tag name that
           belongs to all protocol elements. F.e.: message, presence, iq, xdb, ...
           Second parameter is the [ancestor of] Protocol class, which instance will
           built from the received node with call

                if received_packet.getName()==tag_name:
                    stanza = Proto(node = received_packet)
        RDN(RR(R)ttag_nametProto((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR&scCs�|r|rd}n|j|j||�sIg|j|||<n|r�|j|||ji|d6|d6|d6�n1|j|||ji|d6|d6|d6�dS(s�Sets the callback func for processing incoming stanzas.
           Multiple callback functions can be set which are called in
           succession. Callback can optionally raise an NodeProcessed error to
           stop stanza from further processing. A type and namespace attributes can
           also be optionally passed so the callback is only called when a stanza of
           this type is received. Namespace attribute MUST be omitted if you
           registering an Iq processing handler.

           If 'chainOutput' is set to False (the default), the given function
           should be defined as follows:

                def myCallback(c, p)

           Where the first parameter is the Client object, and the second
           parameter is the [ancestor of] Protocol object representing the stanza
           which was received.

           If 'chainOutput' is set to True, the output from the various
           handler functions will be chained together.  In this case,
           the given callback function should be defined like this:

                def myCallback(c, p, output)

           Where 'output' is the value returned by the previous
           callback function.  For the first callback routine, 'output' will be
           set to an empty string.

           'makefirst' argument gives you control over handler prioriy in its type
           and namespace scope. Note that handlers for particular type or namespace always
           have lower priority that common handlers.
        RDRER.RN(RR@tinserttappend(R)RNRTRR2R-t	makefirstR((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR"3s 	4cCs
||_dS(srSet the callback for a disconnect.
           The given function will be called with a single parameter (the
           connection object) when the connection is broken unexpectedly (eg,
           in response to sending badly formed XML).  self.lastErr and
           self.lastErrCode will be set to the error which caused the
           disconnection, if any.
        N(tdisconnectHandler(R)R.((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytsetDisconnectHandlerXscCst|�}d|j|<t}tj�|}|rX|jd|t|�ft�n|jdt|�t�xM|j|r�|r�|jd�s�dS|rutj�|krut}ququW|r�d|_	dS|j|}|j|=|j
�r|j�|_	|j
�|_dS|S(s/Blocks untils a protocol element with the given id is received.
           If an error is received, waitForResponse returns None and
           self.lastErr and self.lastErrCode is set to the received error.  If
           the operation times out (which only happens if a timeout value is
           given), waitForResponse will return None and self.lastErr will be
           set to "Timeout".
           Changed default from timeout=0 to timeout=300 to avoid hangs in
           scripts and such.
           If you _really_ want no timeout, just set it to 0swaiting with timeout:%s for %sswaiting for %sg�������?tTimeoutN(
R
tNoneR%RLttimeR4tDBG_NODE_IQR:R$R'tgetErrorCodetgetErrorR((R)tIDR;t
has_timed_outt
abort_timetresponse((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytwaitForResponseds,

#
	

cCsl|dkrC|j�}|dkrC|j�}|j|�qCnt|�}|j|�|j||�S(s�Sends a protocol element object and blocks until a response with
           the same ID is received.  The received protocol object is returned
           as the function result. N(R^tgetIDtgetAnIDtsetIDR
R9Rg(R)tobjRcR;((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytSendAndWaitForResponse�s
cCs|jd|_t|j�S(sReturns a unique IDi(R&R
(R)((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyRi�sN(RR
t__doc__RLRtTCPR^RR0R1R3R<R9R#RURR"R\R;RgRlRi(((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR�s				'	
%	#
RcBseZdZdgeejddd�Zd�Zddddd�Z	e	Z
d�Zd�Zd�Z
d�Zd	�Zd
�Zd�Zd�Zddd
�Zd�Zdd�Zd�Zd�Zdd�Zdd�Zd�Zdd�Zdd�Zdd�ZRS(s:Class for managing a client connection to a jabber server.ifc
Cs�tj|||t||d|d|d|�|jd|jdtdt�|jd|jdtdt�|jd|jdtdt�|jd|j	dt
dt�|jd|jdt�t�|_
i|_i|_d	|_dS(
NRRRRtresultRtsetRR(RRt	NS_CLIENTR"t_IqRosterManaget	NS_ROSTERR$t_IqRegisterResulttNS_REGISTERt_IqAgentsResultt	NS_AGENTSt_presenceHandlertRostert_rostert_agentst	_reg_infot
_reg_agent(R)R*R+RRRRR((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR�s		cCs*|jtdd��tjj|�dS(s,Safely disconnects from the connected serverRtunavailableN(R9R!RRt
disconnect(R)((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR�sc
Cs,|jtd|d|d|d|��dS(siSends a presence protocol element to the server.
           Used to inform the server that you are onlineRtprioritytshowtstatusN(R9R!(R)RR�R�R�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytsendPresence�scCs�t|j��}|j�}|jd|t�|dksE|ro|jd|t�|jj|d�n6|dkr�|jd|t�|jj|d�n|jj||j��|jj	||j
��dS(Nspresence type is %st	availablesroster setting %s to onlinetonlineR~sroster setting %s to offlinetoffline(R
tgetFromRIR4tDBG_NODE_PRESENCERzt
_setOnlinet_setShowtgetShowt
_setStatust	getStatus(R)RAtpres_objtwhoR((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyRx�sc

Cs�x�|j�j�D]�}|jd�}|jd�}|jd�}|jd�}g}x*|jd�D]}	|j|	j��qkW|r�|dks�|dkr�|jj|�q�|jjd|d|d|d	|d|�q|j	d
t
�qWdS(s"NS_ROSTER and type in [result,set]tjidRNtsubscriptiontasktgrouptremovetnonetgroupstsubsroster - jid not defined ?N(tgetQueryNodetgetChildrenR?tgetTagsRYtgetDataRzt_removet_setR4R`(
R)RARBtitemR�RNR�R�R�R�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyRr�s
cCsCi|_x3|j�j�D]}|j�|j|j�<qWdS(sNS_REGISTER and type==resultN(R|R�R�R�RF(R)RARBR�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyRt�s	cCs�|jdt�i|_x�|j�j�D]n}|j�dkr,i|j|jd�<x=|j�D],}|j�|j|jd�|j�<qgWq,q,WdS(sNS_AGENTS and type==resultsgot agents resulttagentR�N(R4R`R{R�R�RFR?R�(R)RARBR�tinfo((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyRv�s	cCs�tdd�}|jd�|jt�}|jd�j|�|j|�|jd�}|dkrmt	S|}|j
d�}|jdtt
f�tdd�}	|	jd�|	jt�}|jd�j|�|jd	�j|�|j
d
�r�|j
d
�j�}
|j
d�j�}|jdtt
f�tjd
tjd
|�j�|
�j�}x/tt|��D]}
tj|�j�}qW|jd�j|�n�|j
d�r|jdtt
f�|jd�}|jtjd
|j�|�j��n,|jdtt
f�|jd�j|�|j|	�}|dkrbt	S|j�dkrxtS|j�|_|j�|_t	StS(s/Authenticates and logs in to the specified jabber server
           Automatically selects the 'best' authentication method
           provided by the server.
           Supports plain text, digest and zero-k authentication.

           Returns True if the login was successful, False otherwise.
        Rtgetsauth-gettusernametquerysauth-get node arrived!Rpsauth-settresourcettokentsequenceszero-k authentication supportedtsha1thashtdigestsdigest authentication supporteds#plain text authentication supportedtpasswordN(RRjtsetQuerytNS_AUTHt	insertTagt
insertDataR9RgR^RLtgetTagR4R5R`R�thashlibtnewt	hexdigesttxrangetinttshat
getIncomingIDRlRbR$R'RaR((R)R�tpasswdR�tauth_get_iqtqt
auth_responset
auth_ret_nodetauth_ret_querytauth_set_iqR�tseqR�tfooR�t	iq_result((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytauth�sP


.cCs]tdd�}|jt�|j|�|jdt�|jdt|j�t�|jS(sURequests the roster from the server and returns a
           Roster() class instance.RR�sgot roster responsesroster -> %s(RR�RsRlR4R`R
Rz(R)trost_iq((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyt
requestRoster-s

cCs|jS(sTReturns the current Roster() class instance. Does
           not contact the server.(Rz(R)((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyt	getRoster8scCs |jtd|dd��dS(s; Send off a request to subscribe to the given jid.
        ttoRt	subscribeN(R9R!(R)R�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyt
addRosterItem>scCs�tdd�}|jt�jd�}|jdt|��|dkr\|jd|�n|dkr�x'|D]}|jd�j|�qoWn|j|�}dS(sx Update the information stored in the roster about a roster item.

            'jid' is the Jabber ID of the roster entry; 'name' is the value to
            set the entry's name to, and 'groups' is a list of groups to which
            this roster entry can belong.  If either 'name' or 'groups' is not
            specified, that value is not updated in the roster.
        RRpR�R�RNR�N(	RR�RsR�tputAttrR
R^R�Rl(R)R�RNR�RR�R�tdummy((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytupdateRosterItemDs
cCsatdd�}|jt�jd�}|jdt|��|jdd�|j|�|jS(sRemoves an item with Jabber ID jid from both the
           server's roster and the local internal Roster()
           instanceRRpR�R�R�R�(RR�RsR�R�R
RlRz(R)R�R�R�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytremoveRosterItemVs
RcCs�|r|d}ni|_tddd||j�}|jt�|jd||jft�|jt|�t�|j|�S(sfRequests registration info from the server.
           Returns the Iq object received from the server.t.RR�R�sRequesting reg info from %s%s:(	R|RR6R�RuR4R`R
Rl(R)R�treg_iq((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytrequestRegInfocs
	
cCs|jS(s Returns a dictionary of fields requested by the server for a
           registration attempt.  Each dictionary entry maps from the name of
           the field to the field's current value (either as returned by the
           server or set programmatically by calling self.setRegInfo(). (R|(R)((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyt
getRegInfooscCs||j|<dS(s[Sets a name/value attribute. Note: requestRegInfo must be
           called before setting.N(R|(R)RQtval((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyt
setRegInfowscCs�|r|d}n|dkr(d}ntd||jdd�}|jt�}x4|jj�D]#}|j|�j|j|�qcW|j	|�S(s>Sends the populated registration dictionary back to the serverR�RR�RRpN(
R^RR6R�RuR|tkeysR�tputDataRl(R)R�R�R�R�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytsendRegInfo}s
	!cCs(|r6|d}|jtd||jdd��n|dkrKd}n|j�}|j�}|jd�}td||jdd�}|jt	�|j
d�|j�}|dkr�|jd|j
�d	�n|jd
�|j|�}|dkr
tS|j�dkr tStSdS(
s� Send off a request to deregister with the server or with the given
            agent.  Returns True if successful, else False.

            Note that you must be authorised before attempting to deregister.
        R�R�RtunsubscribedRRQRps<key>s</key>s	<remove/>RoN(R9R!R6R^R�tgetQueryPayloadR�RR�RutsetQueryNodeR�t	insertXMLR�RlRLRIR$(R)R�R�tkidstkeyTagRRo((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyt
deregister�s*
&	


cCsVi|_tdd�}|jt�|j|�|jdt|j�t�|jS(s'Requests a list of available agents.  Returns a dictionary
           containing information about each agent; each entry in the
           dictionary maps the agent's JID to a dictionary of attributes
           describing what that agent can do (as returned by the
           NS_AGENTS query).RR�sagents -> %s(R{RR�RwRlR4R
R`(R)t	agents_iq((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyt
requestAgents�s	

cCsWtd|ddd|�}|r4|jd|�n|j|�}|rS|j�SdS(NR�RR�R�RC(RR�RlR�(R)R2R�RCRtrep((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyt	_discover�scCs:g}x-|jt||�D]}|j|j�qW|S(sJ According to JEP-0030: jid is mandatory, name, node, action is optional. (R�tNS_P_DISC_ITEMSRYtattrs(R)R�RCtretti((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyt
discoverItems�scCs�gg}}xm|jt||�D]V}|j�dkrN|j|j�q#|j�dkr#|j|jd��q#q#W||fS(s� According to JEP-0030:
            For identity: category, name is mandatory, type is optional.
            For feature: var is mandatorytidentitytfeaturetvar(R�tNS_P_DISC_INFORFRYR�R?(R)R�RCt
identitiestfeaturesR�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytdiscoverInfo�s
N(RR
RmRLRRnR^RRR�tsendInitPresenceRxRrRtRvR�R�R�R�R�R�R�R�R�R�R�R�R�R�R�(((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR�s2			
			
	@				
		!	
RcBs�eZdZdddddgdd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd�Zdd�Zd�ZRS(sBase class for jabber 'protocol elements' - messages, presences and iqs.
       Implements methods that are common to all thesec
Cs}|si}n|r"||d<n|r5||d<n|rH||d<n||_tjj|d|d|d|d|�dS(NR�tfromRttagR�tpayloadRC(t_nodeRtNodeR(R)RNR�RR�tfrmR�RC((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR�s	


	cCs	dGH|S(sBack compartibility methodsTWARNING! "asNode()" method is obsolette, use Protocol object as Node object instead.((R)((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytasNode�scCs&y|jd�j�SWndSXdS(s Returns the error string, if anyterrorN(R�R�R^(R)((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyRb�scCs)y|jd�jd�SWndSXdS(sReturns the error code, if anyR�tcodeN(R�R?R^(R)((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyRa�scCsN|jd�}|s'|jd�}n|j|�|jdt|��dS(sSets an error string and codeR�R�N(R�R�R�R�R(R)R�R�terr((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytsetError�s

cCs
|j�S(N(R(R)((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyt__repr__�scCs&yt|jd��SWndSXdS(s+Returns the 'to' attribute as a JID object.R�N(tJIDR?R^(R)((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytgetTo�scCs&yt|jd��SWndSXdS(s-Returns the 'from' attribute as a JID object.R�N(R�R?R^(R)((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR��scCs y|jd�SWndSXdS(s5Returns the 'type' attribute of the protocol element.RN(R?R^(R)((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyRIscCs y|jd�SWndSXdS(s3Returns the 'id' attribute of the protocol element.R>N(R?R^(R)((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyRh
scCs|jdt|��dS(s'Sets the 'to' element to the given JID.R�N(R�R
(R)R�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytsetToscCs|jdt|��dS(s)Sets the 'from' element to the given JID.R�N(R�R
(R)R�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytsetFromscCs|jd|�dS(s1Sets the 'type' attribute of the protocol elementRN(R�(R)R�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytsetTypescCs|jd|�dS(s#Sets the ID of the protocol elementR>N(R�(R)R�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyRjsicCs$y|j�|jSWndSXdS(sZReturns the x namespace, optionally passed an index if there are
           multiple tags.N(t	getXNodesR,R^(R)tindex((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytgetX$scCs;|jd|�}|s*|jd�}n|j|�|S(sbSets the name space of the x tag. It also creates the node
           if it doesn't already exist.tx(R�R�tsetNamespace(R)R,R�R((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytsetX+s

RcCsq|j|�}t|�td�ks?t|�td�krWtj|�j�}ng|_|j|�dS(sRSets the Child of an 'x' tag. Can be a Node instance or an
           XML documentRuN(RRRtNodeBuildertgetDomR�t
insertNode(R)R�R,R((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytsetXPayload4s
0	cCs�g}|dk	r�t|�td�krqx@|jd�D]/}|j�|kr:|j|jd�q:q:W|Sy|jd�|jdSWq�dSXnx+|jd�D]}|j|jd�q�W|S(s8Returns the x tags' payload as a list of Node instances.RRiN(R^RR�tgetNamespaceRYR�(R)R�tnodestxnode((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytgetXPayload@scCs�|dk	r�g}t|�td�krjx9|jd�D](}|j�|kr:|j|�q:q:W|Sy|jd�|SWq�dSXny|jd�SWndSXdS(sReturns the x Node instance. If there are multiple tags
           the first Node is returned. For multiple X nodes use getXNodes
           or pass an index integer value or namespace string to getXNode
           and if a match is found it will be returned.RRN(R^RR�RRYR�(R)R�R	R
((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytgetXNodeQscCs
|jd�S(sReturns a list of X nodes.R(R�(R)((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR�cscCs|jd�j|�dS(s1Sets the x tag's data to the given textual value.RN(R�R�(R)R�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytsetXNodegscCs0|j�}|j|j��|j|�dS(sSwaps the element's from and to attributes.
           Note that this is only useful for writing components; if you are
           writing a Jabber client you shouldn't use this, because the Jabber
           server will set the 'from' field automatically.N(R�R�R�R�(R)ttmp((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytfromToksN(RR
RmR^RR�RbRaR�R�R�R�RIRhR�R�R�RjRRRRRR�R
R(((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR�s.																R c	Bs�eZdZd
d
d
d
d
d
gd
d�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd
d	�Zd
d�Z
d
d�ZRS(saBuilds on the Protocol class to provide an interface for sending
       message protocol elementsc		Cs�tj|dd|d|d|d|d|d|�|rJ|j|�n|r`|j|�ny#|j|jd�jd	��Wn|j�nXdS(
NRR�RR�R�R�RCRtstamp(RRtsetBodyt
setSubjecttsetTimestampR�R?(	R)R�tbodyRtsubjectR�R�R�RC((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyRys4#cCs&y|jd�j�SWndSXdS(sReturns the message body.RN(R�R�R^(R)((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytgetBody�scCs&y|jd�j�SWndSXdS(sReturns the message's subject.RN(R�R�R^(R)((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyt
getSubject�scCs&y|jd�j�SWndSXdS(s Returns the message's thread ID.tthreadN(R�R�R^(R)((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyt	getThread�scCs|jS(N(t
time_stamp(R)((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytgetTimestamp�scCsA|jd�}|r%|j|�n|jd�j|�}dS(sSets the message body text.RN(R�R�R�(R)R�R((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR�scCs?|jd�}|r%|j|�n|jd�j|�dS(sSets the message subject text.RN(R�R�R�(R)R�tsubj((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR�scCs?|jd�}|r%|j|�n|jd�j|�dS(sSets the message thread ID.RN(R�R�R�(R)R�R((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyt	setThread�scCs7|s*tjdtjtj���}n||_dS(Ns%Y%m%dT%H:%M:%S(R_tstrftimetgmtimeR(R)R�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR�s$RcCsitd|j�d|�}|j�dksC|j|j��n|j�}|re|j|�n|S(s�Returns a new Message object as a reply to itself.
           The reply message has the 'to', 'type' and 'thread' attributes
           automatically set.R�RN(R R�RIR^R�RR(R)t	reply_txttmtt((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyt
buildReply�scCsdGH|j|�S(NsAWARNING: build_reply method is obsolette. Use buildReply instead.(R#(R)R ((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytbuild_reply�sN(RR
RmR^RRRRRRRRRR#R$(((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR vs!										R!c
BsheZdZdddddddgdd�	Zd�Zd�Zd�Zd�Zd�Z	d�Z
RS(	sJClass for creating and managing jabber <presence> protocol
       elementsc

Csztj|dd|d|d|d|d|d|	�|rJ|j|�n|r`|j|�n|rv|j|�ndS(NRR�RR�R�R�RC(RRtsetPrioritytsetShowt	setStatus(
R)R�RR�R�R�R�R�R�RC((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR�s4cCs&y|jd�j�SWndSXdS(sReturns the presence statusR�N(R�R�R^(R)((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR��scCs&y|jd�j�SWndSXdS(sReturns the presence showR�N(R�R�R^(R)((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR��scCs&y|jd�j�SWndSXdS(sReturns the presence priorityR�N(R�R�R^(R)((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytgetPriority�scCs?|jd�}|r%|j|�n|jd�j|�dS(sSets the presence showR�N(R�R�R�(R)R�R�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR&�scCs?|jd�}|r%|j|�n|jd�j|�dS(sSets the presence statusR�N(R�R�R�(R)R�R�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR'�scCs?|jd�}|r%|j|�n|jd�j|�dS(sSets the presence priorityR�N(R�R�R�(R)R�tpri((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR%�sN(RR
RmR^RR�R�R(R&R'R%(((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR!�s$					RcBs�eZdZdddddgdd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
ed�Zd	�Z
d
�Zd�ZRS(
sDClass for creating and managing jabber <iq> protocol
       elementscCsNtj|dd|d|d|d|d|d|�|rJ|j|�ndS(NRR�RR�R�R�RC(RRR�(R)R�RR�R�R�R�RC((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR�s4cCs#y|j|�jSWndSXdS(N(R�R,R^(R)R�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyt_getTag�scCsA|j|�}|r!||_n|j|�}|j|�|S(N(R�R,R�R(R)R�R,R�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyt_setTags
cCs
|jd�S(sreturns the list namespacetlist(R*(R)((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytgetList
scCs|jd|�S(NR,(R+(R)R,((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytsetListscCs
|jd�S(sreturns the query namespaceR�(R*(R)((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyRJscCs|jd|�S(s�Sets a query's namespace, and inserts a query tag if
           one doesn't already exist.  The resulting query tag
           is returned as the function result.R�(R+(R)R,((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR�scCs�|j�}|dkr*|jd�}nt|�td�ksZt|�td�krrtj|�j�}n|s�g|_n|j|�dS(s�Sets a Iq's query payload.  'payload' can be either a Node
           structure or a valid xml document. The query tag is automatically
           inserted if it doesn't already exist.R�RuN(	R�R^R�RRRRR�R(R)R�taddR�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytsetQueryPayloads0cCs|j�}|r|jSdS(s*Returns the query's payload as a Node listN(R�R�(R)R�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR�-scCs y|jd�SWndSXdS(s3Returns any textual data contained by the query tagR�N(R�R^(R)((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR�2scCs?|jd�}|r%|j|�n|jd�j|�dS(s,Sets textual data contained by the query tagR�N(R�R�R�(R)R�R�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR�7sN(RR
RmR^RR*R+R-R.RJR�RLR0R�R�R�(((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR�s		
						RycBs�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�ZRS(sWA Class for simplifying roster management. Also tracks roster
       item availability.cCs4i|_d|_itd6td6td6|_dS(NtbothR�R�(t_dataR^t	_listenertRS_SUB_BOTHtRS_SUB_FROMt	RS_SUB_TOt_lut(R)((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyRDs
		
cCs
||_dS(s� Set a listener function to be called whenever the roster changes.

            The given function will be called whenever the contents of the
            roster changes in response to a received <presence> or <iq> packet.
            The listener function should be defined as follows:

                def listener(action, jid, info)

            'action' is a string indicating what type of change has occurred:

                "add"     A new item has been added to the roster.
                "update"  An existing roster item has been updated.
                "remove"  A roster entry has been removed.

            'jid' is the Jabber ID (as a string) of the affected roster entry.

            'info' is a dictionary containing the information that has been
            added or updated for this roster entry.  This dictionary may
            contain any combination of the following:

                "name"    The associated name of this roster entry.
                "groups"  A list of groups associated with this roster entry.
                "online"  The roster entry's "online" value ("online",
                          "offline" or "pending").
                "sub"     The roster entry's subscription value ("none",
                          "from", "to" or "both").
                "ask"     The roster entry's ask value, if any (None,
                          "subscribe", "unsubscribe").
                "show"    The roster entry's show value, if any (None, "away",
                          "chat", "dnd", "normal", "xa").
                "status"  The roster entry's current 'status' value, if
                          specified.
        N(R3(R)tlistener((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytsetListenerMs"cCs1t|�}|jj|�r-|j|dSdS(s@Returns the 'status' value for a Roster item with the given jid.R�N(R
R2R@R^(R)R�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR�rscCs1t|�}|jj|�r-|j|dSdS(s>Returns the 'show' value for a Roster item with the given jid.R�N(R
R2R@R^(R)R�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR�zscCs1t|�}|jj|�r-|j|dSdS(sMReturns the 'online' status for a Roster item with the given jid.
           R�N(R
R2R@R^(R)R�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyt	getOnline�scCs1t|�}|jj|�r-|j|dSdS(sRReturns the 'subscription' status for a Roster item with the given
           jid.R�N(R
R2R@R^(R)R�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytgetSub�scCs1t|�}|jj|�r-|j|dSdS(s8Returns the 'name' for a Roster item with the given jid.RNN(R
R2R@R^(R)R�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyRF�scCs1t|�}|jj|�r-|j|dSdS(sK Returns the lsit of groups associated with the given roster item.
        R�N(R
R2R@R^(R)R�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyt	getGroups�scCs1t|�}|jj|�r-|j|dSdS(s>Returns the 'ask' status for a Roster item with the given jid.R�N(R
R2R@R^(R)R�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytgetAsk�scCs9i}x,|jj�D]}|j|d||<qW|S(s�Returns a summary of the roster's contents.  The returned value is a
           dictionary mapping the basic (no resource) JIDs to their current
           availability status (online, offline, pending). R�(R2R�(R)tto_retR�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyt
getSummary�scCs7g}x*|jj�D]}|jt|��qW|S(sdReturns a list of JIDs stored within the roster.  Each entry in the
           list is a JID object.(R2R�RYR�(R)R>R�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytgetJIDs�scCs|jS(s7Returns the internal data representation of the roster.(R2(R)((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytgetRaw�scCs-t|�}|j|�dkr%tStSdS(s6Returns True if the given jid is online, False if not.R�N(R
R:RLR$(R)R�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytisOnline�scCsEt|�}d}|r!d}n|jj|�r�||j|d<||j|d<||j|d<||j|d<|jdkrA|jd|i|d6|d6|d6|d6�qAn�i|d6|d6|d6|d6|d6dd	6dd
6|j|<|jdkrA|jd|i|d6|d6|d6|d6|d6�ndS(
sUsed internally - privateR�tpendingRNR�R�R�tupdateR�R�R�R/N(R
R2R@R3R^(R)R�RNR�R�R�R�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR��s(	cCs�t|�}|jj|�r^||j|d<|jdkr�|jd|i|d6�q�ndt|�j�}|jj|�r�||j|d<|jdkr�|jd|i|d6�q�ndS(sUsed internally - privateR�RDN(R
R2R@R3R^R�tgetStripped(R)R�R�t	jid_basic((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR��s cCs�t|�}|jj|�r^||j|d<|jdkr�|jd|i|d6�q�ndt|�j�}|jj|�r�||j|d<|jdkr�|jd|i|d6�q�ndS(sUsed internally - privateR�RDN(R
R2R@R3R^R�RE(R)R�R�RF((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR��s cCs�t|�}|jj|�r^||j|d<|jdkr�|jd|i|d6�q�ndt|�j�}|jj|�r�||j|d<|jdkr�|jd|i|d6�q�ndS(sUsed internally - privateR�RDN(R
R2R@R3R^R�RE(R)R�R�RF((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR�s cCsH|jj|�rD|j|=|jdkrD|jd|i�qDndS(sUsed internally - privateR�N(R2R@R3R^(R)R�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR�s
(RR
RmRR9R�R�R:R;RFR<R=R?R@RARBR�R�R�R�R�(((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyRyAs&			%											
									R�cBszeZdZddddd�Zd�ZeZd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
RS(s.A Simple class for managing jabber users id's RcCs�|r�|jd�dkr'd|_n)|jdd�}|d|_|d}|jd�dkrz||_d|_q�|jdd�\|_|_n||_||_||_dS(Nt@i����Riit/(tfindRCtsplittdomainR�(R)R�RCRKR�tbits((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyRs

	!		cCsG|j}|jr&|jd|}n|jrC|d|j7}n|S(NRGRH(RKRCR�(R)tjid_str((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR3s			cCs|jS(sReturns JID Node as string(RC(R)((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytgetNode<scCs|jS(s.Returns JID domain as string or None if absent(RK(R)((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyt	getDomainAscCs|jS(s0Returns JID resource as string or None if absent(R�(R)((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytgetResourceFscCs
||_dS(sSets JID Node from stringN(RC(R)R�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytsetNodeKscCs
||_dS(sSets JID domain from stringN(RK(R)R�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyt	setDomainPscCs
||_dS(sSets JID resource from stringN(R�(R)R�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pytsetResourceUscCs&|jr|jd|jS|jSdS(s%Returns a JID string with no resourceRGN(RCRK(R)((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyREZs	cCst|�t|�kS(smReturns whether this JID is identical to another one.
           The "other" can be a JID object or a string.(R(R)tother((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyt__eq___s(RR
RmRRR�RNRORPRQRRRSRERU(((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR�s								t	ComponentcBs>eZdZejgeeddd�Zd�Z	d�Z
RS(sdocs to come soon... c		CsTtj|||d|d|d|d|d|d|�t|_|jdt�dS(NR,RRRRRtxdb(RRRLt_auth_OKRtXDB(	R)R*R+RRRR2RR((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyRns	cCs[|jdtjd|j�|�j��x'|jsV|jd�|jd�q0WtS(swill disconnect on failureu <handshake id='1'>%s</handshake>R�swaiting on handshakei(	R9R�R�R�R�RXR4R:R$(R)tsecret((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR�vs	$
cCs/|jdkrt|_ntj||�dS(sCatch the <handshake/> heret	handshakeN(RNR$RXRRU(R)t	root_node((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyRU�sN(RR
RmRRnRLtNS_COMP_ACCEPTR^RR�RU(((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyRVls
	RYcBs#eZddddgdd�ZRS(cCs8tj|dd|d|d|d|d|d|�dS(NRWR�RR�R�R�RC(RR(R)R�RR�R�R�RC((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR�sN(RR
R^R(((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyRY�stLogcBs5eZddddgdd�Zd�Zd�ZRS(cCs8tj|dd|d|d|d|d|d|�dS(NRR�RR�R�R�RC(RR(R)R�RR�R�R�RC((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR�scCs|jd�j|�dS(sSets the log message text.RN(R�R�(R)R�((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR�scCs|jd�j�S(sReturns the log message text.R(R�R�(R)((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR�sN(RR
R^RRR(((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR^�s	tServercBseZRS((RR
(((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyR_�s(JRmRR_R�RtVERSIONRLR$R;R5t
DBG_ALWAYSRKtdebug_flagsRYRHR`tDBG_NODE_MESSAGER�RGtNS_AGENTRwR�RqtNS_DELAYtNS_OOBRuRst
NS_XROSTERt	NS_SERVERtNS_TIMEt
NS_VERSIONR]tNS_COMP_CONNECTt_NS_PROTOCOLtNS_PASStNS_XDATAtNS_RPCt	NS_BROWSEtNS_LASTt
NS_PRIVACYt	NS_XEVENTt
NS_XEXPIREt
NS_XENCRYPTEDt
NS_XSIGNEDtNS_P_MUCtNS_VCARDt_NS_P_DISCOR�R�t
NS_P_COMMANDSR4R5R6tRS_ASK_SUBSCRIBEtRS_ASK_UNSUBSCRIBEt
RS_EXT_ONLINEtRS_EXT_OFFLINEtRS_EXT_PENDINGR
t	ExceptionRRRR�RR R!RRyR�RVRYR^R_(((s1/usr/lib/python2.7/site-packages/jabber/jabber.pyt<module>?s�			




		��5�S,L�O