aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src/module
diff options
context:
space:
mode:
Diffstat (limited to 'xmpp-vala/src/module')
-rw-r--r--xmpp-vala/src/module/xep/0030_service_discovery/items_result.vala4
-rw-r--r--xmpp-vala/src/module/xep/0030_service_discovery/module.vala6
-rw-r--r--xmpp-vala/src/module/xep/0065_socks5_bytestreams.vala1
-rw-r--r--xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala1
-rw-r--r--xmpp-vala/src/module/xep/0363_http_file_upload.vala20
5 files changed, 25 insertions, 7 deletions
diff --git a/xmpp-vala/src/module/xep/0030_service_discovery/items_result.vala b/xmpp-vala/src/module/xep/0030_service_discovery/items_result.vala
index 233a0c06..105da893 100644
--- a/xmpp-vala/src/module/xep/0030_service_discovery/items_result.vala
+++ b/xmpp-vala/src/module/xep/0030_service_discovery/items_result.vala
@@ -26,6 +26,10 @@ public class ItemsResult {
}
public static ItemsResult? create_from_iq(Iq.Stanza iq) {
+ if (iq.type_ != Iq.Stanza.TYPE_RESULT) return null;
+
+ if (iq.stanza.get_subnode("query", NS_URI_ITEMS) == null) return null;
+
return new ItemsResult.from_iq(iq);
}
}
diff --git a/xmpp-vala/src/module/xep/0030_service_discovery/module.vala b/xmpp-vala/src/module/xep/0030_service_discovery/module.vala
index 708d5311..f21146f1 100644
--- a/xmpp-vala/src/module/xep/0030_service_discovery/module.vala
+++ b/xmpp-vala/src/module/xep/0030_service_discovery/module.vala
@@ -46,11 +46,11 @@ public class Module : XmppStreamModule, Iq.Handler {
if (flag.has_entity_feature(jid, feature) == null) {
InfoResult? info_result = yield request_info(stream, jid);
- stream.get_flag(Flag.IDENTITY).set_entity_features(info_result.iq.from, info_result != null ? info_result.features : null);
- stream.get_flag(Flag.IDENTITY).set_entity_identities(info_result.iq.from, info_result != null ? info_result.identities : null);
+ stream.get_flag(Flag.IDENTITY).set_entity_features(jid, info_result != null ? info_result.features : null);
+ stream.get_flag(Flag.IDENTITY).set_entity_identities(jid, info_result != null ? info_result.identities : null);
}
- return flag.has_entity_feature(jid, feature);
+ return flag.has_entity_feature(jid, feature) ?? false;
}
public async Gee.Set<Identity>? get_entity_identities(XmppStream stream, Jid jid) {
diff --git a/xmpp-vala/src/module/xep/0065_socks5_bytestreams.vala b/xmpp-vala/src/module/xep/0065_socks5_bytestreams.vala
index bdc54879..fdee2411 100644
--- a/xmpp-vala/src/module/xep/0065_socks5_bytestreams.vala
+++ b/xmpp-vala/src/module/xep/0065_socks5_bytestreams.vala
@@ -35,6 +35,7 @@ public class Module : XmppStreamModule, Iq.Handler {
private async void query_availability(XmppStream stream) {
ServiceDiscovery.ItemsResult? items_result = yield stream.get_module(ServiceDiscovery.Module.IDENTITY).request_items(stream, stream.remote_name);
+ if (items_result == null) return;
foreach (Xep.ServiceDiscovery.Item item in items_result.items) {
bool has_feature = yield stream.get_module(ServiceDiscovery.Module.IDENTITY).has_entity_feature(stream, item.jid, NS_URI);
diff --git a/xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala b/xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala
index 60d13211..20279546 100644
--- a/xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala
+++ b/xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala
@@ -86,6 +86,7 @@ namespace Xmpp.Xep.EntityCapabilities {
ServiceDiscovery.Identity identity = storage.get_identities(caps_hash);
if (identity == null) {
ServiceDiscovery.InfoResult? info_result = yield stream.get_module(ServiceDiscovery.Module.IDENTITY).request_info(stream, jid_from);
+ if (info_result == null) return;
store_entity_result(stream, caps_hash, info_result);
} else {
stream.get_flag(ServiceDiscovery.Flag.IDENTITY).set_entity_features(jid_from, capabilities);
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 64fbbebc..a6ebbecb 100644
--- a/xmpp-vala/src/module/xep/0363_http_file_upload.vala
+++ b/xmpp-vala/src/module/xep/0363_http_file_upload.vala
@@ -116,14 +116,26 @@ public class Module : XmppStreamModule {
bool available = check_ns_in_info(stream, stream.remote_name, info_result);
if (!available) {
ServiceDiscovery.ItemsResult? items_result = yield stream.get_module(ServiceDiscovery.Module.IDENTITY).request_items(stream, stream.remote_name);
- foreach (Xep.ServiceDiscovery.Item item in items_result.items) {
- ServiceDiscovery.InfoResult? info_result2 = yield stream.get_module(ServiceDiscovery.Module.IDENTITY).request_info(stream, item.jid);
- check_ns_in_info(stream, item.jid, info_result2);
+ if (items_result == null) return;
+
+ for (int i = 0; i < 2; i++) {
+ foreach (Xep.ServiceDiscovery.Item item in items_result.items) {
+
+ // First try the promising items and only afterwards all the others
+ bool promising_upload_item = item.jid.to_string().has_prefix("upload");
+ if ((i == 0 && !promising_upload_item) || (i == 1) && promising_upload_item) continue;
+
+ ServiceDiscovery.InfoResult? info_result2 = yield stream.get_module(ServiceDiscovery.Module.IDENTITY).request_info(stream, item.jid);
+ bool available2 = check_ns_in_info(stream, item.jid, info_result2);
+ if (available2) return;
+ }
}
}
}
- private bool check_ns_in_info(XmppStream stream, Jid jid, Xep.ServiceDiscovery.InfoResult info_result) {
+ private bool check_ns_in_info(XmppStream stream, Jid jid, Xep.ServiceDiscovery.InfoResult? info_result) {
+ if (info_result == null) return false;
+
bool ver_available = false;
bool ver_0_available = false;
foreach (string feature in info_result.features) {