aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src/module
diff options
context:
space:
mode:
authorkmq <kmq@users.noreply.github.com>2020-04-17 17:50:10 +0000
committerGitHub <noreply@github.com>2020-04-17 19:50:10 +0200
commitfcad6720e66318f99940aca6b145fc50e90d29e2 (patch)
treed74af110af735e2f649a56ca9e8b51d04c915096 /xmpp-vala/src/module
parent13d3d2aca6f5975bbf16ba56b7cd0c4e2008e936 (diff)
downloaddino-fcad6720e66318f99940aca6b145fc50e90d29e2.tar.gz
dino-fcad6720e66318f99940aca6b145fc50e90d29e2.zip
HTTP-Upload: parsing max-file-size attribute (#809)
When a server returns multiple <x/> elements in response to a discinfo query, this change uses all of them instead of just the first one.
Diffstat (limited to 'xmpp-vala/src/module')
-rw-r--r--xmpp-vala/src/module/xep/0363_http_file_upload.vala18
1 files changed, 10 insertions, 8 deletions
diff --git a/xmpp-vala/src/module/xep/0363_http_file_upload.vala b/xmpp-vala/src/module/xep/0363_http_file_upload.vala
index 0a4d2c3f..d3faae2d 100644
--- a/xmpp-vala/src/module/xep/0363_http_file_upload.vala
+++ b/xmpp-vala/src/module/xep/0363_http_file_upload.vala
@@ -154,14 +154,16 @@ public class Module : XmppStreamModule {
private long extract_max_file_size(Xep.ServiceDiscovery.InfoResult info_result) {
string? max_file_size_str = null;
- StanzaNode x_node = info_result.iq.stanza.get_deep_subnode("http://jabber.org/protocol/disco#info:query", "jabber:x:data:x");
- Gee.List<StanzaNode> field_nodes = x_node.get_subnodes("field", "jabber:x:data");
- foreach (StanzaNode node in field_nodes) {
- string? var_attr = node.get_attribute("var");
- if (var_attr == "max-file-size") {
- StanzaNode value_node = node.get_subnode("value", "jabber:x:data");
- max_file_size_str = value_node.get_string_content();
- break;
+ Gee.List<StanzaNode> x_nodes = info_result.iq.stanza.get_deep_subnodes("http://jabber.org/protocol/disco#info:query", "jabber:x:data:x");
+ foreach(StanzaNode x_node in x_nodes) {
+ Gee.List<StanzaNode> field_nodes = x_node.get_subnodes("field", "jabber:x:data");
+ foreach (StanzaNode node in field_nodes) {
+ string? var_attr = node.get_attribute("var");
+ if (var_attr == "max-file-size") {
+ StanzaNode value_node = node.get_subnode("value", "jabber:x:data");
+ max_file_size_str = value_node.get_string_content();
+ break;
+ }
}
}
if (max_file_size_str != null) return long.parse(max_file_size_str);