comparison src/core/xmpp.py @ 519:b7577230a7c8

reverted bad commit
author Goffi <goffi@goffi.org>
date Sun, 21 Oct 2012 12:55:27 +0200
parents 75216d94a89d
children 9a3913fb0a6c
comparison
equal deleted inserted replaced
518:75216d94a89d 519:b7577230a7c8
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()
41 40
42 def getConnectionDeferred(self): 41 def getConnectionDeferred(self):
43 """Return a deferred which fire when the client is connected""" 42 """Return a deferred which fire when the client is connected"""
44 return self.conn_deferred 43 return self.conn_deferred
45 44
96 except AttributeError: 95 except AttributeError:
97 debug (_("No keep_alife")) 96 debug (_("No keep_alife"))
98 self.host_app.bridge.disconnected(self.profile) #we send the signal to the clients 97 self.host_app.bridge.disconnected(self.profile) #we send the signal to the clients
99 self.host_app.purgeClient(self.profile) #and we remove references to this client 98 self.host_app.purgeClient(self.profile) #and we remove references to this client
100 99
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
115 100
116 class SatMessageProtocol(xmppim.MessageProtocol): 101 class SatMessageProtocol(xmppim.MessageProtocol):
117 102
118 def __init__(self, host): 103 def __init__(self, host):
119 xmppim.MessageProtocol.__init__(self) 104 xmppim.MessageProtocol.__init__(self)
120 self.host = host 105 self.host = host
121 106
122 def onMessage(self, message): 107 def onMessage(self, message):
123 debug (_(u"got message from: %s") % message["from"]) 108 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
129 if not self.host.trigger.point("MessageReceived",message, profile=self.parent.profile): 109 if not self.host.trigger.point("MessageReceived",message, profile=self.parent.profile):
130 return 110 return
131 for e in message.elements(): 111 for e in message.elements():
132 if e.name == "body": 112 if e.name == "body":
133 mess_type = message['type'] if message.hasAttribute('type') else 'normal' 113 mess_type = message['type'] if message.hasAttribute('type') else 'normal'