def idle(self): print 'Idle...' Client.idle(self) if self.session_established and not self.sent: self.sent = True target = JID('-' + self.to_uid, self.jid.domain) self.get_stream().send(Message(to_jid=target, body=unicode(self.message)))
def idle(self): """Called when there is a chance to do idle work.""" print '%s Idle' % datetime.datetime.now() if self.outbox_directory: # Outbox format is one message per file. First line is the recipient, # the remaining lines are the message for ent in os.listdir(self.outbox_directory): print ' ... Found %s' % ent f = open('%s/%s' % (self.outbox_directory, ent), 'r') d = f.readlines() f.close() m = Message(to_jid=JID(d[0].rstrip('\n')), from_jid=self.jid, stanza_type='chat', subject=None, body=Normalize(''.join(d[1:]).rstrip('\n'))) self.stream.send(m) print ' ... recipient = %s' % d[0].rstrip('\n') print ' ... body = %s' % Normalize(''.join(d[1:]).rstrip('\n')) os.unlink('%s/%s' % (self.outbox_directory, ent)) Client.idle(self)
def authorized(self): """Handle "authorized" event. May be overriden in derived classes. By default: request an IM session and setup Disco handlers.""" Client.authorized(self) self.stream.set_iq_get_handler("query",DISCO_ITEMS_NS,self.__disco_items) self.stream.set_iq_get_handler("query",DISCO_INFO_NS,self.__disco_info) disco.register_disco_cache_fetchers(self.cache,self.stream)
def authorized(self): """Handle "authorized" event. May be overriden in derived classes. By default: request an IM session and setup Disco handlers.""" self.stream.set_iq_get_handler("query",DISCO_ITEMS_NS,self._JabberClient__disco_items) self.stream.set_iq_get_handler("query",DISCO_INFO_NS,self._JabberClient__disco_info) pyxmpp_disco.register_disco_cache_fetchers(self.cache,self.stream) Client.authorized(self)
def connect(self, register=False): """Connect to the server and set up the stream. Set `self.stream` and notify `self.state_changed` when connection succeeds. Additionally, initialize Disco items and info of the client. """ Client.connect(self, register) if register: self.stream.registration_callback = self.process_registration_form
def connect(self, register = False): """Connect to the server and set up the stream. Set `self.stream` and notify `self.state_changed` when connection succeeds. Additionally, initialize Disco items and info of the client. """ Client.connect(self, register) if register: self.stream.registration_callback = self.process_registration_form
def _session_started(self): """Called when session is started. Activates objects from `self.interface_provides` by installing their disco features.""" Client._session_started(self) for ob in self.interface_providers: if IFeaturesProvider.providedBy(ob): for ns in ob.get_features(): self.register_feature(ns)
def __init__(self, jid=None, password=None, server=None, port=5222, auth_methods=("sasl:DIGEST-MD5", "digest"), tls_settings=None, keepalive=0, disco_name=u"pyxmpp based Jabber client", disco_category=u"client", disco_type=u"pc"): """Initialize a JabberClient object. :Parameters: - `jid`: user full JID for the connection. - `password`: user password. - `server`: server to use. If not given then address will be derived form the JID. - `port`: port number to use. If not given then address will be derived form the JID. - `auth_methods`: sallowed authentication methods. SASL authentication mechanisms in the list should be prefixed with "sasl:" string. - `tls_settings`: settings for StartTLS -- `TLSSettings` instance. - `keepalive`: keepalive output interval. 0 to disable. - `disco_name`: name of the client identity in the disco#info replies. - `disco_category`: category of the client identity in the disco#info replies. The default of u'client' should be the right choice in most cases. - `disco_type`: type of the client identity in the disco#info replies. Use `the types registered by Jabber Registrar <http://www.jabber.org/registrar/disco-categories.html>`__ :Types: - `jid`: `pyxmpp.JID` - `password`: `unicode` - `server`: `unicode` - `port`: `int` - `auth_methods`: sequence of `str` - `tls_settings`: `pyxmpp.TLSSettings` - `keepalive`: `int` - `disco_name`: `unicode` - `disco_category`: `unicode` - `disco_type`: `unicode` """ Client.__init__(self, jid, password, server, port, auth_methods, tls_settings, keepalive) self.stream_class = LegacyClientStream self.disco_items = DiscoItems() self.disco_info = DiscoInfo() self.disco_identity = DiscoIdentity(self.disco_info, disco_name, disco_category, disco_type) self.register_feature(u"dnssrv") self.register_feature(u"stringprep") self.register_feature(u"urn:ietf:params:xml:ns:xmpp-sasl#c2s") self.cache = CacheSuite(max_items=1000) self.__logger = logging.getLogger("pyxmpp.jabber.JabberClient")
def __init__(self,jid=None, password=None, server=None, port=5222, auth_methods=("sasl:DIGEST-MD5","digest"), tls_settings=None, keepalive=0, disco_name=u"pyxmpp based Jabber client", disco_category=u"client", disco_type=u"pc"): """Initialize a JabberClient object. :Parameters: - `jid`: user full JID for the connection. - `password`: user password. - `server`: server to use. If not given then address will be derived form the JID. - `port`: port number to use. If not given then address will be derived form the JID. - `auth_methods`: sallowed authentication methods. SASL authentication mechanisms in the list should be prefixed with "sasl:" string. - `tls_settings`: settings for StartTLS -- `TLSSettings` instance. - `keepalive`: keepalive output interval. 0 to disable. - `disco_name`: name of the client identity in the disco#info replies. - `disco_category`: category of the client identity in the disco#info replies. The default of u'client' should be the right choice in most cases. - `disco_type`: type of the client identity in the disco#info replies. Use `the types registered by Jabber Registrar <http://www.jabber.org/registrar/disco-categories.html>`__ :Types: - `jid`: `pyxmpp.JID` - `password`: `unicode` - `server`: `unicode` - `port`: `int` - `auth_methods`: sequence of `str` - `tls_settings`: `pyxmpp.TLSSettings` - `keepalive`: `int` - `disco_name`: `unicode` - `disco_category`: `unicode` - `disco_type`: `unicode` """ Client.__init__(self,jid,password,server,port,auth_methods,tls_settings,keepalive) self.stream_class = LegacyClientStream self.disco_items=DiscoItems() self.disco_info=DiscoInfo() self.disco_identity=DiscoIdentity(self.disco_info, disco_name, disco_category, disco_type) self.register_feature(u"dnssrv") self.register_feature(u"stringprep") self.register_feature(u"urn:ietf:params:xml:ns:xmpp-sasl#c2s") self.cache = CacheSuite(max_items = 1000) self.__logger = logging.getLogger("pyxmpp.jabber.JabberClient")
def __init__(self, to_uid, message, **kwargs): Client.__init__(self, **kwargs) self.to_uid = to_uid self.message = message self.sent = False
def idle(self): Client.idle(self)
def __init__(self, chatbuff=None, **kwargs): Client.__init__(self, **kwargs) if chatbuff != None: self.buffr = chatbuff