Mercurial > libervia-backend
comparison src/memory/memory.py @ 1970:200cd707a46d
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
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 27 Jun 2016 21:45:11 +0200 |
parents | a2bc5089c2eb |
children | b536dd121da1 |
comparison
equal
deleted
inserted
replaced
1969:5fbe09b9b568 | 1970:200cd707a46d |
---|---|
633 if presence_data.show != C.PRESENCE_UNAVAILABLE: | 633 if presence_data.show != C.PRESENCE_UNAVAILABLE: |
634 available.append(resource) | 634 available.append(resource) |
635 return available | 635 return available |
636 | 636 |
637 def _getMainResource(self, jid_s, profile_key): | 637 def _getMainResource(self, jid_s, profile_key): |
638 client = self.host.getClient(profile_key) | |
638 jid_ = jid.JID(jid_s) | 639 jid_ = jid.JID(jid_s) |
639 return self.getMainResource(jid_, profile_key) or "" | 640 return self.getMainResource(client, jid_) or "" |
640 | 641 |
641 def getMainResource(self, entity_jid, profile_key): | 642 def getMainResource(self, client, entity_jid): |
642 """Return the main resource used by an entity | 643 """Return the main resource used by an entity |
643 | 644 |
644 @param entity_jid: bare entity jid | 645 @param entity_jid: bare entity jid |
645 @param profile_key: %(doc_profile_key)s | |
646 @return (unicode): main resource or None | 646 @return (unicode): main resource or None |
647 """ | 647 """ |
648 if entity_jid.resource: | 648 if entity_jid.resource: |
649 raise ValueError("getMainResource must be used with a bare jid (got {})".format(entity_jid)) | 649 raise ValueError("getMainResource must be used with a bare jid (got {})".format(entity_jid)) |
650 try: | 650 try: |
651 if self.host.plugins["XEP-0045"].isRoom(entity_jid, profile_key): | 651 if self.host.plugins["XEP-0045"].isJoinedRoom(client, entity_jid): |
652 return None # MUC rooms have no main resource | 652 return None # MUC rooms have no main resource |
653 except KeyError: # plugin not found | 653 except KeyError: # plugin not found |
654 pass | 654 pass |
655 try: | 655 try: |
656 resources = self.getAllResources(entity_jid, profile_key) | 656 resources = self.getAllResources(entity_jid, client.profile) |
657 except exceptions.UnknownEntityError: | 657 except exceptions.UnknownEntityError: |
658 log.warning(u"Entity is not in cache, we can't find any resource") | 658 log.warning(u"Entity is not in cache, we can't find any resource") |
659 return None | 659 return None |
660 priority_resources = [] | 660 priority_resources = [] |
661 for resource in resources: | 661 for resource in resources: |
662 full_jid = copy.copy(entity_jid) | 662 full_jid = copy.copy(entity_jid) |
663 full_jid.resource = resource | 663 full_jid.resource = resource |
664 try: | 664 try: |
665 presence_data = self.getEntityDatum(full_jid, "presence", profile_key) | 665 presence_data = self.getEntityDatum(full_jid, "presence", client.profile) |
666 except KeyError: | 666 except KeyError: |
667 log.debug(u"No presence information for {}".format(full_jid)) | 667 log.debug(u"No presence information for {}".format(full_jid)) |
668 continue | 668 continue |
669 priority_resources.append((resource, presence_data.priority)) | 669 priority_resources.append((resource, presence_data.priority)) |
670 try: | 670 try: |