Fix delegate copying issue
This commit is contained in:
parent
13cef27d46
commit
bd1f116b3a
|
@ -109,18 +109,19 @@ public class StreamModule : XmppStreamModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void attach(XmppStream stream) {
|
public override void attach(XmppStream stream) {
|
||||||
if (Plugin.context == null) return;
|
|
||||||
Message.Module.require(stream);
|
Message.Module.require(stream);
|
||||||
Pubsub.Module.require(stream);
|
Pubsub.Module.require(stream);
|
||||||
stream.get_module(Message.Module.IDENTITY).pre_received_message.connect(on_pre_received_message);
|
if (Plugin.context == null) return;
|
||||||
stream.get_module(Pubsub.Module.IDENTITY).add_filtered_notification(stream, NODE_DEVICELIST, on_devicelist, this);
|
|
||||||
this.store = Plugin.context.create_store();
|
this.store = Plugin.context.create_store();
|
||||||
store_created(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) => (obj as StreamModule).on_devicelist(stream, jid, id, node), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void on_pre_received_message(XmppStream stream, Message.Stanza message) {
|
private void on_pre_received_message(XmppStream stream, Message.Stanza message) {
|
||||||
StanzaNode? encrypted = message.stanza.get_subnode("encrypted", NS_URI);
|
StanzaNode? encrypted = message.stanza.get_subnode("encrypted", NS_URI);
|
||||||
if (encrypted == null) return;
|
if (encrypted == null || MessageFlag.get_flag(message) != null) return;
|
||||||
MessageFlag flag = new MessageFlag();
|
MessageFlag flag = new MessageFlag();
|
||||||
message.add_flag(flag);
|
message.add_flag(flag);
|
||||||
StanzaNode? header = encrypted.get_subnode("header");
|
StanzaNode? header = encrypted.get_subnode("header");
|
||||||
|
|
|
@ -60,7 +60,7 @@ namespace Xmpp.Xep.Pubsub {
|
||||||
string node = items_node.get_attribute("node", NS_URI_EVENT);
|
string node = items_node.get_attribute("node", NS_URI_EVENT);
|
||||||
string id = item_node.get_attribute("id", NS_URI_EVENT);
|
string id = item_node.get_attribute("id", NS_URI_EVENT);
|
||||||
if (event_listeners.has_key(node)) {
|
if (event_listeners.has_key(node)) {
|
||||||
event_listeners[node].on_result(stream, message.from, id, item_node.sub_nodes[0]);
|
event_listeners[node].on_result(stream, message.from, id, item_node.sub_nodes[0], event_listeners[node].reference);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,9 +76,10 @@ namespace Xmpp.Xep.Pubsub {
|
||||||
}
|
}
|
||||||
|
|
||||||
public class EventListenerDelegate {
|
public class EventListenerDelegate {
|
||||||
public delegate void ResultFunc(XmppStream stream, string jid, string id, StanzaNode node);
|
[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 ResultFunc on_result { get; private set; }
|
||||||
private Object reference;
|
public Object? reference { get; private set; }
|
||||||
|
|
||||||
public EventListenerDelegate(ResultFunc on_result, Object? reference = null) {
|
public EventListenerDelegate(ResultFunc on_result, Object? reference = null) {
|
||||||
this.on_result = on_result;
|
this.on_result = on_result;
|
||||||
|
|
|
@ -36,13 +36,14 @@ namespace Xmpp.Xep.UserAvatars {
|
||||||
|
|
||||||
public override void attach(XmppStream stream) {
|
public override void attach(XmppStream stream) {
|
||||||
Pubsub.Module.require(stream);
|
Pubsub.Module.require(stream);
|
||||||
stream.get_module(Pubsub.Module.IDENTITY).add_filtered_notification(stream, NS_URI_METADATA, on_event_result, this);
|
stream.get_module(Pubsub.Module.IDENTITY).add_filtered_notification(stream, NS_URI_METADATA, on_event_result, storage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void detach(XmppStream stream) { }
|
public override void detach(XmppStream stream) { }
|
||||||
|
|
||||||
|
|
||||||
public void on_event_result(XmppStream stream, string jid, string id, StanzaNode node) {
|
public static void on_event_result(XmppStream stream, string jid, string id, StanzaNode node, Object? obj) {
|
||||||
|
PixbufStorage? storage = obj as PixbufStorage;
|
||||||
StanzaNode info_node = node.get_subnode("info", NS_URI_METADATA);
|
StanzaNode info_node = node.get_subnode("info", NS_URI_METADATA);
|
||||||
if (info_node.get_attribute("type") != "image/png") return;
|
if (info_node.get_attribute("type") != "image/png") return;
|
||||||
if (storage.has_image(id)) {
|
if (storage.has_image(id)) {
|
||||||
|
|
Loading…
Reference in a new issue