# HG changeset patch # User Goffi # Date 1424711065 -3600 # Node ID 15e177584d82609804e6276088477708914c9473 # Parent 7c2289090b9bf2c8b2deaedfce50182854083b1a quick frontends(contact list): added a getFullJid method to add resource to a bare jid diff -r 7c2289090b9b -r 15e177584d82 frontends/src/quick_frontend/quick_contact_list.py --- a/frontends/src/quick_frontend/quick_contact_list.py Mon Feb 23 18:04:16 2015 +0100 +++ b/frontends/src/quick_frontend/quick_contact_list.py Mon Feb 23 18:04:25 2015 +0100 @@ -22,6 +22,7 @@ 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 @@ - 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 @@ """ 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