changeset 272:0cb9869b42b6

browser_side: bug fix for RoomAndContactsChooser (do not display the MUCs in the list)
author souliane <souliane@mailoo.org>
date Thu, 21 Nov 2013 13:44:26 +0100
parents d868181d0649
children 11718798ab8a
files browser_side/contact.py browser_side/dialog.py browser_side/menu.py
diffstat 3 files changed, 13 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/browser_side/contact.py	Tue Nov 19 21:21:49 2013 +0100
+++ b/browser_side/contact.py	Thu Nov 21 13:44:26 2013 +0100
@@ -258,7 +258,7 @@
 
     def updateContact(self, jid, attributes, groups):
         """Add a contact to the panel if it doesn't exist, update it else
-        @param jid: jid
+        @param jid: jid userhost as unicode
         @attributes: cf SàT Bridge API's newContact
         @param groups: list of groups"""
         _current_groups = self.getContactGroups(jid)
@@ -291,7 +291,9 @@
         self._contact_list.remove(jid)
 
     def setConnected(self, jid, resource, availability, priority, statuses):
-        """Set connection status"""
+        """Set connection status
+        @param jid: JID userhost as unicode
+        """
         if availability == 'unavailable':
             if self.connected.has_key(jid):
                 if self.connected[jid].has_key(resource):
@@ -314,11 +316,13 @@
         @param waiting: True if message are waiting"""
         self._contact_list.setState(jid, "messageWaiting", waiting)
 
-    def getConnected(self):
-        """return a list of all jid (bare jid) connected"""
+    def getConnected(self, filter_muc=False):
+        """return a list of all jid (bare jid) connected
+        @param filter_muc: if True, remove the groups from the list
+        """
         contacts = self.connected.keys()
         contacts.sort()
-        return contacts
+        return contacts if not filter_muc else list(set(contacts).intersection(set(self.getContacts())))
 
     def getContactGroups(self, contact_jid):
         """Get groups where contact is
--- a/browser_side/dialog.py	Tue Nov 19 21:21:49 2013 +0100
+++ b/browser_side/dialog.py	Thu Nov 21 13:44:26 2013 +0100
@@ -140,7 +140,7 @@
         @param select: list of the contacts to select by default
         """
         self.contacts_list.clear()
-        contacts = self.host.contact_panel.getConnected()
+        contacts = self.host.contact_panel.getConnected(filter_muc=True)
         self.contacts_list.setVisibleItemCount(10 if len(contacts) > 5 else 5)
         self.contacts_list.addItem("")
         for contact in contacts:
@@ -218,6 +218,7 @@
         room_jid = self.getRoom()
         if room_jid != "" and "@" not in room_jid:
             Window.alert('You must enter a room jid in the form room@chat.%s' % self.host._defaultDomain)
+            return
         self.hide()
         self.callback(room_jid, self.getContacts())
 
--- a/browser_side/menu.py	Tue Nov 19 21:21:49 2013 +0100
+++ b/browser_side/menu.py	Thu Nov 21 13:44:26 2013 +0100
@@ -310,13 +310,13 @@
     def onCollectiveRadio(self):
         def callback(room_jid, contacts):
             self.host.bridge.call('launchRadioCollective', None, contacts, room_jid)
-        dialog.RoomAndContactsChooser(self.host, callback, ok_button="Choose", visible=(False, True))
+        dialog.RoomAndContactsChooser(self.host, callback, ok_button="Choose", title="Collective Radio", visible=(False, True))
 
     #Game menu
     def onTarotGame(self):
         def onPlayersSelected(room_jid, other_players):
             self.host.bridge.call('launchTarotGame', None, other_players, room_jid)
-        dialog.RoomAndContactsChooser(self.host, onPlayersSelected, 3, title_invite="Please select 3 other players", visible=(False, True))
+        dialog.RoomAndContactsChooser(self.host, onPlayersSelected, 3, title="Tarot", title_invite="Please select 3 other players", visible=(False, True))
 
     def onXiangqiGame(self):
         Window.alert("A Xiangqi game is planed, but not available yet")