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.
This commit is contained in:
parent
b485240f9b
commit
7a32e05df4
|
@ -154,14 +154,16 @@ public class Module : XmppStreamModule {
|
||||||
|
|
||||||
private long extract_max_file_size(Xep.ServiceDiscovery.InfoResult info_result) {
|
private long extract_max_file_size(Xep.ServiceDiscovery.InfoResult info_result) {
|
||||||
string? max_file_size_str = null;
|
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> x_nodes = info_result.iq.stanza.get_deep_subnodes("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 x_node in x_nodes) {
|
||||||
foreach (StanzaNode node in field_nodes) {
|
Gee.List<StanzaNode> field_nodes = x_node.get_subnodes("field", "jabber:x:data");
|
||||||
string? var_attr = node.get_attribute("var");
|
foreach (StanzaNode node in field_nodes) {
|
||||||
if (var_attr == "max-file-size") {
|
string? var_attr = node.get_attribute("var");
|
||||||
StanzaNode value_node = node.get_subnode("value", "jabber:x:data");
|
if (var_attr == "max-file-size") {
|
||||||
max_file_size_str = value_node.get_string_content();
|
StanzaNode value_node = node.get_subnode("value", "jabber:x:data");
|
||||||
break;
|
max_file_size_str = value_node.get_string_content();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (max_file_size_str != null) return long.parse(max_file_size_str);
|
if (max_file_size_str != null) return long.parse(max_file_size_str);
|
||||||
|
|
Loading…
Reference in a new issue