diff sat/plugins/plugin_xep_0166.py @ 3333:ac9342f359e9

plugin XEP-0329: download thumbnails: - thumbnails are now downloaded directly when BoB is used, `filename` is then filled - `utils.asDeferred` is now used for Jingle methods, so `async` coroutines can be used - (XEP-0231): fixed `dumpData`
author Goffi <goffi@goffi.org>
date Thu, 13 Aug 2020 23:46:18 +0200
parents 559a625a236b
children 26a0af6e32c1
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0166.py	Thu Aug 13 23:46:18 2020 +0200
+++ b/sat/plugins/plugin_xep_0166.py	Thu Aug 13 23:46:18 2020 +0200
@@ -1,7 +1,6 @@
 #!/usr/bin/env python3
 
-
-# SAT plugin for Jingle (XEP-0166)
+# SàT plugin for Jingle (XEP-0166)
 # Copyright (C) 2009-2020 Jérôme Poisson (goffi@goffi.org)
 
 # This program is free software: you can redistribute it and/or modify
@@ -17,25 +16,27 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+
+import uuid
+import time
+from collections import namedtuple
+from zope.interface import implementer
+from twisted.words.protocols.jabber import jid
+from twisted.internet import defer
+from twisted.internet import reactor
+from twisted.words.protocols.jabber import error
+from twisted.words.protocols.jabber import xmlstream
+from twisted.python import failure
+from wokkel import disco, iwokkel
+from sat.core import exceptions
 from sat.core.i18n import _, D_
 from sat.core.constants import Const as C
 from sat.core.log import getLogger
 from sat.tools import xml_tools
+from sat.tools import utils
+
 
 log = getLogger(__name__)
-from sat.core import exceptions
-from twisted.words.protocols.jabber import jid
-from twisted.internet import defer
-from twisted.internet import reactor
-from wokkel import disco, iwokkel
-from twisted.words.protocols.jabber import error
-from twisted.words.protocols.jabber import xmlstream
-from twisted.python import failure
-from collections import namedtuple
-import uuid
-import time
-
-from zope.interface import implementer
 
 
 IQ_SET = '/iq[@type="set"]'
@@ -757,7 +758,7 @@
                     elt = content_data.pop(elt_name) if delete else content_data[elt_name]
                 else:
                     elt = force_element
-                d = defer.maybeDeferred(
+                d = utils.asDeferred(
                     method, client, action, session, content_name, elt
                 )
                 defers_list.append(d)
@@ -846,7 +847,7 @@
             application = content_data["application"]
             app_session_accept_cb = application.handler.jingleHandler
 
-            app_d = defer.maybeDeferred(
+            app_d = utils.asDeferred(
                 app_session_accept_cb,
                 client,
                 XEP_0166.A_SESSION_INITIATE,
@@ -860,7 +861,7 @@
             transport = content_data["transport"]
             transport_session_accept_cb = transport.handler.jingleHandler
 
-            transport_d = defer.maybeDeferred(
+            transport_d = utils.asDeferred(
                 transport_session_accept_cb,
                 client,
                 XEP_0166.A_SESSION_INITIATE,