xmpp-vala: Use more async

This commit is contained in:
fiaxh 2020-04-24 14:19:42 +02:00
parent 1db94905ae
commit f8f305efe5
16 changed files with 90 additions and 123 deletions

View file

@ -223,7 +223,7 @@ public class ConnectionManager : Object {
DateTime? last_activity_was = connections[account].last_activity; DateTime? last_activity_was = connections[account].last_activity;
XmppStream stream = connections[account].stream; XmppStream stream = connections[account].stream;
stream.get_module(Xep.Ping.Module.IDENTITY).send_ping(stream, account.bare_jid.domain_jid, () => { stream.get_module(Xep.Ping.Module.IDENTITY).send_ping.begin(stream, account.bare_jid.domain_jid, () => {
acked = true; acked = true;
if (connections[account].stream != stream) return; if (connections[account].stream != stream) return;
change_connection_state(account, ConnectionState.CONNECTED); change_connection_state(account, ConnectionState.CONNECTED);

View file

@ -54,7 +54,7 @@ namespace Xmpp.Iq {
public override string get_ns() { return NS_URI; } public override string get_ns() { return NS_URI; }
public override string get_id() { return IDENTITY.id; } public override string get_id() { return IDENTITY.id; }
private void on_received_iq_stanza(XmppStream stream, StanzaNode node) { private async void on_received_iq_stanza(XmppStream stream, StanzaNode node) {
Iq.Stanza iq = new Iq.Stanza.from_stanza(node, stream.has_flag(Bind.Flag.IDENTITY) ? stream.get_flag(Bind.Flag.IDENTITY).my_jid : null); Iq.Stanza iq = new Iq.Stanza.from_stanza(node, stream.has_flag(Bind.Flag.IDENTITY) ? stream.get_flag(Bind.Flag.IDENTITY).my_jid : null);
if (iq.type_ == Iq.Stanza.TYPE_RESULT || iq.is_error()) { if (iq.type_ == Iq.Stanza.TYPE_RESULT || iq.is_error()) {
@ -71,9 +71,9 @@ namespace Xmpp.Iq {
Gee.List<Handler> handlers = namespaceRegistrants[children[0].ns_uri]; Gee.List<Handler> handlers = namespaceRegistrants[children[0].ns_uri];
foreach (Handler handler in handlers) { foreach (Handler handler in handlers) {
if (iq.type_ == Iq.Stanza.TYPE_GET) { if (iq.type_ == Iq.Stanza.TYPE_GET) {
handler.on_iq_get(stream, iq); yield handler.on_iq_get(stream, iq);
} else if (iq.type_ == Iq.Stanza.TYPE_SET) { } else if (iq.type_ == Iq.Stanza.TYPE_SET) {
handler.on_iq_set(stream, iq); yield handler.on_iq_set(stream, iq);
} }
} }
} else { } else {
@ -94,11 +94,11 @@ namespace Xmpp.Iq {
} }
public interface Handler : Object { public interface Handler : Object {
public virtual void on_iq_get(XmppStream stream, Iq.Stanza iq) { public async virtual void on_iq_get(XmppStream stream, Iq.Stanza iq) {
Iq.Stanza bad_request = new Iq.Stanza.error(iq, new ErrorStanza.bad_request("unexpected IQ get for this namespace")); Iq.Stanza bad_request = new Iq.Stanza.error(iq, new ErrorStanza.bad_request("unexpected IQ get for this namespace"));
stream.get_module(Module.IDENTITY).send_iq(stream, bad_request); stream.get_module(Module.IDENTITY).send_iq(stream, bad_request);
} }
public virtual void on_iq_set(XmppStream stream, Iq.Stanza iq) { public async virtual void on_iq_set(XmppStream stream, Iq.Stanza iq) {
Iq.Stanza bad_request = new Iq.Stanza.error(iq, new ErrorStanza.bad_request("unexpected IQ set for this namespace")); Iq.Stanza bad_request = new Iq.Stanza.error(iq, new ErrorStanza.bad_request("unexpected IQ set for this namespace"));
stream.get_module(Module.IDENTITY).send_iq(stream, bad_request); stream.get_module(Module.IDENTITY).send_iq(stream, bad_request);
} }

View file

@ -44,7 +44,7 @@ public class Module : XmppStreamModule, Iq.Handler {
roster_set(stream, item); roster_set(stream, item);
} }
public void on_iq_set(XmppStream stream, Iq.Stanza iq) { public async void on_iq_set(XmppStream stream, Iq.Stanza iq) {
StanzaNode? query_node = iq.stanza.get_subnode("query", NS_URI); StanzaNode? query_node = iq.stanza.get_subnode("query", NS_URI);
if (query_node == null) return; if (query_node == null) return;
if (!iq.from.equals(stream.get_flag(Bind.Flag.IDENTITY).my_jid.bare_jid)) { if (!iq.from.equals(stream.get_flag(Bind.Flag.IDENTITY).my_jid.bare_jid)) {

View file

@ -22,16 +22,16 @@ public class Module : XmppStreamNegotiationModule {
public override string get_ns() { return NS_URI; } public override string get_ns() { return NS_URI; }
public override string get_id() { return IDENTITY.id; } public override string get_id() { return IDENTITY.id; }
private void on_bound_resource(XmppStream stream, Jid my_jid) { private async void on_bound_resource(XmppStream stream, Jid my_jid) {
StanzaNode? session_node = stream.features.get_subnode("session", NS_URI); StanzaNode? session_node = stream.features.get_subnode("session", NS_URI);
if (session_node != null && session_node.get_subnode("optional", NS_URI) == null) { if (session_node != null && session_node.get_subnode("optional", NS_URI) == null) {
stream.add_flag(new Flag()); stream.add_flag(new Flag());
Iq.Stanza iq = new Iq.Stanza.set(new StanzaNode.build("session", NS_URI).add_self_xmlns()) { to=stream.remote_name }; Iq.Stanza iq = new Iq.Stanza.set(new StanzaNode.build("session", NS_URI).add_self_xmlns()) { to=stream.remote_name };
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, (stream, iq) => {
if (!iq.is_error()) { Iq.Stanza result_iq = yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq);
stream.get_flag(Flag.IDENTITY).finished = true; if (!result_iq.is_error()) {
} stream.get_flag(Flag.IDENTITY).finished = true;
}); }
} }
} }
} }

View file

@ -100,7 +100,7 @@ public class Module : XmppStreamModule, Iq.Handler {
return result; return result;
} }
public void on_iq_get(XmppStream stream, Iq.Stanza iq) { public async void on_iq_get(XmppStream stream, Iq.Stanza iq) {
StanzaNode? query_node = iq.stanza.get_subnode("query", NS_URI_INFO); StanzaNode? query_node = iq.stanza.get_subnode("query", NS_URI_INFO);
if (query_node != null) { if (query_node != null) {
send_query_result(stream, iq); send_query_result(stream, iq);

View file

@ -333,9 +333,9 @@ public class Module : XmppStreamModule {
Jid bare_jid = presence.from.bare_jid; Jid bare_jid = presence.from.bare_jid;
if (flag.get_enter_id(bare_jid) != null) { if (flag.get_enter_id(bare_jid) != null) {
query_affiliation(stream, bare_jid, "member", null); query_affiliation.begin(stream, bare_jid, "member");
query_affiliation(stream, bare_jid, "admin", null); query_affiliation.begin(stream, bare_jid, "admin");
query_affiliation(stream, bare_jid, "owner", null); query_affiliation.begin(stream, bare_jid, "owner");
flag.finish_muc_enter(bare_jid, presence.from.resourcepart); flag.finish_muc_enter(bare_jid, presence.from.resourcepart);
flag.enter_futures[bare_jid].set_value(new JoinResult() {nick=presence.from.resourcepart}); flag.enter_futures[bare_jid].set_value(new JoinResult() {nick=presence.from.resourcepart});
@ -437,36 +437,38 @@ public class Module : XmppStreamModule {
room_info_updated(stream, jid); room_info_updated(stream, jid);
} }
public delegate void OnAffiliationResult(XmppStream stream, Gee.List<Jid> jids); private async Gee.List<Jid>? query_affiliation(XmppStream stream, Jid jid, string affiliation) {
private void query_affiliation(XmppStream stream, Jid jid, string affiliation, owned OnAffiliationResult? listener) {
Iq.Stanza iq = new Iq.Stanza.get( Iq.Stanza iq = new Iq.Stanza.get(
new StanzaNode.build("query", NS_URI_ADMIN) new StanzaNode.build("query", NS_URI_ADMIN)
.add_self_xmlns() .add_self_xmlns()
.put_node(new StanzaNode.build("item", NS_URI_ADMIN) .put_node(new StanzaNode.build("item", NS_URI_ADMIN)
.put_attribute("affiliation", affiliation)) .put_attribute("affiliation", affiliation))
) { to=jid }; ) { to=jid };
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, (stream, iq) => {
if (iq.is_error()) return;
StanzaNode? query_node = iq.stanza.get_subnode("query", NS_URI_ADMIN); Iq.Stanza iq_result = yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq);
if (query_node == null) return; if (iq_result.is_error()) return null;
Gee.List<StanzaNode> item_nodes = query_node.get_subnodes("item", NS_URI_ADMIN);
Gee.List<Jid> ret_jids = new ArrayList<Jid>(Jid.equals_func); StanzaNode? query_node = iq_result.stanza.get_subnode("query", NS_URI_ADMIN);
foreach (StanzaNode item in item_nodes) { if (query_node == null) return null;
string jid__ = item.get_attribute("jid");
string? affiliation_ = item.get_attribute("affiliation"); Gee.List<StanzaNode> item_nodes = query_node.get_subnodes("item", NS_URI_ADMIN);
if (jid__ != null && affiliation_ != null) { Gee.List<Jid> ret_jids = new ArrayList<Jid>(Jid.equals_func);
try { foreach (StanzaNode item in item_nodes) {
Jid jid_ = new Jid(jid__); string jid__ = item.get_attribute("jid");
stream.get_flag(Flag.IDENTITY).set_offline_member(iq.from, jid_, parse_affiliation(affiliation_)); string? affiliation_ = item.get_attribute("affiliation");
ret_jids.add(jid_); if (jid__ != null && affiliation_ != null) {
received_occupant_jid(stream, iq.from, jid_); try {
} catch (InvalidJidError e) { Jid jid_ = new Jid(jid__);
warning("Received invalid occupant jid: %s", e.message); stream.get_flag(Flag.IDENTITY).set_offline_member(iq_result.from, jid_, parse_affiliation(affiliation_));
} ret_jids.add(jid_);
received_occupant_jid(stream, iq_result.from, jid_);
} catch (InvalidJidError e) {
warning("Received invalid occupant jid: %s", e.message);
} }
} }
if (listener != null) listener(stream, ret_jids); }
}); return ret_jids;
} }
private static ArrayList<int> get_status_codes(StanzaNode x_node) { private static ArrayList<int> get_status_codes(StanzaNode x_node) {

View file

@ -18,7 +18,7 @@ public class Module : XmppStreamModule, Iq.Handler {
stream.get_module(Iq.Module.IDENTITY).unregister_from_namespace(NS_URI, this); stream.get_module(Iq.Module.IDENTITY).unregister_from_namespace(NS_URI, this);
} }
public void on_iq_set(XmppStream stream, Iq.Stanza iq) { public async void on_iq_set(XmppStream stream, Iq.Stanza iq) {
// the iq module ensures that there's only one child node // the iq module ensures that there's only one child node
StanzaNode? node = null; StanzaNode? node = null;
node = (node != null) ? node : iq.stanza.get_subnode("open", NS_URI); node = (node != null) ? node : iq.stanza.get_subnode("open", NS_URI);

View file

@ -7,25 +7,21 @@ public class Module : BookmarksProvider, XmppStreamModule {
public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0048_bookmarks_module"); public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0048_bookmarks_module");
public async Set<Conference>? get_conferences(XmppStream stream) { public async Set<Conference>? get_conferences(XmppStream stream) {
Set<Conference> ret = new HashSet<Conference>(Conference.hash_func, Conference.equals_func);
StanzaNode get_node = new StanzaNode.build("storage", NS_URI).add_self_xmlns(); StanzaNode get_node = new StanzaNode.build("storage", NS_URI).add_self_xmlns();
stream.get_module(PrivateXmlStorage.Module.IDENTITY).retrieve(stream, get_node, (stream, node) => { StanzaNode? result_node = yield stream.get_module(PrivateXmlStorage.Module.IDENTITY).retrieve(stream, get_node);
if (node != null) { if (result_node == null) return null;
Gee.List<StanzaNode> conferences_node = node.get_subnode("storage", NS_URI).get_subnodes("conference", NS_URI);
foreach (StanzaNode conference_node in conferences_node) {
Conference? conference = Bookmarks1Conference.create_from_stanza_node(conference_node);
ret.add(conference);
}
}
Idle.add(get_conferences.callback);
});
yield;
Set<Conference> ret = new HashSet<Conference>(Conference.hash_func, Conference.equals_func);
Gee.List<StanzaNode> conferences_node = result_node.get_subnode("storage", NS_URI).get_subnodes("conference", NS_URI);
foreach (StanzaNode conference_node in conferences_node) {
Conference? conference = Bookmarks1Conference.create_from_stanza_node(conference_node);
ret.add(conference);
}
return ret; return ret;
} }
private void set_conferences(XmppStream stream, Set<Conference> conferences) { private async void set_conferences(XmppStream stream, Set<Conference> conferences) {
StanzaNode storage_node = (new StanzaNode.build("storage", NS_URI)).add_self_xmlns(); StanzaNode storage_node = (new StanzaNode.build("storage", NS_URI)).add_self_xmlns();
foreach (Conference conference in conferences) { foreach (Conference conference in conferences) {
Bookmarks1Conference? bookmarks1conference = conference as Bookmarks1Conference; Bookmarks1Conference? bookmarks1conference = conference as Bookmarks1Conference;
@ -46,15 +42,14 @@ public class Module : BookmarksProvider, XmppStreamModule {
storage_node.put_node(conference_node); storage_node.put_node(conference_node);
} }
} }
stream.get_module(PrivateXmlStorage.Module.IDENTITY).store(stream, storage_node, (stream) => { yield stream.get_module(PrivateXmlStorage.Module.IDENTITY).store(stream, storage_node);
stream.get_module(Module.IDENTITY).received_conferences(stream, conferences); stream.get_module(Module.IDENTITY).received_conferences(stream, conferences);
});
} }
public async void add_conference(XmppStream stream, Conference conference) { public async void add_conference(XmppStream stream, Conference conference) {
Set<Conference>? conferences = yield get_conferences(stream); Set<Conference>? conferences = yield get_conferences(stream);
conferences.add(conference); conferences.add(conference);
set_conferences(stream, conferences); yield set_conferences(stream, conferences);
} }
public async void replace_conference(XmppStream stream, Jid muc_jid, Conference modified_conference) { public async void replace_conference(XmppStream stream, Jid muc_jid, Conference modified_conference) {
@ -67,13 +62,13 @@ public class Module : BookmarksProvider, XmppStreamModule {
conference.password = modified_conference.password; conference.password = modified_conference.password;
} }
} }
set_conferences(stream, conferences); yield set_conferences(stream, conferences);
} }
public async void remove_conference(XmppStream stream, Conference conference_remove) { public async void remove_conference(XmppStream stream, Conference conference_remove) {
Set<Conference>? conferences = yield get_conferences(stream); Set<Conference>? conferences = yield get_conferences(stream);
conferences.remove(conference_remove); conferences.remove(conference_remove);
set_conferences(stream, conferences); yield set_conferences(stream, conferences);
} }
public override void attach(XmppStream stream) { } public override void attach(XmppStream stream) { }

View file

@ -6,22 +6,17 @@ namespace Xmpp.Xep.PrivateXmlStorage {
public class Module : XmppStreamModule { public class Module : XmppStreamModule {
public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0049_private_xml_storage"); public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0049_private_xml_storage");
public delegate void OnSuccess(XmppStream stream); public async void store(XmppStream stream, StanzaNode node) {
public void store(XmppStream stream, StanzaNode node, owned OnSuccess listener) {
StanzaNode queryNode = new StanzaNode.build("query", NS_URI).add_self_xmlns().put_node(node); StanzaNode queryNode = new StanzaNode.build("query", NS_URI).add_self_xmlns().put_node(node);
Iq.Stanza iq = new Iq.Stanza.set(queryNode); Iq.Stanza iq = new Iq.Stanza.set(queryNode);
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, (stream, iq) => { yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq);
listener(stream);
});
} }
public delegate void OnResponse(XmppStream stream, StanzaNode? node); public async StanzaNode? retrieve(XmppStream stream, StanzaNode node) {
public void retrieve(XmppStream stream, StanzaNode node, owned OnResponse listener) {
StanzaNode queryNode = new StanzaNode.build("query", NS_URI).add_self_xmlns().put_node(node); StanzaNode queryNode = new StanzaNode.build("query", NS_URI).add_self_xmlns().put_node(node);
Iq.Stanza iq = new Iq.Stanza.get(queryNode); Iq.Stanza iq = new Iq.Stanza.get(queryNode);
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, (stream, iq) => { Iq.Stanza iq_result = yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq);
listener(stream, iq.stanza.get_subnode("query", NS_URI)); return iq_result.stanza.get_subnode("query", NS_URI);
});
} }
public override void attach(XmppStream stream) { } public override void attach(XmppStream stream) { }

View file

@ -27,7 +27,7 @@ public class Module : XmppStreamModule, Iq.Handler {
} }
public override void detach(XmppStream stream) { } public override void detach(XmppStream stream) { }
public void on_iq_set(XmppStream stream, Iq.Stanza iq) { } public async void on_iq_set(XmppStream stream, Iq.Stanza iq) { }
public Gee.List<Proxy> get_proxies(XmppStream stream) { public Gee.List<Proxy> get_proxies(XmppStream stream) {
return stream.get_flag(Flag.IDENTITY).proxies; return stream.get_flag(Flag.IDENTITY).proxies;

View file

@ -8,34 +8,27 @@ public class Module : XmppStreamNegotiationModule {
public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0077_in_band_registration"); public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0077_in_band_registration");
public async Form? get_from_server(XmppStream stream, Jid jid) { public async Form? get_from_server(XmppStream stream, Jid jid) {
Iq.Stanza request_form_iq = new Iq.Stanza.get(new StanzaNode.build("query", NS_URI).add_self_xmlns()); StanzaNode query_node = new StanzaNode.build("query", NS_URI).add_self_xmlns();
Iq.Stanza request_form_iq = new Iq.Stanza.get(query_node) { to=jid };
request_form_iq.to = jid; request_form_iq.to = jid;
SourceFunc callback = get_from_server.callback; SourceFunc callback = get_from_server.callback;
Form? form = null;
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, request_form_iq, (stream, response_iq) => { Iq.Stanza iq_result = yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, request_form_iq);
form = new Form.from_node(stream, response_iq); return new Form.from_node(stream, iq_result);
Idle.add((owned)callback);
});
yield;
return form;
} }
public async string? submit_to_server(XmppStream stream, Jid jid, Form form) { public async string? submit_to_server(XmppStream stream, Jid jid, Form form) {
StanzaNode query_node = new StanzaNode.build("query", NS_URI).add_self_xmlns(); StanzaNode query_node = new StanzaNode.build("query", NS_URI).add_self_xmlns();
query_node.put_node(form.get_submit_node()); query_node.put_node(form.get_submit_node());
Iq.Stanza iq = new Iq.Stanza.set(query_node); Iq.Stanza iq = new Iq.Stanza.set(query_node) { to=jid };
iq.to = jid;
string? error_message = null; Iq.Stanza iq_result = yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq);
SourceFunc callback = submit_to_server.callback; if (iq_result.is_error()) {
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, (stream, response_iq) => { ErrorStanza? error_stanza = iq_result.get_error();
if (response_iq.is_error()) { return error_stanza.text ?? "Error";
ErrorStanza? error_stanza = response_iq.get_error(); }
error_message = error_stanza.text ?? "Error";
} return null;
Idle.add((owned)callback);
});
yield;
return error_message;
} }
public override bool mandatory_outstanding(XmppStream stream) { return false; } public override bool mandatory_outstanding(XmppStream stream) { return false; }

View file

@ -295,7 +295,7 @@ public class Module : XmppStreamModule, Iq.Handler {
current_stream.get_flag(Flag.IDENTITY).remove_session(sid); current_stream.get_flag(Flag.IDENTITY).remove_session(sid);
} }
public void on_iq_set(XmppStream stream, Iq.Stanza iq) { public async void on_iq_set(XmppStream stream, Iq.Stanza iq) {
try { try {
handle_iq_set(stream, iq); handle_iq_set(stream, iq);
} catch (IqError e) { } catch (IqError e) {

View file

@ -45,7 +45,7 @@ public class Module : XmppStreamModule, Iq.Handler {
return stream.has_flag(Flag.IDENTITY); return stream.has_flag(Flag.IDENTITY);
} }
private void on_iq_set(XmppStream stream, Iq.Stanza iq) { private async void on_iq_set(XmppStream stream, Iq.Stanza iq) {
StanzaNode? block_node = iq.stanza.get_subnode("block", NS_URI); StanzaNode? block_node = iq.stanza.get_subnode("block", NS_URI);
StanzaNode? unblock_node = iq.stanza.get_subnode("unblock", NS_URI); StanzaNode? unblock_node = iq.stanza.get_subnode("unblock", NS_URI);
Gee.List<string> jids; Gee.List<string> jids;

View file

@ -6,13 +6,10 @@ namespace Xmpp.Xep.Ping {
public class Module : XmppStreamModule, Iq.Handler { public class Module : XmppStreamModule, Iq.Handler {
public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0199_ping"); public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0199_ping");
public delegate void OnResult(XmppStream stream); public async void send_ping(XmppStream stream, Jid jid) {
public void send_ping(XmppStream stream, Jid jid, owned OnResult? listener) { StanzaNode ping_node = new StanzaNode.build("ping", NS_URI).add_self_xmlns();
Iq.Stanza iq = new Iq.Stanza.get(new StanzaNode.build("ping", NS_URI).add_self_xmlns()); Iq.Stanza iq = new Iq.Stanza.get(ping_node) { to=jid };
iq.to = jid; yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq);
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, (stream) => {
if (listener != null) listener(stream);
});
} }
public override void attach(XmppStream stream) { public override void attach(XmppStream stream) {
@ -25,8 +22,8 @@ namespace Xmpp.Xep.Ping {
stream.get_module(ServiceDiscovery.Module.IDENTITY).remove_feature(stream, NS_URI); stream.get_module(ServiceDiscovery.Module.IDENTITY).remove_feature(stream, NS_URI);
} }
public void on_iq_get(XmppStream stream, Iq.Stanza iq) { public async void on_iq_get(XmppStream stream, Iq.Stanza iq) {
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, new Iq.Stanza.result(iq)); yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, new Iq.Stanza.result(iq));
} }
public override string get_ns() { return NS_URI; } public override string get_ns() { return NS_URI; }

View file

@ -7,14 +7,14 @@ public class Module : XmppStreamModule {
private ReceivedPipelineListener received_pipeline_listener = new ReceivedPipelineListener(); private ReceivedPipelineListener received_pipeline_listener = new ReceivedPipelineListener();
public void enable(XmppStream stream) { public async void enable(XmppStream stream) {
Iq.Stanza iq = new Iq.Stanza.set(new StanzaNode.build("enable", NS_URI).add_self_xmlns()); Iq.Stanza iq = new Iq.Stanza.set(new StanzaNode.build("enable", NS_URI).add_self_xmlns());
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq); yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq);
} }
public void disable(XmppStream stream) { public async void disable(XmppStream stream) {
Iq.Stanza iq = new Iq.Stanza.set(new StanzaNode.build("disable", NS_URI).add_self_xmlns()); Iq.Stanza iq = new Iq.Stanza.set(new StanzaNode.build("disable", NS_URI).add_self_xmlns());
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq); yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq);
} }
public override void attach(XmppStream stream) { public override void attach(XmppStream stream) {

View file

@ -56,18 +56,10 @@ public class Module : XmppStreamModule {
if (stream.get_flag(Flag.IDENTITY) == null) return null; if (stream.get_flag(Flag.IDENTITY) == null) return null;
var query_node = crate_base_query(stream, jid, query_id, start_time, end_time); var query_node = crate_base_query(stream, jid, query_id, start_time, end_time);
query_node.put_node(create_set_rsm_node(end_id)); query_node.put_node(create_set_rsm_node(end_id));
Iq.Stanza iq = new Iq.Stanza.set(query_node); Iq.Stanza iq = new Iq.Stanza.set(query_node);
Iq.Stanza? result_iq = null; return yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq);
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, (stream, iq) => {
result_iq = iq;
Idle.add(query_archive.callback);
});
yield;
return result_iq;
} }
public override void attach(XmppStream stream) { public override void attach(XmppStream stream) {
@ -98,14 +90,7 @@ public class Module : XmppStreamModule {
Iq.Stanza paging_iq = new Iq.Stanza.set(query_node); Iq.Stanza paging_iq = new Iq.Stanza.set(query_node);
Iq.Stanza? result_iq = null; return yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, paging_iq);
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, paging_iq, (stream, iq) => {
result_iq = iq;
Idle.add(page_through_results.callback);
});
yield;
return result_iq;
} }
private async void query_availability(XmppStream stream) { private async void query_availability(XmppStream stream) {