diff frontends/wix/chat.py @ 77:1ae680f9682e

wix: MUC groupchat management + short nick shown in chat window instead of full jid when possible
author Goffi <goffi@goffi.org>
date Tue, 30 Mar 2010 16:08:44 +1100
parents 8becde8a967c
children ace2af8abc5a
line wrap: on
line diff
--- a/frontends/wix/chat.py	Tue Mar 30 13:15:05 2010 +1100
+++ b/frontends/wix/chat.py	Tue Mar 30 16:08:44 2010 +1100
@@ -153,7 +153,10 @@
 
     def onEnterPressed(self, event):
         """Behaviour when enter pressed in send line."""
-        self.host.bridge.sendMessage(self.target, event.GetString(), profile_key=self.host.profile)
+        self.host.bridge.sendMessage(self.target.short if self.type=='group' else self.target,
+                                     event.GetString(), 
+                                     type = "groupchat" if self.type=='group' else "chat",
+                                     profile_key=self.host.profile)
         self.textBox.Clear()
 
         
@@ -161,10 +164,11 @@
     def printMessage(self, from_jid, msg, profile, timestamp=""):
         """Print the message with differents colors depending on where it comes from."""
         jid=JID(from_jid)
+        nick = jid.resource if self.type == "group" else (self.host.CM.getAttr(jid,'nick') or self.host.CM.getAttr(jid,'name') or jid)
         mymess = (jid.short == self.host.profiles[profile]['whoami'].short) #mymess = True if message comes from local user
         _font = wx.Font(self.font["points"], self.font["family"], wx.NORMAL, wx.BOLD)
         self.chatWindow.SetDefaultStyle(wx.TextAttr( "BLACK" if mymess else "BLUE", font=_font))
-        self.chatWindow.AppendText("[%s] " % jid)
+        self.chatWindow.AppendText("[%s] " % nick)
         _font = wx.Font(self.font["points"], self.font["family"], wx.ITALIC if mymess else wx.NORMAL, wx.NORMAL)
         self.chatWindow.SetDefaultStyle(wx.TextAttr("BLACK", font=_font))
         self.chatWindow.AppendText("%s\n" % msg)