Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim-plugins.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Hörist <forenjunkie@chello.at>2017-11-23 16:23:46 +0300
committerPhilipp Hörist <forenjunkie@chello.at>2017-11-23 16:24:46 +0300
commit7b88c0e0ef354fbd0cb5224a6b4af54ad3de6822 (patch)
treee5dac95a65ee2f46a5f9a7dc5b4f60f10f031a27
parent3140045e78e8afe72b0672505a97a0a4875e4531 (diff)
[httpupload] Discover max-file-size reliably
-rw-r--r--httpupload/httpupload.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/httpupload/httpupload.py b/httpupload/httpupload.py
index e8e2a53..cb06383 100644
--- a/httpupload/httpupload.py
+++ b/httpupload/httpupload.py
@@ -91,13 +91,20 @@ class HTTPUploadPlugin(GajimPlugin):
interface.component = event.jid
interface.update_button_states(True)
- try:
- for form in event.data:
- tmp = form.getField("max-file-size").getValue()
- interface.max_file_size = int(tmp)
- except AttributeError:
- interface.max_file_size = None
- log.warning("%s does not provide maximum file size" % account)
+ for form in event.data:
+ form_dict = form.asDict()
+ if form_dict.get('FORM_TYPE', None) != NS_HTTPUPLOAD:
+ continue
+ size = form_dict.get('max-file-size', None)
+ if size is not None:
+ interface.max_file_size = int(size)
+ break
+
+ if interface.max_file_size is None:
+ log.warning('%s does not provide maximum file size', account)
+ else:
+ log.info('%s has a maximum file size of: %s',
+ account, interface.max_file_size)
def handle_outgoing_stanza(self, event):
message = event.msg_iq.getTagData('body')
@@ -145,6 +152,7 @@ class Base(object):
self.encrypted_upload = False
self.enabled = False
self.component = None
+ self.max_file_size = None
self.controls = {}
def add_button(self, chat_control):