comparison src/sat.tac @ 252:c09aa319712e

Core: Trigger implementation + version number update - first trigger: MessageReceived - switching to dev version 0.1.1D
author Goffi <goffi@goffi.org>
date Mon, 17 Jan 2011 00:15:28 +0100
parents e077f068ff57
children 012c38b56cdd
comparison
equal deleted inserted replaced
251:dbe1803eca7c 252:c09aa319712e
19 along with this program. If not, see <http://www.gnu.org/licenses/>. 19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 """ 20 """
21 21
22 CONST = { 22 CONST = {
23 'client_name' : u'SàT (Salut à toi)', 23 'client_name' : u'SàT (Salut à toi)',
24 'client_version' : u'0.1.1', #Please add 'D' at the end for dev versions 24 'client_version' : u'0.1.1D', #Please add 'D' at the end for dev versions
25 'local_dir' : '~/.sat' 25 'local_dir' : '~/.sat'
26 } 26 }
27 27
28 import gettext 28 import gettext
29 gettext.install('sat', "i18n", unicode=True) 29 gettext.install('sat', "i18n", unicode=True)
48 import signal, sys 48 import signal, sys
49 import os.path 49 import os.path
50 50
51 from sat.tools.memory import Memory 51 from sat.tools.memory import Memory
52 from sat.tools.xml_tools import tupleList2dataForm 52 from sat.tools.xml_tools import tupleList2dataForm
53 from sat.tools.misc import TriggerManager
53 from glob import glob 54 from glob import glob
54 55
55 try: 56 try:
56 from twisted.words.protocols.xmlstream import XMPPHandler 57 from twisted.words.protocols.xmlstream import XMPPHandler
57 except ImportError: 58 except ImportError:
124 xmppim.MessageProtocol.__init__(self) 125 xmppim.MessageProtocol.__init__(self)
125 self.host = host 126 self.host = host
126 127
127 def onMessage(self, message): 128 def onMessage(self, message):
128 debug (_(u"got message from: %s"), message["from"]) 129 debug (_(u"got message from: %s"), message["from"])
130 if not self.host.trigger.point("MessageReceived",message):
131 return
129 for e in message.elements(): 132 for e in message.elements():
130 if e.name == "body": 133 if e.name == "body":
131 type = message['type'] if message.hasAttribute('type') else 'chat' #FIXME: check specs 134 type = message['type'] if message.hasAttribute('type') else 'chat' #FIXME: check specs
132 self.host.bridge.newMessage(message["from"], e.children[0], type, profile=self.parent.profile) 135 self.host.bridge.newMessage(message["from"], e.children[0], type, profile=self.parent.profile)
133 self.host.memory.addToHistory(self.parent.jid, jid.JID(message["from"]), self.parent.jid, "chat", e.children[0]) 136 self.host.memory.addToHistory(self.parent.jid, jid.JID(message["from"]), self.parent.jid, "chat", e.children[0])
322 325
323 self.__waiting_conf = {} #callback called when a confirmation is received 326 self.__waiting_conf = {} #callback called when a confirmation is received
324 self.__progress_cb_map = {} #callback called when a progress is requested (key = progress id) 327 self.__progress_cb_map = {} #callback called when a progress is requested (key = progress id)
325 self.__general_cb_map = {} #callback called for general reasons (key = name) 328 self.__general_cb_map = {} #callback called for general reasons (key = name)
326 self.__private_data = {} #used for internal callbacks (key = id) 329 self.__private_data = {} #used for internal callbacks (key = id)
330 self.trigger = TriggerManager() #trigger are user to change SàT behaviour
327 self.profiles = {} 331 self.profiles = {}
328 self.plugins = {} 332 self.plugins = {}
329 self.menus = {} #used to know which new menus are wanted by plugins 333 self.menus = {} #used to know which new menus are wanted by plugins
330 334
331 self.memory=Memory(self) 335 self.memory=Memory(self)