diff --git a/frontends/src/quick_frontend/quick_contact_list.py b/frontends/src/quick_frontend/quick_contact_list.py index 72fa12fa..2b487520 100644 --- a/frontends/src/quick_frontend/quick_contact_list.py +++ b/frontends/src/quick_frontend/quick_contact_list.py @@ -22,6 +22,7 @@ from sat.core.log import getLogger log = getLogger(__name__) from sat_frontends.quick_frontend.quick_widgets import QuickWidget from sat_frontends.quick_frontend.constants import Const as C +from sat_frontends.tools import jid try: @@ -133,6 +134,7 @@ class QuickContactList(QuickWidget): - if no resource is given (bare jid), the main resource is used, according to priority - if resource is given, it is used @param name(unicode): name the data to get, or None to get everything + @return: full cache if no name is given, or value of "name", or None """ try: cache = self._cache[entity.bare] @@ -167,6 +169,19 @@ class QuickContactList(QuickWidget): """ self.setContact(entity, None, {name: value}) + def getFullJid(self, entity): + """Get full jid from a bare jid + + @param entity(jid.JID): must be a bare jid + @return (jid.JID): bare jid + main resource + @raise ValueError: the entity is not bare + """ + if entity.resource: + raise ValueError("getFullJid must be used with a bare jid") + main_resource = self.getCache(entity, C.CONTACT_MAIN_RESOURCE) + return jid.JID(u"{}/{}".format(entity, main_resource)) + + def setGroupData(self, group, name, value): """Register a data for a group