jp: jp asyncio port:

/!\ this commit is huge. Jp is temporarily not working with `dbus` bridge /!\

This patch implements the port of jp to asyncio, so it is now correctly using the bridge
asynchronously, and it can be used with bridges like `pb`. This also simplify the code,
notably for things which were previously implemented with many callbacks (like pagination
with RSM).

During the process, some behaviours have been modified/fixed, in jp and backends, check
diff for details.
This commit is contained in:
Goffi 2019-09-25 08:56:41 +02:00
commit 76aadbb3fb

View file

@ -595,10 +595,14 @@ class XEP_0329(object):
):
return
for file_data in files_data:
file_elt = self._jf.buildFileElementFromDict(
file_data, modified=file_data.get("modified", file_data["created"])
)
query_elt.addChild(file_elt)
if file_data['type'] == C.FILE_TYPE_DIRECTORY:
directory_elt = query_elt.addElement("directory")
directory_elt['name'] = file_data['name']
else:
file_elt = self._jf.buildFileElementFromDict(
file_data, modified=file_data.get("modified", file_data["created"])
)
query_elt.addChild(file_elt)
client.send(iq_result_elt)
def onComponentRequest(self, iq_elt, client):
@ -624,7 +628,7 @@ class XEP_0329(object):
file_data = {"name": elt["name"], "type": C.FILE_TYPE_DIRECTORY}
else:
log.warning(
_("unexpected element, ignoring: {elt}").format(elt=elt.toXml())
_(f"unexpected element, ignoring: {elt.toXml()}")
)
continue
files.append(file_data)
@ -642,7 +646,7 @@ class XEP_0329(object):
def _listFiles(self, target_jid, path, extra, profile):
client = self.host.getClient(profile)
target_jid = client.jid.userhostJID() if not target_jid else jid.JID(target_jid)
target_jid = client.jid if not target_jid else jid.JID(target_jid)
d = self.listFiles(client, target_jid, path or None)
d.addCallback(self._serializeData)
return d