MUC: added subject management
- plugin xep-0045: added roomNewSubject signal - wix: added subject bar for group windows
This commit is contained in:
parent
39807e5b36
commit
5486458797
3 changed files with 33 additions and 5 deletions
|
|
@ -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"""
|
||||
|
|
|
|||
|
|
@ -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"))
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ class XEP_0045():
|
|||
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 @@ class XEP_0045():
|
|||
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 @@ class SatMUCClient (muc.MUCClient):
|
|||
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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue