# HG changeset patch # User Goffi # Date 1582476506 -3600 # Node ID f2bb57348587d9219dec75f151c3eeb108686e38 # Parent 5ff2cf7f0abacc5f655f7ca97219a53e066b0a42 plugin attach, XEP-0363: progress id can now be specified: progress id can be specified in options, using the "progress_id" option, this can be more handy for frontends to keep track of attachments progresses. diff -r 5ff2cf7f0aba -r f2bb57348587 sat/plugins/plugin_misc_attach.py --- a/sat/plugins/plugin_misc_attach.py Sun Feb 23 17:48:26 2020 +0100 +++ b/sat/plugins/plugin_misc_attach.py Sun Feb 23 17:48:26 2020 +0100 @@ -75,6 +75,9 @@ name = attachment["name"] = path.name options = {} + progress_id = attachment.get("progress_id") + if progress_id: + options["progress_id"] = attachment["progress_id"] if client.encryption.isEncryptionRequested(data): # FIXME: we should not use implementation specific value here # but for not it's the only file encryption method available with @@ -85,6 +88,7 @@ client, filepath=path, filename=name, + options=options, ) uploads_d.append(upload_d) diff -r 5ff2cf7f0aba -r f2bb57348587 sat/plugins/plugin_misc_file.py --- a/sat/plugins/plugin_misc_file.py Sun Feb 23 17:48:26 2020 +0100 +++ b/sat/plugins/plugin_misc_file.py Sun Feb 23 17:48:26 2020 +0100 @@ -48,7 +48,8 @@ SENDING = D_("Please select a file to send to {peer}") SENDING_TITLE = D_("File sending") CONFIRM = D_( - '{peer} wants to send the file "{name}" to you:\n{desc}\n\nThe file has a size of {size_human}\n\nDo you accept ?' + '{peer} wants to send the file "{name}" to you:\n{desc}\n\nThe file has a size of ' + '{size_human}\n\nDo you accept ?' ) CONFIRM_TITLE = D_("Confirm file transfer") CONFIRM_OVERWRITE = D_("File {} already exists, are you sure you want to overwrite ?") @@ -58,7 +59,7 @@ PROGRESS_ID_KEY = "progress_id" -class FilePlugin(object): +class FilePlugin: File = stream.SatFile def __init__(self, host): @@ -99,7 +100,8 @@ @param filename(unicode, None): name to use, or None to find it from filepath @param file_desc(unicode, None): description of the file @param profile: %(doc_profile)s - @return (dict): action dictionary, with progress id in case of success, else xmlui message + @return (dict): action dictionary, with progress id in case of success, else + xmlui message """ if not os.path.isfile(filepath): raise exceptions.DataError("The given path doesn't link to a file") diff -r 5ff2cf7f0aba -r f2bb57348587 sat/plugins/plugin_misc_upload.py --- a/sat/plugins/plugin_misc_upload.py Sun Feb 23 17:48:26 2020 +0100 +++ b/sat/plugins/plugin_misc_upload.py Sun Feb 23 17:48:26 2020 +0100 @@ -111,6 +111,8 @@ @param options(dict): option to use for the upload, may be: - ignore_tls_errors(bool): True to ignore SSL/TLS certificate verification used only if HTTPS transport is needed + - progress_id(str): id to use for progression + if not specified, one will be generated @param profile: %(doc_profile)s @return (tuple[unicode,D(unicode)]): progress_id and a Deferred which fire download URL when upload is finished diff -r 5ff2cf7f0aba -r f2bb57348587 sat/plugins/plugin_xep_0363.py --- a/sat/plugins/plugin_xep_0363.py Sun Feb 23 17:48:26 2020 +0100 +++ b/sat/plugins/plugin_xep_0363.py Sun Feb 23 17:48:26 2020 +0100 @@ -160,7 +160,8 @@ else: log.debug(f"Got upload slot: {slot}") sat_file = self.host.plugins["FILE"].File( - self.host, client, filepath, size=size, auto_end_signals=False + self.host, client, filepath, uid=options.get("progress_id"), size=size, + auto_end_signals=False ) progress_id = sat_file.uid diff -r 5ff2cf7f0aba -r f2bb57348587 sat/tools/stream.py --- a/sat/tools/stream.py Sun Feb 23 17:48:26 2020 +0100 +++ b/sat/tools/stream.py Sun Feb 23 17:48:26 2020 +0100 @@ -1,7 +1,6 @@ #!/usr/bin/env python3 - -# SAT: a jabber client +# SàT: an XMPP client # Copyright (C) 2009-2020 Jérôme Poisson (goffi@goffi.org) # This program is free software: you can redistribute it and/or modify