core: added IQ_SET to core.constants + getLastResource now manage correctly jid.JID

This commit is contained in:
Goffi 2014-03-22 13:42:59 +01:00
commit c67faecba1
3 changed files with 12 additions and 6 deletions

View file

@ -25,3 +25,4 @@ class Const(object):
SAVEFILE_DATABASE = "/sat.db"
PROF_KEY_NONE = '@NONE@'
PROF_KEY_DEFAULT = '@DEFAULT@'
IQ_SET = '/iq[@type="set"]'

View file

@ -143,7 +143,7 @@ class SAT(service.Service):
self.bridge.register("disconnect", self.disconnect)
self.bridge.register("getContacts", self.getContacts)
self.bridge.register("getContactsFromGroup", self.getContactsFromGroup)
self.bridge.register("getLastResource", self.memory.getLastResource)
self.bridge.register("getLastResource", self.memory._getLastResource)
self.bridge.register("getPresenceStatus", self.memory.getPresenceStatus)
self.bridge.register("getWaitingSub", self.memory.getWaitingSub)
self.bridge.register("getWaitingConf", self.getWaitingConf)

View file

@ -338,15 +338,20 @@ class Memory(object):
warning(_("Features of %s not available, maybe they haven't been asked yet?") % jid_)
return None
def getLastResource(self, contact, profile_key):
"""Return the last resource used by a contact
@param contact: contact jid (unicode)
def _getLastResource(self, jid_s, profile_key):
jid_ = jid.JID(jid_s)
return self.getLastResource(jid_, profile_key)
def getLastResource(self, jid_, profile_key):
"""Return the last resource used by a jid_
@param jid_: bare jid
@param profile_key: %(doc_profile_key)s"""
profile = self.getProfileName(profile_key)
if not profile or not self.host.isConnected(profile):
error(_('Asking contacts for a non-existant or not connected profile'))
error(_('Asking jid_s for a non-existant or not connected profile'))
return ""
entity = jid.JID(contact).userhost()
entity = jid_.userhost()
if not entity in self.entitiesCache[profile]:
info(_("Entity not in cache"))
return ""