Mercurial > libervia-backend
diff src/core/xmpp.py @ 944:e1842ebcb2f3
core, plugin XEP-0115: discovery refactoring:
- hashing algorithm of XEP-0115 has been including in core
- our own hash is still calculated by XEP-0115 and can be regenerated with XEP_0115.recalculateHash
- old discovery methods have been removed. Now the following methods are used:
- hasFeature: tell if a feature is available for an entity
- getDiscoInfos: self explaining
- getDiscoItems: self explaining
- findServiceEntities: return all available items of an entity which given (category, type)
- findFeaturesSet: search for a set of features in entity + entity's items
all these methods are asynchronous, and manage cache automatically
- XEP-0115 manage in a better way hashes, and now use a trigger for presence instead of monkey patch
- new FeatureNotFound exception, when we want to do something which is not available
- refactored client initialisation sequence, removed client.initialized Deferred
- added constant APP_URL
- test_plugin_xep_0033.py has been temporarly deactivated, the time to adapt it
- lot of cleaning
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 28 Mar 2014 18:07:22 +0100 |
parents | 34dd9287dfe5 |
children | 61c4755f0394 |
line wrap: on
line diff
--- a/src/core/xmpp.py Fri Mar 28 18:07:17 2014 +0100 +++ b/src/core/xmpp.py Fri Mar 28 18:07:22 2014 +0100 @@ -41,7 +41,6 @@ self.__connected = False self.profile = profile self.host_app = host_app - self.client_initialized = defer.Deferred() self.conn_deferred = defer.Deferred() self._waiting_conf = {} # callback called when a confirmation is received self._progress_cb_map = {} # callback called when a progress is requested (key = progress id) @@ -69,19 +68,17 @@ self.disco.setHandlerParent(self) self.discoHandler = disco.DiscoHandler() self.discoHandler.setHandlerParent(self) + disco_d = defer.succeed(None) - if not self.host_app.trigger.point("Disco Handled", self.profile): + if not self.host_app.trigger.point("Disco handled", disco_d, self.profile): return - self.roster.requestRoster() - - self.presence.available() + def finish_connection(dummy): + self.roster.requestRoster() + self.presence.available() + self.conn_deferred.callback(None) - jid_ = self.getHostJid() - self.disco.requestInfo(jid_).addCallback(self.host_app.serverDisco, jid_, self.profile) # FIXME: use these informations - - self.disco.requestItems(jid_).addCallback(self.host_app.serverDiscoItems, self.disco, jid_, self.profile, self.client_initialized) - self.conn_deferred.callback(None) + disco_d.addCallback(finish_connection) def initializationFailed(self, reason): error(_("ERROR: XMPP connection failed for profile '%(profile)s': %(reason)s" % {'profile': self.profile, 'reason': reason})) @@ -106,10 +103,6 @@ self.host_app.bridge.disconnected(self.profile) # we send the signal to the clients self.host_app.purgeClient(self.profile) # and we remove references to this client - def getHostJid(self): - """@return: the jid of the local server""" - return jid.JID(self.jid.host) - class SatMessageProtocol(xmppim.MessageProtocol): @@ -292,6 +285,11 @@ xmppim.PresenceClientProtocol.__init__(self) self.host = host + def send(self, obj): + if not self.host.trigger.point("Presence send", obj): + return + super(SatPresenceProtocol, self).send(obj) + def availableReceived(self, entity, show=None, statuses=None, priority=0): debug(_("presence update for [%(entity)s] (available, show=%(show)s statuses=%(statuses)s priority=%(priority)d)") % {'entity': entity, 'show': show, 'statuses': statuses, 'priority': priority}) @@ -434,7 +432,7 @@ if self.user_email: _email = query.addElement('email') _email.addContent(self.user_email) - reg = iq.send(self.jabber_host).addCallbacks(self.registrationAnswer, self.registrationFailure) + iq.send(self.jabber_host).addCallbacks(self.registrationAnswer, self.registrationFailure) def registrationAnswer(self, answer): debug(_("registration answer: %s") % answer.toXml())