# HG changeset patch # User Goffi # Date 1359157017 -3600 # Node ID 8475a29d7214af2c89f61e619d73e13ecbf66b7c # Parent 7a349be99a7729c06e1165790dd74f37d2627448 closing a group chat widget now leave the muc room (bug 11) diff -r 7a349be99a77 -r 8475a29d7214 browser_side/panels.py --- a/browser_side/panels.py Fri Jan 25 00:49:34 2013 +0100 +++ b/browser_side/panels.py Sat Jan 26 00:36:57 2013 +0100 @@ -114,6 +114,7 @@ return False if isinstance(self, LiberviaWidget): self.host.unregisterWidget(self) + self.onQuit() if not isinstance(_new_panel, LiberviaWidget): print ('WARNING: droping an object which is not a class of LiberviaWidget') _flextable = self.getParent() @@ -183,8 +184,14 @@ self.host.select(self) def onClose(self, sender): + """ Called when the close button is pushed """ _widgetspanel = self._getWidgetsPanel() _widgetspanel.removeWidget(self) + self.onQuit() + + def onQuit(self): + """ Called when the widget is actually ending """ + pass def onSetting(self, sender): widpanel = self._getWidgetsPanel() @@ -683,7 +690,7 @@ class ChatPanel(LiberviaWidget): - def __init__(self, host, target, type='one2one'): + def __init__(self, host, target, type_='one2one'): """Panel used for conversation (one 2 one or group chat) @param host: SatWebFrontend instance @param target: entity (JID) with who we have a conversation (contact's jid for one 2 one chat, or MUC room) @@ -691,7 +698,7 @@ LiberviaWidget.__init__(self, host, target.bare, selectable = True) self.vpanel = VerticalPanel() self.vpanel.setSize('100%','100%') - self.type = type + self.type = type_ self.nick = None if not target: print "ERROR: Empty target !" @@ -701,7 +708,7 @@ self.__body.setStyleName('chatPanel_body') chat_area = HorizontalPanel() chat_area.setStyleName('chatArea') - if type == 'group': + if type_ == 'group': self.occupants_list = OccupantsList() chat_area.add(self.occupants_list) self.__body.add(chat_area) @@ -724,6 +731,12 @@ #the event will not propagate to children ScrollPanelWrapper.doAttachChildren(self)""" + def onQuit(self): + LiberviaWidget.onQuit(self) + if self.type == 'group': + self.host.bridge.call('mucLeave', None, self.target.bare) + + def setUserNick(self, nick): """Set the nick of the user, usefull for e.g. change the color of the user""" self.nick = nick diff -r 7a349be99a77 -r 8475a29d7214 libervia.py --- a/libervia.py Fri Jan 25 00:49:34 2013 +0100 +++ b/libervia.py Sat Jan 26 00:36:57 2013 +0100 @@ -83,7 +83,7 @@ def __init__(self): LiberviaJsonProxy.__init__(self, "/json_api", ["getContacts", "addContact", "sendMessage", "sendMblog", "getLastMblogs", "getMassiveLastMblogs", "getProfileJid", "getHistory", "getPresenceStatus", - "joinMUC", "getRoomsJoined", "launchTarotGame", "getTarotCardsPaths", "tarotGameReady", "tarotGameContratChoosed", + "joinMUC", "mucLeave", "getRoomsJoined", "launchTarotGame", "getTarotCardsPaths", "tarotGameReady", "tarotGameContratChoosed", "tarotGamePlayCards", "launchRadioCollective", "getWaitingSub", "subscription", "delContact", "updateContact", "getEntityData", "getParamsUI", #"setParam", "launchAction", "disconnect", @@ -389,7 +389,7 @@ def _roomJoinedCb(self, room_jid, room_nicks, user_nick): _target = JID(room_jid) self.room_list.add(_target) - chat_panel = panels.ChatPanel(self, _target, type='group') + chat_panel = panels.ChatPanel(self, _target, type_='group') chat_panel.setUserNick(user_nick) if _target.node.startswith('sat_tarot_'): #XXX: it's not really beautiful, but it works :) self.addTab(chat_panel, "Tarot") diff -r 7a349be99a77 -r 8475a29d7214 libervia.tac --- a/libervia.tac Fri Jan 25 00:49:34 2013 +0100 +++ b/libervia.tac Sat Jan 26 00:36:57 2013 +0100 @@ -269,6 +269,16 @@ return self.sat_host.bridge.joinMUC(room_jid.userhost(), nick, {}, profile) + def jsonrpc_mucLeave(self, room_jid): + """Quit a Multi-User Chat room""" + profile = ISATSession(self.session).profile + try: + room_jid = JID(room_jid) + except: + warning('Invalid room jid') + return + self.sat_host.bridge.mucLeave(room_jid.userhost(), profile) + def jsonrpc_getRoomsJoined(self): """Return list of room already joined by user""" profile = ISATSession(self.session).profile