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/iq/module.vala6
-rw-r--r--xmpp-vala/src/module/tls.vala6
-rw-r--r--xmpp-vala/src/module/util.vala25
-rw-r--r--xmpp-vala/src/module/xep/0368_srv_records_tls.vala10
4 files changed, 18 insertions, 29 deletions
diff --git a/xmpp-vala/src/module/iq/module.vala b/xmpp-vala/src/module/iq/module.vala
index c19cc2e5..7a2425b4 100644
--- a/xmpp-vala/src/module/iq/module.vala
+++ b/xmpp-vala/src/module/iq/module.vala
@@ -13,11 +13,7 @@ namespace Xmpp.Iq {
public delegate void OnResult(XmppStream stream, Iq.Stanza iq);
public void send_iq(XmppStream stream, Iq.Stanza iq, owned OnResult? listener = null) {
- try {
- stream.write(iq.stanza);
- } catch (IOStreamError e) {
- print(@"$(e.message)\n");
- }
+ stream.write(iq.stanza);
if (listener != null) {
responseListeners[iq.id] = new ResponseListener((owned) listener);
}
diff --git a/xmpp-vala/src/module/tls.vala b/xmpp-vala/src/module/tls.vala
index dd4fd82d..dcd7ab40 100644
--- a/xmpp-vala/src/module/tls.vala
+++ b/xmpp-vala/src/module/tls.vala
@@ -53,11 +53,7 @@ namespace Xmpp.Tls {
server_requires_tls = true;
}
if (server_requires_tls || require) {
- try {
- stream.write(new StanzaNode.build("starttls", NS_URI).add_self_xmlns());
- } catch (IOStreamError e) {
- stderr.printf("Failed to request TLS: %s\n", e.message);
- }
+ stream.write(new StanzaNode.build("starttls", NS_URI).add_self_xmlns());
}
if (identity == null) {
identity = new NetworkService("xmpp-client", "tcp", stream.remote_name);
diff --git a/xmpp-vala/src/module/util.vala b/xmpp-vala/src/module/util.vala
index 812b09ad..e42c4768 100644
--- a/xmpp-vala/src/module/util.vala
+++ b/xmpp-vala/src/module/util.vala
@@ -48,16 +48,6 @@ public class StanzaListenerHolder<T> : Object {
}
}
- private Gee.List<StanzaListener<T>> set_minus(Gee.List<StanzaListener<T>> main_set, Gee.List<StanzaListener<T>> minus) {
- Gee.List<StanzaListener<T>> res = new ArrayList<StanzaListener<T>>();
- foreach (StanzaListener<T> l in main_set) {
- if (!minus.contains(l)) {
- res.add(l);
- }
- }
- return res;
- }
-
private bool set_contains_action(Gee.List<StanzaListener<T>> s, string[] actions) {
foreach(StanzaListener<T> l in s) {
if (l.action_group in actions) {
@@ -69,16 +59,23 @@ public class StanzaListenerHolder<T> : Object {
private void resort_list() {
ArrayList<StanzaListener<T>> new_list = new ArrayList<StanzaListener<T>>();
- while (listeners.size > new_list.size) {
+ ArrayList<StanzaListener<T>> remaining = new ArrayList<StanzaListener<T>>();
+ remaining.add_all(listeners);
+ while (remaining.size > 0) {
bool changed = false;
- foreach (StanzaListener<T> l in listeners) {
- Gee.List<StanzaListener<T>> remaining = set_minus(listeners, new_list);
+ Gee.Iterator<StanzaListener<T>> iter = remaining.iterator();
+ while (iter.has_next()) {
+ if (!iter.valid) {
+ iter.next();
+ }
+ StanzaListener<T> l = iter.get();
if (!set_contains_action(remaining, l.after_actions)) {
new_list.add(l);
+ iter.remove();
changed = true;
}
}
- if (!changed) warning("Can't sort listeners");
+ if (!changed) error("Can't sort listeners");
}
listeners = new_list;
}
diff --git a/xmpp-vala/src/module/xep/0368_srv_records_tls.vala b/xmpp-vala/src/module/xep/0368_srv_records_tls.vala
index 4c24c63e..4d34e750 100644
--- a/xmpp-vala/src/module/xep/0368_srv_records_tls.vala
+++ b/xmpp-vala/src/module/xep/0368_srv_records_tls.vala
@@ -22,11 +22,11 @@ public class Module : XmppStreamNegotiationModule {
public class TlsConnectionProvider : ConnectionProvider {
private SrvTarget? srv_target;
- public override int? get_priority(string remote_name) {
+ public async override int? get_priority(string remote_name) {
GLib.List<SrvTarget>? xmpp_target = null;
try {
- Resolver resolver = Resolver.get_default();
- xmpp_target = resolver.lookup_service("xmpps-client", "tcp", remote_name, null);
+ GLibFixes.Resolver resolver = GLibFixes.Resolver.get_default();
+ xmpp_target = yield resolver.lookup_service_async("xmpps-client", "tcp", remote_name, null);
} catch (Error e) {
return null;
}
@@ -35,10 +35,10 @@ public class TlsConnectionProvider : ConnectionProvider {
return xmpp_target.nth(0).data.get_priority();
}
- public override IOStream? connect(XmppStream stream) {
+ public async override IOStream? connect(XmppStream stream) {
SocketClient client = new SocketClient();
try {
- IOStream? io_stream = client.connect_to_host(srv_target.get_hostname(), srv_target.get_port());
+ IOStream? io_stream = yield client.connect_to_host_async(srv_target.get_hostname(), srv_target.get_port());
io_stream = TlsClientConnection.new(io_stream, new NetworkAddress(srv_target.get_hostname(), srv_target.get_port()));
stream.add_flag(new Tls.Flag() { finished=true });
return io_stream;