Compare commits
9 Commits
moxxmpp-v0
...
moxxmpp_so
| Author | SHA1 | Date | |
|---|---|---|---|
| d1de394cd9 | |||
| 14c48bcc64 | |||
| 138edffb0a | |||
| eb8f6ba17a | |||
| beff05765b | |||
| 3b7ded3b96 | |||
| edc86a10b3 | |||
| 39e9c55fae | |||
| 1b2c567787 |
@@ -16,10 +16,10 @@ dependencies:
|
|||||||
version: 0.1.4+1
|
version: 0.1.4+1
|
||||||
moxxmpp:
|
moxxmpp:
|
||||||
hosted: https://git.polynom.me/api/packages/Moxxy/pub
|
hosted: https://git.polynom.me/api/packages/Moxxy/pub
|
||||||
version: 0.1.3
|
version: 0.1.6
|
||||||
moxxmpp_socket_tcp:
|
moxxmpp_socket_tcp:
|
||||||
hosted: https://git.polynom.me/api/packages/Moxxy/pub
|
hosted: https://git.polynom.me/api/packages/Moxxy/pub
|
||||||
version: 0.1.2+4
|
version: 0.1.2+8
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|||||||
@@ -1,3 +1,20 @@
|
|||||||
|
## 0.1.6
|
||||||
|
|
||||||
|
- **FEAT**: Implement XEP-0308.
|
||||||
|
|
||||||
|
## 0.1.5
|
||||||
|
|
||||||
|
- **FEAT**: Message events now contain the stanza error, if available.
|
||||||
|
|
||||||
|
## 0.1.4
|
||||||
|
|
||||||
|
- **FIX**: Only stanza-id required 'sid:0' support.
|
||||||
|
- **FEAT**: Implement parsing and sending of retractions.
|
||||||
|
|
||||||
|
## 0.1.3+1
|
||||||
|
|
||||||
|
- **FIX**: Expose the error classes.
|
||||||
|
|
||||||
## 0.1.3
|
## 0.1.3
|
||||||
|
|
||||||
- **REFACTOR**: Replace MayFail by Result.
|
- **REFACTOR**: Replace MayFail by Result.
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
library moxxmpp;
|
library moxxmpp;
|
||||||
|
|
||||||
export 'package:moxxmpp/src/connection.dart';
|
export 'package:moxxmpp/src/connection.dart';
|
||||||
|
export 'package:moxxmpp/src/errors.dart';
|
||||||
export 'package:moxxmpp/src/events.dart';
|
export 'package:moxxmpp/src/events.dart';
|
||||||
export 'package:moxxmpp/src/iq.dart';
|
export 'package:moxxmpp/src/iq.dart';
|
||||||
export 'package:moxxmpp/src/jid.dart';
|
export 'package:moxxmpp/src/jid.dart';
|
||||||
@@ -16,6 +17,7 @@ export 'package:moxxmpp/src/negotiators/manager.dart';
|
|||||||
export 'package:moxxmpp/src/negotiators/namespaces.dart';
|
export 'package:moxxmpp/src/negotiators/namespaces.dart';
|
||||||
export 'package:moxxmpp/src/negotiators/negotiator.dart';
|
export 'package:moxxmpp/src/negotiators/negotiator.dart';
|
||||||
export 'package:moxxmpp/src/negotiators/resource_binding.dart';
|
export 'package:moxxmpp/src/negotiators/resource_binding.dart';
|
||||||
|
export 'package:moxxmpp/src/negotiators/sasl/errors.dart';
|
||||||
export 'package:moxxmpp/src/negotiators/sasl/negotiator.dart';
|
export 'package:moxxmpp/src/negotiators/sasl/negotiator.dart';
|
||||||
export 'package:moxxmpp/src/negotiators/sasl/plain.dart';
|
export 'package:moxxmpp/src/negotiators/sasl/plain.dart';
|
||||||
export 'package:moxxmpp/src/negotiators/sasl/scram.dart';
|
export 'package:moxxmpp/src/negotiators/sasl/scram.dart';
|
||||||
@@ -71,6 +73,7 @@ export 'package:moxxmpp/src/xeps/xep_0384/types.dart';
|
|||||||
export 'package:moxxmpp/src/xeps/xep_0384/xep_0384.dart';
|
export 'package:moxxmpp/src/xeps/xep_0384/xep_0384.dart';
|
||||||
export 'package:moxxmpp/src/xeps/xep_0385.dart';
|
export 'package:moxxmpp/src/xeps/xep_0385.dart';
|
||||||
export 'package:moxxmpp/src/xeps/xep_0414.dart';
|
export 'package:moxxmpp/src/xeps/xep_0414.dart';
|
||||||
|
export 'package:moxxmpp/src/xeps/xep_0424.dart';
|
||||||
export 'package:moxxmpp/src/xeps/xep_0446.dart';
|
export 'package:moxxmpp/src/xeps/xep_0446.dart';
|
||||||
export 'package:moxxmpp/src/xeps/xep_0447.dart';
|
export 'package:moxxmpp/src/xeps/xep_0447.dart';
|
||||||
export 'package:moxxmpp/src/xeps/xep_0448.dart';
|
export 'package:moxxmpp/src/xeps/xep_0448.dart';
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import 'package:moxxmpp/src/xeps/xep_0066.dart';
|
|||||||
import 'package:moxxmpp/src/xeps/xep_0085.dart';
|
import 'package:moxxmpp/src/xeps/xep_0085.dart';
|
||||||
import 'package:moxxmpp/src/xeps/xep_0359.dart';
|
import 'package:moxxmpp/src/xeps/xep_0359.dart';
|
||||||
import 'package:moxxmpp/src/xeps/xep_0385.dart';
|
import 'package:moxxmpp/src/xeps/xep_0385.dart';
|
||||||
|
import 'package:moxxmpp/src/xeps/xep_0424.dart';
|
||||||
import 'package:moxxmpp/src/xeps/xep_0446.dart';
|
import 'package:moxxmpp/src/xeps/xep_0446.dart';
|
||||||
import 'package:moxxmpp/src/xeps/xep_0447.dart';
|
import 'package:moxxmpp/src/xeps/xep_0447.dart';
|
||||||
import 'package:moxxmpp/src/xeps/xep_0461.dart';
|
import 'package:moxxmpp/src/xeps/xep_0461.dart';
|
||||||
@@ -62,6 +63,7 @@ class MessageEvent extends XmppEvent {
|
|||||||
required this.isMarkable,
|
required this.isMarkable,
|
||||||
required this.encrypted,
|
required this.encrypted,
|
||||||
required this.other,
|
required this.other,
|
||||||
|
this.error,
|
||||||
this.type,
|
this.type,
|
||||||
this.oob,
|
this.oob,
|
||||||
this.sfs,
|
this.sfs,
|
||||||
@@ -71,7 +73,10 @@ class MessageEvent extends XmppEvent {
|
|||||||
this.fun,
|
this.fun,
|
||||||
this.funReplacement,
|
this.funReplacement,
|
||||||
this.funCancellation,
|
this.funCancellation,
|
||||||
|
this.messageRetraction,
|
||||||
|
this.messageCorrectionId,
|
||||||
});
|
});
|
||||||
|
final StanzaError? error;
|
||||||
final String body;
|
final String body;
|
||||||
final JID fromJid;
|
final JID fromJid;
|
||||||
final JID toJid;
|
final JID toJid;
|
||||||
@@ -90,6 +95,8 @@ class MessageEvent extends XmppEvent {
|
|||||||
final String? funReplacement;
|
final String? funReplacement;
|
||||||
final String? funCancellation;
|
final String? funCancellation;
|
||||||
final bool encrypted;
|
final bool encrypted;
|
||||||
|
final MessageRetractionData? messageRetraction;
|
||||||
|
final String? messageCorrectionId;
|
||||||
final Map<String, dynamic> other;
|
final Map<String, dynamic> other;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import 'package:moxxmpp/src/xeps/xep_0203.dart';
|
|||||||
import 'package:moxxmpp/src/xeps/xep_0359.dart';
|
import 'package:moxxmpp/src/xeps/xep_0359.dart';
|
||||||
import 'package:moxxmpp/src/xeps/xep_0380.dart';
|
import 'package:moxxmpp/src/xeps/xep_0380.dart';
|
||||||
import 'package:moxxmpp/src/xeps/xep_0385.dart';
|
import 'package:moxxmpp/src/xeps/xep_0385.dart';
|
||||||
|
import 'package:moxxmpp/src/xeps/xep_0424.dart';
|
||||||
import 'package:moxxmpp/src/xeps/xep_0446.dart';
|
import 'package:moxxmpp/src/xeps/xep_0446.dart';
|
||||||
import 'package:moxxmpp/src/xeps/xep_0447.dart';
|
import 'package:moxxmpp/src/xeps/xep_0447.dart';
|
||||||
import 'package:moxxmpp/src/xeps/xep_0461.dart';
|
import 'package:moxxmpp/src/xeps/xep_0461.dart';
|
||||||
@@ -55,6 +56,11 @@ class StanzaHandlerData with _$StanzaHandlerData {
|
|||||||
// This is for stanza handlers that are not part of the XMPP library but still need
|
// This is for stanza handlers that are not part of the XMPP library but still need
|
||||||
// pass data around.
|
// pass data around.
|
||||||
@Default(<String, dynamic>{}) Map<String, dynamic> other,
|
@Default(<String, dynamic>{}) Map<String, dynamic> other,
|
||||||
|
// If non-null, then it indicates the origin Id of the message that should be
|
||||||
|
// retracted
|
||||||
|
MessageRetractionData? messageRetraction,
|
||||||
|
// If non-null, then the message is a correction for the specified stanza Id
|
||||||
|
String? lastMessageCorrectionSid,
|
||||||
}
|
}
|
||||||
) = _StanzaHandlerData;
|
) = _StanzaHandlerData;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,12 @@ mixin _$StanzaHandlerData {
|
|||||||
DelayedDelivery? get delayedDelivery =>
|
DelayedDelivery? get delayedDelivery =>
|
||||||
throw _privateConstructorUsedError; // This is for stanza handlers that are not part of the XMPP library but still need
|
throw _privateConstructorUsedError; // This is for stanza handlers that are not part of the XMPP library but still need
|
||||||
// pass data around.
|
// pass data around.
|
||||||
Map<String, dynamic> get other => throw _privateConstructorUsedError;
|
Map<String, dynamic> get other =>
|
||||||
|
throw _privateConstructorUsedError; // If non-null, then it indicates the origin Id of the message that should be
|
||||||
|
// retracted
|
||||||
|
MessageRetractionData? get messageRetraction =>
|
||||||
|
throw _privateConstructorUsedError; // If non-null, then the message is a correction for the specified stanza Id
|
||||||
|
String? get lastMessageCorrectionSid => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
$StanzaHandlerDataCopyWith<StanzaHandlerData> get copyWith =>
|
$StanzaHandlerDataCopyWith<StanzaHandlerData> get copyWith =>
|
||||||
@@ -87,7 +92,9 @@ abstract class $StanzaHandlerDataCopyWith<$Res> {
|
|||||||
bool encrypted,
|
bool encrypted,
|
||||||
ExplicitEncryptionType? encryptionType,
|
ExplicitEncryptionType? encryptionType,
|
||||||
DelayedDelivery? delayedDelivery,
|
DelayedDelivery? delayedDelivery,
|
||||||
Map<String, dynamic> other});
|
Map<String, dynamic> other,
|
||||||
|
MessageRetractionData? messageRetraction,
|
||||||
|
String? lastMessageCorrectionSid});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@@ -122,6 +129,8 @@ class _$StanzaHandlerDataCopyWithImpl<$Res>
|
|||||||
Object? encryptionType = freezed,
|
Object? encryptionType = freezed,
|
||||||
Object? delayedDelivery = freezed,
|
Object? delayedDelivery = freezed,
|
||||||
Object? other = freezed,
|
Object? other = freezed,
|
||||||
|
Object? messageRetraction = freezed,
|
||||||
|
Object? lastMessageCorrectionSid = freezed,
|
||||||
}) {
|
}) {
|
||||||
return _then(_value.copyWith(
|
return _then(_value.copyWith(
|
||||||
done: done == freezed
|
done: done == freezed
|
||||||
@@ -208,6 +217,14 @@ class _$StanzaHandlerDataCopyWithImpl<$Res>
|
|||||||
? _value.other
|
? _value.other
|
||||||
: other // ignore: cast_nullable_to_non_nullable
|
: other // ignore: cast_nullable_to_non_nullable
|
||||||
as Map<String, dynamic>,
|
as Map<String, dynamic>,
|
||||||
|
messageRetraction: messageRetraction == freezed
|
||||||
|
? _value.messageRetraction
|
||||||
|
: messageRetraction // ignore: cast_nullable_to_non_nullable
|
||||||
|
as MessageRetractionData?,
|
||||||
|
lastMessageCorrectionSid: lastMessageCorrectionSid == freezed
|
||||||
|
? _value.lastMessageCorrectionSid
|
||||||
|
: lastMessageCorrectionSid // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String?,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -240,7 +257,9 @@ abstract class _$$_StanzaHandlerDataCopyWith<$Res>
|
|||||||
bool encrypted,
|
bool encrypted,
|
||||||
ExplicitEncryptionType? encryptionType,
|
ExplicitEncryptionType? encryptionType,
|
||||||
DelayedDelivery? delayedDelivery,
|
DelayedDelivery? delayedDelivery,
|
||||||
Map<String, dynamic> other});
|
Map<String, dynamic> other,
|
||||||
|
MessageRetractionData? messageRetraction,
|
||||||
|
String? lastMessageCorrectionSid});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@@ -277,6 +296,8 @@ class __$$_StanzaHandlerDataCopyWithImpl<$Res>
|
|||||||
Object? encryptionType = freezed,
|
Object? encryptionType = freezed,
|
||||||
Object? delayedDelivery = freezed,
|
Object? delayedDelivery = freezed,
|
||||||
Object? other = freezed,
|
Object? other = freezed,
|
||||||
|
Object? messageRetraction = freezed,
|
||||||
|
Object? lastMessageCorrectionSid = freezed,
|
||||||
}) {
|
}) {
|
||||||
return _then(_$_StanzaHandlerData(
|
return _then(_$_StanzaHandlerData(
|
||||||
done == freezed
|
done == freezed
|
||||||
@@ -363,6 +384,14 @@ class __$$_StanzaHandlerDataCopyWithImpl<$Res>
|
|||||||
? _value._other
|
? _value._other
|
||||||
: other // ignore: cast_nullable_to_non_nullable
|
: other // ignore: cast_nullable_to_non_nullable
|
||||||
as Map<String, dynamic>,
|
as Map<String, dynamic>,
|
||||||
|
messageRetraction: messageRetraction == freezed
|
||||||
|
? _value.messageRetraction
|
||||||
|
: messageRetraction // ignore: cast_nullable_to_non_nullable
|
||||||
|
as MessageRetractionData?,
|
||||||
|
lastMessageCorrectionSid: lastMessageCorrectionSid == freezed
|
||||||
|
? _value.lastMessageCorrectionSid
|
||||||
|
: lastMessageCorrectionSid // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String?,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -387,7 +416,9 @@ class _$_StanzaHandlerData implements _StanzaHandlerData {
|
|||||||
this.encrypted = false,
|
this.encrypted = false,
|
||||||
this.encryptionType,
|
this.encryptionType,
|
||||||
this.delayedDelivery,
|
this.delayedDelivery,
|
||||||
final Map<String, dynamic> other = const <String, dynamic>{}})
|
final Map<String, dynamic> other = const <String, dynamic>{},
|
||||||
|
this.messageRetraction,
|
||||||
|
this.lastMessageCorrectionSid})
|
||||||
: _other = other;
|
: _other = other;
|
||||||
|
|
||||||
// Indicates to the runner that processing is now done. This means that all
|
// Indicates to the runner that processing is now done. This means that all
|
||||||
@@ -463,9 +494,17 @@ class _$_StanzaHandlerData implements _StanzaHandlerData {
|
|||||||
return EqualUnmodifiableMapView(_other);
|
return EqualUnmodifiableMapView(_other);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If non-null, then it indicates the origin Id of the message that should be
|
||||||
|
// retracted
|
||||||
|
@override
|
||||||
|
final MessageRetractionData? messageRetraction;
|
||||||
|
// If non-null, then the message is a correction for the specified stanza Id
|
||||||
|
@override
|
||||||
|
final String? lastMessageCorrectionSid;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'StanzaHandlerData(done: $done, cancel: $cancel, cancelReason: $cancelReason, stanza: $stanza, retransmitted: $retransmitted, sims: $sims, sfs: $sfs, oob: $oob, stableId: $stableId, reply: $reply, chatState: $chatState, isCarbon: $isCarbon, deliveryReceiptRequested: $deliveryReceiptRequested, isMarkable: $isMarkable, fun: $fun, funReplacement: $funReplacement, funCancellation: $funCancellation, encrypted: $encrypted, encryptionType: $encryptionType, delayedDelivery: $delayedDelivery, other: $other)';
|
return 'StanzaHandlerData(done: $done, cancel: $cancel, cancelReason: $cancelReason, stanza: $stanza, retransmitted: $retransmitted, sims: $sims, sfs: $sfs, oob: $oob, stableId: $stableId, reply: $reply, chatState: $chatState, isCarbon: $isCarbon, deliveryReceiptRequested: $deliveryReceiptRequested, isMarkable: $isMarkable, fun: $fun, funReplacement: $funReplacement, funCancellation: $funCancellation, encrypted: $encrypted, encryptionType: $encryptionType, delayedDelivery: $delayedDelivery, other: $other, messageRetraction: $messageRetraction, lastMessageCorrectionSid: $lastMessageCorrectionSid)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -501,7 +540,11 @@ class _$_StanzaHandlerData implements _StanzaHandlerData {
|
|||||||
.equals(other.encryptionType, encryptionType) &&
|
.equals(other.encryptionType, encryptionType) &&
|
||||||
const DeepCollectionEquality()
|
const DeepCollectionEquality()
|
||||||
.equals(other.delayedDelivery, delayedDelivery) &&
|
.equals(other.delayedDelivery, delayedDelivery) &&
|
||||||
const DeepCollectionEquality().equals(other._other, this._other));
|
const DeepCollectionEquality().equals(other._other, this._other) &&
|
||||||
|
const DeepCollectionEquality()
|
||||||
|
.equals(other.messageRetraction, messageRetraction) &&
|
||||||
|
const DeepCollectionEquality().equals(
|
||||||
|
other.lastMessageCorrectionSid, lastMessageCorrectionSid));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -527,7 +570,9 @@ class _$_StanzaHandlerData implements _StanzaHandlerData {
|
|||||||
const DeepCollectionEquality().hash(encrypted),
|
const DeepCollectionEquality().hash(encrypted),
|
||||||
const DeepCollectionEquality().hash(encryptionType),
|
const DeepCollectionEquality().hash(encryptionType),
|
||||||
const DeepCollectionEquality().hash(delayedDelivery),
|
const DeepCollectionEquality().hash(delayedDelivery),
|
||||||
const DeepCollectionEquality().hash(_other)
|
const DeepCollectionEquality().hash(_other),
|
||||||
|
const DeepCollectionEquality().hash(messageRetraction),
|
||||||
|
const DeepCollectionEquality().hash(lastMessageCorrectionSid)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
@@ -556,7 +601,9 @@ abstract class _StanzaHandlerData implements StanzaHandlerData {
|
|||||||
final bool encrypted,
|
final bool encrypted,
|
||||||
final ExplicitEncryptionType? encryptionType,
|
final ExplicitEncryptionType? encryptionType,
|
||||||
final DelayedDelivery? delayedDelivery,
|
final DelayedDelivery? delayedDelivery,
|
||||||
final Map<String, dynamic> other}) = _$_StanzaHandlerData;
|
final Map<String, dynamic> other,
|
||||||
|
final MessageRetractionData? messageRetraction,
|
||||||
|
final String? lastMessageCorrectionSid}) = _$_StanzaHandlerData;
|
||||||
|
|
||||||
@override // Indicates to the runner that processing is now done. This means that all
|
@override // Indicates to the runner that processing is now done. This means that all
|
||||||
// pre-processing is done and no other handlers should be consulted.
|
// pre-processing is done and no other handlers should be consulted.
|
||||||
@@ -606,6 +653,11 @@ abstract class _StanzaHandlerData implements StanzaHandlerData {
|
|||||||
@override // This is for stanza handlers that are not part of the XMPP library but still need
|
@override // This is for stanza handlers that are not part of the XMPP library but still need
|
||||||
// pass data around.
|
// pass data around.
|
||||||
Map<String, dynamic> get other;
|
Map<String, dynamic> get other;
|
||||||
|
@override // If non-null, then it indicates the origin Id of the message that should be
|
||||||
|
// retracted
|
||||||
|
MessageRetractionData? get messageRetraction;
|
||||||
|
@override // If non-null, then the message is a correction for the specified stanza Id
|
||||||
|
String? get lastMessageCorrectionSid;
|
||||||
@override
|
@override
|
||||||
@JsonKey(ignore: true)
|
@JsonKey(ignore: true)
|
||||||
_$$_StanzaHandlerDataCopyWith<_$_StanzaHandlerData> get copyWith =>
|
_$$_StanzaHandlerDataCopyWith<_$_StanzaHandlerData> get copyWith =>
|
||||||
|
|||||||
@@ -24,3 +24,5 @@ const omemoManager = 'org.moxxmpp.omemomanager';
|
|||||||
const emeManager = 'org.moxxmpp.ememanager';
|
const emeManager = 'org.moxxmpp.ememanager';
|
||||||
const cryptographicHashManager = 'org.moxxmpp.cryptographichashmanager';
|
const cryptographicHashManager = 'org.moxxmpp.cryptographichashmanager';
|
||||||
const delayedDeliveryManager = 'org.moxxmpp.delayeddeliverymanager';
|
const delayedDeliveryManager = 'org.moxxmpp.delayeddeliverymanager';
|
||||||
|
const messageRetractionManager = 'org.moxxmpp.messageretractionmanager';
|
||||||
|
const lastMessageCorrectionManager = 'org.moxxmpp.lastmessagecorrectionmanager';
|
||||||
|
|||||||
@@ -11,14 +11,15 @@ import 'package:moxxmpp/src/xeps/staging/file_upload_notification.dart';
|
|||||||
import 'package:moxxmpp/src/xeps/xep_0066.dart';
|
import 'package:moxxmpp/src/xeps/xep_0066.dart';
|
||||||
import 'package:moxxmpp/src/xeps/xep_0085.dart';
|
import 'package:moxxmpp/src/xeps/xep_0085.dart';
|
||||||
import 'package:moxxmpp/src/xeps/xep_0184.dart';
|
import 'package:moxxmpp/src/xeps/xep_0184.dart';
|
||||||
|
import 'package:moxxmpp/src/xeps/xep_0308.dart';
|
||||||
import 'package:moxxmpp/src/xeps/xep_0333.dart';
|
import 'package:moxxmpp/src/xeps/xep_0333.dart';
|
||||||
import 'package:moxxmpp/src/xeps/xep_0359.dart';
|
import 'package:moxxmpp/src/xeps/xep_0359.dart';
|
||||||
|
import 'package:moxxmpp/src/xeps/xep_0424.dart';
|
||||||
import 'package:moxxmpp/src/xeps/xep_0446.dart';
|
import 'package:moxxmpp/src/xeps/xep_0446.dart';
|
||||||
import 'package:moxxmpp/src/xeps/xep_0447.dart';
|
import 'package:moxxmpp/src/xeps/xep_0447.dart';
|
||||||
import 'package:moxxmpp/src/xeps/xep_0448.dart';
|
import 'package:moxxmpp/src/xeps/xep_0448.dart';
|
||||||
|
|
||||||
class MessageDetails {
|
class MessageDetails {
|
||||||
|
|
||||||
const MessageDetails({
|
const MessageDetails({
|
||||||
required this.to,
|
required this.to,
|
||||||
this.body,
|
this.body,
|
||||||
@@ -35,6 +36,8 @@ class MessageDetails {
|
|||||||
this.funReplacement,
|
this.funReplacement,
|
||||||
this.funCancellation,
|
this.funCancellation,
|
||||||
this.shouldEncrypt = false,
|
this.shouldEncrypt = false,
|
||||||
|
this.messageRetraction,
|
||||||
|
this.lastMessageCorrectionId,
|
||||||
});
|
});
|
||||||
final String to;
|
final String to;
|
||||||
final String? body;
|
final String? body;
|
||||||
@@ -51,6 +54,8 @@ class MessageDetails {
|
|||||||
final String? funReplacement;
|
final String? funReplacement;
|
||||||
final String? funCancellation;
|
final String? funCancellation;
|
||||||
final bool shouldEncrypt;
|
final bool shouldEncrypt;
|
||||||
|
final MessageRetractionData? messageRetraction;
|
||||||
|
final String? lastMessageCorrectionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
class MessageManager extends XmppManagerBase {
|
class MessageManager extends XmppManagerBase {
|
||||||
@@ -95,7 +100,10 @@ class MessageManager extends XmppManagerBase {
|
|||||||
funReplacement: state.funReplacement,
|
funReplacement: state.funReplacement,
|
||||||
funCancellation: state.funCancellation,
|
funCancellation: state.funCancellation,
|
||||||
encrypted: state.encrypted,
|
encrypted: state.encrypted,
|
||||||
|
messageRetraction: state.messageRetraction,
|
||||||
|
messageCorrectionId: state.lastMessageCorrectionSid,
|
||||||
other: state.other,
|
other: state.other,
|
||||||
|
error: StanzaError.fromStanza(message),
|
||||||
),);
|
),);
|
||||||
|
|
||||||
return state.copyWith(done: true);
|
return state.copyWith(done: true);
|
||||||
@@ -159,6 +167,8 @@ class MessageManager extends XmppManagerBase {
|
|||||||
} else if (firstSource is StatelessFileSharingEncryptedSource) {
|
} else if (firstSource is StatelessFileSharingEncryptedSource) {
|
||||||
body = firstSource.source.url;
|
body = firstSource.source.url;
|
||||||
}
|
}
|
||||||
|
} else if (details.messageRetraction?.fallback != null) {
|
||||||
|
body = details.messageRetraction!.fallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
stanza.addChild(
|
stanza.addChild(
|
||||||
@@ -217,6 +227,41 @@ class MessageManager extends XmppManagerBase {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (details.messageRetraction != null) {
|
||||||
|
stanza.addChild(
|
||||||
|
XMLNode.xmlns(
|
||||||
|
tag: 'apply-to',
|
||||||
|
xmlns: fasteningXmlns,
|
||||||
|
attributes: <String, String>{
|
||||||
|
'id': details.messageRetraction!.id,
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
XMLNode.xmlns(
|
||||||
|
tag: 'retract',
|
||||||
|
xmlns: messageRetractionXmlns,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (details.messageRetraction!.fallback != null) {
|
||||||
|
stanza.addChild(
|
||||||
|
XMLNode.xmlns(
|
||||||
|
tag: 'fallback',
|
||||||
|
xmlns: fallbackIndicationXmlns,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (details.lastMessageCorrectionId != null) {
|
||||||
|
stanza.addChild(
|
||||||
|
makeLastMessageCorrectionEdit(
|
||||||
|
details.lastMessageCorrectionId!,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
getAttributes().sendStanza(stanza, awaitable: false);
|
getAttributes().sendStanza(stanza, awaitable: false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,6 +76,9 @@ const hashSha3512 = 'sha3-512';
|
|||||||
const hashBlake2b256 = 'blake2b-256';
|
const hashBlake2b256 = 'blake2b-256';
|
||||||
const hashBlake2b512 = 'blake2b-512';
|
const hashBlake2b512 = 'blake2b-512';
|
||||||
|
|
||||||
|
// XEP-0308
|
||||||
|
const lmcXmlns = 'urn:xmpp:message-correct:0';
|
||||||
|
|
||||||
// XEP-0333
|
// XEP-0333
|
||||||
const chatMarkersXmlns = 'urn:xmpp:chat-markers:0';
|
const chatMarkersXmlns = 'urn:xmpp:chat-markers:0';
|
||||||
|
|
||||||
@@ -114,6 +117,15 @@ const simsXmlns = 'urn:xmpp:sims:1';
|
|||||||
// XEP-0420
|
// XEP-0420
|
||||||
const sceXmlns = 'urn:xmpp:sce:1';
|
const sceXmlns = 'urn:xmpp:sce:1';
|
||||||
|
|
||||||
|
// XEP-0422
|
||||||
|
const fasteningXmlns = 'urn:xmpp:fasten:0';
|
||||||
|
|
||||||
|
// XEP-0424
|
||||||
|
const messageRetractionXmlns = 'urn:xmpp:message-retract:0';
|
||||||
|
|
||||||
|
// XEp-0428
|
||||||
|
const fallbackIndicationXmlns = 'urn:xmpp:fallback:0';
|
||||||
|
|
||||||
// XEP-0446
|
// XEP-0446
|
||||||
const fileMetadataXmlns = 'urn:xmpp:file:metadata:0';
|
const fileMetadataXmlns = 'urn:xmpp:file:metadata:0';
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,28 @@
|
|||||||
import 'package:moxxmpp/src/namespaces.dart';
|
import 'package:moxxmpp/src/namespaces.dart';
|
||||||
import 'package:moxxmpp/src/stringxml.dart';
|
import 'package:moxxmpp/src/stringxml.dart';
|
||||||
|
|
||||||
|
/// A simple description of the <error /> element that may be inside a stanza
|
||||||
|
class StanzaError {
|
||||||
|
StanzaError(this.type, this.error);
|
||||||
|
String type;
|
||||||
|
String error;
|
||||||
|
|
||||||
|
/// Returns a StanzaError if [stanza] contains a <error /> element. If not, returns
|
||||||
|
/// null.
|
||||||
|
static StanzaError? fromStanza(Stanza stanza) {
|
||||||
|
final error = stanza.firstTag('error');
|
||||||
|
if (error == null) return null;
|
||||||
|
|
||||||
|
final stanzaError = error.firstTagByXmlns(fullStanzaXmlns);
|
||||||
|
if (stanzaError == null) return null;
|
||||||
|
|
||||||
|
return StanzaError(
|
||||||
|
error.attributes['type']! as String,
|
||||||
|
stanzaError.tag,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class Stanza extends XMLNode {
|
class Stanza extends XMLNode {
|
||||||
// ignore: use_super_parameters
|
// ignore: use_super_parameters
|
||||||
Stanza({ this.to, this.from, this.type, this.id, List<XMLNode> children = const [], required String tag, Map<String, String> attributes = const {} }) : super(
|
Stanza({ this.to, this.from, this.type, this.id, List<XMLNode> children = const [], required String tag, Map<String, String> attributes = const {} }) : super(
|
||||||
|
|||||||
52
packages/moxxmpp/lib/src/xeps/xep_0308.dart
Normal file
52
packages/moxxmpp/lib/src/xeps/xep_0308.dart
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
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/namespaces.dart';
|
||||||
|
import 'package:moxxmpp/src/stanza.dart';
|
||||||
|
import 'package:moxxmpp/src/stringxml.dart';
|
||||||
|
|
||||||
|
XMLNode makeLastMessageCorrectionEdit(String id) {
|
||||||
|
return XMLNode.xmlns(
|
||||||
|
tag: 'replace',
|
||||||
|
xmlns: lmcXmlns,
|
||||||
|
attributes: <String, String>{
|
||||||
|
'id': id,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
class LastMessageCorrectionManager extends XmppManagerBase {
|
||||||
|
@override
|
||||||
|
String getName() => 'LastMessageCorrectionManager';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String getId() => lastMessageCorrectionManager;
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<String> getDiscoFeatures() => [ lmcXmlns ];
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<StanzaHandler> getIncomingStanzaHandlers() => [
|
||||||
|
StanzaHandler(
|
||||||
|
stanzaTag: 'message',
|
||||||
|
tagName: 'reply',
|
||||||
|
tagXmlns: replyXmlns,
|
||||||
|
callback: _onMessage,
|
||||||
|
// Before the message handler
|
||||||
|
priority: -99,
|
||||||
|
)
|
||||||
|
];
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<bool> isSupported() async => true;
|
||||||
|
|
||||||
|
Future<StanzaHandlerData> _onMessage(Stanza stanza, StanzaHandlerData state) async {
|
||||||
|
final edit = stanza.firstTag('replace', xmlns: lmcXmlns);
|
||||||
|
if (edit == null) return state;
|
||||||
|
|
||||||
|
return state.copyWith(
|
||||||
|
lastMessageCorrectionSid: edit.attributes['id']! as String,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -58,8 +58,16 @@ class StableIdManager extends XmppManagerBase {
|
|||||||
String? stanzaIdBy;
|
String? stanzaIdBy;
|
||||||
final originIdTag = message.firstTag('origin-id', xmlns: stableIdXmlns);
|
final originIdTag = message.firstTag('origin-id', xmlns: stableIdXmlns);
|
||||||
final stanzaIdTag = message.firstTag('stanza-id', xmlns: stableIdXmlns);
|
final stanzaIdTag = message.firstTag('stanza-id', xmlns: stableIdXmlns);
|
||||||
if (originIdTag != null || stanzaIdTag != null) {
|
|
||||||
logger.finest('Found Unique and Stable Stanza Id tag');
|
// Process the origin id
|
||||||
|
if (originIdTag != null) {
|
||||||
|
logger.finest('Found origin Id tag');
|
||||||
|
originId = originIdTag.attributes['id']! as String;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process the stanza id tag
|
||||||
|
if (stanzaIdTag != null) {
|
||||||
|
logger.finest('Found stanza Id tag');
|
||||||
final attrs = getAttributes();
|
final attrs = getAttributes();
|
||||||
final disco = attrs.getManagerById<DiscoManager>(discoManager)!;
|
final disco = attrs.getManagerById<DiscoManager>(discoManager)!;
|
||||||
final result = await disco.discoInfoQuery(from.toString());
|
final result = await disco.discoInfoQuery(from.toString());
|
||||||
@@ -68,17 +76,10 @@ class StableIdManager extends XmppManagerBase {
|
|||||||
logger.finest('Got info for ${from.toString()}');
|
logger.finest('Got info for ${from.toString()}');
|
||||||
if (info.features.contains(stableIdXmlns)) {
|
if (info.features.contains(stableIdXmlns)) {
|
||||||
logger.finest('${from.toString()} supports $stableIdXmlns.');
|
logger.finest('${from.toString()} supports $stableIdXmlns.');
|
||||||
|
stanzaId = stanzaIdTag.attributes['id']! as String;
|
||||||
if (originIdTag != null) {
|
stanzaIdBy = stanzaIdTag.attributes['by']! as String;
|
||||||
originId = originIdTag.attributes['id']! as String;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stanzaIdTag != null) {
|
|
||||||
stanzaId = stanzaIdTag.attributes['id']! as String;
|
|
||||||
stanzaIdBy = stanzaIdTag.attributes['by']! as String;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
logger.finest('${from.toString()} does not support $stableIdXmlns. Ignoring... ');
|
logger.finest('${from.toString()} does not support $stableIdXmlns. Ignoring stanza id... ');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.finest('Failed to find out if ${from.toString()} supports $stableIdXmlns. Ignoring... ');
|
logger.finest('Failed to find out if ${from.toString()} supports $stableIdXmlns. Ignoring... ');
|
||||||
|
|||||||
59
packages/moxxmpp/lib/src/xeps/xep_0424.dart
Normal file
59
packages/moxxmpp/lib/src/xeps/xep_0424.dart
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
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/namespaces.dart';
|
||||||
|
import 'package:moxxmpp/src/stanza.dart';
|
||||||
|
|
||||||
|
class MessageRetractionData {
|
||||||
|
MessageRetractionData(this.id, this.fallback);
|
||||||
|
final String? fallback;
|
||||||
|
final String id;
|
||||||
|
}
|
||||||
|
|
||||||
|
class MessageRetractionManager extends XmppManagerBase {
|
||||||
|
@override
|
||||||
|
String getName() => 'MessageRetractionManager';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String getId() => messageRetractionManager;
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<String> getDiscoFeatures() => [ messageRetractionXmlns ];
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<StanzaHandler> getIncomingStanzaHandlers() => [
|
||||||
|
StanzaHandler(
|
||||||
|
stanzaTag: 'message',
|
||||||
|
callback: _onMessage,
|
||||||
|
// Before the MessageManager
|
||||||
|
priority: -99,
|
||||||
|
)
|
||||||
|
];
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<bool> isSupported() async => true;
|
||||||
|
|
||||||
|
Future<StanzaHandlerData> _onMessage(Stanza message, StanzaHandlerData state) async {
|
||||||
|
final applyTo = message.firstTag('apply-to', xmlns: fasteningXmlns);
|
||||||
|
if (applyTo == null) {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
final retract = applyTo.firstTag('retract', xmlns: messageRetractionXmlns);
|
||||||
|
if (retract == null) {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
final isFallbackBody = message.firstTag('fallback', xmlns: fallbackIndicationXmlns) != null;
|
||||||
|
|
||||||
|
return state.copyWith(
|
||||||
|
messageRetraction: MessageRetractionData(
|
||||||
|
applyTo.attributes['id']! as String,
|
||||||
|
isFallbackBody ?
|
||||||
|
message.firstTag('body')?.innerText() :
|
||||||
|
null,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
name: moxxmpp
|
name: moxxmpp
|
||||||
description: A pure-Dart XMPP library
|
description: A pure-Dart XMPP library
|
||||||
version: 0.1.3
|
version: 0.1.6
|
||||||
homepage: https://codeberg.org/moxxy/moxxmpp
|
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
|
||||||
|
|
||||||
@@ -31,6 +31,6 @@ dev_dependencies:
|
|||||||
build_runner: ^2.1.11
|
build_runner: ^2.1.11
|
||||||
moxxmpp_socket_tcp:
|
moxxmpp_socket_tcp:
|
||||||
hosted: https://git.polynom.me/api/packages/Moxxy/pub
|
hosted: https://git.polynom.me/api/packages/Moxxy/pub
|
||||||
version: ^0.1.2+4
|
version: ^0.1.2+8
|
||||||
test: ^1.16.0
|
test: ^1.16.0
|
||||||
very_good_analysis: ^3.0.1
|
very_good_analysis: ^3.0.1
|
||||||
|
|||||||
@@ -1,3 +1,19 @@
|
|||||||
|
## 0.1.2+8
|
||||||
|
|
||||||
|
- Update a dependency to the latest release.
|
||||||
|
|
||||||
|
## 0.1.2+7
|
||||||
|
|
||||||
|
- Update a dependency to the latest release.
|
||||||
|
|
||||||
|
## 0.1.2+6
|
||||||
|
|
||||||
|
- Update a dependency to the latest release.
|
||||||
|
|
||||||
|
## 0.1.2+5
|
||||||
|
|
||||||
|
- Update a dependency to the latest release.
|
||||||
|
|
||||||
## 0.1.2+4
|
## 0.1.2+4
|
||||||
|
|
||||||
- Update a dependency to the latest release.
|
- Update a dependency to the latest release.
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name: moxxmpp_socket_tcp
|
name: moxxmpp_socket_tcp
|
||||||
description: A socket for moxxmpp using TCP that implements the RFC6120 connection algorithm and XEP-0368
|
description: A socket for moxxmpp using TCP that implements the RFC6120 connection algorithm and XEP-0368
|
||||||
version: 0.1.2+4
|
version: 0.1.2+8
|
||||||
homepage: https://codeberg.org/moxxy/moxxmpp
|
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
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ dependencies:
|
|||||||
meta: ^1.6.0
|
meta: ^1.6.0
|
||||||
moxxmpp:
|
moxxmpp:
|
||||||
hosted: https://git.polynom.me/api/packages/Moxxy/pub
|
hosted: https://git.polynom.me/api/packages/Moxxy/pub
|
||||||
version: ^0.1.3
|
version: ^0.1.6
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
lints: ^2.0.0
|
lints: ^2.0.0
|
||||||
|
|||||||
Reference in New Issue
Block a user