merge bookmark @
This commit is contained in:
commit
50d7cb2a51
4 changed files with 277 additions and 150 deletions
|
|
@ -309,9 +309,11 @@ class AndroidPlugin(object):
|
|||
# "XXX has no attribute 'invoke'" error (looks like the same issue as
|
||||
# https://github.com/kivy/pyjnius/issues/59)
|
||||
self.br = BroadcastReceiver(
|
||||
callback=lambda *args, **kwargs: reactor.callLater(0,
|
||||
self.onConnectivityChange),
|
||||
actions=["android.net.conn.CONNECTIVITY_CHANGE"])
|
||||
callback=lambda *args, **kwargs: reactor.callFromThread(
|
||||
self.onConnectivityChange
|
||||
),
|
||||
actions=["android.net.conn.CONNECTIVITY_CHANGE"]
|
||||
)
|
||||
self.br.start()
|
||||
|
||||
@property
|
||||
|
|
|
|||
|
|
@ -237,8 +237,8 @@ class FilePlugin:
|
|||
data_cb=file_data.get("data_cb"),
|
||||
)
|
||||
|
||||
def _gotConfirmation(
|
||||
self, data, client, peer_jid, transfer_data, file_data, stream_object
|
||||
async def _gotConfirmation(
|
||||
self, client, data, peer_jid, transfer_data, file_data, stream_object
|
||||
):
|
||||
"""Called when the permission and dest path have been received
|
||||
|
||||
|
|
@ -258,19 +258,7 @@ class FilePlugin:
|
|||
|
||||
# we manage case where file already exists
|
||||
if os.path.exists(file_path):
|
||||
|
||||
def check_overwrite(overwrite):
|
||||
if overwrite:
|
||||
self.openFileWrite(
|
||||
client, file_path, transfer_data, file_data, stream_object
|
||||
)
|
||||
return True
|
||||
else:
|
||||
return defer.ensureDeferred(
|
||||
self.getDestDir(client, peer_jid, transfer_data, file_data)
|
||||
)
|
||||
|
||||
exists_d = xml_tools.deferConfirm(
|
||||
overwrite = await xml_tools.deferConfirm(
|
||||
self.host,
|
||||
_(CONFIRM_OVERWRITE).format(file_path),
|
||||
_(CONFIRM_OVERWRITE_TITLE),
|
||||
|
|
@ -282,8 +270,9 @@ class FilePlugin:
|
|||
security_limit=SECURITY_LIMIT,
|
||||
profile=client.profile,
|
||||
)
|
||||
exists_d.addCallback(check_overwrite)
|
||||
return exists_d
|
||||
|
||||
if not overwrite:
|
||||
return await self.getDestDir(client, peer_jid, transfer_data, file_data)
|
||||
|
||||
self.openFileWrite(client, file_path, transfer_data, file_data, stream_object)
|
||||
return True
|
||||
|
|
@ -315,7 +304,7 @@ class FilePlugin:
|
|||
"size_human" will also be added with human readable file size
|
||||
@param stream_object(bool): if True, a stream_object will be used instead of file_obj
|
||||
a stream.FileStreamObject will be used
|
||||
return (defer.Deferred): True if transfer is accepted
|
||||
return: True if transfer is accepted
|
||||
"""
|
||||
cont, ret_value = await self.host.trigger.asyncReturnPoint(
|
||||
"FILE_getDestDir", client, peer_jid, transfer_data, file_data, stream_object
|
||||
|
|
@ -327,7 +316,7 @@ class FilePlugin:
|
|||
assert PROGRESS_ID_KEY in file_data
|
||||
# human readable size
|
||||
file_data["size_human"] = common_utils.getHumanSize(file_data["size"])
|
||||
d = xml_tools.deferDialog(
|
||||
resp_data = await xml_tools.deferDialog(
|
||||
self.host,
|
||||
_(CONFIRM).format(peer=peer_jid.full(), **file_data),
|
||||
_(CONFIRM_TITLE),
|
||||
|
|
@ -341,12 +330,13 @@ class FilePlugin:
|
|||
security_limit=SECURITY_LIMIT,
|
||||
profile=client.profile,
|
||||
)
|
||||
d.addCallback(
|
||||
self._gotConfirmation,
|
||||
|
||||
accepted = await self._gotConfirmation(
|
||||
client,
|
||||
resp_data,
|
||||
peer_jid,
|
||||
transfer_data,
|
||||
file_data,
|
||||
stream_object,
|
||||
)
|
||||
return d
|
||||
return accepted
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@
|
|||
import time
|
||||
import dateutil
|
||||
import calendar
|
||||
import urllib.parse
|
||||
from secrets import token_urlsafe
|
||||
from typing import Optional
|
||||
from functools import partial
|
||||
|
|
@ -1032,13 +1031,12 @@ class XEP_0277(object):
|
|||
will return(JID(u'sat-pubsub.example.net'), 'urn:xmpp:comments:_af43b363-3259-4b2a-ba4c-1bc33aa87634__urn:xmpp:groupblog:somebody@example.net')
|
||||
@return (tuple[jid.JID, unicode]): service and node
|
||||
"""
|
||||
parsed_url = urllib.parse.urlparse(node_url, "xmpp")
|
||||
service = jid.JID(parsed_url.path)
|
||||
parsed_queries = urllib.parse.parse_qs(parsed_url.query)
|
||||
node = parsed_queries.get("node", [""])[0]
|
||||
|
||||
if not node:
|
||||
raise exceptions.DataError("Invalid comments link")
|
||||
try:
|
||||
parsed_url = xmpp_uri.parseXMPPUri(node_url)
|
||||
service = jid.JID(parsed_url["path"])
|
||||
node = parsed_url["node"]
|
||||
except Exception as e:
|
||||
raise exceptions.DataError(f"Invalid comments link: {e}")
|
||||
|
||||
return (service, node)
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
from zope.interface import implementer
|
||||
from twisted.internet import defer
|
||||
from twisted.internet import reactor
|
||||
from twisted.words.protocols.jabber import xmlstream, jid
|
||||
from twisted.words.protocols.jabber import xmlstream, jid, error
|
||||
from twisted.words.xish import domish
|
||||
from wokkel import disco, iwokkel
|
||||
from sat.core.i18n import _, D_
|
||||
|
|
@ -38,7 +38,7 @@ PLUGIN_INFO = {
|
|||
C.PI_NAME: "Jingle Message Initiation",
|
||||
C.PI_IMPORT_NAME: "XEP-0353",
|
||||
C.PI_TYPE: "XEP",
|
||||
C.PI_MODES: C.PLUG_MODE_CLIENT,
|
||||
C.PI_MODES: [C.PLUG_MODE_CLIENT],
|
||||
C.PI_PROTOCOLS: ["XEP-0353"],
|
||||
C.PI_DEPENDENCIES: ["XEP-0166"],
|
||||
C.PI_MAIN: "XEP_0353",
|
||||
|
|
@ -85,8 +85,15 @@ class XEP_0353:
|
|||
if peer_jid.resource:
|
||||
return True
|
||||
|
||||
infos = await self.host.memory.disco.getInfos(client, peer_jid)
|
||||
categories = {c for c, __ in infos.identities}
|
||||
try:
|
||||
infos = await self.host.memory.disco.getInfos(client, peer_jid)
|
||||
except error.StanzaError as e:
|
||||
if e.condition == "service-unavailable":
|
||||
categories = {}
|
||||
else:
|
||||
raise e
|
||||
else:
|
||||
categories = {c for c, __ in infos.identities}
|
||||
if "component" in categories:
|
||||
# we don't use message initiation with components
|
||||
return True
|
||||
|
|
|
|||
Loading…
Reference in a new issue