diff options
author | fiaxh <git@mx.ax.lt> | 2017-03-11 01:40:42 +0100 |
---|---|---|
committer | fiaxh <git@mx.ax.lt> | 2017-03-11 01:40:42 +0100 |
commit | 1ccad732b9a783d8f0140373602b7c1b84d04198 (patch) | |
tree | 368df267ba013c03d01c06c78b6559fa59338be3 | |
parent | 95e8d126db06a183918b4db4e84013ff28f8b1f7 (diff) | |
download | dino-1ccad732b9a783d8f0140373602b7c1b84d04198.tar.gz dino-1ccad732b9a783d8f0140373602b7c1b84d04198.zip |
Use typed identity in stream modules
32 files changed, 135 insertions, 232 deletions
diff --git a/libdino/src/service/avatar_manager.vala b/libdino/src/service/avatar_manager.vala index 0a141449..d0b25d3b 100644 --- a/libdino/src/service/avatar_manager.vala +++ b/libdino/src/service/avatar_manager.vala @@ -65,7 +65,7 @@ public class AvatarManager : StreamInteractionModule, Object { pixbuf.save_to_buffer(out buffer, "png"); Core.XmppStream stream = stream_interactor.get_stream(account); 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)); } } catch (Error e) { diff --git a/libdino/src/service/chat_interaction.vala b/libdino/src/service/chat_interaction.vala index cd6907fa..9d5c19e7 100644 --- a/libdino/src/service/chat_interaction.vala +++ b/libdino/src/service/chat_interaction.vala @@ -132,14 +132,14 @@ public class ChatInteraction : StreamInteractionModule, Object { private void send_chat_marker(Conversation conversation, Entities.Message message, string marker) { Core.XmppStream stream = stream_interactor.get_stream(conversation.account); 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) { Core.XmppStream stream = stream_interactor.get_stream(conversation.account); 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); } } } diff --git a/libdino/src/service/connection_manager.vala b/libdino/src/service/connection_manager.vala index 92827296..c95e42e3 100644 --- a/libdino/src/service/connection_manager.vala +++ b/libdino/src/service/connection_manager.vala @@ -153,7 +153,7 @@ public class ConnectionManager { private void check_reconnect(Account account) { PingResponseListenerImpl ping_response_listener = new PingResponseListenerImpl(this, account); 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, () => { if (stream_states[account].stream != stream) return false; @@ -203,7 +203,7 @@ public class ConnectionManager { Xmpp.Presence.Stanza presence = new Xmpp.Presence.Stanza(); presence.type_ = Xmpp.Presence.Stanza.TYPE_UNAVAILABLE; 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(); } catch (Error e) { print(@"on_prepare_for_sleep error $(e.message)\n"); } } diff --git a/libdino/src/service/message_manager.vala b/libdino/src/service/message_manager.vala index 76a05f9e..07a35a49 100644 --- a/libdino/src/service/message_manager.vala +++ b/libdino/src/service/message_manager.vala @@ -171,7 +171,7 @@ public class MessageManager : StreamInteractionModule, Object { if (message.encryption == Entities.Message.Encryption.PGP) { string? key_id = PgpManager.get_instance(stream_interactor).get_key_id(conversation.account, message.counterpart); 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) { message.marked = Entities.Message.Marked.WONTSEND; return; @@ -179,9 +179,9 @@ public class MessageManager : StreamInteractionModule, Object { } } 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 = new_message; } else { diff --git a/libdino/src/service/muc_manager.vala b/libdino/src/service/muc_manager.vala index 74467077..8e894211 100644 --- a/libdino/src/service/muc_manager.vala +++ b/libdino/src/service/muc_manager.vala @@ -28,27 +28,27 @@ public class MucManager : StreamInteractionModule, Object { public void join(Account account, Jid jid, string nick, string? password = null) { 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) { 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) { 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) { 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) { 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) { @@ -76,28 +76,28 @@ public class MucManager : StreamInteractionModule, Object { public void get_bookmarks(Account account, Xep.Bookmarks.ConferencesRetrieveResponseListener listener) { Core.XmppStream? stream = stream_interactor.get_stream(account); 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) { Core.XmppStream? stream = stream_interactor.get_stream(account); 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) { Core.XmppStream? stream = stream_interactor.get_stream(account); 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) { Core.XmppStream? stream = stream_interactor.get_stream(account); 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) { 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) { diff --git a/libdino/src/service/presence_manager.vala b/libdino/src/service/presence_manager.vala index be1e00fc..fd78496f 100644 --- a/libdino/src/service/presence_manager.vala +++ b/libdino/src/service/presence_manager.vala @@ -57,17 +57,17 @@ public class PresenceManager : StreamInteractionModule, Object { public void request_subscription(Account account, Jid jid) { 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) { 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) { 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) { diff --git a/libdino/src/service/roster_manager.vala b/libdino/src/service/roster_manager.vala index 6f6f402a..720a746a 100644 --- a/libdino/src/service/roster_manager.vala +++ b/libdino/src/service/roster_manager.vala @@ -41,12 +41,12 @@ namespace Dino { public void remove_jid(Account account, Jid jid) { 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) { 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) { diff --git a/libdino/src/ui/chat_input.vala b/libdino/src/ui/chat_input.vala index cc4fd24a..5030fcea 100644 --- a/libdino/src/ui/chat_input.vala +++ b/libdino/src/ui/chat_input.vala @@ -68,11 +68,6 @@ public class ChatInput : Grid { case "/nick": MucManager.get_instance(stream_interactor).change_nick(conversation.account, conversation.counterpart, token[1]); 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": MucManager.get_instance(stream_interactor).change_subject(conversation.account, conversation.counterpart, token[1]); break; diff --git a/xmpp-vala/CMakeLists.txt b/xmpp-vala/CMakeLists.txt index a0e91841..77e16136 100644 --- a/xmpp-vala/CMakeLists.txt +++ b/xmpp-vala/CMakeLists.txt @@ -80,7 +80,7 @@ OPTIONS --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_library(xmpp-vala SHARED ${ENGINE_VALA_C}) add_dependencies(xmpp-vala gpgme-vapi) diff --git a/xmpp-vala/src/module/bind.vala b/xmpp-vala/src/module/bind.vala index 388a907e..4ddce17d 100644 --- a/xmpp-vala/src/module/bind.vala +++ b/xmpp-vala/src/module/bind.vala @@ -35,14 +35,14 @@ namespace Xmpp.Bind { var flag = new Flag(); 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))); - 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); } } private class IqResponseListenerImpl : Iq.ResponseListener, Object { 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); } - public static Module? get_module(XmppStream stream) { - return (Module?) stream.get_module(IDENTITY); - } - 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) { diff --git a/xmpp-vala/src/module/iq/module.vala b/xmpp-vala/src/module/iq/module.vala index d5dbdca2..c3bb81ff 100644 --- a/xmpp-vala/src/module/iq/module.vala +++ b/xmpp-vala/src/module/iq/module.vala @@ -38,12 +38,8 @@ namespace Xmpp.Iq { 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) { - 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; } diff --git a/xmpp-vala/src/module/message/module.vala b/xmpp-vala/src/module/message/module.vala index 8aad08df..1d54443c 100644 --- a/xmpp-vala/src/module/message/module.vala +++ b/xmpp-vala/src/module/message/module.vala @@ -27,12 +27,8 @@ namespace Xmpp.Message { received_message(stream, message); } - public static Module? get_module(XmppStream stream) { - return (Module?) stream.get_module(IDENTITY); - } - 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) { diff --git a/xmpp-vala/src/module/presence/module.vala b/xmpp-vala/src/module/presence/module.vala index c69f1e3a..63545982 100644 --- a/xmpp-vala/src/module/presence/module.vala +++ b/xmpp-vala/src/module/presence/module.vala @@ -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) { - 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; } diff --git a/xmpp-vala/src/module/roster/module.vala b/xmpp-vala/src/module/roster/module.vala index 7bf8917c..c9400b3a 100644 --- a/xmpp-vala/src/module/roster/module.vala +++ b/xmpp-vala/src/module/roster/module.vala @@ -72,24 +72,20 @@ namespace Xmpp.Roster { 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) { - 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) { 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.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()); } 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; } @@ -99,7 +95,7 @@ namespace Xmpp.Roster { Flag.get_flag(stream).iq_id = random_uuid(); 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.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 { @@ -111,7 +107,7 @@ namespace Xmpp.Roster { Item item = new Item.from_stanza_node(item_node); 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() .put_node(roster_item.stanza_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); } } } diff --git a/xmpp-vala/src/module/sasl.vala b/xmpp-vala/src/module/sasl.vala index af9087cd..79748211 100644 --- a/xmpp-vala/src/module/sasl.vala +++ b/xmpp-vala/src/module/sasl.vala @@ -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) { - 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) { diff --git a/xmpp-vala/src/module/stream_error.vala b/xmpp-vala/src/module/stream_error.vala index d47ddc60..c775bdaa 100644 --- a/xmpp-vala/src/module/stream_error.vala +++ b/xmpp-vala/src/module/stream_error.vala @@ -18,12 +18,8 @@ namespace Xmpp.StreamError { 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) { - 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; } diff --git a/xmpp-vala/src/module/tls.vala b/xmpp-vala/src/module/tls.vala index 0d4a7e73..01dcf51d 100644 --- a/xmpp-vala/src/module/tls.vala +++ b/xmpp-vala/src/module/tls.vala @@ -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) { return require && (!Flag.has_flag(stream) || !Flag.get_flag(stream).finished); } diff --git a/xmpp-vala/src/module/xep/0027_pgp/module.vala b/xmpp-vala/src/module/xep/0027_pgp/module.vala index 3fcd6559..8d75a17d 100644 --- a/xmpp-vala/src/module/xep/0027_pgp/module.vala +++ b/xmpp-vala/src/module/xep/0027_pgp/module.vala @@ -39,25 +39,21 @@ namespace Xmpp.Xep.Pgp { public override void attach(XmppStream stream) { Presence.Module.require(stream); - Presence.Module.get_module(stream).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).received_presence.connect(on_received_presence); + stream.get_module(Presence.Module.IDENTITY).pre_send_presence_stanza.connect(on_pre_send_presence_stanza); 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()); } public override void detach(XmppStream stream) { - Presence.Module.get_module(stream).received_presence.disconnect(on_received_presence); - Presence.Module.get_module(stream).pre_send_presence_stanza.disconnect(on_pre_send_presence_stanza); - Message.Module.get_module(stream).pre_received_message.disconnect(on_pre_received_message); - } - - public static Module? get_module(XmppStream stream) { - return (Module?) stream.get_module(IDENTITY); + stream.get_module(Presence.Module.IDENTITY).received_presence.disconnect(on_received_presence); + stream.get_module(Presence.Module.IDENTITY).pre_send_presence_stanza.disconnect(on_pre_send_presence_stanza); + stream.get_module(Message.Module.IDENTITY).pre_received_message.disconnect(on_pre_received_message); } 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; } 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 163f8cfc..439d825c 100644 --- a/xmpp-vala/src/module/xep/0030_service_discovery/module.vala +++ b/xmpp-vala/src/module/xep/0030_service_discovery/module.vala @@ -32,7 +32,7 @@ namespace Xmpp.Xep.ServiceDiscovery { 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.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 { @@ -54,7 +54,7 @@ namespace Xmpp.Xep.ServiceDiscovery { 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.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 { @@ -76,19 +76,15 @@ namespace Xmpp.Xep.ServiceDiscovery { public override void attach(XmppStream 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()); add_feature(stream, NS_URI_INFO); } 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) { - 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; } @@ -98,7 +94,7 @@ namespace Xmpp.Xep.ServiceDiscovery { InfoResult query_result = new ServiceDiscovery.InfoResult(iq_request); query_result.features = Flag.get_flag(stream).features; 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); } } diff --git a/xmpp-vala/src/module/xep/0045_muc/module.vala b/xmpp-vala/src/module/xep/0045_muc/module.vala index cb7f0d85..3b0c3c12 100644 --- a/xmpp-vala/src/module/xep/0045_muc/module.vala +++ b/xmpp-vala/src/module/xep/0045_muc/module.vala @@ -48,7 +48,7 @@ public class Module : XmppStreamModule { 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) { @@ -56,7 +56,7 @@ public class Module : XmppStreamModule { Presence.Stanza presence = new Presence.Stanza(); presence.to = jid + "/" + nick; 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) { @@ -64,13 +64,13 @@ public class Module : XmppStreamModule { message.to = jid; message.type_ = Message.Stanza.TYPE_GROUPCHAT; 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) { Presence.Stanza presence = new Presence.Stanza(); 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) { @@ -80,30 +80,26 @@ public class Module : XmppStreamModule { public override void attach(XmppStream stream) { stream.add_flag(new Muc.Flag()); 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.get_module(stream).received_presence.connect(on_received_presence); - Presence.Module.get_module(stream).received_available.connect(on_received_available); - Presence.Module.get_module(stream).received_unavailable.connect(on_received_unavailable); - if (ServiceDiscovery.Module.get_module(stream) != null) { - ServiceDiscovery.Module.get_module(stream).add_feature(stream, NS_URI); + stream.get_module(Presence.Module.IDENTITY).received_presence.connect(on_received_presence); + stream.get_module(Presence.Module.IDENTITY).received_available.connect(on_received_available); + stream.get_module(Presence.Module.IDENTITY).received_unavailable.connect(on_received_unavailable); + if (stream.get_module(ServiceDiscovery.Module.IDENTITY) != null) { + stream.get_module(ServiceDiscovery.Module.IDENTITY).add_feature(stream, NS_URI); } } public override void detach(XmppStream stream) { - Message.Module.get_module(stream).received_message.disconnect(on_received_message); - Presence.Module.get_module(stream).received_presence.disconnect(on_received_presence); - Presence.Module.get_module(stream).received_available.disconnect(on_received_available); - Presence.Module.get_module(stream).received_unavailable.disconnect(on_received_unavailable); - } - - public static Module? get_module(XmppStream stream) { - return (Module?) stream.get_module(IDENTITY); + stream.get_module(Message.Module.IDENTITY).received_message.disconnect(on_received_message); + stream.get_module(Presence.Module.IDENTITY).received_presence.disconnect(on_received_presence); + stream.get_module(Presence.Module.IDENTITY).received_available.disconnect(on_received_available); + stream.get_module(Presence.Module.IDENTITY).received_unavailable.disconnect(on_received_unavailable); } public static void require(XmppStream 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; } @@ -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)); Iq.Stanza iq = new Iq.Stanza.set(query); 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) { diff --git a/xmpp-vala/src/module/xep/0048_bookmarks/module.vala b/xmpp-vala/src/module/xep/0048_bookmarks/module.vala index 25a4678e..25191122 100644 --- a/xmpp-vala/src/module/xep/0048_bookmarks/module.vala +++ b/xmpp-vala/src/module/xep/0048_bookmarks/module.vala @@ -13,7 +13,7 @@ public class Module : XmppStreamModule { public void get_conferences(XmppStream stream, ConferencesRetrieveResponseListener response_listener) { 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) { @@ -21,7 +21,7 @@ public class Module : XmppStreamModule { foreach (Conference conference in conferences) { 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 { @@ -30,7 +30,7 @@ public class Module : XmppStreamModule { this.conferences = conferences; } 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) { 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; } } - 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); - 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 static Module? get_module(XmppStream stream) { - return (Module?) stream.get_module(IDENTITY); - } - 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; } 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 0472296c..f59d0bdd 100644 --- a/xmpp-vala/src/module/xep/0049_private_xml_storage.vala +++ b/xmpp-vala/src/module/xep/0049_private_xml_storage.vala @@ -10,7 +10,7 @@ namespace Xmpp.Xep.PrivateXmlStorage { public void store(XmppStream stream, StanzaNode node, StoreResponseListener listener) { StanzaNode queryNode = new StanzaNode.build("query", NS_URI).add_self_xmlns().put_node(node); 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 { @@ -26,7 +26,7 @@ namespace Xmpp.Xep.PrivateXmlStorage { public void retrieve(XmppStream stream, StanzaNode node, RetrieveResponseListener responseListener) { StanzaNode queryNode = new StanzaNode.build("query", NS_URI).add_self_xmlns().put_node(node); 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 { @@ -44,12 +44,8 @@ namespace Xmpp.Xep.PrivateXmlStorage { 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) { - 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; } diff --git a/xmpp-vala/src/module/xep/0054_vcard/module.vala b/xmpp-vala/src/module/xep/0054_vcard/module.vala index d0b23db5..037f723b 100644 --- a/xmpp-vala/src/module/xep/0054_vcard/module.vala +++ b/xmpp-vala/src/module/xep/0054_vcard/module.vala @@ -19,19 +19,15 @@ public class Module : XmppStreamModule { public override void attach(XmppStream stream) { Iq.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) { - Presence.Module.get_module(stream).received_presence.disconnect(on_received_presence); - } - - public static Module? get_module(XmppStream stream) { - return (Module?) stream.get_module(IDENTITY); + stream.get_module(Presence.Module.IDENTITY).received_presence.disconnect(on_received_presence); } 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; } @@ -57,7 +53,7 @@ public class Module : XmppStreamModule { } else { 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)); } } diff --git a/xmpp-vala/src/module/xep/0060_pubsub.vala b/xmpp-vala/src/module/xep/0060_pubsub.vala index f9379c45..c69f6a25 100644 --- a/xmpp-vala/src/module/xep/0060_pubsub.vala +++ b/xmpp-vala/src/module/xep/0060_pubsub.vala @@ -13,14 +13,14 @@ 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) { - 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); } 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))); 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 { @@ -44,7 +44,7 @@ namespace Xmpp.Xep.Pubsub { items_node.put_node(content); publish_node.put_node(items_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 { @@ -63,19 +63,15 @@ namespace Xmpp.Xep.Pubsub { Iq.Module.require(stream); Message.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) { - Message.Module.get_module(stream).received_message.disconnect(on_received_message); - } - - public static Module? get_module(XmppStream stream) { - return (Module?) stream.get_module(IDENTITY); + stream.get_module(Message.Module.IDENTITY).received_message.disconnect(on_received_message); } 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; } diff --git a/xmpp-vala/src/module/xep/0084_user_avatars.vala b/xmpp-vala/src/module/xep/0084_user_avatars.vala index 3654509c..edaa25df 100644 --- a/xmpp-vala/src/module/xep/0084_user_avatars.vala +++ b/xmpp-vala/src/module/xep/0084_user_avatars.vala @@ -21,7 +21,7 @@ namespace Xmpp.Xep.UserAvatars { string sha1 = Checksum.compute_for_data(ChecksumType.SHA1, image); StanzaNode data_node = new StanzaNode.build("data", NS_URI_DATA).add_self_xmlns() .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 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("type", "image/png"); 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 { @@ -47,7 +47,7 @@ namespace Xmpp.Xep.UserAvatars { public override void attach(XmppStream 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) { } @@ -57,9 +57,9 @@ namespace Xmpp.Xep.UserAvatars { StanzaNode info_node = node.get_subnode("info", NS_URI_METADATA); if (info_node.get_attribute("type") != "image/png") return; 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 { - 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) { if (node == null) return; 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) { - 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; } diff --git a/xmpp-vala/src/module/xep/0085_chat_state_notifications.vala b/xmpp-vala/src/module/xep/0085_chat_state_notifications.vala index 3e92cd44..6dbbb6f6 100644 --- a/xmpp-vala/src/module/xep/0085_chat_state_notifications.vala +++ b/xmpp-vala/src/module/xep/0085_chat_state_notifications.vala @@ -27,27 +27,23 @@ public class Module : XmppStreamModule { message.to = jid; message.type_ = Message.Stanza.TYPE_CHAT; 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) { ServiceDiscovery.Module.require(stream); - ServiceDiscovery.Module.get_module(stream).add_feature(stream, NS_URI); - Message.Module.get_module(stream).pre_send_message.connect(on_pre_send_message); - Message.Module.get_module(stream).received_message.connect(on_received_message); + stream.get_module(ServiceDiscovery.Module.IDENTITY).add_feature(stream, NS_URI); + stream.get_module(Message.Module.IDENTITY).pre_send_message.connect(on_pre_send_message); + stream.get_module(Message.Module.IDENTITY).received_message.connect(on_received_message); } public override void detach(XmppStream stream) { - Message.Module.get_module(stream).pre_send_message.disconnect(on_pre_send_message); - Message.Module.get_module(stream).received_message.disconnect(on_received_message); - } - - public static Module? get_module(XmppStream stream) { - return (Module?) stream.get_module(IDENTITY); + stream.get_module(Message.Module.IDENTITY).pre_send_message.disconnect(on_pre_send_message); + stream.get_module(Message.Module.IDENTITY).received_message.disconnect(on_received_message); } 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; } diff --git a/xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala b/xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala index c39f9cad..6b8ae3bb 100644 --- a/xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala +++ b/xmpp-vala/src/module/xep/0115_entitiy_capabilities.vala @@ -18,7 +18,7 @@ namespace Xmpp.Xep.EntityCapabilities { private string get_own_hash(XmppStream stream) { 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; } @@ -26,22 +26,18 @@ namespace Xmpp.Xep.EntityCapabilities { public override void attach(XmppStream stream) { ServiceDiscovery.Module.require(stream); Presence.Module.require(stream); - Presence.Module.get_module(stream).pre_send_presence_stanza.connect(on_pre_send_presence_stanza); - Presence.Module.get_module(stream).received_presence.connect(on_received_presence); - ServiceDiscovery.Module.get_module(stream).add_feature(stream, NS_URI); + stream.get_module(Presence.Module.IDENTITY).pre_send_presence_stanza.connect(on_pre_send_presence_stanza); + stream.get_module(Presence.Module.IDENTITY).received_presence.connect(on_received_presence); + stream.get_module(ServiceDiscovery.Module.IDENTITY).add_feature(stream, NS_URI); } public override void detach(XmppStream stream) { - Presence.Module.get_module(stream).pre_send_presence_stanza.disconnect(on_pre_send_presence_stanza); - Presence.Module.get_module(stream).received_presence.disconnect(on_received_presence); - } - - public static Module? get_module(XmppStream stream) { - return (Module?) stream.get_module(IDENTITY); + stream.get_module(Presence.Module.IDENTITY).pre_send_presence_stanza.disconnect(on_pre_send_presence_stanza); + stream.get_module(Presence.Module.IDENTITY).received_presence.disconnect(on_received_presence); } 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; } @@ -62,7 +58,7 @@ 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) { - ServiceDiscovery.Module.get_module(stream) + stream.get_module(ServiceDiscovery.Module.IDENTITY) .request_info(stream, presence.from, new ServiceDiscoveryInfoResponseListenerImpl(storage, ver_attribute)); } else { ServiceDiscovery.Flag.get_flag(stream).set_entitiy_features(presence.from, capabilities); diff --git a/xmpp-vala/src/module/xep/0184_message_delivery_receipts.vala b/xmpp-vala/src/module/xep/0184_message_delivery_receipts.vala index bd0fe98a..b8597d07 100644 --- a/xmpp-vala/src/module/xep/0184_message_delivery_receipts.vala +++ b/xmpp-vala/src/module/xep/0184_message_delivery_receipts.vala @@ -15,22 +15,18 @@ namespace Xmpp.Xep.MessageDeliveryReceipts { ServiceDiscovery.Module.require(stream); Message.Module.require(stream); - ServiceDiscovery.Module.get_module(stream).add_feature(stream, NS_URI); - Message.Module.get_module(stream).received_message.connect(received_message); - Message.Module.get_module(stream).pre_send_message.connect(pre_send_message); + stream.get_module(ServiceDiscovery.Module.IDENTITY).add_feature(stream, NS_URI); + stream.get_module(Message.Module.IDENTITY).received_message.connect(received_message); + stream.get_module(Message.Module.IDENTITY).pre_send_message.connect(pre_send_message); } public override void detach(XmppStream stream) { - Message.Module.get_module(stream).received_message.disconnect(received_message); - Message.Module.get_module(stream).pre_send_message.disconnect(pre_send_message); - } - - public static Module? get_module(XmppStream stream) { - return (Module?) stream.get_module(IDENTITY); + stream.get_module(Message.Module.IDENTITY).received_message.disconnect(received_message); + stream.get_module(Message.Module.IDENTITY).pre_send_message.disconnect(pre_send_message); } 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; } @@ -49,7 +45,7 @@ namespace Xmpp.Xep.MessageDeliveryReceipts { Message.Stanza received_message = new Message.Stanza(); received_message.to = message.from; 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) { diff --git a/xmpp-vala/src/module/xep/0199_ping.vala b/xmpp-vala/src/module/xep/0199_ping.vala index 800ccfd8..a4157e99 100644 --- a/xmpp-vala/src/module/xep/0199_ping.vala +++ b/xmpp-vala/src/module/xep/0199_ping.vala @@ -12,7 +12,7 @@ namespace Xmpp.Xep.Ping { 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.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 { @@ -27,17 +27,13 @@ namespace Xmpp.Xep.Ping { public override void attach(XmppStream 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 static Module? get_module(XmppStream stream) { - return (Module?) stream.get_module(IDENTITY); - } - 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; } @@ -45,7 +41,7 @@ namespace Xmpp.Xep.Ping { private class IqHandlerImpl : Iq.Handler, Object { 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) { } } diff --git a/xmpp-vala/src/module/xep/0203_delayed_delivery.vala b/xmpp-vala/src/module/xep/0203_delayed_delivery.vala index 4dd8a0cb..4dbe33ff 100644 --- a/xmpp-vala/src/module/xep/0203_delayed_delivery.vala +++ b/xmpp-vala/src/module/xep/0203_delayed_delivery.vala @@ -24,17 +24,13 @@ namespace Xmpp.Xep.DelayedDelivery { } 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 static Module? get_module(XmppStream stream) { - return (Module?) stream.get_module(IDENTITY); - } - 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; } diff --git a/xmpp-vala/src/module/xep/0280_message_carbons.vala b/xmpp-vala/src/module/xep/0280_message_carbons.vala index 097a4a76..6f11ec05 100644 --- a/xmpp-vala/src/module/xep/0280_message_carbons.vala +++ b/xmpp-vala/src/module/xep/0280_message_carbons.vala @@ -9,12 +9,12 @@ namespace Xmpp.Xep.MessageCarbons { public void enable(XmppStream stream) { 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) { 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) { @@ -24,21 +24,17 @@ namespace Xmpp.Xep.MessageCarbons { ServiceDiscovery.Module.require(stream); stream.stream_negotiated.connect(enable); - Message.Module.get_module(stream).pre_received_message.connect(pre_received_message); - ServiceDiscovery.Module.get_module(stream).add_feature(stream, NS_URI); + stream.get_module(Message.Module.IDENTITY).pre_received_message.connect(pre_received_message); + stream.get_module(ServiceDiscovery.Module.IDENTITY).add_feature(stream, NS_URI); } public override void detach(XmppStream stream) { stream.stream_negotiated.disconnect(enable); - Message.Module.get_module(stream).pre_received_message.disconnect(pre_received_message); - } - - public static Module? get_module(XmppStream stream) { - return (Module?) stream.get_module(IDENTITY); + stream.get_module(Message.Module.IDENTITY).pre_received_message.disconnect(pre_received_message); } 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; } diff --git a/xmpp-vala/src/module/xep/0333_chat_markers.vala b/xmpp-vala/src/module/xep/0333_chat_markers.vala index 64388e47..46fb92fa 100644 --- a/xmpp-vala/src/module/xep/0333_chat_markers.vala +++ b/xmpp-vala/src/module/xep/0333_chat_markers.vala @@ -22,7 +22,7 @@ public class Module : XmppStreamModule { received_message.to = jid; received_message.type_ = type_; 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) { @@ -35,22 +35,18 @@ public class Module : XmppStreamModule { Message.Module.require(stream); ServiceDiscovery.Module.require(stream); - ServiceDiscovery.Module.get_module(stream).add_feature(stream, NS_URI); - Message.Module.get_module(stream).pre_send_message.connect(on_pre_send_message); - Message.Module.get_module(stream).received_message.connect(on_received_message); + stream.get_module(ServiceDiscovery.Module.IDENTITY).add_feature(stream, NS_URI); + stream.get_module(Message.Module.IDENTITY).pre_send_message.connect(on_pre_send_message); + stream.get_module(Message.Module.IDENTITY).received_message.connect(on_received_message); } public override void detach(XmppStream stream) { - Message.Module.get_module(stream).pre_send_message.disconnect(on_pre_send_message); - Message.Module.get_module(stream).received_message.disconnect(on_received_message); - } - - public static Module? get_module(XmppStream stream) { - return (Module?) stream.get_module(IDENTITY); + stream.get_module(Message.Module.IDENTITY).pre_send_message.disconnect(on_pre_send_message); + stream.get_module(Message.Module.IDENTITY).received_message.disconnect(on_received_message); } 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; } |