diff src/plugins/plugin_sec_otr.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 ca82c97db195
line wrap: on
line diff
--- a/src/plugins/plugin_sec_otr.py	Fri Jun 24 22:41:28 2016 +0200
+++ b/src/plugins/plugin_sec_otr.py	Mon Jun 27 21:45:11 2016 +0200
@@ -276,10 +276,11 @@
         @param menu_data: %(menu_data)s
         @param profile: %(doc_profile)s
         """
+        client = self.host.getClient(profile)
         try:
             to_jid = jid.JID(menu_data['jid'])
             if not to_jid.resource:
-                to_jid.resource = self.host.memory.getMainResource(to_jid, profile) # FIXME: temporary and unsecure, must be changed when frontends are refactored
+                to_jid.resource = self.host.memory.getMainResource(client, to_jid) # FIXME: temporary and unsecure, must be changed when frontends are refactored
         except KeyError:
             log.error(_("jid key is not present !"))
             return defer.fail(exceptions.DataError)
@@ -294,10 +295,11 @@
         @param menu_data: %(menu_data)s
         @param profile: %(doc_profile)s
         """
+        client = self.host.getClient(profile)
         try:
             to_jid = jid.JID(menu_data['jid'])
             if not to_jid.resource:
-                to_jid.resource = self.host.memory.getMainResource(to_jid, profile) # FIXME: temporary and unsecure, must be changed when frontends are refactored
+                to_jid.resource = self.host.memory.getMainResource(client, to_jid) # FIXME: temporary and unsecure, must be changed when frontends are refactored
         except KeyError:
             log.error(_("jid key is not present !"))
             return defer.fail(exceptions.DataError)
@@ -311,10 +313,11 @@
         @param menu_data: %(menu_data)s
         @param profile: %(doc_profile)s
         """
+        client = self.host.getClient(profile)
         try:
             to_jid = jid.JID(menu_data['jid'])
             if not to_jid.resource:
-                to_jid.resource = self.host.memory.getMainResource(to_jid, profile) # FIXME: temporary and unsecure, must be changed when frontends are refactored
+                to_jid.resource = self.host.memory.getMainResource(client, to_jid) # FIXME: temporary and unsecure, must be changed when frontends are refactored
         except KeyError:
             log.error(_("jid key is not present !"))
             return defer.fail(exceptions.DataError)
@@ -381,10 +384,11 @@
         @param menu_data: %(menu_data)s
         @param profile: %(doc_profile)s
         """
+        client = self.host.getClient(profile)
         try:
             to_jid = jid.JID(menu_data['jid'])
             if not to_jid.resource:
-                to_jid.resource = self.host.memory.getMainResource(to_jid, profile) # FIXME: temporary and unsecure, must be changed when frontends are refactored
+                to_jid.resource = self.host.memory.getMainResource(client, to_jid) # FIXME: temporary and unsecure, must be changed when frontends are refactored
         except KeyError:
             log.error(_("jid key is not present !"))
             return defer.fail(exceptions.DataError)
@@ -467,7 +471,7 @@
             return True
         to_jid = copy.copy(mess_data['to'])
         if mess_data['type'] != 'groupchat' and not to_jid.resource:
-            to_jid.resource = self.host.memory.getMainResource(to_jid, profile) # FIXME: it's dirty, but frontends don't manage resources correctly now, refactoring is planed
+            to_jid.resource = self.host.memory.getMainResource(client, to_jid) # FIXME: it's dirty, but frontends don't manage resources correctly now, refactoring is planed
         otrctx = self.context_managers[profile].getContextForUser(to_jid)
         if mess_data['type'] != 'groupchat' and otrctx.state != potr.context.STATE_PLAINTEXT:
             if otrctx.state == potr.context.STATE_ENCRYPTED:
@@ -496,11 +500,12 @@
             return True
 
     def _presenceReceivedTrigger(self, entity, show, priority, statuses, profile):
+        client = self.host.getClient(profile)
         if show != C.PRESENCE_UNAVAILABLE:
             return True
         if not entity.resource:
             try:
-                entity.resource = self.host.memory.getMainResource(entity, profile)  # FIXME: temporary and unsecure, must be changed when frontends are refactored
+                entity.resource = self.host.memory.getMainResource(client, entity)  # FIXME: temporary and unsecure, must be changed when frontends are refactored
             except exceptions.UnknownEntityError:
                 return True  #  entity was not connected
         if entity in self.context_managers[profile].contexts: