def add_notify( self, what ): self._subnotify.append( weakref.ref(what) ) if self._cache and self._cache.has_key('INDEX'): for entry in self.get_index(): what.notify_addto( entry ) elif self._search is not None: for entry in self._search.entries(): what.notify_addto( entry ) if self._waited: what.notify_complete( 'ok' )
def __init__( self, s=None, connection=None, base=None, enum=None, criteria=None, context=None, notify=None, ret=None, sort=None, notify_complete=None, depth=None, limit=None, chunked=False, index=None ): '''Create the search object. Uses: s = The search command, sans tag, in ACAP syntax. Sorry. connection = Connection to be used. context = The context name used, if any. This is optional. notify = An object instance used to notify that the context has changed. If there is a notify object given, but no context, (or a context which is not set to NOTIFY) then the notify object will still be called as search results come in. If there is a context but no notify, then no notifications will happen. But the results will still get updated.''' self._notify = None if notify is not None: self._notify = weakref.ref(notify) self._notify_complete = notify_complete self._written = False self._command_raw = s if isinstance(s,unicode): self._command_raw = s.encode('utf-8') self._command_parsed = None self._enumerate = enum self._base = base self._depth = depth self._criteria = criteria or 'ALL' self._sort = sort self._entries = {} self._connection = None self._ctxt = context self._complete = False self._state = None self._enum = index self._toomany = None self._retpart = ret self._state_payload = None self._enum_tag = None self._modtime = None if self._enumerate and self._sort is None: raise "Must sort with enumerate." self._limit = limit self._chunked = chunked if self._enum is None: if self._limit is None or self._limit!=0: self._enum = [] if self._chunked and self._limit is None: self._limit = 25 if connection is not None: self.set_connection( connection )
def __init__( self, server, use_plain=False ): self.server = weakref.ref(server) if not server.have_capability( 'SASL' ): raise infotrope.base.connection.exception( "ACAP server does not support SASL?" ) self.sasl = server.sasl if use_plain: self.mech = self.sasl.mechlist( ['PLAIN'] ) else: self.mech = self.sasl.mechlist( server.get_capability('SASL') ) cmd = ['AUTHENTICATE', infotrope.base.string( self.mech.name() )] x = self.mech.process( None ) if x is not None: cmd.append( string( x ) ) infotrope.base.command.__init__( self, server.env, 'AUTH', cmd ) self.feeding = True self.oncomplete( self.notify ) self.resend = False
def fromRosterItemXml( self, xml, r ): self.name = xml.getAttribute('name') self.jid = infotrope.url.URL( 'xmpp:' + xml.getAttribute('jid') ).bare_jid() sub = xml.getAttribute('subscription') if sub in ['from','both']: self.sub_from = True else: self.sub_from = False if sub in ['to','both']: self.sub_to = True else: self.sub_to = False self.groups = [] for x in xml.childNodes: if x.nodeType == x.ELEMENT_NODE and x.localName == 'group': self.groups.append( x.childNodes[0].nodeValue ) r[x.childNodes[0].nodeValue].append( weakref.ref(self) ) return sub == 'remove'
def __init__( self, idc, server ): print 1 self.cmd = None self.server = weakref.ref( server ) self.sasl = server.sasl try: print 2 self.mech = self.sasl.mechlist( server.get_capability('AUTH') ) print 3, `self.mech` if self.mech is None: raise "No mech" sir = self.mech.process( None ) print 4, `sir` if sir is None: cmd = 'AUTH %s' % self.mech.name() else: cmd = 'AUTH %s %s' % ( self.mech.name(), ''.join( sir.encode('base64').split('\n') ) ) print 5 infotrope.xtp.command.__init__( self, server.env, idc, cmd ) print 6 self.oncomplete( self.auth_complete ) except infotrope.sasl.error, e: server.sasl_fail( e ) raise
def __init__( self, server, payload ): infotrope.xtp.command.__init__( self, server.env, None, 'DATA' ) self.server = weakref.ref( server ) self.payload = payload
def __init__( self, conn ): self.groups = {} self.all = {} self.server = weakref.ref( conn )
def add_notify( self, me ): self.roster_listeners.append( weakref.ref(me) )
def add_resync( self, callable ): self._resyncs = [ x for x in self._resyncs if x() is not None ] + [ weakref.ref(callable) ]