Mercurial > libervia-backend
comparison src/core/xmpp.py @ 518:75216d94a89d
primitivus: fixed messages order in chat window
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 21 Oct 2012 12:03:29 +0200 |
parents | 8ee9113d307b |
children | b7577230a7c8 |
comparison
equal
deleted
inserted
replaced
517:59b32c04e105 | 518:75216d94a89d |
---|---|
35 self.__connected=False | 35 self.__connected=False |
36 self.profile = profile | 36 self.profile = profile |
37 self.host_app = host_app | 37 self.host_app = host_app |
38 self.client_initialized = defer.Deferred() | 38 self.client_initialized = defer.Deferred() |
39 self.conn_deferred = defer.Deferred() | 39 self.conn_deferred = defer.Deferred() |
40 self.ignored = set() | |
40 | 41 |
41 def getConnectionDeferred(self): | 42 def getConnectionDeferred(self): |
42 """Return a deferred which fire when the client is connected""" | 43 """Return a deferred which fire when the client is connected""" |
43 return self.conn_deferred | 44 return self.conn_deferred |
44 | 45 |
95 except AttributeError: | 96 except AttributeError: |
96 debug (_("No keep_alife")) | 97 debug (_("No keep_alife")) |
97 self.host_app.bridge.disconnected(self.profile) #we send the signal to the clients | 98 self.host_app.bridge.disconnected(self.profile) #we send the signal to the clients |
98 self.host_app.purgeClient(self.profile) #and we remove references to this client | 99 self.host_app.purgeClient(self.profile) #and we remove references to this client |
99 | 100 |
101 def ignore(self, entity_jid): | |
102 """Put entity in ignore list | |
103 @param entity_jid: jid of the entity to ignore""" | |
104 self.ignored.add(entity_jid) | |
105 | |
106 def unignore(self, entity_jid): | |
107 """Remove an entity from ignore list | |
108 @param entity_jid: jid of the entity to ignore""" | |
109 self.ignored.discard(entity_jid) | |
110 | |
111 def isIgnored(self, entity_jid): | |
112 """Tell if an entity is in ignore | |
113 @param entity_jid: jid of the entity to ignore""" | |
114 return entity_jid in self.ignored | |
100 | 115 |
101 class SatMessageProtocol(xmppim.MessageProtocol): | 116 class SatMessageProtocol(xmppim.MessageProtocol): |
102 | 117 |
103 def __init__(self, host): | 118 def __init__(self, host): |
104 xmppim.MessageProtocol.__init__(self) | 119 xmppim.MessageProtocol.__init__(self) |
105 self.host = host | 120 self.host = host |
106 | 121 |
107 def onMessage(self, message): | 122 def onMessage(self, message): |
108 debug (_(u"got message from: %s"), message["from"]) | 123 debug (_(u"got message from: %s") % message["from"]) |
124 | |
125 if self.parent.isIgnored(jid.JID(message["from"])): | |
126 info(_(u"%s is ignored, discarding the message") % message["from"]) | |
127 return | |
128 | |
109 if not self.host.trigger.point("MessageReceived",message, profile=self.parent.profile): | 129 if not self.host.trigger.point("MessageReceived",message, profile=self.parent.profile): |
110 return | 130 return |
111 for e in message.elements(): | 131 for e in message.elements(): |
112 if e.name == "body": | 132 if e.name == "body": |
113 mess_type = message['type'] if message.hasAttribute('type') else 'normal' | 133 mess_type = message['type'] if message.hasAttribute('type') else 'normal' |