Mercurial > libervia-backend
changeset 76:8becde8a967c
MUC: added subject management
- plugin xep-0045: added roomNewSubject signal
- wix: added subject bar for group windows
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 30 Mar 2010 13:15:05 +1100 |
parents | 7322a41f8a8e |
children | 1ae680f9682e |
files | frontends/quick_frontend/quick_app.py frontends/wix/chat.py plugins/plugin_xep_0045.py |
diffstat | 3 files changed, 33 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/frontends/quick_frontend/quick_app.py Mon Mar 29 16:54:53 2010 +1100 +++ b/frontends/quick_frontend/quick_app.py Tue Mar 30 13:15:05 2010 +1100 @@ -45,6 +45,7 @@ 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 @@ 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 @@ 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"""
--- a/frontends/wix/chat.py Mon Mar 29 16:54:53 2010 +1100 +++ b/frontends/wix/chat.py Tue Mar 30 13:15:05 2010 +1100 @@ -43,15 +43,17 @@ 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 @@ 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 @@ 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"))
--- a/plugins/plugin_xep_0045.py Mon Mar 29 16:54:53 2010 +1100 +++ b/plugins/plugin_xep_0045.py Tue Mar 30 13:15:05 2010 +1100 @@ -72,6 +72,7 @@ host.bridge.addSignal("roomJoined", ".communication", signature='ssasss') #args: room_id, room_service, room_nicks, user_nick, profile host.bridge.addSignal("roomUserJoined", ".communication", signature='sssa{ss}s') #args: room_id, room_service, user_nick, user_data, profile host.bridge.addSignal("roomUserLeft", ".communication", signature='sssa{ss}s') #args: room_id, room_service, user_nick, user_data, profile + host.bridge.addSignal("roomNewSubject", ".communication", signature='ssss') #args: room_id, room_service, subject, profile def __check_profile(self, profile): """check if profile is used and connected @@ -95,7 +96,7 @@ def __err_joining_room(self, failure, profile): """Called when something is going wrong when joining the room""" error ("Error when joining the room") - pdb.set_trace() + #TODO: gof: send an error message throught the bridge def join(self, service, roomId, nick, profile_key='@DEFAULT@'): profile = self.host.memory.getProfileName(profile_key) @@ -138,6 +139,10 @@ user_data={'entity':user.entity or '', 'affiliation':user.affiliation, 'role':user.role} self.host.bridge.roomUserLeft(room.roomIdentifier, room.service, user.nick, user_data, self.parent.profile) + def receivedSubject(self, room, subject): + debug (_("New subject for room (%(room_id)s): %(subject)s") % {'room_id':room.occupantJID.userhost(),'subject':subject}) + self.host.bridge.roomNewSubject(room.roomIdentifier, room.service, subject, self.parent.profile) + #def connectionInitialized(self): #pass