# HG changeset patch # User souliane # Date 1401371486 -7200 # Node ID 05e98b8d9f02ea6303540a50f5f4e00e4a312696 # Parent 3ef6ce200c2769ceea6e3982708231c56f83df7f browser side: display messages from contacts not in roster diff -r 3ef6ce200c27 -r 05e98b8d9f02 src/browser/contact.py --- a/src/browser/contact.py Mon May 26 14:25:56 2014 +0200 +++ b/src/browser/contact.py Thu May 29 15:51:26 2014 +0200 @@ -198,10 +198,15 @@ else: sender.onClick(sender) - def add(self, jid, name=None): + def add(self, jid_s, name=None): + """Add a contact + + @param jid_s (str): JID as unicode + @param name (str): nickname + """ def item_cb(item): self.context_menu.registerRightClickSender(item) - GenericContactList.add(self, jid, name, item_cb) + GenericContactList.add(self, jid_s, name, item_cb) def setState(self, jid, type_, state): """Change the appearance of the contact, according to the state @@ -275,18 +280,18 @@ ideal_height = tab_bar_h - DOM.getAbsoluteTop(contact_panel_elt) - 5 self.scroll_panel.setHeight("%s%s" % (ideal_height, "px")) - def updateContact(self, jid, attributes, groups): + def updateContact(self, jid_s, attributes, groups): """Add a contact to the panel if it doesn't exist, update it else - @param jid: jid userhost as unicode - @attributes: cf SàT Bridge API's newContact + @param jid_s: jid userhost as unicode + @param attributes: cf SàT Bridge API's newContact @param groups: list of groups""" - _current_groups = self.getContactGroups(jid) + _current_groups = self.getContactGroups(jid_s) _new_groups = set(groups) _key = "@%s: " for group in _current_groups.difference(_new_groups): # We remove the contact from the groups where he isn't anymore - self.groups[group].remove(jid) + self.groups[group].remove(jid_s) if not self.groups[group]: # The group is now empty, we must remove it del self.groups[group] @@ -301,10 +306,10 @@ self._groupList.add(group) if self.host.uni_box: self.host.uni_box.addKey(_key % group) - self.groups[group].add(jid) + self.groups[group].add(jid_s) # We add the contact to contact list, it will check if contact already exists - self._contact_list.add(jid) + self._contact_list.add(jid_s) def removeContact(self, jid): """Remove contacts from groups where he is and contact list""" @@ -359,14 +364,14 @@ contacts.sort() return contacts if not filter_muc else list(set(contacts).intersection(set(self.getContacts()))) - def getContactGroups(self, contact_jid): + def getContactGroups(self, contact_jid_s): """Get groups where contact is @param group: string of single group, or list of string - @param contact_jid: jid to test + @param contact_jid_s: jid to test, as unicode """ result = set() for group in self.groups: - if self.isContactInGroup(group, contact_jid): + if self.isContactInGroup(group, contact_jid_s): result.add(group) return result diff -r 3ef6ce200c27 -r 05e98b8d9f02 src/browser/libervia_main.py --- a/src/browser/libervia_main.py Mon May 26 14:25:56 2014 +0200 +++ b/src/browser/libervia_main.py Thu May 29 15:51:26 2014 +0200 @@ -680,6 +680,8 @@ if lib_wid is not None: lib_wid.printMessage(_from, msg, extra) else: + if not self.contact_panel.isContactInRoster(other.bare): + self.contact_panel.updateContact(other.bare, {}, [C.GROUP_NOT_IN_ROSTER]) # The message has not been shown, we must indicate it self.contact_panel.setContactMessageWaiting(other.bare, True)