From d5493a185a5dcc48beaf229c1055c570f3cde2ef Mon Sep 17 00:00:00 2001 From: "Alexander \"PapaTutuWawa" Date: Wed, 9 Nov 2022 16:52:59 +0100 Subject: [PATCH] feat: Remove Moxxy specific strings --- example/lib/main.dart | 2 +- .../moxxmpp/lib/src/managers/namespaces.dart | 52 +++++++++---------- .../lib/src/negotiators/namespaces.dart | 18 +++---- packages/moxxmpp/lib/src/presence.dart | 8 +-- .../lib/src/xeps/xep_0030/xep_0030.dart | 4 +- packages/moxxmpp/test/negotiator_test.dart | 2 +- packages/moxxmpp/test/xeps/xep_0030.dart | 4 +- packages/moxxmpp/test/xeps/xep_0198_test.dart | 12 ++--- packages/moxxmpp/test/xmpp_test.dart | 10 ++-- 9 files changed, 57 insertions(+), 55 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 0591fba..17506f9 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -69,7 +69,7 @@ class _MyHomePageState extends State { RosterManager(), PingManager(), MessageManager(), - PresenceManager(), + PresenceManager('http://moxxmpp.example'), ]) ..registerFeatureNegotiators([ ResourceBindingNegotiator(), diff --git a/packages/moxxmpp/lib/src/managers/namespaces.dart b/packages/moxxmpp/lib/src/managers/namespaces.dart index 04c674c..afb4b33 100644 --- a/packages/moxxmpp/lib/src/managers/namespaces.dart +++ b/packages/moxxmpp/lib/src/managers/namespaces.dart @@ -1,26 +1,26 @@ -const smManager = 'im.moxxy.streammangementmanager'; -const discoManager = 'im.moxxy.discomanager'; -const messageManager = 'im.moxxy.messagemanager'; -const rosterManager = 'im.moxxy.rostermanager'; -const presenceManager = 'im.moxxy.presencemanager'; -const csiManager = 'im.moxxy.csimanager'; -const carbonsManager = 'im.moxxy.carbonsmanager'; -const vcardManager = 'im.moxxy.vcardmanager'; -const pubsubManager = 'im.moxxy.pubsubmanager'; -const userAvatarManager = 'im.moxxy.useravatarmanager'; -const stableIdManager = 'im.moxxy.stableidmanager'; -const simsManager = 'im.moxxy.simsmanager'; -const messageDeliveryReceiptManager = 'im.moxxy.messagedeliveryreceiptmanager'; -const chatMarkerManager = 'im.moxxy.chatmarkermanager'; -const oobManager = 'im.moxxy.oobmanager'; -const sfsManager = 'im.moxxy.sfsmanager'; -const messageRepliesManager = 'im.moxxy.messagerepliesmanager'; -const blockingManager = 'im.moxxy.blockingmanager'; -const httpFileUploadManager = 'im.moxxy.httpfileuploadmanager'; -const chatStateManager = 'im.moxxy.chatstatemanager'; -const pingManager = 'im.moxxy.ping'; -const fileUploadNotificationManager = 'im.moxxy.fileuploadnotificationmanager'; -const omemoManager = 'org.moxxy.omemomanager'; -const emeManager = 'org.moxxy.ememanager'; -const cryptographicHashManager = 'org.moxxy.cryptographichashmanager'; -const delayedDeliveryManager = 'org.moxxy.delayeddeliverymanager'; +const smManager = 'im.moxxmpp.streammangementmanager'; +const discoManager = 'im.moxxmpp.discomanager'; +const messageManager = 'im.moxxmpp.messagemanager'; +const rosterManager = 'im.moxxmpp.rostermanager'; +const presenceManager = 'im.moxxmpp.presencemanager'; +const csiManager = 'im.moxxmpp.csimanager'; +const carbonsManager = 'im.moxxmpp.carbonsmanager'; +const vcardManager = 'im.moxxmpp.vcardmanager'; +const pubsubManager = 'im.moxxmpp.pubsubmanager'; +const userAvatarManager = 'im.moxxmpp.useravatarmanager'; +const stableIdManager = 'im.moxxmpp.stableidmanager'; +const simsManager = 'im.moxxmpp.simsmanager'; +const messageDeliveryReceiptManager = 'im.moxxmpp.messagedeliveryreceiptmanager'; +const chatMarkerManager = 'im.moxxmpp.chatmarkermanager'; +const oobManager = 'im.moxxmpp.oobmanager'; +const sfsManager = 'im.moxxmpp.sfsmanager'; +const messageRepliesManager = 'im.moxxmpp.messagerepliesmanager'; +const blockingManager = 'im.moxxmpp.blockingmanager'; +const httpFileUploadManager = 'im.moxxmpp.httpfileuploadmanager'; +const chatStateManager = 'im.moxxmpp.chatstatemanager'; +const pingManager = 'im.moxxmpp.ping'; +const fileUploadNotificationManager = 'im.moxxmpp.fileuploadnotificationmanager'; +const omemoManager = 'org.moxxmpp.omemomanager'; +const emeManager = 'org.moxxmpp.ememanager'; +const cryptographicHashManager = 'org.moxxmpp.cryptographichashmanager'; +const delayedDeliveryManager = 'org.moxxmpp.delayeddeliverymanager'; diff --git a/packages/moxxmpp/lib/src/negotiators/namespaces.dart b/packages/moxxmpp/lib/src/negotiators/namespaces.dart index 8ea71fb..00595b7 100644 --- a/packages/moxxmpp/lib/src/negotiators/namespaces.dart +++ b/packages/moxxmpp/lib/src/negotiators/namespaces.dart @@ -1,9 +1,9 @@ -const saslPlainNegotiator = 'im.moxxy.sasl.plain'; -const saslScramSha1Negotiator = 'im.moxxy.sasl.scram.sha1'; -const saslScramSha256Negotiator = 'im.moxxy.sasl.scram.sha256'; -const saslScramSha512Negotiator = 'im.moxxy.sasl.scram.sha512'; -const csiNegotiator = 'im.moxxy.xeps.csi'; -const rosterNegotiator = 'im.moxxy.core.roster'; -const resourceBindingNegotiator = 'im.moxxy.core.resource'; -const streamManagementNegotiator = 'im.moxxy.xeps.sm'; -const startTlsNegotiator = 'im.moxxy.core.starttls'; +const saslPlainNegotiator = 'im.moxxmpp.sasl.plain'; +const saslScramSha1Negotiator = 'im.moxxmpp.sasl.scram.sha1'; +const saslScramSha256Negotiator = 'im.moxxmpp.sasl.scram.sha256'; +const saslScramSha512Negotiator = 'im.moxxmpp.sasl.scram.sha512'; +const csiNegotiator = 'im.moxxmpp.xeps.csi'; +const rosterNegotiator = 'im.moxxmpp.core.roster'; +const resourceBindingNegotiator = 'im.moxxmpp.core.resource'; +const streamManagementNegotiator = 'im.moxxmpp.xeps.sm'; +const startTlsNegotiator = 'im.moxxmpp.core.starttls'; diff --git a/packages/moxxmpp/lib/src/presence.dart b/packages/moxxmpp/lib/src/presence.dart index e8140f4..eabef7b 100644 --- a/packages/moxxmpp/lib/src/presence.dart +++ b/packages/moxxmpp/lib/src/presence.dart @@ -14,9 +14,11 @@ import 'package:moxxmpp/src/xeps/xep_0115.dart'; import 'package:moxxmpp/src/xeps/xep_0414.dart'; class PresenceManager extends XmppManagerBase { - - PresenceManager() : _capabilityHash = null, super(); + PresenceManager(this._capHashNode) : _capabilityHash = null, super(); String? _capabilityHash; + final String _capHashNode; + + String get capabilityHashNode => _capHashNode; @override String getId() => presenceManager; @@ -93,7 +95,7 @@ class PresenceManager extends XmppManagerBase { xmlns: capsXmlns, attributes: { 'hash': 'sha-1', - 'node': 'http://moxxy.im', + 'node': _capHashNode, 'ver': await getCapabilityHash() }, ) diff --git a/packages/moxxmpp/lib/src/xeps/xep_0030/xep_0030.dart b/packages/moxxmpp/lib/src/xeps/xep_0030/xep_0030.dart index 6c44860..4e31763 100644 --- a/packages/moxxmpp/lib/src/xeps/xep_0030/xep_0030.dart +++ b/packages/moxxmpp/lib/src/xeps/xep_0030/xep_0030.dart @@ -157,7 +157,7 @@ class DiscoManager extends XmppManagerBase { final query = stanza.firstTag('query')!; final node = query.attributes['node'] as String?; final capHash = await presence.getCapabilityHash(); - final isCapabilityNode = node == 'http://moxxy.im#$capHash'; + final isCapabilityNode = node == '${presence.capabilityHashNode}#$capHash'; if (!isCapabilityNode && node != null) { await getAttributes().sendStanza(Stanza.iq( @@ -200,7 +200,7 @@ class DiscoManager extends XmppManagerBase { xmlns: discoInfoXmlns, attributes: { ...!isCapabilityNode ? {} : { - 'node': 'http://moxxy.im#$capHash' + 'node': '${presence.capabilityHashNode}#$capHash' } }, children: [ diff --git a/packages/moxxmpp/test/negotiator_test.dart b/packages/moxxmpp/test/negotiator_test.dart index a8bf526..5b934a0 100644 --- a/packages/moxxmpp/test/negotiator_test.dart +++ b/packages/moxxmpp/test/negotiator_test.dart @@ -60,7 +60,7 @@ void main() { StubNegotiator2(), ]) ..registerManagers([ - PresenceManager(), + PresenceManager('http://moxxmpp.example'), RosterManager(), DiscoManager(), PingManager(), diff --git a/packages/moxxmpp/test/xeps/xep_0030.dart b/packages/moxxmpp/test/xeps/xep_0030.dart index 1e50b31..cfd5272 100644 --- a/packages/moxxmpp/test/xeps/xep_0030.dart +++ b/packages/moxxmpp/test/xeps/xep_0030.dart @@ -53,7 +53,7 @@ void main() { ignoreId: true, ), StringExpectation( - "chat", + "chat", '', ), StanzaExpectation( @@ -73,7 +73,7 @@ void main() { allowPlainAuth: true, ),); conn.registerManagers([ - PresenceManager(), + PresenceManager('http://moxxmpp.example'), RosterManager(), DiscoManager(), PingManager(), diff --git a/packages/moxxmpp/test/xeps/xep_0198_test.dart b/packages/moxxmpp/test/xeps/xep_0198_test.dart index e099f35..404cc00 100644 --- a/packages/moxxmpp/test/xeps/xep_0198_test.dart +++ b/packages/moxxmpp/test/xeps/xep_0198_test.dart @@ -242,7 +242,7 @@ void main() { ),); final sm = StreamManagementManager(); conn.registerManagers([ - PresenceManager(), + PresenceManager('http://moxxmpp.example'), RosterManager(), DiscoManager(), PingManager(), @@ -343,7 +343,7 @@ void main() { '', ), StringExpectation( - "chat", + "chat", '', ), StanzaExpectation( @@ -364,7 +364,7 @@ void main() { ),); final sm = StreamManagementManager(); conn.registerManagers([ - PresenceManager(), + PresenceManager('http://moxxmpp.example'), RosterManager(), DiscoManager(), PingManager(), @@ -518,7 +518,7 @@ void main() { allowPlainAuth: true, ),); conn.registerManagers([ - PresenceManager(), + PresenceManager('http://moxxmpp.example'), RosterManager(), DiscoManager(), PingManager(), @@ -610,7 +610,7 @@ void main() { allowPlainAuth: true, ),); conn.registerManagers([ - PresenceManager(), + PresenceManager('http://moxxmpp.example'), RosterManager(), DiscoManager(), PingManager(), @@ -702,7 +702,7 @@ void main() { allowPlainAuth: true, ),); conn.registerManagers([ - PresenceManager(), + PresenceManager('http://moxxmpp.example'), RosterManager(), DiscoManager(), PingManager(), diff --git a/packages/moxxmpp/test/xmpp_test.dart b/packages/moxxmpp/test/xmpp_test.dart index c18c448..afbcae7 100644 --- a/packages/moxxmpp/test/xmpp_test.dart +++ b/packages/moxxmpp/test/xmpp_test.dart @@ -104,7 +104,7 @@ void main() { attributes: { // TODO: Somehow make the test ignore this attribute 'ver': 'QRTBC5cg/oYd+UOTYazSQR4zb/I=', - 'node': 'http://moxxy.im', + 'node': 'http://moxxmpp.example', 'hash': 'sha-1' }, ) @@ -126,7 +126,7 @@ void main() { allowPlainAuth: true, ),); conn.registerManagers([ - PresenceManager(), + PresenceManager('http://moxxmpp.example'), RosterManager(), DiscoManager(), PingManager(), @@ -180,7 +180,7 @@ void main() { allowPlainAuth: true, ),); conn.registerManagers([ - PresenceManager(), + PresenceManager('http://moxxmpp.example'), RosterManager(), DiscoManager(), PingManager(), @@ -234,7 +234,7 @@ void main() { allowPlainAuth: true, ),); conn.registerManagers([ - PresenceManager(), + PresenceManager('http://moxxmpp.example'), RosterManager(), DiscoManager(), PingManager(), @@ -289,7 +289,7 @@ void main() { allowPlainAuth: false, ),); conn.registerManagers([ - PresenceManager(), + PresenceManager('http://moxxmpp.example'), RosterManager(), DiscoManager(), PingManager(),