MUC: added subject management

- plugin xep-0045: added roomNewSubject signal
- wix: added subject bar for group windows
This commit is contained in:
Goffi 2010-03-30 13:15:05 +11:00
commit 5486458797
2 changed files with 33 additions and 5 deletions

View file

@ -45,6 +45,7 @@ class QuickApp():
self.bridge.register("roomJoined", self.roomJoined)
self.bridge.register("roomUserJoined", self.roomUserJoined)
self.bridge.register("roomUserLeft", self.roomUserLeft)
self.bridge.register("roomNewSubject", self.roomNewSubject)
self.bridge.register("subscribe", self.subscribe)
self.bridge.register("paramUpdate", self.paramUpdate)
self.bridge.register("contactDeleted", self.contactDeleted)
@ -215,7 +216,7 @@ class QuickApp():
room_jid=room_id+'@'+room_service
if self.chat_wins.has_key(room_jid):
self.chat_wins[room_jid].replaceUser(user_nick)
debug (_("user [%(user_nick)s] joined room [%(room_jid)s]") % {'user_nick':user_nick, 'room_jid':room_jid})
debug (_("user [%(user_nick)s] joined room [%(room_jid)s]") % {'user_nick':user_nick, 'room_jid':room_jid})
def roomUserLeft(self, room_id, room_service, user_nick, user_data, profile):
"""Called when an user joined a MUC room"""
@ -224,7 +225,17 @@ class QuickApp():
room_jid=room_id+'@'+room_service
if self.chat_wins.has_key(room_jid):
self.chat_wins[room_jid].removeUser(user_nick)
debug (_("user [%(user_nick)s] left room [%(room_jid)s]") % {'user_nick':user_nick, 'room_jid':room_jid})
debug (_("user [%(user_nick)s] left room [%(room_jid)s]") % {'user_nick':user_nick, 'room_jid':room_jid})
def roomNewSubject(self, room_id, room_service, subject, profile):
"""Called when subject of MUC room change"""
if not self.__check_profile(profile):
return
room_jid=room_id+'@'+room_service
if self.chat_wins.has_key(room_jid):
self.chat_wins[room_jid].setSubject(subject)
debug (_("new subject for room [%(room_jid)s]: %(subject)s") % {'room_jid':room_jid, "subject":subject})
def subscribe(self, type, raw_jid, profile):
"""Called when a subsciption maangement signal is received"""

View file

@ -43,15 +43,17 @@ class Chat(wx.Frame, QuickChat):
self.conv_panel = wx.Panel(self.splitter)
self.conv_panel.sizer = wx.BoxSizer(wx.VERTICAL)
self.subjectBox = wx.TextCtrl(self.conv_panel, -1, style = wx.TE_READONLY)
self.chatWindow = wx.TextCtrl(self.conv_panel, -1, style = wx.TE_MULTILINE | wx.TE_RICH | wx.TE_READONLY)
self.textBox = wx.TextCtrl(self.conv_panel, -1, style = wx.TE_PROCESS_ENTER)
self.conv_panel.sizer.Add(self.subjectBox, flag=wx.EXPAND)
self.conv_panel.sizer.Add(self.chatWindow, 1, flag=wx.EXPAND)
self.conv_panel.sizer.Add(self.textBox, flag=wx.EXPAND)
self.conv_panel.SetSizer(self.conv_panel.sizer)
self.splitter.Initialize(self.conv_panel)
self.setType(self.type)
self.createMenus()
self.__createMenus()
#events
self.Bind(wx.EVT_CLOSE, self.onClose, self)
@ -83,9 +85,12 @@ class Chat(wx.Frame, QuickChat):
QuickChat.setType(self, type)
if type is 'group' and not self.splitter.IsSplit():
self.__createPresents()
self.subjectBox.Show()
elif type is 'one2one' and self.splitter.IsSplit():
self.splitter.Unsplit(self.present_panel)
del self.present_panel
else:
self.subjectBox.Hide()
def setPresents(self, nicks):
"""Set the users presents in the contact list for a group chat
@ -115,9 +120,16 @@ class Chat(wx.Frame, QuickChat):
return
self.present_panel.presents.remove(nick)
def setSubject(self, subject):
"""Set title for a group chat"""
debug(_("Setting subject to %s") % subject)
if self.type != "group":
error (_("[INTERNAL] trying to set subject for a non group chat window"))
return
self.subjectBox.SetValue(subject)
def createMenus(self):
def __createMenus(self):
info("Creating menus")
actionMenu = wx.Menu()
actionMenu.Append(idSEND, _("&SendFile CTRL-s"),_(" Send a file to contact"))