primitivus: fixed messages order in chat window

This commit is contained in:
Goffi 2012-10-21 12:03:29 +02:00
commit 031bd3134f

View file

@ -37,6 +37,7 @@ class SatXMPPClient(client.XMPPClient):
self.host_app = host_app
self.client_initialized = defer.Deferred()
self.conn_deferred = defer.Deferred()
self.ignored = set()
def getConnectionDeferred(self):
"""Return a deferred which fire when the client is connected"""
@ -97,6 +98,20 @@ 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 ignore(self, entity_jid):
"""Put entity in ignore list
@param entity_jid: jid of the entity to ignore"""
self.ignored.add(entity_jid)
def unignore(self, entity_jid):
"""Remove an entity from ignore list
@param entity_jid: jid of the entity to ignore"""
self.ignored.discard(entity_jid)
def isIgnored(self, entity_jid):
"""Tell if an entity is in ignore
@param entity_jid: jid of the entity to ignore"""
return entity_jid in self.ignored
class SatMessageProtocol(xmppim.MessageProtocol):
@ -105,7 +120,12 @@ class SatMessageProtocol(xmppim.MessageProtocol):
self.host = host
def onMessage(self, message):
debug (_(u"got message from: %s"), message["from"])
debug (_(u"got message from: %s") % message["from"])
if self.parent.isIgnored(jid.JID(message["from"])):
info(_(u"%s is ignored, discarding the message") % message["from"])
return
if not self.host.trigger.point("MessageReceived",message, profile=self.parent.profile):
return
for e in message.elements():