Use typed identity in stream modules

This commit is contained in:
fiaxh 2017-03-11 01:40:42 +01:00
parent 95e8d126db
commit 1ccad732b9
32 changed files with 135 additions and 232 deletions

View file

@ -65,7 +65,7 @@ public class AvatarManager : StreamInteractionModule, Object {
pixbuf.save_to_buffer(out buffer, "png"); pixbuf.save_to_buffer(out buffer, "png");
Core.XmppStream stream = stream_interactor.get_stream(account); Core.XmppStream stream = stream_interactor.get_stream(account);
if (stream != null) { if (stream != null) {
Xep.UserAvatars.Module.get_module(stream).publish_png(stream, buffer, pixbuf.width, pixbuf.height); stream.get_module(Xep.UserAvatars.Module.IDENTITY).publish_png(stream, buffer, pixbuf.width, pixbuf.height);
on_user_avatar_received(account, account.bare_jid, Base64.encode(buffer)); on_user_avatar_received(account, account.bare_jid, Base64.encode(buffer));
} }
} catch (Error e) { } catch (Error e) {

View file

@ -132,14 +132,14 @@ public class ChatInteraction : StreamInteractionModule, Object {
private void send_chat_marker(Conversation conversation, Entities.Message message, string marker) { private void send_chat_marker(Conversation conversation, Entities.Message message, string marker) {
Core.XmppStream stream = stream_interactor.get_stream(conversation.account); Core.XmppStream stream = stream_interactor.get_stream(conversation.account);
if (stream != null && Settings.instance().send_read && Xep.ChatMarkers.Module.requests_marking(message.stanza)) { if (stream != null && Settings.instance().send_read && Xep.ChatMarkers.Module.requests_marking(message.stanza)) {
Xep.ChatMarkers.Module.get_module(stream).send_marker(stream, message.stanza.from, message.stanza_id, message.get_type_string(), marker); stream.get_module(Xep.ChatMarkers.Module.IDENTITY).send_marker(stream, message.stanza.from, message.stanza_id, message.get_type_string(), marker);
} }
} }
private void send_chat_state_notification(Conversation conversation, string state) { private void send_chat_state_notification(Conversation conversation, string state) {
Core.XmppStream stream = stream_interactor.get_stream(conversation.account); Core.XmppStream stream = stream_interactor.get_stream(conversation.account);
if (stream != null && Settings.instance().send_read) { if (stream != null && Settings.instance().send_read) {
Xep.ChatStateNotifications.Module.get_module(stream).send_state(stream, conversation.counterpart.to_string(), state); stream.get_module(Xep.ChatStateNotifications.Module.IDENTITY).send_state(stream, conversation.counterpart.to_string(), state);
} }
} }
} }

View file

@ -153,7 +153,7 @@ public class ConnectionManager {
private void check_reconnect(Account account) { private void check_reconnect(Account account) {
PingResponseListenerImpl ping_response_listener = new PingResponseListenerImpl(this, account); PingResponseListenerImpl ping_response_listener = new PingResponseListenerImpl(this, account);
Core.XmppStream stream = stream_states[account].stream; Core.XmppStream stream = stream_states[account].stream;
Xep.Ping.Module.get_module(stream).send_ping(stream, account.domainpart, ping_response_listener); stream.get_module(Xep.Ping.Module.IDENTITY).send_ping(stream, account.domainpart, ping_response_listener);
Timeout.add_seconds(5, () => { Timeout.add_seconds(5, () => {
if (stream_states[account].stream != stream) return false; if (stream_states[account].stream != stream) return false;
@ -203,7 +203,7 @@ public class ConnectionManager {
Xmpp.Presence.Stanza presence = new Xmpp.Presence.Stanza(); Xmpp.Presence.Stanza presence = new Xmpp.Presence.Stanza();
presence.type_ = Xmpp.Presence.Stanza.TYPE_UNAVAILABLE; presence.type_ = Xmpp.Presence.Stanza.TYPE_UNAVAILABLE;
try { try {
Presence.Module.get_module(stream_states[account].stream).send_presence(stream_states[account].stream, presence); stream_states[account].stream.get_module(Presence.Module.IDENTITY).send_presence(stream_states[account].stream, presence);
stream_states[account].stream.disconnect(); stream_states[account].stream.disconnect();
} catch (Error e) { print(@"on_prepare_for_sleep error $(e.message)\n"); } } catch (Error e) { print(@"on_prepare_for_sleep error $(e.message)\n"); }
} }

View file

@ -171,7 +171,7 @@ public class MessageManager : StreamInteractionModule, Object {
if (message.encryption == Entities.Message.Encryption.PGP) { if (message.encryption == Entities.Message.Encryption.PGP) {
string? key_id = PgpManager.get_instance(stream_interactor).get_key_id(conversation.account, message.counterpart); string? key_id = PgpManager.get_instance(stream_interactor).get_key_id(conversation.account, message.counterpart);
if (key_id != null) { if (key_id != null) {
bool encrypted = Xep.Pgp.Module.get_module(stream).encrypt(new_message, key_id); bool encrypted = stream.get_module(Xep.Pgp.Module.IDENTITY).encrypt(new_message, key_id);
if (!encrypted) { if (!encrypted) {
message.marked = Entities.Message.Marked.WONTSEND; message.marked = Entities.Message.Marked.WONTSEND;
return; return;
@ -179,9 +179,9 @@ public class MessageManager : StreamInteractionModule, Object {
} }
} }
if (delayed) { if (delayed) {
Xmpp.Xep.DelayedDelivery.Module.get_module(stream).set_message_delay(new_message, message.time); stream.get_module(Xmpp.Xep.DelayedDelivery.Module.IDENTITY).set_message_delay(new_message, message.time);
} }
Xmpp.Message.Module.get_module(stream).send_message(stream, new_message); stream.get_module(Xmpp.Message.Module.IDENTITY).send_message(stream, new_message);
message.stanza_id = new_message.id; message.stanza_id = new_message.id;
message.stanza = new_message; message.stanza = new_message;
} else { } else {

View file

@ -28,27 +28,27 @@ public class MucManager : StreamInteractionModule, Object {
public void join(Account account, Jid jid, string nick, string? password = null) { public void join(Account account, Jid jid, string nick, string? password = null) {
Core.XmppStream stream = stream_interactor.get_stream(account); Core.XmppStream stream = stream_interactor.get_stream(account);
if (stream != null) Xep.Muc.Module.get_module(stream).enter(stream, jid.bare_jid.to_string(), nick, password, new MucEnterListenerImpl(this, jid, nick, account)); if (stream != null) stream.get_module(Xep.Muc.Module.IDENTITY).enter(stream, jid.bare_jid.to_string(), nick, password, new MucEnterListenerImpl(this, jid, nick, account));
} }
public void part(Account account, Jid jid) { public void part(Account account, Jid jid) {
Core.XmppStream stream = stream_interactor.get_stream(account); Core.XmppStream stream = stream_interactor.get_stream(account);
if (stream != null) Xep.Muc.Module.get_module(stream).exit(stream, jid.bare_jid.to_string()); if (stream != null) stream.get_module(Xep.Muc.Module.IDENTITY).exit(stream, jid.bare_jid.to_string());
} }
public void change_subject(Account account, Jid jid, string subject) { public void change_subject(Account account, Jid jid, string subject) {
Core.XmppStream stream = stream_interactor.get_stream(account); Core.XmppStream stream = stream_interactor.get_stream(account);
if (stream != null) Xep.Muc.Module.get_module(stream).change_subject(stream, jid.bare_jid.to_string(), subject); if (stream != null) stream.get_module(Xep.Muc.Module.IDENTITY).change_subject(stream, jid.bare_jid.to_string(), subject);
} }
public void change_nick(Account account, Jid jid, string new_nick) { public void change_nick(Account account, Jid jid, string new_nick) {
Core.XmppStream stream = stream_interactor.get_stream(account); Core.XmppStream stream = stream_interactor.get_stream(account);
if (stream != null) Xep.Muc.Module.get_module(stream).change_nick(stream, jid.bare_jid.to_string(), new_nick); if (stream != null) stream.get_module(Xep.Muc.Module.IDENTITY).change_nick(stream, jid.bare_jid.to_string(), new_nick);
} }
public void kick(Account account, Jid jid, string nick) { public void kick(Account account, Jid jid, string nick) {
Core.XmppStream stream = stream_interactor.get_stream(account); Core.XmppStream stream = stream_interactor.get_stream(account);
if (stream != null) Xep.Muc.Module.get_module(stream).kick(stream, jid.bare_jid.to_string(), nick); if (stream != null) stream.get_module(Xep.Muc.Module.IDENTITY).kick(stream, jid.bare_jid.to_string(), nick);
} }
public ArrayList<Jid>? get_occupants(Jid jid, Account account) { public ArrayList<Jid>? get_occupants(Jid jid, Account account) {
@ -76,28 +76,28 @@ public class MucManager : StreamInteractionModule, Object {
public void get_bookmarks(Account account, Xep.Bookmarks.ConferencesRetrieveResponseListener listener) { public void get_bookmarks(Account account, Xep.Bookmarks.ConferencesRetrieveResponseListener listener) {
Core.XmppStream? stream = stream_interactor.get_stream(account); Core.XmppStream? stream = stream_interactor.get_stream(account);
if (stream != null) { if (stream != null) {
Xep.Bookmarks.Module.get_module(stream).get_conferences(stream, listener); stream.get_module(Xep.Bookmarks.Module.IDENTITY).get_conferences(stream, listener);
} }
} }
public void add_bookmark(Account account, Xep.Bookmarks.Conference conference) { public void add_bookmark(Account account, Xep.Bookmarks.Conference conference) {
Core.XmppStream? stream = stream_interactor.get_stream(account); Core.XmppStream? stream = stream_interactor.get_stream(account);
if (stream != null) { if (stream != null) {
Xep.Bookmarks.Module.get_module(stream).add_conference(stream, conference); stream.get_module(Xep.Bookmarks.Module.IDENTITY).add_conference(stream, conference);
} }
} }
public void replace_bookmark(Account account, Xep.Bookmarks.Conference was, Xep.Bookmarks.Conference replace) { public void replace_bookmark(Account account, Xep.Bookmarks.Conference was, Xep.Bookmarks.Conference replace) {
Core.XmppStream? stream = stream_interactor.get_stream(account); Core.XmppStream? stream = stream_interactor.get_stream(account);
if (stream != null) { if (stream != null) {
Xep.Bookmarks.Module.get_module(stream).replace_conference(stream, was, replace); stream.get_module(Xep.Bookmarks.Module.IDENTITY).replace_conference(stream, was, replace);
} }
} }
public void remove_bookmark(Account account, Xep.Bookmarks.Conference conference) { public void remove_bookmark(Account account, Xep.Bookmarks.Conference conference) {
Core.XmppStream? stream = stream_interactor.get_stream(account); Core.XmppStream? stream = stream_interactor.get_stream(account);
if (stream != null) { if (stream != null) {
Xep.Bookmarks.Module.get_module(stream).remove_conference(stream, conference); stream.get_module(Xep.Bookmarks.Module.IDENTITY).remove_conference(stream, conference);
} }
} }
@ -158,7 +158,7 @@ public class MucManager : StreamInteractionModule, Object {
private void on_stream_negotiated(Account account) { private void on_stream_negotiated(Account account) {
Core.XmppStream stream = stream_interactor.get_stream(account); Core.XmppStream stream = stream_interactor.get_stream(account);
if (stream != null) Xep.Bookmarks.Module.get_module(stream).get_conferences(stream, new BookmarksRetrieveResponseListener(this, account)); if (stream != null) stream.get_module(Xep.Bookmarks.Module.IDENTITY).get_conferences(stream, new BookmarksRetrieveResponseListener(this, account));
} }
private void on_pre_message_received(Entities.Message message, Conversation conversation) { private void on_pre_message_received(Entities.Message message, Conversation conversation) {

View file

@ -57,17 +57,17 @@ public class PresenceManager : StreamInteractionModule, Object {
public void request_subscription(Account account, Jid jid) { public void request_subscription(Account account, Jid jid) {
Core.XmppStream stream = stream_interactor.get_stream(account); Core.XmppStream stream = stream_interactor.get_stream(account);
if (stream != null) Xmpp.Presence.Module.get_module(stream).request_subscription(stream, jid.bare_jid.to_string()); if (stream != null) stream.get_module(Xmpp.Presence.Module.IDENTITY).request_subscription(stream, jid.bare_jid.to_string());
} }
public void approve_subscription(Account account, Jid jid) { public void approve_subscription(Account account, Jid jid) {
Core.XmppStream stream = stream_interactor.get_stream(account); Core.XmppStream stream = stream_interactor.get_stream(account);
if (stream != null) Xmpp.Presence.Module.get_module(stream).approve_subscription(stream, jid.bare_jid.to_string()); if (stream != null) stream.get_module(Xmpp.Presence.Module.IDENTITY).approve_subscription(stream, jid.bare_jid.to_string());
} }
public void deny_subscription(Account account, Jid jid) { public void deny_subscription(Account account, Jid jid) {
Core.XmppStream stream = stream_interactor.get_stream(account); Core.XmppStream stream = stream_interactor.get_stream(account);
if (stream != null) Xmpp.Presence.Module.get_module(stream).deny_subscription(stream, jid.bare_jid.to_string()); if (stream != null) stream.get_module(Xmpp.Presence.Module.IDENTITY).deny_subscription(stream, jid.bare_jid.to_string());
} }
public static PresenceManager? get_instance(StreamInteractor stream_interactor) { public static PresenceManager? get_instance(StreamInteractor stream_interactor) {

View file

@ -41,12 +41,12 @@ namespace Dino {
public void remove_jid(Account account, Jid jid) { public void remove_jid(Account account, Jid jid) {
Core.XmppStream? stream = stream_interactor.get_stream(account); Core.XmppStream? stream = stream_interactor.get_stream(account);
if (stream != null) Xmpp.Roster.Module.get_module(stream).remove_jid(stream, jid.bare_jid.to_string()); if (stream != null) stream.get_module(Xmpp.Roster.Module.IDENTITY).remove_jid(stream, jid.bare_jid.to_string());
} }
public void add_jid(Account account, Jid jid, string? handle) { public void add_jid(Account account, Jid jid, string? handle) {
Core.XmppStream? stream = stream_interactor.get_stream(account); Core.XmppStream? stream = stream_interactor.get_stream(account);
if (stream != null) Xmpp.Roster.Module.get_module(stream).add_jid(stream, jid.bare_jid.to_string(), handle); if (stream != null) stream.get_module(Xmpp.Roster.Module.IDENTITY).add_jid(stream, jid.bare_jid.to_string(), handle);
} }
public static RosterManager? get_instance(StreamInteractor stream_interactor) { public static RosterManager? get_instance(StreamInteractor stream_interactor) {

View file

@ -68,11 +68,6 @@ public class ChatInput : Grid {
case "/nick": case "/nick":
MucManager.get_instance(stream_interactor).change_nick(conversation.account, conversation.counterpart, token[1]); MucManager.get_instance(stream_interactor).change_nick(conversation.account, conversation.counterpart, token[1]);
break; break;
case "/ping": // TODO remove this
Xep.Ping.Module.get_module(stream_interactor.get_stream(conversation.account))
.send_ping(stream_interactor.get_stream(conversation.account), @"$(conversation.counterpart.bare_jid)/$(token[1])");
Xep.Ping.Module.get_module(stream_interactor.get_stream(conversation.account)).get_id();
break;
case "/topic": case "/topic":
MucManager.get_instance(stream_interactor).change_subject(conversation.account, conversation.counterpart, token[1]); MucManager.get_instance(stream_interactor).change_subject(conversation.account, conversation.counterpart, token[1]);
break; break;

View file

@ -80,7 +80,7 @@ OPTIONS
--vapidir=${CMAKE_SOURCE_DIR}/vapi --vapidir=${CMAKE_SOURCE_DIR}/vapi
) )
set(CFLAGS ${VALA_CFLAGS} ${ENGINE_CFLAGS} ${GPGME_CFLAGS} ${LIBUUID_CFLAGS} -I${CMAKE_BINARY_DIR}/gpgme-vala) set(CFLAGS ${VALA_CFLAGS} ${ENGINE_CFLAGS} ${GPGME_CFLAGS} ${LIBUUID_CFLAGS} -I${CMAKE_BINARY_DIR}/gpgme-vala -I${CMAKE_SOURCE_DIR}/gpgme-vala/src)
add_definitions(${CFLAGS}) add_definitions(${CFLAGS})
add_library(xmpp-vala SHARED ${ENGINE_VALA_C}) add_library(xmpp-vala SHARED ${ENGINE_VALA_C})
add_dependencies(xmpp-vala gpgme-vapi) add_dependencies(xmpp-vala gpgme-vapi)

View file

@ -35,14 +35,14 @@ namespace Xmpp.Bind {
var flag = new Flag(); var flag = new Flag();
StanzaNode bind_node = new StanzaNode.build("bind", NS_URI).add_self_xmlns() StanzaNode bind_node = new StanzaNode.build("bind", NS_URI).add_self_xmlns()
.put_node(new StanzaNode.build("resource", NS_URI).put_node(new StanzaNode.text(requested_resource))); .put_node(new StanzaNode.build("resource", NS_URI).put_node(new StanzaNode.text(requested_resource)));
Iq.Module.get_module(stream).send_iq(stream, new Iq.Stanza.set(bind_node), new IqResponseListenerImpl()); stream.get_module(Iq.Module.IDENTITY).send_iq(stream, new Iq.Stanza.set(bind_node), new IqResponseListenerImpl());
stream.add_flag(flag); stream.add_flag(flag);
} }
} }
private class IqResponseListenerImpl : Iq.ResponseListener, Object { private class IqResponseListenerImpl : Iq.ResponseListener, Object {
public void on_result(XmppStream stream, Iq.Stanza iq) { public void on_result(XmppStream stream, Iq.Stanza iq) {
Bind.Module.get_module(stream).iq_response_stanza(stream, iq); stream.get_module(Bind.Module.IDENTITY).iq_response_stanza(stream, iq);
} }
} }
@ -55,12 +55,8 @@ namespace Xmpp.Bind {
stream.received_features_node.disconnect(this.received_features_node); stream.received_features_node.disconnect(this.received_features_node);
} }
public static Module? get_module(XmppStream stream) {
return (Module?) stream.get_module(IDENTITY);
}
public static void require(XmppStream stream) { public static void require(XmppStream stream) {
if (get_module(stream) == null) stream.add_module(new Bind.Module("")); if (stream.get_module(IDENTITY) == null) stream.add_module(new Bind.Module(""));
} }
public override bool mandatory_outstanding(XmppStream stream) { public override bool mandatory_outstanding(XmppStream stream) {

View file

@ -38,12 +38,8 @@ namespace Xmpp.Iq {
stream.received_iq_stanza.disconnect(on_received_iq_stanza); stream.received_iq_stanza.disconnect(on_received_iq_stanza);
} }
public static Module? get_module(XmppStream stream) {
return (Module?) stream.get_module(IDENTITY);
}
public static void require(XmppStream stream) { public static void require(XmppStream stream) {
if (get_module(stream) == null) stream.add_module(new Iq.Module()); if (stream.get_module(IDENTITY) == null) stream.add_module(new Iq.Module());
} }
public override bool mandatory_outstanding(XmppStream stream) { return false; } public override bool mandatory_outstanding(XmppStream stream) { return false; }

View file

@ -27,12 +27,8 @@ namespace Xmpp.Message {
received_message(stream, message); received_message(stream, message);
} }
public static Module? get_module(XmppStream stream) {
return (Module?) stream.get_module(IDENTITY);
}
public static void require(XmppStream stream) { public static void require(XmppStream stream) {
if (get_module(stream) == null) stream.add_module(new Message.Module()); if (stream.get_module(IDENTITY) == null) stream.add_module(new Message.Module());
} }
public override void attach(XmppStream stream) { public override void attach(XmppStream stream) {

View file

@ -96,12 +96,8 @@ namespace Xmpp.Presence {
} }
} }
public static Module? get_module(XmppStream stream) {
return (Module?) stream.get_module(IDENTITY);
}
public static void require(XmppStream stream) { public static void require(XmppStream stream) {
if (get_module(stream) == null) stream.add_module(new Presence.Module()); if (stream.get_module(IDENTITY) == null) stream.add_module(new Presence.Module());
} }
public override string get_ns() { return NS_URI; } public override string get_ns() { return NS_URI; }

View file

@ -72,24 +72,20 @@ namespace Xmpp.Roster {
public void on_iq_get(XmppStream stream, Iq.Stanza iq) { } public void on_iq_get(XmppStream stream, Iq.Stanza iq) { }
public static Module? get_module(XmppStream stream) {
return (Module?) stream.get_module(IDENTITY);
}
public static void require(XmppStream stream) { public static void require(XmppStream stream) {
if (get_module(stream) == null) stream.add_module(new Module()); if (stream.get_module(IDENTITY) == null) stream.add_module(new Module());
} }
public override void attach(XmppStream stream) { public override void attach(XmppStream stream) {
Iq.Module.require(stream); Iq.Module.require(stream);
Iq.Module.get_module(stream).register_for_namespace(NS_URI, this); stream.get_module(Iq.Module.IDENTITY).register_for_namespace(NS_URI, this);
Presence.Module.require(stream); Presence.Module.require(stream);
Presence.Module.get_module(stream).initial_presence_sent.connect(roster_get); stream.get_module(Presence.Module.IDENTITY).initial_presence_sent.connect(roster_get);
stream.add_flag(new Flag()); stream.add_flag(new Flag());
} }
public override void detach(XmppStream stream) { public override void detach(XmppStream stream) {
Presence.Module.get_module(stream).initial_presence_sent.disconnect(roster_get); stream.get_module(Presence.Module.IDENTITY).initial_presence_sent.disconnect(roster_get);
} }
internal override string get_ns() { return NS_URI; } internal override string get_ns() { return NS_URI; }
@ -99,7 +95,7 @@ namespace Xmpp.Roster {
Flag.get_flag(stream).iq_id = random_uuid(); Flag.get_flag(stream).iq_id = random_uuid();
StanzaNode query_node = new StanzaNode.build("query", NS_URI).add_self_xmlns(); StanzaNode query_node = new StanzaNode.build("query", NS_URI).add_self_xmlns();
Iq.Stanza iq = new Iq.Stanza.get(query_node, Flag.get_flag(stream).iq_id); Iq.Stanza iq = new Iq.Stanza.get(query_node, Flag.get_flag(stream).iq_id);
Iq.Module.get_module(stream).send_iq(stream, iq, new IqResponseListenerImpl()); stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, new IqResponseListenerImpl());
} }
private class IqResponseListenerImpl : Iq.ResponseListener, Object { private class IqResponseListenerImpl : Iq.ResponseListener, Object {
@ -111,7 +107,7 @@ namespace Xmpp.Roster {
Item item = new Item.from_stanza_node(item_node); Item item = new Item.from_stanza_node(item_node);
flag.roster_items[item.jid] = item; flag.roster_items[item.jid] = item;
} }
Module.get_module(stream).received_roster(stream, flag.roster_items.values); stream.get_module(Module.IDENTITY).received_roster(stream, flag.roster_items.values);
} }
} }
} }
@ -120,7 +116,7 @@ namespace Xmpp.Roster {
StanzaNode query_node = new StanzaNode.build("query", NS_URI).add_self_xmlns() StanzaNode query_node = new StanzaNode.build("query", NS_URI).add_self_xmlns()
.put_node(roster_item.stanza_node); .put_node(roster_item.stanza_node);
Iq.Stanza iq = new Iq.Stanza.set(query_node); Iq.Stanza iq = new Iq.Stanza.set(query_node);
Iq.Module.get_module(stream).send_iq(stream, iq, null); stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, null);
} }
} }
} }

View file

@ -89,12 +89,8 @@ namespace Xmpp.PlainSasl {
} }
} }
public static Module? get_module(XmppStream stream) {
return (Module?) stream.get_module(IDENTITY);
}
public static void require(XmppStream stream) { public static void require(XmppStream stream) {
if (get_module(stream) == null) stderr.printf("PlainSaslModule required but not attached!\n"); if (stream.get_module(IDENTITY) == null) stderr.printf("PlainSaslModule required but not attached!\n");
} }
private static uchar[] get_plain_bytes(string name_s, string password_s) { private static uchar[] get_plain_bytes(string name_s, string password_s) {

View file

@ -18,12 +18,8 @@ namespace Xmpp.StreamError {
stream.received_nonza.disconnect(on_received_nonstanza); stream.received_nonza.disconnect(on_received_nonstanza);
} }
public static Module? get_module(XmppStream stream) {
return (Module?) stream.get_module(IDENTITY);
}
public static void require(XmppStream stream) { public static void require(XmppStream stream) {
if (get_module(stream) == null) stream.add_module(new StreamError.Module()); if (stream.get_module(IDENTITY) == null) stream.add_module(new Module());
} }
public override string get_ns() { return NS_URI; } public override string get_ns() { return NS_URI; }

View file

@ -67,10 +67,6 @@ namespace Xmpp.Tls {
} }
} }
public static Module? get_module(XmppStream stream) {
return (Module?) stream.get_module(IDENTITY);
}
public override bool mandatory_outstanding(XmppStream stream) { public override bool mandatory_outstanding(XmppStream stream) {
return require && (!Flag.has_flag(stream) || !Flag.get_flag(stream).finished); return require && (!Flag.has_flag(stream) || !Flag.get_flag(stream).finished);
} }

View file

@ -39,25 +39,21 @@ namespace Xmpp.Xep.Pgp {
public override void attach(XmppStream stream) { public override void attach(XmppStream stream) {
Presence.Module.require(stream); Presence.Module.require(stream);
Presence.Module.get_module(stream).received_presence.connect(on_received_presence); stream.get_module(Presence.Module.IDENTITY).received_presence.connect(on_received_presence);
Presence.Module.get_module(stream).pre_send_presence_stanza.connect(on_pre_send_presence_stanza); stream.get_module(Presence.Module.IDENTITY).pre_send_presence_stanza.connect(on_pre_send_presence_stanza);
Message.Module.require(stream); Message.Module.require(stream);
Message.Module.get_module(stream).pre_received_message.connect(on_pre_received_message); stream.get_module(Message.Module.IDENTITY).pre_received_message.connect(on_pre_received_message);
stream.add_flag(new Flag()); stream.add_flag(new Flag());
} }
public override void detach(XmppStream stream) { public override void detach(XmppStream stream) {
Presence.Module.get_module(stream).received_presence.disconnect(on_received_presence); stream.get_module(Presence.Module.IDENTITY).received_presence.disconnect(on_received_presence);
Presence.Module.get_module(stream).pre_send_presence_stanza.disconnect(on_pre_send_presence_stanza); stream.get_module(Presence.Module.IDENTITY).pre_send_presence_stanza.disconnect(on_pre_send_presence_stanza);
Message.Module.get_module(stream).pre_received_message.disconnect(on_pre_received_message); stream.get_module(Message.Module.IDENTITY).pre_received_message.disconnect(on_pre_received_message);
}
public static Module? get_module(XmppStream stream) {
return (Module?) stream.get_module(IDENTITY);
} }
public static void require(XmppStream stream) { public static void require(XmppStream stream) {
if (get_module(stream) == null) stream.add_module(new Module()); if (stream.get_module(IDENTITY) == null) stream.add_module(new Module());
} }
public override string get_ns() { return NS_URI; } public override string get_ns() { return NS_URI; }

View file

@ -32,7 +32,7 @@ namespace Xmpp.Xep.ServiceDiscovery {
public void request_info(XmppStream stream, string jid, InfoResponseListener response_listener) { public void request_info(XmppStream stream, string jid, InfoResponseListener response_listener) {
Iq.Stanza iq = new Iq.Stanza.get(new StanzaNode.build("query", NS_URI_INFO).add_self_xmlns()); Iq.Stanza iq = new Iq.Stanza.get(new StanzaNode.build("query", NS_URI_INFO).add_self_xmlns());
iq.to = jid; iq.to = jid;
Iq.Module.get_module(stream).send_iq(stream, iq, new IqInfoResponseListener(response_listener)); stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, new IqInfoResponseListener(response_listener));
} }
private class IqInfoResponseListener : Iq.ResponseListener, Object { private class IqInfoResponseListener : Iq.ResponseListener, Object {
@ -54,7 +54,7 @@ namespace Xmpp.Xep.ServiceDiscovery {
public void request_items(XmppStream stream, string jid, ItemsResponseListener response_listener) { public void request_items(XmppStream stream, string jid, ItemsResponseListener response_listener) {
Iq.Stanza iq = new Iq.Stanza.get(new StanzaNode.build("query", NS_URI_ITEMS).add_self_xmlns()); Iq.Stanza iq = new Iq.Stanza.get(new StanzaNode.build("query", NS_URI_ITEMS).add_self_xmlns());
iq.to = jid; iq.to = jid;
Iq.Module.get_module(stream).send_iq(stream, iq, new IqItemsResponseListener(response_listener)); stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, new IqItemsResponseListener(response_listener));
} }
private class IqItemsResponseListener : Iq.ResponseListener, Object { private class IqItemsResponseListener : Iq.ResponseListener, Object {
@ -76,19 +76,15 @@ namespace Xmpp.Xep.ServiceDiscovery {
public override void attach(XmppStream stream) { public override void attach(XmppStream stream) {
Iq.Module.require(stream); Iq.Module.require(stream);
Iq.Module.get_module(stream).register_for_namespace(NS_URI_INFO, this); stream.get_module(Iq.Module.IDENTITY).register_for_namespace(NS_URI_INFO, this);
stream.add_flag(new Flag()); stream.add_flag(new Flag());
add_feature(stream, NS_URI_INFO); add_feature(stream, NS_URI_INFO);
} }
public override void detach(XmppStream stream) { } public override void detach(XmppStream stream) { }
public static Module? get_module(XmppStream stream) {
return (Module?) stream.get_module(IDENTITY);
}
public static void require(XmppStream stream) { public static void require(XmppStream stream) {
if (get_module(stream) == null) stream.add_module(new ServiceDiscovery.Module()); if (stream.get_module(IDENTITY) == null) stream.add_module(new ServiceDiscovery.Module());
} }
public override string get_ns() { return NS_URI; } public override string get_ns() { return NS_URI; }
@ -98,7 +94,7 @@ namespace Xmpp.Xep.ServiceDiscovery {
InfoResult query_result = new ServiceDiscovery.InfoResult(iq_request); InfoResult query_result = new ServiceDiscovery.InfoResult(iq_request);
query_result.features = Flag.get_flag(stream).features; query_result.features = Flag.get_flag(stream).features;
query_result.identities = identities; query_result.identities = identities;
Iq.Module.get_module(stream).send_iq(stream, query_result.iq, null); stream.get_module(Iq.Module.IDENTITY).send_iq(stream, query_result.iq, null);
} }
} }

View file

@ -48,7 +48,7 @@ public class Module : XmppStreamModule {
Muc.Flag.get_flag(stream).start_muc_enter(bare_jid, presence.id, listener); Muc.Flag.get_flag(stream).start_muc_enter(bare_jid, presence.id, listener);
Presence.Module.get_module(stream).send_presence(stream, presence); stream.get_module(Presence.Module.IDENTITY).send_presence(stream, presence);
} }
public void exit(XmppStream stream, string jid) { public void exit(XmppStream stream, string jid) {
@ -56,7 +56,7 @@ public class Module : XmppStreamModule {
Presence.Stanza presence = new Presence.Stanza(); Presence.Stanza presence = new Presence.Stanza();
presence.to = jid + "/" + nick; presence.to = jid + "/" + nick;
presence.type_ = Presence.Stanza.TYPE_UNAVAILABLE; presence.type_ = Presence.Stanza.TYPE_UNAVAILABLE;
Presence.Module.get_module(stream).send_presence(stream, presence); stream.get_module(Presence.Module.IDENTITY).send_presence(stream, presence);
} }
public void change_subject(XmppStream stream, string jid, string subject) { public void change_subject(XmppStream stream, string jid, string subject) {
@ -64,13 +64,13 @@ public class Module : XmppStreamModule {
message.to = jid; message.to = jid;
message.type_ = Message.Stanza.TYPE_GROUPCHAT; message.type_ = Message.Stanza.TYPE_GROUPCHAT;
message.stanza.put_node((new StanzaNode.build("subject")).put_node(new StanzaNode.text(subject))); message.stanza.put_node((new StanzaNode.build("subject")).put_node(new StanzaNode.text(subject)));
Message.Module.get_module(stream).send_message(stream, message); stream.get_module(Message.Module.IDENTITY).send_message(stream, message);
} }
public void change_nick(XmppStream stream, string jid, string new_nick) { public void change_nick(XmppStream stream, string jid, string new_nick) {
Presence.Stanza presence = new Presence.Stanza(); Presence.Stanza presence = new Presence.Stanza();
presence.to = jid + "/" + new_nick; presence.to = jid + "/" + new_nick;
Presence.Module.get_module(stream).send_presence(stream, presence); stream.get_module(Presence.Module.IDENTITY).send_presence(stream, presence);
} }
public void kick(XmppStream stream, string jid, string nick) { public void kick(XmppStream stream, string jid, string nick) {
@ -80,30 +80,26 @@ public class Module : XmppStreamModule {
public override void attach(XmppStream stream) { public override void attach(XmppStream stream) {
stream.add_flag(new Muc.Flag()); stream.add_flag(new Muc.Flag());
Message.Module.require(stream); Message.Module.require(stream);
Message.Module.get_module(stream).received_message.connect(on_received_message); stream.get_module(Message.Module.IDENTITY).received_message.connect(on_received_message);
Presence.Module.require(stream); Presence.Module.require(stream);
Presence.Module.get_module(stream).received_presence.connect(on_received_presence); stream.get_module(Presence.Module.IDENTITY).received_presence.connect(on_received_presence);
Presence.Module.get_module(stream).received_available.connect(on_received_available); stream.get_module(Presence.Module.IDENTITY).received_available.connect(on_received_available);
Presence.Module.get_module(stream).received_unavailable.connect(on_received_unavailable); stream.get_module(Presence.Module.IDENTITY).received_unavailable.connect(on_received_unavailable);
if (ServiceDiscovery.Module.get_module(stream) != null) { if (stream.get_module(ServiceDiscovery.Module.IDENTITY) != null) {
ServiceDiscovery.Module.get_module(stream).add_feature(stream, NS_URI); stream.get_module(ServiceDiscovery.Module.IDENTITY).add_feature(stream, NS_URI);
} }
} }
public override void detach(XmppStream stream) { public override void detach(XmppStream stream) {
Message.Module.get_module(stream).received_message.disconnect(on_received_message); stream.get_module(Message.Module.IDENTITY).received_message.disconnect(on_received_message);
Presence.Module.get_module(stream).received_presence.disconnect(on_received_presence); stream.get_module(Presence.Module.IDENTITY).received_presence.disconnect(on_received_presence);
Presence.Module.get_module(stream).received_available.disconnect(on_received_available); stream.get_module(Presence.Module.IDENTITY).received_available.disconnect(on_received_available);
Presence.Module.get_module(stream).received_unavailable.disconnect(on_received_unavailable); stream.get_module(Presence.Module.IDENTITY).received_unavailable.disconnect(on_received_unavailable);
}
public static Module? get_module(XmppStream stream) {
return (Module?) stream.get_module(IDENTITY);
} }
public static void require(XmppStream stream) { public static void require(XmppStream stream) {
Presence.Module.require(stream); Presence.Module.require(stream);
if (get_module(stream) == null) stream.add_module(new Muc.Module()); if (stream.get_module(IDENTITY) == null) stream.add_module(new Muc.Module());
} }
public override string get_ns() { return NS_URI; } public override string get_ns() { return NS_URI; }
@ -114,7 +110,7 @@ public class Module : XmppStreamModule {
query.put_node(new StanzaNode.build("item", NS_URI_ADMIN).put_attribute("nick", nick, NS_URI_ADMIN).put_attribute("role", new_role, NS_URI_ADMIN)); query.put_node(new StanzaNode.build("item", NS_URI_ADMIN).put_attribute("nick", nick, NS_URI_ADMIN).put_attribute("role", new_role, NS_URI_ADMIN));
Iq.Stanza iq = new Iq.Stanza.set(query); Iq.Stanza iq = new Iq.Stanza.set(query);
iq.to = jid; iq.to = jid;
Iq.Module.get_module(stream).send_iq(stream, iq); stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq);
} }
private void on_received_message(XmppStream stream, Message.Stanza message) { private void on_received_message(XmppStream stream, Message.Stanza message) {

View file

@ -13,7 +13,7 @@ public class Module : XmppStreamModule {
public void get_conferences(XmppStream stream, ConferencesRetrieveResponseListener response_listener) { public void get_conferences(XmppStream stream, ConferencesRetrieveResponseListener response_listener) {
StanzaNode get_node = new StanzaNode.build("storage", NS_URI).add_self_xmlns(); StanzaNode get_node = new StanzaNode.build("storage", NS_URI).add_self_xmlns();
PrivateXmlStorage.Module.get_module(stream).retrieve(stream, get_node, new GetConferences(response_listener)); stream.get_module(PrivateXmlStorage.Module.IDENTITY).retrieve(stream, get_node, new GetConferences(response_listener));
} }
public void set_conferences(XmppStream stream, ArrayList<Conference> conferences) { public void set_conferences(XmppStream stream, ArrayList<Conference> conferences) {
@ -21,7 +21,7 @@ public class Module : XmppStreamModule {
foreach (Conference conference in conferences) { foreach (Conference conference in conferences) {
storage_node.put_node(conference.stanza_node); storage_node.put_node(conference.stanza_node);
} }
PrivateXmlStorage.Module.get_module(stream).store(stream, storage_node, new StoreResponseListenerImpl(conferences)); stream.get_module(PrivateXmlStorage.Module.IDENTITY).store(stream, storage_node, new StoreResponseListenerImpl(conferences));
} }
private class StoreResponseListenerImpl : PrivateXmlStorage.StoreResponseListener, Object { private class StoreResponseListenerImpl : PrivateXmlStorage.StoreResponseListener, Object {
@ -30,7 +30,7 @@ public class Module : XmppStreamModule {
this.conferences = conferences; this.conferences = conferences;
} }
public void on_success(XmppStream stream) { public void on_success(XmppStream stream) {
Module.get_module(stream).conferences_updated(stream, conferences); stream.get_module(Module.IDENTITY).conferences_updated(stream, conferences);
} }
} }
@ -65,7 +65,7 @@ public class Module : XmppStreamModule {
} }
public void on_result(XmppStream stream, ArrayList<Conference> conferences) { public void on_result(XmppStream stream, ArrayList<Conference> conferences) {
conferences.add(conference); conferences.add(conference);
Module.get_module(stream).set_conferences(stream, conferences); stream.get_module(Module.IDENTITY).set_conferences(stream, conferences);
} }
} }
@ -85,7 +85,7 @@ public class Module : XmppStreamModule {
break; break;
} }
} }
Module.get_module(stream).set_conferences(stream, conferences); stream.get_module(Module.IDENTITY).set_conferences(stream, conferences);
} }
} }
@ -102,7 +102,7 @@ public class Module : XmppStreamModule {
} }
} }
if (rem != null) conferences.remove(rem); if (rem != null) conferences.remove(rem);
Module.get_module(stream).set_conferences(stream, conferences); stream.get_module(Module.IDENTITY).set_conferences(stream, conferences);
} }
} }
@ -110,12 +110,8 @@ public class Module : XmppStreamModule {
public override void detach(XmppStream stream) { } public override void detach(XmppStream stream) { }
public static Module? get_module(XmppStream stream) {
return (Module?) stream.get_module(IDENTITY);
}
public static void require(XmppStream stream) { public static void require(XmppStream stream) {
if (get_module(stream) == null) stderr.printf(""); if (stream.get_module(IDENTITY) == null) stderr.printf("");
} }
public override string get_ns() { return NS_URI; } public override string get_ns() { return NS_URI; }

View file

@ -10,7 +10,7 @@ namespace Xmpp.Xep.PrivateXmlStorage {
public void store(XmppStream stream, StanzaNode node, StoreResponseListener listener) { public void store(XmppStream stream, StanzaNode node, StoreResponseListener 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);
Iq.Module.get_module(stream).send_iq(stream, iq, new IqStoreResponse(listener)); stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, new IqStoreResponse(listener));
} }
private class IqStoreResponse : Iq.ResponseListener, Object { private class IqStoreResponse : Iq.ResponseListener, Object {
@ -26,7 +26,7 @@ namespace Xmpp.Xep.PrivateXmlStorage {
public void retrieve(XmppStream stream, StanzaNode node, RetrieveResponseListener responseListener) { public void retrieve(XmppStream stream, StanzaNode node, RetrieveResponseListener responseListener) {
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);
Iq.Module.get_module(stream).send_iq(stream, iq, new IqRetrieveResponse(responseListener)); stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, new IqRetrieveResponse(responseListener));
} }
private class IqRetrieveResponse : Iq.ResponseListener, Object { private class IqRetrieveResponse : Iq.ResponseListener, Object {
@ -44,12 +44,8 @@ namespace Xmpp.Xep.PrivateXmlStorage {
public override void detach(XmppStream stream) { } public override void detach(XmppStream stream) { }
public static Module? get_module(XmppStream stream) {
return (Module?) stream.get_module(IDENTITY);
}
public static void require(XmppStream stream) { public static void require(XmppStream stream) {
if (get_module(stream) == null) stream.add_module(new PrivateXmlStorage.Module()); if (stream.get_module(IDENTITY) == null) stream.add_module(new PrivateXmlStorage.Module());
} }
public override string get_ns() { return NS_URI; } public override string get_ns() { return NS_URI; }

View file

@ -19,19 +19,15 @@ public class Module : XmppStreamModule {
public override void attach(XmppStream stream) { public override void attach(XmppStream stream) {
Iq.Module.require(stream); Iq.Module.require(stream);
Presence.Module.require(stream); Presence.Module.require(stream);
Presence.Module.get_module(stream).received_presence.connect(on_received_presence); stream.get_module(Presence.Module.IDENTITY).received_presence.connect(on_received_presence);
} }
public override void detach(XmppStream stream) { public override void detach(XmppStream stream) {
Presence.Module.get_module(stream).received_presence.disconnect(on_received_presence); stream.get_module(Presence.Module.IDENTITY).received_presence.disconnect(on_received_presence);
}
public static Module? get_module(XmppStream stream) {
return (Module?) stream.get_module(IDENTITY);
} }
public static void require(XmppStream stream) { public static void require(XmppStream stream) {
if (get_module(stream) == null) stderr.printf("VCardModule required but not attached!\n"); ; if (stream.get_module(IDENTITY) == null) stderr.printf("VCardModule required but not attached!\n"); ;
} }
public override string get_ns() { return NS_URI; } public override string get_ns() { return NS_URI; }
@ -57,7 +53,7 @@ public class Module : XmppStreamModule {
} else { } else {
iq.to = get_bare_jid(presence.from); iq.to = get_bare_jid(presence.from);
} }
Iq.Module.get_module(stream).send_iq(stream, iq, new IqResponseListenerImpl(this, storage, sha1)); stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, new IqResponseListenerImpl(this, storage, sha1));
} }
} }

View file

@ -13,14 +13,14 @@ namespace Xmpp.Xep.Pubsub {
private HashMap<string, EventListenerDelegate> event_listeners = new HashMap<string, EventListenerDelegate>(); 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, EventListenerDelegate.ResultFunc on_result, Object? reference = null) {
ServiceDiscovery.Module.get_module(stream).add_feature_notify(stream, node); stream.get_module(ServiceDiscovery.Module.IDENTITY).add_feature_notify(stream, node);
event_listeners[node] = new EventListenerDelegate(on_result, reference); event_listeners[node] = new EventListenerDelegate(on_result, reference);
} }
public void request(XmppStream stream, string jid, string node, RequestResponseListener listener) { // TODO multiple nodes gehen auch public void request(XmppStream stream, string jid, string node, RequestResponseListener listener) { // 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))); 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; a.to = jid;
Iq.Module.get_module(stream).send_iq(stream, a, new IqRequestResponseListener(listener)); stream.get_module(Iq.Module.IDENTITY).send_iq(stream, a, new IqRequestResponseListener(listener));
} }
private class IqRequestResponseListener : Iq.ResponseListener, Object { private class IqRequestResponseListener : Iq.ResponseListener, Object {
@ -44,7 +44,7 @@ namespace Xmpp.Xep.Pubsub {
items_node.put_node(content); items_node.put_node(content);
publish_node.put_node(items_node); publish_node.put_node(items_node);
Iq.Stanza iq = new Iq.Stanza.set(pubsub_node); Iq.Stanza iq = new Iq.Stanza.set(pubsub_node);
Iq.Module.get_module(stream).send_iq(stream, iq, null); stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, null);
} }
private class IqPublishResponseListener : Iq.ResponseListener, Object { private class IqPublishResponseListener : Iq.ResponseListener, Object {
@ -63,19 +63,15 @@ namespace Xmpp.Xep.Pubsub {
Iq.Module.require(stream); Iq.Module.require(stream);
Message.Module.require(stream); Message.Module.require(stream);
ServiceDiscovery.Module.require(stream); ServiceDiscovery.Module.require(stream);
Message.Module.get_module(stream).received_message.connect(on_received_message); stream.get_module(Message.Module.IDENTITY).received_message.connect(on_received_message);
} }
public override void detach(XmppStream stream) { public override void detach(XmppStream stream) {
Message.Module.get_module(stream).received_message.disconnect(on_received_message); stream.get_module(Message.Module.IDENTITY).received_message.disconnect(on_received_message);
}
public static Module? get_module(XmppStream stream) {
return (Module?) stream.get_module(IDENTITY);
} }
public static void require(XmppStream stream) { public static void require(XmppStream stream) {
if (get_module(stream) == null) stream.add_module(new Module()); if (stream.get_module(IDENTITY) == null) stream.add_module(new Module());
} }
public override string get_ns() { return NS_URI; } public override string get_ns() { return NS_URI; }

View file

@ -21,7 +21,7 @@ namespace Xmpp.Xep.UserAvatars {
string sha1 = Checksum.compute_for_data(ChecksumType.SHA1, image); string sha1 = Checksum.compute_for_data(ChecksumType.SHA1, image);
StanzaNode data_node = new StanzaNode.build("data", NS_URI_DATA).add_self_xmlns() StanzaNode data_node = new StanzaNode.build("data", NS_URI_DATA).add_self_xmlns()
.put_node(new StanzaNode.text(Base64.encode(image))); .put_node(new StanzaNode.text(Base64.encode(image)));
Pubsub.Module.get_module(stream).publish(stream, null, NS_URI_DATA, NS_URI_DATA, sha1, data_node); stream.get_module(Pubsub.Module.IDENTITY).publish(stream, null, NS_URI_DATA, NS_URI_DATA, sha1, data_node);
StanzaNode metadata_node = new StanzaNode.build("metadata", NS_URI_METADATA).add_self_xmlns(); StanzaNode metadata_node = new StanzaNode.build("metadata", NS_URI_METADATA).add_self_xmlns();
StanzaNode info_node = new StanzaNode.build("info", NS_URI_METADATA) StanzaNode info_node = new StanzaNode.build("info", NS_URI_METADATA)
@ -31,7 +31,7 @@ namespace Xmpp.Xep.UserAvatars {
.put_attribute("height", height.to_string()) .put_attribute("height", height.to_string())
.put_attribute("type", "image/png"); .put_attribute("type", "image/png");
metadata_node.put_node(info_node); metadata_node.put_node(info_node);
Pubsub.Module.get_module(stream).publish(stream, null, NS_URI_METADATA, NS_URI_METADATA, sha1, metadata_node); stream.get_module(Pubsub.Module.IDENTITY).publish(stream, null, NS_URI_METADATA, NS_URI_METADATA, sha1, metadata_node);
} }
private class PublishResponseListenerImpl : Pubsub.PublishResponseListener, Object { private class PublishResponseListenerImpl : Pubsub.PublishResponseListener, Object {
@ -47,7 +47,7 @@ namespace Xmpp.Xep.UserAvatars {
public override void attach(XmppStream stream) { public override void attach(XmppStream stream) {
Pubsub.Module.require(stream); Pubsub.Module.require(stream);
Pubsub.Module.get_module(stream).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, this);
} }
public override void detach(XmppStream stream) { } public override void detach(XmppStream stream) { }
@ -57,9 +57,9 @@ namespace Xmpp.Xep.UserAvatars {
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)) {
Module.get_module(stream).received_avatar(stream, jid, id); stream.get_module(Module.IDENTITY).received_avatar(stream, jid, id);
} else { } else {
Pubsub.Module.get_module(stream).request(stream, jid, NS_URI_DATA, new PubsubRequestResponseListenerImpl(storage)); stream.get_module(Pubsub.Module.IDENTITY).request(stream, jid, NS_URI_DATA, new PubsubRequestResponseListenerImpl(storage));
} }
} }
@ -69,16 +69,12 @@ namespace Xmpp.Xep.UserAvatars {
public void on_result(XmppStream stream, string jid, string? id, StanzaNode? node) { public void on_result(XmppStream stream, string jid, string? id, StanzaNode? node) {
if (node == null) return; if (node == null) return;
storage.store(id, Base64.decode(node.get_string_content())); storage.store(id, Base64.decode(node.get_string_content()));
Module.get_module(stream).received_avatar(stream, jid, id); stream.get_module(Module.IDENTITY).received_avatar(stream, jid, id);
} }
} }
public static Module? get_module(XmppStream stream) {
return (Module?) stream.get_module(IDENTITY);
}
public static void require(XmppStream stream) { public static void require(XmppStream stream) {
if (get_module(stream) == null) stderr.printf("UserAvatarsModule required but not attached!\n"); if (stream.get_module(IDENTITY) == null) stderr.printf("UserAvatarsModule required but not attached!\n");
} }
public override string get_ns() { return NS_URI; } public override string get_ns() { return NS_URI; }

View file

@ -27,27 +27,23 @@ public class Module : XmppStreamModule {
message.to = jid; message.to = jid;
message.type_ = Message.Stanza.TYPE_CHAT; message.type_ = Message.Stanza.TYPE_CHAT;
message.stanza.put_node(new StanzaNode.build(state, NS_URI).add_self_xmlns()); message.stanza.put_node(new StanzaNode.build(state, NS_URI).add_self_xmlns());
Message.Module.get_module(stream).send_message(stream, message); stream.get_module(Message.Module.IDENTITY).send_message(stream, message);
} }
public override void attach(XmppStream stream) { public override void attach(XmppStream stream) {
ServiceDiscovery.Module.require(stream); ServiceDiscovery.Module.require(stream);
ServiceDiscovery.Module.get_module(stream).add_feature(stream, NS_URI); stream.get_module(ServiceDiscovery.Module.IDENTITY).add_feature(stream, NS_URI);
Message.Module.get_module(stream).pre_send_message.connect(on_pre_send_message); stream.get_module(Message.Module.IDENTITY).pre_send_message.connect(on_pre_send_message);
Message.Module.get_module(stream).received_message.connect(on_received_message); stream.get_module(Message.Module.IDENTITY).received_message.connect(on_received_message);
} }
public override void detach(XmppStream stream) { public override void detach(XmppStream stream) {
Message.Module.get_module(stream).pre_send_message.disconnect(on_pre_send_message); stream.get_module(Message.Module.IDENTITY).pre_send_message.disconnect(on_pre_send_message);
Message.Module.get_module(stream).received_message.disconnect(on_received_message); stream.get_module(Message.Module.IDENTITY).received_message.disconnect(on_received_message);
}
public static Module? get_module(XmppStream stream) {
return (Module?) stream.get_module(IDENTITY);
} }
public static void require(XmppStream stream) { public static void require(XmppStream stream) {
if (get_module(stream) == null) stream.add_module(new Module()); ; if (stream.get_module(IDENTITY) == null) stream.add_module(new Module()); ;
} }
public override string get_ns() { return NS_URI; } public override string get_ns() { return NS_URI; }

View file

@ -18,7 +18,7 @@ namespace Xmpp.Xep.EntityCapabilities {
private string get_own_hash(XmppStream stream) { private string get_own_hash(XmppStream stream) {
if (own_ver_hash == null) { if (own_ver_hash == null) {
own_ver_hash = compute_hash(ServiceDiscovery.Module.get_module(stream).identities, ServiceDiscovery.Flag.get_flag(stream).features); own_ver_hash = compute_hash(stream.get_module(ServiceDiscovery.Module.IDENTITY).identities, ServiceDiscovery.Flag.get_flag(stream).features);
} }
return own_ver_hash; return own_ver_hash;
} }
@ -26,22 +26,18 @@ namespace Xmpp.Xep.EntityCapabilities {
public override void attach(XmppStream stream) { public override void attach(XmppStream stream) {
ServiceDiscovery.Module.require(stream); ServiceDiscovery.Module.require(stream);
Presence.Module.require(stream); Presence.Module.require(stream);
Presence.Module.get_module(stream).pre_send_presence_stanza.connect(on_pre_send_presence_stanza); stream.get_module(Presence.Module.IDENTITY).pre_send_presence_stanza.connect(on_pre_send_presence_stanza);
Presence.Module.get_module(stream).received_presence.connect(on_received_presence); stream.get_module(Presence.Module.IDENTITY).received_presence.connect(on_received_presence);
ServiceDiscovery.Module.get_module(stream).add_feature(stream, NS_URI); stream.get_module(ServiceDiscovery.Module.IDENTITY).add_feature(stream, NS_URI);
} }
public override void detach(XmppStream stream) { public override void detach(XmppStream stream) {
Presence.Module.get_module(stream).pre_send_presence_stanza.disconnect(on_pre_send_presence_stanza); stream.get_module(Presence.Module.IDENTITY).pre_send_presence_stanza.disconnect(on_pre_send_presence_stanza);
Presence.Module.get_module(stream).received_presence.disconnect(on_received_presence); stream.get_module(Presence.Module.IDENTITY).received_presence.disconnect(on_received_presence);
}
public static Module? get_module(XmppStream stream) {
return (Module?) stream.get_module(IDENTITY);
} }
public static void require(XmppStream stream) { public static void require(XmppStream stream) {
if (get_module(stream) == null) stderr.printf("EntityCapabilitiesModule required but not attached!\n"); if (stream.get_module(IDENTITY) == null) stderr.printf("EntityCapabilitiesModule required but not attached!\n");
} }
public override string get_ns() { return NS_URI; } public override string get_ns() { return NS_URI; }
@ -62,7 +58,7 @@ namespace Xmpp.Xep.EntityCapabilities {
string ver_attribute = c_node.get_attribute("ver", NS_URI); string ver_attribute = c_node.get_attribute("ver", NS_URI);
ArrayList<string> capabilities = storage.get_features(ver_attribute); ArrayList<string> capabilities = storage.get_features(ver_attribute);
if (capabilities.size == 0) { if (capabilities.size == 0) {
ServiceDiscovery.Module.get_module(stream) stream.get_module(ServiceDiscovery.Module.IDENTITY)
.request_info(stream, presence.from, new ServiceDiscoveryInfoResponseListenerImpl(storage, ver_attribute)); .request_info(stream, presence.from, new ServiceDiscoveryInfoResponseListenerImpl(storage, ver_attribute));
} else { } else {
ServiceDiscovery.Flag.get_flag(stream).set_entitiy_features(presence.from, capabilities); ServiceDiscovery.Flag.get_flag(stream).set_entitiy_features(presence.from, capabilities);

View file

@ -15,22 +15,18 @@ namespace Xmpp.Xep.MessageDeliveryReceipts {
ServiceDiscovery.Module.require(stream); ServiceDiscovery.Module.require(stream);
Message.Module.require(stream); Message.Module.require(stream);
ServiceDiscovery.Module.get_module(stream).add_feature(stream, NS_URI); stream.get_module(ServiceDiscovery.Module.IDENTITY).add_feature(stream, NS_URI);
Message.Module.get_module(stream).received_message.connect(received_message); stream.get_module(Message.Module.IDENTITY).received_message.connect(received_message);
Message.Module.get_module(stream).pre_send_message.connect(pre_send_message); stream.get_module(Message.Module.IDENTITY).pre_send_message.connect(pre_send_message);
} }
public override void detach(XmppStream stream) { public override void detach(XmppStream stream) {
Message.Module.get_module(stream).received_message.disconnect(received_message); stream.get_module(Message.Module.IDENTITY).received_message.disconnect(received_message);
Message.Module.get_module(stream).pre_send_message.disconnect(pre_send_message); stream.get_module(Message.Module.IDENTITY).pre_send_message.disconnect(pre_send_message);
}
public static Module? get_module(XmppStream stream) {
return (Module?) stream.get_module(IDENTITY);
} }
public static void require(XmppStream stream) { public static void require(XmppStream stream) {
if (get_module(stream) == null) stream.add_module(new Module()); if (stream.get_module(IDENTITY) == null) stream.add_module(new Module());
} }
public override string get_ns() { return NS_URI; } public override string get_ns() { return NS_URI; }
@ -49,7 +45,7 @@ namespace Xmpp.Xep.MessageDeliveryReceipts {
Message.Stanza received_message = new Message.Stanza(); Message.Stanza received_message = new Message.Stanza();
received_message.to = message.from; received_message.to = message.from;
received_message.stanza.put_node(new StanzaNode.build("received", NS_URI).add_self_xmlns().put_attribute("id", message.id)); received_message.stanza.put_node(new StanzaNode.build("received", NS_URI).add_self_xmlns().put_attribute("id", message.id));
Message.Module.get_module(stream).send_message(stream, received_message); stream.get_module(Message.Module.IDENTITY).send_message(stream, received_message);
} }
private void pre_send_message(XmppStream stream, Message.Stanza message) { private void pre_send_message(XmppStream stream, Message.Stanza message) {

View file

@ -12,7 +12,7 @@ namespace Xmpp.Xep.Ping {
public void send_ping(XmppStream stream, string jid, ResponseListener? listener = null) { public void send_ping(XmppStream stream, string jid, ResponseListener? listener = null) {
Iq.Stanza iq = new Iq.Stanza.get(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.to = jid; iq.to = jid;
Iq.Module.get_module(stream).send_iq(stream, iq, listener == null? null : new IqResponseListenerImpl(listener)); stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq, listener == null? null : new IqResponseListenerImpl(listener));
} }
private class IqResponseListenerImpl : Iq.ResponseListener, Object { private class IqResponseListenerImpl : Iq.ResponseListener, Object {
@ -27,17 +27,13 @@ namespace Xmpp.Xep.Ping {
public override void attach(XmppStream stream) { public override void attach(XmppStream stream) {
Iq.Module.require(stream); Iq.Module.require(stream);
Iq.Module.get_module(stream).register_for_namespace(NS_URI, new IqHandlerImpl()); stream.get_module(Iq.Module.IDENTITY).register_for_namespace(NS_URI, new IqHandlerImpl());
} }
public override void detach(XmppStream stream) { } public override void detach(XmppStream stream) { }
public static Module? get_module(XmppStream stream) {
return (Module?) stream.get_module(IDENTITY);
}
public static void require(XmppStream stream) { public static void require(XmppStream stream) {
if (get_module(stream) == null) stream.add_module(new Module()); if (stream.get_module(IDENTITY) == null) stream.add_module(new Module());
} }
public override string get_ns() { return NS_URI; } public override string get_ns() { return NS_URI; }
@ -45,7 +41,7 @@ namespace Xmpp.Xep.Ping {
private class IqHandlerImpl : Iq.Handler, Object { private class IqHandlerImpl : Iq.Handler, Object {
public void on_iq_get(XmppStream stream, Iq.Stanza iq) { public void on_iq_get(XmppStream stream, Iq.Stanza iq) {
Iq.Module.get_module(stream).send_iq(stream, new Iq.Stanza.result(iq)); stream.get_module(Iq.Module.IDENTITY).send_iq(stream, new Iq.Stanza.result(iq));
} }
public void on_iq_set(XmppStream stream, Iq.Stanza iq) { } public void on_iq_set(XmppStream stream, Iq.Stanza iq) { }
} }

View file

@ -24,17 +24,13 @@ namespace Xmpp.Xep.DelayedDelivery {
} }
public override void attach(XmppStream stream) { public override void attach(XmppStream stream) {
Message.Module.get_module(stream).pre_received_message.connect(on_pre_received_message); stream.get_module(Message.Module.IDENTITY).pre_received_message.connect(on_pre_received_message);
} }
public override void detach(XmppStream stream) { } public override void detach(XmppStream stream) { }
public static Module? get_module(XmppStream stream) {
return (Module?) stream.get_module(IDENTITY);
}
public static void require(XmppStream stream) { public static void require(XmppStream stream) {
if (get_module(stream) == null) stream.add_module(new Module()); if (stream.get_module(IDENTITY) == null) stream.add_module(new Module());
} }
public override string get_ns() { return NS_URI; } public override string get_ns() { return NS_URI; }

View file

@ -9,12 +9,12 @@ namespace Xmpp.Xep.MessageCarbons {
public void enable(XmppStream stream) { public 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());
Iq.Module.get_module(stream).send_iq(stream, iq); stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq);
} }
public void disable(XmppStream stream) { public 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());
Iq.Module.get_module(stream).send_iq(stream, iq); stream.get_module(Iq.Module.IDENTITY).send_iq(stream, iq);
} }
public override void attach(XmppStream stream) { public override void attach(XmppStream stream) {
@ -24,21 +24,17 @@ namespace Xmpp.Xep.MessageCarbons {
ServiceDiscovery.Module.require(stream); ServiceDiscovery.Module.require(stream);
stream.stream_negotiated.connect(enable); stream.stream_negotiated.connect(enable);
Message.Module.get_module(stream).pre_received_message.connect(pre_received_message); stream.get_module(Message.Module.IDENTITY).pre_received_message.connect(pre_received_message);
ServiceDiscovery.Module.get_module(stream).add_feature(stream, NS_URI); stream.get_module(ServiceDiscovery.Module.IDENTITY).add_feature(stream, NS_URI);
} }
public override void detach(XmppStream stream) { public override void detach(XmppStream stream) {
stream.stream_negotiated.disconnect(enable); stream.stream_negotiated.disconnect(enable);
Message.Module.get_module(stream).pre_received_message.disconnect(pre_received_message); stream.get_module(Message.Module.IDENTITY).pre_received_message.disconnect(pre_received_message);
}
public static Module? get_module(XmppStream stream) {
return (Module?) stream.get_module(IDENTITY);
} }
public static void require(XmppStream stream) { public static void require(XmppStream stream) {
if (get_module(stream) == null) stream.add_module(new Module()); if (stream.get_module(IDENTITY) == null) stream.add_module(new Module());
} }
public override string get_ns() { return NS_URI; } public override string get_ns() { return NS_URI; }

View file

@ -22,7 +22,7 @@ public class Module : XmppStreamModule {
received_message.to = jid; received_message.to = jid;
received_message.type_ = type_; received_message.type_ = type_;
received_message.stanza.put_node(new StanzaNode.build(marker, NS_URI).add_self_xmlns().put_attribute("id", message_id)); received_message.stanza.put_node(new StanzaNode.build(marker, NS_URI).add_self_xmlns().put_attribute("id", message_id));
Message.Module.get_module(stream).send_message(stream, received_message); stream.get_module(Message.Module.IDENTITY).send_message(stream, received_message);
} }
public static bool requests_marking(Message.Stanza message) { public static bool requests_marking(Message.Stanza message) {
@ -35,22 +35,18 @@ public class Module : XmppStreamModule {
Message.Module.require(stream); Message.Module.require(stream);
ServiceDiscovery.Module.require(stream); ServiceDiscovery.Module.require(stream);
ServiceDiscovery.Module.get_module(stream).add_feature(stream, NS_URI); stream.get_module(ServiceDiscovery.Module.IDENTITY).add_feature(stream, NS_URI);
Message.Module.get_module(stream).pre_send_message.connect(on_pre_send_message); stream.get_module(Message.Module.IDENTITY).pre_send_message.connect(on_pre_send_message);
Message.Module.get_module(stream).received_message.connect(on_received_message); stream.get_module(Message.Module.IDENTITY).received_message.connect(on_received_message);
} }
public override void detach(XmppStream stream) { public override void detach(XmppStream stream) {
Message.Module.get_module(stream).pre_send_message.disconnect(on_pre_send_message); stream.get_module(Message.Module.IDENTITY).pre_send_message.disconnect(on_pre_send_message);
Message.Module.get_module(stream).received_message.disconnect(on_received_message); stream.get_module(Message.Module.IDENTITY).received_message.disconnect(on_received_message);
}
public static Module? get_module(XmppStream stream) {
return (Module?) stream.get_module(IDENTITY);
} }
public static void require(XmppStream stream) { public static void require(XmppStream stream) {
if (get_module(stream) == null) stream.add_module(new ChatMarkers.Module()); if (stream.get_module(IDENTITY) == null) stream.add_module(new ChatMarkers.Module());
} }
public override string get_ns() { return NS_URI; } public override string get_ns() { return NS_URI; }