Mercurial > libervia-backend
changeset 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 (2010-02-03) |
parents | 8147b4f40809 |
children | 9b842086d915 |
files | frontends/quick_frontend/quick_chat.py frontends/sat_bridge_frontend/DBus.py frontends/sortilege/chat.py frontends/sortilege/sortilege frontends/wix/chat.py frontends/wix/main_window.py sat.tac sat_bridge/DBus.py |
diffstat | 8 files changed, 31 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/frontends/quick_frontend/quick_chat.py Wed Feb 03 23:35:57 2010 +1100 +++ b/frontends/quick_frontend/quick_chat.py Thu Feb 04 01:06:36 2010 +1100 @@ -30,18 +30,18 @@ self.to_jid = to_jid self.host = host - def historyPrint(self, size=20, keep_last=False): + def historyPrint(self, size=20, keep_last=False, profile='@NONE@'): """Print the initial history""" debug ("now we print history") - history=self.host.bridge.getHistory(self.host.whoami.short, self.to_jid, 20) + history=self.host.bridge.getHistory(self.host.profiles[profile]['whoami'].short, self.to_jid, 20) stamps=history.keys() stamps.sort() for stamp in stamps: - self.printMessage(JID(history[stamp][0]), history[stamp][1], stamp) + self.printMessage(JID(history[stamp][0]), history[stamp][1], profile, stamp) if keep_last: ##FIXME hack for sortilege self.last_history = stamps[-1] if stamps else None - def printMessage(self, from_jid, msg, timestamp): + def printMessage(self, from_jid, msg, profile, timestamp): """Print message in chat window. Must be implemented by child class""" raise NotImplementedError
--- a/frontends/sat_bridge_frontend/DBus.py Wed Feb 03 23:35:57 2010 +1100 +++ b/frontends/sat_bridge_frontend/DBus.py Thu Feb 04 01:06:36 2010 +1100 @@ -67,8 +67,8 @@ def getWaitingSub(self, profile_key='@DEFAULT@'): return self.db_comm_iface.getWaitingSub(profile_key) - def sendMessage(self, to, message, profile_key='@DEFAULT@'): - return self.db_comm_iface.sendMessage(to, message, profile_key) + def sendMessage(self, to, message, type='chat', profile_key='@DEFAULT@'): + return self.db_comm_iface.sendMessage(to, message, type, profile_key) def setPresence(self, to="", show="", priority=0, statuses={}, profile_key='@DEFAULT@'): return self.db_comm_iface.setPresence(to, show, priority, statuses, profile_key)
--- a/frontends/sortilege/chat.py Wed Feb 03 23:35:57 2010 +1100 +++ b/frontends/sortilege/chat.py Thu Feb 04 01:06:36 2010 +1100 @@ -48,7 +48,7 @@ Window.__init__(self, self.__parent, self.__parent.getmaxyx()[0]-2, self.__parent.getmaxyx()[1]-30, 0,30, code=host.code) #history - self.historyPrint(50, True) + self.historyPrint(50, True, profile=self.host.profile) self.hide() @@ -68,7 +68,7 @@ if self.host.chatParams["timestamp"]: header = header + '[%s] ' % strftime("%H:%M", localtime(float(line[0]))) if self.host.chatParams['short_nick']: - header = header + ('> ' if line[1]==self.host.whoami.short else '** ') + header = header + ('> ' if line[1]==self.host.profiles[self.host.profile]['whoami'] else '** ') else: header = header + '<%s> ' % line[1] return header @@ -85,7 +85,7 @@ header=self.__getHeader(self.content[idx]) msg=self.content[idx][2] part=0 #part of the text - if JID(self.content[idx][1]).short==self.host.whoami.short: + if JID(self.content[idx][1]).short==self.host.profiles[self.host.profile]['whoami'].short: att_header=curses.color_pair(1) else: att_header=curses.color_pair(2) @@ -137,7 +137,7 @@ self.__scollIdx = self.__scollIdx - 1 self.update() - def printMessage(self, jid, msg, timestamp=""): + def printMessage(self, jid, msg, profile, timestamp=""): if timestamp=="": current_time=time() timestamp=str(current_time)
--- a/frontends/sortilege/sortilege Wed Feb 03 23:35:57 2010 +1100 +++ b/frontends/sortilege/sortilege Thu Feb 04 01:06:36 2010 +1100 @@ -222,6 +222,7 @@ self.chat_wins=ChatList(self) QuickApp.__init__(self) #XXX: yes it's an unusual place for the constructor of a parent class, but the init order is important + self.plug_profile() signal (SIGWINCH, self.onResize) #we manage SIGWINCH ourselves, because the loop is not called otherwise @@ -271,8 +272,8 @@ def onTextEntered(self, text): - jid=JID(self.whoami) - self.bridge.sendMessage(self.currentChat, text) + jid=JID(self.profiles[self.profile]['whoami']) + self.bridge.sendMessage(self.currentChat, text, profile_key=self.profile) def showDialog(self, message, title, type="info"): if type==question: @@ -280,8 +281,8 @@ pass - def presenceUpdate(self, jabber_id, show, priority, statuses): - QuickApp.presenceUpdate(self, jabber_id, show, priority, statuses) + def presenceUpdate(self, jabber_id, show, priority, statuses, profile): + QuickApp.presenceUpdate(self, jabber_id, show, priority, statuses, profile) self.editBar.replace_cur() curses.doupdate() @@ -293,8 +294,8 @@ #FIXME info ("FIXME: actionResult not implemented") - def newMessage(self, from_jid, msg, type, to_jid): - QuickApp.newMessage(self, from_jid, msg, type, to_jid) + def newMessage(self, from_jid, msg, type, to_jid, profile): + QuickApp.newMessage(self, from_jid, msg, type, to_jid, profile) sender=JID(from_jid) addr=JID(to_jid) win = addr if sender.short == self.whoami.short else sender #FIXME: duplicate code with QuickApp
--- a/frontends/wix/chat.py Wed Feb 03 23:35:57 2010 +1100 +++ b/frontends/wix/chat.py Thu Feb 04 01:06:36 2010 +1100 @@ -56,7 +56,7 @@ self.font["points"] = self.chatWindow.GetFont().GetPointSize() self.font["family"] = self.chatWindow.GetFont().GetFamily() - self.historyPrint() + self.historyPrint(profile=self.host.profile) #misc self.textBox.SetFocus() @@ -87,7 +87,7 @@ def onEnterPressed(self, event): """Behaviour when enter pressed in send line.""" - self.host.bridge.sendMessage(self.to_jid, event.GetString()) + self.host.bridge.sendMessage(self.to_jid, event.GetString(), profile_key=self.host.profile) self.textBox.Clear()
--- a/frontends/wix/main_window.py Wed Feb 03 23:35:57 2010 +1100 +++ b/frontends/wix/main_window.py Thu Feb 04 01:06:36 2010 +1100 @@ -290,8 +290,8 @@ wx.EVT_MENU(self, idFIND_GATEWAYS, self.onFindGateways) - def newMessage(self, from_jid, msg, type, to_jid): - QuickApp.newMessage(self, from_jid, msg, type, to_jid) + def newMessage(self, from_jid, msg, type, to_jid, profile): + QuickApp.newMessage(self, from_jid, msg, type, to_jid, profile) def showAlert(self, message): # TODO: place this in a separate class
--- a/sat.tac Wed Feb 03 23:35:57 2010 +1100 +++ b/sat.tac Thu Feb 04 01:06:36 2010 +1100 @@ -125,7 +125,8 @@ debug (u"got_message from: %s", message["from"]) for e in message.elements(): if e.name == "body": - self.host.bridge.newMessage(message["from"], e.children[0], self.parent.profile) + type = message['type'] if message.hasAttribute('type') else 'chat' #FIXME: check specs + self.host.bridge.newMessage(message["from"], e.children[0], type, profile=self.parent.profile) self.host.memory.addToHistory(self.parent.jid, jid.JID(message["from"]), self.parent.jid, "chat", e.children[0]) break @@ -573,6 +574,7 @@ ## jabber methods ## def sendMessage(self,to,msg,type='chat', profile_key='@DEFAULT@'): + print "sendtype=", type #gof #FIXME: check validity of recipient profile = self.memory.getProfileName(profile_key) assert(profile) @@ -585,7 +587,7 @@ message.addElement("body", "jabber:client", msg) self.profiles[profile].xmlstream.send(message) self.memory.addToHistory(current_jid, current_jid, jid.JID(to), message["type"], unicode(msg)) - self.bridge.newMessage(message['from'], unicode(msg), to=message['to'], profile=profile) #We send back the message, so all clients are aware of it + 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 def setPresence(self, to="", show="", priority = 0, statuses={}, profile_key='@DEFAULT@'):
--- a/sat_bridge/DBus.py Wed Feb 03 23:35:57 2010 +1100 +++ b/sat_bridge/DBus.py Thu Feb 04 01:06:36 2010 +1100 @@ -60,7 +60,7 @@ @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, signature='sssss') - def newMessage(self, from_jid, msg, type='chat', to='', profile='@NONE@'): + def newMessage(self, from_jid, msg, type, to, profile): debug("new message signal (from:%s msg:%s type:%s to:%s) sended", from_jid, msg, type, to) @dbus.service.signal(const_INT_PREFIX+const_COMM_SUFFIX, @@ -165,10 +165,11 @@ return self.cb["getWaitingSub"](profile_key) @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, - in_signature='sss', out_signature='') - def sendMessage(self, to, message, profile_key='@DEFAULT@'): + in_signature='ssss', out_signature='') + def sendMessage(self, to, message, type='chat', profile_key='@DEFAULT@'): debug("sendMessage...") - self.cb["sendMessage"](to, message, profile_key) + print "sendtype=", type #gof + self.cb["sendMessage"](to, message, type, profile_key) @dbus.service.method(const_INT_PREFIX+const_COMM_SUFFIX, in_signature='ssia{ss}s', out_signature='') @@ -293,7 +294,7 @@ def newContact(self, contact, attributes, groups, profile): self.dbus_bridge.newContact(contact, attributes, groups, profile) - def newMessage(self,from_jid, msg, type, to, profile): + def newMessage(self, from_jid, msg, type='chat', to='', profile='@NONE@'): debug("sending message...") self.dbus_bridge.newMessage(from_jid, msg, type, to, profile)