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
This commit is contained in:
parent
382d49a628
commit
95678d7967
1 changed files with 431 additions and 479 deletions
|
|
@ -41,7 +41,6 @@ class SatXMPPClient(client.XMPPClient):
|
|||
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 @@ class SatXMPPClient(client.XMPPClient):
|
|||
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()
|
||||
def finish_connection(dummy):
|
||||
self.roster.requestRoster()
|
||||
self.presence.available()
|
||||
self.conn_deferred.callback(None)
|
||||
|
||||
self.presence.available()
|
||||
|
||||
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 @@ class SatXMPPClient(client.XMPPClient):
|
|||
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 @@ class SatPresenceProtocol(xmppim.PresenceClientProtocol):
|
|||
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 @@ class RegisteringAuthenticator(xmlstream.ConnectAuthenticator):
|
|||
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())
|
||||
|
|
|
|||
Loading…
Reference in a new issue