Ϫf%dZddlmZddlmZddlmZmZddlm Z ddl m Z ddl m Z ddlmZmZGd d ZGd d ZGd dZGdde j(Zy)zyInstance Messenger base classes for protocol support. You will find these useful if you're adding a new protocol to IM. )Type)error)ProtocolconnectionDone)styles)FailureprefixedMethods)OFFLINE OfflineErrorcBeZdZdZdZdZdZdZdefdZ defdZ y ) AbstractGroupc ||_||_yN)nameaccount)selfrrs >/usr/lib/python3/dist-packages/twisted/words/im/basesupport.py__init__zAbstractGroup.__init__s  ct|dS)zfinds group commands these commands are methods on me that start with imgroup_; they are called with no arguments imgroup_r rs rgetGroupCommandszAbstractGroup.getGroupCommandss tZ00rct|dS)a(finds group commands these commands are methods on me that start with imgroup_; they are called with a user present within this room as an argument you may want to override this in your group in order to filter for appropriate commands on the given user imtarget_r )rtargets rgetTargetCommandszAbstractGroup.getTargetCommands#st[11rc|jjst|jjj|jyr)rclientr joinGrouprrs rjoinzAbstractGroup.join.s1||""  %%dii0rc|jjst|jjj|jyr)rr r leaveGrouprrs rleavezAbstractGroup.leave3s1||""  &&tyy1rreturnc<d|jd|jdS)N< >) __class__rrs r__repr__zAbstractGroup.__repr__8s 4>>"!DII=22rcL|jd|jjSN@rr accountNamers r__str__zAbstractGroup.__str__;"))Adll66788rN) __name__ __module__ __qualname__rrrr"r%strr,r2rrrrs31 21 2 3#399rrc6eZdZdZdZdZdefdZdefdZy)AbstractPersonc6||_||_t|_yr)rrr status)rr baseAccounts rrzAbstractPerson.__init__@s "  rct|dS)zfinds person commands these commands are methods on me that start with imperson_; they are called with no arguments imperson_r rs rgetPersonCommandsz AbstractPerson.getPersonCommandsEs t[11rcy)z# Returns a string. z--r8rs r getIdleTimezAbstractPerson.getIdleTimeMsrr&cVd|jd|jd|jdS)Nr(r)/r*)r+rr<rs rr,zAbstractPerson.__repr__Ss*4>>"!DII=$++a@@rcL|jd|jjSr.r0rs rr2zAbstractPerson.__str__Vr3rN) r4r5r6rr@rBr7r,r2r8rrr:r:?s+ 2 A#A99rr:cLeZdZUdZdZeeed<dZdZ e fde ddfdZ d Z y) AbstractClientMixinzDesigned to be mixed in to a Protocol implementing class. Inherit from me first. @ivar _logonDeferred: Fired when I am done logging in. N _protoBasec|jjD]%}t|ts||j_n ||_||_||_yr)r+ __bases__ issubclassrrHrchat_logonDeferred)rrchatui logonDeferredbases rrzAbstractClientMixin.__init__dsONN,, D$),0)    +rc:|jj|yr)rHconnectionMaders rrRz"AbstractClientMixin.connectionMadeos &&t,rreasonr&c|jj|||j|jj ||Sr)r _clientLostunregisterAsAccountClientrHconnectionLostrrSs rrWz"AbstractClientMixin.connectionLostrs9   v. &&(--dF;;rc:|jj|y)z*Tell the chat UI that I have `signed off'.N)rLunregisterAccountClientrs rrVz-AbstractClientMixin.unregisterAsAccountClientws ))$/r)r4r5r6__doc__rHrr__annotations__rrRrrrWrVr8rrrGrGZs>"&JX% ,-0>}, I implement L{isOnline} and most of L{logOn}, though you'll need to implement L{_startLogOn} in a subclass. @cvar _groupFactory: A Callable that will return a L{IGroup} appropriate for this account type. @cvar _personFactory: A Callable that will return a L{IPerson} appropriate for this account type. @type _isConnecting: boolean @ivar _isConnecting: Whether I am in the process of establishing a connection to the server. @type _isOnline: boolean @ivar _isOnline: Whether I am currently on-line with the server. @ivar accountName: @ivar autoLogin: @ivar username: @ivar password: @ivar host: @ivar port: rNct||_||_||_||_||_||_i|_i|_yr)r1 autoLoginusernamepasswordhostport_groups_persons)rr1rarbrcrdres rrzAbstractAccount.__init__s;&"        rcFdD]}t||rt||iy)N)rfrg)hasattrsetattr)rks rupgrateToVersion2z!AbstractAccount.upgrateToVersion2s'( %A4#a$ %rcxtjj|}dD]} ||=|S#t$rYwxYw)N)r _isOnline _isConnecting)r Versioned __getstate__KeyError)rstaterks rrqzAbstractAccount.__getstate__sN  --d39 A !H     s - 99c|jSr)rnrs risOnlinezAbstractAccount.isOnlines ~~rc2|jsw|jskd|_|j|}|j|j|j|j |j |j|Stjd)a=Log on to this account. Takes care to not start a connection if a connection is already in progress. You will need to implement L{_startLogOn} for this to work, and it would be a good idea to override L{_loginFailed} too. @returntype: Deferred L{interfaces.IClient} zConnection in progress) rorn _startLogOn addCallback _cb_logOnregisterAccountClient addErrback _loginFailedr ConnectError)rrNds rlogOnzAbstractAccount.logOnsx""T^^!"D   (A MM$.. ) MM&66 7 LL** +H$$%=> >rc|jj|}|!|j||}||j|<|S)zkGroup factory. @param name: Name of the group on this account. @type name: string )rfget _groupFactory)rrgroups rgetGroupzAbstractAccount.getGroupsB    & =&&tT2E!&DLL  rc|jj|}|!|j||}||j|<|S)zmPerson factory. @param name: Name of the person on this account. @type name: string )rgr_personFactory)rrpersons r getPersonzAbstractAccount.getPersonsB ""4( >((t4F"(DMM$  rct)z{Start the sign on process. Factored out of L{logOn}. @returntype: Deferred L{interfaces.IClient} )NotImplementedError)rrNs rrxzAbstractAccount._startLogOns "##rc0d|_d|_||_|S)Nrrw)rornr )rr s rrzzAbstractAccount._cb_logOns  rc"d|_d|_|S)zErrorback for L{logOn}. @type reason: Failure @returns: I{reason}, for further processing in the callback chain. @returntype: Failure r)rornrXs rr}zAbstractAccount._loginFaileds rc0d|_d|_d|_|S)Nr)r rorn)rr rSs rrUzAbstractAccount._clientLosts  rr&cdj|j|j|j|j|j S)Nz<{}: {} ({}@{}:{})>)formatr+r1rbrdrers rr,zAbstractAccount.__repr__ s:$++ NN    MM II II   r)r4r5r6r[rnror rrr:rpersistanceVersionrrlrqrurrrrxrzr}rUr7r,r8rrr^r^|sk2IM F!M#N % ?.  $   # rr^N)r[typingrtwisted.internetrtwisted.internet.protocolrrtwisted.persistedrtwisted.python.failurertwisted.python.reflectr twisted.words.im.localsr r rr:rGrpr^r8rrrsU ">$*29 &9&9R99600DW f&&W r