diff --git a/packages/moxxmpp/lib/src/roster/roster.dart b/packages/moxxmpp/lib/src/roster/roster.dart index dc481de..2bdf3bf 100644 --- a/packages/moxxmpp/lib/src/roster/roster.dart +++ b/packages/moxxmpp/lib/src/roster/roster.dart @@ -1,5 +1,6 @@ import 'dart:async'; import 'package:moxxmpp/src/jid.dart'; +import 'package:moxxmpp/src/managers/attributes.dart'; import 'package:moxxmpp/src/managers/base.dart'; import 'package:moxxmpp/src/managers/data.dart'; import 'package:moxxmpp/src/managers/handlers.dart'; @@ -66,10 +67,16 @@ class RosterFeatureNegotiator extends XmppFeatureNegotiatorBase { /// This manager requires a RosterFeatureNegotiator to be registered. class RosterManager extends XmppManagerBase { - RosterManager(this._stateManager) : super() { - _stateManager.register(getAttributes().sendEvent); - } + RosterManager(this._stateManager) : super(); + + /// The class managing the entire roster state. final BaseRosterStateManager _stateManager; + + @override + void register(XmppManagerAttributes attributes) { + super.register(attributes); + _stateManager.register(attributes.sendEvent); + } @override String getId() => rosterManager; diff --git a/packages/moxxmpp/test/negotiator_test.dart b/packages/moxxmpp/test/negotiator_test.dart index e2589ef..f7d5b00 100644 --- a/packages/moxxmpp/test/negotiator_test.dart +++ b/packages/moxxmpp/test/negotiator_test.dart @@ -61,7 +61,7 @@ void main() { ]) ..registerManagers([ PresenceManager('http://moxxmpp.example'), - RosterManager(), + RosterManager(TestingRosterStateManager('', [])), DiscoManager(), PingManager(), ]) diff --git a/packages/moxxmpp/test/xeps/xep_0198_test.dart b/packages/moxxmpp/test/xeps/xep_0198_test.dart index 404cc00..37ab414 100644 --- a/packages/moxxmpp/test/xeps/xep_0198_test.dart +++ b/packages/moxxmpp/test/xeps/xep_0198_test.dart @@ -243,7 +243,7 @@ void main() { final sm = StreamManagementManager(); conn.registerManagers([ PresenceManager('http://moxxmpp.example'), - RosterManager(), + RosterManager(TestingRosterStateManager('', [])), DiscoManager(), PingManager(), sm, @@ -365,7 +365,7 @@ void main() { final sm = StreamManagementManager(); conn.registerManagers([ PresenceManager('http://moxxmpp.example'), - RosterManager(), + RosterManager(TestingRosterStateManager('', [])), DiscoManager(), PingManager(), sm, @@ -519,7 +519,7 @@ void main() { ),); conn.registerManagers([ PresenceManager('http://moxxmpp.example'), - RosterManager(), + RosterManager(TestingRosterStateManager('', [])), DiscoManager(), PingManager(), StreamManagementManager(), @@ -611,7 +611,7 @@ void main() { ),); conn.registerManagers([ PresenceManager('http://moxxmpp.example'), - RosterManager(), + RosterManager(TestingRosterStateManager('', [])), DiscoManager(), PingManager(), StreamManagementManager(), @@ -703,7 +703,7 @@ void main() { ),); conn.registerManagers([ PresenceManager('http://moxxmpp.example'), - RosterManager(), + RosterManager(TestingRosterStateManager('', [])), DiscoManager(), PingManager(), StreamManagementManager(), diff --git a/packages/moxxmpp/test/xmpp_test.dart b/packages/moxxmpp/test/xmpp_test.dart index afbcae7..3e1b3d7 100644 --- a/packages/moxxmpp/test/xmpp_test.dart +++ b/packages/moxxmpp/test/xmpp_test.dart @@ -7,7 +7,7 @@ import 'helpers/xmpp.dart'; /// Returns true if the roster manager triggeres an event for a given stanza Future testRosterManager(String bareJid, String resource, String stanzaString) async { var eventTriggered = false; - final roster = RosterManager(); + final roster = RosterManager(TestingRosterStateManager('', [])); roster.register(XmppManagerAttributes( sendStanza: (_, { StanzaFromType addFrom = StanzaFromType.full, bool addId = true, bool retransmitted = false, bool awaitable = true, bool encrypted = false }) async => XMLNode(tag: 'hallo'), sendEvent: (event) { @@ -127,7 +127,7 @@ void main() { ),); conn.registerManagers([ PresenceManager('http://moxxmpp.example'), - RosterManager(), + RosterManager(TestingRosterStateManager('', [])), DiscoManager(), PingManager(), StreamManagementManager(), @@ -181,7 +181,7 @@ void main() { ),); conn.registerManagers([ PresenceManager('http://moxxmpp.example'), - RosterManager(), + RosterManager(TestingRosterStateManager('', [])), DiscoManager(), PingManager(), ]); @@ -235,7 +235,7 @@ void main() { ),); conn.registerManagers([ PresenceManager('http://moxxmpp.example'), - RosterManager(), + RosterManager(TestingRosterStateManager('', [])), DiscoManager(), PingManager(), ]); @@ -290,7 +290,7 @@ void main() { ),); conn.registerManagers([ PresenceManager('http://moxxmpp.example'), - RosterManager(), + RosterManager(TestingRosterStateManager('', [])), DiscoManager(), PingManager(), ]); @@ -308,7 +308,7 @@ void main() { group('Test roster pushes', () { test('Test for a CVE-2015-8688 style vulnerability', () async { var eventTriggered = false; - final roster = RosterManager(); + final roster = RosterManager(TestingRosterStateManager('', [])); roster.register(XmppManagerAttributes( sendStanza: (_, { StanzaFromType addFrom = StanzaFromType.full, bool addId = true, bool retransmitted = false, bool awaitable = true, bool encrypted = false }) async => XMLNode(tag: 'hallo'), sendEvent: (event) {