comparison sat/plugins/plugin_misc_file.py @ 3182:f2bb57348587

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.
author Goffi <goffi@goffi.org>
date Sun, 23 Feb 2020 17:48:26 +0100
parents 559a625a236b
children 404d4b29de52
comparison
equal deleted inserted replaced
3181:5ff2cf7f0aba 3182:f2bb57348587
46 46
47 47
48 SENDING = D_("Please select a file to send to {peer}") 48 SENDING = D_("Please select a file to send to {peer}")
49 SENDING_TITLE = D_("File sending") 49 SENDING_TITLE = D_("File sending")
50 CONFIRM = D_( 50 CONFIRM = D_(
51 '{peer} wants to send the file "{name}" to you:\n{desc}\n\nThe file has a size of {size_human}\n\nDo you accept ?' 51 '{peer} wants to send the file "{name}" to you:\n{desc}\n\nThe file has a size of '
52 '{size_human}\n\nDo you accept ?'
52 ) 53 )
53 CONFIRM_TITLE = D_("Confirm file transfer") 54 CONFIRM_TITLE = D_("Confirm file transfer")
54 CONFIRM_OVERWRITE = D_("File {} already exists, are you sure you want to overwrite ?") 55 CONFIRM_OVERWRITE = D_("File {} already exists, are you sure you want to overwrite ?")
55 CONFIRM_OVERWRITE_TITLE = D_("File exists") 56 CONFIRM_OVERWRITE_TITLE = D_("File exists")
56 SECURITY_LIMIT = 30 57 SECURITY_LIMIT = 30
57 58
58 PROGRESS_ID_KEY = "progress_id" 59 PROGRESS_ID_KEY = "progress_id"
59 60
60 61
61 class FilePlugin(object): 62 class FilePlugin:
62 File = stream.SatFile 63 File = stream.SatFile
63 64
64 def __init__(self, host): 65 def __init__(self, host):
65 log.info(_("plugin File initialization")) 66 log.info(_("plugin File initialization"))
66 self.host = host 67 self.host = host
97 @param peer_jid(jid.JID): jid of the destinee 98 @param peer_jid(jid.JID): jid of the destinee
98 @param filepath(str): absolute path to the file 99 @param filepath(str): absolute path to the file
99 @param filename(unicode, None): name to use, or None to find it from filepath 100 @param filename(unicode, None): name to use, or None to find it from filepath
100 @param file_desc(unicode, None): description of the file 101 @param file_desc(unicode, None): description of the file
101 @param profile: %(doc_profile)s 102 @param profile: %(doc_profile)s
102 @return (dict): action dictionary, with progress id in case of success, else xmlui message 103 @return (dict): action dictionary, with progress id in case of success, else
104 xmlui message
103 """ 105 """
104 if not os.path.isfile(filepath): 106 if not os.path.isfile(filepath):
105 raise exceptions.DataError("The given path doesn't link to a file") 107 raise exceptions.DataError("The given path doesn't link to a file")
106 if not filename: 108 if not filename:
107 filename = os.path.basename(filepath) or "_" 109 filename = os.path.basename(filepath) or "_"