aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfiaxh <git@mx.ax.lt>2017-06-13 18:14:59 +0200
committerfiaxh <git@mx.ax.lt>2017-06-13 20:12:40 +0200
commit7bbbb738fdb233f4ad91ffdd7d9247b28849d715 (patch)
tree649ac26e3feef6bae614442a7f3d6ee1057336e0
parentdabc2a8b1d2a7bf2019e5f913c736d80f11ceb53 (diff)
downloaddino-7bbbb738fdb233f4ad91ffdd7d9247b28849d715.tar.gz
dino-7bbbb738fdb233f4ad91ffdd7d9247b28849d715.zip
Get rid of manual storage objects for delegates
-rw-r--r--libdino/src/service/connection_manager.vala27
-rw-r--r--libdino/src/service/message_processor.vala18
-rw-r--r--libdino/src/service/muc_manager.vala44
-rw-r--r--main/src/ui/add_conversation/conference/conference_list.vala14
-rw-r--r--main/src/ui/contact_details/muc_config_form_provider.vala13
-rw-r--r--plugins/omemo/src/stream_module.vala21
-rw-r--r--xmpp-vala/src/module/bind.vala8
-rw-r--r--xmpp-vala/src/module/iq/module.vala16
-rw-r--r--xmpp-vala/src/module/xep/0004_data_forms.vala19
-rw-r--r--xmpp-vala/src/module/xep/0030_service_discovery/module.vala29
-rw-r--r--xmpp-vala/src/module/xep/0045_muc/module.vala58
-rw-r--r--xmpp-vala/src/module/xep/0048_bookmarks/module.vala57
-rw-r--r--xmpp-vala/src/module/xep/0049_private_xml_storage.vala26
-rw-r--r--xmpp-vala/src/module/xep/0054_vcard/module.vala5
-rw-r--r--xmpp-vala/src/module/xep/0060_pubsub.vala43
-rw-r--r--xmpp-vala/src/module/xep/0084_user_avatars.vala10
-rw-r--r--xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala10
-rw-r--r--xmpp-vala/src/module/xep/0199_ping.vala14
18 files changed, 178 insertions, 254 deletions
diff --git a/libdino/src/service/connection_manager.vala b/libdino/src/service/connection_manager.vala
index 03c97bdb..509964b3 100644
--- a/libdino/src/service/connection_manager.vala
+++ b/libdino/src/service/connection_manager.vala
@@ -178,7 +178,7 @@ public class ConnectionManager {
return;
}
if (network_manager != null && network_manager.State != NetworkManager.CONNECTED_GLOBAL) {
- wait_sec = 60;
+ wait_sec = 30;
}
print(@"recovering in $wait_sec\n");
Timeout.add_seconds(wait_sec, () => {
@@ -194,13 +194,17 @@ public class ConnectionManager {
}
private void check_reconnect(Account account) {
- PingResponseListenerImpl ping_response_listener = new PingResponseListenerImpl(this, account);
+ bool acked = false;
+
Core.XmppStream stream = connections[account].stream;
- stream.get_module(Xep.Ping.Module.IDENTITY).send_ping(stream, account.domainpart, ping_response_listener);
+ stream.get_module(Xep.Ping.Module.IDENTITY).send_ping(stream, account.domainpart, (stream) => {
+ acked = true;
+ change_connection_state(account, ConnectionState.CONNECTED);
+ });
Timeout.add_seconds(5, () => {
if (connections[account].stream != stream) return false;
- if (ping_response_listener.acked) return false;
+ if (acked) return false;
change_connection_state(account, ConnectionState.DISCONNECTED);
try {
@@ -210,21 +214,6 @@ public class ConnectionManager {
});
}
- private class PingResponseListenerImpl : Xep.Ping.ResponseListener, Object {
- public bool acked = false;
- ConnectionManager outer;
- Account account;
- public PingResponseListenerImpl(ConnectionManager outer, Account account) {
- this.outer = outer;
- this.account = account;
- }
- public void on_result(Core.XmppStream stream) {
- print("ping ok\n");
- acked = true;
- outer.change_connection_state(account, ConnectionState.CONNECTED);
- }
- }
-
private void on_nm_state_changed(uint32 state) {
print("nm " + state.to_string() + "\n");
if (state == NetworkManager.CONNECTED_GLOBAL) {
diff --git a/libdino/src/service/message_processor.vala b/libdino/src/service/message_processor.vala
index ccaec915..390199d5 100644
--- a/libdino/src/service/message_processor.vala
+++ b/libdino/src/service/message_processor.vala
@@ -118,23 +118,21 @@ public class MessageProcessor : StreamInteractionModule, Object {
}
} else {
Core.XmppStream stream = stream_interactor.get_stream(account);
- if (stream != null) stream.get_module(Xep.ServiceDiscovery.Module.IDENTITY).get_entity_categories(stream, message.counterpart.bare_jid.to_string(), (stream, identities, store) => {
- Triple<MessageProcessor, Entities.Message, Xmpp.Message.Stanza> triple = store as Triple<MessageProcessor, Entities.Message, Xmpp.Message.Stanza>;
- Entities.Message m = triple.b;
+ if (stream != null) stream.get_module(Xep.ServiceDiscovery.Module.IDENTITY).get_entity_categories(stream, message.counterpart.bare_jid.to_string(), (stream, identities) => {
if (identities == null) {
- m.type_ = Entities.Message.Type.CHAT;
- triple.a.process_message(m, triple.c);
+ message.type_ = Entities.Message.Type.CHAT;
+ process_message(message, message_stanza);
return;
}
foreach (Xep.ServiceDiscovery.Identity identity in identities) {
if (identity.category == Xep.ServiceDiscovery.Identity.CATEGORY_CONFERENCE) {
- m.type_ = Entities.Message.Type.GROUPCHAT_PM;
+ message.type_ = Entities.Message.Type.GROUPCHAT_PM;
} else {
- m.type_ = Entities.Message.Type.CHAT;
+ message.type_ = Entities.Message.Type.CHAT;
}
- triple.a.process_message(m, triple.c);
+ process_message(message, message_stanza);
}
- }, Triple.create(this, message, message_stanza));
+ });
}
}
}
@@ -185,4 +183,4 @@ public class MessageProcessor : StreamInteractionModule, Object {
}
}
-} \ No newline at end of file
+}
diff --git a/libdino/src/service/muc_manager.vala b/libdino/src/service/muc_manager.vala
index 2c916c99..c6f37116 100644
--- a/libdino/src/service/muc_manager.vala
+++ b/libdino/src/service/muc_manager.vala
@@ -48,14 +48,13 @@ public class MucManager : StreamInteractionModule, Object {
if (conversation != null) stream_interactor.get_module(ConversationManager.IDENTITY).close_conversation(conversation);
}
- [CCode (has_target = false)] public delegate void OnResult(Jid jid, Xep.DataForms.DataForm data_form, Object? store);
- public void get_config_form(Account account, Jid jid, OnResult on_result, Object? store) {
+ public delegate void OnResult(Jid jid, Xep.DataForms.DataForm data_form);
+ public void get_config_form(Account account, Jid jid, owned OnResult listener) {
Core.XmppStream? stream = stream_interactor.get_stream(account);
if (stream == null) return;
- stream.get_module(Xep.Muc.Module.IDENTITY).get_config_form(stream, jid.to_string(), (stream, jid, data_form, store) => {
- Tuple<OnResult, Object?> tuple = store as Tuple<OnResult, Object?>;
- tuple.a(new Jid(jid), data_form, tuple.b);
- }, Tuple.create(on_result, store));
+ stream.get_module(Xep.Muc.Module.IDENTITY).get_config_form(stream, jid.to_string(), (stream, jid, data_form) => {
+ listener(new Jid(jid), data_form);
+ });
}
public void change_subject(Account account, Jid jid, string subject) {
@@ -109,11 +108,9 @@ public class MucManager : StreamInteractionModule, Object {
return is_groupchat(jid.bare_jid, account) && jid.is_full();
}
- public void get_bookmarks(Account account, Xep.Bookmarks.Module.OnResult listener, Object? store) {
+ public void get_bookmarks(Account account, owned Xep.Bookmarks.Module.OnResult listener) {
Core.XmppStream? stream = stream_interactor.get_stream(account);
- if (stream != null) {
- stream.get_module(Xep.Bookmarks.Module.IDENTITY).get_conferences(stream, listener, store);
- }
+ if (stream != null) stream.get_module(Xep.Bookmarks.Module.IDENTITY).get_conferences(stream, (owned)listener);
}
public void add_bookmark(Account account, Xep.Bookmarks.Conference conference) {
@@ -223,17 +220,14 @@ public class MucManager : StreamInteractionModule, Object {
}
private void on_stream_negotiated(Account account, Core.XmppStream stream) {
- stream.get_module(Xep.Bookmarks.Module.IDENTITY).get_conferences(stream, (stream, conferences, o) => {
- Tuple<MucManager, Account> tuple = o as Tuple<MucManager, Account>;
- MucManager outer_ = tuple.a;
- Account account_ = tuple.b;
+ stream.get_module(Xep.Bookmarks.Module.IDENTITY).get_conferences(stream, (stream, conferences) => {
foreach (Xep.Bookmarks.Conference bookmark in conferences) {
Jid jid = new Jid(bookmark.jid);
if (bookmark.autojoin) {
- outer_.join(account_, jid, bookmark.nick, bookmark.password);
+ join(account, jid, bookmark.nick, bookmark.password);
}
}
- }, Tuple.create(this, account));
+ });
}
private void on_pre_message_received(Entities.Message message, Xmpp.Message.Stanza message_stanza, Conversation conversation) {
@@ -292,11 +286,10 @@ public class MucManager : StreamInteractionModule, Object {
}
private void set_autojoin(Core.XmppStream stream, Jid jid, string? nick, string? password) {
- stream.get_module(Xep.Bookmarks.Module.IDENTITY).get_conferences(stream, (stream, conferences, storage) => {
- Triple<Jid, string?, string?> triple = storage as Triple<Jid, string?, string?>;
- Xep.Bookmarks.Conference changed = new Xep.Bookmarks.Conference(triple.a.to_string()) { nick=triple.b, password=triple.c, autojoin=true };
+ stream.get_module(Xep.Bookmarks.Module.IDENTITY).get_conferences(stream, (stream, conferences) => {
+ Xep.Bookmarks.Conference changed = new Xep.Bookmarks.Conference(jid.to_string()) { nick=nick, password=password, autojoin=true };
foreach (Xep.Bookmarks.Conference conference in conferences) {
- if (conference.jid == triple.a.bare_jid.to_string() && conference.nick == triple.b && conference.password == triple.c) {
+ if (conference.jid == jid.bare_jid.to_string() && conference.nick == nick && conference.password == password) {
if (!conference.autojoin) {
stream.get_module(Xep.Bookmarks.Module.IDENTITY).replace_conference(stream, conference, changed);
}
@@ -304,22 +297,21 @@ public class MucManager : StreamInteractionModule, Object {
}
}
stream.get_module(Xep.Bookmarks.Module.IDENTITY).add_conference(stream, changed);
- }, Triple.create(jid, nick, password));
+ });
}
private void unset_autojoin(Core.XmppStream stream, Jid jid) {
- stream.get_module(Xep.Bookmarks.Module.IDENTITY).get_conferences(stream, (stream, conferences, storage) => {
- Jid jid_ = storage as Jid;
+ stream.get_module(Xep.Bookmarks.Module.IDENTITY).get_conferences(stream, (stream, conferences) => {
foreach (Xep.Bookmarks.Conference conference in conferences) {
- if (conference.jid == jid_.bare_jid.to_string()) {
+ if (conference.jid == jid.bare_jid.to_string()) {
if (conference.autojoin) {
Xep.Bookmarks.Conference change = new Xep.Bookmarks.Conference(conference.jid) { nick=conference.nick, password=conference.password, autojoin=false };
stream.get_module(Xep.Bookmarks.Module.IDENTITY).replace_conference(stream, conference, change);
}
}
}
- }, jid);
+ });
}
}
-} \ No newline at end of file
+}
diff --git a/main/src/ui/add_conversation/conference/conference_list.vala b/main/src/ui/add_conversation/conference/conference_list.vala
index ac74fa3a..1f4abfa3 100644
--- a/main/src/ui/add_conversation/conference/conference_list.vala
+++ b/main/src/ui/add_conversation/conference/conference_list.vala
@@ -29,7 +29,7 @@ protected class ConferenceList : FilterableList {
});
foreach (Account account in stream_interactor.get_accounts()) {
- stream_interactor.get_module(MucManager.IDENTITY).get_bookmarks(account, on_conference_bookmarks_received, Tuple.create(this, account));
+ stream_interactor.get_module(MucManager.IDENTITY).get_bookmarks(account, (stream, conferences) => { on_conference_bookmarks_received(stream, account, conferences); });
}
}
@@ -42,13 +42,11 @@ protected class ConferenceList : FilterableList {
}
}
- private static void on_conference_bookmarks_received(Core.XmppStream stream, Gee.List<Xep.Bookmarks.Conference> conferences, Object? o) {
+ private void on_conference_bookmarks_received(Core.XmppStream stream, Account account, Gee.List<Xep.Bookmarks.Conference> conferences) {
Idle.add(() => {
- Tuple<ConferenceList, Account> tuple = o as Tuple<ConferenceList, Account>;
- ConferenceList list = tuple.a;
- Account account = tuple.b;
- list.lists[account] = conferences;
- list.refresh_conferences(); return false;
+ lists[account] = conferences;
+ refresh_conferences();
+ return false;
});
}
@@ -102,4 +100,4 @@ internal class ConferenceListRow : ListRow {
}
}
-} \ No newline at end of file
+}
diff --git a/main/src/ui/contact_details/muc_config_form_provider.vala b/main/src/ui/contact_details/muc_config_form_provider.vala
index 2986134a..41df4465 100644
--- a/main/src/ui/contact_details/muc_config_form_provider.vala
+++ b/main/src/ui/contact_details/muc_config_form_provider.vala
@@ -18,19 +18,16 @@ public class MucConfigFormProvider : Plugins.ContactDetailsProvider {
if (conversation.type_ == Conversation.Type.GROUPCHAT) {
Xmpp.Core.XmppStream? stream = stream_interactor.get_stream(conversation.account);
if (stream == null) return;
- stream_interactor.get_module(MucManager.IDENTITY).get_config_form(conversation.account, conversation.counterpart, (jid, data_form, store) => {
- Plugins.ContactDetails contact_details_ = store as Plugins.ContactDetails;
- contact_details_.save.connect(() => {
- data_form.submit();
- });
+ stream_interactor.get_module(MucManager.IDENTITY).get_config_form(conversation.account, conversation.counterpart, (jid, data_form) => {
+ contact_details.save.connect(() => { data_form.submit(); });
Idle.add(() => {
for (int i = 0; i < data_form.fields.size; i++) {
DataForms.DataForm.Field field = data_form.fields[i];
- add_field(field, contact_details_);
+ add_field(field, contact_details);
}
return false;
});
- }, contact_details);
+ });
}
}
@@ -128,4 +125,4 @@ public class MucConfigFormProvider : Plugins.ContactDetailsProvider {
}
}
-} \ No newline at end of file
+}
diff --git a/plugins/omemo/src/stream_module.vala b/plugins/omemo/src/stream_module.vala
index 8dc0dfc5..f6ba82e6 100644
--- a/plugins/omemo/src/stream_module.vala
+++ b/plugins/omemo/src/stream_module.vala
@@ -119,7 +119,7 @@ public class StreamModule : XmppStreamModule {
this.store = Plugin.get_context().create_store();
store_created(store);
stream.get_module(Message.Module.IDENTITY).pre_received_message.connect(on_pre_received_message);
- stream.get_module(Pubsub.Module.IDENTITY).add_filtered_notification(stream, NODE_DEVICELIST, (stream, jid, id, node, obj) => ((StreamModule)obj).on_devicelist(stream, jid, id, node), this);
+ stream.get_module(Pubsub.Module.IDENTITY).add_filtered_notification(stream, NODE_DEVICELIST, (stream, jid, id, node) => on_devicelist(stream, jid, id, node));
}
private void on_pre_received_message(XmppStream stream, Message.Stanza message) {
@@ -185,7 +185,7 @@ public class StreamModule : XmppStreamModule {
public void request_user_devicelist(XmppStream stream, string jid) {
if (active_devicelist_requests.add(jid)) {
if (Plugin.DEBUG) print(@"OMEMO: requesting device list for $jid\n");
- stream.get_module(Pubsub.Module.IDENTITY).request(stream, jid, NODE_DEVICELIST, (stream, jid, id, node, obj) => ((StreamModule)obj).on_devicelist(stream, jid, id ?? "", node), this);
+ stream.get_module(Pubsub.Module.IDENTITY).request(stream, jid, NODE_DEVICELIST, (stream, jid, id, node) => on_devicelist(stream, jid, id ?? "", node));
}
}
@@ -243,7 +243,9 @@ public class StreamModule : XmppStreamModule {
public void start_session_with(XmppStream stream, string bare_jid, int device_id) {
if (active_bundle_requests.add(bare_jid + @":$device_id")) {
if (Plugin.DEBUG) print(@"OMEMO: Asking for bundle from $bare_jid:$device_id\n");
- stream.get_module(Pubsub.Module.IDENTITY).request(stream, bare_jid, @"$NODE_BUNDLES:$device_id", on_other_bundle_result, Tuple.create(store, device_id));
+ stream.get_module(Pubsub.Module.IDENTITY).request(stream, bare_jid, @"$NODE_BUNDLES:$device_id", (stream, jid, id, node) => {
+ on_other_bundle_result(stream, jid, device_id, id, node);
+ });
}
}
@@ -269,11 +271,7 @@ public class StreamModule : XmppStreamModule {
}
}
- private static void on_other_bundle_result(XmppStream stream, string jid, string? id, StanzaNode? node, Object? storage) {
- Tuple<Store, int> tuple = (Tuple<Store, int>)storage;
- Store store = tuple.a;
- int device_id = tuple.b;
-
+ private void on_other_bundle_result(XmppStream stream, string jid, int device_id, string? id, StanzaNode? node) {
bool fail = false;
if (node == null) {
// Device not registered, shouldn't exist
@@ -315,13 +313,12 @@ public class StreamModule : XmppStreamModule {
public void publish_bundles_if_needed(XmppStream stream, string jid) {
if (active_bundle_requests.add(jid + @":$(store.local_registration_id)")) {
- stream.get_module(Pubsub.Module.IDENTITY).request(stream, jid, @"$NODE_BUNDLES:$(store.local_registration_id)", on_self_bundle_result, store);
+ stream.get_module(Pubsub.Module.IDENTITY).request(stream, jid, @"$NODE_BUNDLES:$(store.local_registration_id)", on_self_bundle_result);
}
}
- private static void on_self_bundle_result(XmppStream stream, string jid, string? id, StanzaNode? node, Object? storage) {
+ private void on_self_bundle_result(XmppStream stream, string jid, string? id, StanzaNode? node) {
if (!Plugin.ensure_context()) return;
- Store store = (Store)storage;
Map<int, ECPublicKey> keys = new HashMap<int, ECPublicKey>();
ECPublicKey? identity_key = null;
int32 signed_pre_key_id = -1;
@@ -426,4 +423,4 @@ public class StreamModule : XmppStreamModule {
}
}
-} \ No newline at end of file
+}
diff --git a/xmpp-vala/src/module/bind.vala b/xmpp-vala/src/module/bind.vala
index f4b1a948..5a611875 100644
--- a/xmpp-vala/src/module/bind.vala
+++ b/xmpp-vala/src/module/bind.vala
@@ -34,7 +34,9 @@ namespace Xmpp.Bind {
var flag = new Flag();
StanzaNode bind_node = new StanzaNode.build("bind", NS_URI).add_self_xmlns();
bind_node.put_node(new StanzaNode.build("resource", NS_URI).put_node(new StanzaNode.text(requested_resource)));
- stream.get_module(Iq.Module.IDENTITY).send_iq(stream, new Iq.Stanza.set(bind_node), on_bind_response);
+ stream.get_module(Iq.Module.IDENTITY).send_iq(stream, new Iq.Stanza.set(bind_node), (stream, iq) => {
+ stream.get_module(Bind.Module.IDENTITY).iq_response_stanza(stream, iq);
+ });
stream.add_flag(flag);
}
}
@@ -62,10 +64,6 @@ namespace Xmpp.Bind {
public override string get_ns() { return NS_URI; }
public override string get_id() { return IDENTITY.id; }
-
- private static void on_bind_response(XmppStream stream, Iq.Stanza iq) {
- stream.get_module(Bind.Module.IDENTITY).iq_response_stanza(stream, iq);
- }
}
public class Flag : XmppStreamFlag {
diff --git a/xmpp-vala/src/module/iq/module.vala b/xmpp-vala/src/module/iq/module.vala
index 6cd474ca..c3b7bffe 100644
--- a/xmpp-vala/src/module/iq/module.vala
+++ b/xmpp-vala/src/module/iq/module.vala
@@ -11,15 +11,15 @@ namespace Xmpp.Iq {
private HashMap<string, ResponseListener> responseListeners = new HashMap<string, ResponseListener>();
private HashMap<string, ArrayList<Handler>> namespaceRegistrants = new HashMap<string, ArrayList<Handler>>();
- [CCode (has_target = false)] public delegate void OnResult(XmppStream stream, Iq.Stanza iq, Object? store);
- public void send_iq(XmppStream stream, Iq.Stanza iq, OnResult? listener = null, Object? store = null) {
+ 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");
}
if (listener != null) {
- responseListeners[iq.id] = new ResponseListener(listener, store);
+ responseListeners[iq.id] = new ResponseListener((owned) listener);
}
}
@@ -56,7 +56,7 @@ namespace Xmpp.Iq {
if (responseListeners.has_key(iq.id)) {
ResponseListener? listener = responseListeners.get(iq.id);
if (listener != null) {
- listener.on_result(stream, iq, listener.reference);
+ listener.on_result(stream, iq);
}
responseListeners.unset(iq.id);
}
@@ -79,12 +79,10 @@ namespace Xmpp.Iq {
}
private class ResponseListener {
- public OnResult on_result { get; private set; }
- public Object? reference { get; private set; }
+ public OnResult on_result { get; private owned set; }
- public ResponseListener(OnResult on_result, Object? reference = null) {
- this.on_result = on_result;
- this.reference = reference;
+ public ResponseListener(owned OnResult on_result) {
+ this.on_result = (owned) on_result;
}
}
}
diff --git a/xmpp-vala/src/module/xep/0004_data_forms.vala b/xmpp-vala/src/module/xep/0004_data_forms.vala
index add2fa9a..a0e8cd43 100644
--- a/xmpp-vala/src/module/xep/0004_data_forms.vala
+++ b/xmpp-vala/src/module/xep/0004_data_forms.vala
@@ -13,17 +13,16 @@ public class DataForm {
public XmppStream stream;
public OnResult on_result;
- public Object? store;
public void cancel() {
StanzaNode stanza_node = new StanzaNode.build("x", NS_URI);
stanza_node.add_self_xmlns().set_attribute("type", "cancel");
- on_result(stream, stanza_node, store);
+ on_result(stream, stanza_node);
}
public void submit() {
stanza_node.set_attribute("type", "submit");
- on_result(stream, stanza_node, store);
+ on_result(stream, stanza_node);
}
public enum Type {
@@ -170,11 +169,11 @@ public class DataForm {
// TODO text-multi
- internal DataForm(StanzaNode node, XmppStream stream, OnResult on_result, Object? store) {
+ internal DataForm(StanzaNode node, XmppStream stream, owned OnResult listener) {
this.stanza_node = node;
this.stream = stream;
- this.on_result = on_result;
- this.store = store;
+ this.on_result = (owned)listener;
+
Gee.List<StanzaNode> field_nodes = node.get_subnodes("field", NS_URI);
foreach (StanzaNode field_node in field_nodes) {
string? type = field_node.get_attribute("type", NS_URI);
@@ -199,10 +198,10 @@ public class DataForm {
}
}
- [CCode (has_target = false)] public delegate void OnResult(XmppStream stream, StanzaNode node, Object? store);
- public static DataForm? create(XmppStream stream, StanzaNode node, OnResult on_result, Object? store) {
- return new DataForm(node, stream, on_result, store);
+ public delegate void OnResult(XmppStream stream, StanzaNode node);
+ public static DataForm? create(XmppStream stream, StanzaNode node, owned OnResult listener) {
+ return new DataForm(node, stream, (owned)listener);
}
}
-} \ No newline at end of file
+}
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 2ec0f630..d8852735 100644
--- a/xmpp-vala/src/module/xep/0030_service_discovery/module.vala
+++ b/xmpp-vala/src/module/xep/0030_service_discovery/module.vala
@@ -29,32 +29,29 @@ public class Module : XmppStreamModule, Iq.Handler {
identities.add(new Identity(category, type, name));
}
- [CCode (has_target = false)] public delegate void HasEntryCategoryRes(XmppStream stream, ArrayList<Identity>? identities, Object? store);
- public void get_entity_categories(XmppStream stream, string jid, HasEntryCategoryRes on_result, Object? store) {
+ public delegate void HasEntryCategoryRes(XmppStream stream, ArrayList<Identity>? identities);
+ public void get_entity_categories(XmppStream stream, string jid, owned HasEntryCategoryRes listener) {
ArrayList<Identity>? res = stream.get_flag(Flag.IDENTITY).get_entity_categories(jid);
- if (res != null) on_result(stream, res, store);
- request_info(stream, jid, (stream, query_result, store) => {
- Tuple<HasEntryCategoryRes, Object> tuple = store as Tuple<HasEntryCategoryRes, Object>;
- tuple.a(stream, query_result != null ? query_result.identities : null, tuple.b);
- }, Tuple.create(on_result, store));
+ if (res != null) listener(stream, res);
+ request_info(stream, jid, (stream, query_result) => {
+ listener(stream, query_result != null ? query_result.identities : null);
+ });
}
- [CCode (has_target = false)] public delegate void OnInfoResult(XmppStream stream, InfoResult? query_result, Object? store);
- public void request_info(XmppStream stream, string jid, OnInfoResult listener, Object? store) {
+ public delegate void OnInfoResult(XmppStream stream, InfoResult? query_result);
+ public void request_info(XmppStream stream, string jid, owned OnInfoResult listener) {
Iq.Stanza iq = new Iq.Stanza.get(new StanzaNode.build("query", NS_URI_INFO).add_self_xmlns());
iq.to = jid;
- stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, (stream, iq, o) => {
- Tuple<OnInfoResult, Object> tuple = o as Tuple<OnInfoResult, Object>;
- OnInfoResult on_result = tuple.a;
+ stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, (stream, iq) => {
InfoResult? result = InfoResult.create_from_iq(iq);
stream.get_flag(Flag.IDENTITY).set_entity_features(iq.from, result != null ? result.features : null);
stream.get_flag(Flag.IDENTITY).set_entity_identities(iq.from, result != null ? result.identities : null);
- on_result(stream, result, tuple.b);
- }, Tuple.create(listener, store));
+ listener(stream, result);
+ });
}
- [CCode (has_target = false)] public delegate void OnItemsResult(XmppStream stream, ItemsResult query_result);
- public void request_items(XmppStream stream, string jid, OnItemsResult listener, Object? store) {
+ public delegate void OnItemsResult(XmppStream stream, ItemsResult query_result);
+ public void request_items(XmppStream stream, string jid, owned OnItemsResult listener) {
Iq.Stanza iq = new Iq.Stanza.get(new StanzaNode.build("query", NS_URI_ITEMS).add_self_xmlns());
iq.to = jid;
stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq);
diff --git a/xmpp-vala/src/module/xep/0045_muc/module.vala b/xmpp-vala/src/module/xep/0045_muc/module.vala
index 79870ee1..82a7d7a6 100644
--- a/xmpp-vala/src/module/xep/0045_muc/module.vala
+++ b/xmpp-vala/src/module/xep/0045_muc/module.vala
@@ -136,17 +136,22 @@ public class Module : XmppStreamModule {
return true;
}
- [CCode (has_target = false)] public delegate void OnConfigFormResult(XmppStream stream, string jid, DataForms.DataForm data_form, Object? store);
- public void get_config_form(XmppStream stream, string jid, OnConfigFormResult listener, Object? store) {
- Iq.Stanza iq = new Iq.Stanza.get(new StanzaNode.build("query", NS_URI_OWNER).add_self_xmlns()) { to=jid };
- stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, (stream, iq, store) => {
- Tuple<OnConfigFormResult, Object?> tuple = store as Tuple<OnConfigFormResult, Object?>;
- StanzaNode? x_node = iq.stanza.get_deep_subnode(NS_URI_OWNER + ":query", DataForms.NS_URI + ":x");
+ public delegate void OnConfigFormResult(XmppStream stream, string jid, DataForms.DataForm data_form);
+ public void get_config_form(XmppStream stream, string jid, owned OnConfigFormResult listener) {
+ Iq.Stanza get_iq = new Iq.Stanza.get(new StanzaNode.build("query", NS_URI_OWNER).add_self_xmlns()) { to=jid };
+ stream.get_module(Iq.Module.IDENTITY).send_iq(stream, get_iq, (stream, form_iq) => {
+ StanzaNode? x_node = form_iq.stanza.get_deep_subnode(NS_URI_OWNER + ":query", DataForms.NS_URI + ":x");
if (x_node != null) {
- DataForms.DataForm data_form = DataForms.DataForm.create(stream, x_node, on_config_form_result, iq);
- tuple.a(stream, iq.from, data_form, tuple.b);
+ DataForms.DataForm data_form = DataForms.DataForm.create(stream, x_node, (stream, node) => {
+ StanzaNode stanza_node = new StanzaNode.build("query", NS_URI_OWNER);
+ stanza_node.add_self_xmlns().put_node(node);
+ Iq.Stanza set_iq = new Iq.Stanza.set(stanza_node);
+ set_iq.to = form_iq.from;
+ stream.get_module(Iq.Module.IDENTITY).send_iq(stream, set_iq);
+ });
+ listener(stream, form_iq.from, data_form);
}
- }, Tuple.create(listener, store));
+ });
}
public override void attach(XmppStream stream) {
@@ -162,9 +167,9 @@ public class Module : XmppStreamModule {
}
room_entered.connect((stream, jid, nick) => {
- query_affiliation(stream, jid, "member", null, null);
- query_affiliation(stream, jid, "admin", null, null);
- query_affiliation(stream, jid, "owner", null, null);
+ query_affiliation(stream, jid, "member", null);
+ query_affiliation(stream, jid, "admin", null);
+ query_affiliation(stream, jid, "owner", null);
});
}
@@ -208,9 +213,7 @@ public class Module : XmppStreamModule {
string bare_jid = get_bare_jid(presence.from);
ErrorStanza? error_stanza = presence.get_error();
if (flag.get_enter_id(bare_jid) == presence.id) {
- print("is enter id\n");
MucEnterError? error = null;
- print(@"$(error_stanza.condition) $(error_stanza.type_)\n");
switch (error_stanza.condition) {
case ErrorStanza.CONDITION_NOT_AUTHORIZED:
if (ErrorStanza.TYPE_AUTH == error_stanza.type_) error = MucEnterError.PASSWORD_REQUIRED;
@@ -305,8 +308,7 @@ public class Module : XmppStreamModule {
}
private void query_room_info(XmppStream stream, string jid) {
- stream.get_module(ServiceDiscovery.Module.IDENTITY).request_info(stream, jid, (stream, query_result, store) => {
- Tuple<string, string> tuple = store as Tuple<string, string>;
+ stream.get_module(ServiceDiscovery.Module.IDENTITY).request_info(stream, jid, (stream, query_result) => {
Gee.List<Feature> features = new ArrayList<Feature>();
if (query_result != null) {
@@ -333,20 +335,19 @@ public class Module : XmppStreamModule {
if (parsed != null) features.add(parsed);
}
}
- stream.get_flag(Flag.IDENTITY).set_room_features(tuple.a, features);
- }, Tuple.create(jid, "")); //TODO ugly
+ stream.get_flag(Flag.IDENTITY).set_room_features(jid, features);
+ });
}
- [CCode (has_target = false)] public delegate void OnAffiliationResult(XmppStream stream, Gee.List<string> jids, Object? store);
- private void query_affiliation(XmppStream stream, string jid, string affiliation, OnAffiliationResult? on_result, Object? store) {
+ public delegate void OnAffiliationResult(XmppStream stream, Gee.List<string> jids);
+ private void query_affiliation(XmppStream stream, string jid, string affiliation, owned OnAffiliationResult? listener) {
Iq.Stanza iq = new Iq.Stanza.get(
new StanzaNode.build("query", NS_URI_ADMIN)
.add_self_xmlns()
.put_node(new StanzaNode.build("item", NS_URI_ADMIN)
.put_attribute("affiliation", affiliation))
) { to=jid };
- stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, (stream, iq, store) => {
- Tuple<OnAffiliationResult?, Object?> tuple = store as Tuple<OnAffiliationResult?, Object?>;
+ 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);
if (query_node == null) return;
@@ -360,17 +361,8 @@ public class Module : XmppStreamModule {
ret_jids.add(jid_);
}
}
- if (tuple.a != null) tuple.a(stream, ret_jids, tuple.b);
- }, Tuple.create(on_result, store));
- }
-
- public static void on_config_form_result(XmppStream stream, StanzaNode node, Object? store) {
- Iq.Stanza form_iq = store as Iq.Stanza;
- StanzaNode stanza_node = new StanzaNode.build("query", NS_URI_OWNER);
- stanza_node.add_self_xmlns().put_node(node);
- Iq.Stanza set_iq = new Iq.Stanza.set(stanza_node);
- set_iq.to = form_iq.from;
- stream.get_module(Iq.Module.IDENTITY).send_iq(stream, set_iq);
+ if (listener != null) listener(stream, ret_jids);
+ });
}
private static ArrayList<int> get_status_codes(StanzaNode x_node) {
diff --git a/xmpp-vala/src/module/xep/0048_bookmarks/module.vala b/xmpp-vala/src/module/xep/0048_bookmarks/module.vala
index 3612ac4b..6f42621a 100644
--- a/xmpp-vala/src/module/xep/0048_bookmarks/module.vala
+++ b/xmpp-vala/src/module/xep/0048_bookmarks/module.vala
@@ -10,15 +10,13 @@ public class Module : XmppStreamModule {
public signal void received_conferences(XmppStream stream, Gee.List<Conference> conferences);
- [CCode (has_target = false)] public delegate void OnResult(XmppStream stream, Gee.List<Conference> conferences, Object? storage);
- public void get_conferences(XmppStream stream, OnResult listener, Object? store) {
+ public delegate void OnResult(XmppStream stream, Gee.List<Conference> conferences);
+ public void get_conferences(XmppStream stream, owned OnResult listener) {
StanzaNode get_node = new StanzaNode.build("storage", NS_URI).add_self_xmlns();
- stream.get_module(PrivateXmlStorage.Module.IDENTITY).retrieve(stream, get_node, (stream, node, o) => {
- Tuple<OnResult, Object?> tuple = o as Tuple<OnResult, Object?>;
- OnResult on_result = tuple.a;
+ stream.get_module(PrivateXmlStorage.Module.IDENTITY).retrieve(stream, get_node, (stream, node) => {
Gee.List<Conference> conferences = get_conferences_from_stanza(node);
- on_result(stream, conferences, tuple.b);
- }, Tuple.create(listener, store));
+ listener(stream, conferences);
+ });
}
public void set_conferences(XmppStream stream, Gee.List<Conference> conferences) {
@@ -26,51 +24,46 @@ public class Module : XmppStreamModule {
foreach (Conference conference in conferences) {
storage_node.put_node(conference.stanza_node);
}
- stream.get_module(PrivateXmlStorage.Module.IDENTITY).store(stream, storage_node, (stream, o) => {
- stream.get_module(Module.IDENTITY).received_conferences(stream, o as ArrayList<Conference>);
- }, conferences);
+ stream.get_module(PrivateXmlStorage.Module.IDENTITY).store(stream, storage_node, (stream) => {
+ stream.get_module(Module.IDENTITY).received_conferences(stream, conferences);
+ });
}
- public void add_conference(XmppStream stream, Conference add_) {
- get_conferences(stream, (stream, conferences, o) => {
- Conference add = o as Conference;
- conferences.add(add);
+ public void add_conference(XmppStream stream, Conference conference) {
+ get_conferences(stream, (stream, conferences) => {
+ conferences.add(conference);
stream.get_module(Module.IDENTITY).set_conferences(stream, conferences);
- }, add_);
+ });
}
- public void replace_conference(XmppStream stream, Conference was_, Conference modified_) {
- get_conferences(stream, (stream, conferences, o) => {
- Tuple<Conference, Conference> tuple = o as Tuple<Conference, Conference>;
- Conference was = tuple.a;
- Conference modified = tuple.b;
+ public void replace_conference(XmppStream stream, Conference orig_conference, Conference modified_conference) {
+ get_conferences(stream, (stream, conferences) => {
foreach (Conference conference in conferences) {
- if (conference.autojoin == was.autojoin && conference.jid == was.jid &&
- conference.name == was.name && conference.nick == was.nick) {
- conference.autojoin = modified.autojoin;
- conference.jid = modified.jid;
- conference.name = modified.name;
- conference.nick = modified.nick;
+ if (conference.autojoin == orig_conference.autojoin && conference.jid == orig_conference.jid &&
+ conference.name == orig_conference.name && conference.nick == orig_conference.nick) {
+ conference.autojoin = modified_conference.autojoin;
+ conference.jid = modified_conference.jid;
+ conference.name = modified_conference.name;
+ conference.nick = modified_conference.nick;
break;
}
}
stream.get_module(Module.IDENTITY).set_conferences(stream, conferences);
- }, Tuple.create(was_, modified_));
+ });
}
- public void remove_conference(XmppStream stream, Conference conference_) {
- get_conferences(stream, (stream, conferences, o) => {
- Conference remove = o as Conference;
+ public void remove_conference(XmppStream stream, Conference conference_remove) {
+ get_conferences(stream, (stream, conferences) => {
Conference? rem = null;
foreach (Conference conference in conferences) {
- if (conference.name == remove.name && conference.jid == remove.jid && conference.autojoin == remove.autojoin) {
+ if (conference.name == conference_remove.name && conference.jid == conference_remove.jid && conference.autojoin == conference_remove.autojoin) {
rem = conference;
break;
}
}
if (rem != null) conferences.remove(rem);
stream.get_module(Module.IDENTITY).set_conferences(stream, conferences);
- }, conference_);
+ });
}
public override void attach(XmppStream stream) { }
diff --git a/xmpp-vala/src/module/xep/0049_private_xml_storage.vala b/xmpp-vala/src/module/xep/0049_private_xml_storage.vala
index fc8f5b4c..26a297b4 100644
--- a/xmpp-vala/src/module/xep/0049_private_xml_storage.vala
+++ b/xmpp-vala/src/module/xep/0049_private_xml_storage.vala
@@ -8,18 +8,22 @@ namespace Xmpp.Xep.PrivateXmlStorage {
public class Module : XmppStreamModule {
public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0049_private_xml_storage");
- [CCode (has_target = false)] public delegate void OnSuccess(XmppStream stream, Object? reference);
- public void store(XmppStream stream, StanzaNode node, OnSuccess listener, Object? reference) {
+ public delegate void OnSuccess(XmppStream stream);
+ public void store(XmppStream stream, StanzaNode node, owned OnSuccess listener) {
StanzaNode queryNode = new StanzaNode.build("query", NS_URI).add_self_xmlns().put_node(node);
Iq.Stanza iq = new Iq.Stanza.set(queryNode);
- stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, on_store_response, Tuple.create(listener, reference));
+ stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, (stream, iq) => {
+ listener(stream);
+ });
}
- [CCode (has_target = false)] public delegate void OnResponse(XmppStream stream, StanzaNode node, Object? reference);
- public void retrieve(XmppStream stream, StanzaNode node, OnResponse listener, Object? reference) {
+ public delegate void OnResponse(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);
Iq.Stanza iq = new Iq.Stanza.get(queryNode);
- stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, on_retrieve_response, Tuple.create(listener, reference));
+ stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, (stream, iq) => {
+ listener(stream, iq.stanza.get_subnode("query", NS_URI));
+ });
}
public override void attach(XmppStream stream) {
@@ -34,15 +38,5 @@ namespace Xmpp.Xep.PrivateXmlStorage {
public override string get_ns() { return NS_URI; }
public override string get_id() { return IDENTITY.id; }
-
- private static void on_store_response(XmppStream stream, Iq.Stanza iq, Object? o) {
- Tuple<OnSuccess, Object> tuple = o as Tuple<OnSuccess, Object>;
- tuple.a(stream, tuple.b);
- }
-
- private static void on_retrieve_response(XmppStream stream, Iq.Stanza iq, Object? o) {
- Tuple<OnResponse, Object> tuple = o as Tuple<OnResponse, Object>;
- tuple.a(stream, iq.stanza.get_subnode("query", NS_URI), tuple.b);
- }
}
}
diff --git a/xmpp-vala/src/module/xep/0054_vcard/module.vala b/xmpp-vala/src/module/xep/0054_vcard/module.vala
index 040e0646..b1ad3f48 100644
--- a/xmpp-vala/src/module/xep/0054_vcard/module.vala
+++ b/xmpp-vala/src/module/xep/0054_vcard/module.vala
@@ -52,12 +52,11 @@ public class Module : XmppStreamModule {
} else {
iq.to = get_bare_jid(presence.from);
}
- stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, on_received_vcard, storage);
+ stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, on_received_vcard);
}
}
- private static void on_received_vcard(XmppStream stream, Iq.Stanza iq, Object? storage_obj) {
- PixbufStorage? storage = storage_obj as PixbufStorage;
+ private void on_received_vcard(XmppStream stream, Iq.Stanza iq) {
if (iq.is_error()) return;
string? res = iq.stanza.get_deep_string_content(@"$NS_URI:vCard", "PHOTO", "BINVAL");
if (res == null) return;
diff --git a/xmpp-vala/src/module/xep/0060_pubsub.vala b/xmpp-vala/src/module/xep/0060_pubsub.vala
index 8ba66995..182e6ffe 100644
--- a/xmpp-vala/src/module/xep/0060_pubsub.vala
+++ b/xmpp-vala/src/module/xep/0060_pubsub.vala
@@ -11,16 +11,22 @@ namespace Xmpp.Xep.Pubsub {
private HashMap<string, EventListenerDelegate> event_listeners = new HashMap<string, EventListenerDelegate>();
- public void add_filtered_notification(XmppStream stream, string node, EventListenerDelegate.ResultFunc on_result, Object? reference = null) {
+ public void add_filtered_notification(XmppStream stream, string node, owned EventListenerDelegate.ResultFunc listener) {
stream.get_module(ServiceDiscovery.Module.IDENTITY).add_feature_notify(stream, node);
- event_listeners[node] = new EventListenerDelegate(on_result, reference);
+ event_listeners[node] = new EventListenerDelegate((owned)listener);
}
- [CCode (has_target = false)] public delegate void OnResult(XmppStream stream, string jid, string? id, StanzaNode? node, Object? storage);
- public void request(XmppStream stream, string jid, string node, OnResult listener, Object? store) { // TODO multiple nodes gehen auch
- Iq.Stanza a = new Iq.Stanza.get(new StanzaNode.build("pubsub", NS_URI).add_self_xmlns().put_node(new StanzaNode.build("items", NS_URI).put_attribute("node", node)));
- a.to = jid;
- stream.get_module(Iq.Module.IDENTITY).send_iq(stream, a, on_received_request_response, Tuple.create(listener, store));
+ public delegate void OnResult(XmppStream stream, string jid, string? id, StanzaNode? node);
+ public void request(XmppStream stream, string jid, string node, owned OnResult listener) { // TODO multiple nodes gehen auch
+ Iq.Stanza request_iq = new Iq.Stanza.get(new StanzaNode.build("pubsub", NS_URI).add_self_xmlns().put_node(new StanzaNode.build("items", NS_URI).put_attribute("node", node)));
+ request_iq.to = jid;
+ stream.get_module(Iq.Module.IDENTITY).send_iq(stream, request_iq, (stream, iq) => {
+ StanzaNode event_node = iq.stanza.get_subnode("pubsub", NS_URI);
+ StanzaNode items_node = event_node != null ? event_node.get_subnode("items", NS_URI) : null;
+ StanzaNode item_node = items_node != null ? items_node.get_subnode("item", NS_URI) : null;
+ string? id = item_node != null ? item_node.get_attribute("id", NS_URI) : null;
+ listener(stream, iq.from, id, item_node != null ? item_node.sub_nodes[0] : null);
+ });
}
public void publish(XmppStream stream, string? jid, string node_id, string node, string item_id, StanzaNode content) {
@@ -59,30 +65,17 @@ namespace Xmpp.Xep.Pubsub {
string node = items_node.get_attribute("node", NS_URI_EVENT);
string id = item_node.get_attribute("id", NS_URI_EVENT);
if (event_listeners.has_key(node)) {
- event_listeners[node].on_result(stream, message.from, id, item_node.sub_nodes[0], event_listeners[node].reference);
+ event_listeners[node].on_result(stream, message.from, id, item_node.sub_nodes[0]);
}
}
-
- private static void on_received_request_response(XmppStream stream, Iq.Stanza iq, Object? o) {
- Tuple<OnResult, Object?> tuple = o as Tuple<OnResult, Object?>;
- OnResult on_result = tuple.a;
- StanzaNode event_node = iq.stanza.get_subnode("pubsub", NS_URI);
- StanzaNode items_node = event_node != null ? event_node.get_subnode("items", NS_URI) : null;
- StanzaNode item_node = items_node != null ? items_node.get_subnode("item", NS_URI) : null;
- string? id = item_node != null ? item_node.get_attribute("id", NS_URI) : null;
- on_result(stream, iq.from, id, item_node != null ? item_node.sub_nodes[0] : null, tuple.b);
- }
}
public class EventListenerDelegate {
- [CCode (has_target = false)]
- public delegate void ResultFunc(XmppStream stream, string jid, string id, StanzaNode node, Object? object);
- public ResultFunc on_result { get; private set; }
- public Object? reference { get; private set; }
+ public delegate void ResultFunc(XmppStream stream, string jid, string id, StanzaNode? node);
+ public ResultFunc on_result { get; private owned set; }
- public EventListenerDelegate(ResultFunc on_result, Object? reference = null) {
- this.on_result = on_result;
- this.reference = reference;
+ public EventListenerDelegate(owned ResultFunc on_result) {
+ this.on_result = (owned) on_result;
}
}
}
diff --git a/xmpp-vala/src/module/xep/0084_user_avatars.vala b/xmpp-vala/src/module/xep/0084_user_avatars.vala
index f9bf057f..3648a88b 100644
--- a/xmpp-vala/src/module/xep/0084_user_avatars.vala
+++ b/xmpp-vala/src/module/xep/0084_user_avatars.vala
@@ -35,20 +35,19 @@ namespace Xmpp.Xep.UserAvatars {
public override void attach(XmppStream stream) {
Pubsub.Module.require(stream);
- stream.get_module(Pubsub.Module.IDENTITY).add_filtered_notification(stream, NS_URI_METADATA, on_event_result, storage);
+ stream.get_module(Pubsub.Module.IDENTITY).add_filtered_notification(stream, NS_URI_METADATA, on_pupsub_event);
}
public override void detach(XmppStream stream) { }
- public static void on_event_result(XmppStream stream, string jid, string id, StanzaNode node, Object? obj) {
- PixbufStorage? storage = obj as PixbufStorage;
+ public void on_pupsub_event(XmppStream stream, string jid, string id, StanzaNode? node) {
StanzaNode? info_node = node.get_subnode("info", NS_URI_METADATA);
if (info_node == null || info_node.get_attribute("type") != "image/png") return;
if (storage.has_image(id)) {
stream.get_module(Module.IDENTITY).received_avatar(stream, jid, id);
} else {
- stream.get_module(Pubsub.Module.IDENTITY).request(stream, jid, NS_URI_DATA, on_pubsub_data_response, storage);
+ stream.get_module(Pubsub.Module.IDENTITY).request(stream, jid, NS_URI_DATA, on_pubsub_data_response);
}
}
@@ -59,9 +58,8 @@ namespace Xmpp.Xep.UserAvatars {
public override string get_ns() { return NS_URI; }
public override string get_id() { return IDENTITY.id; }
- private static void on_pubsub_data_response(XmppStream stream, string jid, string? id, StanzaNode? node, Object? o) {
+ private void on_pubsub_data_response(XmppStream stream, string jid, string? id, StanzaNode? node) {
if (node == null) return;
- PixbufStorage storage = o as PixbufStorage;
storage.store(id, Base64.decode(node.get_string_content()));
stream.get_module(Module.IDENTITY).received_avatar(stream, jid, id);
}
diff --git a/xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala b/xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala
index a3f0a704..6f19fb12 100644
--- a/xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala
+++ b/xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala
@@ -57,20 +57,20 @@ namespace Xmpp.Xep.EntityCapabilities {
string ver_attribute = c_node.get_attribute("ver", NS_URI);
ArrayList<string> capabilities = storage.get_features(ver_attribute);
if (capabilities.size == 0) {
- stream.get_module(ServiceDiscovery.Module.IDENTITY).request_info(stream, presence.from, on_received_info_response, Tuple.create(storage, ver_attribute));
+ stream.get_module(ServiceDiscovery.Module.IDENTITY).request_info(stream, presence.from, (stream, query_result) => {
+ store_entity_result(stream, ver_attribute, query_result);
+ });
} else {
stream.get_flag(ServiceDiscovery.Flag.IDENTITY).set_entity_features(presence.from, capabilities);
}
}
}
- private static void on_received_info_response(XmppStream stream, ServiceDiscovery.InfoResult? query_result, Object? store) {
+ private void store_entity_result(XmppStream stream, string entity, ServiceDiscovery.InfoResult? query_result) {
if (query_result == null) return;
- Tuple<Storage, string> tuple = store as Tuple<Storage, string>;
- Storage storage = tuple.a;
- string entity = tuple.b;
if (compute_hash(query_result.identities, query_result.features) == entity) {
storage.store_features(entity, query_result.features);
+ stream.get_flag(ServiceDiscovery.Flag.IDENTITY).set_entity_features(query_result.iq.from, query_result.features);
}
}
diff --git a/xmpp-vala/src/module/xep/0199_ping.vala b/xmpp-vala/src/module/xep/0199_ping.vala
index 6cb3b4ba..3a5c6797 100644
--- a/xmpp-vala/src/module/xep/0199_ping.vala
+++ b/xmpp-vala/src/module/xep/0199_ping.vala
@@ -8,10 +8,11 @@ namespace Xmpp.Xep.Ping {
public class Module : XmppStreamModule {
public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0199_ping");
- public void send_ping(XmppStream stream, string jid, ResponseListener? listener) {
+ public delegate void OnResult(XmppStream stream);
+ public void send_ping(XmppStream stream, string jid, owned OnResult? listener) {
Iq.Stanza iq = new Iq.Stanza.get(new StanzaNode.build("ping", NS_URI).add_self_xmlns());
iq.to = jid;
- stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, on_ping_response, listener);
+ stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, (stream) => { listener(stream); });
}
public override void attach(XmppStream stream) {
@@ -34,14 +35,5 @@ namespace Xmpp.Xep.Ping {
}
public void on_iq_set(XmppStream stream, Iq.Stanza iq) { }
}
-
- private static void on_ping_response(XmppStream stream, Iq.Stanza iq, Object? o) {
- ResponseListener? listener = o as ResponseListener;
- if (listener != null) listener.on_result(stream);
- }
- }
-
- public interface ResponseListener : Object {
- public abstract void on_result(XmppStream stream);
}
}