comparison browser_side/contact.py @ 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 2d6bd975a72d
comparison
equal deleted inserted replaced
271:d868181d0649 272:0cb9869b42b6
256 ideal_height = tab_bar_h - DOM.getAbsoluteTop(contact_panel_elt) - 5 256 ideal_height = tab_bar_h - DOM.getAbsoluteTop(contact_panel_elt) - 5
257 self.scroll_panel.setHeight("%s%s" % (ideal_height, "px")); 257 self.scroll_panel.setHeight("%s%s" % (ideal_height, "px"));
258 258
259 def updateContact(self, jid, attributes, groups): 259 def updateContact(self, jid, attributes, groups):
260 """Add a contact to the panel if it doesn't exist, update it else 260 """Add a contact to the panel if it doesn't exist, update it else
261 @param jid: jid 261 @param jid: jid userhost as unicode
262 @attributes: cf SàT Bridge API's newContact 262 @attributes: cf SàT Bridge API's newContact
263 @param groups: list of groups""" 263 @param groups: list of groups"""
264 _current_groups = self.getContactGroups(jid) 264 _current_groups = self.getContactGroups(jid)
265 _new_groups = set(groups) 265 _new_groups = set(groups)
266 _key = "@%s: " 266 _key = "@%s: "
289 """Remove contacts from groups where he is and contact list""" 289 """Remove contacts from groups where he is and contact list"""
290 self.updateContact(jid, {}, []) # we remove contact from every group 290 self.updateContact(jid, {}, []) # we remove contact from every group
291 self._contact_list.remove(jid) 291 self._contact_list.remove(jid)
292 292
293 def setConnected(self, jid, resource, availability, priority, statuses): 293 def setConnected(self, jid, resource, availability, priority, statuses):
294 """Set connection status""" 294 """Set connection status
295 @param jid: JID userhost as unicode
296 """
295 if availability == 'unavailable': 297 if availability == 'unavailable':
296 if self.connected.has_key(jid): 298 if self.connected.has_key(jid):
297 if self.connected[jid].has_key(resource): 299 if self.connected[jid].has_key(resource):
298 del self.connected[jid][resource] 300 del self.connected[jid][resource]
299 if not self.connected[jid]: 301 if not self.connected[jid]:
312 """Show an visual indicator that contact has send a message 314 """Show an visual indicator that contact has send a message
313 @param jid: jid of the contact 315 @param jid: jid of the contact
314 @param waiting: True if message are waiting""" 316 @param waiting: True if message are waiting"""
315 self._contact_list.setState(jid, "messageWaiting", waiting) 317 self._contact_list.setState(jid, "messageWaiting", waiting)
316 318
317 def getConnected(self): 319 def getConnected(self, filter_muc=False):
318 """return a list of all jid (bare jid) connected""" 320 """return a list of all jid (bare jid) connected
321 @param filter_muc: if True, remove the groups from the list
322 """
319 contacts = self.connected.keys() 323 contacts = self.connected.keys()
320 contacts.sort() 324 contacts.sort()
321 return contacts 325 return contacts if not filter_muc else list(set(contacts).intersection(set(self.getContacts())))
322 326
323 def getContactGroups(self, contact_jid): 327 def getContactGroups(self, contact_jid):
324 """Get groups where contact is 328 """Get groups where contact is
325 @param group: string of single group, or list of string 329 @param group: string of single group, or list of string
326 @param contact_jid: jid to test 330 @param contact_jid: jid to test