Compare commits
No commits in common. "76a9f7be7aa4af29bd37d963dfa1ce6b4a7d371a" and "d4416c8a47fa7ab3e436e5b6af9bdd9e43f1b2ed" have entirely different histories.
76a9f7be7a
...
d4416c8a47
@ -38,7 +38,6 @@ void main(List<String> args) async {
|
|||||||
DiscoManager([]),
|
DiscoManager([]),
|
||||||
PubSubManager(),
|
PubSubManager(),
|
||||||
MessageManager(),
|
MessageManager(),
|
||||||
StableIdManager(),
|
|
||||||
MUCManager(),
|
MUCManager(),
|
||||||
]);
|
]);
|
||||||
await connection.registerFeatureNegotiators([
|
await connection.registerFeatureNegotiators([
|
||||||
@ -58,28 +57,8 @@ void main(List<String> args) async {
|
|||||||
}
|
}
|
||||||
Logger.root.info('Connected.');
|
Logger.root.info('Connected.');
|
||||||
|
|
||||||
// Print received messages.
|
|
||||||
connection
|
|
||||||
.asBroadcastStream()
|
|
||||||
.where((event) => event is MessageEvent)
|
|
||||||
.listen((event) {
|
|
||||||
event as MessageEvent;
|
|
||||||
|
|
||||||
// Ignore messages with no <body />
|
|
||||||
final body = event.get<MessageBodyData>()?.body;
|
|
||||||
if (body == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
print('=====> [${event.from}] $body');
|
|
||||||
});
|
|
||||||
|
|
||||||
// Join room
|
// Join room
|
||||||
await connection.getManagerById<MUCManager>(mucManager)!.joinRoom(
|
await connection.getManagerById<MUCManager>(mucManager)!.joinRoom(muc, nick);
|
||||||
muc,
|
|
||||||
nick,
|
|
||||||
maxHistoryStanzas: 0,
|
|
||||||
);
|
|
||||||
|
|
||||||
final repl = Repl(prompt: '> ');
|
final repl = Repl(prompt: '> ');
|
||||||
await for (final line in repl.runAsync()) {
|
await for (final line in repl.runAsync()) {
|
||||||
@ -89,11 +68,6 @@ void main(List<String> args) async {
|
|||||||
muc,
|
muc,
|
||||||
TypedMap<StanzaHandlerExtension>.fromList([
|
TypedMap<StanzaHandlerExtension>.fromList([
|
||||||
MessageBodyData(line),
|
MessageBodyData(line),
|
||||||
StableIdData(
|
|
||||||
// NOTE: Don't do this. Use a UUID.
|
|
||||||
DateTime.now().millisecondsSinceEpoch.toString(),
|
|
||||||
null,
|
|
||||||
),
|
|
||||||
]),
|
]),
|
||||||
type: 'groupchat');
|
type: 'groupchat');
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ description: A collection of samples for moxxmpp.
|
|||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=3.0.0 <4.0.0'
|
sdk: '>=2.18.0 <3.0.0'
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
args: 2.4.1
|
args: 2.4.1
|
||||||
|
54
flake.lock
54
flake.lock
@ -7,11 +7,11 @@
|
|||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1694377165,
|
"lastModified": 1689798050,
|
||||||
"narHash": "sha256-NeIlZIElbkbKaNK5SZv6ULcFT/UGIICb3q7GPpkf9jk=",
|
"narHash": "sha256-ZyFPra7N0MF803o55dYQQyX9b/BmXr6QTCyN7slRThY=",
|
||||||
"owner": "tadfisher",
|
"owner": "tadfisher",
|
||||||
"repo": "android-nixpkgs",
|
"repo": "android-nixpkgs",
|
||||||
"rev": "b020dc733ee69393841a50cf94d45735d5a5a57a",
|
"rev": "9aa0e2990da86de8ca203af313668851dcb9ea6e",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -29,11 +29,11 @@
|
|||||||
"systems": "systems"
|
"systems": "systems"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1693833206,
|
"lastModified": 1688380630,
|
||||||
"narHash": "sha256-wHOY0nnD6gWj8u9uI85/YlsganYyWRK1hLFZulZwfmY=",
|
"narHash": "sha256-8ilApWVb1mAi4439zS3iFeIT0ODlbrifm/fegWwgHjA=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "devshell",
|
"repo": "devshell",
|
||||||
"rev": "65114ea495a8d3cc1352368bf170d67ef005aa5a",
|
"rev": "f9238ec3d75cefbb2b42a44948c4e8fb1ae9a205",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -47,11 +47,11 @@
|
|||||||
"systems": "systems_2"
|
"systems": "systems_2"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1692799911,
|
"lastModified": 1689068808,
|
||||||
"narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=",
|
"narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44",
|
"rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -61,15 +61,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"flake-utils_2": {
|
"flake-utils_2": {
|
||||||
"inputs": {
|
|
||||||
"systems": "systems_3"
|
|
||||||
},
|
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1692799911,
|
"lastModified": 1667395993,
|
||||||
"narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=",
|
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "flake-utils",
|
"repo": "flake-utils",
|
||||||
"rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44",
|
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -80,11 +77,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1694183432,
|
"lastModified": 1689679375,
|
||||||
"narHash": "sha256-YyPGNapgZNNj51ylQMw9lAgvxtM2ai1HZVUu3GS8Fng=",
|
"narHash": "sha256-LHUC52WvyVDi9PwyL1QCpaxYWBqp4ir4iL6zgOkmcb8=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "db9208ab987cdeeedf78ad9b4cf3c55f5ebd269b",
|
"rev": "684c17c429c42515bafb3ad775d2a710947f3d67",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -96,11 +93,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs_2": {
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1694343207,
|
"lastModified": 1689752456,
|
||||||
"narHash": "sha256-jWi7OwFxU5Owi4k2JmiL1sa/OuBCQtpaAesuj5LXC8w=",
|
"narHash": "sha256-VOChdECcEI8ixz8QY+YC4JaNEFwQd1V8bA0G4B28Ki0=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "78058d810644f5ed276804ce7ea9e82d92bee293",
|
"rev": "7f256d7da238cb627ef189d56ed590739f42f13b",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -146,21 +143,6 @@
|
|||||||
"repo": "default",
|
"repo": "default",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"systems_3": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1681028828,
|
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": "root",
|
"root": "root",
|
||||||
|
@ -68,7 +68,7 @@
|
|||||||
};
|
};
|
||||||
in pkgs.mkShell {
|
in pkgs.mkShell {
|
||||||
buildInputs = with pkgs; [
|
buildInputs = with pkgs; [
|
||||||
flutter pinnedJDK sdk dart # Dart
|
flutter37 pinnedJDK sdk dart # Dart
|
||||||
gitlint # Code hygiene
|
gitlint # Code hygiene
|
||||||
ripgrep # General utilities
|
ripgrep # General utilities
|
||||||
|
|
||||||
|
@ -475,7 +475,7 @@ class XmppConnection {
|
|||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
newStanza,
|
newStanza,
|
||||||
details.extensions ?? TypedMap(),
|
TypedMap(),
|
||||||
encrypted: details.encrypted,
|
encrypted: details.encrypted,
|
||||||
shouldEncrypt: details.shouldEncrypt,
|
shouldEncrypt: details.shouldEncrypt,
|
||||||
forceEncryption: details.forceEncryption,
|
forceEncryption: details.forceEncryption,
|
||||||
|
@ -66,7 +66,7 @@ class MessageManager extends XmppManagerBase {
|
|||||||
stanzaTag: 'message',
|
stanzaTag: 'message',
|
||||||
callback: _onMessage,
|
callback: _onMessage,
|
||||||
priority: messageHandlerPriority,
|
priority: messageHandlerPriority,
|
||||||
),
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -117,7 +117,6 @@ class MessageManager extends XmppManagerBase {
|
|||||||
.flattened
|
.flattened
|
||||||
.toList(),
|
.toList(),
|
||||||
),
|
),
|
||||||
extensions: extensions,
|
|
||||||
awaitable: false,
|
awaitable: false,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -66,7 +66,7 @@ class PresenceManager extends XmppManagerBase {
|
|||||||
stanzaTag: 'presence',
|
stanzaTag: 'presence',
|
||||||
callback: _onPresence,
|
callback: _onPresence,
|
||||||
priority: presenceHandlerPriority,
|
priority: presenceHandlerPriority,
|
||||||
),
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -122,7 +122,7 @@ class RosterManager extends XmppManagerBase {
|
|||||||
tagName: 'query',
|
tagName: 'query',
|
||||||
tagXmlns: rosterXmlns,
|
tagXmlns: rosterXmlns,
|
||||||
callback: _onRosterPush,
|
callback: _onRosterPush,
|
||||||
),
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -277,7 +277,7 @@ class RosterManager extends XmppManagerBase {
|
|||||||
attributes: {
|
attributes: {
|
||||||
'ver': await _stateManager.getRosterVersion() ?? '',
|
'ver': await _stateManager.getRosterVersion() ?? '',
|
||||||
},
|
},
|
||||||
),
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -319,12 +319,14 @@ class RosterManager extends XmppManagerBase {
|
|||||||
tag: 'item',
|
tag: 'item',
|
||||||
attributes: <String, String>{
|
attributes: <String, String>{
|
||||||
'jid': jid,
|
'jid': jid,
|
||||||
if (title == jid.split('@')[0]) 'name': title,
|
...title == jid.split('@')[0]
|
||||||
|
? <String, String>{}
|
||||||
|
: <String, String>{'name': title}
|
||||||
},
|
},
|
||||||
children: (groups ?? [])
|
children: (groups ?? [])
|
||||||
.map((group) => XMLNode(tag: 'group', text: group))
|
.map((group) => XMLNode(tag: 'group', text: group))
|
||||||
.toList(),
|
.toList(),
|
||||||
),
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -355,13 +357,13 @@ class RosterManager extends XmppManagerBase {
|
|||||||
children: [
|
children: [
|
||||||
XMLNode(
|
XMLNode(
|
||||||
tag: 'item',
|
tag: 'item',
|
||||||
attributes: {
|
attributes: <String, String>{
|
||||||
'jid': jid,
|
'jid': jid,
|
||||||
'subscription': 'remove',
|
'subscription': 'remove'
|
||||||
},
|
},
|
||||||
),
|
)
|
||||||
],
|
],
|
||||||
),
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -7,7 +7,6 @@ import 'package:moxxmpp/src/util/typed_map.dart';
|
|||||||
class StanzaDetails {
|
class StanzaDetails {
|
||||||
const StanzaDetails(
|
const StanzaDetails(
|
||||||
this.stanza, {
|
this.stanza, {
|
||||||
this.extensions,
|
|
||||||
this.addId = true,
|
this.addId = true,
|
||||||
this.awaitable = true,
|
this.awaitable = true,
|
||||||
this.shouldEncrypt = true,
|
this.shouldEncrypt = true,
|
||||||
@ -20,9 +19,6 @@ class StanzaDetails {
|
|||||||
/// The stanza to send.
|
/// The stanza to send.
|
||||||
final Stanza stanza;
|
final Stanza stanza;
|
||||||
|
|
||||||
/// The extension data used for constructing the stanza.
|
|
||||||
final TypedMap<StanzaHandlerExtension>? extensions;
|
|
||||||
|
|
||||||
/// Flag indicating whether a stanza id should be added before sending.
|
/// Flag indicating whether a stanza id should be added before sending.
|
||||||
final bool addId;
|
final bool addId;
|
||||||
|
|
||||||
@ -248,14 +244,15 @@ XMLNode buildErrorElement(String type, String condition, {String? text}) {
|
|||||||
XMLNode.xmlns(
|
XMLNode.xmlns(
|
||||||
tag: condition,
|
tag: condition,
|
||||||
xmlns: fullStanzaXmlns,
|
xmlns: fullStanzaXmlns,
|
||||||
children: [
|
children: text != null
|
||||||
if (text != null)
|
? [
|
||||||
XMLNode.xmlns(
|
XMLNode.xmlns(
|
||||||
tag: 'text',
|
tag: 'text',
|
||||||
xmlns: fullStanzaXmlns,
|
xmlns: fullStanzaXmlns,
|
||||||
text: text,
|
text: text,
|
||||||
),
|
)
|
||||||
],
|
]
|
||||||
|
: [],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
@ -10,14 +10,14 @@ class DataFormOption {
|
|||||||
XMLNode toXml() {
|
XMLNode toXml() {
|
||||||
return XMLNode(
|
return XMLNode(
|
||||||
tag: 'option',
|
tag: 'option',
|
||||||
attributes: {
|
attributes: label != null
|
||||||
if (label != null) 'label': label,
|
? <String, dynamic>{'label': label}
|
||||||
},
|
: <String, dynamic>{},
|
||||||
children: [
|
children: [
|
||||||
XMLNode(
|
XMLNode(
|
||||||
tag: 'value',
|
tag: 'value',
|
||||||
text: value,
|
text: value,
|
||||||
),
|
)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -45,22 +45,19 @@ class DataFormField {
|
|||||||
return XMLNode(
|
return XMLNode(
|
||||||
tag: 'field',
|
tag: 'field',
|
||||||
attributes: <String, dynamic>{
|
attributes: <String, dynamic>{
|
||||||
if (varAttr != null) 'var': varAttr,
|
...varAttr != null
|
||||||
if (type != null) 'type': type,
|
? <String, dynamic>{'var': varAttr}
|
||||||
if (label != null) 'label': label,
|
: <String, dynamic>{},
|
||||||
|
...type != null ? <String, dynamic>{'type': type} : <String, dynamic>{},
|
||||||
|
...label != null
|
||||||
|
? <String, dynamic>{'label': label}
|
||||||
|
: <String, dynamic>{}
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
if (description != null)
|
...description != null ? [XMLNode(tag: 'desc', text: description)] : [],
|
||||||
XMLNode(
|
...isRequired ? [XMLNode(tag: 'required')] : [],
|
||||||
tag: 'desc',
|
|
||||||
text: description,
|
|
||||||
),
|
|
||||||
if (isRequired)
|
|
||||||
XMLNode(
|
|
||||||
tag: 'required',
|
|
||||||
),
|
|
||||||
...values.map((value) => XMLNode(tag: 'value', text: value)),
|
...values.map((value) => XMLNode(tag: 'value', text: value)),
|
||||||
...options.map((option) => option.toXml()),
|
...options.map((option) => option.toXml())
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -13,10 +13,8 @@ Stanza buildDiscoInfoQueryStanza(JID entity, String? node) {
|
|||||||
XMLNode.xmlns(
|
XMLNode.xmlns(
|
||||||
tag: 'query',
|
tag: 'query',
|
||||||
xmlns: discoInfoXmlns,
|
xmlns: discoInfoXmlns,
|
||||||
attributes: {
|
attributes: node != null ? {'node': node} : {},
|
||||||
if (node != null) 'node': node,
|
)
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -29,10 +27,8 @@ Stanza buildDiscoItemsQueryStanza(JID entity, {String? node}) {
|
|||||||
XMLNode.xmlns(
|
XMLNode.xmlns(
|
||||||
tag: 'query',
|
tag: 'query',
|
||||||
xmlns: discoItemsXmlns,
|
xmlns: discoItemsXmlns,
|
||||||
attributes: {
|
attributes: node != null ? {'node': node} : {},
|
||||||
if (node != null) 'node': node,
|
)
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -19,11 +19,13 @@ class Identity {
|
|||||||
XMLNode toXMLNode() {
|
XMLNode toXMLNode() {
|
||||||
return XMLNode(
|
return XMLNode(
|
||||||
tag: 'identity',
|
tag: 'identity',
|
||||||
attributes: {
|
attributes: <String, dynamic>{
|
||||||
'category': category,
|
'category': category,
|
||||||
'type': type,
|
'type': type,
|
||||||
'name': name,
|
'name': name,
|
||||||
if (lang != null) 'xml:lang': lang,
|
...lang == null
|
||||||
|
? <String, dynamic>{}
|
||||||
|
: <String, dynamic>{'xml:lang': lang}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -33,22 +33,11 @@ class RoomInformation {
|
|||||||
final String name;
|
final String name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The used message-id and an optional origin-id.
|
|
||||||
typedef PendingMessage = (String, String?);
|
|
||||||
|
|
||||||
class RoomState {
|
class RoomState {
|
||||||
RoomState({required this.roomJid, this.nick, required this.joined}) {
|
RoomState({
|
||||||
pendingMessages = List<PendingMessage>.empty(growable: true);
|
required this.roomJid,
|
||||||
}
|
this.nick,
|
||||||
|
});
|
||||||
/// The JID of the room.
|
|
||||||
final JID roomJid;
|
final JID roomJid;
|
||||||
|
|
||||||
/// The nick we're joined with.
|
|
||||||
String? nick;
|
String? nick;
|
||||||
|
|
||||||
/// Flag whether we're joined and can process messages
|
|
||||||
bool joined;
|
|
||||||
|
|
||||||
late final List<PendingMessage> pendingMessages;
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
import 'package:moxlib/moxlib.dart';
|
import 'package:moxlib/moxlib.dart';
|
||||||
import 'package:moxxmpp/src/events.dart';
|
|
||||||
import 'package:moxxmpp/src/jid.dart';
|
import 'package:moxxmpp/src/jid.dart';
|
||||||
import 'package:moxxmpp/src/managers/base.dart';
|
import 'package:moxxmpp/src/managers/base.dart';
|
||||||
import 'package:moxxmpp/src/managers/data.dart';
|
|
||||||
import 'package:moxxmpp/src/managers/handlers.dart';
|
|
||||||
import 'package:moxxmpp/src/managers/namespaces.dart';
|
import 'package:moxxmpp/src/managers/namespaces.dart';
|
||||||
import 'package:moxxmpp/src/namespaces.dart';
|
import 'package:moxxmpp/src/namespaces.dart';
|
||||||
import 'package:moxxmpp/src/stanza.dart';
|
import 'package:moxxmpp/src/stanza.dart';
|
||||||
@ -12,13 +9,8 @@ import 'package:moxxmpp/src/xeps/xep_0030/types.dart';
|
|||||||
import 'package:moxxmpp/src/xeps/xep_0030/xep_0030.dart';
|
import 'package:moxxmpp/src/xeps/xep_0030/xep_0030.dart';
|
||||||
import 'package:moxxmpp/src/xeps/xep_0045/errors.dart';
|
import 'package:moxxmpp/src/xeps/xep_0045/errors.dart';
|
||||||
import 'package:moxxmpp/src/xeps/xep_0045/types.dart';
|
import 'package:moxxmpp/src/xeps/xep_0045/types.dart';
|
||||||
import 'package:moxxmpp/src/xeps/xep_0359.dart';
|
|
||||||
import 'package:synchronized/extension.dart';
|
|
||||||
import 'package:synchronized/synchronized.dart';
|
import 'package:synchronized/synchronized.dart';
|
||||||
|
|
||||||
/// (Room JID, nickname)
|
|
||||||
typedef MUCRoomJoin = (JID, String);
|
|
||||||
|
|
||||||
class MUCManager extends XmppManagerBase {
|
class MUCManager extends XmppManagerBase {
|
||||||
MUCManager() : super(mucManager);
|
MUCManager() : super(mucManager);
|
||||||
|
|
||||||
@ -31,78 +23,6 @@ class MUCManager extends XmppManagerBase {
|
|||||||
/// Cache lock
|
/// Cache lock
|
||||||
final Lock _cacheLock = Lock();
|
final Lock _cacheLock = Lock();
|
||||||
|
|
||||||
/// Flag indicating whether we joined the rooms added to the room list with
|
|
||||||
/// [prepareRoomList].
|
|
||||||
bool _joinedPreparedRooms = true;
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<StanzaHandler> getIncomingStanzaHandlers() => [
|
|
||||||
StanzaHandler(
|
|
||||||
stanzaTag: 'message',
|
|
||||||
callback: _onMessage,
|
|
||||||
// Before the message handler
|
|
||||||
priority: -99,
|
|
||||||
),
|
|
||||||
];
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<StanzaHandler> getOutgoingPreStanzaHandlers() => [
|
|
||||||
StanzaHandler(
|
|
||||||
stanzaTag: 'message',
|
|
||||||
callback: _onMessageSent,
|
|
||||||
),
|
|
||||||
];
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<void> onXmppEvent(XmppEvent event) async {
|
|
||||||
if (event is! StreamNegotiationsDoneEvent) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only attempt rejoining if we did not resume the stream and all
|
|
||||||
// prepared rooms are already joined.
|
|
||||||
if (event.resumed && _joinedPreparedRooms) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await _cacheLock.synchronized(() async {
|
|
||||||
// Mark all groupchats as not joined.
|
|
||||||
for (final jid in _mucRoomCache.keys) {
|
|
||||||
_mucRoomCache[jid]!.joined = false;
|
|
||||||
|
|
||||||
// Re-join all MUCs.
|
|
||||||
final state = _mucRoomCache[jid]!;
|
|
||||||
await _sendMucJoin(
|
|
||||||
jid,
|
|
||||||
state.nick!,
|
|
||||||
0,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
_joinedPreparedRooms = true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Prepares the internal room list to ensure that the rooms
|
|
||||||
/// [rooms] are joined once we are connected.
|
|
||||||
Future<void> prepareRoomList(List<MUCRoomJoin> rooms) async {
|
|
||||||
assert(
|
|
||||||
rooms.isNotEmpty,
|
|
||||||
'The room list should not be empty',
|
|
||||||
);
|
|
||||||
|
|
||||||
await _cacheLock.synchronized(() {
|
|
||||||
_joinedPreparedRooms = false;
|
|
||||||
for (final room in rooms) {
|
|
||||||
final (roomJid, nick) = room;
|
|
||||||
_mucRoomCache[roomJid] = RoomState(
|
|
||||||
roomJid: roomJid,
|
|
||||||
nick: nick,
|
|
||||||
joined: false,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Queries the information of a Multi-User Chat room.
|
/// Queries the information of a Multi-User Chat room.
|
||||||
///
|
///
|
||||||
/// Retrieves the information about the specified MUC room by performing a
|
/// Retrieves the information about the specified MUC room by performing a
|
||||||
@ -135,32 +55,11 @@ class MUCManager extends XmppManagerBase {
|
|||||||
/// if applicable.
|
/// if applicable.
|
||||||
Future<Result<bool, MUCError>> joinRoom(
|
Future<Result<bool, MUCError>> joinRoom(
|
||||||
JID roomJid,
|
JID roomJid,
|
||||||
String nick, {
|
String nick,
|
||||||
int? maxHistoryStanzas,
|
) async {
|
||||||
}) async {
|
|
||||||
if (nick.isEmpty) {
|
if (nick.isEmpty) {
|
||||||
return Result(NoNicknameSpecified());
|
return Result(NoNicknameSpecified());
|
||||||
}
|
}
|
||||||
|
|
||||||
await _cacheLock.synchronized(
|
|
||||||
() {
|
|
||||||
_mucRoomCache[roomJid] = RoomState(
|
|
||||||
roomJid: roomJid,
|
|
||||||
nick: nick,
|
|
||||||
joined: false,
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
await _sendMucJoin(roomJid, nick, maxHistoryStanzas);
|
|
||||||
return const Result(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> _sendMucJoin(
|
|
||||||
JID roomJid,
|
|
||||||
String nick,
|
|
||||||
int? maxHistoryStanzas,
|
|
||||||
) async {
|
|
||||||
await getAttributes().sendStanza(
|
await getAttributes().sendStanza(
|
||||||
StanzaDetails(
|
StanzaDetails(
|
||||||
Stanza.presence(
|
Stanza.presence(
|
||||||
@ -169,20 +68,17 @@ class MUCManager extends XmppManagerBase {
|
|||||||
XMLNode.xmlns(
|
XMLNode.xmlns(
|
||||||
tag: 'x',
|
tag: 'x',
|
||||||
xmlns: mucXmlns,
|
xmlns: mucXmlns,
|
||||||
children: [
|
)
|
||||||
if (maxHistoryStanzas != null)
|
|
||||||
XMLNode(
|
|
||||||
tag: 'history',
|
|
||||||
attributes: {
|
|
||||||
'maxstanzas': maxHistoryStanzas.toString(),
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
await _cacheLock.synchronized(
|
||||||
|
() {
|
||||||
|
_mucRoomCache[roomJid] = RoomState(roomJid: roomJid, nick: nick);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
return const Result(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Leaves a Multi-User Chat room.
|
/// Leaves a Multi-User Chat room.
|
||||||
@ -212,86 +108,4 @@ class MUCManager extends XmppManagerBase {
|
|||||||
);
|
);
|
||||||
return const Result(true);
|
return const Result(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<StanzaHandlerData> _onMessageSent(
|
|
||||||
Stanza message,
|
|
||||||
StanzaHandlerData state,
|
|
||||||
) async {
|
|
||||||
if (message.to == null) {
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
final toJid = JID.fromString(message.to!);
|
|
||||||
|
|
||||||
return _cacheLock.synchronized(() {
|
|
||||||
if (!_mucRoomCache.containsKey(toJid)) {
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
_mucRoomCache[toJid]!.pendingMessages.add(
|
|
||||||
(message.id!, state.extensions.get<StableIdData>()?.originId),
|
|
||||||
);
|
|
||||||
return state;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<StanzaHandlerData> _onMessage(
|
|
||||||
Stanza message,
|
|
||||||
StanzaHandlerData state,
|
|
||||||
) async {
|
|
||||||
final fromJid = JID.fromString(message.from!);
|
|
||||||
final roomJid = fromJid.toBare();
|
|
||||||
return _mucRoomCache.synchronized(() {
|
|
||||||
final roomState = _mucRoomCache[roomJid];
|
|
||||||
if (roomState == null) {
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (message.type == 'groupchat' && message.firstTag('subject') != null) {
|
|
||||||
// The room subject marks the end of the join flow.
|
|
||||||
if (!roomState.joined) {
|
|
||||||
// Mark the room as joined.
|
|
||||||
_mucRoomCache[roomJid]!.joined = true;
|
|
||||||
logger.finest('$roomJid is now joined');
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(Unknown): Signal the subject?
|
|
||||||
|
|
||||||
return StanzaHandlerData(
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
message,
|
|
||||||
state.extensions,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
if (!roomState.joined) {
|
|
||||||
// Ignore the discussion history.
|
|
||||||
return StanzaHandlerData(
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
message,
|
|
||||||
state.extensions,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if this is the message reflection.
|
|
||||||
final pending =
|
|
||||||
(message.id!, state.extensions.get<StableIdData>()?.originId);
|
|
||||||
if (fromJid.resource == roomState.nick &&
|
|
||||||
roomState.pendingMessages.contains(pending)) {
|
|
||||||
// Silently drop the message.
|
|
||||||
roomState.pendingMessages.remove(pending);
|
|
||||||
|
|
||||||
// TODO(Unknown): Maybe send an event stating that we received the reflection.
|
|
||||||
return StanzaHandlerData(
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
message,
|
|
||||||
state.extensions,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return state;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ class VCardManager extends XmppManagerBase {
|
|||||||
tagName: 'x',
|
tagName: 'x',
|
||||||
tagXmlns: vCardTempUpdate,
|
tagXmlns: vCardTempUpdate,
|
||||||
callback: _onPresence,
|
callback: _onPresence,
|
||||||
),
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -108,7 +108,7 @@ class VCardManager extends XmppManagerBase {
|
|||||||
XMLNode.xmlns(
|
XMLNode.xmlns(
|
||||||
tag: 'vCard',
|
tag: 'vCard',
|
||||||
xmlns: vCardTempXmlns,
|
xmlns: vCardTempXmlns,
|
||||||
),
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
encrypted: true,
|
encrypted: true,
|
||||||
|
@ -38,20 +38,26 @@ class PubSubPublishOptions {
|
|||||||
varAttr: 'FORM_TYPE',
|
varAttr: 'FORM_TYPE',
|
||||||
type: 'hidden',
|
type: 'hidden',
|
||||||
),
|
),
|
||||||
if (accessModel != null)
|
...accessModel != null
|
||||||
DataFormField(
|
? [
|
||||||
options: [],
|
DataFormField(
|
||||||
isRequired: false,
|
options: [],
|
||||||
values: [accessModel!],
|
isRequired: false,
|
||||||
varAttr: 'pubsub#access_model',
|
values: [accessModel!],
|
||||||
),
|
varAttr: 'pubsub#access_model',
|
||||||
if (maxItems != null)
|
)
|
||||||
DataFormField(
|
]
|
||||||
options: [],
|
: [],
|
||||||
isRequired: false,
|
...maxItems != null
|
||||||
values: [maxItems!],
|
? [
|
||||||
varAttr: 'pubsub#max_items',
|
DataFormField(
|
||||||
),
|
options: [],
|
||||||
|
isRequired: false,
|
||||||
|
values: [maxItems!],
|
||||||
|
varAttr: 'pubsub#max_items',
|
||||||
|
),
|
||||||
|
]
|
||||||
|
: [],
|
||||||
],
|
],
|
||||||
).toXml();
|
).toXml();
|
||||||
}
|
}
|
||||||
@ -81,7 +87,7 @@ class PubSubManager extends XmppManagerBase {
|
|||||||
tagName: 'event',
|
tagName: 'event',
|
||||||
tagXmlns: pubsubEventXmlns,
|
tagXmlns: pubsubEventXmlns,
|
||||||
callback: _onPubsubMessage,
|
callback: _onPubsubMessage,
|
||||||
),
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -308,11 +314,11 @@ class PubSubManager extends XmppManagerBase {
|
|||||||
children: [
|
children: [
|
||||||
XMLNode(
|
XMLNode(
|
||||||
tag: 'item',
|
tag: 'item',
|
||||||
attributes: {
|
attributes: id != null
|
||||||
if (id != null) 'id': id,
|
? <String, String>{'id': id}
|
||||||
},
|
: <String, String>{},
|
||||||
children: [payload],
|
children: [payload],
|
||||||
),
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
if (pubOptions != null)
|
if (pubOptions != null)
|
||||||
@ -321,7 +327,7 @@ class PubSubManager extends XmppManagerBase {
|
|||||||
children: [pubOptions.toXml()],
|
children: [pubOptions.toXml()],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
shouldEncrypt: false,
|
shouldEncrypt: false,
|
||||||
@ -416,7 +422,7 @@ class PubSubManager extends XmppManagerBase {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
shouldEncrypt: false,
|
shouldEncrypt: false,
|
||||||
|
@ -45,7 +45,7 @@ class OOBManager extends XmppManagerBase {
|
|||||||
callback: _onMessage,
|
callback: _onMessage,
|
||||||
// Before the message manager
|
// Before the message manager
|
||||||
priority: -99,
|
priority: -99,
|
||||||
),
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -69,7 +69,7 @@ class ChatStateManager extends XmppManagerBase {
|
|||||||
callback: _onChatStateReceived,
|
callback: _onChatStateReceived,
|
||||||
// Before the message handler
|
// Before the message handler
|
||||||
priority: -99,
|
priority: -99,
|
||||||
),
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -66,7 +66,7 @@ class MessageDeliveryReceiptManager extends XmppManagerBase {
|
|||||||
callback: _onDeliveryRequestReceived,
|
callback: _onDeliveryRequestReceived,
|
||||||
// Before the message handler
|
// Before the message handler
|
||||||
priority: -99,
|
priority: -99,
|
||||||
),
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -27,7 +27,7 @@ class BlockingManager extends XmppManagerBase {
|
|||||||
tagName: 'block',
|
tagName: 'block',
|
||||||
tagXmlns: blockingXmlns,
|
tagXmlns: blockingXmlns,
|
||||||
callback: _blockPush,
|
callback: _blockPush,
|
||||||
),
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -107,12 +107,10 @@ class BlockingManager extends XmppManagerBase {
|
|||||||
children: items.map((item) {
|
children: items.map((item) {
|
||||||
return XMLNode(
|
return XMLNode(
|
||||||
tag: 'item',
|
tag: 'item',
|
||||||
attributes: {
|
attributes: <String, String>{'jid': item},
|
||||||
'jid': item,
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
),
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -130,7 +128,7 @@ class BlockingManager extends XmppManagerBase {
|
|||||||
XMLNode.xmlns(
|
XMLNode.xmlns(
|
||||||
tag: 'unblock',
|
tag: 'unblock',
|
||||||
xmlns: blockingXmlns,
|
xmlns: blockingXmlns,
|
||||||
),
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -154,13 +152,11 @@ class BlockingManager extends XmppManagerBase {
|
|||||||
.map(
|
.map(
|
||||||
(item) => XMLNode(
|
(item) => XMLNode(
|
||||||
tag: 'item',
|
tag: 'item',
|
||||||
attributes: {
|
attributes: <String, String>{'jid': item},
|
||||||
'jid': item,
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.toList(),
|
.toList(),
|
||||||
),
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -178,7 +174,7 @@ class BlockingManager extends XmppManagerBase {
|
|||||||
XMLNode.xmlns(
|
XMLNode.xmlns(
|
||||||
tag: 'blocklist',
|
tag: 'blocklist',
|
||||||
xmlns: blockingXmlns,
|
xmlns: blockingXmlns,
|
||||||
),
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -5,10 +5,7 @@ class StreamManagementEnableNonza extends XMLNode {
|
|||||||
StreamManagementEnableNonza()
|
StreamManagementEnableNonza()
|
||||||
: super(
|
: super(
|
||||||
tag: 'enable',
|
tag: 'enable',
|
||||||
attributes: {
|
attributes: <String, String>{'xmlns': smXmlns, 'resume': 'true'},
|
||||||
'xmlns': smXmlns,
|
|
||||||
'resume': 'true',
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -16,10 +13,10 @@ class StreamManagementResumeNonza extends XMLNode {
|
|||||||
StreamManagementResumeNonza(String id, int h)
|
StreamManagementResumeNonza(String id, int h)
|
||||||
: super(
|
: super(
|
||||||
tag: 'resume',
|
tag: 'resume',
|
||||||
attributes: {
|
attributes: <String, String>{
|
||||||
'xmlns': smXmlns,
|
'xmlns': smXmlns,
|
||||||
'previd': id,
|
'previd': id,
|
||||||
'h': h.toString(),
|
'h': h.toString()
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -28,10 +25,7 @@ class StreamManagementAckNonza extends XMLNode {
|
|||||||
StreamManagementAckNonza(int h)
|
StreamManagementAckNonza(int h)
|
||||||
: super(
|
: super(
|
||||||
tag: 'a',
|
tag: 'a',
|
||||||
attributes: {
|
attributes: <String, String>{'xmlns': smXmlns, 'h': h.toString()},
|
||||||
'xmlns': smXmlns,
|
|
||||||
'h': h.toString(),
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +33,7 @@ class StreamManagementRequestNonza extends XMLNode {
|
|||||||
StreamManagementRequestNonza()
|
StreamManagementRequestNonza()
|
||||||
: super(
|
: super(
|
||||||
tag: 'r',
|
tag: 'r',
|
||||||
attributes: {
|
attributes: <String, String>{
|
||||||
'xmlns': smXmlns,
|
'xmlns': smXmlns,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -140,7 +140,7 @@ class StreamManagementManager extends XmppManagerBase {
|
|||||||
nonzaTag: 'a',
|
nonzaTag: 'a',
|
||||||
nonzaXmlns: smXmlns,
|
nonzaXmlns: smXmlns,
|
||||||
callback: _handleAckResponse,
|
callback: _handleAckResponse,
|
||||||
),
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -148,14 +148,14 @@ class StreamManagementManager extends XmppManagerBase {
|
|||||||
StanzaHandler(
|
StanzaHandler(
|
||||||
callback: _onServerStanzaReceived,
|
callback: _onServerStanzaReceived,
|
||||||
priority: 9999,
|
priority: 9999,
|
||||||
),
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<StanzaHandler> getOutgoingPostStanzaHandlers() => [
|
List<StanzaHandler> getOutgoingPostStanzaHandlers() => [
|
||||||
StanzaHandler(
|
StanzaHandler(
|
||||||
callback: _onClientStanzaSent,
|
callback: _onClientStanzaSent,
|
||||||
),
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -49,7 +49,7 @@ class CarbonsManager extends XmppManagerBase {
|
|||||||
tagXmlns: carbonsXmlns,
|
tagXmlns: carbonsXmlns,
|
||||||
callback: _onMessageSent,
|
callback: _onMessageSent,
|
||||||
priority: -98,
|
priority: -98,
|
||||||
),
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -124,7 +124,7 @@ class CarbonsManager extends XmppManagerBase {
|
|||||||
XMLNode.xmlns(
|
XMLNode.xmlns(
|
||||||
tag: 'enable',
|
tag: 'enable',
|
||||||
xmlns: carbonsXmlns,
|
xmlns: carbonsXmlns,
|
||||||
),
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -154,7 +154,7 @@ class CarbonsManager extends XmppManagerBase {
|
|||||||
XMLNode.xmlns(
|
XMLNode.xmlns(
|
||||||
tag: 'disable',
|
tag: 'disable',
|
||||||
xmlns: carbonsXmlns,
|
xmlns: carbonsXmlns,
|
||||||
),
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -40,7 +40,7 @@ class LastMessageCorrectionManager extends XmppManagerBase {
|
|||||||
callback: _onMessage,
|
callback: _onMessage,
|
||||||
// Before the message handler
|
// Before the message handler
|
||||||
priority: -99,
|
priority: -99,
|
||||||
),
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -100,7 +100,7 @@ class ChatMarkerManager extends XmppManagerBase {
|
|||||||
callback: _onMessage,
|
callback: _onMessage,
|
||||||
// Before the message handler
|
// Before the message handler
|
||||||
priority: -99,
|
priority: -99,
|
||||||
),
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -81,7 +81,7 @@ class StableIdManager extends XmppManagerBase {
|
|||||||
callback: _onMessage,
|
callback: _onMessage,
|
||||||
// Before the MessageManager
|
// Before the MessageManager
|
||||||
priority: -99,
|
priority: -99,
|
||||||
),
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -127,13 +127,7 @@ class StableIdManager extends XmppManagerBase {
|
|||||||
TypedMap<StanzaHandlerExtension> extensions,
|
TypedMap<StanzaHandlerExtension> extensions,
|
||||||
) {
|
) {
|
||||||
final data = extensions.get<StableIdData>();
|
final data = extensions.get<StableIdData>();
|
||||||
if (data?.originId != null) {
|
return data != null ? data.toXML() : [];
|
||||||
return [
|
|
||||||
data!.toOriginIdElement(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
return [];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -161,9 +161,9 @@ class HttpFileUploadManager extends XmppManagerBase {
|
|||||||
attributes: {
|
attributes: {
|
||||||
'filename': filename,
|
'filename': filename,
|
||||||
'size': filesize.toString(),
|
'size': filesize.toString(),
|
||||||
if (contentType != null) 'content-type': contentType,
|
...contentType != null ? {'content-type': contentType} : {}
|
||||||
},
|
},
|
||||||
),
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -2,10 +2,10 @@ abstract class OmemoError {}
|
|||||||
|
|
||||||
class UnknownOmemoError extends OmemoError {}
|
class UnknownOmemoError extends OmemoError {}
|
||||||
|
|
||||||
class InvalidAffixElementsException implements Exception {}
|
class InvalidAffixElementsException with Exception {}
|
||||||
|
|
||||||
class OmemoNotSupportedForContactException extends OmemoError {}
|
class OmemoNotSupportedForContactException extends OmemoError {}
|
||||||
|
|
||||||
class EncryptionFailedException implements Exception {}
|
class EncryptionFailedException with Exception {}
|
||||||
|
|
||||||
class InvalidEnvelopePayloadException implements Exception {}
|
class InvalidEnvelopePayloadException with Exception {}
|
||||||
|
@ -82,7 +82,7 @@ class SIMSManager extends XmppManagerBase {
|
|||||||
tagXmlns: referenceXmlns,
|
tagXmlns: referenceXmlns,
|
||||||
// Before the message handler
|
// Before the message handler
|
||||||
priority: -99,
|
priority: -99,
|
||||||
),
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -31,7 +31,7 @@ class MessageRetractionManager extends XmppManagerBase {
|
|||||||
callback: _onMessage,
|
callback: _onMessage,
|
||||||
// Before the MessageManager
|
// Before the MessageManager
|
||||||
priority: -99,
|
priority: -99,
|
||||||
),
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -133,7 +133,7 @@ class SFSManager extends XmppManagerBase {
|
|||||||
callback: _onMessage,
|
callback: _onMessage,
|
||||||
// Before the message handler
|
// Before the message handler
|
||||||
priority: -98,
|
priority: -98,
|
||||||
),
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -96,7 +96,7 @@ class MessageRepliesManager extends XmppManagerBase {
|
|||||||
callback: _onMessage,
|
callback: _onMessage,
|
||||||
// Before the message handler
|
// Before the message handler
|
||||||
priority: -99,
|
priority: -99,
|
||||||
),
|
)
|
||||||
];
|
];
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -5,7 +5,7 @@ homepage: https://codeberg.org/moxxy/moxxmpp
|
|||||||
publish_to: https://git.polynom.me/api/packages/Moxxy/pub
|
publish_to: https://git.polynom.me/api/packages/Moxxy/pub
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=3.0.0 <4.0.0'
|
sdk: '>=2.17.5 <3.0.0'
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
collection: ^1.16.0
|
collection: ^1.16.0
|
||||||
|
@ -14,9 +14,9 @@ final scramSha1StreamFeatures = XMLNode(
|
|||||||
XMLNode(
|
XMLNode(
|
||||||
tag: 'mechanism',
|
tag: 'mechanism',
|
||||||
text: 'SCRAM-SHA-1',
|
text: 'SCRAM-SHA-1',
|
||||||
),
|
)
|
||||||
],
|
],
|
||||||
),
|
)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
final scramSha256StreamFeatures = XMLNode(
|
final scramSha256StreamFeatures = XMLNode(
|
||||||
@ -29,9 +29,9 @@ final scramSha256StreamFeatures = XMLNode(
|
|||||||
XMLNode(
|
XMLNode(
|
||||||
tag: 'mechanism',
|
tag: 'mechanism',
|
||||||
text: 'SCRAM-SHA-256',
|
text: 'SCRAM-SHA-256',
|
||||||
),
|
)
|
||||||
],
|
],
|
||||||
),
|
)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
tagName: '3',
|
tagName: '3',
|
||||||
priority: 50,
|
priority: 50,
|
||||||
),
|
)
|
||||||
]..sort(stanzaHandlerSortComparator);
|
]..sort(stanzaHandlerSortComparator);
|
||||||
|
|
||||||
expect(handlerList[0].tagName, '1');
|
expect(handlerList[0].tagName, '1');
|
||||||
|
@ -158,7 +158,7 @@ void main() {
|
|||||||
</iq>''',
|
</iq>''',
|
||||||
ignoreId: true,
|
ignoreId: true,
|
||||||
adjustId: true,
|
adjustId: true,
|
||||||
),
|
)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ class StubbedDiscoManager extends DiscoManager {
|
|||||||
isRequired: false,
|
isRequired: false,
|
||||||
varAttr: 'FORM_TYPE',
|
varAttr: 'FORM_TYPE',
|
||||||
type: 'hidden',
|
type: 'hidden',
|
||||||
),
|
)
|
||||||
],
|
],
|
||||||
reported: [],
|
reported: [],
|
||||||
items: [],
|
items: [],
|
||||||
@ -153,14 +153,14 @@ void main() {
|
|||||||
'http://jabber.org/protocol/caps',
|
'http://jabber.org/protocol/caps',
|
||||||
'http://jabber.org/protocol/disco#info',
|
'http://jabber.org/protocol/disco#info',
|
||||||
'http://jabber.org/protocol/disco#items',
|
'http://jabber.org/protocol/disco#items',
|
||||||
'http://jabber.org/protocol/muc',
|
'http://jabber.org/protocol/muc'
|
||||||
],
|
],
|
||||||
const [
|
const [
|
||||||
Identity(
|
Identity(
|
||||||
category: 'client',
|
category: 'client',
|
||||||
type: 'pc',
|
type: 'pc',
|
||||||
name: 'Exodus 0.9.1',
|
name: 'Exodus 0.9.1',
|
||||||
),
|
)
|
||||||
],
|
],
|
||||||
const [],
|
const [],
|
||||||
null,
|
null,
|
||||||
@ -179,7 +179,7 @@ void main() {
|
|||||||
'http://jabber.org/protocol/caps',
|
'http://jabber.org/protocol/caps',
|
||||||
'http://jabber.org/protocol/disco#info',
|
'http://jabber.org/protocol/disco#info',
|
||||||
'http://jabber.org/protocol/disco#items',
|
'http://jabber.org/protocol/disco#items',
|
||||||
'http://jabber.org/protocol/muc',
|
'http://jabber.org/protocol/muc'
|
||||||
],
|
],
|
||||||
const [
|
const [
|
||||||
Identity(
|
Identity(
|
||||||
@ -295,14 +295,14 @@ void main() {
|
|||||||
'urn:xmpp:message-correct:0',
|
'urn:xmpp:message-correct:0',
|
||||||
'urn:xmpp:ping',
|
'urn:xmpp:ping',
|
||||||
'urn:xmpp:receipts',
|
'urn:xmpp:receipts',
|
||||||
'urn:xmpp:time',
|
'urn:xmpp:time'
|
||||||
],
|
],
|
||||||
const [
|
const [
|
||||||
Identity(
|
Identity(
|
||||||
category: 'client',
|
category: 'client',
|
||||||
type: 'phone',
|
type: 'phone',
|
||||||
name: 'Conversations',
|
name: 'Conversations',
|
||||||
),
|
)
|
||||||
],
|
],
|
||||||
const [],
|
const [],
|
||||||
null,
|
null,
|
||||||
|
@ -433,11 +433,10 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('Test a failed stream resumption', () async {
|
test('Test a failed stream resumption', () async {
|
||||||
final fakeSocket = StubTCPSocket(
|
final fakeSocket = StubTCPSocket([
|
||||||
[
|
StringExpectation(
|
||||||
StringExpectation(
|
"<stream:stream xmlns='jabber:client' version='1.0' xmlns:stream='http://etherx.jabber.org/streams' to='test.server' from='polynomdivision@test.server' xml:lang='en'>",
|
||||||
"<stream:stream xmlns='jabber:client' version='1.0' xmlns:stream='http://etherx.jabber.org/streams' to='test.server' from='polynomdivision@test.server' xml:lang='en'>",
|
'''
|
||||||
'''
|
|
||||||
<stream:stream
|
<stream:stream
|
||||||
xmlns="jabber:client"
|
xmlns="jabber:client"
|
||||||
version="1.0"
|
version="1.0"
|
||||||
@ -449,14 +448,14 @@ void main() {
|
|||||||
<mechanism>PLAIN</mechanism>
|
<mechanism>PLAIN</mechanism>
|
||||||
</mechanisms>
|
</mechanisms>
|
||||||
</stream:features>''',
|
</stream:features>''',
|
||||||
),
|
),
|
||||||
StringExpectation(
|
StringExpectation(
|
||||||
"<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>AHBvbHlub21kaXZpc2lvbgBhYWFh</auth>",
|
"<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>AHBvbHlub21kaXZpc2lvbgBhYWFh</auth>",
|
||||||
'<success xmlns="urn:ietf:params:xml:ns:xmpp-sasl" />',
|
'<success xmlns="urn:ietf:params:xml:ns:xmpp-sasl" />',
|
||||||
),
|
),
|
||||||
StringExpectation(
|
StringExpectation(
|
||||||
"<stream:stream xmlns='jabber:client' version='1.0' xmlns:stream='http://etherx.jabber.org/streams' to='test.server' from='polynomdivision@test.server' xml:lang='en'>",
|
"<stream:stream xmlns='jabber:client' version='1.0' xmlns:stream='http://etherx.jabber.org/streams' to='test.server' from='polynomdivision@test.server' xml:lang='en'>",
|
||||||
'''
|
'''
|
||||||
<stream:stream
|
<stream:stream
|
||||||
xmlns="jabber:client"
|
xmlns="jabber:client"
|
||||||
version="1.0"
|
version="1.0"
|
||||||
@ -474,22 +473,21 @@ void main() {
|
|||||||
<sm xmlns="urn:xmpp:sm:3"/>
|
<sm xmlns="urn:xmpp:sm:3"/>
|
||||||
</stream:features>
|
</stream:features>
|
||||||
''',
|
''',
|
||||||
),
|
),
|
||||||
StringExpectation(
|
StringExpectation(
|
||||||
"<resume xmlns='urn:xmpp:sm:3' previd='id-1' h='10' />",
|
"<resume xmlns='urn:xmpp:sm:3' previd='id-1' h='10' />",
|
||||||
"<failed xmlns='urn:xmpp:sm:3' h='another-sequence-number'><item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></failed>",
|
"<failed xmlns='urn:xmpp:sm:3' h='another-sequence-number'><item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/></failed>",
|
||||||
),
|
),
|
||||||
StanzaExpectation(
|
StanzaExpectation(
|
||||||
'<iq xmlns="jabber:client" type="set" id="a"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/></iq>',
|
'<iq xmlns="jabber:client" type="set" id="a"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"/></iq>',
|
||||||
'<iq xmlns="jabber:client" type="result" id="a"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><jid>polynomdivision@test.server/MU29eEZn</jid></bind></iq>',
|
'<iq xmlns="jabber:client" type="result" id="a"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><jid>polynomdivision@test.server/MU29eEZn</jid></bind></iq>',
|
||||||
ignoreId: true,
|
ignoreId: true,
|
||||||
),
|
),
|
||||||
StringExpectation(
|
StringExpectation(
|
||||||
"<enable xmlns='urn:xmpp:sm:3' resume='true' />",
|
"<enable xmlns='urn:xmpp:sm:3' resume='true' />",
|
||||||
'<enabled xmlns="urn:xmpp:sm:3" id="id-2" resume="true" />',
|
'<enabled xmlns="urn:xmpp:sm:3" id="id-2" resume="true" />',
|
||||||
),
|
)
|
||||||
],
|
]);
|
||||||
);
|
|
||||||
|
|
||||||
final conn = XmppConnection(
|
final conn = XmppConnection(
|
||||||
TestingReconnectionPolicy(),
|
TestingReconnectionPolicy(),
|
||||||
|
@ -115,19 +115,17 @@ void main() {
|
|||||||
test('Test sending a message processing hint', () async {
|
test('Test sending a message processing hint', () async {
|
||||||
final manager = MessageManager();
|
final manager = MessageManager();
|
||||||
final holder = TestingManagerHolder(
|
final holder = TestingManagerHolder(
|
||||||
stubSocket: StubTCPSocket(
|
stubSocket: StubTCPSocket([
|
||||||
[
|
StanzaExpectation(
|
||||||
StanzaExpectation(
|
'''
|
||||||
'''
|
|
||||||
<message to="user@example.org" type="chat">
|
<message to="user@example.org" type="chat">
|
||||||
<no-copy xmlns="urn:xmpp:hints"/>
|
<no-copy xmlns="urn:xmpp:hints"/>
|
||||||
<no-store xmlns="urn:xmpp:hints"/>
|
<no-store xmlns="urn:xmpp:hints"/>
|
||||||
</message>
|
</message>
|
||||||
''',
|
''',
|
||||||
'',
|
'',
|
||||||
),
|
)
|
||||||
],
|
]),
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
await holder.register([
|
await holder.register([
|
||||||
|
@ -6,7 +6,7 @@ void main() {
|
|||||||
test('invariance', () {
|
test('invariance', () {
|
||||||
final headers = {
|
final headers = {
|
||||||
'authorization': 'Basic Base64String==',
|
'authorization': 'Basic Base64String==',
|
||||||
'cookie': 'foo=bar; user=romeo',
|
'cookie': 'foo=bar; user=romeo'
|
||||||
};
|
};
|
||||||
expect(
|
expect(
|
||||||
prepareHeaders(headers),
|
prepareHeaders(headers),
|
||||||
@ -16,7 +16,7 @@ void main() {
|
|||||||
test('invariance through uppercase', () {
|
test('invariance through uppercase', () {
|
||||||
final headers = {
|
final headers = {
|
||||||
'Authorization': 'Basic Base64String==',
|
'Authorization': 'Basic Base64String==',
|
||||||
'Cookie': 'foo=bar; user=romeo',
|
'Cookie': 'foo=bar; user=romeo'
|
||||||
};
|
};
|
||||||
expect(
|
expect(
|
||||||
prepareHeaders(headers),
|
prepareHeaders(headers),
|
||||||
@ -27,7 +27,7 @@ void main() {
|
|||||||
final headers = {
|
final headers = {
|
||||||
'Authorization': 'Basic Base64String==',
|
'Authorization': 'Basic Base64String==',
|
||||||
'Cookie': 'foo=bar; user=romeo',
|
'Cookie': 'foo=bar; user=romeo',
|
||||||
'X-Tracking': 'Base64String==',
|
'X-Tracking': 'Base64String=='
|
||||||
};
|
};
|
||||||
expect(prepareHeaders(headers), {
|
expect(prepareHeaders(headers), {
|
||||||
'Authorization': 'Basic Base64String==',
|
'Authorization': 'Basic Base64String==',
|
||||||
|
Loading…
Reference in New Issue
Block a user