comparison sat.tac @ 67:0e50dd3a234a

message sending bug fixes + sortilege update - sortilege now use default profile. /!\ sortilege is really buggy currently, need some attention
author Goffi <goffi@goffi.org>
date Thu, 04 Feb 2010 01:06:36 +1100
parents 8147b4f40809
children 9b842086d915
comparison
equal deleted inserted replaced
66:8147b4f40809 67:0e50dd3a234a
123 123
124 def onMessage(self, message): 124 def onMessage(self, message):
125 debug (u"got_message from: %s", message["from"]) 125 debug (u"got_message from: %s", message["from"])
126 for e in message.elements(): 126 for e in message.elements():
127 if e.name == "body": 127 if e.name == "body":
128 self.host.bridge.newMessage(message["from"], e.children[0], self.parent.profile) 128 type = message['type'] if message.hasAttribute('type') else 'chat' #FIXME: check specs
129 self.host.bridge.newMessage(message["from"], e.children[0], type, profile=self.parent.profile)
129 self.host.memory.addToHistory(self.parent.jid, jid.JID(message["from"]), self.parent.jid, "chat", e.children[0]) 130 self.host.memory.addToHistory(self.parent.jid, jid.JID(message["from"]), self.parent.jid, "chat", e.children[0])
130 break 131 break
131 132
132 class SatRosterProtocol(xmppim.RosterClientProtocol): 133 class SatRosterProtocol(xmppim.RosterClientProtocol):
133 134
571 572
572 573
573 ## jabber methods ## 574 ## jabber methods ##
574 575
575 def sendMessage(self,to,msg,type='chat', profile_key='@DEFAULT@'): 576 def sendMessage(self,to,msg,type='chat', profile_key='@DEFAULT@'):
577 print "sendtype=", type #gof
576 #FIXME: check validity of recipient 578 #FIXME: check validity of recipient
577 profile = self.memory.getProfileName(profile_key) 579 profile = self.memory.getProfileName(profile_key)
578 assert(profile) 580 assert(profile)
579 current_jid = self.profiles[profile].jid 581 current_jid = self.profiles[profile].jid
580 debug("Sending jabber message to %s...", to) 582 debug("Sending jabber message to %s...", to)
583 message["from"] = current_jid.full() 585 message["from"] = current_jid.full()
584 message["type"] = type 586 message["type"] = type
585 message.addElement("body", "jabber:client", msg) 587 message.addElement("body", "jabber:client", msg)
586 self.profiles[profile].xmlstream.send(message) 588 self.profiles[profile].xmlstream.send(message)
587 self.memory.addToHistory(current_jid, current_jid, jid.JID(to), message["type"], unicode(msg)) 589 self.memory.addToHistory(current_jid, current_jid, jid.JID(to), message["type"], unicode(msg))
588 self.bridge.newMessage(message['from'], unicode(msg), to=message['to'], profile=profile) #We send back the message, so all clients are aware of it 590 self.bridge.newMessage(message['from'], unicode(msg), to=message['to'], type=type, profile=profile) #We send back the message, so all clients are aware of it
589 591
590 592
591 def setPresence(self, to="", show="", priority = 0, statuses={}, profile_key='@DEFAULT@'): 593 def setPresence(self, to="", show="", priority = 0, statuses={}, profile_key='@DEFAULT@'):
592 """Send our presence information""" 594 """Send our presence information"""
593 profile = self.memory.getProfileName(profile_key) 595 profile = self.memory.getProfileName(profile_key)