plugin XEP-0045, quick_frontend + primitivus (chat): cleaning of XEP-0045 (first pass):
- bridge methods/signals now all start with "muc" to follow new convention
- internal method use client instead of profile to follow new convention
- removed excetpions from plugin XEP-0045 in favor of core.exceptions, NotReady added
- cleaned/simplified several part of the code. checkClient removed as it is not needed anymore
- self.clients map removed, muc data are now stored directly in client
- getRoomEntityNick and getRoomNicksOfUsers are removed as they don't look sane.
/!\ This break all room game plugins for the moment
- use of uuid4 instead of uuid1 for getUniqueName, as host ID and current time are used for uuid1
This commit is contained in:
parent
a28bb7be8f
commit
04515e5013
1 changed files with 296 additions and 309 deletions
|
|
@ -635,25 +635,25 @@ class Memory(object):
|
|||
return available
|
||||
|
||||
def _getMainResource(self, jid_s, profile_key):
|
||||
client = self.host.getClient(profile_key)
|
||||
jid_ = jid.JID(jid_s)
|
||||
return self.getMainResource(jid_, profile_key) or ""
|
||||
return self.getMainResource(client, jid_) or ""
|
||||
|
||||
def getMainResource(self, entity_jid, profile_key):
|
||||
def getMainResource(self, client, entity_jid):
|
||||
"""Return the main resource used by an entity
|
||||
|
||||
@param entity_jid: bare entity jid
|
||||
@param profile_key: %(doc_profile_key)s
|
||||
@return (unicode): main resource or None
|
||||
"""
|
||||
if entity_jid.resource:
|
||||
raise ValueError("getMainResource must be used with a bare jid (got {})".format(entity_jid))
|
||||
try:
|
||||
if self.host.plugins["XEP-0045"].isRoom(entity_jid, profile_key):
|
||||
if self.host.plugins["XEP-0045"].isJoinedRoom(client, entity_jid):
|
||||
return None # MUC rooms have no main resource
|
||||
except KeyError: # plugin not found
|
||||
pass
|
||||
try:
|
||||
resources = self.getAllResources(entity_jid, profile_key)
|
||||
resources = self.getAllResources(entity_jid, client.profile)
|
||||
except exceptions.UnknownEntityError:
|
||||
log.warning(u"Entity is not in cache, we can't find any resource")
|
||||
return None
|
||||
|
|
@ -662,7 +662,7 @@ class Memory(object):
|
|||
full_jid = copy.copy(entity_jid)
|
||||
full_jid.resource = resource
|
||||
try:
|
||||
presence_data = self.getEntityDatum(full_jid, "presence", profile_key)
|
||||
presence_data = self.getEntityDatum(full_jid, "presence", client.profile)
|
||||
except KeyError:
|
||||
log.debug(u"No presence information for {}".format(full_jid))
|
||||
continue
|
||||
|
|
|
|||
Loading…
Reference in a new issue